drizzle-cube 0.5.0 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/adapters/express/index.cjs +2 -2
- package/dist/adapters/express/index.js +106 -102
- package/dist/adapters/fastify/index.cjs +2 -2
- package/dist/adapters/fastify/index.js +109 -105
- package/dist/adapters/{handler-3LGcjLtr.js → handler-BC3nFNxV.js} +2 -2
- package/dist/adapters/{handler-BzzbVpcl.cjs → handler-Cqf-CqAS.cjs} +2 -2
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +41 -45
- package/dist/adapters/locale-BoiA6WiV.cjs +198 -0
- package/dist/adapters/{locale-DTnJrxm1.js → locale-D9VQkLXt.js} +442 -404
- package/dist/adapters/mcp-tools.cjs +1 -1
- package/dist/adapters/mcp-tools.d.ts +7 -3
- package/dist/adapters/mcp-tools.js +28 -28
- package/dist/adapters/mcp-transport-B0mgxRnJ.js +579 -0
- package/dist/adapters/mcp-transport-irsahKmD.cjs +39 -0
- package/dist/adapters/mcp-transport.d.ts +14 -2
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +140 -136
- package/dist/adapters/{openai-C4BD8xnN.cjs → openai-B4N3KfTG.cjs} +1 -1
- package/dist/adapters/{openai-CaSQEduB.js → openai-BWdm0JvG.js} +1 -1
- package/dist/adapters/openai-CoqT_FM5.cjs +16 -0
- package/dist/{server/openai-CqZg6zYL.js → adapters/openai-D0Nsvc9L.js} +824 -720
- package/dist/adapters/{utils-DOg9oGdt.js → utils-CTYvfZ3I.js} +711 -713
- package/dist/adapters/{utils-DNrj-ryp.cjs → utils-XPOzzMdY.cjs} +5 -5
- package/dist/adapters/utils.cjs +1 -1
- package/dist/adapters/utils.d.ts +38 -2
- package/dist/adapters/utils.js +1 -1
- package/dist/cli/index.cjs +2 -2
- package/dist/client/charts.js +10 -10
- package/dist/client/chunks/{DashboardEditModal-cSSIAZGy.js → DashboardEditModal-IU_0dgfC.js} +12 -12
- package/dist/client/chunks/{DashboardEditModal-cSSIAZGy.js.map → DashboardEditModal-IU_0dgfC.js.map} +1 -1
- package/dist/client/chunks/{FieldSearchModal-CZNo4pNK.js → FieldSearchModal-BCWanpPX.js} +3 -3
- package/dist/client/chunks/{FieldSearchModal-CZNo4pNK.js.map → FieldSearchModal-BCWanpPX.js.map} +1 -1
- package/dist/client/chunks/KpiDelta-_igN6cJa.js +2 -0
- package/dist/client/chunks/KpiNumber-t5n8PtRU.js +2 -0
- package/dist/client/chunks/KpiText-BCZJJ6a0.js +2 -0
- package/dist/client/chunks/{RetentionCombinedChart-BD8tGeM_.js → RetentionCombinedChart-CQMBODsK.js} +2 -2
- package/dist/client/chunks/{RetentionCombinedChart-BD8tGeM_.js.map → RetentionCombinedChart-CQMBODsK.js.map} +1 -1
- package/dist/client/chunks/SchemaVisualization-BUUhlOvG.js +2 -0
- package/dist/client/chunks/SchemaVisualizationLazy-CwaPCUL0.js +2 -0
- package/dist/client/chunks/{analysis-builder-BeVZhiQ5.js → analysis-builder-Dm6eD_AX.js} +6 -6
- package/dist/client/chunks/{analysis-builder-BeVZhiQ5.js.map → analysis-builder-Dm6eD_AX.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-shared-BWc7ZZnG.js → analysis-builder-shared-DT5bXwCA.js} +6 -6
- package/dist/client/chunks/{analysis-builder-shared-BWc7ZZnG.js.map → analysis-builder-shared-DT5bXwCA.js.map} +1 -1
- package/dist/client/chunks/{chart-area-D63kG8OT.js → chart-area-DDti9Qtp.js} +2 -2
- package/dist/client/chunks/{chart-area-D63kG8OT.js.map → chart-area-DDti9Qtp.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-BEfsCLjl.js → chart-bar-B3s9qDlh.js} +2 -2
- package/dist/client/chunks/{chart-bar-BEfsCLjl.js.map → chart-bar-B3s9qDlh.js.map} +1 -1
- package/dist/client/chunks/{chart-data-table-C3Xh9jwL.js → chart-data-table-Qrt6EAno.js} +17 -17
- package/dist/client/chunks/{chart-data-table-C3Xh9jwL.js.map → chart-data-table-Qrt6EAno.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-CYE0S1x_.js → chart-kpi-delta-CgldZ7zO.js} +3 -3
- package/dist/client/chunks/{chart-kpi-delta-CYE0S1x_.js.map → chart-kpi-delta-CgldZ7zO.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-BlZ79xHW.js → chart-kpi-number-ByfuX1ki.js} +5 -5
- package/dist/client/chunks/{chart-kpi-number-BlZ79xHW.js.map → chart-kpi-number-ByfuX1ki.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text-DY1BnxPe.js → chart-kpi-text-DeNuDraJ.js} +2 -2
- package/dist/client/chunks/{chart-kpi-text-DY1BnxPe.js.map → chart-kpi-text-DeNuDraJ.js.map} +1 -1
- package/dist/client/chunks/{chart-line-CBsTThTv.js → chart-line-RdZwtk27.js} +2 -2
- package/dist/client/chunks/{chart-line-CBsTThTv.js.map → chart-line-RdZwtk27.js.map} +1 -1
- package/dist/client/chunks/{chart-markdown-BWaWVkuz.js → chart-markdown-CiGRZdJj.js} +1203 -1139
- package/dist/client/chunks/chart-markdown-CiGRZdJj.js.map +1 -0
- package/dist/client/chunks/{chart-measure-profile-B41qCTBG.js → chart-measure-profile-Ckjw9bX6.js} +2 -2
- package/dist/client/chunks/{chart-measure-profile-B41qCTBG.js.map → chart-measure-profile-Ckjw9bX6.js.map} +1 -1
- package/dist/client/chunks/{chart-pie-Djbu8x2v.js → chart-pie-BvY4FY__.js} +2 -2
- package/dist/client/chunks/{chart-pie-Djbu8x2v.js.map → chart-pie-BvY4FY__.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-BsTcKV0K.js → chart-radar-DjiiEAmc.js} +2 -2
- package/dist/client/chunks/{chart-radar-BsTcKV0K.js.map → chart-radar-DjiiEAmc.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-Du7XNnwE.js → chart-radial-bar-lla_JEYu.js} +2 -2
- package/dist/client/chunks/{chart-radial-bar-Du7XNnwE.js.map → chart-radial-bar-lla_JEYu.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-D8krEYsA.js → chart-scatter-DwXnI0rr.js} +2 -2
- package/dist/client/chunks/{chart-scatter-D8krEYsA.js.map → chart-scatter-DwXnI0rr.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-C5C2iaWM.js → chart-tree-map-DJHoA26f.js} +2 -2
- package/dist/client/chunks/{chart-tree-map-C5C2iaWM.js.map → chart-tree-map-DJHoA26f.js.map} +1 -1
- package/dist/client/chunks/{chart-waterfall-BGdPrJ5Y.js → chart-waterfall-Y7c8csO5.js} +2 -2
- package/dist/client/chunks/{chart-waterfall-BGdPrJ5Y.js.map → chart-waterfall-Y7c8csO5.js.map} +1 -1
- package/dist/client/chunks/{core-DcfMGTVa.js → core-Dk6z6kC0.js} +2 -2
- package/dist/client/chunks/{core-DcfMGTVa.js.map → core-Dk6z6kC0.js.map} +1 -1
- package/dist/client/chunks/{exceljs.min-CcjgM-qg.js → exceljs.min-DaJsLlWM.js} +24 -24
- package/dist/client/chunks/{exceljs.min-CcjgM-qg.js.map → exceljs.min-DaJsLlWM.js.map} +1 -1
- package/dist/client/chunks/{schema-visualization-Xp60Ff2W.js → schema-visualization-DWwJukK7.js} +8 -8
- package/dist/client/chunks/{schema-visualization-Xp60Ff2W.js.map → schema-visualization-DWwJukK7.js.map} +1 -1
- package/dist/client/chunks/{syntaxHighlighting-CnDujqwg.js → syntaxHighlighting-D8J6Yt9j.js} +2 -2
- package/dist/client/chunks/{syntaxHighlighting-CnDujqwg.js.map → syntaxHighlighting-D8J6Yt9j.js.map} +1 -1
- package/dist/client/chunks/{useDebounce-CfmUMFau.js → useDebounce-DyJVREop.js} +2 -2
- package/dist/client/chunks/{useDebounce-CfmUMFau.js.map → useDebounce-DyJVREop.js.map} +1 -1
- package/dist/client/chunks/{useExplainAI-BKGmejIj.js → useExplainAI-CxSkjocM.js} +4 -4
- package/dist/client/chunks/{useExplainAI-BKGmejIj.js.map → useExplainAI-CxSkjocM.js.map} +1 -1
- package/dist/client/chunks/{utils-BldkcRHv.js → utils-BHZdKxua.js} +2 -2
- package/dist/client/chunks/{utils-BldkcRHv.js.map → utils-BHZdKxua.js.map} +1 -1
- package/dist/client/chunks/{vendor-ClXpIiea.js → vendor-CBD_Olr0.js} +8 -8
- package/dist/client/chunks/{vendor-ClXpIiea.js.map → vendor-CBD_Olr0.js.map} +1 -1
- package/dist/client/components.js +3 -3
- package/dist/client/hooks.js +3 -3
- package/dist/client/icons.js +1 -1
- package/dist/client/index.js +11 -11
- package/dist/client/providers.js +1 -1
- package/dist/client/schema.js +1 -1
- package/dist/client/utils.js +5 -5
- package/dist/client-bundle-stats.html +1 -1
- package/dist/mcp-app/mcp-app.html +39 -37
- package/dist/server/index.cjs +42 -42
- package/dist/server/index.js +1009 -971
- package/dist/server/{openai-D9Zjuby1.cjs → openai-BfiZU0rG.cjs} +1 -1
- package/dist/server/openai-BwsBio1K.cjs +16 -0
- package/dist/server/{openai-rwauPzCT.js → openai-CLWSwD-D.js} +1 -1
- package/dist/{adapters/openai-BAnEZgKZ.js → server/openai-zpXlGbbF.js} +824 -720
- package/package.json +2 -2
- package/dist/adapters/locale-DueXjqMh.cjs +0 -198
- package/dist/adapters/mcp-transport-45SiFcCH.cjs +0 -39
- package/dist/adapters/mcp-transport-Bxpc4mRy.js +0 -553
- package/dist/adapters/openai-4JP2B6pB.cjs +0 -16
- package/dist/client/chunks/KpiDelta-Dll_eCV1.js +0 -2
- package/dist/client/chunks/KpiNumber-BPlR92hI.js +0 -2
- package/dist/client/chunks/KpiText-BIxq7Jso.js +0 -2
- package/dist/client/chunks/SchemaVisualization-CCICjhvv.js +0 -2
- package/dist/client/chunks/SchemaVisualizationLazy-DraGsMx6.js +0 -2
- package/dist/client/chunks/chart-markdown-BWaWVkuz.js.map +0 -1
- package/dist/server/openai-DmuEbFd6.cjs +0 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as e, s as t } from "./utils-
|
|
1
|
+
import { _ as e, s as t } from "./utils-CTYvfZ3I.js";
|
|
2
2
|
//#region node_modules/drizzle-orm/entity.js
|
|
3
3
|
var n = Symbol.for("drizzle:entityKind");
|
|
4
4
|
function r(e, t) {
|
|
@@ -397,7 +397,7 @@ function P(...e) {
|
|
|
397
397
|
new S(")")
|
|
398
398
|
]);
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function ne(...e) {
|
|
401
401
|
let t = e.filter((e) => e !== void 0);
|
|
402
402
|
if (t.length !== 0) return t.length === 1 ? new C(t) : new C([
|
|
403
403
|
new S("("),
|
|
@@ -405,34 +405,34 @@ function F(...e) {
|
|
|
405
405
|
new S(")")
|
|
406
406
|
]);
|
|
407
407
|
}
|
|
408
|
-
var
|
|
409
|
-
function
|
|
408
|
+
var re = (e, t) => O`${e} > ${j(t, e)}`, F = (e, t) => O`${e} >= ${j(t, e)}`, ie = (e, t) => O`${e} < ${j(t, e)}`, I = (e, t) => O`${e} <= ${j(t, e)}`;
|
|
409
|
+
function ae(e, t) {
|
|
410
410
|
return Array.isArray(t) ? t.length === 0 ? O`false` : O`${e} in ${t.map((t) => j(t, e))}` : O`${e} in ${j(t, e)}`;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function oe(e, t) {
|
|
413
413
|
return Array.isArray(t) ? t.length === 0 ? O`true` : O`${e} not in ${t.map((t) => j(t, e))}` : O`${e} not in ${j(t, e)}`;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function se(e) {
|
|
416
416
|
return O`${e} is null`;
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function ce(e) {
|
|
419
419
|
return O`${e} is not null`;
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function le(e, t) {
|
|
422
422
|
if (Array.isArray(t)) {
|
|
423
423
|
if (t.length === 0) throw Error("arrayContains requires at least one value");
|
|
424
424
|
return O`${e} @> ${O`${j(t, e)}`}`;
|
|
425
425
|
}
|
|
426
426
|
return O`${e} @> ${j(t, e)}`;
|
|
427
427
|
}
|
|
428
|
-
function
|
|
428
|
+
function ue(e, t) {
|
|
429
429
|
if (Array.isArray(t)) {
|
|
430
430
|
if (t.length === 0) throw Error("arrayContained requires at least one value");
|
|
431
431
|
return O`${e} <@ ${O`${j(t, e)}`}`;
|
|
432
432
|
}
|
|
433
433
|
return O`${e} <@ ${j(t, e)}`;
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function de(e, t) {
|
|
436
436
|
if (Array.isArray(t)) {
|
|
437
437
|
if (t.length === 0) throw Error("arrayOverlaps requires at least one value");
|
|
438
438
|
return O`${e} && ${O`${j(t, e)}`}`;
|
|
@@ -441,32 +441,32 @@ function ue(e, t) {
|
|
|
441
441
|
}
|
|
442
442
|
//#endregion
|
|
443
443
|
//#region node_modules/drizzle-orm/sql/expressions/select.js
|
|
444
|
-
function
|
|
444
|
+
function fe(e) {
|
|
445
445
|
return O`${e} asc`;
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function pe(e) {
|
|
448
448
|
return O`${e} desc`;
|
|
449
449
|
}
|
|
450
450
|
//#endregion
|
|
451
451
|
//#region node_modules/drizzle-orm/sql/functions/aggregate.js
|
|
452
|
-
function
|
|
452
|
+
function me(e) {
|
|
453
453
|
return O`count(${e || O.raw("*")})`.mapWith(Number);
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function he(e) {
|
|
456
456
|
return O`count(distinct ${e})`.mapWith(Number);
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function L(e) {
|
|
459
459
|
return O`sum(${e})`.mapWith(String);
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function R(e) {
|
|
462
462
|
return O`max(${e})`.mapWith(r(e, i) ? e : String);
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function ge(e) {
|
|
465
465
|
return O`min(${e})`.mapWith(r(e, i) ? e : String);
|
|
466
466
|
}
|
|
467
467
|
//#endregion
|
|
468
468
|
//#region src/server/adapters/base-adapter.ts
|
|
469
|
-
var
|
|
469
|
+
var z = class {
|
|
470
470
|
preprocessCalculatedTemplate(e) {
|
|
471
471
|
return e;
|
|
472
472
|
}
|
|
@@ -495,7 +495,7 @@ var V = class {
|
|
|
495
495
|
let t = this.parseISODuration(e);
|
|
496
496
|
return t.years * 365 * 24 * 60 * 60 + t.months * 30 * 24 * 60 * 60 + t.days * 24 * 60 * 60 + t.hours * 60 * 60 + t.minutes * 60 + t.seconds;
|
|
497
497
|
}
|
|
498
|
-
},
|
|
498
|
+
}, _e = class extends z {
|
|
499
499
|
getEngineType() {
|
|
500
500
|
return "postgres";
|
|
501
501
|
}
|
|
@@ -633,7 +633,7 @@ var V = class {
|
|
|
633
633
|
default: throw Error(`Unsupported window function: ${e}`);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
},
|
|
636
|
+
}, ve = class extends z {
|
|
637
637
|
getEngineType() {
|
|
638
638
|
return "mysql";
|
|
639
639
|
}
|
|
@@ -780,7 +780,7 @@ var V = class {
|
|
|
780
780
|
default: throw Error(`Unsupported window function: ${e}`);
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
|
-
},
|
|
783
|
+
}, ye = class extends z {
|
|
784
784
|
getEngineType() {
|
|
785
785
|
return "sqlite";
|
|
786
786
|
}
|
|
@@ -871,7 +871,7 @@ var V = class {
|
|
|
871
871
|
return e.length > 1e3 ? e : e.replace(/(\{[^}]+\})\s*\/\s*/g, (e, t) => `${t.replace(/\{([^}]+)\}/, "CAST({$1} AS REAL)")} / `);
|
|
872
872
|
}
|
|
873
873
|
convertFilterValue(e) {
|
|
874
|
-
return typeof e == "boolean" ? e
|
|
874
|
+
return typeof e == "boolean" ? +!!e : e instanceof Date ? e.getTime() : Array.isArray(e) ? e.map((e) => this.convertFilterValue(e)) : e;
|
|
875
875
|
}
|
|
876
876
|
prepareDateValue(e) {
|
|
877
877
|
if (!(e instanceof Date)) {
|
|
@@ -932,11 +932,11 @@ var V = class {
|
|
|
932
932
|
default: throw Error(`Unsupported window function: ${e}`);
|
|
933
933
|
}
|
|
934
934
|
}
|
|
935
|
-
},
|
|
935
|
+
}, be = class extends ve {
|
|
936
936
|
getEngineType() {
|
|
937
937
|
return "singlestore";
|
|
938
938
|
}
|
|
939
|
-
},
|
|
939
|
+
}, xe = class extends z {
|
|
940
940
|
getEngineType() {
|
|
941
941
|
return "duckdb";
|
|
942
942
|
}
|
|
@@ -1069,7 +1069,7 @@ var V = class {
|
|
|
1069
1069
|
default: throw Error(`Unsupported window function: ${e}`);
|
|
1070
1070
|
}
|
|
1071
1071
|
}
|
|
1072
|
-
},
|
|
1072
|
+
}, Se = class extends z {
|
|
1073
1073
|
getEngineType() {
|
|
1074
1074
|
return "databend";
|
|
1075
1075
|
}
|
|
@@ -1203,7 +1203,7 @@ var V = class {
|
|
|
1203
1203
|
default: throw Error(`Unsupported window function: ${e}`);
|
|
1204
1204
|
}
|
|
1205
1205
|
}
|
|
1206
|
-
},
|
|
1206
|
+
}, Ce = class extends z {
|
|
1207
1207
|
getEngineType() {
|
|
1208
1208
|
return "snowflake";
|
|
1209
1209
|
}
|
|
@@ -1339,29 +1339,29 @@ var V = class {
|
|
|
1339
1339
|
};
|
|
1340
1340
|
//#endregion
|
|
1341
1341
|
//#region src/server/database-utils.ts
|
|
1342
|
-
function
|
|
1342
|
+
function we(e) {
|
|
1343
1343
|
switch (e) {
|
|
1344
|
-
case "postgres": return new
|
|
1345
|
-
case "mysql": return new
|
|
1346
|
-
case "sqlite": return new
|
|
1347
|
-
case "singlestore": return new
|
|
1348
|
-
case "duckdb": return new
|
|
1349
|
-
case "databend": return new
|
|
1350
|
-
case "snowflake": return new
|
|
1344
|
+
case "postgres": return new _e();
|
|
1345
|
+
case "mysql": return new ve();
|
|
1346
|
+
case "sqlite": return new ye();
|
|
1347
|
+
case "singlestore": return new be();
|
|
1348
|
+
case "duckdb": return new xe();
|
|
1349
|
+
case "databend": return new Se();
|
|
1350
|
+
case "snowflake": return new Ce();
|
|
1351
1351
|
default: throw Error(`Unsupported database engine: ${e}`);
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
1354
1354
|
//#endregion
|
|
1355
1355
|
//#region src/server/executors/base-executor.ts
|
|
1356
|
-
var
|
|
1356
|
+
var B = class {
|
|
1357
1357
|
databaseAdapter;
|
|
1358
1358
|
constructor(e, t, n) {
|
|
1359
|
-
this.db = e, this.schema = t, this.databaseAdapter =
|
|
1359
|
+
this.db = e, this.schema = t, this.databaseAdapter = we(n || this.getEngineType());
|
|
1360
1360
|
}
|
|
1361
1361
|
};
|
|
1362
1362
|
//#endregion
|
|
1363
1363
|
//#region src/server/explain/postgres-parser.ts
|
|
1364
|
-
function
|
|
1364
|
+
function Te(e, t) {
|
|
1365
1365
|
let n = [], r = [], i = !1, a, o, s, c = [];
|
|
1366
1366
|
for (let t of e) {
|
|
1367
1367
|
let e = t.match(/Planning Time:\s*([\d.]+)\s*ms/i);
|
|
@@ -1374,7 +1374,7 @@ function Ce(e, t) {
|
|
|
1374
1374
|
o = parseFloat(l[1]);
|
|
1375
1375
|
continue;
|
|
1376
1376
|
}
|
|
1377
|
-
let u =
|
|
1377
|
+
let u = Ee(t);
|
|
1378
1378
|
if (u) {
|
|
1379
1379
|
u.type.includes("Seq Scan") && (i = !0), u.index && r.push(u.index), n.length === 0 && u.estimatedCost !== void 0 && (s = u.estimatedCost);
|
|
1380
1380
|
let e = t.search(/\S/);
|
|
@@ -1404,7 +1404,7 @@ function Ce(e, t) {
|
|
|
1404
1404
|
sql: t
|
|
1405
1405
|
};
|
|
1406
1406
|
}
|
|
1407
|
-
function
|
|
1407
|
+
function Ee(e) {
|
|
1408
1408
|
let t = e.replace(/^[\s->]+/, "").trim();
|
|
1409
1409
|
if (!t) return null;
|
|
1410
1410
|
let n = t.match(/^([A-Za-z][A-Za-z0-9 ]+?)(?:\s+using\s+(\S+))?(?:\s+on\s+(\S+))?(?:\s+\w+)?(?:\s+\(cost=([\d.]+)\.\.([\d.]+)\s+rows=(\d+)(?:\s+width=\d+)?\))?(?:\s+\(actual time=([\d.]+)\.\.([\d.]+)\s+rows=(\d+)\s+loops=(\d+)\))?/i);
|
|
@@ -1422,17 +1422,17 @@ function we(e) {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
//#endregion
|
|
1424
1424
|
//#region src/server/executors/postgres-executor.ts
|
|
1425
|
-
function
|
|
1425
|
+
function De(e) {
|
|
1426
1426
|
return Array.isArray(e) ? e : e && typeof e == "object" && "rows" in e && Array.isArray(e.rows) ? e.rows : [];
|
|
1427
1427
|
}
|
|
1428
|
-
var
|
|
1428
|
+
var Oe = class extends B {
|
|
1429
1429
|
async execute(e, t) {
|
|
1430
1430
|
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
1431
1431
|
let n = await e.execute();
|
|
1432
1432
|
return Array.isArray(n) ? n.map((e) => this.convertNumericFields(e, t)) : n;
|
|
1433
1433
|
}
|
|
1434
1434
|
if (!this.db.execute) throw Error("PostgreSQL database instance must have an execute method");
|
|
1435
|
-
let n = await this.db.execute(e), r =
|
|
1435
|
+
let n = await this.db.execute(e), r = De(n);
|
|
1436
1436
|
return r.length > 0 ? r.map((e) => this.convertNumericFields(e, t)) : n;
|
|
1437
1437
|
}
|
|
1438
1438
|
convertNumericFields(e, t) {
|
|
@@ -1471,11 +1471,11 @@ var Ee = class extends H {
|
|
|
1471
1471
|
let r = t[parseInt(n, 10) - 1];
|
|
1472
1472
|
return r === null ? "NULL" : typeof r == "number" ? String(r) : typeof r == "boolean" ? r ? "TRUE" : "FALSE" : r instanceof Date ? `'${r.toISOString()}'` : `'${String(r).replace(/'/g, "''")}'`;
|
|
1473
1473
|
}))}`), a = [];
|
|
1474
|
-
for (let e of
|
|
1474
|
+
for (let e of De(i)) if (e && typeof e == "object") {
|
|
1475
1475
|
let t = e["QUERY PLAN"] || e["query plan"] || e.queryplan;
|
|
1476
1476
|
typeof t == "string" && a.push(t);
|
|
1477
1477
|
}
|
|
1478
|
-
return
|
|
1478
|
+
return Te(a, {
|
|
1479
1479
|
sql: e,
|
|
1480
1480
|
params: t
|
|
1481
1481
|
});
|
|
@@ -1484,7 +1484,7 @@ var Ee = class extends H {
|
|
|
1484
1484
|
if (!e || e.length === 0) return [];
|
|
1485
1485
|
if (!this.db.execute) throw Error("PostgreSQL database instance must have an execute method");
|
|
1486
1486
|
try {
|
|
1487
|
-
let t = e.map((e) => `'${e.toLowerCase()}'`).join(","), n =
|
|
1487
|
+
let t = e.map((e) => `'${e.toLowerCase()}'`).join(","), n = De(await this.db.execute(O`
|
|
1488
1488
|
SELECT
|
|
1489
1489
|
t.relname as table_name,
|
|
1490
1490
|
i.relname as index_name,
|
|
@@ -1514,12 +1514,12 @@ var Ee = class extends H {
|
|
|
1514
1514
|
}
|
|
1515
1515
|
}
|
|
1516
1516
|
};
|
|
1517
|
-
function
|
|
1518
|
-
return new
|
|
1517
|
+
function ke(e, t) {
|
|
1518
|
+
return new Oe(e, t, "postgres");
|
|
1519
1519
|
}
|
|
1520
1520
|
//#endregion
|
|
1521
1521
|
//#region src/server/explain/mysql-parser.ts
|
|
1522
|
-
function
|
|
1522
|
+
function Ae(e, t) {
|
|
1523
1523
|
let n = t?.toLowerCase() || "";
|
|
1524
1524
|
switch (e.toLowerCase()) {
|
|
1525
1525
|
case "all": return "Seq Scan";
|
|
@@ -1533,10 +1533,10 @@ function Oe(e, t) {
|
|
|
1533
1533
|
default: return `MySQL ${e}`;
|
|
1534
1534
|
}
|
|
1535
1535
|
}
|
|
1536
|
-
function
|
|
1536
|
+
function je(e, t) {
|
|
1537
1537
|
let n = [], r = [], i = !1, a = 0;
|
|
1538
1538
|
for (let t of e) {
|
|
1539
|
-
let e =
|
|
1539
|
+
let e = Ae(t.type, t.Extra);
|
|
1540
1540
|
t.type.toLowerCase() === "all" && (i = !0), t.key && r.push(t.key);
|
|
1541
1541
|
let o = {
|
|
1542
1542
|
type: e,
|
|
@@ -1567,7 +1567,7 @@ function ke(e, t) {
|
|
|
1567
1567
|
}
|
|
1568
1568
|
//#endregion
|
|
1569
1569
|
//#region src/server/executors/mysql-executor.ts
|
|
1570
|
-
var
|
|
1570
|
+
var Me = class extends B {
|
|
1571
1571
|
async execute(e, t) {
|
|
1572
1572
|
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
1573
1573
|
let n = await e.execute();
|
|
@@ -1617,7 +1617,7 @@ var Ae = class extends H {
|
|
|
1617
1617
|
filtered: Number(e.filtered) || 100,
|
|
1618
1618
|
Extra: e.Extra || null
|
|
1619
1619
|
});
|
|
1620
|
-
return
|
|
1620
|
+
return je(s, {
|
|
1621
1621
|
sql: e,
|
|
1622
1622
|
params: t
|
|
1623
1623
|
});
|
|
@@ -1651,12 +1651,12 @@ var Ae = class extends H {
|
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
1653
|
};
|
|
1654
|
-
function
|
|
1655
|
-
return new
|
|
1654
|
+
function Ne(e, t) {
|
|
1655
|
+
return new Me(e, t, "mysql");
|
|
1656
1656
|
}
|
|
1657
1657
|
//#endregion
|
|
1658
1658
|
//#region src/server/explain/sqlite-parser.ts
|
|
1659
|
-
function
|
|
1659
|
+
function Pe(e) {
|
|
1660
1660
|
let t = e.toLowerCase(), n = e.match(/^SCAN\s+(\S+)/i);
|
|
1661
1661
|
if (n) return {
|
|
1662
1662
|
type: "Seq Scan",
|
|
@@ -1681,10 +1681,10 @@ function Me(e) {
|
|
|
1681
1681
|
table: a[1]
|
|
1682
1682
|
} : t.includes("temp b-tree") ? t.includes("order by") ? { type: "Sort" } : t.includes("group by") ? { type: "Group" } : t.includes("distinct") ? { type: "Distinct" } : { type: "Temp B-Tree" } : t.includes("compound") ? { type: "Compound Query" } : t.includes("subquery") ? { type: "Subquery" } : t.includes("co-routine") ? { type: "Coroutine" } : { type: e };
|
|
1683
1683
|
}
|
|
1684
|
-
function
|
|
1684
|
+
function Fe(e, t) {
|
|
1685
1685
|
let n = [], r = [], i = !1, a = /* @__PURE__ */ new Map();
|
|
1686
1686
|
for (let t of e) {
|
|
1687
|
-
let e =
|
|
1687
|
+
let e = Pe(t.detail);
|
|
1688
1688
|
e.type === "Seq Scan" && (i = !0), e.index && r.push(e.index);
|
|
1689
1689
|
let o = {
|
|
1690
1690
|
type: e.type,
|
|
@@ -1715,7 +1715,7 @@ function Ne(e, t) {
|
|
|
1715
1715
|
}
|
|
1716
1716
|
//#endregion
|
|
1717
1717
|
//#region src/server/executors/sqlite-executor.ts
|
|
1718
|
-
var
|
|
1718
|
+
var Ie = class extends B {
|
|
1719
1719
|
async execute(e, t) {
|
|
1720
1720
|
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
1721
1721
|
let n = await e.execute();
|
|
@@ -1764,7 +1764,7 @@ var Pe = class extends H {
|
|
|
1764
1764
|
notused: Number(e.notused) || 0,
|
|
1765
1765
|
detail: String(e.detail || "")
|
|
1766
1766
|
});
|
|
1767
|
-
return
|
|
1767
|
+
return Fe(s, {
|
|
1768
1768
|
sql: e,
|
|
1769
1769
|
params: t
|
|
1770
1770
|
});
|
|
@@ -1797,29 +1797,29 @@ var Pe = class extends H {
|
|
|
1797
1797
|
}
|
|
1798
1798
|
}
|
|
1799
1799
|
};
|
|
1800
|
-
function
|
|
1801
|
-
return new
|
|
1800
|
+
function Le(e, t) {
|
|
1801
|
+
return new Ie(e, t, "sqlite");
|
|
1802
1802
|
}
|
|
1803
1803
|
//#endregion
|
|
1804
1804
|
//#region src/server/executors/singlestore-executor.ts
|
|
1805
|
-
var
|
|
1805
|
+
var Re = class extends Me {
|
|
1806
1806
|
getEngineType() {
|
|
1807
1807
|
return "singlestore";
|
|
1808
1808
|
}
|
|
1809
1809
|
};
|
|
1810
|
-
function
|
|
1811
|
-
return new
|
|
1810
|
+
function ze(e, t) {
|
|
1811
|
+
return new Re(e, t);
|
|
1812
1812
|
}
|
|
1813
1813
|
//#endregion
|
|
1814
1814
|
//#region src/server/explain/duckdb-parser.ts
|
|
1815
|
-
function
|
|
1815
|
+
function Be(e, t) {
|
|
1816
1816
|
let n = [], r = [], i = !1, a, o = [];
|
|
1817
1817
|
for (let t of e) {
|
|
1818
1818
|
if (/^[┌├└│─┐┤┘]+$/.test(t.trim()) || /EXPLANATION|QUERY PLAN/i.test(t)) continue;
|
|
1819
|
-
let e =
|
|
1819
|
+
let e = He(t);
|
|
1820
1820
|
if (e) {
|
|
1821
1821
|
(e.type.includes("SEQ_SCAN") || e.type.includes("TABLE_SCAN")) && (i = !0), e.type.includes("INDEX_SCAN") && e.index && r.push(e.index), n.length === 0 && e.estimatedCost !== void 0 && (a = e.estimatedCost);
|
|
1822
|
-
let s =
|
|
1822
|
+
let s = Ve(t);
|
|
1823
1823
|
for (; o.length > 0 && o[o.length - 1].indent >= s;) o.pop();
|
|
1824
1824
|
if (o.length === 0) n.push(e);
|
|
1825
1825
|
else {
|
|
@@ -1846,13 +1846,13 @@ function Re(e, t) {
|
|
|
1846
1846
|
sql: t
|
|
1847
1847
|
};
|
|
1848
1848
|
}
|
|
1849
|
-
function
|
|
1849
|
+
function Ve(e) {
|
|
1850
1850
|
let t = 0;
|
|
1851
1851
|
for (let n of e) if (n === " " || n === "│" || n === "├" || n === "└" || n === "─") t++;
|
|
1852
1852
|
else break;
|
|
1853
1853
|
return t;
|
|
1854
1854
|
}
|
|
1855
|
-
function
|
|
1855
|
+
function He(e) {
|
|
1856
1856
|
let t = e.replace(/[┌├└│─┐┤┘]/g, "").replace(/^\s*/, "").trim();
|
|
1857
1857
|
if (!t || t.match(/^\(cost=([\d.]+)\s+rows=(\d+)\)$/i)) return null;
|
|
1858
1858
|
let n = t.match(/^([A-Z_]+)(?:\s+(\S+))?(?:\s+on\s+(\S+))?(?:\s+\(cost=([\d.]+)\s+rows=(\d+)\))?/i);
|
|
@@ -1878,7 +1878,7 @@ function Be(e) {
|
|
|
1878
1878
|
}
|
|
1879
1879
|
//#endregion
|
|
1880
1880
|
//#region src/server/executors/duckdb-executor.ts
|
|
1881
|
-
var
|
|
1881
|
+
var Ue = class extends B {
|
|
1882
1882
|
async execute(e, t) {
|
|
1883
1883
|
if (e && typeof e == "object" && typeof e.execute == "function") try {
|
|
1884
1884
|
let n = await e.execute();
|
|
@@ -1972,7 +1972,7 @@ var Ve = class extends H {
|
|
|
1972
1972
|
typeof t == "string" && a.push(t);
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
|
-
return
|
|
1975
|
+
return Be(a, {
|
|
1976
1976
|
sql: e,
|
|
1977
1977
|
params: t
|
|
1978
1978
|
});
|
|
@@ -2005,19 +2005,19 @@ var Ve = class extends H {
|
|
|
2005
2005
|
}
|
|
2006
2006
|
}
|
|
2007
2007
|
};
|
|
2008
|
-
function
|
|
2009
|
-
return new
|
|
2008
|
+
function We(e, t) {
|
|
2009
|
+
return new Ue(e, t, "duckdb");
|
|
2010
2010
|
}
|
|
2011
2011
|
//#endregion
|
|
2012
2012
|
//#region src/server/explain/databend-parser.ts
|
|
2013
|
-
function
|
|
2013
|
+
function Ge(e, t) {
|
|
2014
2014
|
let n = [], r = [], i = !1, a, o = [];
|
|
2015
2015
|
for (let t of e) {
|
|
2016
2016
|
if (!t.trim()) continue;
|
|
2017
|
-
let e =
|
|
2017
|
+
let e = qe(t);
|
|
2018
2018
|
if (e) {
|
|
2019
2019
|
(e.type.includes("TableScan") || e.type.includes("SCAN")) && (i = !0), e.type.includes("IndexScan") && e.index && r.push(e.index), n.length === 0 && e.estimatedCost !== void 0 && (a = e.estimatedCost);
|
|
2020
|
-
let s =
|
|
2020
|
+
let s = Ke(t);
|
|
2021
2021
|
for (; o.length > 0 && o[o.length - 1].indent >= s;) o.pop();
|
|
2022
2022
|
if (o.length === 0) n.push(e);
|
|
2023
2023
|
else {
|
|
@@ -2044,13 +2044,13 @@ function Ue(e, t) {
|
|
|
2044
2044
|
sql: t
|
|
2045
2045
|
};
|
|
2046
2046
|
}
|
|
2047
|
-
function
|
|
2047
|
+
function Ke(e) {
|
|
2048
2048
|
let t = 0;
|
|
2049
2049
|
for (let n of e) if (n === " " || n === "│" || n === "├" || n === "└" || n === "─") t++;
|
|
2050
2050
|
else break;
|
|
2051
2051
|
return t;
|
|
2052
2052
|
}
|
|
2053
|
-
function
|
|
2053
|
+
function qe(e) {
|
|
2054
2054
|
let t = e.replace(/[┌├└│─┐┤┘]/g, "").replace(/^\s*/, "").trim();
|
|
2055
2055
|
if (!t || /^(filters|table|estimated rows|output columns|push downs):/.test(t)) return null;
|
|
2056
2056
|
let n = t.match(/^([A-Z][A-Za-z_]+(?:\s+[A-Z][A-Za-z_]+)*)(?:\s+(\S+))?/);
|
|
@@ -2064,7 +2064,7 @@ function Ge(e) {
|
|
|
2064
2064
|
}
|
|
2065
2065
|
//#endregion
|
|
2066
2066
|
//#region src/server/executors/databend-executor.ts
|
|
2067
|
-
var
|
|
2067
|
+
var Je = class extends B {
|
|
2068
2068
|
async execute(e, t) {
|
|
2069
2069
|
if (e && typeof e == "object" && typeof e.execute == "function") try {
|
|
2070
2070
|
let n = await e.execute();
|
|
@@ -2158,7 +2158,7 @@ var Ke = class extends H {
|
|
|
2158
2158
|
typeof t == "string" && a.push(t);
|
|
2159
2159
|
}
|
|
2160
2160
|
}
|
|
2161
|
-
return
|
|
2161
|
+
return Ge(a, {
|
|
2162
2162
|
sql: e,
|
|
2163
2163
|
params: t
|
|
2164
2164
|
});
|
|
@@ -2167,19 +2167,19 @@ var Ke = class extends H {
|
|
|
2167
2167
|
return !e || e.length, [];
|
|
2168
2168
|
}
|
|
2169
2169
|
};
|
|
2170
|
-
function
|
|
2171
|
-
return new
|
|
2170
|
+
function Ye(e, t) {
|
|
2171
|
+
return new Je(e, t, "databend");
|
|
2172
2172
|
}
|
|
2173
2173
|
//#endregion
|
|
2174
2174
|
//#region src/server/explain/snowflake-parser.ts
|
|
2175
|
-
function
|
|
2175
|
+
function Xe(e, t) {
|
|
2176
2176
|
let n = [], r = [], i = !1, a, o = [];
|
|
2177
2177
|
for (let t of e) {
|
|
2178
2178
|
if (!t.trim()) continue;
|
|
2179
|
-
let e =
|
|
2179
|
+
let e = Qe(t);
|
|
2180
2180
|
if (e) {
|
|
2181
2181
|
(e.type.includes("TableScan") || e.type.includes("SCAN")) && (i = !0), n.length === 0 && e.estimatedCost !== void 0 && (a = e.estimatedCost);
|
|
2182
|
-
let r =
|
|
2182
|
+
let r = Ze(t);
|
|
2183
2183
|
for (; o.length > 0 && o[o.length - 1].indent >= r;) o.pop();
|
|
2184
2184
|
if (o.length === 0) n.push(e);
|
|
2185
2185
|
else {
|
|
@@ -2206,13 +2206,13 @@ function Je(e, t) {
|
|
|
2206
2206
|
sql: t
|
|
2207
2207
|
};
|
|
2208
2208
|
}
|
|
2209
|
-
function
|
|
2209
|
+
function Ze(e) {
|
|
2210
2210
|
let t = 0;
|
|
2211
2211
|
for (let n of e) if (n === " " || n === "-" || n === ">") t++;
|
|
2212
2212
|
else break;
|
|
2213
2213
|
return t;
|
|
2214
2214
|
}
|
|
2215
|
-
function
|
|
2215
|
+
function Qe(e) {
|
|
2216
2216
|
let t = e.replace(/^[\s\d:]*->/, "").trim();
|
|
2217
2217
|
if (!t || /^(GlobalStats|partitions|bytes):/i.test(t) || /^\w+=\d+/.test(t)) return null;
|
|
2218
2218
|
let n = t.match(/^([A-Z][A-Za-z_]+(?:\s+[A-Z][A-Za-z_]+)*)(?:\s+(\S+))?/);
|
|
@@ -2226,7 +2226,7 @@ function Xe(e) {
|
|
|
2226
2226
|
}
|
|
2227
2227
|
//#endregion
|
|
2228
2228
|
//#region src/server/executors/snowflake-executor.ts
|
|
2229
|
-
var
|
|
2229
|
+
var $e = class extends B {
|
|
2230
2230
|
async execute(e, t) {
|
|
2231
2231
|
if (e && typeof e == "object" && typeof e.execute == "function") try {
|
|
2232
2232
|
let n = await e.execute();
|
|
@@ -2319,7 +2319,7 @@ var Ze = class extends H {
|
|
|
2319
2319
|
typeof t == "string" && i.push(t);
|
|
2320
2320
|
}
|
|
2321
2321
|
}
|
|
2322
|
-
return
|
|
2322
|
+
return Xe(i, {
|
|
2323
2323
|
sql: e,
|
|
2324
2324
|
params: t
|
|
2325
2325
|
});
|
|
@@ -2328,31 +2328,31 @@ var Ze = class extends H {
|
|
|
2328
2328
|
return [];
|
|
2329
2329
|
}
|
|
2330
2330
|
};
|
|
2331
|
-
function
|
|
2332
|
-
return new
|
|
2331
|
+
function et(e, t) {
|
|
2332
|
+
return new $e(e, t, "snowflake");
|
|
2333
2333
|
}
|
|
2334
2334
|
//#endregion
|
|
2335
2335
|
//#region src/server/executors/index.ts
|
|
2336
|
-
function
|
|
2336
|
+
function tt(e, t, n) {
|
|
2337
2337
|
if (n) switch (n) {
|
|
2338
|
-
case "postgres": return
|
|
2339
|
-
case "mysql": return
|
|
2340
|
-
case "sqlite": return
|
|
2341
|
-
case "singlestore": return
|
|
2342
|
-
case "duckdb": return
|
|
2343
|
-
case "databend": return
|
|
2344
|
-
case "snowflake": return
|
|
2345
|
-
}
|
|
2346
|
-
if (e.all && e.run) return
|
|
2347
|
-
if (e.execute) return
|
|
2338
|
+
case "postgres": return ke(e, t);
|
|
2339
|
+
case "mysql": return Ne(e, t);
|
|
2340
|
+
case "sqlite": return Le(e, t);
|
|
2341
|
+
case "singlestore": return ze(e, t);
|
|
2342
|
+
case "duckdb": return We(e, t);
|
|
2343
|
+
case "databend": return Ye(e, t);
|
|
2344
|
+
case "snowflake": return et(e, t);
|
|
2345
|
+
}
|
|
2346
|
+
if (e.all && e.run) return Le(e, t);
|
|
2347
|
+
if (e.execute) return ke(e, t);
|
|
2348
2348
|
throw Error("Unable to determine database engine type. Please specify engineType parameter.");
|
|
2349
2349
|
}
|
|
2350
2350
|
//#endregion
|
|
2351
2351
|
//#region src/server/cube-utils.ts
|
|
2352
|
-
function
|
|
2352
|
+
function V(e, t) {
|
|
2353
2353
|
return typeof e == "string" ? t ? t.get(e) || (console.warn(`[drizzle-cube] Cannot resolve cube reference '${e}': no cube with that name is registered. Registered cubes: ${Array.from(t.keys()).join(", ") || "(none)"}. Join will be skipped.`), null) : (console.warn(`[drizzle-cube] Cannot resolve string cube reference '${e}': no cube registry provided. Join will be skipped.`), null) : typeof e == "function" ? e() : e;
|
|
2354
2354
|
}
|
|
2355
|
-
function
|
|
2355
|
+
function nt(e) {
|
|
2356
2356
|
switch (e) {
|
|
2357
2357
|
case "belongsTo": return "hasMany";
|
|
2358
2358
|
case "hasMany": return "belongsTo";
|
|
@@ -2361,7 +2361,7 @@ function et(e) {
|
|
|
2361
2361
|
default: return e;
|
|
2362
2362
|
}
|
|
2363
2363
|
}
|
|
2364
|
-
function
|
|
2364
|
+
function rt(e, t) {
|
|
2365
2365
|
if (t) return t;
|
|
2366
2366
|
switch (e) {
|
|
2367
2367
|
case "belongsTo": return "inner";
|
|
@@ -2371,17 +2371,17 @@ function tt(e, t) {
|
|
|
2371
2371
|
default: return "left";
|
|
2372
2372
|
}
|
|
2373
2373
|
}
|
|
2374
|
-
function
|
|
2374
|
+
function it(e) {
|
|
2375
2375
|
return e && typeof e == "object" ? O`${O`${e}`}` : e;
|
|
2376
2376
|
}
|
|
2377
|
-
function
|
|
2377
|
+
function at(e) {
|
|
2378
2378
|
if (e === "__proto__" || e === "constructor" || e === "prototype") throw Error(`Unsafe property key: ${e}`);
|
|
2379
2379
|
return e;
|
|
2380
2380
|
}
|
|
2381
|
-
function
|
|
2382
|
-
return
|
|
2381
|
+
function H(e, t) {
|
|
2382
|
+
return it(typeof e == "function" ? e(t) : e);
|
|
2383
2383
|
}
|
|
2384
|
-
function
|
|
2384
|
+
function ot(e, t) {
|
|
2385
2385
|
if (e.relationship !== "belongsToMany" || !e.through) throw Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
|
|
2386
2386
|
let { table: n, sourceKey: r, targetKey: i, securitySql: a } = e.through, o = [];
|
|
2387
2387
|
for (let e of r) {
|
|
@@ -2398,7 +2398,7 @@ function it(e, t) {
|
|
|
2398
2398
|
let e = a(t);
|
|
2399
2399
|
c = Array.isArray(e) ? e : [e];
|
|
2400
2400
|
}
|
|
2401
|
-
let l =
|
|
2401
|
+
let l = rt("belongsToMany", e.sqlJoinType);
|
|
2402
2402
|
return {
|
|
2403
2403
|
junctionJoins: [{
|
|
2404
2404
|
joinType: l,
|
|
@@ -2414,16 +2414,16 @@ function it(e, t) {
|
|
|
2414
2414
|
}
|
|
2415
2415
|
//#endregion
|
|
2416
2416
|
//#region src/server/filter-cache.ts
|
|
2417
|
-
function
|
|
2418
|
-
if ("and" in e) return `and:[${e.and.map(
|
|
2419
|
-
if ("or" in e) return `or:[${e.or.map(
|
|
2417
|
+
function U(e) {
|
|
2418
|
+
if ("and" in e) return `and:[${e.and.map(U).sort().join(",")}]`;
|
|
2419
|
+
if ("or" in e) return `or:[${e.or.map(U).sort().join(",")}]`;
|
|
2420
2420
|
let t = e, n = JSON.stringify(Array.isArray(t.values) ? [...t.values].sort() : t.values), r = t.dateRange ? `:dr:${JSON.stringify(t.dateRange)}` : "";
|
|
2421
2421
|
return `${t.member}:${t.operator}:${n}${r}`;
|
|
2422
2422
|
}
|
|
2423
|
-
function
|
|
2423
|
+
function st(e, t) {
|
|
2424
2424
|
return `timeDim:${e}:${JSON.stringify(t)}`;
|
|
2425
2425
|
}
|
|
2426
|
-
var
|
|
2426
|
+
var W = class {
|
|
2427
2427
|
cache = /* @__PURE__ */ new Map();
|
|
2428
2428
|
stats = {
|
|
2429
2429
|
hits: 0,
|
|
@@ -2461,44 +2461,44 @@ var K = class {
|
|
|
2461
2461
|
};
|
|
2462
2462
|
}
|
|
2463
2463
|
};
|
|
2464
|
-
function
|
|
2464
|
+
function ct(e) {
|
|
2465
2465
|
let t = [];
|
|
2466
|
-
for (let n of e) "and" in n && n.and ? t.push(...
|
|
2466
|
+
for (let n of e) "and" in n && n.and ? t.push(...ct(n.and)) : "or" in n && n.or ? t.push(...ct(n.or)) : "member" in n && t.push(n);
|
|
2467
2467
|
return t;
|
|
2468
2468
|
}
|
|
2469
2469
|
//#endregion
|
|
2470
2470
|
//#region src/server/cache-utils.ts
|
|
2471
|
-
function
|
|
2472
|
-
let r = n.keyPrefix ?? "drizzle-cube:", i =
|
|
2471
|
+
function lt(e, t, n = {}) {
|
|
2472
|
+
let r = n.keyPrefix ?? "drizzle-cube:", i = ut(e), a = `${r}query:${ht(JSON.stringify(i))}`;
|
|
2473
2473
|
if (n.includeSecurityContext !== !1) {
|
|
2474
|
-
let e =
|
|
2474
|
+
let e = ht(n.securityContextSerializer ? n.securityContextSerializer(t) : JSON.stringify(K(t)));
|
|
2475
2475
|
a += `:ctx:${e}`;
|
|
2476
2476
|
}
|
|
2477
2477
|
return a;
|
|
2478
2478
|
}
|
|
2479
|
-
function
|
|
2479
|
+
function ut(e) {
|
|
2480
2480
|
return {
|
|
2481
2481
|
measures: e.measures ? [...e.measures].sort() : void 0,
|
|
2482
2482
|
dimensions: e.dimensions ? [...e.dimensions].sort() : void 0,
|
|
2483
|
-
filters: e.filters ?
|
|
2484
|
-
timeDimensions: e.timeDimensions ?
|
|
2483
|
+
filters: e.filters ? G(e.filters) : void 0,
|
|
2484
|
+
timeDimensions: e.timeDimensions ? mt(e.timeDimensions) : void 0,
|
|
2485
2485
|
limit: e.limit,
|
|
2486
2486
|
offset: e.offset,
|
|
2487
|
-
order: e.order ?
|
|
2487
|
+
order: e.order ? K(e.order) : void 0,
|
|
2488
2488
|
fillMissingDatesValue: e.fillMissingDatesValue,
|
|
2489
|
-
funnel: e.funnel ?
|
|
2490
|
-
flow: e.flow ?
|
|
2491
|
-
retention: e.retention ?
|
|
2489
|
+
funnel: e.funnel ? dt(e.funnel) : void 0,
|
|
2490
|
+
flow: e.flow ? ft(e.flow) : void 0,
|
|
2491
|
+
retention: e.retention ? pt(e.retention) : void 0
|
|
2492
2492
|
};
|
|
2493
2493
|
}
|
|
2494
|
-
function
|
|
2494
|
+
function dt(e) {
|
|
2495
2495
|
return {
|
|
2496
2496
|
bindingKey: e.bindingKey,
|
|
2497
2497
|
timeDimension: e.timeDimension,
|
|
2498
2498
|
steps: e.steps.map((e) => {
|
|
2499
2499
|
let t = {
|
|
2500
2500
|
name: e.name,
|
|
2501
|
-
filter: e.filter ? Array.isArray(e.filter) ?
|
|
2501
|
+
filter: e.filter ? Array.isArray(e.filter) ? G(e.filter) : G([e.filter])[0] : void 0,
|
|
2502
2502
|
timeToConvert: e.timeToConvert
|
|
2503
2503
|
};
|
|
2504
2504
|
return "cube" in e && e.cube && (t.cube = e.cube), t;
|
|
@@ -2507,14 +2507,14 @@ function lt(e) {
|
|
|
2507
2507
|
globalTimeWindow: e.globalTimeWindow
|
|
2508
2508
|
};
|
|
2509
2509
|
}
|
|
2510
|
-
function
|
|
2510
|
+
function ft(e) {
|
|
2511
2511
|
return {
|
|
2512
2512
|
bindingKey: e.bindingKey,
|
|
2513
2513
|
timeDimension: e.timeDimension,
|
|
2514
2514
|
eventDimension: e.eventDimension,
|
|
2515
2515
|
startingStep: {
|
|
2516
2516
|
name: e.startingStep.name,
|
|
2517
|
-
filter: e.startingStep.filter ? Array.isArray(e.startingStep.filter) ?
|
|
2517
|
+
filter: e.startingStep.filter ? Array.isArray(e.startingStep.filter) ? G(e.startingStep.filter) : G([e.startingStep.filter])[0] : void 0
|
|
2518
2518
|
},
|
|
2519
2519
|
stepsBefore: e.stepsBefore,
|
|
2520
2520
|
stepsAfter: e.stepsAfter,
|
|
@@ -2523,7 +2523,7 @@ function ut(e) {
|
|
|
2523
2523
|
joinStrategy: e.joinStrategy
|
|
2524
2524
|
};
|
|
2525
2525
|
}
|
|
2526
|
-
function
|
|
2526
|
+
function pt(e) {
|
|
2527
2527
|
return {
|
|
2528
2528
|
timeDimension: e.timeDimension,
|
|
2529
2529
|
bindingKey: e.bindingKey,
|
|
@@ -2531,15 +2531,15 @@ function dt(e) {
|
|
|
2531
2531
|
granularity: e.granularity,
|
|
2532
2532
|
periods: e.periods,
|
|
2533
2533
|
retentionType: e.retentionType,
|
|
2534
|
-
cohortFilters: e.cohortFilters ? Array.isArray(e.cohortFilters) ?
|
|
2535
|
-
activityFilters: e.activityFilters ? Array.isArray(e.activityFilters) ?
|
|
2534
|
+
cohortFilters: e.cohortFilters ? Array.isArray(e.cohortFilters) ? G(e.cohortFilters) : G([e.cohortFilters])[0] : void 0,
|
|
2535
|
+
activityFilters: e.activityFilters ? Array.isArray(e.activityFilters) ? G(e.activityFilters) : G([e.activityFilters])[0] : void 0,
|
|
2536
2536
|
breakdownDimensions: e.breakdownDimensions
|
|
2537
2537
|
};
|
|
2538
2538
|
}
|
|
2539
|
-
function
|
|
2539
|
+
function G(e) {
|
|
2540
2540
|
return [...e].map((e) => {
|
|
2541
|
-
if ("and" in e && e.and) return { and:
|
|
2542
|
-
if ("or" in e && e.or) return { or:
|
|
2541
|
+
if ("and" in e && e.and) return { and: G(e.and) };
|
|
2542
|
+
if ("or" in e && e.or) return { or: G(e.or) };
|
|
2543
2543
|
let t = e;
|
|
2544
2544
|
return {
|
|
2545
2545
|
...t,
|
|
@@ -2547,7 +2547,7 @@ function q(e) {
|
|
|
2547
2547
|
};
|
|
2548
2548
|
}).sort((e, t) => JSON.stringify(e).localeCompare(JSON.stringify(t)));
|
|
2549
2549
|
}
|
|
2550
|
-
function
|
|
2550
|
+
function mt(e) {
|
|
2551
2551
|
return [...e].map((e) => ({
|
|
2552
2552
|
dimension: e.dimension,
|
|
2553
2553
|
granularity: e.granularity,
|
|
@@ -2559,22 +2559,22 @@ function ft(e) {
|
|
|
2559
2559
|
}) : void 0
|
|
2560
2560
|
})).sort((e, t) => e.dimension.localeCompare(t.dimension));
|
|
2561
2561
|
}
|
|
2562
|
-
function
|
|
2563
|
-
return typeof e != "object" || !e ? e : Array.isArray(e) ? e.map(
|
|
2562
|
+
function K(e) {
|
|
2563
|
+
return typeof e != "object" || !e ? e : Array.isArray(e) ? e.map(K) : Object.keys(e).sort().reduce((t, n) => (t[n] = K(e[n]), t), {});
|
|
2564
2564
|
}
|
|
2565
|
-
function
|
|
2565
|
+
function ht(e) {
|
|
2566
2566
|
let t = 2166136261, n = Math.min(e.length, 65536);
|
|
2567
2567
|
for (let r = 0; r < n; r++) t ^= e.charCodeAt(r), t = t * 16777619 >>> 0;
|
|
2568
2568
|
return t.toString(16).padStart(8, "0");
|
|
2569
2569
|
}
|
|
2570
2570
|
//#endregion
|
|
2571
2571
|
//#region src/server/builders/date-time-builder.ts
|
|
2572
|
-
var
|
|
2572
|
+
var q = class {
|
|
2573
2573
|
constructor(e) {
|
|
2574
2574
|
this.databaseAdapter = e;
|
|
2575
2575
|
}
|
|
2576
2576
|
buildTimeDimensionExpression(e, t, n) {
|
|
2577
|
-
let r =
|
|
2577
|
+
let r = H(e, n);
|
|
2578
2578
|
return t ? this.databaseAdapter.buildTimeDimension(t, r) : r instanceof C ? r : O`${r}`;
|
|
2579
2579
|
}
|
|
2580
2580
|
buildDateRangeCondition(e, t) {
|
|
@@ -2586,13 +2586,13 @@ var Y = class {
|
|
|
2586
2586
|
let e = typeof r == "number" ? /* @__PURE__ */ new Date(r * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(r), t = new Date(e);
|
|
2587
2587
|
t.setUTCHours(23, 59, 59, 999), r = this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(t.getTime() / 1e3) : t.getTime() : t.toISOString();
|
|
2588
2588
|
}
|
|
2589
|
-
return P(
|
|
2589
|
+
return P(F(e, n), I(e, r));
|
|
2590
2590
|
}
|
|
2591
2591
|
if (typeof t == "string") {
|
|
2592
2592
|
let n = this.parseRelativeDateRange(t);
|
|
2593
2593
|
if (n) {
|
|
2594
2594
|
let t, r;
|
|
2595
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (t = Math.floor(n.start.getTime() / 1e3), r = Math.floor(n.end.getTime() / 1e3)) : (t = n.start.getTime(), r = n.end.getTime()) : (t = n.start.toISOString(), r = n.end.toISOString()), P(
|
|
2595
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (t = Math.floor(n.start.getTime() / 1e3), r = Math.floor(n.end.getTime() / 1e3)) : (t = n.start.getTime(), r = n.end.getTime()) : (t = n.start.toISOString(), r = n.end.toISOString()), P(F(e, t), I(e, r));
|
|
2596
2596
|
}
|
|
2597
2597
|
let r = this.normalizeDate(t);
|
|
2598
2598
|
if (!r) return null;
|
|
@@ -2601,7 +2601,7 @@ var Y = class {
|
|
|
2601
2601
|
let o = new Date(i);
|
|
2602
2602
|
o.setUTCHours(23, 59, 59, 999);
|
|
2603
2603
|
let s, c;
|
|
2604
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (s = Math.floor(a.getTime() / 1e3), c = Math.floor(o.getTime() / 1e3)) : (s = a.getTime(), c = o.getTime()) : (s = a.toISOString(), c = o.toISOString()), P(
|
|
2604
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (s = Math.floor(a.getTime() / 1e3), c = Math.floor(o.getTime() / 1e3)) : (s = a.getTime(), c = o.getTime()) : (s = a.toISOString(), c = o.toISOString()), P(F(e, s), I(e, c));
|
|
2605
2605
|
}
|
|
2606
2606
|
return null;
|
|
2607
2607
|
}
|
|
@@ -2736,7 +2736,7 @@ var Y = class {
|
|
|
2736
2736
|
let t = new Date(e);
|
|
2737
2737
|
return isNaN(t.getTime()) ? null : this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(t.getTime() / 1e3) : t.getTime() : t.toISOString();
|
|
2738
2738
|
}
|
|
2739
|
-
},
|
|
2739
|
+
}, J = class {
|
|
2740
2740
|
constructor(e, t) {
|
|
2741
2741
|
this.databaseAdapter = e, this.dateTimeBuilder = t;
|
|
2742
2742
|
}
|
|
@@ -2751,18 +2751,18 @@ var Y = class {
|
|
|
2751
2751
|
if (a.length === 0 && !["set", "notSet"].includes(t)) return t === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
2752
2752
|
let o = a[0];
|
|
2753
2753
|
switch (t) {
|
|
2754
|
-
case "equals": return a.length > 1 ? r?.type === "time" ?
|
|
2755
|
-
case "notEquals": return a.length > 1 ?
|
|
2754
|
+
case "equals": return a.length > 1 ? r?.type === "time" ? ae(e, a.map((e) => this.dateTimeBuilder.normalizeDate(e) || e)) : ae(e, a) : a.length === 1 ? M(e, r?.type === "time" && this.dateTimeBuilder.normalizeDate(o) || o) : this.databaseAdapter.buildBooleanLiteral(!1);
|
|
2755
|
+
case "notEquals": return a.length > 1 ? oe(e, a) : a.length === 1 ? N(e, o) : null;
|
|
2756
2756
|
case "contains": return this.databaseAdapter.buildStringCondition(e, "contains", o);
|
|
2757
2757
|
case "notContains": return this.databaseAdapter.buildStringCondition(e, "notContains", o);
|
|
2758
2758
|
case "startsWith": return this.databaseAdapter.buildStringCondition(e, "startsWith", o);
|
|
2759
2759
|
case "endsWith": return this.databaseAdapter.buildStringCondition(e, "endsWith", o);
|
|
2760
|
-
case "gt": return
|
|
2761
|
-
case "gte": return
|
|
2762
|
-
case "lt": return
|
|
2763
|
-
case "lte": return
|
|
2764
|
-
case "set": return
|
|
2765
|
-
case "notSet": return
|
|
2760
|
+
case "gt": return re(e, o);
|
|
2761
|
+
case "gte": return F(e, o);
|
|
2762
|
+
case "lt": return ie(e, o);
|
|
2763
|
+
case "lte": return I(e, o);
|
|
2764
|
+
case "set": return ce(e);
|
|
2765
|
+
case "notSet": return se(e);
|
|
2766
2766
|
case "inDateRange":
|
|
2767
2767
|
if (a.length >= 2) {
|
|
2768
2768
|
let t = this.dateTimeBuilder.normalizeDate(a[0]), r = this.dateTimeBuilder.normalizeDate(a[1]);
|
|
@@ -2772,32 +2772,32 @@ var Y = class {
|
|
|
2772
2772
|
let e = typeof r == "number" ? /* @__PURE__ */ new Date(r * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(r), t = new Date(e);
|
|
2773
2773
|
t.setUTCHours(23, 59, 59, 999), r = this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(t.getTime() / 1e3) : t.getTime() : t.toISOString();
|
|
2774
2774
|
}
|
|
2775
|
-
return P(
|
|
2775
|
+
return P(F(e, t), I(e, r));
|
|
2776
2776
|
}
|
|
2777
2777
|
}
|
|
2778
2778
|
return null;
|
|
2779
2779
|
case "beforeDate": {
|
|
2780
2780
|
let t = this.dateTimeBuilder.normalizeDate(o);
|
|
2781
|
-
return t ?
|
|
2781
|
+
return t ? ie(e, t) : null;
|
|
2782
2782
|
}
|
|
2783
2783
|
case "afterDate": {
|
|
2784
2784
|
let t = this.dateTimeBuilder.normalizeDate(o);
|
|
2785
|
-
return t ?
|
|
2785
|
+
return t ? re(e, t) : null;
|
|
2786
2786
|
}
|
|
2787
|
-
case "between": return a.length >= 2 ? P(
|
|
2788
|
-
case "notBetween": return a.length >= 2 ?
|
|
2789
|
-
case "in": return a.length > 0 ?
|
|
2790
|
-
case "notIn": return a.length > 0 ?
|
|
2787
|
+
case "between": return a.length >= 2 ? P(F(e, a[0]), I(e, a[1])) : null;
|
|
2788
|
+
case "notBetween": return a.length >= 2 ? ne(ie(e, a[0]), re(e, a[1])) : null;
|
|
2789
|
+
case "in": return a.length > 0 ? ae(e, a) : null;
|
|
2790
|
+
case "notIn": return a.length > 0 ? oe(e, a) : null;
|
|
2791
2791
|
case "like": return this.databaseAdapter.buildStringCondition(e, "like", o);
|
|
2792
2792
|
case "notLike": return this.databaseAdapter.buildStringCondition(e, "notLike", o);
|
|
2793
2793
|
case "ilike": return this.databaseAdapter.buildStringCondition(e, "ilike", o);
|
|
2794
2794
|
case "regex": return this.databaseAdapter.buildStringCondition(e, "regex", o);
|
|
2795
2795
|
case "notRegex": return this.databaseAdapter.buildStringCondition(e, "notRegex", o);
|
|
2796
|
-
case "isEmpty": return
|
|
2797
|
-
case "isNotEmpty": return P(
|
|
2798
|
-
case "arrayContains": return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
2799
|
-
case "arrayOverlaps": return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
2800
|
-
case "arrayContained": return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
2796
|
+
case "isEmpty": return ne(se(e), M(e, ""));
|
|
2797
|
+
case "isNotEmpty": return P(ce(e), N(e, ""));
|
|
2798
|
+
case "arrayContains": return this.databaseAdapter.getEngineType() === "postgres" ? le(e, a) : null;
|
|
2799
|
+
case "arrayOverlaps": return this.databaseAdapter.getEngineType() === "postgres" ? de(e, a) : null;
|
|
2800
|
+
case "arrayContained": return this.databaseAdapter.getEngineType() === "postgres" ? ue(e, a) : null;
|
|
2801
2801
|
default: return null;
|
|
2802
2802
|
}
|
|
2803
2803
|
}
|
|
@@ -2808,7 +2808,7 @@ var Y = class {
|
|
|
2808
2808
|
}
|
|
2809
2809
|
if ("or" in e && e.or) {
|
|
2810
2810
|
let r = e.or.map((e) => this.buildSingleFilter(e, t, n)).filter((e) => e !== null);
|
|
2811
|
-
return r.length > 0 ? r.length === 1 ? r[0] :
|
|
2811
|
+
return r.length > 0 ? r.length === 1 ? r[0] : ne(...r) : null;
|
|
2812
2812
|
}
|
|
2813
2813
|
return null;
|
|
2814
2814
|
}
|
|
@@ -2818,10 +2818,10 @@ var Y = class {
|
|
|
2818
2818
|
if (!o) return null;
|
|
2819
2819
|
let s = o.dimensions?.[a];
|
|
2820
2820
|
if (!s) return null;
|
|
2821
|
-
let c = s.type === "time" ?
|
|
2821
|
+
let c = s.type === "time" ? H(s.sql, n) : typeof s.sql == "function" ? s.sql(n) : s.sql;
|
|
2822
2822
|
return this.buildFilterCondition(c, r.operator, r.values, s, r.dateRange);
|
|
2823
2823
|
}
|
|
2824
|
-
},
|
|
2824
|
+
}, Y = class {
|
|
2825
2825
|
dependencyGraph;
|
|
2826
2826
|
cubes;
|
|
2827
2827
|
constructor(e) {
|
|
@@ -2949,8 +2949,8 @@ var Y = class {
|
|
|
2949
2949
|
};
|
|
2950
2950
|
//#endregion
|
|
2951
2951
|
//#region src/server/template-substitution.ts
|
|
2952
|
-
function
|
|
2953
|
-
let { cube: r, allCubes: i, resolvedMeasures: a } = n, o =
|
|
2952
|
+
function gt(t, n) {
|
|
2953
|
+
let { cube: r, allCubes: i, resolvedMeasures: a } = n, o = _t(t), s = /* @__PURE__ */ new Map();
|
|
2954
2954
|
for (let t of o) {
|
|
2955
2955
|
let { originalRef: n, cubeName: o, fieldName: c } = t, l = o || r.name;
|
|
2956
2956
|
if (!i.get(l)) throw Error(e("server.validation.template.substituteTargetCubeNotFound", {
|
|
@@ -2979,7 +2979,7 @@ function mt(t, n) {
|
|
|
2979
2979
|
for (let e = 0; e < c.length; e++) c[e] && d.push(new S(c[e])), e < l.length && d.push(l[e]);
|
|
2980
2980
|
return O.join(d, O.raw(""));
|
|
2981
2981
|
}
|
|
2982
|
-
function
|
|
2982
|
+
function _t(e) {
|
|
2983
2983
|
if (e.length > 1e3) return [];
|
|
2984
2984
|
let t = e.matchAll(/\{([^}]+)\}/g), n = [];
|
|
2985
2985
|
for (let e of t) {
|
|
@@ -2999,7 +2999,7 @@ function ht(e) {
|
|
|
2999
2999
|
}
|
|
3000
3000
|
return n;
|
|
3001
3001
|
}
|
|
3002
|
-
function
|
|
3002
|
+
function vt(t) {
|
|
3003
3003
|
let n = [], r = 0;
|
|
3004
3004
|
for (let i = 0; i < t.length; i++) if (t[i] === "{") r++;
|
|
3005
3005
|
else if (t[i] === "}" && (r--, r < 0)) {
|
|
@@ -3007,7 +3007,7 @@ function gt(t) {
|
|
|
3007
3007
|
break;
|
|
3008
3008
|
}
|
|
3009
3009
|
r > 0 && n.push(e("server.validation.template.unmatchedOpeningBrace")), /\{\s*\}/.test(t) && n.push(e("server.validation.template.emptyReference")), /\{[^}]*\{/.test(t) && n.push(e("server.validation.template.nestedBraces"));
|
|
3010
|
-
let i =
|
|
3010
|
+
let i = _t(t);
|
|
3011
3011
|
for (let t of i) {
|
|
3012
3012
|
let r = t.cubeName ? `${t.cubeName}.${t.fieldName}` : t.fieldName;
|
|
3013
3013
|
/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(r) || n.push(e("server.validation.template.invalidMemberReference", { ref: `{${t.originalRef}}` })), r.split(".").length > 2 && n.push(e("server.validation.template.multipleDots", { ref: `{${t.originalRef}}` }));
|
|
@@ -3017,8 +3017,8 @@ function gt(t) {
|
|
|
3017
3017
|
errors: n
|
|
3018
3018
|
};
|
|
3019
3019
|
}
|
|
3020
|
-
function
|
|
3021
|
-
let n =
|
|
3020
|
+
function yt(e, t) {
|
|
3021
|
+
let n = _t(e), r = /* @__PURE__ */ new Set();
|
|
3022
3022
|
for (let e of n) {
|
|
3023
3023
|
let n = `${e.cubeName || t}.${e.fieldName}`;
|
|
3024
3024
|
r.add(n);
|
|
@@ -3027,12 +3027,12 @@ function _t(e, t) {
|
|
|
3027
3027
|
}
|
|
3028
3028
|
//#endregion
|
|
3029
3029
|
//#region src/server/builders/measure-builder.ts
|
|
3030
|
-
var
|
|
3030
|
+
var X = class e {
|
|
3031
3031
|
constructor(e) {
|
|
3032
3032
|
this.databaseAdapter = e;
|
|
3033
3033
|
}
|
|
3034
3034
|
buildResolvedMeasures(t, n, r, i) {
|
|
3035
|
-
let a = /* @__PURE__ */ new Map(), o = [], s = [], c = new Set(t), l = new
|
|
3035
|
+
let a = /* @__PURE__ */ new Map(), o = [], s = [], c = new Set(t), l = new Y(n);
|
|
3036
3036
|
for (let e of n.values()) l.buildGraph(e);
|
|
3037
3037
|
let u = [];
|
|
3038
3038
|
for (let r of t) {
|
|
@@ -3045,11 +3045,11 @@ var Q = class e {
|
|
|
3045
3045
|
n && c.add(n);
|
|
3046
3046
|
continue;
|
|
3047
3047
|
}
|
|
3048
|
-
|
|
3048
|
+
Y.isCalculatedMeasure(d) ? (s.push(r), yt(d.calculatedSql, t).forEach((e) => c.add(e)), l.getAllDependencies(r).forEach((e) => {
|
|
3049
3049
|
let [t, r] = e.split("."), i = n.get(t);
|
|
3050
3050
|
if (i && i.measures[r]) {
|
|
3051
3051
|
let e = i.measures[r];
|
|
3052
|
-
|
|
3052
|
+
Y.isCalculatedMeasure(e) && yt(e.calculatedSql, t).forEach((e) => c.add(e));
|
|
3053
3053
|
}
|
|
3054
3054
|
})) : o.push(r);
|
|
3055
3055
|
}
|
|
@@ -3059,7 +3059,7 @@ var Q = class e {
|
|
|
3059
3059
|
if (a && a.measures && a.measures[i]) {
|
|
3060
3060
|
let n = a.measures[i];
|
|
3061
3061
|
if (e.isPostAggregationWindow(n)) continue;
|
|
3062
|
-
|
|
3062
|
+
Y.isCalculatedMeasure(n) ? s.includes(t) || s.push(t) : o.includes(t) || o.push(t);
|
|
3063
3063
|
}
|
|
3064
3064
|
}
|
|
3065
3065
|
for (let e of o) {
|
|
@@ -3080,7 +3080,7 @@ var Q = class e {
|
|
|
3080
3080
|
}
|
|
3081
3081
|
buildCalculatedMeasure(e, t, n, r, i) {
|
|
3082
3082
|
if (!e.calculatedSql) throw Error(`Calculated measure '${t.name}.${e.name}' missing calculatedSql property`);
|
|
3083
|
-
return
|
|
3083
|
+
return gt(this.databaseAdapter.preprocessCalculatedTemplate(e.calculatedSql), {
|
|
3084
3084
|
cube: t,
|
|
3085
3085
|
allCubes: n,
|
|
3086
3086
|
resolvedMeasures: r,
|
|
@@ -3089,7 +3089,7 @@ var Q = class e {
|
|
|
3089
3089
|
}
|
|
3090
3090
|
buildCTECalculatedMeasure(e, t, n, r, i) {
|
|
3091
3091
|
if (!e.calculatedSql) throw Error(`Calculated measure '${t.name}.${e.name || "unknown"}' missing calculatedSql property`);
|
|
3092
|
-
let a = /* @__PURE__ */ new Map(), o =
|
|
3092
|
+
let a = /* @__PURE__ */ new Map(), o = yt(e.calculatedSql, t.name);
|
|
3093
3093
|
for (let e of o) {
|
|
3094
3094
|
let [t, i] = e.split("."), o = r.get(t);
|
|
3095
3095
|
if (o && o.measures[i]) {
|
|
@@ -3100,21 +3100,21 @@ var Q = class e {
|
|
|
3100
3100
|
case "count":
|
|
3101
3101
|
case "countDistinct":
|
|
3102
3102
|
case "sum":
|
|
3103
|
-
o =
|
|
3103
|
+
o = L(r);
|
|
3104
3104
|
break;
|
|
3105
3105
|
case "avg":
|
|
3106
3106
|
o = this.databaseAdapter.buildAvg(r);
|
|
3107
3107
|
break;
|
|
3108
3108
|
case "min":
|
|
3109
|
-
o =
|
|
3109
|
+
o = ge(r);
|
|
3110
3110
|
break;
|
|
3111
3111
|
case "max":
|
|
3112
|
-
o =
|
|
3112
|
+
o = R(r);
|
|
3113
3113
|
break;
|
|
3114
3114
|
case "number":
|
|
3115
|
-
o =
|
|
3115
|
+
o = L(r);
|
|
3116
3116
|
break;
|
|
3117
|
-
default: o =
|
|
3117
|
+
default: o = L(r);
|
|
3118
3118
|
}
|
|
3119
3119
|
a.set(e, () => o);
|
|
3120
3120
|
}
|
|
@@ -3136,12 +3136,12 @@ var Q = class e {
|
|
|
3136
3136
|
switch (n.type) {
|
|
3137
3137
|
case "count":
|
|
3138
3138
|
case "countDistinct":
|
|
3139
|
-
case "sum": return
|
|
3139
|
+
case "sum": return L(e);
|
|
3140
3140
|
case "avg": return this.databaseAdapter.buildAvg(e);
|
|
3141
|
-
case "min": return
|
|
3142
|
-
case "max": return
|
|
3143
|
-
case "number": return
|
|
3144
|
-
default: return
|
|
3141
|
+
case "min": return ge(e);
|
|
3142
|
+
case "max": return R(e);
|
|
3143
|
+
case "number": return L(e);
|
|
3144
|
+
default: return L(e);
|
|
3145
3145
|
}
|
|
3146
3146
|
}
|
|
3147
3147
|
}
|
|
@@ -3151,7 +3151,7 @@ var Q = class e {
|
|
|
3151
3151
|
if (t.type === "calculated") throw Error(`Cannot build calculated measure '${t.name}' directly. Use buildCalculatedMeasure instead.`);
|
|
3152
3152
|
if (e.isPostAggregationWindow(t)) throw Error(`Post-aggregation window measure '${t.name}' should be built via buildPostAggregationWindowExpression, not buildMeasureExpression.`);
|
|
3153
3153
|
if (!t.sql) throw Error(`Measure '${t.name}' of type '${t.type}' is missing required 'sql' property. Only calculated measures and post-aggregation window functions can omit 'sql'.`);
|
|
3154
|
-
let i =
|
|
3154
|
+
let i = H(t.sql, n);
|
|
3155
3155
|
if (n.ungrouped) return i;
|
|
3156
3156
|
if (t.filters && t.filters.length > 0) {
|
|
3157
3157
|
let e = t.filters.map((e) => {
|
|
@@ -3167,12 +3167,12 @@ var Q = class e {
|
|
|
3167
3167
|
}
|
|
3168
3168
|
}
|
|
3169
3169
|
switch (t.type) {
|
|
3170
|
-
case "count": return
|
|
3171
|
-
case "countDistinct": return
|
|
3172
|
-
case "sum": return
|
|
3170
|
+
case "count": return me(i);
|
|
3171
|
+
case "countDistinct": return he(i);
|
|
3172
|
+
case "sum": return L(i);
|
|
3173
3173
|
case "avg": return this.databaseAdapter.buildAvg(i);
|
|
3174
|
-
case "min": return
|
|
3175
|
-
case "max": return
|
|
3174
|
+
case "min": return ge(i);
|
|
3175
|
+
case "max": return R(i);
|
|
3176
3176
|
case "number": return i;
|
|
3177
3177
|
case "stddev":
|
|
3178
3178
|
case "stddevSamp": {
|
|
@@ -3218,7 +3218,7 @@ var Q = class e {
|
|
|
3218
3218
|
if (e.partitionBy && e.partitionBy.length > 0 && r) {
|
|
3219
3219
|
let t = e.partitionBy.map((e) => {
|
|
3220
3220
|
let t = e.includes(".") ? e.split(".")[1] : e, i = r.dimensions?.[t];
|
|
3221
|
-
return i ?
|
|
3221
|
+
return i ? H(i.sql, n) : (console.warn(`[drizzle-cube] Window function partition dimension '${e}' not found in cube '${r.name}'`), null);
|
|
3222
3222
|
}).filter((e) => e !== null);
|
|
3223
3223
|
t.length > 0 && (a = t);
|
|
3224
3224
|
}
|
|
@@ -3227,12 +3227,12 @@ var Q = class e {
|
|
|
3227
3227
|
let t = e.orderBy.map((e) => {
|
|
3228
3228
|
let t = e.field.includes(".") ? e.field.split(".")[1] : e.field, i = r.dimensions?.[t];
|
|
3229
3229
|
if (i) return {
|
|
3230
|
-
field:
|
|
3230
|
+
field: H(i.sql, n),
|
|
3231
3231
|
direction: e.direction
|
|
3232
3232
|
};
|
|
3233
3233
|
let a = r.measures?.[t];
|
|
3234
3234
|
return a && a.sql ? {
|
|
3235
|
-
field:
|
|
3235
|
+
field: H(a.sql, n),
|
|
3236
3236
|
direction: e.direction
|
|
3237
3237
|
} : (console.warn(`[drizzle-cube] Window function order field '${e.field}' not found in cube '${r.name}'`), null);
|
|
3238
3238
|
}).filter((e) => e !== null);
|
|
@@ -3250,7 +3250,7 @@ var Q = class e {
|
|
|
3250
3250
|
});
|
|
3251
3251
|
return s === null ? (console.warn(`[drizzle-cube] ${t.type} not supported on ${this.databaseAdapter.getEngineType()}, returning NULL`), O`NULL`) : s;
|
|
3252
3252
|
}
|
|
3253
|
-
default: return
|
|
3253
|
+
default: return me(i);
|
|
3254
3254
|
}
|
|
3255
3255
|
}
|
|
3256
3256
|
static WINDOW_FUNCTION_TYPES = [
|
|
@@ -3324,7 +3324,7 @@ var Q = class e {
|
|
|
3324
3324
|
let { postAggWindowMeasures: r } = e.categorizeForPostAggregation(t, n);
|
|
3325
3325
|
return r.length > 0;
|
|
3326
3326
|
}
|
|
3327
|
-
},
|
|
3327
|
+
}, bt = class {
|
|
3328
3328
|
constructor(e) {
|
|
3329
3329
|
this.dateTimeBuilder = e;
|
|
3330
3330
|
}
|
|
@@ -3372,8 +3372,8 @@ var Q = class e {
|
|
|
3372
3372
|
l = !0;
|
|
3373
3373
|
break;
|
|
3374
3374
|
}
|
|
3375
|
-
if (
|
|
3376
|
-
let n =
|
|
3375
|
+
if (X.isPostAggregationWindow(e)) {
|
|
3376
|
+
let n = X.getWindowBaseMeasure(e, t);
|
|
3377
3377
|
if (n) {
|
|
3378
3378
|
let [e, t] = n.split("."), r = a.get(e)?.measures?.[t];
|
|
3379
3379
|
if (r && this.isAggregateFunctionType(r.type)) {
|
|
@@ -3397,7 +3397,7 @@ var Q = class e {
|
|
|
3397
3397
|
i.push(t);
|
|
3398
3398
|
}
|
|
3399
3399
|
} else {
|
|
3400
|
-
let e = s.dimensions[o], t =
|
|
3400
|
+
let e = s.dimensions[o], t = H(e.sql, n);
|
|
3401
3401
|
i.push(t);
|
|
3402
3402
|
}
|
|
3403
3403
|
}
|
|
@@ -3423,13 +3423,13 @@ var Q = class e {
|
|
|
3423
3423
|
}
|
|
3424
3424
|
return i;
|
|
3425
3425
|
}
|
|
3426
|
-
},
|
|
3426
|
+
}, xt = class {
|
|
3427
3427
|
dateTimeBuilder;
|
|
3428
3428
|
filterBuilder;
|
|
3429
3429
|
groupByBuilder;
|
|
3430
3430
|
measureBuilder;
|
|
3431
3431
|
constructor(e) {
|
|
3432
|
-
this.dateTimeBuilder = new
|
|
3432
|
+
this.dateTimeBuilder = new q(e), this.filterBuilder = new J(e, this.dateTimeBuilder), this.groupByBuilder = new bt(this.dateTimeBuilder), this.measureBuilder = new X(e);
|
|
3433
3433
|
}
|
|
3434
3434
|
buildResolvedMeasures(e, t, n, r) {
|
|
3435
3435
|
return this.measureBuilder.buildResolvedMeasures(e, t, n, r);
|
|
@@ -3440,7 +3440,7 @@ var Q = class e {
|
|
|
3440
3440
|
let [t, a] = e.split("."), o = i.get(t);
|
|
3441
3441
|
if (o && o.dimensions && o.dimensions[a]) {
|
|
3442
3442
|
let t = o.dimensions[a];
|
|
3443
|
-
r[e] = O`${
|
|
3443
|
+
r[e] = O`${H(t.sql, n)}`.as(e);
|
|
3444
3444
|
}
|
|
3445
3445
|
}
|
|
3446
3446
|
if (t.measures) {
|
|
@@ -3457,7 +3457,7 @@ var Q = class e {
|
|
|
3457
3457
|
r[e.dimension] = O`${i}`.as(e.dimension);
|
|
3458
3458
|
}
|
|
3459
3459
|
}
|
|
3460
|
-
return Object.keys(r).length === 0 && (r.count =
|
|
3460
|
+
return Object.keys(r).length === 0 && (r.count = me()), r;
|
|
3461
3461
|
}
|
|
3462
3462
|
buildCalculatedMeasure(e, t, n, r, i) {
|
|
3463
3463
|
return this.measureBuilder.buildCalculatedMeasure(e, t, n, r, i);
|
|
@@ -3494,13 +3494,13 @@ var Q = class e {
|
|
|
3494
3494
|
if (s && s.dimensions[i] && e.dateRange) {
|
|
3495
3495
|
if (r?.preAggregationCTEs && r.preAggregationCTEs.some((e) => e.cube.name === t)) continue;
|
|
3496
3496
|
if (n.filterCache) {
|
|
3497
|
-
let t =
|
|
3497
|
+
let t = st(e.dimension, e.dateRange), r = n.filterCache.get(t);
|
|
3498
3498
|
if (r) {
|
|
3499
3499
|
a.push(r);
|
|
3500
3500
|
continue;
|
|
3501
3501
|
}
|
|
3502
3502
|
}
|
|
3503
|
-
let o = s.dimensions[i], c =
|
|
3503
|
+
let o = s.dimensions[i], c = H(o.sql, n), l = this.buildDateRangeCondition(c, e.dateRange);
|
|
3504
3504
|
l && a.push(l);
|
|
3505
3505
|
}
|
|
3506
3506
|
}
|
|
@@ -3523,7 +3523,7 @@ var Q = class e {
|
|
|
3523
3523
|
}
|
|
3524
3524
|
if (a.or) {
|
|
3525
3525
|
let e = a.or.map((e) => this.processFilter(e, t, n, r, i)).filter((e) => e !== null);
|
|
3526
|
-
return e.length > 0 ?
|
|
3526
|
+
return e.length > 0 ? ne(...e) : null;
|
|
3527
3527
|
}
|
|
3528
3528
|
}
|
|
3529
3529
|
let a = e, [o, s] = a.member.split("."), c = t.get(o);
|
|
@@ -3534,10 +3534,10 @@ var Q = class e {
|
|
|
3534
3534
|
if (i?.preAggregationCTEs && i.preAggregationCTEs.some((e) => e.cube.name === o)) return null;
|
|
3535
3535
|
let t = l.type === "time";
|
|
3536
3536
|
if (n.filterCache) {
|
|
3537
|
-
let t =
|
|
3537
|
+
let t = U(e), r = n.filterCache.get(t);
|
|
3538
3538
|
if (r) return r;
|
|
3539
3539
|
}
|
|
3540
|
-
let r = t ?
|
|
3540
|
+
let r = t ? H(l.sql, n) : typeof l.sql == "function" ? l.sql(n) : l.sql;
|
|
3541
3541
|
return this.buildFilterCondition(r, a.operator, a.values, d, a.dateRange);
|
|
3542
3542
|
} else if (r === "where" && u) return null;
|
|
3543
3543
|
else if (r === "having" && u) {
|
|
@@ -3563,12 +3563,12 @@ var Q = class e {
|
|
|
3563
3563
|
];
|
|
3564
3564
|
if (e.order && Object.keys(e.order).length > 0) for (let [t, i] of Object.entries(e.order)) {
|
|
3565
3565
|
if (!r.includes(t)) throw Error(`Cannot order by '${t}': field is not selected in the query`);
|
|
3566
|
-
let e = i === "desc" ?
|
|
3566
|
+
let e = i === "desc" ? pe(O.identifier(t)) : fe(O.identifier(t));
|
|
3567
3567
|
n.push(e);
|
|
3568
3568
|
}
|
|
3569
3569
|
if (e.timeDimensions && e.timeDimensions.length > 0) {
|
|
3570
3570
|
let t = new Set(Object.keys(e.order || {})), r = [...e.timeDimensions].sort((e, t) => e.dimension.localeCompare(t.dimension));
|
|
3571
|
-
for (let e of r) t.has(e.dimension) || n.push(
|
|
3571
|
+
for (let e of r) t.has(e.dimension) || n.push(fe(O.identifier(e.dimension)));
|
|
3572
3572
|
}
|
|
3573
3573
|
return n;
|
|
3574
3574
|
}
|
|
@@ -3603,7 +3603,7 @@ var Q = class e {
|
|
|
3603
3603
|
buildLogicalFilter(e, t, n) {
|
|
3604
3604
|
return this.filterBuilder.buildLogicalFilter(e, t, n);
|
|
3605
3605
|
}
|
|
3606
|
-
},
|
|
3606
|
+
}, Z = class {
|
|
3607
3607
|
cubes;
|
|
3608
3608
|
connectivityCache = /* @__PURE__ */ new Map();
|
|
3609
3609
|
reverseIndex;
|
|
@@ -3614,7 +3614,7 @@ var Q = class e {
|
|
|
3614
3614
|
let e = /* @__PURE__ */ new Map();
|
|
3615
3615
|
for (let [t, n] of this.cubes) if (n.joins) for (let [, r] of Object.entries(n.joins)) {
|
|
3616
3616
|
if (r.relationship === "belongsToMany") continue;
|
|
3617
|
-
let n =
|
|
3617
|
+
let n = V(r.targetCube, this.cubes);
|
|
3618
3618
|
if (!n) continue;
|
|
3619
3619
|
let i = n.name, a = e.get(i);
|
|
3620
3620
|
a || (a = [], e.set(i, a)), a.push({
|
|
@@ -3635,7 +3635,7 @@ var Q = class e {
|
|
|
3635
3635
|
for (; a.length > 0;) {
|
|
3636
3636
|
let { cube: e, path: n } = a.shift(), i = this.cubes.get(e);
|
|
3637
3637
|
if (i?.joins) for (let [, s] of Object.entries(i.joins)) {
|
|
3638
|
-
let i =
|
|
3638
|
+
let i = V(s.targetCube, this.cubes);
|
|
3639
3639
|
if (!i) continue;
|
|
3640
3640
|
let c = i.name;
|
|
3641
3641
|
if (o.has(c)) continue;
|
|
@@ -3731,7 +3731,7 @@ var Q = class e {
|
|
|
3731
3731
|
if (n.length >= r) continue;
|
|
3732
3732
|
let s = this.cubes.get(e);
|
|
3733
3733
|
if (s?.joins) for (let [, r] of Object.entries(s.joins)) {
|
|
3734
|
-
let s =
|
|
3734
|
+
let s = V(r.targetCube, this.cubes);
|
|
3735
3735
|
if (!s) continue;
|
|
3736
3736
|
let c = s.name;
|
|
3737
3737
|
if (o.has(c)) continue;
|
|
@@ -3789,7 +3789,7 @@ var Q = class e {
|
|
|
3789
3789
|
for (; r.length > 0;) {
|
|
3790
3790
|
let { cube: e, path: n } = r.shift(), a = this.cubes.get(e);
|
|
3791
3791
|
if (a?.joins) for (let [, o] of Object.entries(a.joins)) {
|
|
3792
|
-
let a =
|
|
3792
|
+
let a = V(o.targetCube, this.cubes);
|
|
3793
3793
|
if (!a) continue;
|
|
3794
3794
|
let s = a.name;
|
|
3795
3795
|
if (i.has(s)) continue;
|
|
@@ -3810,7 +3810,7 @@ var Q = class e {
|
|
|
3810
3810
|
buildJoinCondition(e, t, n) {
|
|
3811
3811
|
let r = [];
|
|
3812
3812
|
for (let i of e.on) {
|
|
3813
|
-
let e = t ? O`${O.identifier(t)}.${O.identifier(i.source.name)}` :
|
|
3813
|
+
let e = t ? O`${O.identifier(t)}.${O.identifier(i.source.name)}` : it(i.source), a = n ? O`${O.identifier(n)}.${O.identifier(i.target.name)}` : it(i.target), o = i.as || M;
|
|
3814
3814
|
r.push(o(e, a));
|
|
3815
3815
|
}
|
|
3816
3816
|
return P(...r);
|
|
@@ -3820,7 +3820,7 @@ var Q = class e {
|
|
|
3820
3820
|
for (; n.length > 0;) {
|
|
3821
3821
|
let e = n.shift(), r = this.cubes.get(e);
|
|
3822
3822
|
if (r?.joins) for (let [, e] of Object.entries(r.joins)) {
|
|
3823
|
-
let r =
|
|
3823
|
+
let r = V(e.targetCube, this.cubes);
|
|
3824
3824
|
if (!r) continue;
|
|
3825
3825
|
let i = r.name;
|
|
3826
3826
|
t.has(i) || (t.add(i), n.push(i));
|
|
@@ -3840,11 +3840,11 @@ var Q = class e {
|
|
|
3840
3840
|
setInCache(e, t) {
|
|
3841
3841
|
this.connectivityCache.set(e, { path: t });
|
|
3842
3842
|
}
|
|
3843
|
-
},
|
|
3843
|
+
}, St = class {
|
|
3844
3844
|
resolverCache = /* @__PURE__ */ new WeakMap();
|
|
3845
3845
|
getResolver(e) {
|
|
3846
3846
|
let t = this.resolverCache.get(e);
|
|
3847
|
-
return t || (t = new
|
|
3847
|
+
return t || (t = new Z(e), this.resolverCache.set(e, t)), t;
|
|
3848
3848
|
}
|
|
3849
3849
|
analyzeCubeUsage(e) {
|
|
3850
3850
|
let t = /* @__PURE__ */ new Set();
|
|
@@ -3936,9 +3936,9 @@ var Q = class e {
|
|
|
3936
3936
|
if (c.has(r)) continue;
|
|
3937
3937
|
let l = t.get(r);
|
|
3938
3938
|
if (!l) throw Error(e("server.errors.cubeNotFound", { cubeName: r }));
|
|
3939
|
-
let d = u ?
|
|
3939
|
+
let d = u ? nt(a.relationship) : a.relationship;
|
|
3940
3940
|
if (d === "belongsToMany" && a.through) {
|
|
3941
|
-
let e =
|
|
3941
|
+
let e = ot(a, i.securityContext);
|
|
3942
3942
|
s.push({
|
|
3943
3943
|
cube: l,
|
|
3944
3944
|
alias: `${r.toLowerCase()}_cube`,
|
|
@@ -3955,7 +3955,7 @@ var Q = class e {
|
|
|
3955
3955
|
}
|
|
3956
3956
|
});
|
|
3957
3957
|
} else {
|
|
3958
|
-
let e = o.buildJoinCondition(a, null, null), t =
|
|
3958
|
+
let e = o.buildJoinCondition(a, null, null), t = rt(d, a.sqlJoinType);
|
|
3959
3959
|
s.push({
|
|
3960
3960
|
cube: l,
|
|
3961
3961
|
alias: `${r.toLowerCase()}_cube`,
|
|
@@ -4013,7 +4013,7 @@ var Q = class e {
|
|
|
4013
4013
|
targetColumnObj: e.target
|
|
4014
4014
|
})), h = void 0;
|
|
4015
4015
|
}
|
|
4016
|
-
let g = this.findPropagatingFilters(r, c, e), _ = new Map([[c.name, c]]), { aggregateMeasures: v, requiredBaseMeasures: y } =
|
|
4016
|
+
let g = this.findPropagatingFilters(r, c, e), _ = new Map([[c.name, c]]), { aggregateMeasures: v, requiredBaseMeasures: y } = X.categorizeForPostAggregation(f, _), b = [...new Set([...v, ...Array.from(y).filter((e) => e.startsWith(c.name + "."))])];
|
|
4017
4017
|
if (b.length > 0) {
|
|
4018
4018
|
let t = this.expandCalculatedMeasureDependencies(c, b), i = this.findDownstreamJoinKeys(c, r, e);
|
|
4019
4019
|
a.push({
|
|
@@ -4034,7 +4034,7 @@ var Q = class e {
|
|
|
4034
4034
|
}
|
|
4035
4035
|
findJoinInfoToCube(e, t) {
|
|
4036
4036
|
for (let [, n] of e) if (n.name !== t && n.joins) for (let [, r] of Object.entries(n.joins)) {
|
|
4037
|
-
let i =
|
|
4037
|
+
let i = V(r.targetCube, e);
|
|
4038
4038
|
if (i && i.name === t) return {
|
|
4039
4039
|
sourceCube: n,
|
|
4040
4040
|
joinDef: r
|
|
@@ -4051,7 +4051,7 @@ var Q = class e {
|
|
|
4051
4051
|
joinDef: e.joinDef,
|
|
4052
4052
|
reversed: e.reversed
|
|
4053
4053
|
}));
|
|
4054
|
-
if (!c.slice(0, -1).some((e) => (e.reversed ?
|
|
4054
|
+
if (!c.slice(0, -1).some((e) => (e.reversed ? nt(e.joinDef.relationship) : e.joinDef.relationship) === "hasMany")) return {
|
|
4055
4055
|
path: c,
|
|
4056
4056
|
hasIntermediateHasMany: !1,
|
|
4057
4057
|
intermediateJoins: [],
|
|
@@ -4095,7 +4095,7 @@ var Q = class e {
|
|
|
4095
4095
|
}
|
|
4096
4096
|
findJoinInfoForCube(e, t, n) {
|
|
4097
4097
|
if (t.joins) for (let [, r] of Object.entries(t.joins)) {
|
|
4098
|
-
let i =
|
|
4098
|
+
let i = V(r.targetCube, e);
|
|
4099
4099
|
if (i && i.name === n) return {
|
|
4100
4100
|
sourceCube: t,
|
|
4101
4101
|
joinDef: r
|
|
@@ -4103,7 +4103,7 @@ var Q = class e {
|
|
|
4103
4103
|
}
|
|
4104
4104
|
let r = e.get(n);
|
|
4105
4105
|
if (r?.joins) for (let [, n] of Object.entries(r.joins)) {
|
|
4106
|
-
let i =
|
|
4106
|
+
let i = V(n.targetCube, e);
|
|
4107
4107
|
if (i && i.name === t.name) return {
|
|
4108
4108
|
sourceCube: r,
|
|
4109
4109
|
joinDef: n,
|
|
@@ -4111,7 +4111,7 @@ var Q = class e {
|
|
|
4111
4111
|
};
|
|
4112
4112
|
}
|
|
4113
4113
|
for (let [, r] of e) if (!(r.name === t.name || r.name === n) && r.joins) for (let [, t] of Object.entries(r.joins)) {
|
|
4114
|
-
let i =
|
|
4114
|
+
let i = V(t.targetCube, e);
|
|
4115
4115
|
if (i && i.name === n) return {
|
|
4116
4116
|
sourceCube: r,
|
|
4117
4117
|
joinDef: t
|
|
@@ -4134,7 +4134,7 @@ var Q = class e {
|
|
|
4134
4134
|
i.delete(e.name);
|
|
4135
4135
|
}
|
|
4136
4136
|
if (e.joins) for (let [, t] of Object.entries(e.joins)) {
|
|
4137
|
-
let e =
|
|
4137
|
+
let e = V(t.targetCube, n);
|
|
4138
4138
|
if (!e) continue;
|
|
4139
4139
|
let a = e.name;
|
|
4140
4140
|
if (i.has(a)) {
|
|
@@ -4185,7 +4185,7 @@ var Q = class e {
|
|
|
4185
4185
|
findHasManyJoinDef(e, t, n) {
|
|
4186
4186
|
if (!e.joins) return null;
|
|
4187
4187
|
for (let [, r] of Object.entries(e.joins)) {
|
|
4188
|
-
let e =
|
|
4188
|
+
let e = V(r.targetCube, n);
|
|
4189
4189
|
if (e && e.name === t && r.relationship === "hasMany") return r;
|
|
4190
4190
|
}
|
|
4191
4191
|
return null;
|
|
@@ -4204,7 +4204,7 @@ var Q = class e {
|
|
|
4204
4204
|
if (a === t.name) continue;
|
|
4205
4205
|
let i = n.get(a);
|
|
4206
4206
|
if (i?.joins) for (let [, o] of Object.entries(i.joins)) {
|
|
4207
|
-
let s =
|
|
4207
|
+
let s = V(o.targetCube, n);
|
|
4208
4208
|
if (s && s.name === t.name && o.relationship === "hasMany") {
|
|
4209
4209
|
let t = this.extractFiltersForCube(e.filters, a), n = this.extractTimeDimensionFiltersForCube(e, a), s = [...t, ...n];
|
|
4210
4210
|
s.length > 0 && o.on.length > 0 && r.push({
|
|
@@ -4355,7 +4355,7 @@ var Q = class e {
|
|
|
4355
4355
|
}
|
|
4356
4356
|
convertInternalPathToJoinPathSteps(e) {
|
|
4357
4357
|
return e.map((e) => {
|
|
4358
|
-
let t = e.reversed ?
|
|
4358
|
+
let t = e.reversed ? nt(e.joinDef.relationship) : e.joinDef.relationship, n = rt(t, e.joinDef.sqlJoinType), r = e.joinDef.on.map((e) => ({
|
|
4359
4359
|
sourceColumn: e.source.name,
|
|
4360
4360
|
targetColumn: e.target.name
|
|
4361
4361
|
})), i = {
|
|
@@ -4420,7 +4420,28 @@ var Q = class e {
|
|
|
4420
4420
|
suggestion: "Add a dimension to see per-group breakdowns, or add a time dimension with granularity."
|
|
4421
4421
|
};
|
|
4422
4422
|
}
|
|
4423
|
-
}
|
|
4423
|
+
};
|
|
4424
|
+
//#endregion
|
|
4425
|
+
//#region src/server/builders/cte-builder.ts
|
|
4426
|
+
function Ct(e, t) {
|
|
4427
|
+
if (!t.joins) return e;
|
|
4428
|
+
for (let n of t.joins) switch (n.type || "left") {
|
|
4429
|
+
case "left":
|
|
4430
|
+
e = e.leftJoin(n.table, n.on);
|
|
4431
|
+
break;
|
|
4432
|
+
case "inner":
|
|
4433
|
+
e = e.innerJoin(n.table, n.on);
|
|
4434
|
+
break;
|
|
4435
|
+
case "right":
|
|
4436
|
+
e = e.rightJoin(n.table, n.on);
|
|
4437
|
+
break;
|
|
4438
|
+
case "full":
|
|
4439
|
+
e = e.fullJoin(n.table, n.on);
|
|
4440
|
+
break;
|
|
4441
|
+
}
|
|
4442
|
+
return e;
|
|
4443
|
+
}
|
|
4444
|
+
var wt = class {
|
|
4424
4445
|
constructor(e) {
|
|
4425
4446
|
this.queryBuilder = e;
|
|
4426
4447
|
}
|
|
@@ -4461,7 +4482,7 @@ var Q = class e {
|
|
|
4461
4482
|
}
|
|
4462
4483
|
if (Object.keys(c).length === 0) return null;
|
|
4463
4484
|
let f = n.db.select(c).from(o.from);
|
|
4464
|
-
if (s && e.intermediateJoins) {
|
|
4485
|
+
if (f = Ct(f, o), s && e.intermediateJoins) {
|
|
4465
4486
|
let t = [...e.intermediateJoins].reverse();
|
|
4466
4487
|
for (let e of t) {
|
|
4467
4488
|
let t = e.cube.sql(n), r = [M(e.cteJoinColumn, e.joinDef.on[0]?.target)];
|
|
@@ -4518,7 +4539,7 @@ var Q = class e {
|
|
|
4518
4539
|
if (t.dimensions) for (let e of t.dimensions) {
|
|
4519
4540
|
let [t, r] = e.split(".");
|
|
4520
4541
|
if (t === l && a.dimensions && a.dimensions[r]) {
|
|
4521
|
-
let e = a.dimensions[r], t =
|
|
4542
|
+
let e = a.dimensions[r], t = H(e.sql, n);
|
|
4522
4543
|
_.push(t);
|
|
4523
4544
|
}
|
|
4524
4545
|
}
|
|
@@ -4563,17 +4584,17 @@ var Q = class e {
|
|
|
4563
4584
|
if (i.length === 0) return null;
|
|
4564
4585
|
let a = i.length === 1 ? i[0] : P(...i), o = e.joinConditions;
|
|
4565
4586
|
if (o.length === 1) {
|
|
4566
|
-
let { source: e, target: n } = o[0];
|
|
4567
|
-
return
|
|
4587
|
+
let { source: e, target: n } = o[0], i = t.db.select({ pk: e }).from(r.from);
|
|
4588
|
+
return i = Ct(i, r), i = i.where(a), O`${n} IN ${i}`;
|
|
4568
4589
|
} else {
|
|
4569
|
-
let e = P(...o.map((e) => M(e.source, e.target)), a);
|
|
4570
|
-
return
|
|
4590
|
+
let e = P(...o.map((e) => M(e.source, e.target)), a), n = t.db.select({ one: O`1` }).from(r.from);
|
|
4591
|
+
return n = Ct(n, r), n = n.where(e), O`EXISTS ${n}`;
|
|
4571
4592
|
}
|
|
4572
4593
|
}
|
|
4573
4594
|
};
|
|
4574
4595
|
//#endregion
|
|
4575
4596
|
//#region src/shared/date-utils.ts
|
|
4576
|
-
function
|
|
4597
|
+
function Tt(e) {
|
|
4577
4598
|
let t = /* @__PURE__ */ new Date(), n = e.toLowerCase().trim(), r = t.getUTCFullYear(), i = t.getUTCMonth(), a = t.getUTCDate(), o = t.getUTCDay();
|
|
4578
4599
|
if (n === "today") {
|
|
4579
4600
|
let e = new Date(t);
|
|
@@ -4688,12 +4709,12 @@ function Ct(e) {
|
|
|
4688
4709
|
}
|
|
4689
4710
|
//#endregion
|
|
4690
4711
|
//#region src/server/gap-filler.ts
|
|
4691
|
-
function
|
|
4692
|
-
let r = [], i =
|
|
4693
|
-
for (; i <= a && r.length < 1e4;) r.push(new Date(i)), i =
|
|
4712
|
+
function Et(e, t, n) {
|
|
4713
|
+
let r = [], i = Dt(new Date(e), n), a = Dt(new Date(t), n);
|
|
4714
|
+
for (; i <= a && r.length < 1e4;) r.push(new Date(i)), i = Ot(i, n);
|
|
4694
4715
|
return r;
|
|
4695
4716
|
}
|
|
4696
|
-
function
|
|
4717
|
+
function Dt(e, t) {
|
|
4697
4718
|
let n = new Date(e);
|
|
4698
4719
|
switch (t) {
|
|
4699
4720
|
case "second":
|
|
@@ -4727,7 +4748,7 @@ function Tt(e, t) {
|
|
|
4727
4748
|
}
|
|
4728
4749
|
return n;
|
|
4729
4750
|
}
|
|
4730
|
-
function
|
|
4751
|
+
function Ot(e, t) {
|
|
4731
4752
|
let n = new Date(e);
|
|
4732
4753
|
switch (t) {
|
|
4733
4754
|
case "second":
|
|
@@ -4757,7 +4778,7 @@ function Et(e, t) {
|
|
|
4757
4778
|
}
|
|
4758
4779
|
return n;
|
|
4759
4780
|
}
|
|
4760
|
-
function
|
|
4781
|
+
function kt(e) {
|
|
4761
4782
|
if (e instanceof Date) return e.toISOString();
|
|
4762
4783
|
if (typeof e == "string") {
|
|
4763
4784
|
let t = new Date(e);
|
|
@@ -4765,15 +4786,15 @@ function Dt(e) {
|
|
|
4765
4786
|
}
|
|
4766
4787
|
return String(e);
|
|
4767
4788
|
}
|
|
4768
|
-
function
|
|
4789
|
+
function At(e, t) {
|
|
4769
4790
|
return t.length === 0 ? "__all__" : t.map((t) => String(e[t] ?? "")).join("|||");
|
|
4770
4791
|
}
|
|
4771
|
-
function
|
|
4772
|
-
let { timeDimensionKey: n, granularity: r, dateRange: i, fillValue: a, measures: o, dimensions: s } = t, c =
|
|
4792
|
+
function jt(e, t) {
|
|
4793
|
+
let { timeDimensionKey: n, granularity: r, dateRange: i, fillValue: a, measures: o, dimensions: s } = t, c = Et(i[0], i[1], r);
|
|
4773
4794
|
if (c.length === 0) return e;
|
|
4774
4795
|
let l = /* @__PURE__ */ new Map();
|
|
4775
4796
|
for (let t of e) {
|
|
4776
|
-
let e =
|
|
4797
|
+
let e = At(t, s), r = kt(t[n]);
|
|
4777
4798
|
l.has(e) || l.set(e, /* @__PURE__ */ new Map()), l.get(e).set(r, t);
|
|
4778
4799
|
}
|
|
4779
4800
|
l.size === 0 && s.length === 0 && l.set("__all__", /* @__PURE__ */ new Map());
|
|
@@ -4793,28 +4814,28 @@ function kt(e, t) {
|
|
|
4793
4814
|
}
|
|
4794
4815
|
return u;
|
|
4795
4816
|
}
|
|
4796
|
-
function
|
|
4817
|
+
function Q(e) {
|
|
4797
4818
|
if (!e) return null;
|
|
4798
4819
|
if (Array.isArray(e)) {
|
|
4799
4820
|
if (e.length < 2) return null;
|
|
4800
4821
|
let t = new Date(e[0]), n = new Date(e[1]);
|
|
4801
4822
|
return isNaN(t.getTime()) || isNaN(n.getTime()) ? null : [t, n];
|
|
4802
4823
|
}
|
|
4803
|
-
let t =
|
|
4824
|
+
let t = Tt(e);
|
|
4804
4825
|
if (t) return [t.start, t.end];
|
|
4805
4826
|
let n = new Date(e);
|
|
4806
4827
|
return isNaN(n.getTime()) ? null : [n, n];
|
|
4807
4828
|
}
|
|
4808
|
-
function
|
|
4829
|
+
function Mt(e, t, n) {
|
|
4809
4830
|
if (!t.timeDimensions || t.timeDimensions.length === 0) return e;
|
|
4810
4831
|
let r = t.timeDimensions.filter((e) => {
|
|
4811
|
-
let n = e.fillMissingDates !== !1, r = !!e.granularity, i = e.dateRange ||
|
|
4832
|
+
let n = e.fillMissingDates !== !1, r = !!e.granularity, i = e.dateRange || Nt(e.dimension, t.filters);
|
|
4812
4833
|
return n && r && i;
|
|
4813
4834
|
});
|
|
4814
4835
|
if (r.length === 0) return e;
|
|
4815
4836
|
let i = t.fillMissingDatesValue === void 0 ? 0 : t.fillMissingDatesValue, a = new Set(t.timeDimensions.map((e) => e.dimension)), o = (t.dimensions || []).filter((e) => !a.has(e)), s = e;
|
|
4816
4837
|
for (let e of r) {
|
|
4817
|
-
let r =
|
|
4838
|
+
let r = Q(e.dateRange) || Pt(e.dimension, t.filters);
|
|
4818
4839
|
if (!r) continue;
|
|
4819
4840
|
let a = {
|
|
4820
4841
|
timeDimensionKey: e.dimension,
|
|
@@ -4824,46 +4845,46 @@ function jt(e, t, n) {
|
|
|
4824
4845
|
measures: n,
|
|
4825
4846
|
dimensions: o
|
|
4826
4847
|
};
|
|
4827
|
-
s =
|
|
4848
|
+
s = jt(s, a);
|
|
4828
4849
|
}
|
|
4829
4850
|
return s;
|
|
4830
4851
|
}
|
|
4831
|
-
function
|
|
4852
|
+
function Nt(e, t) {
|
|
4832
4853
|
if (!t) return null;
|
|
4833
4854
|
for (let n of t) {
|
|
4834
4855
|
if ("member" in n && "operator" in n && n.member === e && n.operator === "inDateRange") return n;
|
|
4835
4856
|
if ("and" in n && n.and) {
|
|
4836
|
-
let t =
|
|
4857
|
+
let t = Nt(e, n.and);
|
|
4837
4858
|
if (t) return t;
|
|
4838
4859
|
}
|
|
4839
4860
|
if ("or" in n && n.or) {
|
|
4840
|
-
let t =
|
|
4861
|
+
let t = Nt(e, n.or);
|
|
4841
4862
|
if (t) return t;
|
|
4842
4863
|
}
|
|
4843
4864
|
}
|
|
4844
4865
|
return null;
|
|
4845
4866
|
}
|
|
4846
|
-
function
|
|
4847
|
-
let n =
|
|
4867
|
+
function Pt(e, t) {
|
|
4868
|
+
let n = Nt(e, t);
|
|
4848
4869
|
if (!n) return null;
|
|
4849
4870
|
if (n.dateRange) {
|
|
4850
|
-
let e =
|
|
4871
|
+
let e = Q(n.dateRange);
|
|
4851
4872
|
if (e) return e;
|
|
4852
4873
|
}
|
|
4853
4874
|
let r = n.values;
|
|
4854
4875
|
if (!r || r.length === 0) return null;
|
|
4855
4876
|
if (r.length === 1 && typeof r[0] == "string") {
|
|
4856
|
-
let e =
|
|
4857
|
-
return e ? [e.start, e.end] :
|
|
4877
|
+
let e = Tt(r[0]);
|
|
4878
|
+
return e ? [e.start, e.end] : Q(r);
|
|
4858
4879
|
}
|
|
4859
|
-
return r.length >= 2 ?
|
|
4880
|
+
return r.length >= 2 ? Q(r) : null;
|
|
4860
4881
|
}
|
|
4861
4882
|
//#endregion
|
|
4862
4883
|
//#region src/server/builders/comparison-query-builder.ts
|
|
4863
|
-
var
|
|
4884
|
+
var Ft = class {
|
|
4864
4885
|
dateTimeBuilder;
|
|
4865
4886
|
constructor(e) {
|
|
4866
|
-
this.dateTimeBuilder = new
|
|
4887
|
+
this.dateTimeBuilder = new q(e);
|
|
4867
4888
|
}
|
|
4868
4889
|
hasComparison(e) {
|
|
4869
4890
|
return e.timeDimensions?.some((e) => e.compareDateRange && e.compareDateRange.length >= 2) ?? !1;
|
|
@@ -4991,11 +5012,11 @@ var Pt = class {
|
|
|
4991
5012
|
return typeof i == "string" && typeof a == "string" ? new Date(i).getTime() - new Date(a).getTime() : 0;
|
|
4992
5013
|
});
|
|
4993
5014
|
}
|
|
4994
|
-
},
|
|
5015
|
+
}, It = class {
|
|
4995
5016
|
filterBuilder;
|
|
4996
5017
|
dateTimeBuilder;
|
|
4997
5018
|
constructor(e) {
|
|
4998
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
5019
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new q(e), this.filterBuilder = new J(e, this.dateTimeBuilder);
|
|
4999
5020
|
}
|
|
5000
5021
|
hasFunnel(e) {
|
|
5001
5022
|
return e.funnel !== void 0 && e.funnel.steps.length >= 2;
|
|
@@ -5042,7 +5063,7 @@ var Pt = class {
|
|
|
5042
5063
|
}))), a.filter) {
|
|
5043
5064
|
let o;
|
|
5044
5065
|
"cube" in a && a.cube ? o = a.cube : typeof t.bindingKey == "string" && ([o] = t.bindingKey.split("."));
|
|
5045
|
-
let s = o ? new
|
|
5066
|
+
let s = o ? new Z(n) : null, c = Array.isArray(a.filter) ? a.filter : [a.filter];
|
|
5046
5067
|
for (let t of c) if ("member" in t) {
|
|
5047
5068
|
let [a, c] = t.member.split("."), l = n.get(a);
|
|
5048
5069
|
if (!l) r.push(e("server.validation.funnel.stepFilterCubeNotFound", {
|
|
@@ -5122,7 +5143,7 @@ var Pt = class {
|
|
|
5122
5143
|
return t;
|
|
5123
5144
|
}
|
|
5124
5145
|
resolveSteps(e, t, n) {
|
|
5125
|
-
let r = new
|
|
5146
|
+
let r = new Z(t);
|
|
5126
5147
|
return e.steps.map((i, a) => {
|
|
5127
5148
|
let o = this.resolveCubeForStep(i, e, t), s = this.resolveBindingKey(e, o, n), c = this.resolveTimeDimension(e, o, n), l = this.buildStepFilters(i, o, t, n), u = this.extractFilterCubeNames(i), d = [];
|
|
5128
5149
|
for (let e of u) if (e !== o.name) {
|
|
@@ -5164,25 +5185,25 @@ var Pt = class {
|
|
|
5164
5185
|
if (typeof t.bindingKey == "string") {
|
|
5165
5186
|
let [, i] = t.bindingKey.split("."), a = n.dimensions?.[i];
|
|
5166
5187
|
if (!a) throw Error(e("server.errors.funnel.bindingKeyDimNotFound", { bindingKey: t.bindingKey }));
|
|
5167
|
-
return
|
|
5188
|
+
return H(a.sql, r);
|
|
5168
5189
|
}
|
|
5169
5190
|
let i = t.bindingKey.find((e) => e.cube === n.name);
|
|
5170
5191
|
if (!i) throw Error(e("server.errors.funnel.noBindingKeyMapping", { cubeName: n.name }));
|
|
5171
5192
|
let [, a] = i.dimension.split("."), o = n.dimensions?.[a];
|
|
5172
5193
|
if (!o) throw Error(e("server.errors.funnel.bindingKeyMappingDimNotFound", { dimension: i.dimension }));
|
|
5173
|
-
return
|
|
5194
|
+
return H(o.sql, r);
|
|
5174
5195
|
}
|
|
5175
5196
|
resolveTimeDimension(t, n, r) {
|
|
5176
5197
|
if (typeof t.timeDimension == "string") {
|
|
5177
5198
|
let [, i] = t.timeDimension.split("."), a = n.dimensions?.[i];
|
|
5178
5199
|
if (!a) throw Error(e("server.errors.funnel.timeDimNotFound", { timeDimension: t.timeDimension }));
|
|
5179
|
-
return
|
|
5200
|
+
return H(a.sql, r);
|
|
5180
5201
|
}
|
|
5181
5202
|
let i = t.timeDimension.find((e) => e.cube === n.name);
|
|
5182
5203
|
if (!i) throw Error(e("server.errors.funnel.noTimeDimMapping", { cubeName: n.name }));
|
|
5183
5204
|
let [, a] = i.dimension.split("."), o = n.dimensions?.[a];
|
|
5184
5205
|
if (!o) throw Error(e("server.errors.funnel.timeDimMappingNotFound", { dimension: i.dimension }));
|
|
5185
|
-
return
|
|
5206
|
+
return H(o.sql, r);
|
|
5186
5207
|
}
|
|
5187
5208
|
buildStepFilters(e, t, n, r) {
|
|
5188
5209
|
if (!e.filter) return [];
|
|
@@ -5220,12 +5241,12 @@ var Pt = class {
|
|
|
5220
5241
|
let u = n.get(s);
|
|
5221
5242
|
if (!u) return null;
|
|
5222
5243
|
if (s !== t.name) {
|
|
5223
|
-
let e = new
|
|
5244
|
+
let e = new Z(n).findPath(t.name, s);
|
|
5224
5245
|
if (!e || e.length === 0) return console.warn(`Funnel filter: Cannot filter by '${String(s).replace(/\n|\r/g, "")}.${String(c).replace(/\n|\r/g, "")}' in step using '${String(t.name).replace(/\n|\r/g, "")}'. No join path found. Filter will be skipped.`), null;
|
|
5225
5246
|
}
|
|
5226
5247
|
let d = u.dimensions?.[c];
|
|
5227
5248
|
if (!d) return null;
|
|
5228
|
-
let f = d.type === "time" ?
|
|
5249
|
+
let f = d.type === "time" ? H(d.sql, r) : typeof d.sql == "function" ? d.sql(r) : d.sql;
|
|
5229
5250
|
return this.filterBuilder.buildFilterCondition(f, o.operator, o.values || [], d, o.dateRange);
|
|
5230
5251
|
}
|
|
5231
5252
|
buildStepCTE(e, t, n) {
|
|
@@ -5301,12 +5322,12 @@ var Pt = class {
|
|
|
5301
5322
|
let o = i.db.select(a).from(e);
|
|
5302
5323
|
return i.db.$with("funnel_metrics").as(o);
|
|
5303
5324
|
}
|
|
5304
|
-
},
|
|
5325
|
+
}, Lt = class {
|
|
5305
5326
|
filterBuilder;
|
|
5306
5327
|
dateTimeBuilder;
|
|
5307
5328
|
databaseAdapter;
|
|
5308
5329
|
constructor(e) {
|
|
5309
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
5330
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new q(e), this.filterBuilder = new J(e, this.dateTimeBuilder);
|
|
5310
5331
|
}
|
|
5311
5332
|
hasFlow(e) {
|
|
5312
5333
|
return e.flow !== void 0 && e.flow.startingStep !== void 0 && e.flow.eventDimension !== void 0;
|
|
@@ -5439,30 +5460,30 @@ var Pt = class {
|
|
|
5439
5460
|
if (typeof t.bindingKey == "string") {
|
|
5440
5461
|
let [, i] = t.bindingKey.split("."), a = n.dimensions?.[i];
|
|
5441
5462
|
if (!a) throw Error(e("server.errors.flow.bindingKeyDimNotFound", { bindingKey: t.bindingKey }));
|
|
5442
|
-
return
|
|
5463
|
+
return H(a.sql, r);
|
|
5443
5464
|
}
|
|
5444
5465
|
let i = t.bindingKey.find((e) => e.cube === n.name);
|
|
5445
5466
|
if (!i) throw Error(e("server.errors.flow.noBindingKeyMapping", { cubeName: n.name }));
|
|
5446
5467
|
let [, a] = i.dimension.split("."), o = n.dimensions?.[a];
|
|
5447
5468
|
if (!o) throw Error(e("server.errors.flow.bindingKeyMappingDimNotFound", { dimension: i.dimension }));
|
|
5448
|
-
return
|
|
5469
|
+
return H(o.sql, r);
|
|
5449
5470
|
}
|
|
5450
5471
|
resolveTimeDimension(t, n, r) {
|
|
5451
5472
|
if (typeof t.timeDimension == "string") {
|
|
5452
5473
|
let [, i] = t.timeDimension.split("."), a = n.dimensions?.[i];
|
|
5453
5474
|
if (!a) throw Error(e("server.errors.flow.timeDimNotFound", { timeDimension: t.timeDimension }));
|
|
5454
|
-
return
|
|
5475
|
+
return H(a.sql, r);
|
|
5455
5476
|
}
|
|
5456
5477
|
let i = t.timeDimension.find((e) => e.cube === n.name);
|
|
5457
5478
|
if (!i) throw Error(e("server.errors.flow.noTimeDimMapping", { cubeName: n.name }));
|
|
5458
5479
|
let [, a] = i.dimension.split("."), o = n.dimensions?.[a];
|
|
5459
5480
|
if (!o) throw Error(e("server.errors.flow.timeDimMappingNotFound", { dimension: i.dimension }));
|
|
5460
|
-
return
|
|
5481
|
+
return H(o.sql, r);
|
|
5461
5482
|
}
|
|
5462
5483
|
resolveEventDimension(t, n, r) {
|
|
5463
5484
|
let [, i] = t.eventDimension.split("."), a = n.dimensions?.[i];
|
|
5464
5485
|
if (!a) throw Error(e("server.errors.flow.eventDimNotFound", { eventDimension: t.eventDimension }));
|
|
5465
|
-
return
|
|
5486
|
+
return H(a.sql, r);
|
|
5466
5487
|
}
|
|
5467
5488
|
buildStartingStepFilters(e, t, n) {
|
|
5468
5489
|
if (!e.startingStep.filter) return [];
|
|
@@ -5492,7 +5513,7 @@ var Pt = class {
|
|
|
5492
5513
|
}
|
|
5493
5514
|
let r = e, [, i] = r.member.split("."), a = t.dimensions?.[i];
|
|
5494
5515
|
if (!a) return null;
|
|
5495
|
-
let o = a.type === "time" ?
|
|
5516
|
+
let o = a.type === "time" ? H(a.sql, n) : typeof a.sql == "function" ? a.sql(n) : a.sql;
|
|
5496
5517
|
return this.filterBuilder.buildFilterCondition(o, r.operator, r.values || [], a, r.dateRange);
|
|
5497
5518
|
}
|
|
5498
5519
|
buildStartingEntitiesCTE(e, t, n) {
|
|
@@ -5777,31 +5798,31 @@ var Pt = class {
|
|
|
5777
5798
|
};
|
|
5778
5799
|
//#endregion
|
|
5779
5800
|
//#region src/server/types/retention.ts
|
|
5780
|
-
function
|
|
5801
|
+
function Rt(e) {
|
|
5781
5802
|
return Array.isArray(e);
|
|
5782
5803
|
}
|
|
5783
|
-
function
|
|
5804
|
+
function zt(e) {
|
|
5784
5805
|
return typeof e == "object" && !!e && "cube" in e;
|
|
5785
5806
|
}
|
|
5786
|
-
function
|
|
5787
|
-
if (
|
|
5807
|
+
function Bt(e) {
|
|
5808
|
+
if (zt(e)) return e.cube;
|
|
5788
5809
|
let t = e.indexOf(".");
|
|
5789
5810
|
if (t === -1) throw Error(`Invalid time dimension format: ${e}. Expected 'CubeName.dimensionName'`);
|
|
5790
5811
|
return e.substring(0, t);
|
|
5791
5812
|
}
|
|
5792
|
-
function
|
|
5793
|
-
if (
|
|
5813
|
+
function Vt(e) {
|
|
5814
|
+
if (zt(e)) return e.dimension;
|
|
5794
5815
|
let t = e.indexOf(".");
|
|
5795
5816
|
if (t === -1) throw Error(`Invalid time dimension format: ${e}. Expected 'CubeName.dimensionName'`);
|
|
5796
5817
|
return e.substring(t + 1);
|
|
5797
5818
|
}
|
|
5798
5819
|
//#endregion
|
|
5799
5820
|
//#region src/server/builders/retention-query-builder.ts
|
|
5800
|
-
var
|
|
5821
|
+
var Ht = class {
|
|
5801
5822
|
filterBuilder;
|
|
5802
5823
|
dateTimeBuilder;
|
|
5803
5824
|
constructor(e) {
|
|
5804
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
5825
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new q(e), this.filterBuilder = new J(e, this.dateTimeBuilder);
|
|
5805
5826
|
}
|
|
5806
5827
|
hasRetention(e) {
|
|
5807
5828
|
return e.retention !== void 0 && e.retention.timeDimension != null && e.retention.bindingKey != null;
|
|
@@ -5809,12 +5830,12 @@ var Vt = class {
|
|
|
5809
5830
|
validateConfig(t, n) {
|
|
5810
5831
|
let r = [];
|
|
5811
5832
|
try {
|
|
5812
|
-
let i =
|
|
5833
|
+
let i = Bt(t.timeDimension), a = Vt(t.timeDimension), o = n.get(i);
|
|
5813
5834
|
o ? o.dimensions?.[a] || r.push(e("server.validation.retention.timeDimNotFound", { dimName: a })) : r.push(e("server.validation.retention.cubeNotFound", { cubeName: i }));
|
|
5814
5835
|
} catch {
|
|
5815
5836
|
r.push(e("server.validation.retention.invalidTimeDimFormat", { timeDimension: t.timeDimension }));
|
|
5816
5837
|
}
|
|
5817
|
-
if (
|
|
5838
|
+
if (Rt(t.bindingKey)) for (let i of t.bindingKey) {
|
|
5818
5839
|
let t = n.get(i.cube);
|
|
5819
5840
|
if (!t) r.push(e("server.validation.retention.bindingKeyMappingCubeNotFound", { cubeName: i.cube }));
|
|
5820
5841
|
else {
|
|
@@ -5911,15 +5932,15 @@ var Vt = class {
|
|
|
5911
5932
|
});
|
|
5912
5933
|
}
|
|
5913
5934
|
resolveConfig(t, n, r) {
|
|
5914
|
-
let i =
|
|
5935
|
+
let i = Bt(t.timeDimension), a = Vt(t.timeDimension), o = n.get(i);
|
|
5915
5936
|
if (!o) throw Error(e("server.validation.retention.cubeNotFound", { cubeName: i }));
|
|
5916
5937
|
let s = o.dimensions?.[a];
|
|
5917
5938
|
if (!s) throw Error(e("server.validation.retention.timeDimNotFound", { dimName: a }));
|
|
5918
|
-
let c =
|
|
5939
|
+
let c = H(s.sql, r), l = this.resolveBindingKey(t.bindingKey, o, n, r), u = this.buildFilterConditions(t.cohortFilters, o, n, r), d = this.buildFilterConditions(t.activityFilters, o, n, r), f = [];
|
|
5919
5940
|
if (t.breakdownDimensions && t.breakdownDimensions.length > 0) for (let e of t.breakdownDimensions) {
|
|
5920
5941
|
let [t, i] = e.split("."), a = n.get(t);
|
|
5921
5942
|
if (a && a.dimensions?.[i]) {
|
|
5922
|
-
let t =
|
|
5943
|
+
let t = H(a.dimensions[i].sql, r);
|
|
5923
5944
|
f.push({
|
|
5924
5945
|
dimension: e,
|
|
5925
5946
|
expr: t
|
|
@@ -5936,7 +5957,7 @@ var Vt = class {
|
|
|
5936
5957
|
};
|
|
5937
5958
|
}
|
|
5938
5959
|
resolveBindingKey(t, n, r, i) {
|
|
5939
|
-
if (
|
|
5960
|
+
if (Rt(t)) {
|
|
5940
5961
|
let a = t.find((e) => e.cube === n.name);
|
|
5941
5962
|
if (!a) throw Error(e("server.validation.retention.noBindingKeyMapping", { cubeName: n.name }));
|
|
5942
5963
|
let o = this.extractDimensionName(a.dimension), s = r.get(a.cube);
|
|
@@ -5946,7 +5967,7 @@ var Vt = class {
|
|
|
5946
5967
|
dimName: a.dimension,
|
|
5947
5968
|
cubeName: a.cube
|
|
5948
5969
|
}));
|
|
5949
|
-
return
|
|
5970
|
+
return H(c.sql, i);
|
|
5950
5971
|
}
|
|
5951
5972
|
let [a, o] = t.split("."), s = r.get(a);
|
|
5952
5973
|
if (!s) throw Error(e("server.validation.retention.bindingKeyCubeNotFound", { cubeName: a }));
|
|
@@ -5955,7 +5976,7 @@ var Vt = class {
|
|
|
5955
5976
|
dimName: t,
|
|
5956
5977
|
cubeName: a
|
|
5957
5978
|
}));
|
|
5958
|
-
return
|
|
5979
|
+
return H(c.sql, i);
|
|
5959
5980
|
}
|
|
5960
5981
|
buildFilterConditions(e, t, n, r) {
|
|
5961
5982
|
if (!e) return [];
|
|
@@ -5979,7 +6000,7 @@ var Vt = class {
|
|
|
5979
6000
|
if (!s) return null;
|
|
5980
6001
|
let c = s.dimensions?.[o];
|
|
5981
6002
|
if (!c) return null;
|
|
5982
|
-
let l = c.type === "time" ?
|
|
6003
|
+
let l = c.type === "time" ? H(c.sql, r) : typeof c.sql == "function" ? c.sql(r) : c.sql;
|
|
5983
6004
|
return this.filterBuilder.buildFilterCondition(l, i.operator, i.values || [], c, i.dateRange);
|
|
5984
6005
|
}
|
|
5985
6006
|
buildCohortBaseCTE(e, t, n) {
|
|
@@ -6081,7 +6102,7 @@ var Vt = class {
|
|
|
6081
6102
|
let t = e.split(".");
|
|
6082
6103
|
return t.length > 1 ? t[1] : t[0];
|
|
6083
6104
|
}
|
|
6084
|
-
},
|
|
6105
|
+
}, Ut = class {
|
|
6085
6106
|
constructor(e) {
|
|
6086
6107
|
this.queryPlanner = e;
|
|
6087
6108
|
}
|
|
@@ -6098,7 +6119,7 @@ var Vt = class {
|
|
|
6098
6119
|
let n = t.get(e);
|
|
6099
6120
|
n && g.set(e, n);
|
|
6100
6121
|
}
|
|
6101
|
-
let _ =
|
|
6122
|
+
let _ = X.hasPostAggregationWindows(n.measures ?? [], g), v = [...c.filter((e) => !e.pathFound && e.error).map((e) => e.error), ...d.map((e) => e.message)];
|
|
6102
6123
|
return {
|
|
6103
6124
|
plan: m,
|
|
6104
6125
|
analysis: {
|
|
@@ -6281,7 +6302,7 @@ var Vt = class {
|
|
|
6281
6302
|
hasDirectJoinToSharedDimension(e, t, n) {
|
|
6282
6303
|
if (!e?.joins) return !1;
|
|
6283
6304
|
for (let [, r] of Object.entries(e.joins)) {
|
|
6284
|
-
let e =
|
|
6305
|
+
let e = V(r.targetCube, n);
|
|
6285
6306
|
if (!(!e || e.name !== t) && (r.relationship === "belongsTo" || r.relationship === "hasOne")) return !0;
|
|
6286
6307
|
}
|
|
6287
6308
|
return !1;
|
|
@@ -6525,7 +6546,7 @@ var Vt = class {
|
|
|
6525
6546
|
timeDimensions: []
|
|
6526
6547
|
};
|
|
6527
6548
|
}
|
|
6528
|
-
},
|
|
6549
|
+
}, Wt = class {
|
|
6529
6550
|
name = "identity";
|
|
6530
6551
|
optimise(e) {
|
|
6531
6552
|
return e;
|
|
@@ -6533,7 +6554,7 @@ var Vt = class {
|
|
|
6533
6554
|
};
|
|
6534
6555
|
//#endregion
|
|
6535
6556
|
//#region src/server/physical-plan/processors/cte-processor.ts
|
|
6536
|
-
function
|
|
6557
|
+
function Gt(e, t, n, r) {
|
|
6537
6558
|
let i = /* @__PURE__ */ new Map();
|
|
6538
6559
|
if (e.preAggregationCTEs && e.preAggregationCTEs.length > 0) {
|
|
6539
6560
|
for (let t of e.preAggregationCTEs) if (t.propagatingFilters && t.propagatingFilters.length > 0) for (let e of t.propagatingFilters) {
|
|
@@ -6563,23 +6584,23 @@ function Wt(e, t, n, r) {
|
|
|
6563
6584
|
}
|
|
6564
6585
|
//#endregion
|
|
6565
6586
|
//#region src/server/physical-plan/processors/window-processor.ts
|
|
6566
|
-
function
|
|
6587
|
+
function Kt(e, t, n, r, i, a) {
|
|
6567
6588
|
if (n.measures) for (let o of n.measures) {
|
|
6568
6589
|
let [s, c] = o.split("."), l = i.get(s);
|
|
6569
6590
|
if (!l?.measures?.[c]) continue;
|
|
6570
6591
|
let u = l.measures[c];
|
|
6571
|
-
if (!
|
|
6572
|
-
let d =
|
|
6592
|
+
if (!X.isPostAggregationWindow(u)) continue;
|
|
6593
|
+
let d = X.getWindowBaseMeasure(u, s);
|
|
6573
6594
|
if (!d) continue;
|
|
6574
6595
|
let [f, p] = d.split("."), m = i.get(f);
|
|
6575
6596
|
if (!m?.measures?.[p]) continue;
|
|
6576
6597
|
let h = m.measures[p], g = t.preAggregationCTEs?.find((e) => e.cube?.name === f && e.measures?.includes(d)), _;
|
|
6577
6598
|
_ = g ? O`sum(${O`${O.identifier(g.cteAlias)}.${O.identifier(p)}`})` : a.queryBuilder.buildMeasureExpression(h, r, m), e[d] || (e[d] = O`${_}`.as(d));
|
|
6578
|
-
let v =
|
|
6599
|
+
let v = qt(u, _, n, r, l, t, a);
|
|
6579
6600
|
v && (e[o] = O`${v}`.as(o));
|
|
6580
6601
|
}
|
|
6581
6602
|
}
|
|
6582
|
-
function
|
|
6603
|
+
function qt(e, t, n, r, i, a, o) {
|
|
6583
6604
|
let s = e.windowConfig || {}, c = (e, t) => {
|
|
6584
6605
|
if (!a.preAggregationCTEs) return null;
|
|
6585
6606
|
let n = a.preAggregationCTEs.find((t) => t.cube?.name === e);
|
|
@@ -6604,7 +6625,7 @@ function Kt(e, t, n, r, i, a, o) {
|
|
|
6604
6625
|
}
|
|
6605
6626
|
let l = i.dimensions?.[a];
|
|
6606
6627
|
return l ? {
|
|
6607
|
-
field:
|
|
6628
|
+
field: H(l.sql, r),
|
|
6608
6629
|
direction: e.direction
|
|
6609
6630
|
} : a === (s.measure?.includes(".") ? s.measure.split(".")[1] : s.measure) || e.field === s.measure ? {
|
|
6610
6631
|
field: t,
|
|
@@ -6631,7 +6652,7 @@ function Kt(e, t, n, r, i, a, o) {
|
|
|
6631
6652
|
let u;
|
|
6632
6653
|
s.partitionBy && s.partitionBy.length > 0 && (u = s.partitionBy.map((e) => {
|
|
6633
6654
|
let t = e.includes(".") ? e.split(".")[1] : e, n = i.dimensions?.[t];
|
|
6634
|
-
return n ?
|
|
6655
|
+
return n ? H(n.sql, r) : null;
|
|
6635
6656
|
}).filter((e) => e !== null));
|
|
6636
6657
|
let d = o.databaseAdapter.buildWindowFunction(e.type, t, u, l, {
|
|
6637
6658
|
offset: s.offset,
|
|
@@ -6640,7 +6661,7 @@ function Kt(e, t, n, r, i, a, o) {
|
|
|
6640
6661
|
frame: s.frame
|
|
6641
6662
|
});
|
|
6642
6663
|
if (!d) return null;
|
|
6643
|
-
switch (s.operation ||
|
|
6664
|
+
switch (s.operation || X.getDefaultWindowOperation(e.type)) {
|
|
6644
6665
|
case "difference": return O`${t} - ${d}`;
|
|
6645
6666
|
case "ratio": return O`${t} / NULLIF(${d}, 0)`;
|
|
6646
6667
|
case "percentChange": return O`((${t} - ${d}) / NULLIF(${d}, 0)) * 100`;
|
|
@@ -6649,7 +6670,7 @@ function Kt(e, t, n, r, i, a, o) {
|
|
|
6649
6670
|
}
|
|
6650
6671
|
//#endregion
|
|
6651
6672
|
//#region src/server/physical-plan/processors/selection-processor.ts
|
|
6652
|
-
function
|
|
6673
|
+
function Jt(e, t, n, r, i) {
|
|
6653
6674
|
let a = { ...i.queryBuilder.buildSelections(e.joinCubes.length > 0 ? r : e.primaryCube, t, n) };
|
|
6654
6675
|
if (e.preAggregationCTEs) for (let o of e.preAggregationCTEs) {
|
|
6655
6676
|
let e = o.cube.name;
|
|
@@ -6660,26 +6681,26 @@ function qt(e, t, n, r, i) {
|
|
|
6660
6681
|
let u = l.measures[c], d = O`${O.identifier(o.cteAlias)}.${O.identifier(c)}`, f;
|
|
6661
6682
|
if (u.type === "calculated" && u.calculatedSql) f = i.queryBuilder.buildCTECalculatedMeasure(u, l, o, r, n);
|
|
6662
6683
|
else {
|
|
6663
|
-
let e = o.cteReason === "fanOutPrevention", n =
|
|
6684
|
+
let e = o.cteReason === "fanOutPrevention", n = Yt(o, t, r), a = e || n;
|
|
6664
6685
|
switch (u.type) {
|
|
6665
6686
|
case "count":
|
|
6666
6687
|
case "countDistinct":
|
|
6667
6688
|
case "sum":
|
|
6668
|
-
f = a ?
|
|
6689
|
+
f = a ? R(d) : L(d);
|
|
6669
6690
|
break;
|
|
6670
6691
|
case "avg":
|
|
6671
|
-
f = a ?
|
|
6692
|
+
f = a ? R(d) : i.databaseAdapter.buildAvg(d);
|
|
6672
6693
|
break;
|
|
6673
6694
|
case "min":
|
|
6674
|
-
f =
|
|
6695
|
+
f = ge(d);
|
|
6675
6696
|
break;
|
|
6676
6697
|
case "max":
|
|
6677
|
-
f =
|
|
6698
|
+
f = R(d);
|
|
6678
6699
|
break;
|
|
6679
6700
|
case "number":
|
|
6680
|
-
f =
|
|
6701
|
+
f = R(d);
|
|
6681
6702
|
break;
|
|
6682
|
-
default: f = a ?
|
|
6703
|
+
default: f = a ? R(d) : L(d);
|
|
6683
6704
|
}
|
|
6684
6705
|
}
|
|
6685
6706
|
a[s] = O`${f}`.as(s);
|
|
@@ -6697,12 +6718,12 @@ function qt(e, t, n, r, i) {
|
|
|
6697
6718
|
(u || l && s?.dimensions?.[i]) && (a[t] = O`${O.identifier(o.cteAlias)}.${O.identifier(i)}`.as(t));
|
|
6698
6719
|
}
|
|
6699
6720
|
}
|
|
6700
|
-
return
|
|
6701
|
-
}
|
|
6702
|
-
function Jt(e, t, n) {
|
|
6703
|
-
return e.cteReason !== "hasMany" || e.downstreamJoinKeys && e.downstreamJoinKeys.length > 0 || e.intermediateJoins && e.intermediateJoins.length > 0 || !(t.dimensions && t.dimensions.length > 0 || t.timeDimensions && t.timeDimensions.length > 0) || t.dimensions?.some((t) => t.startsWith(`${e.cube.name}.`)) || t.timeDimensions?.some((t) => t.dimension.startsWith(`${e.cube.name}.`)) ? !1 : e.joinKeys.length > 0 && e.joinKeys.every((e) => !!e.sourceColumnObj && Yt(e.sourceColumnObj, t, n));
|
|
6721
|
+
return Kt(a, e, t, n, r, i), a;
|
|
6704
6722
|
}
|
|
6705
6723
|
function Yt(e, t, n) {
|
|
6724
|
+
return e.cteReason !== "hasMany" || e.downstreamJoinKeys && e.downstreamJoinKeys.length > 0 || e.intermediateJoins && e.intermediateJoins.length > 0 || !(t.dimensions && t.dimensions.length > 0 || t.timeDimensions && t.timeDimensions.length > 0) || t.dimensions?.some((t) => t.startsWith(`${e.cube.name}.`)) || t.timeDimensions?.some((t) => t.dimension.startsWith(`${e.cube.name}.`)) ? !1 : e.joinKeys.length > 0 && e.joinKeys.every((e) => !!e.sourceColumnObj && Xt(e.sourceColumnObj, t, n));
|
|
6725
|
+
}
|
|
6726
|
+
function Xt(e, t, n) {
|
|
6706
6727
|
if (t.dimensions) for (let r of t.dimensions) {
|
|
6707
6728
|
let [t, i] = r.split(".");
|
|
6708
6729
|
if (n.get(t)?.dimensions?.[i]?.sql === e) return !0;
|
|
@@ -6716,7 +6737,7 @@ function Yt(e, t, n) {
|
|
|
6716
6737
|
}
|
|
6717
6738
|
//#endregion
|
|
6718
6739
|
//#region src/server/physical-plan/processors/joins-processor.ts
|
|
6719
|
-
function
|
|
6740
|
+
function Zt(e, t, n, r, i, a) {
|
|
6720
6741
|
let o = [], s = t.db.select(r).from(n.from);
|
|
6721
6742
|
if (i.ctes.length > 0 && (s = t.db.with(...i.ctes).select(r).from(n.from)), n.joins) for (let e of n.joins) switch (e.type || "left") {
|
|
6722
6743
|
case "left":
|
|
@@ -6776,11 +6797,11 @@ function Xt(e, t, n, r, i, a) {
|
|
|
6776
6797
|
l.length > 0 && o.push(...l);
|
|
6777
6798
|
} catch {}
|
|
6778
6799
|
}
|
|
6779
|
-
let d, f, p;
|
|
6800
|
+
let d, f, p, m;
|
|
6780
6801
|
if (u) d = O`${O.identifier(u)}`, f = a.cteBuilder.buildCTEJoinCondition(n, u, e), p = void 0;
|
|
6781
6802
|
else {
|
|
6782
|
-
let e = i.downstreamCubeMap.get(n.cube.name)
|
|
6783
|
-
if (d =
|
|
6803
|
+
let e = i.downstreamCubeMap.get(n.cube.name);
|
|
6804
|
+
if (m = n.cube.sql(t), d = m.from, p = m.where, e && !n.junctionTable) {
|
|
6784
6805
|
let t = [];
|
|
6785
6806
|
for (let n of e.joinKeys) {
|
|
6786
6807
|
let r = O`${O.identifier(e.cteAlias)}.${O.identifier(n.sourceColumn)}`, i = n.targetColumnObj || O.identifier(n.targetColumn);
|
|
@@ -6789,20 +6810,34 @@ function Xt(e, t, n, r, i, a) {
|
|
|
6789
6810
|
f = t.length === 1 ? t[0] : P(...t);
|
|
6790
6811
|
} else f = n.joinCondition;
|
|
6791
6812
|
}
|
|
6792
|
-
let
|
|
6813
|
+
let h = n.joinType || "left", g = h !== "inner" && p ? P(f, p) : f;
|
|
6793
6814
|
try {
|
|
6794
|
-
switch (
|
|
6815
|
+
switch (h) {
|
|
6795
6816
|
case "left":
|
|
6796
|
-
s = s.leftJoin(d,
|
|
6817
|
+
s = s.leftJoin(d, g), p && c.add(n.cube.name);
|
|
6797
6818
|
break;
|
|
6798
6819
|
case "inner":
|
|
6799
6820
|
s = s.innerJoin(d, f);
|
|
6800
6821
|
break;
|
|
6801
6822
|
case "right":
|
|
6802
|
-
s = s.rightJoin(d,
|
|
6823
|
+
s = s.rightJoin(d, g), p && c.add(n.cube.name);
|
|
6803
6824
|
break;
|
|
6804
6825
|
case "full":
|
|
6805
|
-
s = s.fullJoin(d,
|
|
6826
|
+
s = s.fullJoin(d, g), p && c.add(n.cube.name);
|
|
6827
|
+
break;
|
|
6828
|
+
}
|
|
6829
|
+
if (m?.joins) for (let e of m.joins) switch (e.type || "left") {
|
|
6830
|
+
case "left":
|
|
6831
|
+
s = s.leftJoin(e.table, e.on);
|
|
6832
|
+
break;
|
|
6833
|
+
case "inner":
|
|
6834
|
+
s = s.innerJoin(e.table, e.on);
|
|
6835
|
+
break;
|
|
6836
|
+
case "right":
|
|
6837
|
+
s = s.rightJoin(e.table, e.on);
|
|
6838
|
+
break;
|
|
6839
|
+
case "full":
|
|
6840
|
+
s = s.fullJoin(e.table, e.on);
|
|
6806
6841
|
break;
|
|
6807
6842
|
}
|
|
6808
6843
|
} catch {}
|
|
@@ -6816,7 +6851,7 @@ function Xt(e, t, n, r, i, a) {
|
|
|
6816
6851
|
}
|
|
6817
6852
|
//#endregion
|
|
6818
6853
|
//#region src/server/physical-plan/processors/predicates-processor.ts
|
|
6819
|
-
function
|
|
6854
|
+
function Qt(e, t, n, r, i, a, o, s) {
|
|
6820
6855
|
let c = [...o.allWhereConditions];
|
|
6821
6856
|
if (i.where && c.push(i.where), e.joinCubes && e.joinCubes.length > 0) for (let t of e.joinCubes) {
|
|
6822
6857
|
let e = t.cube.name;
|
|
@@ -6844,14 +6879,14 @@ function Zt(e, t, n, r, i, a, o, s) {
|
|
|
6844
6879
|
}
|
|
6845
6880
|
//#endregion
|
|
6846
6881
|
//#region src/server/physical-plan/processors/shared.ts
|
|
6847
|
-
function
|
|
6882
|
+
function $t(e) {
|
|
6848
6883
|
let t = /* @__PURE__ */ new Map();
|
|
6849
6884
|
if (t.set(e.primaryCube.name, e.primaryCube), e.joinCubes) for (let n of e.joinCubes) t.set(n.cube.name, n.cube);
|
|
6850
6885
|
return t;
|
|
6851
6886
|
}
|
|
6852
6887
|
//#endregion
|
|
6853
6888
|
//#region src/server/physical-plan/drizzle-plan-builder.ts
|
|
6854
|
-
var
|
|
6889
|
+
var en = class {
|
|
6855
6890
|
constructor(e, t, n) {
|
|
6856
6891
|
this.queryBuilder = e, this.cteBuilder = t, this.databaseAdapter = n;
|
|
6857
6892
|
}
|
|
@@ -6991,13 +7026,13 @@ var $t = class {
|
|
|
6991
7026
|
if (i) return i;
|
|
6992
7027
|
let a = this.tryBuildKeysDeduplicationQuery(e, t, n, r);
|
|
6993
7028
|
if (a) return a;
|
|
6994
|
-
let o =
|
|
6995
|
-
return
|
|
7029
|
+
let o = Gt(e, t, n, r), s = e.primaryCube.sql(n), c = e.joinCubes.length > 0 ? $t(e) : new Map([[e.primaryCube.name, e.primaryCube]]);
|
|
7030
|
+
return Qt(e, t, n, c, s, o, Zt(e, n, s, Jt(e, t, n, c, r), o, r), r);
|
|
6996
7031
|
}
|
|
6997
7032
|
tryBuildKeysDeduplicationQuery(e, t, n, r) {
|
|
6998
7033
|
let i = e.keysDeduplication;
|
|
6999
7034
|
if (!i?.multipliedCubeName || !t.measures?.length) return null;
|
|
7000
|
-
let a = e.joinCubes.length > 0 ?
|
|
7035
|
+
let a = e.joinCubes.length > 0 ? $t(e) : new Map([[e.primaryCube.name, e.primaryCube]]), o = a.get(i.multipliedCubeName);
|
|
7001
7036
|
if (!o || !this.canExecuteKeysDeduplication(t, o, i.multipliedCubeName)) return null;
|
|
7002
7037
|
let s = i.primaryKeyDimensions.length > 0 ? i.primaryKeyDimensions : this.getPrimaryKeyDimensions(o);
|
|
7003
7038
|
if (s.length === 0) return null;
|
|
@@ -7005,7 +7040,7 @@ var $t = class {
|
|
|
7005
7040
|
if (t.dimensions) for (let e of t.dimensions) {
|
|
7006
7041
|
let [t, r] = e.split("."), i = a.get(t), o = i?.dimensions?.[r];
|
|
7007
7042
|
if (!i || !o) return null;
|
|
7008
|
-
let s =
|
|
7043
|
+
let s = H(o.sql, n);
|
|
7009
7044
|
u[e] = O`${s}`.as(e), d.push(s);
|
|
7010
7045
|
}
|
|
7011
7046
|
if (t.timeDimensions) for (let e of t.timeDimensions) {
|
|
@@ -7018,7 +7053,7 @@ var $t = class {
|
|
|
7018
7053
|
for (let e of s) {
|
|
7019
7054
|
let t = o.dimensions?.[e];
|
|
7020
7055
|
if (!t) return null;
|
|
7021
|
-
let r =
|
|
7056
|
+
let r = H(t.sql, n), i = `__pk__${e}`;
|
|
7022
7057
|
u[i] = O`${r}`.as(i), d.push(r), f.push(i);
|
|
7023
7058
|
}
|
|
7024
7059
|
let p = i.regularMeasures ?? [], m = new Set(p), h = t.measures.filter((e) => !m.has(e));
|
|
@@ -7041,14 +7076,15 @@ var $t = class {
|
|
|
7041
7076
|
Array.isArray(e) ? _.push(...e) : _.push(e);
|
|
7042
7077
|
}
|
|
7043
7078
|
let e = t.cube.sql(n);
|
|
7044
|
-
v = this.applyJoinByType(v, t.joinType ?? "left", e.from, t.joinCondition), e.
|
|
7079
|
+
if (v = this.applyJoinByType(v, t.joinType ?? "left", e.from, t.joinCondition), e.joins) for (let t of e.joins) v = this.applyJoinByType(v, t.type ?? "left", t.table, t.on);
|
|
7080
|
+
e.where && _.push(e.where);
|
|
7045
7081
|
}
|
|
7046
7082
|
_.push(...r.queryBuilder.buildWhereConditions(a, t, n)), _.length > 0 && (v = v.where(_.length === 1 ? _[0] : P(..._))), d.length > 0 && (v = v.groupBy(...d));
|
|
7047
7083
|
let y = n.db.$with(c).as(v), b = o.sql(n), x = {}, S = [];
|
|
7048
7084
|
for (let e of s) {
|
|
7049
7085
|
let t = o.dimensions?.[e];
|
|
7050
7086
|
if (!t) return null;
|
|
7051
|
-
let r =
|
|
7087
|
+
let r = H(t.sql, n);
|
|
7052
7088
|
x[e] = O`${r}`.as(e), S.push(r);
|
|
7053
7089
|
}
|
|
7054
7090
|
let C = /* @__PURE__ */ new Set();
|
|
@@ -7073,10 +7109,12 @@ var $t = class {
|
|
|
7073
7109
|
if (!C.has(t)) continue;
|
|
7074
7110
|
let r = o.measures?.[t];
|
|
7075
7111
|
if (!r?.sql) return null;
|
|
7076
|
-
let i =
|
|
7112
|
+
let i = H(r.sql, n), a = `__avg_sum__${t}`, s = `__avg_count__${t}`;
|
|
7077
7113
|
x[a] = O`sum(${i})`.as(a), x[s] = O`count(${i})`.as(s);
|
|
7078
7114
|
}
|
|
7079
|
-
let T = n.db.select(x).from(b.from)
|
|
7115
|
+
let T = n.db.select(x).from(b.from);
|
|
7116
|
+
if (b.joins) for (let e of b.joins) T = this.applyJoinByType(T, e.type ?? "left", e.table, e.on);
|
|
7117
|
+
let E = [];
|
|
7080
7118
|
b.where && E.push(b.where), E.push(...r.queryBuilder.buildWhereConditions(o, t, n)), E.length > 0 && (T = T.where(E.length === 1 ? E[0] : P(...E))), S.length > 0 && (T = T.groupBy(...S));
|
|
7081
7119
|
let ee = n.db.$with(l).as(T), D = {};
|
|
7082
7120
|
for (let e of t.dimensions ?? []) D[e] = O`${O.identifier(c)}.${O.identifier(e)}`.as(e);
|
|
@@ -7216,7 +7254,7 @@ function $(e, t) {
|
|
|
7216
7254
|
console.log(`\n[DC_DEBUG] ${e}`), console.log(n), r.length > 0 && console.log("params:", r), console.log();
|
|
7217
7255
|
} catch {}
|
|
7218
7256
|
}
|
|
7219
|
-
var
|
|
7257
|
+
var tn = class {
|
|
7220
7258
|
queryBuilder;
|
|
7221
7259
|
drizzlePlanBuilder;
|
|
7222
7260
|
databaseAdapter;
|
|
@@ -7230,9 +7268,9 @@ var en = class {
|
|
|
7230
7268
|
rlsSetup;
|
|
7231
7269
|
constructor(t, n, r) {
|
|
7232
7270
|
if (this.dbExecutor = t, this.databaseAdapter = t.databaseAdapter, !this.databaseAdapter) throw Error(e("server.errors.dbAdapterRequired"));
|
|
7233
|
-
this.queryBuilder = new
|
|
7234
|
-
let i = new
|
|
7235
|
-
this.drizzlePlanBuilder = new
|
|
7271
|
+
this.queryBuilder = new xt(this.databaseAdapter);
|
|
7272
|
+
let i = new St(), a = new wt(this.queryBuilder);
|
|
7273
|
+
this.drizzlePlanBuilder = new en(this.queryBuilder, a, this.databaseAdapter), this.comparisonQueryBuilder = new Ft(this.databaseAdapter), this.funnelQueryBuilder = new It(this.databaseAdapter), this.flowQueryBuilder = new Lt(this.databaseAdapter), this.retentionQueryBuilder = new Ht(this.databaseAdapter), this.logicalPlanBuilder = new Ut(i), this.planOptimiser = new Wt(), this.cacheConfig = n, this.rlsSetup = r;
|
|
7236
7274
|
}
|
|
7237
7275
|
async withRLSContext(t, n) {
|
|
7238
7276
|
if (!this.rlsSetup) return n();
|
|
@@ -7250,7 +7288,7 @@ var en = class {
|
|
|
7250
7288
|
let e = this.resolveQueryMode(n);
|
|
7251
7289
|
this.validateQueryForMode(e, t, n);
|
|
7252
7290
|
let a;
|
|
7253
|
-
if (this.cacheConfig?.enabled !== !1 && this.cacheConfig?.provider) if (a =
|
|
7291
|
+
if (this.cacheConfig?.enabled !== !1 && this.cacheConfig?.provider) if (a = lt(n, r, this.cacheConfig), i?.skipCache) this.cacheConfig.onCacheEvent?.({
|
|
7254
7292
|
type: "miss",
|
|
7255
7293
|
key: a,
|
|
7256
7294
|
durationMs: 0
|
|
@@ -7295,11 +7333,11 @@ var en = class {
|
|
|
7295
7333
|
}
|
|
7296
7334
|
}
|
|
7297
7335
|
buildLogicalPlan(e, t, n) {
|
|
7298
|
-
let r = new
|
|
7336
|
+
let r = new W(), i = this.createQueryContext(n, r, t);
|
|
7299
7337
|
return this.preloadFilterCache(t, r, e, i), this.buildRegularQueryArtifacts(e, t, i).optimisedPlan;
|
|
7300
7338
|
}
|
|
7301
7339
|
analyzeQuery(e, t, n) {
|
|
7302
|
-
let r = new
|
|
7340
|
+
let r = new W(), i = this.createQueryContext(n, r, t);
|
|
7303
7341
|
return this.preloadFilterCache(t, r, e, i), this.buildRegularQueryArtifacts(e, t, i).analysis;
|
|
7304
7342
|
}
|
|
7305
7343
|
async executeQuery(e, t, n) {
|
|
@@ -7430,13 +7468,13 @@ var en = class {
|
|
|
7430
7468
|
};
|
|
7431
7469
|
}
|
|
7432
7470
|
async executeStandardQuery(e, t, n) {
|
|
7433
|
-
let r = new
|
|
7471
|
+
let r = new W(), i = this.createQueryContext(n, r, t);
|
|
7434
7472
|
this.preloadFilterCache(t, r, e, i);
|
|
7435
7473
|
let { optimisedPlan: a } = this.buildRegularQueryArtifacts(e, t, i), o = this.drizzlePlanBuilder.derivePhysicalPlanContext(a), s = this.drizzlePlanBuilder.build(o, t, i);
|
|
7436
7474
|
$("query", s);
|
|
7437
7475
|
let c = this.queryBuilder.collectNumericFields(e, t), l = await this.dbExecutor.execute(s, c);
|
|
7438
7476
|
return {
|
|
7439
|
-
data:
|
|
7477
|
+
data: Mt(Array.isArray(l) ? l.map((e) => {
|
|
7440
7478
|
let n = { ...e };
|
|
7441
7479
|
if (t.timeDimensions) {
|
|
7442
7480
|
for (let e of t.timeDimensions) if (e.dimension in n) {
|
|
@@ -7547,7 +7585,7 @@ var en = class {
|
|
|
7547
7585
|
return this.validateQueryForMode(r, e, t), this.generateSqlForMode(r, e, t, n);
|
|
7548
7586
|
}
|
|
7549
7587
|
async generateUnifiedSQL(e, t, n) {
|
|
7550
|
-
let r = new
|
|
7588
|
+
let r = new W(), i = this.createQueryContext(n, r, t);
|
|
7551
7589
|
this.preloadFilterCache(t, r, e, i);
|
|
7552
7590
|
let { optimisedPlan: a } = this.buildRegularQueryArtifacts(e, t, i), o = this.drizzlePlanBuilder.derivePhysicalPlanContext(a), s = this.drizzlePlanBuilder.build(o, t, i).toSQL();
|
|
7553
7591
|
return {
|
|
@@ -7563,7 +7601,7 @@ var en = class {
|
|
|
7563
7601
|
}
|
|
7564
7602
|
validateQueryForMode(t, n, r) {
|
|
7565
7603
|
let i = () => {
|
|
7566
|
-
let t =
|
|
7604
|
+
let t = an(n, r);
|
|
7567
7605
|
if (!t.isValid) throw Error(e("server.errors.queryValidationFailed", { errors: t.errors.join(", ") }));
|
|
7568
7606
|
};
|
|
7569
7607
|
({
|
|
@@ -7581,7 +7619,7 @@ var en = class {
|
|
|
7581
7619
|
let t = this.retentionQueryBuilder.validateConfig(r.retention, n);
|
|
7582
7620
|
if (!t.isValid) throw Error(e("server.errors.retentionValidationFailed", { errors: t.errors.join(", ") }));
|
|
7583
7621
|
}
|
|
7584
|
-
})[
|
|
7622
|
+
})[at(t)]();
|
|
7585
7623
|
}
|
|
7586
7624
|
async executeQueryByModeWithCache(e, t, n, r, i) {
|
|
7587
7625
|
return {
|
|
@@ -7590,17 +7628,17 @@ var en = class {
|
|
|
7590
7628
|
funnel: () => this.executeFunnelQueryWithCache(t, n, r, i),
|
|
7591
7629
|
flow: () => this.executeFlowQueryWithCache(t, n, r, i),
|
|
7592
7630
|
retention: () => this.executeRetentionQueryWithCache(t, n, r, i)
|
|
7593
|
-
}[
|
|
7631
|
+
}[at(e)]();
|
|
7594
7632
|
}
|
|
7595
7633
|
async executeRegularQueryWithCache(e, t, n, r) {
|
|
7596
|
-
let i = new
|
|
7634
|
+
let i = new W(), a = this.createQueryContext(n, i, t);
|
|
7597
7635
|
this.preloadFilterCache(t, i, e, a);
|
|
7598
7636
|
let { optimisedPlan: o } = this.buildRegularQueryArtifacts(e, t, a), s = this.drizzlePlanBuilder.derivePhysicalPlanContext(o);
|
|
7599
7637
|
this.validateSecurityContext(s, a);
|
|
7600
7638
|
let c = this.drizzlePlanBuilder.build(s, t, a);
|
|
7601
7639
|
$("query", c);
|
|
7602
7640
|
let l = this.queryBuilder.collectNumericFields(e, t), u = await this.dbExecutor.execute(c, l), d = {
|
|
7603
|
-
data:
|
|
7641
|
+
data: Mt(Array.isArray(u) ? u.map((e) => {
|
|
7604
7642
|
let n = { ...e };
|
|
7605
7643
|
if (t.timeDimensions) {
|
|
7606
7644
|
for (let e of t.timeDimensions) if (e.dimension in n) {
|
|
@@ -7638,7 +7676,7 @@ var en = class {
|
|
|
7638
7676
|
funnel: () => this.dryRunFunnel(t, n, r),
|
|
7639
7677
|
flow: () => this.dryRunFlow(t, n, r),
|
|
7640
7678
|
retention: () => this.dryRunRetention(t, n, r)
|
|
7641
|
-
}[
|
|
7679
|
+
}[at(e)]();
|
|
7642
7680
|
}
|
|
7643
7681
|
async generateComparisonSQL(e, t, n) {
|
|
7644
7682
|
let r = this.buildComparisonExecutionPlan(t).periodQueries[0];
|
|
@@ -7690,9 +7728,9 @@ var en = class {
|
|
|
7690
7728
|
}
|
|
7691
7729
|
preloadFilterCache(e, t, n, r) {
|
|
7692
7730
|
if (e.filters && e.filters.length > 0) {
|
|
7693
|
-
let i =
|
|
7731
|
+
let i = ct(e.filters);
|
|
7694
7732
|
for (let e of i) {
|
|
7695
|
-
let i =
|
|
7733
|
+
let i = U(e);
|
|
7696
7734
|
if (t.has(i)) continue;
|
|
7697
7735
|
let [a, o] = e.member.split("."), s = n.get(a);
|
|
7698
7736
|
if (!s) continue;
|
|
@@ -7702,24 +7740,24 @@ var en = class {
|
|
|
7702
7740
|
"arrayOverlaps",
|
|
7703
7741
|
"arrayContained"
|
|
7704
7742
|
].includes(e.operator)) continue;
|
|
7705
|
-
let l = c.type === "time" ?
|
|
7743
|
+
let l = c.type === "time" ? H(c.sql, r) : typeof c.sql == "function" ? c.sql(r) : c.sql, u = this.queryBuilder.buildFilterConditionPublic(l, e.operator, e.values, c, e.dateRange);
|
|
7706
7744
|
u && t.set(i, u);
|
|
7707
7745
|
}
|
|
7708
7746
|
}
|
|
7709
7747
|
if (e.timeDimensions) {
|
|
7710
7748
|
for (let i of e.timeDimensions) if (i.dateRange) {
|
|
7711
|
-
let e =
|
|
7749
|
+
let e = st(i.dimension, i.dateRange);
|
|
7712
7750
|
if (t.has(e)) continue;
|
|
7713
7751
|
let [a, o] = i.dimension.split("."), s = n.get(a);
|
|
7714
7752
|
if (!s) continue;
|
|
7715
7753
|
let c = s.dimensions?.[o];
|
|
7716
7754
|
if (!c) continue;
|
|
7717
|
-
let l =
|
|
7755
|
+
let l = H(c.sql, r), u = this.queryBuilder.buildDateRangeCondition(l, i.dateRange);
|
|
7718
7756
|
u && t.set(e, u);
|
|
7719
7757
|
}
|
|
7720
7758
|
}
|
|
7721
7759
|
}
|
|
7722
|
-
},
|
|
7760
|
+
}, nn = class n {
|
|
7723
7761
|
cubes = /* @__PURE__ */ new Map();
|
|
7724
7762
|
metadataCache;
|
|
7725
7763
|
cacheConfig;
|
|
@@ -7744,10 +7782,10 @@ var en = class {
|
|
|
7744
7782
|
}
|
|
7745
7783
|
createDbExecutor() {
|
|
7746
7784
|
if (!this.db) throw Error(e("server.errors.dbNotConfigured"));
|
|
7747
|
-
return
|
|
7785
|
+
return tt(this.db, this.schema, this.engineType);
|
|
7748
7786
|
}
|
|
7749
7787
|
createQueryExecutor(e = !1) {
|
|
7750
|
-
return new
|
|
7788
|
+
return new tn(this.createDbExecutor(), e ? this.cacheConfig : void 0, this.rlsSetup);
|
|
7751
7789
|
}
|
|
7752
7790
|
formatSqlResult(e) {
|
|
7753
7791
|
let n = this.getEngineType() ?? "postgres";
|
|
@@ -7757,7 +7795,7 @@ var en = class {
|
|
|
7757
7795
|
};
|
|
7758
7796
|
}
|
|
7759
7797
|
registerCube(e) {
|
|
7760
|
-
this.validateCalculatedMeasures(e), new
|
|
7798
|
+
this.validateCalculatedMeasures(e), new Y(this.cubes).populateDependencies(e), this.cubes.set(e.name, e), this.invalidateMetadataCache();
|
|
7761
7799
|
}
|
|
7762
7800
|
validateCubeReferences() {
|
|
7763
7801
|
let t = [];
|
|
@@ -7778,7 +7816,7 @@ var en = class {
|
|
|
7778
7816
|
}));
|
|
7779
7817
|
continue;
|
|
7780
7818
|
}
|
|
7781
|
-
let a =
|
|
7819
|
+
let a = vt(i.calculatedSql);
|
|
7782
7820
|
if (!a.isValid) {
|
|
7783
7821
|
n.push(e("server.validation.calculatedMeasure.invalidSyntax", {
|
|
7784
7822
|
cubeName: t.name,
|
|
@@ -7789,7 +7827,7 @@ var en = class {
|
|
|
7789
7827
|
}
|
|
7790
7828
|
let o = new Map(this.cubes);
|
|
7791
7829
|
o.set(t.name, t);
|
|
7792
|
-
let s = new
|
|
7830
|
+
let s = new Y(o);
|
|
7793
7831
|
try {
|
|
7794
7832
|
s.validateDependencies(t);
|
|
7795
7833
|
} catch (e) {
|
|
@@ -7799,7 +7837,7 @@ var en = class {
|
|
|
7799
7837
|
if (n.length === 0) {
|
|
7800
7838
|
let r = new Map(this.cubes);
|
|
7801
7839
|
r.set(t.name, t);
|
|
7802
|
-
let i = new
|
|
7840
|
+
let i = new Y(r);
|
|
7803
7841
|
i.buildGraph(t);
|
|
7804
7842
|
let a = i.detectCycle();
|
|
7805
7843
|
a && n.push(e("server.validation.calculatedMeasure.circularDependency", { cycle: a.join(" -> ") }));
|
|
@@ -7879,7 +7917,7 @@ var en = class {
|
|
|
7879
7917
|
}
|
|
7880
7918
|
let o = [];
|
|
7881
7919
|
if (e.joins) for (let [, t] of Object.entries(e.joins)) {
|
|
7882
|
-
let e =
|
|
7920
|
+
let e = V(t.targetCube, this.cubes);
|
|
7883
7921
|
e && o.push({
|
|
7884
7922
|
targetCube: e.name,
|
|
7885
7923
|
relationship: t.relationship,
|
|
@@ -7955,18 +7993,18 @@ var en = class {
|
|
|
7955
7993
|
return Array.from(this.cubes.keys());
|
|
7956
7994
|
}
|
|
7957
7995
|
validateQuery(e) {
|
|
7958
|
-
return
|
|
7996
|
+
return an(this.cubes, e);
|
|
7959
7997
|
}
|
|
7960
7998
|
analyzeQuery(e, t) {
|
|
7961
7999
|
return this.createQueryExecutor(!0).analyzeQuery(this.cubes, e, t);
|
|
7962
8000
|
}
|
|
7963
8001
|
};
|
|
7964
|
-
function
|
|
8002
|
+
function rn(e) {
|
|
7965
8003
|
let t = [];
|
|
7966
8004
|
return e.timeDimensions?.some((e) => e.compareDateRange && e.compareDateRange.length >= 2) && t.push("comparison"), e.funnel !== void 0 && e.funnel.steps?.length >= 2 && t.push("funnel"), e.flow !== void 0 && e.flow.startingStep !== void 0 && e.flow.eventDimension !== void 0 && t.push("flow"), e.retention !== void 0 && e.retention.timeDimension != null && e.retention.bindingKey != null && t.push("retention"), t.length === 0 ? [] : t;
|
|
7967
8005
|
}
|
|
7968
|
-
function
|
|
7969
|
-
let r = [], i =
|
|
8006
|
+
function an(t, n) {
|
|
8007
|
+
let r = [], i = rn(n);
|
|
7970
8008
|
if (i.length > 1) return r.push(e("server.validation.query.multipleQueryModes", { modes: i.join(", ") })), {
|
|
7971
8009
|
isValid: !1,
|
|
7972
8010
|
errors: r
|
|
@@ -7987,7 +8025,7 @@ function rn(t, n) {
|
|
|
7987
8025
|
}
|
|
7988
8026
|
},
|
|
7989
8027
|
retention: () => {
|
|
7990
|
-
let i = n.retention, a =
|
|
8028
|
+
let i = n.retention, a = sn(i.timeDimension);
|
|
7991
8029
|
a && !t.has(a) && r.push(e("server.validation.query.retentionCubeNotFound", { cubeName: a }));
|
|
7992
8030
|
let o = i.bindingKey;
|
|
7993
8031
|
if (typeof o == "string") {
|
|
@@ -8073,7 +8111,7 @@ function rn(t, n) {
|
|
|
8073
8111
|
cubeName: n
|
|
8074
8112
|
}));
|
|
8075
8113
|
}
|
|
8076
|
-
if (n.filters) for (let e of n.filters)
|
|
8114
|
+
if (n.filters) for (let e of n.filters) on(e, t, r, o);
|
|
8077
8115
|
if (o.size === 0 && r.push(e("server.validation.query.mustReferenceAtLeastOneCube")), n.ungrouped) {
|
|
8078
8116
|
n.dimensions && n.dimensions.length > 0 || n.timeDimensions && n.timeDimensions.length > 0 || r.push(e("server.validation.query.ungroupedRequiresDimension")), n.funnel && r.push(e("server.validation.query.ungroupedIncompatibleFunnel")), n.flow && r.push(e("server.validation.query.ungroupedIncompatibleFlow")), n.retention && r.push(e("server.validation.query.ungroupedIncompatibleRetention")), n.timeDimensions?.some((e) => e.compareDateRange && e.compareDateRange.length > 0) && r.push(e("server.validation.query.ungroupedIncompatibleCompareDateRange")), n.timeDimensions?.some((e) => e.fillMissingDates === !0) && r.push(e("server.validation.query.ungroupedIncompatibleFillMissingDates"));
|
|
8079
8117
|
let i = new Set([
|
|
@@ -8117,7 +8155,7 @@ function rn(t, n) {
|
|
|
8117
8155
|
let n = t.get(e);
|
|
8118
8156
|
if (n && n.joins) {
|
|
8119
8157
|
for (let [i, a] of Object.entries(n.joins)) if (a.relationship === "hasMany") {
|
|
8120
|
-
let n =
|
|
8158
|
+
let n = V(a.targetCube, t);
|
|
8121
8159
|
n && o.has(n.name) && r.push(`Ungrouped queries are incompatible with hasMany relationships (${e} → ${i} is hasMany)`);
|
|
8122
8160
|
}
|
|
8123
8161
|
}
|
|
@@ -8128,10 +8166,10 @@ function rn(t, n) {
|
|
|
8128
8166
|
errors: r
|
|
8129
8167
|
};
|
|
8130
8168
|
}
|
|
8131
|
-
function
|
|
8169
|
+
function on(t, n, r, i) {
|
|
8132
8170
|
if ("and" in t || "or" in t) {
|
|
8133
8171
|
let e = t.and || t.or || [];
|
|
8134
|
-
for (let t of e)
|
|
8172
|
+
for (let t of e) on(t, n, r, i);
|
|
8135
8173
|
return;
|
|
8136
8174
|
}
|
|
8137
8175
|
if (!("member" in t)) {
|
|
@@ -8161,7 +8199,7 @@ function an(t, n, r, i) {
|
|
|
8161
8199
|
}));
|
|
8162
8200
|
}
|
|
8163
8201
|
}
|
|
8164
|
-
function
|
|
8202
|
+
function sn(e) {
|
|
8165
8203
|
if (typeof e == "string") {
|
|
8166
8204
|
let [t] = e.split(".");
|
|
8167
8205
|
return t || null;
|
|
@@ -8170,25 +8208,25 @@ function on(e) {
|
|
|
8170
8208
|
}
|
|
8171
8209
|
//#endregion
|
|
8172
8210
|
//#region src/adapters/locale.ts
|
|
8173
|
-
var
|
|
8174
|
-
function
|
|
8211
|
+
var cn = "x-dc-locale";
|
|
8212
|
+
function ln(e) {
|
|
8175
8213
|
if (!e) return;
|
|
8176
8214
|
let t = (Array.isArray(e) ? e[0] : e).split(",")[0]?.trim();
|
|
8177
8215
|
if (t && /^[A-Za-z0-9-]{2,35}$/.test(t)) return t;
|
|
8178
8216
|
}
|
|
8179
|
-
function
|
|
8180
|
-
return
|
|
8217
|
+
function un(e) {
|
|
8218
|
+
return ln(e(cn));
|
|
8181
8219
|
}
|
|
8182
|
-
function
|
|
8220
|
+
function dn(e, t) {
|
|
8183
8221
|
let n = e && typeof e == "object" ? e : {}, r = typeof n.locale == "string" ? n.locale : void 0, i = t ?? r ?? "en-GB";
|
|
8184
8222
|
return r === i ? n : {
|
|
8185
8223
|
...n,
|
|
8186
8224
|
locale: i
|
|
8187
8225
|
};
|
|
8188
8226
|
}
|
|
8189
|
-
function
|
|
8227
|
+
function fn(e) {
|
|
8190
8228
|
let t = Array.isArray(e) ? [...e] : (e ?? "").split(",").map((e) => e.trim()).filter(Boolean);
|
|
8191
8229
|
return t.some((e) => e.toLowerCase() === "x-dc-locale") || t.push("X-DC-Locale"), t;
|
|
8192
8230
|
}
|
|
8193
8231
|
//#endregion
|
|
8194
|
-
export {
|
|
8232
|
+
export { nn as i, un as n, dn as r, fn as t };
|