drizzle-cube 0.4.52 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/express/index.cjs +2 -2
- package/dist/adapters/express/index.js +92 -83
- package/dist/adapters/fastify/index.cjs +2 -2
- package/dist/adapters/fastify/index.js +126 -116
- package/dist/adapters/{handler-RItnSaEl.js → handler-3LGcjLtr.js} +617 -612
- package/dist/adapters/handler-BzzbVpcl.cjs +25 -0
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +94 -86
- package/dist/adapters/{compiler-D_o2IzHn.js → locale-DTnJrxm1.js} +1363 -1079
- package/dist/adapters/locale-DueXjqMh.cjs +198 -0
- package/dist/adapters/locale.d.ts +8 -0
- package/dist/adapters/mcp-tools.cjs +1 -1
- package/dist/adapters/mcp-tools.js +14 -14
- package/dist/adapters/mcp-transport-45SiFcCH.cjs +39 -0
- package/dist/adapters/mcp-transport-Bxpc4mRy.js +553 -0
- package/dist/adapters/mcp-transport.d.ts +11 -0
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +138 -122
- package/dist/adapters/utils-DNrj-ryp.cjs +17 -0
- package/dist/adapters/{utils-IH1ePsBd.js → utils-DOg9oGdt.js} +2341 -819
- package/dist/adapters/utils.cjs +1 -1
- package/dist/adapters/utils.d.ts +7 -0
- package/dist/adapters/utils.js +1 -1
- package/dist/client/charts.js +12 -12
- package/dist/client/chunks/{DashboardEditModal-BTdV528l.js → DashboardEditModal-cSSIAZGy.js} +1968 -1973
- package/dist/client/chunks/DashboardEditModal-cSSIAZGy.js.map +1 -0
- package/dist/client/chunks/{FieldSearchModal-D75vy4Wb.js → FieldSearchModal-CZNo4pNK.js} +550 -536
- package/dist/client/chunks/FieldSearchModal-CZNo4pNK.js.map +1 -0
- package/dist/client/chunks/KpiDelta-Dll_eCV1.js +2 -0
- package/dist/client/chunks/KpiNumber-BPlR92hI.js +2 -0
- package/dist/client/chunks/KpiText-BIxq7Jso.js +2 -0
- package/dist/client/chunks/{RetentionCombinedChart-DIhK5pD8.js → RetentionCombinedChart-BD8tGeM_.js} +96 -96
- package/dist/client/chunks/RetentionCombinedChart-BD8tGeM_.js.map +1 -0
- package/dist/client/chunks/{RetentionHeatmap-CyREolyP.js → RetentionHeatmap-B_5sewwi.js} +77 -77
- package/dist/client/chunks/RetentionHeatmap-B_5sewwi.js.map +1 -0
- package/dist/client/chunks/SchemaVisualization-CCICjhvv.js +2 -0
- package/dist/client/chunks/SchemaVisualizationLazy-DraGsMx6.js +2 -0
- package/dist/client/chunks/af-ZA-xDmO5F0s.js +1431 -0
- package/dist/client/chunks/af-ZA-xDmO5F0s.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-C1CJ0c7L.js → analysis-builder-BeVZhiQ5.js} +1519 -1507
- package/dist/client/chunks/analysis-builder-BeVZhiQ5.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-shared-rkjJfWLT.js → analysis-builder-shared-BWc7ZZnG.js} +925 -954
- package/dist/client/chunks/analysis-builder-shared-BWc7ZZnG.js.map +1 -0
- package/dist/client/chunks/chart-activity-grid-CWT0gLv4.js +2376 -0
- package/dist/client/chunks/chart-activity-grid-CWT0gLv4.js.map +1 -0
- package/dist/client/chunks/{chart-area-BwYaflNk.js → chart-area-D63kG8OT.js} +157 -157
- package/dist/client/chunks/chart-area-D63kG8OT.js.map +1 -0
- package/dist/client/chunks/{chart-bar-BiENfFgE.js → chart-bar-BEfsCLjl.js} +78 -78
- package/dist/client/chunks/chart-bar-BEfsCLjl.js.map +1 -0
- package/dist/client/chunks/{chart-box-plot-BJF1tBXC.js → chart-box-plot-o-h9MRX5.js} +111 -114
- package/dist/client/chunks/chart-box-plot-o-h9MRX5.js.map +1 -0
- package/dist/client/chunks/{chart-bubble-DQQhGVDJ.js → chart-bubble-CMDp4Pfm.js} +121 -121
- package/dist/client/chunks/chart-bubble-CMDp4Pfm.js.map +1 -0
- package/dist/client/chunks/chart-candlestick-WyANJ0Ky.js +303 -0
- package/dist/client/chunks/chart-candlestick-WyANJ0Ky.js.map +1 -0
- package/dist/client/chunks/chart-config-activity-grid-C-EkgYoa.js +51 -0
- package/dist/client/chunks/chart-config-activity-grid-C-EkgYoa.js.map +1 -0
- package/dist/client/chunks/chart-config-area-CMZpbIah.js +93 -0
- package/dist/client/chunks/chart-config-area-CMZpbIah.js.map +1 -0
- package/dist/client/chunks/chart-config-bar-B8_V4YLg.js +87 -0
- package/dist/client/chunks/chart-config-bar-B8_V4YLg.js.map +1 -0
- package/dist/client/chunks/chart-config-box-plot-Dwj7sEbU.js +35 -0
- package/dist/client/chunks/chart-config-box-plot-Dwj7sEbU.js.map +1 -0
- package/dist/client/chunks/chart-config-bubble-B0w0ZVp4.js +82 -0
- package/dist/client/chunks/chart-config-bubble-B0w0ZVp4.js.map +1 -0
- package/dist/client/chunks/chart-config-candlestick-Bvo3zeIn.js +72 -0
- package/dist/client/chunks/chart-config-candlestick-Bvo3zeIn.js.map +1 -0
- package/dist/client/chunks/{chart-config-data-table-Bhdx5Hem.js → chart-config-data-table-BQXSn4b_.js} +9 -9
- package/dist/client/chunks/chart-config-data-table-BQXSn4b_.js.map +1 -0
- package/dist/client/chunks/chart-config-funnel-BzEsHmjR.js +93 -0
- package/dist/client/chunks/chart-config-funnel-BzEsHmjR.js.map +1 -0
- package/dist/client/chunks/chart-config-gauge-C5ZiyZy7.js +64 -0
- package/dist/client/chunks/chart-config-gauge-C5ZiyZy7.js.map +1 -0
- package/dist/client/chunks/chart-config-heat-map-Cv8qNnVP.js +91 -0
- package/dist/client/chunks/chart-config-heat-map-Cv8qNnVP.js.map +1 -0
- package/dist/client/chunks/chart-config-kpi-delta-BraHQc2E.js +94 -0
- package/dist/client/chunks/chart-config-kpi-delta-BraHQc2E.js.map +1 -0
- package/dist/client/chunks/chart-config-kpi-number-CeCkx7mC.js +75 -0
- package/dist/client/chunks/chart-config-kpi-number-CeCkx7mC.js.map +1 -0
- package/dist/client/chunks/chart-config-kpi-text-CImM3SvH.js +47 -0
- package/dist/client/chunks/chart-config-kpi-text-CImM3SvH.js.map +1 -0
- package/dist/client/chunks/chart-config-line-BVKapAQK.js +104 -0
- package/dist/client/chunks/chart-config-line-BVKapAQK.js.map +1 -0
- package/dist/client/chunks/chart-config-markdown-C-_g_8te.js +117 -0
- package/dist/client/chunks/chart-config-markdown-C-_g_8te.js.map +1 -0
- package/dist/client/chunks/chart-config-measure-profile-KTVV1gO3.js +82 -0
- package/dist/client/chunks/chart-config-measure-profile-KTVV1gO3.js.map +1 -0
- package/dist/client/chunks/chart-config-pie-BZxVl25X.js +68 -0
- package/dist/client/chunks/chart-config-pie-BZxVl25X.js.map +1 -0
- package/dist/client/chunks/chart-config-radar-B7FByX3t.js +49 -0
- package/dist/client/chunks/chart-config-radar-B7FByX3t.js.map +1 -0
- package/dist/client/chunks/chart-config-radial-bar-UfW_3yyX.js +38 -0
- package/dist/client/chunks/chart-config-radial-bar-UfW_3yyX.js.map +1 -0
- package/dist/client/chunks/chart-config-sankey-DGAThN9i.js +66 -0
- package/dist/client/chunks/chart-config-sankey-DGAThN9i.js.map +1 -0
- package/dist/client/chunks/chart-config-scatter-BVVJuOnt.js +61 -0
- package/dist/client/chunks/chart-config-scatter-BVVJuOnt.js.map +1 -0
- package/dist/client/chunks/chart-config-sunburst-utejM2YS.js +45 -0
- package/dist/client/chunks/chart-config-sunburst-utejM2YS.js.map +1 -0
- package/dist/client/chunks/chart-config-tree-map-IHp97OyV.js +51 -0
- package/dist/client/chunks/chart-config-tree-map-IHp97OyV.js.map +1 -0
- package/dist/client/chunks/chart-config-waterfall-BdqG1V-x.js +59 -0
- package/dist/client/chunks/chart-config-waterfall-BdqG1V-x.js.map +1 -0
- package/dist/client/chunks/{chart-data-table-2iCsn0CF.js → chart-data-table-C3Xh9jwL.js} +1083 -1086
- package/dist/client/chunks/chart-data-table-C3Xh9jwL.js.map +1 -0
- package/dist/client/chunks/{chart-funnel-poyOf7-e.js → chart-funnel-C7pgktN5.js} +132 -132
- package/dist/client/chunks/chart-funnel-C7pgktN5.js.map +1 -0
- package/dist/client/chunks/{chart-gauge-D5J4gRky.js → chart-gauge-D2r2B_AR.js} +150 -150
- package/dist/client/chunks/chart-gauge-D2r2B_AR.js.map +1 -0
- package/dist/client/chunks/{chart-heat-map-BAMVhLGG.js → chart-heat-map-Dw2yjwfO.js} +75 -80
- package/dist/client/chunks/chart-heat-map-Dw2yjwfO.js.map +1 -0
- package/dist/client/chunks/{chart-kpi-delta-KQjUIeal.js → chart-kpi-delta-CYE0S1x_.js} +117 -117
- package/dist/client/chunks/chart-kpi-delta-CYE0S1x_.js.map +1 -0
- package/dist/client/chunks/chart-kpi-number-BlZ79xHW.js +321 -0
- package/dist/client/chunks/chart-kpi-number-BlZ79xHW.js.map +1 -0
- package/dist/client/chunks/chart-kpi-text-DY1BnxPe.js +148 -0
- package/dist/client/chunks/chart-kpi-text-DY1BnxPe.js.map +1 -0
- package/dist/client/chunks/{chart-line-B5_WntY5.js → chart-line-CBsTThTv.js} +123 -123
- package/dist/client/chunks/chart-line-CBsTThTv.js.map +1 -0
- package/dist/client/chunks/chart-markdown-BWaWVkuz.js +3474 -0
- package/dist/client/chunks/chart-markdown-BWaWVkuz.js.map +1 -0
- package/dist/client/chunks/chart-measure-profile-B41qCTBG.js +179 -0
- package/dist/client/chunks/chart-measure-profile-B41qCTBG.js.map +1 -0
- package/dist/client/chunks/chart-pie-Djbu8x2v.js +172 -0
- package/dist/client/chunks/chart-pie-Djbu8x2v.js.map +1 -0
- package/dist/client/chunks/chart-radar-BsTcKV0K.js +154 -0
- package/dist/client/chunks/chart-radar-BsTcKV0K.js.map +1 -0
- package/dist/client/chunks/chart-radial-bar-Du7XNnwE.js +148 -0
- package/dist/client/chunks/chart-radial-bar-Du7XNnwE.js.map +1 -0
- package/dist/client/chunks/{chart-sankey-BOyxfG1Q.js → chart-sankey-WwkZAhLy.js} +73 -73
- package/dist/client/chunks/chart-sankey-WwkZAhLy.js.map +1 -0
- package/dist/client/chunks/chart-scatter-D8krEYsA.js +255 -0
- package/dist/client/chunks/chart-scatter-D8krEYsA.js.map +1 -0
- package/dist/client/chunks/{chart-sunburst-D9lGEOCc.js → chart-sunburst-CIDB_pTl.js} +66 -66
- package/dist/client/chunks/chart-sunburst-CIDB_pTl.js.map +1 -0
- package/dist/client/chunks/chart-tree-map-C5C2iaWM.js +298 -0
- package/dist/client/chunks/chart-tree-map-C5C2iaWM.js.map +1 -0
- package/dist/client/chunks/{chart-waterfall-BCdUx4DC.js → chart-waterfall-BGdPrJ5Y.js} +80 -80
- package/dist/client/chunks/chart-waterfall-BGdPrJ5Y.js.map +1 -0
- package/dist/client/chunks/{charts-core-C5Yokk-x.js → charts-core-BXOqaYFn.js} +92 -92
- package/dist/client/chunks/charts-core-BXOqaYFn.js.map +1 -0
- package/dist/client/chunks/en-US-5xPTdCXg.js +35 -0
- package/dist/client/chunks/en-US-5xPTdCXg.js.map +1 -0
- package/dist/client/chunks/nl-NL-vCifBijs.js +1491 -0
- package/dist/client/chunks/nl-NL-vCifBijs.js.map +1 -0
- package/dist/client/chunks/{schema-visualization-t1KiOORo.js → schema-visualization-Xp60Ff2W.js} +352 -364
- package/dist/client/chunks/schema-visualization-Xp60Ff2W.js.map +1 -0
- package/dist/client/chunks/{useDebounce-CKqkM42n.js → useDebounce-CfmUMFau.js} +85 -85
- package/dist/client/chunks/useDebounce-CfmUMFau.js.map +1 -0
- package/dist/client/chunks/{useExplainAI-DBIfYwz-.js → useExplainAI-BKGmejIj.js} +4 -4
- package/dist/client/chunks/{useExplainAI-DBIfYwz-.js.map → useExplainAI-BKGmejIj.js.map} +1 -1
- package/dist/client/chunks/{utils--qCr8Yn5.js → utils-BldkcRHv.js} +2 -2
- package/dist/client/chunks/{utils--qCr8Yn5.js.map → utils-BldkcRHv.js.map} +1 -1
- package/dist/client/chunks/{vendor-BRlsCGnK.js → vendor-ClXpIiea.js} +2 -2
- package/dist/client/chunks/{vendor-BRlsCGnK.js.map → vendor-ClXpIiea.js.map} +1 -1
- package/dist/client/components/AnalysisBuilder/types.d.ts +6 -6
- package/dist/client/components.js +3 -3
- package/dist/client/hooks/useTranslation.d.ts +21 -0
- package/dist/client/hooks.js +3 -3
- package/dist/client/icons.js +1 -1
- package/dist/client/index.js +493 -488
- package/dist/client/index.js.map +1 -1
- package/dist/client/providers/CubeApiProvider.d.ts +2 -1
- package/dist/client/providers/CubeProvider.d.ts +7 -1
- package/dist/client/providers/I18nProvider.d.ts +18 -0
- package/dist/client/providers.js +1 -1
- package/dist/client/schema.js +1 -1
- package/dist/client/shared/types.d.ts +5 -20
- package/dist/client/styles.css +1 -1
- package/dist/client/utils.js +5 -5
- package/dist/client-bundle-stats.html +1 -1
- package/dist/mcp-app/mcp-app.html +26 -24
- package/dist/server/index.cjs +42 -40
- package/dist/server/index.js +3353 -1567
- package/package.json +5 -2
- package/dist/adapters/compiler-Bbsijr3W.cjs +0 -198
- package/dist/adapters/handler-DumFgnNM.cjs +0 -25
- package/dist/adapters/mcp-transport-C6bsIOSV.js +0 -545
- package/dist/adapters/mcp-transport-DMhuYmFp.cjs +0 -39
- package/dist/adapters/utils-CyBt-as9.cjs +0 -15
- package/dist/client/chunks/DashboardEditModal-BTdV528l.js.map +0 -1
- package/dist/client/chunks/FieldSearchModal-D75vy4Wb.js.map +0 -1
- package/dist/client/chunks/KpiDelta-Bk8bzKYM.js +0 -2
- package/dist/client/chunks/KpiNumber-CKF-8e_T.js +0 -2
- package/dist/client/chunks/KpiText-Iz1vIvu_.js +0 -2
- package/dist/client/chunks/RetentionCombinedChart-DIhK5pD8.js.map +0 -1
- package/dist/client/chunks/RetentionHeatmap-CyREolyP.js.map +0 -1
- package/dist/client/chunks/SchemaVisualization-B1GUT-FM.js +0 -2
- package/dist/client/chunks/SchemaVisualizationLazy-DymwT34e.js +0 -2
- package/dist/client/chunks/analysis-builder-C1CJ0c7L.js.map +0 -1
- package/dist/client/chunks/analysis-builder-shared-rkjJfWLT.js.map +0 -1
- package/dist/client/chunks/chart-activity-grid-DLktOINm.js +0 -806
- package/dist/client/chunks/chart-activity-grid-DLktOINm.js.map +0 -1
- package/dist/client/chunks/chart-area-BwYaflNk.js.map +0 -1
- package/dist/client/chunks/chart-bar-BiENfFgE.js.map +0 -1
- package/dist/client/chunks/chart-box-plot-BJF1tBXC.js.map +0 -1
- package/dist/client/chunks/chart-bubble-DQQhGVDJ.js.map +0 -1
- package/dist/client/chunks/chart-candlestick-C2UuXbLe.js +0 -306
- package/dist/client/chunks/chart-candlestick-C2UuXbLe.js.map +0 -1
- package/dist/client/chunks/chart-config-activity-grid-DJOU3TEz.js +0 -51
- package/dist/client/chunks/chart-config-activity-grid-DJOU3TEz.js.map +0 -1
- package/dist/client/chunks/chart-config-area-CWnWVT6a.js +0 -93
- package/dist/client/chunks/chart-config-area-CWnWVT6a.js.map +0 -1
- package/dist/client/chunks/chart-config-bar-C-7Dr1Ho.js +0 -87
- package/dist/client/chunks/chart-config-bar-C-7Dr1Ho.js.map +0 -1
- package/dist/client/chunks/chart-config-box-plot-mVOwmLdu.js +0 -35
- package/dist/client/chunks/chart-config-box-plot-mVOwmLdu.js.map +0 -1
- package/dist/client/chunks/chart-config-bubble-BPE2CeiD.js +0 -82
- package/dist/client/chunks/chart-config-bubble-BPE2CeiD.js.map +0 -1
- package/dist/client/chunks/chart-config-candlestick-BSB9DRy2.js +0 -72
- package/dist/client/chunks/chart-config-candlestick-BSB9DRy2.js.map +0 -1
- package/dist/client/chunks/chart-config-data-table-Bhdx5Hem.js.map +0 -1
- package/dist/client/chunks/chart-config-funnel-Cl-v-bm1.js +0 -93
- package/dist/client/chunks/chart-config-funnel-Cl-v-bm1.js.map +0 -1
- package/dist/client/chunks/chart-config-gauge-CdrUTJMJ.js +0 -64
- package/dist/client/chunks/chart-config-gauge-CdrUTJMJ.js.map +0 -1
- package/dist/client/chunks/chart-config-heat-map-DGE3NzoF.js +0 -91
- package/dist/client/chunks/chart-config-heat-map-DGE3NzoF.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-delta-DMrQerUW.js +0 -94
- package/dist/client/chunks/chart-config-kpi-delta-DMrQerUW.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-number-DCytCytn.js +0 -75
- package/dist/client/chunks/chart-config-kpi-number-DCytCytn.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-text-KdKQUvHo.js +0 -47
- package/dist/client/chunks/chart-config-kpi-text-KdKQUvHo.js.map +0 -1
- package/dist/client/chunks/chart-config-line-Bl9VDAdz.js +0 -104
- package/dist/client/chunks/chart-config-line-Bl9VDAdz.js.map +0 -1
- package/dist/client/chunks/chart-config-markdown-BX26b94i.js +0 -117
- package/dist/client/chunks/chart-config-markdown-BX26b94i.js.map +0 -1
- package/dist/client/chunks/chart-config-measure-profile-DwtRhEFh.js +0 -82
- package/dist/client/chunks/chart-config-measure-profile-DwtRhEFh.js.map +0 -1
- package/dist/client/chunks/chart-config-pie-BzBcqPMJ.js +0 -68
- package/dist/client/chunks/chart-config-pie-BzBcqPMJ.js.map +0 -1
- package/dist/client/chunks/chart-config-radar-6ZOgt__z.js +0 -49
- package/dist/client/chunks/chart-config-radar-6ZOgt__z.js.map +0 -1
- package/dist/client/chunks/chart-config-radial-bar-Df6Eta7N.js +0 -38
- package/dist/client/chunks/chart-config-radial-bar-Df6Eta7N.js.map +0 -1
- package/dist/client/chunks/chart-config-sankey-DgqKBFvN.js +0 -66
- package/dist/client/chunks/chart-config-sankey-DgqKBFvN.js.map +0 -1
- package/dist/client/chunks/chart-config-scatter-D5nVLDvi.js +0 -61
- package/dist/client/chunks/chart-config-scatter-D5nVLDvi.js.map +0 -1
- package/dist/client/chunks/chart-config-sunburst-Ca3FX9nW.js +0 -45
- package/dist/client/chunks/chart-config-sunburst-Ca3FX9nW.js.map +0 -1
- package/dist/client/chunks/chart-config-tree-map-Bjy4QNa3.js +0 -51
- package/dist/client/chunks/chart-config-tree-map-Bjy4QNa3.js.map +0 -1
- package/dist/client/chunks/chart-config-waterfall-C5K2eqR7.js +0 -59
- package/dist/client/chunks/chart-config-waterfall-C5K2eqR7.js.map +0 -1
- package/dist/client/chunks/chart-data-table-2iCsn0CF.js.map +0 -1
- package/dist/client/chunks/chart-funnel-poyOf7-e.js.map +0 -1
- package/dist/client/chunks/chart-gauge-D5J4gRky.js.map +0 -1
- package/dist/client/chunks/chart-heat-map-BAMVhLGG.js.map +0 -1
- package/dist/client/chunks/chart-kpi-delta-KQjUIeal.js.map +0 -1
- package/dist/client/chunks/chart-kpi-number-CsQgV_x3.js +0 -325
- package/dist/client/chunks/chart-kpi-number-CsQgV_x3.js.map +0 -1
- package/dist/client/chunks/chart-kpi-text-BR0IyeUU.js +0 -148
- package/dist/client/chunks/chart-kpi-text-BR0IyeUU.js.map +0 -1
- package/dist/client/chunks/chart-line-B5_WntY5.js.map +0 -1
- package/dist/client/chunks/chart-markdown-B6bENbel.js +0 -3473
- package/dist/client/chunks/chart-markdown-B6bENbel.js.map +0 -1
- package/dist/client/chunks/chart-measure-profile-yWk-obNb.js +0 -179
- package/dist/client/chunks/chart-measure-profile-yWk-obNb.js.map +0 -1
- package/dist/client/chunks/chart-pie-BodrUoHv.js +0 -172
- package/dist/client/chunks/chart-pie-BodrUoHv.js.map +0 -1
- package/dist/client/chunks/chart-radar-gG3zfLud.js +0 -154
- package/dist/client/chunks/chart-radar-gG3zfLud.js.map +0 -1
- package/dist/client/chunks/chart-radial-bar-C2IPCV8c.js +0 -148
- package/dist/client/chunks/chart-radial-bar-C2IPCV8c.js.map +0 -1
- package/dist/client/chunks/chart-sankey-BOyxfG1Q.js.map +0 -1
- package/dist/client/chunks/chart-scatter-B8OwlsAX.js +0 -255
- package/dist/client/chunks/chart-scatter-B8OwlsAX.js.map +0 -1
- package/dist/client/chunks/chart-sunburst-D9lGEOCc.js.map +0 -1
- package/dist/client/chunks/chart-tree-map-DZaKy9he.js +0 -298
- package/dist/client/chunks/chart-tree-map-DZaKy9he.js.map +0 -1
- package/dist/client/chunks/chart-waterfall-BCdUx4DC.js.map +0 -1
- package/dist/client/chunks/charts-core-C5Yokk-x.js.map +0 -1
- package/dist/client/chunks/schema-visualization-t1KiOORo.js.map +0 -1
- package/dist/client/chunks/useDebounce-CKqkM42n.js.map +0 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as e, s as t } from "./utils-DOg9oGdt.js";
|
|
2
2
|
//#region node_modules/drizzle-orm/entity.js
|
|
3
|
-
var
|
|
4
|
-
function
|
|
3
|
+
var n = Symbol.for("drizzle:entityKind");
|
|
4
|
+
function r(e, t) {
|
|
5
5
|
if (!e || typeof e != "object") return !1;
|
|
6
|
-
if (e instanceof
|
|
7
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
6
|
+
if (e instanceof t) return !0;
|
|
7
|
+
if (!Object.prototype.hasOwnProperty.call(t, n)) throw Error(`Class "${t.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);
|
|
8
8
|
let r = Object.getPrototypeOf(e).constructor;
|
|
9
9
|
if (r) for (; r;) {
|
|
10
|
-
if (
|
|
10
|
+
if (n in r && r[n] === t[n]) return !0;
|
|
11
11
|
r = Object.getPrototypeOf(r);
|
|
12
12
|
}
|
|
13
13
|
return !1;
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region node_modules/drizzle-orm/column.js
|
|
17
|
-
var
|
|
17
|
+
var i = class {
|
|
18
18
|
constructor(e, t) {
|
|
19
19
|
this.table = e, this.config = t, this.name = t.name, this.keyAsName = t.keyAsName, this.notNull = t.notNull, this.default = t.default, this.defaultFn = t.defaultFn, this.onUpdateFn = t.onUpdateFn, this.hasDefault = t.hasDefault, this.primary = t.primaryKey, this.isUnique = t.isUnique, this.uniqueName = t.uniqueName, this.uniqueType = t.uniqueType, this.dataType = t.dataType, this.columnType = t.columnType, this.generated = t.generated, this.generatedIdentity = t.generatedIdentity;
|
|
20
20
|
}
|
|
21
|
-
static [
|
|
21
|
+
static [n] = "Column";
|
|
22
22
|
name;
|
|
23
23
|
keyAsName;
|
|
24
24
|
primary;
|
|
@@ -45,14 +45,14 @@ var r = class {
|
|
|
45
45
|
shouldDisableInsert() {
|
|
46
46
|
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
47
47
|
}
|
|
48
|
-
},
|
|
49
|
-
function
|
|
50
|
-
return !!e && typeof e == "function" &&
|
|
48
|
+
}, a = Symbol.for("drizzle:Name"), o = Symbol.for("drizzle:isPgEnum");
|
|
49
|
+
function s(e) {
|
|
50
|
+
return !!e && typeof e == "function" && o in e && e[o] === !0;
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region node_modules/drizzle-orm/subquery.js
|
|
54
|
-
var
|
|
55
|
-
static [
|
|
54
|
+
var c = class {
|
|
55
|
+
static [n] = "Subquery";
|
|
56
56
|
constructor(e, t, n, r = !1, i = []) {
|
|
57
57
|
this._ = {
|
|
58
58
|
brand: "Subquery",
|
|
@@ -63,39 +63,39 @@ var s = class {
|
|
|
63
63
|
usedTables: i
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
},
|
|
66
|
+
}, l = { startActiveSpan(e, t) {
|
|
67
67
|
return t();
|
|
68
|
-
} },
|
|
69
|
-
static [
|
|
68
|
+
} }, u = Symbol.for("drizzle:ViewBaseConfig"), d = Symbol.for("drizzle:Schema"), f = Symbol.for("drizzle:Columns"), p = Symbol.for("drizzle:ExtraConfigColumns"), m = Symbol.for("drizzle:OriginalName"), h = Symbol.for("drizzle:BaseName"), g = Symbol.for("drizzle:IsAlias"), _ = Symbol.for("drizzle:ExtraConfigBuilder"), v = Symbol.for("drizzle:IsDrizzleTable"), y = class {
|
|
69
|
+
static [n] = "Table";
|
|
70
70
|
static Symbol = {
|
|
71
|
-
Name:
|
|
72
|
-
Schema:
|
|
73
|
-
OriginalName:
|
|
74
|
-
Columns:
|
|
75
|
-
ExtraConfigColumns:
|
|
76
|
-
BaseName:
|
|
77
|
-
IsAlias:
|
|
78
|
-
ExtraConfigBuilder:
|
|
71
|
+
Name: a,
|
|
72
|
+
Schema: d,
|
|
73
|
+
OriginalName: m,
|
|
74
|
+
Columns: f,
|
|
75
|
+
ExtraConfigColumns: p,
|
|
76
|
+
BaseName: h,
|
|
77
|
+
IsAlias: g,
|
|
78
|
+
ExtraConfigBuilder: _
|
|
79
79
|
};
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[u];
|
|
80
|
+
[a];
|
|
81
|
+
[m];
|
|
83
82
|
[d];
|
|
84
83
|
[f];
|
|
85
|
-
[
|
|
86
|
-
[h]
|
|
87
|
-
[
|
|
88
|
-
[
|
|
84
|
+
[p];
|
|
85
|
+
[h];
|
|
86
|
+
[g] = !1;
|
|
87
|
+
[v] = !0;
|
|
88
|
+
[_] = void 0;
|
|
89
89
|
constructor(e, t, n) {
|
|
90
|
-
this[
|
|
90
|
+
this[a] = this[m] = e, this[d] = t, this[h] = n;
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
//#endregion
|
|
94
94
|
//#region node_modules/drizzle-orm/sql/sql.js
|
|
95
|
-
function
|
|
95
|
+
function b(e) {
|
|
96
96
|
return e != null && typeof e.getSQL == "function";
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function x(e) {
|
|
99
99
|
let t = {
|
|
100
100
|
sql: "",
|
|
101
101
|
params: []
|
|
@@ -103,32 +103,32 @@ function b(e) {
|
|
|
103
103
|
for (let n of e) t.sql += n.sql, t.params.push(...n.params), n.typings?.length && (t.typings ||= [], t.typings.push(...n.typings));
|
|
104
104
|
return t;
|
|
105
105
|
}
|
|
106
|
-
var
|
|
107
|
-
static [
|
|
106
|
+
var S = class {
|
|
107
|
+
static [n] = "StringChunk";
|
|
108
108
|
value;
|
|
109
109
|
constructor(e) {
|
|
110
110
|
this.value = Array.isArray(e) ? e : [e];
|
|
111
111
|
}
|
|
112
112
|
getSQL() {
|
|
113
|
-
return new
|
|
113
|
+
return new C([this]);
|
|
114
114
|
}
|
|
115
|
-
},
|
|
115
|
+
}, C = class e {
|
|
116
116
|
constructor(e) {
|
|
117
117
|
this.queryChunks = e;
|
|
118
|
-
for (let t of e) if (
|
|
119
|
-
let e = t[
|
|
120
|
-
this.usedTables.push(e === void 0 ? t[
|
|
118
|
+
for (let t of e) if (r(t, y)) {
|
|
119
|
+
let e = t[y.Symbol.Schema];
|
|
120
|
+
this.usedTables.push(e === void 0 ? t[y.Symbol.Name] : e + "." + t[y.Symbol.Name]);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
static [
|
|
124
|
-
decoder =
|
|
123
|
+
static [n] = "SQL";
|
|
124
|
+
decoder = E;
|
|
125
125
|
shouldInlineParams = !1;
|
|
126
126
|
usedTables = [];
|
|
127
127
|
append(e) {
|
|
128
128
|
return this.queryChunks.push(...e.queryChunks), this;
|
|
129
129
|
}
|
|
130
130
|
toQuery(e) {
|
|
131
|
-
return
|
|
131
|
+
return l.startActiveSpan("drizzle.buildSQL", (t) => {
|
|
132
132
|
let n = this.buildQueryFromSourceParams(this.queryChunks, e);
|
|
133
133
|
return t?.setAttributes({
|
|
134
134
|
"drizzle.query.text": n.sql,
|
|
@@ -136,18 +136,18 @@ var x = class {
|
|
|
136
136
|
}), n;
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
buildQueryFromSourceParams(t,
|
|
140
|
-
let a = Object.assign({},
|
|
141
|
-
inlineParams:
|
|
142
|
-
paramStartIndex:
|
|
143
|
-
}), { casing:
|
|
144
|
-
return
|
|
145
|
-
if (
|
|
139
|
+
buildQueryFromSourceParams(t, n) {
|
|
140
|
+
let a = Object.assign({}, n, {
|
|
141
|
+
inlineParams: n.inlineParams || this.shouldInlineParams,
|
|
142
|
+
paramStartIndex: n.paramStartIndex || { value: 0 }
|
|
143
|
+
}), { casing: o, escapeName: l, escapeParam: d, prepareTyping: f, inlineParams: p, paramStartIndex: m } = a;
|
|
144
|
+
return x(t.map((t) => {
|
|
145
|
+
if (r(t, S)) return {
|
|
146
146
|
sql: t.value.join(""),
|
|
147
147
|
params: []
|
|
148
148
|
};
|
|
149
|
-
if (
|
|
150
|
-
sql:
|
|
149
|
+
if (r(t, w)) return {
|
|
150
|
+
sql: l(t.value),
|
|
151
151
|
params: []
|
|
152
152
|
};
|
|
153
153
|
if (t === void 0) return {
|
|
@@ -155,84 +155,84 @@ var x = class {
|
|
|
155
155
|
params: []
|
|
156
156
|
};
|
|
157
157
|
if (Array.isArray(t)) {
|
|
158
|
-
let e = [new
|
|
159
|
-
for (let [n, r] of t.entries()) e.push(r), n < t.length - 1 && e.push(new
|
|
160
|
-
return e.push(new
|
|
158
|
+
let e = [new S("(")];
|
|
159
|
+
for (let [n, r] of t.entries()) e.push(r), n < t.length - 1 && e.push(new S(", "));
|
|
160
|
+
return e.push(new S(")")), this.buildQueryFromSourceParams(e, a);
|
|
161
161
|
}
|
|
162
|
-
if (
|
|
162
|
+
if (r(t, e)) return this.buildQueryFromSourceParams(t.queryChunks, {
|
|
163
163
|
...a,
|
|
164
164
|
inlineParams: p || t.shouldInlineParams
|
|
165
165
|
});
|
|
166
|
-
if (
|
|
167
|
-
let e = t[
|
|
166
|
+
if (r(t, y)) {
|
|
167
|
+
let e = t[y.Symbol.Schema], n = t[y.Symbol.Name];
|
|
168
168
|
return {
|
|
169
|
-
sql: e === void 0 || t[
|
|
169
|
+
sql: e === void 0 || t[g] ? l(n) : l(e) + "." + l(n),
|
|
170
170
|
params: []
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
if (
|
|
174
|
-
let e =
|
|
175
|
-
if (
|
|
176
|
-
sql:
|
|
173
|
+
if (r(t, i)) {
|
|
174
|
+
let e = o.getColumnCasing(t);
|
|
175
|
+
if (n.invokeSource === "indexes") return {
|
|
176
|
+
sql: l(e),
|
|
177
177
|
params: []
|
|
178
178
|
};
|
|
179
|
-
let
|
|
179
|
+
let r = t.table[y.Symbol.Schema];
|
|
180
180
|
return {
|
|
181
|
-
sql: t.table[
|
|
181
|
+
sql: t.table[g] || r === void 0 ? l(t.table[y.Symbol.Name]) + "." + l(e) : l(r) + "." + l(t.table[y.Symbol.Name]) + "." + l(e),
|
|
182
182
|
params: []
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
if (
|
|
186
|
-
let e = t[
|
|
185
|
+
if (r(t, te)) {
|
|
186
|
+
let e = t[u].schema, n = t[u].name;
|
|
187
187
|
return {
|
|
188
|
-
sql: e === void 0 || t[
|
|
188
|
+
sql: e === void 0 || t[u].isAlias ? l(n) : l(e) + "." + l(n),
|
|
189
189
|
params: []
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
192
|
+
if (r(t, D)) {
|
|
193
|
+
if (r(t.value, k)) return {
|
|
194
194
|
sql: d(m.value++, t),
|
|
195
195
|
params: [t],
|
|
196
196
|
typings: ["none"]
|
|
197
197
|
};
|
|
198
|
-
let
|
|
199
|
-
if (n
|
|
198
|
+
let n = t.value === null ? null : t.encoder.mapToDriverValue(t.value);
|
|
199
|
+
if (r(n, e)) return this.buildQueryFromSourceParams([n], a);
|
|
200
200
|
if (p) return {
|
|
201
|
-
sql: this.mapInlineParam(
|
|
201
|
+
sql: this.mapInlineParam(n, a),
|
|
202
202
|
params: []
|
|
203
203
|
};
|
|
204
204
|
let i = ["none"];
|
|
205
205
|
return f && (i = [f(t.encoder)]), {
|
|
206
|
-
sql: d(m.value++,
|
|
207
|
-
params: [
|
|
206
|
+
sql: d(m.value++, n),
|
|
207
|
+
params: [n],
|
|
208
208
|
typings: i
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
return
|
|
211
|
+
return r(t, k) ? {
|
|
212
212
|
sql: d(m.value++, t),
|
|
213
213
|
params: [t],
|
|
214
214
|
typings: ["none"]
|
|
215
|
-
} :
|
|
216
|
-
sql:
|
|
215
|
+
} : r(t, e.Aliased) && t.fieldAlias !== void 0 ? {
|
|
216
|
+
sql: l(t.fieldAlias),
|
|
217
217
|
params: []
|
|
218
|
-
} :
|
|
219
|
-
sql:
|
|
218
|
+
} : r(t, c) ? t._.isWith ? {
|
|
219
|
+
sql: l(t._.alias),
|
|
220
220
|
params: []
|
|
221
221
|
} : this.buildQueryFromSourceParams([
|
|
222
|
-
new
|
|
222
|
+
new S("("),
|
|
223
223
|
t._.sql,
|
|
224
|
-
new
|
|
225
|
-
new
|
|
226
|
-
], a) :
|
|
227
|
-
sql:
|
|
224
|
+
new S(") "),
|
|
225
|
+
new w(t._.alias)
|
|
226
|
+
], a) : s(t) ? t.schema ? {
|
|
227
|
+
sql: l(t.schema) + "." + l(t.enumName),
|
|
228
228
|
params: []
|
|
229
229
|
} : {
|
|
230
|
-
sql:
|
|
230
|
+
sql: l(t.enumName),
|
|
231
231
|
params: []
|
|
232
|
-
} :
|
|
233
|
-
new
|
|
232
|
+
} : b(t) ? t.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([t.getSQL()], a) : this.buildQueryFromSourceParams([
|
|
233
|
+
new S("("),
|
|
234
234
|
t.getSQL(),
|
|
235
|
-
new
|
|
235
|
+
new S(")")
|
|
236
236
|
], a) : p ? {
|
|
237
237
|
sql: this.mapInlineParam(t, a),
|
|
238
238
|
params: []
|
|
@@ -268,61 +268,61 @@ var x = class {
|
|
|
268
268
|
if(e) {
|
|
269
269
|
return e ? this : void 0;
|
|
270
270
|
}
|
|
271
|
-
},
|
|
271
|
+
}, w = class {
|
|
272
272
|
constructor(e) {
|
|
273
273
|
this.value = e;
|
|
274
274
|
}
|
|
275
|
-
static [
|
|
275
|
+
static [n] = "Name";
|
|
276
276
|
brand;
|
|
277
277
|
getSQL() {
|
|
278
|
-
return new
|
|
278
|
+
return new C([this]);
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
|
-
function
|
|
281
|
+
function T(e) {
|
|
282
282
|
return typeof e == "object" && !!e && "mapToDriverValue" in e && typeof e.mapToDriverValue == "function";
|
|
283
283
|
}
|
|
284
|
-
var
|
|
284
|
+
var E = { mapFromDriverValue: (e) => e }, ee = { mapToDriverValue: (e) => e };
|
|
285
285
|
({
|
|
286
|
-
...
|
|
287
|
-
...
|
|
286
|
+
...E,
|
|
287
|
+
...ee
|
|
288
288
|
});
|
|
289
289
|
var D = class {
|
|
290
|
-
constructor(e, t =
|
|
290
|
+
constructor(e, t = ee) {
|
|
291
291
|
this.value = e, this.encoder = t;
|
|
292
292
|
}
|
|
293
|
-
static [
|
|
293
|
+
static [n] = "Param";
|
|
294
294
|
brand;
|
|
295
295
|
getSQL() {
|
|
296
|
-
return new
|
|
296
|
+
return new C([this]);
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
299
|
function O(e, ...t) {
|
|
300
300
|
let n = [];
|
|
301
|
-
(t.length > 0 || e.length > 0 && e[0] !== "") && n.push(new
|
|
302
|
-
for (let [r, i] of t.entries()) n.push(i, new
|
|
303
|
-
return new
|
|
301
|
+
(t.length > 0 || e.length > 0 && e[0] !== "") && n.push(new S(e[0]));
|
|
302
|
+
for (let [r, i] of t.entries()) n.push(i, new S(e[r + 1]));
|
|
303
|
+
return new C(n);
|
|
304
304
|
}
|
|
305
305
|
((e) => {
|
|
306
306
|
function t() {
|
|
307
|
-
return new
|
|
307
|
+
return new C([]);
|
|
308
308
|
}
|
|
309
309
|
e.empty = t;
|
|
310
310
|
function n(e) {
|
|
311
|
-
return new
|
|
311
|
+
return new C(e);
|
|
312
312
|
}
|
|
313
313
|
e.fromList = n;
|
|
314
314
|
function r(e) {
|
|
315
|
-
return new
|
|
315
|
+
return new C([new S(e)]);
|
|
316
316
|
}
|
|
317
317
|
e.raw = r;
|
|
318
318
|
function i(e, t) {
|
|
319
319
|
let n = [];
|
|
320
320
|
for (let [r, i] of e.entries()) r > 0 && t !== void 0 && n.push(t), n.push(i);
|
|
321
|
-
return new
|
|
321
|
+
return new C(n);
|
|
322
322
|
}
|
|
323
323
|
e.join = i;
|
|
324
324
|
function a(e) {
|
|
325
|
-
return new
|
|
325
|
+
return new w(e);
|
|
326
326
|
}
|
|
327
327
|
e.identifier = a;
|
|
328
328
|
function o(e) {
|
|
@@ -334,35 +334,35 @@ function O(e, ...t) {
|
|
|
334
334
|
}
|
|
335
335
|
e.param = s;
|
|
336
336
|
})(O ||= {}), ((e) => {
|
|
337
|
-
class
|
|
337
|
+
class t {
|
|
338
338
|
constructor(e, t) {
|
|
339
339
|
this.sql = e, this.fieldAlias = t;
|
|
340
340
|
}
|
|
341
|
-
static [
|
|
341
|
+
static [n] = "SQL.Aliased";
|
|
342
342
|
isSelectionField = !1;
|
|
343
343
|
getSQL() {
|
|
344
344
|
return this.sql;
|
|
345
345
|
}
|
|
346
346
|
clone() {
|
|
347
|
-
return new
|
|
347
|
+
return new t(this.sql, this.fieldAlias);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
e.Aliased =
|
|
351
|
-
})(
|
|
350
|
+
e.Aliased = t;
|
|
351
|
+
})(C ||= {});
|
|
352
352
|
var k = class {
|
|
353
353
|
constructor(e) {
|
|
354
354
|
this.name = e;
|
|
355
355
|
}
|
|
356
|
-
static [
|
|
356
|
+
static [n] = "Placeholder";
|
|
357
357
|
getSQL() {
|
|
358
|
-
return new
|
|
358
|
+
return new C([this]);
|
|
359
359
|
}
|
|
360
|
-
}, A = Symbol.for("drizzle:IsDrizzleView"),
|
|
361
|
-
static [
|
|
362
|
-
[
|
|
360
|
+
}, A = Symbol.for("drizzle:IsDrizzleView"), te = class {
|
|
361
|
+
static [n] = "View";
|
|
362
|
+
[u];
|
|
363
363
|
[A] = !0;
|
|
364
364
|
constructor({ name: e, schema: t, selectedFields: n, query: r }) {
|
|
365
|
-
this[
|
|
365
|
+
this[u] = {
|
|
366
366
|
name: e,
|
|
367
367
|
originalName: e,
|
|
368
368
|
schema: t,
|
|
@@ -373,96 +373,96 @@ var k = class {
|
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
375
|
getSQL() {
|
|
376
|
-
return new
|
|
376
|
+
return new C([this]);
|
|
377
377
|
}
|
|
378
378
|
};
|
|
379
|
-
|
|
380
|
-
return new
|
|
381
|
-
},
|
|
382
|
-
return new
|
|
383
|
-
},
|
|
384
|
-
return new
|
|
379
|
+
i.prototype.getSQL = function() {
|
|
380
|
+
return new C([this]);
|
|
381
|
+
}, y.prototype.getSQL = function() {
|
|
382
|
+
return new C([this]);
|
|
383
|
+
}, c.prototype.getSQL = function() {
|
|
384
|
+
return new C([this]);
|
|
385
385
|
};
|
|
386
386
|
//#endregion
|
|
387
387
|
//#region node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
388
|
-
function
|
|
389
|
-
return
|
|
388
|
+
function j(e, t) {
|
|
389
|
+
return T(t) && !b(e) && !r(e, D) && !r(e, k) && !r(e, i) && !r(e, y) && !r(e, te) ? new D(e, t) : e;
|
|
390
390
|
}
|
|
391
|
-
var
|
|
392
|
-
function
|
|
391
|
+
var M = (e, t) => O`${e} = ${j(t, e)}`, N = (e, t) => O`${e} <> ${j(t, e)}`;
|
|
392
|
+
function P(...e) {
|
|
393
393
|
let t = e.filter((e) => e !== void 0);
|
|
394
|
-
if (t.length !== 0) return t.length === 1 ? new
|
|
395
|
-
new
|
|
396
|
-
O.join(t, new
|
|
397
|
-
new
|
|
394
|
+
if (t.length !== 0) return t.length === 1 ? new C(t) : new C([
|
|
395
|
+
new S("("),
|
|
396
|
+
O.join(t, new S(" and ")),
|
|
397
|
+
new S(")")
|
|
398
398
|
]);
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function F(...e) {
|
|
401
401
|
let t = e.filter((e) => e !== void 0);
|
|
402
|
-
if (t.length !== 0) return t.length === 1 ? new
|
|
403
|
-
new
|
|
404
|
-
O.join(t, new
|
|
405
|
-
new
|
|
402
|
+
if (t.length !== 0) return t.length === 1 ? new C(t) : new C([
|
|
403
|
+
new S("("),
|
|
404
|
+
O.join(t, new S(" or ")),
|
|
405
|
+
new S(")")
|
|
406
406
|
]);
|
|
407
407
|
}
|
|
408
|
-
var
|
|
409
|
-
function
|
|
410
|
-
return Array.isArray(t) ? t.length === 0 ? O`false` : O`${e} in ${t.map((t) =>
|
|
408
|
+
var ne = (e, t) => O`${e} > ${j(t, e)}`, I = (e, t) => O`${e} >= ${j(t, e)}`, re = (e, t) => O`${e} < ${j(t, e)}`, L = (e, t) => O`${e} <= ${j(t, e)}`;
|
|
409
|
+
function ie(e, t) {
|
|
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
|
|
413
|
-
return Array.isArray(t) ? t.length === 0 ? O`true` : O`${e} not in ${t.map((t) =>
|
|
412
|
+
function ae(e, t) {
|
|
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 oe(e) {
|
|
416
416
|
return O`${e} is null`;
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function se(e) {
|
|
419
419
|
return O`${e} is not null`;
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function ce(e, t) {
|
|
422
422
|
if (Array.isArray(t)) {
|
|
423
423
|
if (t.length === 0) throw Error("arrayContains requires at least one value");
|
|
424
|
-
return O`${e} @> ${O`${
|
|
424
|
+
return O`${e} @> ${O`${j(t, e)}`}`;
|
|
425
425
|
}
|
|
426
|
-
return O`${e} @> ${
|
|
426
|
+
return O`${e} @> ${j(t, e)}`;
|
|
427
427
|
}
|
|
428
|
-
function
|
|
428
|
+
function le(e, t) {
|
|
429
429
|
if (Array.isArray(t)) {
|
|
430
430
|
if (t.length === 0) throw Error("arrayContained requires at least one value");
|
|
431
|
-
return O`${e} <@ ${O`${
|
|
431
|
+
return O`${e} <@ ${O`${j(t, e)}`}`;
|
|
432
432
|
}
|
|
433
|
-
return O`${e} <@ ${
|
|
433
|
+
return O`${e} <@ ${j(t, e)}`;
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function ue(e, t) {
|
|
436
436
|
if (Array.isArray(t)) {
|
|
437
437
|
if (t.length === 0) throw Error("arrayOverlaps requires at least one value");
|
|
438
|
-
return O`${e} && ${O`${
|
|
438
|
+
return O`${e} && ${O`${j(t, e)}`}`;
|
|
439
439
|
}
|
|
440
|
-
return O`${e} && ${
|
|
440
|
+
return O`${e} && ${j(t, e)}`;
|
|
441
441
|
}
|
|
442
442
|
//#endregion
|
|
443
443
|
//#region node_modules/drizzle-orm/sql/expressions/select.js
|
|
444
|
-
function
|
|
444
|
+
function de(e) {
|
|
445
445
|
return O`${e} asc`;
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function fe(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 pe(e) {
|
|
453
453
|
return O`count(${e || O.raw("*")})`.mapWith(Number);
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function me(e) {
|
|
456
456
|
return O`count(distinct ${e})`.mapWith(Number);
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function R(e) {
|
|
459
459
|
return O`sum(${e})`.mapWith(String);
|
|
460
460
|
}
|
|
461
|
-
function
|
|
462
|
-
return O`max(${e})`.mapWith(
|
|
461
|
+
function z(e) {
|
|
462
|
+
return O`max(${e})`.mapWith(r(e, i) ? e : String);
|
|
463
463
|
}
|
|
464
|
-
function
|
|
465
|
-
return O`min(${e})`.mapWith(
|
|
464
|
+
function B(e) {
|
|
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
|
|
@@ -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
|
+
}, he = class extends V {
|
|
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
|
+
}, ge = class extends V {
|
|
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
|
+
}, _e = class extends V {
|
|
784
784
|
getEngineType() {
|
|
785
785
|
return "sqlite";
|
|
786
786
|
}
|
|
@@ -932,11 +932,11 @@ var V = class {
|
|
|
932
932
|
default: throw Error(`Unsupported window function: ${e}`);
|
|
933
933
|
}
|
|
934
934
|
}
|
|
935
|
-
},
|
|
935
|
+
}, ve = class extends ge {
|
|
936
936
|
getEngineType() {
|
|
937
937
|
return "singlestore";
|
|
938
938
|
}
|
|
939
|
-
},
|
|
939
|
+
}, ye = class extends V {
|
|
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
|
+
}, be = class extends V {
|
|
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
|
+
}, xe = class extends V {
|
|
1207
1207
|
getEngineType() {
|
|
1208
1208
|
return "snowflake";
|
|
1209
1209
|
}
|
|
@@ -1339,15 +1339,15 @@ var V = class {
|
|
|
1339
1339
|
};
|
|
1340
1340
|
//#endregion
|
|
1341
1341
|
//#region src/server/database-utils.ts
|
|
1342
|
-
function
|
|
1342
|
+
function Se(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 he();
|
|
1345
|
+
case "mysql": return new ge();
|
|
1346
|
+
case "sqlite": return new _e();
|
|
1347
|
+
case "singlestore": return new ve();
|
|
1348
|
+
case "duckdb": return new ye();
|
|
1349
|
+
case "databend": return new be();
|
|
1350
|
+
case "snowflake": return new xe();
|
|
1351
1351
|
default: throw Error(`Unsupported database engine: ${e}`);
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
@@ -1356,12 +1356,12 @@ function xe(e) {
|
|
|
1356
1356
|
var H = 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 = Se(n || this.getEngineType());
|
|
1360
1360
|
}
|
|
1361
1361
|
};
|
|
1362
1362
|
//#endregion
|
|
1363
1363
|
//#region src/server/explain/postgres-parser.ts
|
|
1364
|
-
function
|
|
1364
|
+
function Ce(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 Se(e, t) {
|
|
|
1374
1374
|
o = parseFloat(l[1]);
|
|
1375
1375
|
continue;
|
|
1376
1376
|
}
|
|
1377
|
-
let u =
|
|
1377
|
+
let u = we(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 Se(e, t) {
|
|
|
1404
1404
|
sql: t
|
|
1405
1405
|
};
|
|
1406
1406
|
}
|
|
1407
|
-
function
|
|
1407
|
+
function we(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 Ce(e) {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
//#endregion
|
|
1424
1424
|
//#region src/server/executors/postgres-executor.ts
|
|
1425
|
-
function
|
|
1425
|
+
function Te(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 Ee = class extends H {
|
|
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 = Te(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 Te = 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 Te(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 Ce(a, {
|
|
1479
1479
|
sql: e,
|
|
1480
1480
|
params: t
|
|
1481
1481
|
});
|
|
@@ -1484,7 +1484,7 @@ var Te = 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 = Te(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 Te = class extends H {
|
|
|
1514
1514
|
}
|
|
1515
1515
|
}
|
|
1516
1516
|
};
|
|
1517
|
-
function
|
|
1518
|
-
return new
|
|
1517
|
+
function De(e, t) {
|
|
1518
|
+
return new Ee(e, t, "postgres");
|
|
1519
1519
|
}
|
|
1520
1520
|
//#endregion
|
|
1521
1521
|
//#region src/server/explain/mysql-parser.ts
|
|
1522
|
-
function
|
|
1522
|
+
function Oe(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 De(e, t) {
|
|
|
1533
1533
|
default: return `MySQL ${e}`;
|
|
1534
1534
|
}
|
|
1535
1535
|
}
|
|
1536
|
-
function
|
|
1536
|
+
function ke(e, t) {
|
|
1537
1537
|
let n = [], r = [], i = !1, a = 0;
|
|
1538
1538
|
for (let t of e) {
|
|
1539
|
-
let e =
|
|
1539
|
+
let e = Oe(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 Oe(e, t) {
|
|
|
1567
1567
|
}
|
|
1568
1568
|
//#endregion
|
|
1569
1569
|
//#region src/server/executors/mysql-executor.ts
|
|
1570
|
-
var
|
|
1570
|
+
var Ae = class extends H {
|
|
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 ke = class extends H {
|
|
|
1617
1617
|
filtered: Number(e.filtered) || 100,
|
|
1618
1618
|
Extra: e.Extra || null
|
|
1619
1619
|
});
|
|
1620
|
-
return
|
|
1620
|
+
return ke(s, {
|
|
1621
1621
|
sql: e,
|
|
1622
1622
|
params: t
|
|
1623
1623
|
});
|
|
@@ -1651,12 +1651,12 @@ var ke = class extends H {
|
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
1653
|
};
|
|
1654
|
-
function
|
|
1655
|
-
return new
|
|
1654
|
+
function je(e, t) {
|
|
1655
|
+
return new Ae(e, t, "mysql");
|
|
1656
1656
|
}
|
|
1657
1657
|
//#endregion
|
|
1658
1658
|
//#region src/server/explain/sqlite-parser.ts
|
|
1659
|
-
function
|
|
1659
|
+
function Me(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 je(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 Ne(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 = Me(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 Me(e, t) {
|
|
|
1715
1715
|
}
|
|
1716
1716
|
//#endregion
|
|
1717
1717
|
//#region src/server/executors/sqlite-executor.ts
|
|
1718
|
-
var
|
|
1718
|
+
var Pe = class extends H {
|
|
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 Ne = class extends H {
|
|
|
1764
1764
|
notused: Number(e.notused) || 0,
|
|
1765
1765
|
detail: String(e.detail || "")
|
|
1766
1766
|
});
|
|
1767
|
-
return
|
|
1767
|
+
return Ne(s, {
|
|
1768
1768
|
sql: e,
|
|
1769
1769
|
params: t
|
|
1770
1770
|
});
|
|
@@ -1797,29 +1797,29 @@ var Ne = class extends H {
|
|
|
1797
1797
|
}
|
|
1798
1798
|
}
|
|
1799
1799
|
};
|
|
1800
|
-
function
|
|
1801
|
-
return new
|
|
1800
|
+
function Fe(e, t) {
|
|
1801
|
+
return new Pe(e, t, "sqlite");
|
|
1802
1802
|
}
|
|
1803
1803
|
//#endregion
|
|
1804
1804
|
//#region src/server/executors/singlestore-executor.ts
|
|
1805
|
-
var
|
|
1805
|
+
var Ie = class extends Ae {
|
|
1806
1806
|
getEngineType() {
|
|
1807
1807
|
return "singlestore";
|
|
1808
1808
|
}
|
|
1809
1809
|
};
|
|
1810
|
-
function
|
|
1811
|
-
return new
|
|
1810
|
+
function Le(e, t) {
|
|
1811
|
+
return new Ie(e, t);
|
|
1812
1812
|
}
|
|
1813
1813
|
//#endregion
|
|
1814
1814
|
//#region src/server/explain/duckdb-parser.ts
|
|
1815
|
-
function
|
|
1815
|
+
function Re(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 = Be(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 = ze(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 Le(e, t) {
|
|
|
1846
1846
|
sql: t
|
|
1847
1847
|
};
|
|
1848
1848
|
}
|
|
1849
|
-
function
|
|
1849
|
+
function ze(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 Be(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 ze(e) {
|
|
|
1878
1878
|
}
|
|
1879
1879
|
//#endregion
|
|
1880
1880
|
//#region src/server/executors/duckdb-executor.ts
|
|
1881
|
-
var
|
|
1881
|
+
var Ve = class extends H {
|
|
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 Be = class extends H {
|
|
|
1972
1972
|
typeof t == "string" && a.push(t);
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
|
-
return
|
|
1975
|
+
return Re(a, {
|
|
1976
1976
|
sql: e,
|
|
1977
1977
|
params: t
|
|
1978
1978
|
});
|
|
@@ -2005,19 +2005,19 @@ var Be = class extends H {
|
|
|
2005
2005
|
}
|
|
2006
2006
|
}
|
|
2007
2007
|
};
|
|
2008
|
-
function
|
|
2009
|
-
return new
|
|
2008
|
+
function He(e, t) {
|
|
2009
|
+
return new Ve(e, t, "duckdb");
|
|
2010
2010
|
}
|
|
2011
2011
|
//#endregion
|
|
2012
2012
|
//#region src/server/explain/databend-parser.ts
|
|
2013
|
-
function
|
|
2013
|
+
function Ue(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 = Ge(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 = We(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 He(e, t) {
|
|
|
2044
2044
|
sql: t
|
|
2045
2045
|
};
|
|
2046
2046
|
}
|
|
2047
|
-
function
|
|
2047
|
+
function We(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 Ge(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 We(e) {
|
|
|
2064
2064
|
}
|
|
2065
2065
|
//#endregion
|
|
2066
2066
|
//#region src/server/executors/databend-executor.ts
|
|
2067
|
-
var
|
|
2067
|
+
var Ke = class extends H {
|
|
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 Ge = class extends H {
|
|
|
2158
2158
|
typeof t == "string" && a.push(t);
|
|
2159
2159
|
}
|
|
2160
2160
|
}
|
|
2161
|
-
return
|
|
2161
|
+
return Ue(a, {
|
|
2162
2162
|
sql: e,
|
|
2163
2163
|
params: t
|
|
2164
2164
|
});
|
|
@@ -2167,19 +2167,19 @@ var Ge = class extends H {
|
|
|
2167
2167
|
return !e || e.length, [];
|
|
2168
2168
|
}
|
|
2169
2169
|
};
|
|
2170
|
-
function
|
|
2171
|
-
return new
|
|
2170
|
+
function qe(e, t) {
|
|
2171
|
+
return new Ke(e, t, "databend");
|
|
2172
2172
|
}
|
|
2173
2173
|
//#endregion
|
|
2174
2174
|
//#region src/server/explain/snowflake-parser.ts
|
|
2175
|
-
function
|
|
2175
|
+
function Je(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 = Xe(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 = Ye(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 qe(e, t) {
|
|
|
2206
2206
|
sql: t
|
|
2207
2207
|
};
|
|
2208
2208
|
}
|
|
2209
|
-
function
|
|
2209
|
+
function Ye(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 Xe(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 Ye(e) {
|
|
|
2226
2226
|
}
|
|
2227
2227
|
//#endregion
|
|
2228
2228
|
//#region src/server/executors/snowflake-executor.ts
|
|
2229
|
-
var
|
|
2229
|
+
var Ze = class extends H {
|
|
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 Xe = class extends H {
|
|
|
2319
2319
|
typeof t == "string" && i.push(t);
|
|
2320
2320
|
}
|
|
2321
2321
|
}
|
|
2322
|
-
return
|
|
2322
|
+
return Je(i, {
|
|
2323
2323
|
sql: e,
|
|
2324
2324
|
params: t
|
|
2325
2325
|
});
|
|
@@ -2328,23 +2328,23 @@ var Xe = class extends H {
|
|
|
2328
2328
|
return [];
|
|
2329
2329
|
}
|
|
2330
2330
|
};
|
|
2331
|
-
function
|
|
2332
|
-
return new
|
|
2331
|
+
function Qe(e, t) {
|
|
2332
|
+
return new Ze(e, t, "snowflake");
|
|
2333
2333
|
}
|
|
2334
2334
|
//#endregion
|
|
2335
2335
|
//#region src/server/executors/index.ts
|
|
2336
|
-
function
|
|
2336
|
+
function $e(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 De(e, t);
|
|
2339
|
+
case "mysql": return je(e, t);
|
|
2340
|
+
case "sqlite": return Fe(e, t);
|
|
2341
|
+
case "singlestore": return Le(e, t);
|
|
2342
|
+
case "duckdb": return He(e, t);
|
|
2343
|
+
case "databend": return qe(e, t);
|
|
2344
|
+
case "snowflake": return Qe(e, t);
|
|
2345
|
+
}
|
|
2346
|
+
if (e.all && e.run) return Fe(e, t);
|
|
2347
|
+
if (e.execute) return De(e, t);
|
|
2348
2348
|
throw Error("Unable to determine database engine type. Please specify engineType parameter.");
|
|
2349
2349
|
}
|
|
2350
2350
|
//#endregion
|
|
@@ -2352,7 +2352,7 @@ function Qe(e, t, n) {
|
|
|
2352
2352
|
function U(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 et(e) {
|
|
2356
2356
|
switch (e) {
|
|
2357
2357
|
case "belongsTo": return "hasMany";
|
|
2358
2358
|
case "hasMany": return "belongsTo";
|
|
@@ -2361,7 +2361,7 @@ function $e(e) {
|
|
|
2361
2361
|
default: return e;
|
|
2362
2362
|
}
|
|
2363
2363
|
}
|
|
2364
|
-
function
|
|
2364
|
+
function tt(e, t) {
|
|
2365
2365
|
if (t) return t;
|
|
2366
2366
|
switch (e) {
|
|
2367
2367
|
case "belongsTo": return "inner";
|
|
@@ -2371,26 +2371,26 @@ function et(e, t) {
|
|
|
2371
2371
|
default: return "left";
|
|
2372
2372
|
}
|
|
2373
2373
|
}
|
|
2374
|
-
function
|
|
2374
|
+
function nt(e) {
|
|
2375
2375
|
return e && typeof e == "object" ? O`${O`${e}`}` : e;
|
|
2376
2376
|
}
|
|
2377
|
-
function
|
|
2377
|
+
function rt(e) {
|
|
2378
2378
|
if (e === "__proto__" || e === "constructor" || e === "prototype") throw Error(`Unsafe property key: ${e}`);
|
|
2379
2379
|
return e;
|
|
2380
2380
|
}
|
|
2381
2381
|
function W(e, t) {
|
|
2382
|
-
return
|
|
2382
|
+
return nt(typeof e == "function" ? e(t) : e);
|
|
2383
2383
|
}
|
|
2384
|
-
function
|
|
2384
|
+
function it(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) {
|
|
2388
|
-
let t = e.as ||
|
|
2388
|
+
let t = e.as || M;
|
|
2389
2389
|
o.push(t(e.source, e.target));
|
|
2390
2390
|
}
|
|
2391
2391
|
let s = [];
|
|
2392
2392
|
for (let e of i) {
|
|
2393
|
-
let t = e.as ||
|
|
2393
|
+
let t = e.as || M;
|
|
2394
2394
|
s.push(t(e.source, e.target));
|
|
2395
2395
|
}
|
|
2396
2396
|
let c;
|
|
@@ -2398,16 +2398,16 @@ function rt(e, t) {
|
|
|
2398
2398
|
let e = a(t);
|
|
2399
2399
|
c = Array.isArray(e) ? e : [e];
|
|
2400
2400
|
}
|
|
2401
|
-
let l =
|
|
2401
|
+
let l = tt("belongsToMany", e.sqlJoinType);
|
|
2402
2402
|
return {
|
|
2403
2403
|
junctionJoins: [{
|
|
2404
2404
|
joinType: l,
|
|
2405
2405
|
table: n,
|
|
2406
|
-
condition:
|
|
2406
|
+
condition: P(...o)
|
|
2407
2407
|
}, {
|
|
2408
2408
|
joinType: l,
|
|
2409
2409
|
table: n,
|
|
2410
|
-
condition:
|
|
2410
|
+
condition: P(...s)
|
|
2411
2411
|
}],
|
|
2412
2412
|
junctionSecurityConditions: c
|
|
2413
2413
|
};
|
|
@@ -2420,7 +2420,7 @@ function G(e) {
|
|
|
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 at(e, t) {
|
|
2424
2424
|
return `timeDim:${e}:${JSON.stringify(t)}`;
|
|
2425
2425
|
}
|
|
2426
2426
|
var K = class {
|
|
@@ -2461,37 +2461,37 @@ var K = class {
|
|
|
2461
2461
|
};
|
|
2462
2462
|
}
|
|
2463
2463
|
};
|
|
2464
|
-
function
|
|
2464
|
+
function ot(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(...ot(n.and)) : "or" in n && n.or ? t.push(...ot(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 st(e, t, n = {}) {
|
|
2472
|
+
let r = n.keyPrefix ?? "drizzle-cube:", i = ct(e), a = `${r}query:${pt(JSON.stringify(i))}`;
|
|
2473
2473
|
if (n.includeSecurityContext !== !1) {
|
|
2474
|
-
let e =
|
|
2474
|
+
let e = pt(n.securityContextSerializer ? n.securityContextSerializer(t) : JSON.stringify(J(t)));
|
|
2475
2475
|
a += `:ctx:${e}`;
|
|
2476
2476
|
}
|
|
2477
2477
|
return a;
|
|
2478
2478
|
}
|
|
2479
|
-
function
|
|
2479
|
+
function ct(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
2483
|
filters: e.filters ? q(e.filters) : void 0,
|
|
2484
|
-
timeDimensions: e.timeDimensions ?
|
|
2484
|
+
timeDimensions: e.timeDimensions ? ft(e.timeDimensions) : void 0,
|
|
2485
2485
|
limit: e.limit,
|
|
2486
2486
|
offset: e.offset,
|
|
2487
2487
|
order: e.order ? J(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 ? lt(e.funnel) : void 0,
|
|
2490
|
+
flow: e.flow ? ut(e.flow) : void 0,
|
|
2491
|
+
retention: e.retention ? dt(e.retention) : void 0
|
|
2492
2492
|
};
|
|
2493
2493
|
}
|
|
2494
|
-
function
|
|
2494
|
+
function lt(e) {
|
|
2495
2495
|
return {
|
|
2496
2496
|
bindingKey: e.bindingKey,
|
|
2497
2497
|
timeDimension: e.timeDimension,
|
|
@@ -2507,7 +2507,7 @@ function ct(e) {
|
|
|
2507
2507
|
globalTimeWindow: e.globalTimeWindow
|
|
2508
2508
|
};
|
|
2509
2509
|
}
|
|
2510
|
-
function
|
|
2510
|
+
function ut(e) {
|
|
2511
2511
|
return {
|
|
2512
2512
|
bindingKey: e.bindingKey,
|
|
2513
2513
|
timeDimension: e.timeDimension,
|
|
@@ -2523,7 +2523,7 @@ function lt(e) {
|
|
|
2523
2523
|
joinStrategy: e.joinStrategy
|
|
2524
2524
|
};
|
|
2525
2525
|
}
|
|
2526
|
-
function
|
|
2526
|
+
function dt(e) {
|
|
2527
2527
|
return {
|
|
2528
2528
|
timeDimension: e.timeDimension,
|
|
2529
2529
|
bindingKey: e.bindingKey,
|
|
@@ -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 ft(e) {
|
|
2551
2551
|
return [...e].map((e) => ({
|
|
2552
2552
|
dimension: e.dimension,
|
|
2553
2553
|
granularity: e.granularity,
|
|
@@ -2562,7 +2562,7 @@ function dt(e) {
|
|
|
2562
2562
|
function J(e) {
|
|
2563
2563
|
return typeof e != "object" || !e ? e : Array.isArray(e) ? e.map(J) : Object.keys(e).sort().reduce((t, n) => (t[n] = J(e[n]), t), {});
|
|
2564
2564
|
}
|
|
2565
|
-
function
|
|
2565
|
+
function pt(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");
|
|
@@ -2575,7 +2575,7 @@ var Y = class {
|
|
|
2575
2575
|
}
|
|
2576
2576
|
buildTimeDimensionExpression(e, t, n) {
|
|
2577
2577
|
let r = W(e, n);
|
|
2578
|
-
return t ? this.databaseAdapter.buildTimeDimension(t, r) : r instanceof
|
|
2578
|
+
return t ? this.databaseAdapter.buildTimeDimension(t, r) : r instanceof C ? r : O`${r}`;
|
|
2579
2579
|
}
|
|
2580
2580
|
buildDateRangeCondition(e, t) {
|
|
2581
2581
|
if (!t) return null;
|
|
@@ -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
|
|
2589
|
+
return P(I(e, n), L(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()),
|
|
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(I(e, t), L(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()),
|
|
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(I(e, s), L(e, c));
|
|
2605
2605
|
}
|
|
2606
2606
|
return null;
|
|
2607
2607
|
}
|
|
@@ -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" ? ie(e, a.map((e) => this.dateTimeBuilder.normalizeDate(e) || e)) : ie(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 ? ae(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 ne(e, o);
|
|
2761
|
+
case "gte": return I(e, o);
|
|
2762
|
+
case "lt": return re(e, o);
|
|
2763
|
+
case "lte": return L(e, o);
|
|
2764
|
+
case "set": return se(e);
|
|
2765
|
+
case "notSet": return oe(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,43 +2772,43 @@ 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
|
|
2775
|
+
return P(I(e, t), L(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 ? re(e, t) : null;
|
|
2782
2782
|
}
|
|
2783
2783
|
case "afterDate": {
|
|
2784
2784
|
let t = this.dateTimeBuilder.normalizeDate(o);
|
|
2785
|
-
return t ?
|
|
2785
|
+
return t ? ne(e, t) : null;
|
|
2786
2786
|
}
|
|
2787
|
-
case "between": return a.length >= 2 ?
|
|
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(I(e, a[0]), L(e, a[1])) : null;
|
|
2788
|
+
case "notBetween": return a.length >= 2 ? F(re(e, a[0]), ne(e, a[1])) : null;
|
|
2789
|
+
case "in": return a.length > 0 ? ie(e, a) : null;
|
|
2790
|
+
case "notIn": return a.length > 0 ? ae(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
|
|
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 F(oe(e), M(e, ""));
|
|
2797
|
+
case "isNotEmpty": return P(se(e), N(e, ""));
|
|
2798
|
+
case "arrayContains": return this.databaseAdapter.getEngineType() === "postgres" ? ce(e, a) : null;
|
|
2799
|
+
case "arrayOverlaps": return this.databaseAdapter.getEngineType() === "postgres" ? ue(e, a) : null;
|
|
2800
|
+
case "arrayContained": return this.databaseAdapter.getEngineType() === "postgres" ? le(e, a) : null;
|
|
2801
2801
|
default: return null;
|
|
2802
2802
|
}
|
|
2803
2803
|
}
|
|
2804
2804
|
buildLogicalFilter(e, t, n) {
|
|
2805
2805
|
if ("and" in e && e.and) {
|
|
2806
2806
|
let r = e.and.map((e) => this.buildSingleFilter(e, t, n)).filter((e) => e !== null);
|
|
2807
|
-
return r.length > 0 ? r.length === 1 ? r[0] :
|
|
2807
|
+
return r.length > 0 ? r.length === 1 ? r[0] : P(...r) : null;
|
|
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] : F(...r) : null;
|
|
2812
2812
|
}
|
|
2813
2813
|
return null;
|
|
2814
2814
|
}
|
|
@@ -2949,31 +2949,37 @@ var Y = class {
|
|
|
2949
2949
|
};
|
|
2950
2950
|
//#endregion
|
|
2951
2951
|
//#region src/server/template-substitution.ts
|
|
2952
|
-
function
|
|
2953
|
-
let { cube:
|
|
2954
|
-
for (let
|
|
2955
|
-
let { originalRef:
|
|
2956
|
-
if (!
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2952
|
+
function mt(t, n) {
|
|
2953
|
+
let { cube: r, allCubes: i, resolvedMeasures: a } = n, o = ht(t), s = /* @__PURE__ */ new Map();
|
|
2954
|
+
for (let t of o) {
|
|
2955
|
+
let { originalRef: n, cubeName: o, fieldName: c } = t, l = o || r.name;
|
|
2956
|
+
if (!i.get(l)) throw Error(e("server.validation.template.substituteTargetCubeNotFound", {
|
|
2957
|
+
ref: `{${n}}`,
|
|
2958
|
+
cubeName: l
|
|
2959
|
+
}));
|
|
2960
|
+
let u = `${l}.${c}`, d = a.get(u);
|
|
2961
|
+
if (!d) throw Error(e("server.validation.template.substituteMeasureNotResolved", {
|
|
2962
|
+
ref: `{${n}}`,
|
|
2963
|
+
measureName: u
|
|
2964
|
+
}));
|
|
2965
|
+
let f = O`${d()}`;
|
|
2966
|
+
s.set(n, f);
|
|
2967
|
+
}
|
|
2968
|
+
let c = [], l = [], u = 0;
|
|
2969
|
+
for (let e of o) {
|
|
2970
|
+
let n = `{${e.originalRef}}`, r = t.indexOf(n, u);
|
|
2965
2971
|
if (r >= 0) {
|
|
2966
|
-
|
|
2967
|
-
let i =
|
|
2968
|
-
i &&
|
|
2972
|
+
c.push(t.substring(u, r));
|
|
2973
|
+
let i = s.get(e.originalRef);
|
|
2974
|
+
i && l.push(i), u = r + n.length;
|
|
2969
2975
|
}
|
|
2970
2976
|
}
|
|
2971
|
-
if (
|
|
2972
|
-
let
|
|
2973
|
-
for (let e = 0; e <
|
|
2974
|
-
return O.join(
|
|
2977
|
+
if (c.push(t.substring(u)), l.length === 0) return O.raw(t);
|
|
2978
|
+
let d = [];
|
|
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
|
+
return O.join(d, O.raw(""));
|
|
2975
2981
|
}
|
|
2976
|
-
function
|
|
2982
|
+
function ht(e) {
|
|
2977
2983
|
if (e.length > 1e3) return [];
|
|
2978
2984
|
let t = e.matchAll(/\{([^}]+)\}/g), n = [];
|
|
2979
2985
|
for (let e of t) {
|
|
@@ -2993,26 +2999,26 @@ function mt(e) {
|
|
|
2993
2999
|
}
|
|
2994
3000
|
return n;
|
|
2995
3001
|
}
|
|
2996
|
-
function
|
|
2997
|
-
let
|
|
2998
|
-
for (let
|
|
2999
|
-
else if (
|
|
3000
|
-
|
|
3002
|
+
function gt(t) {
|
|
3003
|
+
let n = [], r = 0;
|
|
3004
|
+
for (let i = 0; i < t.length; i++) if (t[i] === "{") r++;
|
|
3005
|
+
else if (t[i] === "}" && (r--, r < 0)) {
|
|
3006
|
+
n.push(e("server.validation.template.unmatchedClosingBrace", { position: i }));
|
|
3001
3007
|
break;
|
|
3002
3008
|
}
|
|
3003
|
-
|
|
3004
|
-
let
|
|
3005
|
-
for (let
|
|
3006
|
-
let
|
|
3007
|
-
/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(
|
|
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 = ht(t);
|
|
3011
|
+
for (let t of i) {
|
|
3012
|
+
let r = t.cubeName ? `${t.cubeName}.${t.fieldName}` : t.fieldName;
|
|
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}}` }));
|
|
3008
3014
|
}
|
|
3009
3015
|
return {
|
|
3010
|
-
isValid:
|
|
3011
|
-
errors:
|
|
3016
|
+
isValid: n.length === 0,
|
|
3017
|
+
errors: n
|
|
3012
3018
|
};
|
|
3013
3019
|
}
|
|
3014
|
-
function
|
|
3015
|
-
let n =
|
|
3020
|
+
function _t(e, t) {
|
|
3021
|
+
let n = ht(e), r = /* @__PURE__ */ new Set();
|
|
3016
3022
|
for (let e of n) {
|
|
3017
3023
|
let n = `${e.cubeName || t}.${e.fieldName}`;
|
|
3018
3024
|
r.add(n);
|
|
@@ -3039,11 +3045,11 @@ var Q = class e {
|
|
|
3039
3045
|
n && c.add(n);
|
|
3040
3046
|
continue;
|
|
3041
3047
|
}
|
|
3042
|
-
Z.isCalculatedMeasure(d) ? (s.push(r),
|
|
3048
|
+
Z.isCalculatedMeasure(d) ? (s.push(r), _t(d.calculatedSql, t).forEach((e) => c.add(e)), l.getAllDependencies(r).forEach((e) => {
|
|
3043
3049
|
let [t, r] = e.split("."), i = n.get(t);
|
|
3044
3050
|
if (i && i.measures[r]) {
|
|
3045
3051
|
let e = i.measures[r];
|
|
3046
|
-
Z.isCalculatedMeasure(e) &&
|
|
3052
|
+
Z.isCalculatedMeasure(e) && _t(e.calculatedSql, t).forEach((e) => c.add(e));
|
|
3047
3053
|
}
|
|
3048
3054
|
})) : o.push(r);
|
|
3049
3055
|
}
|
|
@@ -3074,7 +3080,7 @@ var Q = class e {
|
|
|
3074
3080
|
}
|
|
3075
3081
|
buildCalculatedMeasure(e, t, n, r, i) {
|
|
3076
3082
|
if (!e.calculatedSql) throw Error(`Calculated measure '${t.name}.${e.name}' missing calculatedSql property`);
|
|
3077
|
-
return
|
|
3083
|
+
return mt(this.databaseAdapter.preprocessCalculatedTemplate(e.calculatedSql), {
|
|
3078
3084
|
cube: t,
|
|
3079
3085
|
allCubes: n,
|
|
3080
3086
|
resolvedMeasures: r,
|
|
@@ -3083,7 +3089,7 @@ var Q = class e {
|
|
|
3083
3089
|
}
|
|
3084
3090
|
buildCTECalculatedMeasure(e, t, n, r, i) {
|
|
3085
3091
|
if (!e.calculatedSql) throw Error(`Calculated measure '${t.name}.${e.name || "unknown"}' missing calculatedSql property`);
|
|
3086
|
-
let a = /* @__PURE__ */ new Map(), o =
|
|
3092
|
+
let a = /* @__PURE__ */ new Map(), o = _t(e.calculatedSql, t.name);
|
|
3087
3093
|
for (let e of o) {
|
|
3088
3094
|
let [t, i] = e.split("."), o = r.get(t);
|
|
3089
3095
|
if (o && o.measures[i]) {
|
|
@@ -3094,21 +3100,21 @@ var Q = class e {
|
|
|
3094
3100
|
case "count":
|
|
3095
3101
|
case "countDistinct":
|
|
3096
3102
|
case "sum":
|
|
3097
|
-
o =
|
|
3103
|
+
o = R(r);
|
|
3098
3104
|
break;
|
|
3099
3105
|
case "avg":
|
|
3100
3106
|
o = this.databaseAdapter.buildAvg(r);
|
|
3101
3107
|
break;
|
|
3102
3108
|
case "min":
|
|
3103
|
-
o =
|
|
3109
|
+
o = B(r);
|
|
3104
3110
|
break;
|
|
3105
3111
|
case "max":
|
|
3106
|
-
o =
|
|
3112
|
+
o = z(r);
|
|
3107
3113
|
break;
|
|
3108
3114
|
case "number":
|
|
3109
|
-
o =
|
|
3115
|
+
o = R(r);
|
|
3110
3116
|
break;
|
|
3111
|
-
default: o =
|
|
3117
|
+
default: o = R(r);
|
|
3112
3118
|
}
|
|
3113
3119
|
a.set(e, () => o);
|
|
3114
3120
|
}
|
|
@@ -3130,12 +3136,12 @@ var Q = class e {
|
|
|
3130
3136
|
switch (n.type) {
|
|
3131
3137
|
case "count":
|
|
3132
3138
|
case "countDistinct":
|
|
3133
|
-
case "sum": return
|
|
3139
|
+
case "sum": return R(e);
|
|
3134
3140
|
case "avg": return this.databaseAdapter.buildAvg(e);
|
|
3135
|
-
case "min": return
|
|
3136
|
-
case "max": return
|
|
3137
|
-
case "number": return
|
|
3138
|
-
default: return
|
|
3141
|
+
case "min": return B(e);
|
|
3142
|
+
case "max": return z(e);
|
|
3143
|
+
case "number": return R(e);
|
|
3144
|
+
default: return R(e);
|
|
3139
3145
|
}
|
|
3140
3146
|
}
|
|
3141
3147
|
}
|
|
@@ -3153,7 +3159,7 @@ var Q = class e {
|
|
|
3153
3159
|
return t ? O`(${t})` : void 0;
|
|
3154
3160
|
}).filter(Boolean);
|
|
3155
3161
|
if (e.length > 0) {
|
|
3156
|
-
let t = e.length === 1 ? e[0] :
|
|
3162
|
+
let t = e.length === 1 ? e[0] : P(...e);
|
|
3157
3163
|
i = this.databaseAdapter.buildCaseWhen([{
|
|
3158
3164
|
when: t,
|
|
3159
3165
|
then: i
|
|
@@ -3161,12 +3167,12 @@ var Q = class e {
|
|
|
3161
3167
|
}
|
|
3162
3168
|
}
|
|
3163
3169
|
switch (t.type) {
|
|
3164
|
-
case "count": return
|
|
3165
|
-
case "countDistinct": return
|
|
3166
|
-
case "sum": return
|
|
3170
|
+
case "count": return pe(i);
|
|
3171
|
+
case "countDistinct": return me(i);
|
|
3172
|
+
case "sum": return R(i);
|
|
3167
3173
|
case "avg": return this.databaseAdapter.buildAvg(i);
|
|
3168
|
-
case "min": return
|
|
3169
|
-
case "max": return
|
|
3174
|
+
case "min": return B(i);
|
|
3175
|
+
case "max": return z(i);
|
|
3170
3176
|
case "number": return i;
|
|
3171
3177
|
case "stddev":
|
|
3172
3178
|
case "stddevSamp": {
|
|
@@ -3244,7 +3250,7 @@ var Q = class e {
|
|
|
3244
3250
|
});
|
|
3245
3251
|
return s === null ? (console.warn(`[drizzle-cube] ${t.type} not supported on ${this.databaseAdapter.getEngineType()}, returning NULL`), O`NULL`) : s;
|
|
3246
3252
|
}
|
|
3247
|
-
default: return
|
|
3253
|
+
default: return pe(i);
|
|
3248
3254
|
}
|
|
3249
3255
|
}
|
|
3250
3256
|
static WINDOW_FUNCTION_TYPES = [
|
|
@@ -3318,7 +3324,7 @@ var Q = class e {
|
|
|
3318
3324
|
let { postAggWindowMeasures: r } = e.categorizeForPostAggregation(t, n);
|
|
3319
3325
|
return r.length > 0;
|
|
3320
3326
|
}
|
|
3321
|
-
},
|
|
3327
|
+
}, vt = class {
|
|
3322
3328
|
constructor(e) {
|
|
3323
3329
|
this.dateTimeBuilder = e;
|
|
3324
3330
|
}
|
|
@@ -3417,13 +3423,13 @@ var Q = class e {
|
|
|
3417
3423
|
}
|
|
3418
3424
|
return i;
|
|
3419
3425
|
}
|
|
3420
|
-
},
|
|
3426
|
+
}, yt = class {
|
|
3421
3427
|
dateTimeBuilder;
|
|
3422
3428
|
filterBuilder;
|
|
3423
3429
|
groupByBuilder;
|
|
3424
3430
|
measureBuilder;
|
|
3425
3431
|
constructor(e) {
|
|
3426
|
-
this.dateTimeBuilder = new Y(e), this.filterBuilder = new X(e, this.dateTimeBuilder), this.groupByBuilder = new
|
|
3432
|
+
this.dateTimeBuilder = new Y(e), this.filterBuilder = new X(e, this.dateTimeBuilder), this.groupByBuilder = new vt(this.dateTimeBuilder), this.measureBuilder = new Q(e);
|
|
3427
3433
|
}
|
|
3428
3434
|
buildResolvedMeasures(e, t, n, r) {
|
|
3429
3435
|
return this.measureBuilder.buildResolvedMeasures(e, t, n, r);
|
|
@@ -3451,7 +3457,7 @@ var Q = class e {
|
|
|
3451
3457
|
r[e.dimension] = O`${i}`.as(e.dimension);
|
|
3452
3458
|
}
|
|
3453
3459
|
}
|
|
3454
|
-
return Object.keys(r).length === 0 && (r.count =
|
|
3460
|
+
return Object.keys(r).length === 0 && (r.count = pe()), r;
|
|
3455
3461
|
}
|
|
3456
3462
|
buildCalculatedMeasure(e, t, n, r, i) {
|
|
3457
3463
|
return this.measureBuilder.buildCalculatedMeasure(e, t, n, r, i);
|
|
@@ -3488,7 +3494,7 @@ var Q = class e {
|
|
|
3488
3494
|
if (s && s.dimensions[i] && e.dateRange) {
|
|
3489
3495
|
if (r?.preAggregationCTEs && r.preAggregationCTEs.some((e) => e.cube.name === t)) continue;
|
|
3490
3496
|
if (n.filterCache) {
|
|
3491
|
-
let t =
|
|
3497
|
+
let t = at(e.dimension, e.dateRange), r = n.filterCache.get(t);
|
|
3492
3498
|
if (r) {
|
|
3493
3499
|
a.push(r);
|
|
3494
3500
|
continue;
|
|
@@ -3513,11 +3519,11 @@ var Q = class e {
|
|
|
3513
3519
|
let a = e;
|
|
3514
3520
|
if (a.and) {
|
|
3515
3521
|
let e = a.and.map((e) => this.processFilter(e, t, n, r, i)).filter((e) => e !== null);
|
|
3516
|
-
return e.length > 0 ?
|
|
3522
|
+
return e.length > 0 ? P(...e) : null;
|
|
3517
3523
|
}
|
|
3518
3524
|
if (a.or) {
|
|
3519
3525
|
let e = a.or.map((e) => this.processFilter(e, t, n, r, i)).filter((e) => e !== null);
|
|
3520
|
-
return e.length > 0 ?
|
|
3526
|
+
return e.length > 0 ? F(...e) : null;
|
|
3521
3527
|
}
|
|
3522
3528
|
}
|
|
3523
3529
|
let a = e, [o, s] = a.member.split("."), c = t.get(o);
|
|
@@ -3557,12 +3563,12 @@ var Q = class e {
|
|
|
3557
3563
|
];
|
|
3558
3564
|
if (e.order && Object.keys(e.order).length > 0) for (let [t, i] of Object.entries(e.order)) {
|
|
3559
3565
|
if (!r.includes(t)) throw Error(`Cannot order by '${t}': field is not selected in the query`);
|
|
3560
|
-
let e = i === "desc" ?
|
|
3566
|
+
let e = i === "desc" ? fe(O.identifier(t)) : de(O.identifier(t));
|
|
3561
3567
|
n.push(e);
|
|
3562
3568
|
}
|
|
3563
3569
|
if (e.timeDimensions && e.timeDimensions.length > 0) {
|
|
3564
3570
|
let t = new Set(Object.keys(e.order || {})), r = [...e.timeDimensions].sort((e, t) => e.dimension.localeCompare(t.dimension));
|
|
3565
|
-
for (let e of r) t.has(e.dimension) || n.push(
|
|
3571
|
+
for (let e of r) t.has(e.dimension) || n.push(de(O.identifier(e.dimension)));
|
|
3566
3572
|
}
|
|
3567
3573
|
return n;
|
|
3568
3574
|
}
|
|
@@ -3597,7 +3603,7 @@ var Q = class e {
|
|
|
3597
3603
|
buildLogicalFilter(e, t, n) {
|
|
3598
3604
|
return this.filterBuilder.buildLogicalFilter(e, t, n);
|
|
3599
3605
|
}
|
|
3600
|
-
},
|
|
3606
|
+
}, bt = class {
|
|
3601
3607
|
cubes;
|
|
3602
3608
|
connectivityCache = /* @__PURE__ */ new Map();
|
|
3603
3609
|
reverseIndex;
|
|
@@ -3804,10 +3810,10 @@ var Q = class e {
|
|
|
3804
3810
|
buildJoinCondition(e, t, n) {
|
|
3805
3811
|
let r = [];
|
|
3806
3812
|
for (let i of e.on) {
|
|
3807
|
-
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)}` : nt(i.source), a = n ? O`${O.identifier(n)}.${O.identifier(i.target.name)}` : nt(i.target), o = i.as || M;
|
|
3808
3814
|
r.push(o(e, a));
|
|
3809
3815
|
}
|
|
3810
|
-
return
|
|
3816
|
+
return P(...r);
|
|
3811
3817
|
}
|
|
3812
3818
|
getReachableCubes(e) {
|
|
3813
3819
|
let t = new Set([e]), n = [e];
|
|
@@ -3834,11 +3840,11 @@ var Q = class e {
|
|
|
3834
3840
|
setInCache(e, t) {
|
|
3835
3841
|
this.connectivityCache.set(e, { path: t });
|
|
3836
3842
|
}
|
|
3837
|
-
},
|
|
3843
|
+
}, xt = class {
|
|
3838
3844
|
resolverCache = /* @__PURE__ */ new WeakMap();
|
|
3839
3845
|
getResolver(e) {
|
|
3840
3846
|
let t = this.resolverCache.get(e);
|
|
3841
|
-
return t || (t = new
|
|
3847
|
+
return t || (t = new bt(e), this.resolverCache.set(e, t)), t;
|
|
3842
3848
|
}
|
|
3843
3849
|
analyzeCubeUsage(e) {
|
|
3844
3850
|
let t = /* @__PURE__ */ new Set();
|
|
@@ -3910,55 +3916,58 @@ var Q = class e {
|
|
|
3910
3916
|
buildWarnings(e, t) {
|
|
3911
3917
|
return this.generateWarnings(e, t);
|
|
3912
3918
|
}
|
|
3913
|
-
buildJoinPlan(
|
|
3914
|
-
let
|
|
3915
|
-
if (
|
|
3919
|
+
buildJoinPlan(t, n, r, i, a) {
|
|
3920
|
+
let o = this.getResolver(t), s = [], c = new Set([n.name]), l = /* @__PURE__ */ new Set();
|
|
3921
|
+
if (a.measures) for (let e of a.measures) {
|
|
3916
3922
|
let [t] = e.split(".");
|
|
3917
|
-
|
|
3918
|
-
}
|
|
3919
|
-
let
|
|
3920
|
-
for (let
|
|
3921
|
-
let
|
|
3922
|
-
for (let
|
|
3923
|
-
if (
|
|
3924
|
-
let
|
|
3925
|
-
if (!
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3923
|
+
l.add(t);
|
|
3924
|
+
}
|
|
3925
|
+
let u = this.collectPathHintCubes(a), d = /* @__PURE__ */ new Set();
|
|
3926
|
+
for (let e of l) e !== n.name && this.findHasManyJoinDef(n, e, t) && d.add(e);
|
|
3927
|
+
let f = r.filter((e) => e !== n.name);
|
|
3928
|
+
for (let r of f) {
|
|
3929
|
+
if (c.has(r)) continue;
|
|
3930
|
+
let a = new Set([...c].filter((e) => !d.has(e))), l = o.findPathPreferring(n.name, r, u, a);
|
|
3931
|
+
if (!l || l.length === 0) throw Error(e("server.errors.noJoinPath", {
|
|
3932
|
+
fromCube: n.name,
|
|
3933
|
+
toCube: r
|
|
3934
|
+
}));
|
|
3935
|
+
for (let { fromCube: n, toCube: r, joinDef: a, reversed: u } of l) {
|
|
3936
|
+
if (c.has(r)) continue;
|
|
3937
|
+
let l = t.get(r);
|
|
3938
|
+
if (!l) throw Error(e("server.errors.cubeNotFound", { cubeName: r }));
|
|
3939
|
+
let d = u ? et(a.relationship) : a.relationship;
|
|
3940
|
+
if (d === "belongsToMany" && a.through) {
|
|
3941
|
+
let e = it(a, i.securityContext);
|
|
3942
|
+
s.push({
|
|
3943
|
+
cube: l,
|
|
3944
|
+
alias: `${r.toLowerCase()}_cube`,
|
|
3936
3945
|
joinType: e.junctionJoins[1].joinType,
|
|
3937
3946
|
joinCondition: e.junctionJoins[1].condition,
|
|
3938
3947
|
relationship: "belongsToMany",
|
|
3939
3948
|
junctionTable: {
|
|
3940
|
-
table:
|
|
3941
|
-
alias: `junction_${
|
|
3949
|
+
table: a.through.table,
|
|
3950
|
+
alias: `junction_${r.toLowerCase()}`,
|
|
3942
3951
|
joinType: e.junctionJoins[0].joinType,
|
|
3943
3952
|
joinCondition: e.junctionJoins[0].condition,
|
|
3944
|
-
securitySql:
|
|
3945
|
-
sourceCubeName:
|
|
3953
|
+
securitySql: a.through.securitySql,
|
|
3954
|
+
sourceCubeName: n
|
|
3946
3955
|
}
|
|
3947
3956
|
});
|
|
3948
3957
|
} else {
|
|
3949
|
-
let e =
|
|
3950
|
-
|
|
3951
|
-
cube:
|
|
3952
|
-
alias: `${
|
|
3958
|
+
let e = o.buildJoinCondition(a, null, null), t = tt(d, a.sqlJoinType);
|
|
3959
|
+
s.push({
|
|
3960
|
+
cube: l,
|
|
3961
|
+
alias: `${r.toLowerCase()}_cube`,
|
|
3953
3962
|
joinType: t,
|
|
3954
3963
|
joinCondition: e,
|
|
3955
|
-
relationship:
|
|
3964
|
+
relationship: d
|
|
3956
3965
|
});
|
|
3957
3966
|
}
|
|
3958
|
-
|
|
3967
|
+
c.add(r);
|
|
3959
3968
|
}
|
|
3960
3969
|
}
|
|
3961
|
-
return
|
|
3970
|
+
return s;
|
|
3962
3971
|
}
|
|
3963
3972
|
planPreAggregationCTEs(e, t, n, r, i) {
|
|
3964
3973
|
let a = [];
|
|
@@ -4042,7 +4051,7 @@ var Q = class e {
|
|
|
4042
4051
|
joinDef: e.joinDef,
|
|
4043
4052
|
reversed: e.reversed
|
|
4044
4053
|
}));
|
|
4045
|
-
if (!c.slice(0, -1).some((e) => (e.reversed ?
|
|
4054
|
+
if (!c.slice(0, -1).some((e) => (e.reversed ? et(e.joinDef.relationship) : e.joinDef.relationship) === "hasMany")) return {
|
|
4046
4055
|
path: c,
|
|
4047
4056
|
hasIntermediateHasMany: !1,
|
|
4048
4057
|
intermediateJoins: [],
|
|
@@ -4346,7 +4355,7 @@ var Q = class e {
|
|
|
4346
4355
|
}
|
|
4347
4356
|
convertInternalPathToJoinPathSteps(e) {
|
|
4348
4357
|
return e.map((e) => {
|
|
4349
|
-
let t = e.reversed ?
|
|
4358
|
+
let t = e.reversed ? et(e.joinDef.relationship) : e.joinDef.relationship, n = tt(t, e.joinDef.sqlJoinType), r = e.joinDef.on.map((e) => ({
|
|
4350
4359
|
sourceColumn: e.source.name,
|
|
4351
4360
|
targetColumn: e.target.name
|
|
4352
4361
|
})), i = {
|
|
@@ -4411,7 +4420,7 @@ var Q = class e {
|
|
|
4411
4420
|
suggestion: "Add a dimension to see per-group breakdowns, or add a time dimension with granularity."
|
|
4412
4421
|
};
|
|
4413
4422
|
}
|
|
4414
|
-
},
|
|
4423
|
+
}, St = class {
|
|
4415
4424
|
constructor(e) {
|
|
4416
4425
|
this.queryBuilder = e;
|
|
4417
4426
|
}
|
|
@@ -4455,8 +4464,8 @@ var Q = class e {
|
|
|
4455
4464
|
if (s && e.intermediateJoins) {
|
|
4456
4465
|
let t = [...e.intermediateJoins].reverse();
|
|
4457
4466
|
for (let e of t) {
|
|
4458
|
-
let t = e.cube.sql(n), r = [
|
|
4459
|
-
e.securityFilter && r.push(e.securityFilter), f = f.leftJoin(t.from,
|
|
4467
|
+
let t = e.cube.sql(n), r = [M(e.cteJoinColumn, e.joinDef.on[0]?.target)];
|
|
4468
|
+
e.securityFilter && r.push(e.securityFilter), f = f.leftJoin(t.from, P(...r));
|
|
4460
4469
|
}
|
|
4461
4470
|
}
|
|
4462
4471
|
let p = r ? {
|
|
@@ -4494,7 +4503,7 @@ var Q = class e {
|
|
|
4494
4503
|
}
|
|
4495
4504
|
let g = [];
|
|
4496
4505
|
if (o.where && g.push(o.where), g.push(...m, ...h), g.length > 0) {
|
|
4497
|
-
let e = g.length === 1 ? g[0] :
|
|
4506
|
+
let e = g.length === 1 ? g[0] : P(...g);
|
|
4498
4507
|
f = f.where(e);
|
|
4499
4508
|
}
|
|
4500
4509
|
let _ = [], v = /* @__PURE__ */ new Set(), y = (e) => {
|
|
@@ -4528,12 +4537,12 @@ var Q = class e {
|
|
|
4528
4537
|
let i = [];
|
|
4529
4538
|
if (r.intermediateJoins && r.intermediateJoins.length > 0) {
|
|
4530
4539
|
let e = r.intermediateJoins[0], a = this.resolveCTEJoinSourceColumn(r.joinKeys[0], r, n), o = O`${O.identifier(t)}.${O.identifier(e.primaryJoinColumn.name)}`;
|
|
4531
|
-
i.push(
|
|
4540
|
+
i.push(M(a, o));
|
|
4532
4541
|
} else for (let e of r.joinKeys) {
|
|
4533
4542
|
let a = this.resolveCTEJoinSourceColumn(e, r, n), o = O`${O.identifier(t)}.${O.identifier(e.targetColumn)}`;
|
|
4534
|
-
i.push(
|
|
4543
|
+
i.push(M(a, o));
|
|
4535
4544
|
}
|
|
4536
|
-
return i.length === 1 ? i[0] :
|
|
4545
|
+
return i.length === 1 ? i[0] : P(...i);
|
|
4537
4546
|
}
|
|
4538
4547
|
resolveCTEJoinSourceColumn(e, t, n) {
|
|
4539
4548
|
if (!e) throw Error(`Missing join key while building CTE join condition for '${t.cube.name}'`);
|
|
@@ -4552,24 +4561,139 @@ var Q = class e {
|
|
|
4552
4561
|
i.push(...o);
|
|
4553
4562
|
}
|
|
4554
4563
|
if (i.length === 0) return null;
|
|
4555
|
-
let a = i.length === 1 ? i[0] :
|
|
4564
|
+
let a = i.length === 1 ? i[0] : P(...i), o = e.joinConditions;
|
|
4556
4565
|
if (o.length === 1) {
|
|
4557
4566
|
let { source: e, target: n } = o[0];
|
|
4558
4567
|
return O`${n} IN ${t.db.select({ pk: e }).from(r.from).where(a)}`;
|
|
4559
4568
|
} else {
|
|
4560
|
-
let e =
|
|
4569
|
+
let e = P(...o.map((e) => M(e.source, e.target)), a);
|
|
4561
4570
|
return O`EXISTS ${t.db.select({ one: O`1` }).from(r.from).where(e)}`;
|
|
4562
4571
|
}
|
|
4563
4572
|
}
|
|
4564
4573
|
};
|
|
4565
4574
|
//#endregion
|
|
4575
|
+
//#region src/shared/date-utils.ts
|
|
4576
|
+
function Ct(e) {
|
|
4577
|
+
let t = /* @__PURE__ */ new Date(), n = e.toLowerCase().trim(), r = t.getUTCFullYear(), i = t.getUTCMonth(), a = t.getUTCDate(), o = t.getUTCDay();
|
|
4578
|
+
if (n === "today") {
|
|
4579
|
+
let e = new Date(t);
|
|
4580
|
+
e.setUTCHours(0, 0, 0, 0);
|
|
4581
|
+
let n = new Date(t);
|
|
4582
|
+
return n.setUTCHours(23, 59, 59, 999), {
|
|
4583
|
+
start: e,
|
|
4584
|
+
end: n
|
|
4585
|
+
};
|
|
4586
|
+
}
|
|
4587
|
+
if (n === "yesterday") {
|
|
4588
|
+
let e = new Date(t);
|
|
4589
|
+
e.setUTCDate(a - 1), e.setUTCHours(0, 0, 0, 0);
|
|
4590
|
+
let n = new Date(t);
|
|
4591
|
+
return n.setUTCDate(a - 1), n.setUTCHours(23, 59, 59, 999), {
|
|
4592
|
+
start: e,
|
|
4593
|
+
end: n
|
|
4594
|
+
};
|
|
4595
|
+
}
|
|
4596
|
+
if (n === "this week") {
|
|
4597
|
+
let e = o === 0 ? -6 : 1 - o, n = new Date(t);
|
|
4598
|
+
n.setUTCDate(a + e), n.setUTCHours(0, 0, 0, 0);
|
|
4599
|
+
let r = new Date(n);
|
|
4600
|
+
return r.setUTCDate(n.getUTCDate() + 6), r.setUTCHours(23, 59, 59, 999), {
|
|
4601
|
+
start: n,
|
|
4602
|
+
end: r
|
|
4603
|
+
};
|
|
4604
|
+
}
|
|
4605
|
+
if (n === "this month") return {
|
|
4606
|
+
start: new Date(Date.UTC(r, i, 1, 0, 0, 0, 0)),
|
|
4607
|
+
end: new Date(Date.UTC(r, i + 1, 0, 23, 59, 59, 999))
|
|
4608
|
+
};
|
|
4609
|
+
if (n === "this quarter") {
|
|
4610
|
+
let e = Math.floor(i / 3);
|
|
4611
|
+
return {
|
|
4612
|
+
start: new Date(Date.UTC(r, e * 3, 1, 0, 0, 0, 0)),
|
|
4613
|
+
end: new Date(Date.UTC(r, e * 3 + 3, 0, 23, 59, 59, 999))
|
|
4614
|
+
};
|
|
4615
|
+
}
|
|
4616
|
+
if (n === "this year") return {
|
|
4617
|
+
start: new Date(Date.UTC(r, 0, 1, 0, 0, 0, 0)),
|
|
4618
|
+
end: new Date(Date.UTC(r, 11, 31, 23, 59, 59, 999))
|
|
4619
|
+
};
|
|
4620
|
+
let s = n.match(/^last\s+(\d+)\s+days?$/);
|
|
4621
|
+
if (s) {
|
|
4622
|
+
let e = parseInt(s[1], 10), n = new Date(t);
|
|
4623
|
+
n.setUTCDate(a - e + 1), n.setUTCHours(0, 0, 0, 0);
|
|
4624
|
+
let r = new Date(t);
|
|
4625
|
+
return r.setUTCHours(23, 59, 59, 999), {
|
|
4626
|
+
start: n,
|
|
4627
|
+
end: r
|
|
4628
|
+
};
|
|
4629
|
+
}
|
|
4630
|
+
let c = n.match(/^last\s+(\d+)\s+weeks?$/);
|
|
4631
|
+
if (c) {
|
|
4632
|
+
let e = parseInt(c[1], 10) * 7, n = new Date(t);
|
|
4633
|
+
n.setUTCDate(a - e + 1), n.setUTCHours(0, 0, 0, 0);
|
|
4634
|
+
let r = new Date(t);
|
|
4635
|
+
return r.setUTCHours(23, 59, 59, 999), {
|
|
4636
|
+
start: n,
|
|
4637
|
+
end: r
|
|
4638
|
+
};
|
|
4639
|
+
}
|
|
4640
|
+
if (n === "last week") {
|
|
4641
|
+
let e = o === 0 ? -13 : -6 - o, n = new Date(t);
|
|
4642
|
+
n.setUTCDate(a + e), n.setUTCHours(0, 0, 0, 0);
|
|
4643
|
+
let r = new Date(n);
|
|
4644
|
+
return r.setUTCDate(n.getUTCDate() + 6), r.setUTCHours(23, 59, 59, 999), {
|
|
4645
|
+
start: n,
|
|
4646
|
+
end: r
|
|
4647
|
+
};
|
|
4648
|
+
}
|
|
4649
|
+
if (n === "last month") return {
|
|
4650
|
+
start: new Date(Date.UTC(r, i - 1, 1, 0, 0, 0, 0)),
|
|
4651
|
+
end: new Date(Date.UTC(r, i, 0, 23, 59, 59, 999))
|
|
4652
|
+
};
|
|
4653
|
+
if (n === "last quarter") {
|
|
4654
|
+
let e = Math.floor(i / 3), t = e === 0 ? 3 : e - 1, n = e === 0 ? r - 1 : r;
|
|
4655
|
+
return {
|
|
4656
|
+
start: new Date(Date.UTC(n, t * 3, 1, 0, 0, 0, 0)),
|
|
4657
|
+
end: new Date(Date.UTC(n, t * 3 + 3, 0, 23, 59, 59, 999))
|
|
4658
|
+
};
|
|
4659
|
+
}
|
|
4660
|
+
if (n === "last year") return {
|
|
4661
|
+
start: new Date(Date.UTC(r - 1, 0, 1, 0, 0, 0, 0)),
|
|
4662
|
+
end: new Date(Date.UTC(r - 1, 11, 31, 23, 59, 59, 999))
|
|
4663
|
+
};
|
|
4664
|
+
if (n === "last 12 months") {
|
|
4665
|
+
let e = new Date(Date.UTC(r, i - 11, 1, 0, 0, 0, 0)), n = new Date(t);
|
|
4666
|
+
return n.setUTCHours(23, 59, 59, 999), {
|
|
4667
|
+
start: e,
|
|
4668
|
+
end: n
|
|
4669
|
+
};
|
|
4670
|
+
}
|
|
4671
|
+
let l = n.match(/^last\s+(\d+)\s+months?$/);
|
|
4672
|
+
if (l) {
|
|
4673
|
+
let e = parseInt(l[1], 10), n = new Date(Date.UTC(r, i - e + 1, 1, 0, 0, 0, 0)), a = new Date(t);
|
|
4674
|
+
return a.setUTCHours(23, 59, 59, 999), {
|
|
4675
|
+
start: n,
|
|
4676
|
+
end: a
|
|
4677
|
+
};
|
|
4678
|
+
}
|
|
4679
|
+
let u = n.match(/^last\s+(\d+)\s+years?$/);
|
|
4680
|
+
if (u) {
|
|
4681
|
+
let e = parseInt(u[1], 10), n = new Date(Date.UTC(r - e, 0, 1, 0, 0, 0, 0)), i = new Date(t);
|
|
4682
|
+
return i.setUTCHours(23, 59, 59, 999), {
|
|
4683
|
+
start: n,
|
|
4684
|
+
end: i
|
|
4685
|
+
};
|
|
4686
|
+
}
|
|
4687
|
+
return null;
|
|
4688
|
+
}
|
|
4689
|
+
//#endregion
|
|
4566
4690
|
//#region src/server/gap-filler.ts
|
|
4567
|
-
function
|
|
4568
|
-
let r = [], i =
|
|
4569
|
-
for (; i <= a && r.length < 1e4;) r.push(new Date(i)), i =
|
|
4691
|
+
function wt(e, t, n) {
|
|
4692
|
+
let r = [], i = Tt(new Date(e), n), a = Tt(new Date(t), n);
|
|
4693
|
+
for (; i <= a && r.length < 1e4;) r.push(new Date(i)), i = Et(i, n);
|
|
4570
4694
|
return r;
|
|
4571
4695
|
}
|
|
4572
|
-
function
|
|
4696
|
+
function Tt(e, t) {
|
|
4573
4697
|
let n = new Date(e);
|
|
4574
4698
|
switch (t) {
|
|
4575
4699
|
case "second":
|
|
@@ -4603,7 +4727,7 @@ function Ct(e, t) {
|
|
|
4603
4727
|
}
|
|
4604
4728
|
return n;
|
|
4605
4729
|
}
|
|
4606
|
-
function
|
|
4730
|
+
function Et(e, t) {
|
|
4607
4731
|
let n = new Date(e);
|
|
4608
4732
|
switch (t) {
|
|
4609
4733
|
case "second":
|
|
@@ -4633,7 +4757,7 @@ function wt(e, t) {
|
|
|
4633
4757
|
}
|
|
4634
4758
|
return n;
|
|
4635
4759
|
}
|
|
4636
|
-
function
|
|
4760
|
+
function Dt(e) {
|
|
4637
4761
|
if (e instanceof Date) return e.toISOString();
|
|
4638
4762
|
if (typeof e == "string") {
|
|
4639
4763
|
let t = new Date(e);
|
|
@@ -4641,15 +4765,15 @@ function Tt(e) {
|
|
|
4641
4765
|
}
|
|
4642
4766
|
return String(e);
|
|
4643
4767
|
}
|
|
4644
|
-
function
|
|
4768
|
+
function Ot(e, t) {
|
|
4645
4769
|
return t.length === 0 ? "__all__" : t.map((t) => String(e[t] ?? "")).join("|||");
|
|
4646
4770
|
}
|
|
4647
|
-
function
|
|
4648
|
-
let { timeDimensionKey: n, granularity: r, dateRange: i, fillValue: a, measures: o, dimensions: s } = t, c =
|
|
4771
|
+
function kt(e, t) {
|
|
4772
|
+
let { timeDimensionKey: n, granularity: r, dateRange: i, fillValue: a, measures: o, dimensions: s } = t, c = wt(i[0], i[1], r);
|
|
4649
4773
|
if (c.length === 0) return e;
|
|
4650
4774
|
let l = /* @__PURE__ */ new Map();
|
|
4651
4775
|
for (let t of e) {
|
|
4652
|
-
let e =
|
|
4776
|
+
let e = Ot(t, s), r = Dt(t[n]);
|
|
4653
4777
|
l.has(e) || l.set(e, /* @__PURE__ */ new Map()), l.get(e).set(r, t);
|
|
4654
4778
|
}
|
|
4655
4779
|
l.size === 0 && s.length === 0 && l.set("__all__", /* @__PURE__ */ new Map());
|
|
@@ -4669,42 +4793,74 @@ function Dt(e, t) {
|
|
|
4669
4793
|
}
|
|
4670
4794
|
return u;
|
|
4671
4795
|
}
|
|
4672
|
-
function
|
|
4796
|
+
function At(e) {
|
|
4673
4797
|
if (!e) return null;
|
|
4674
4798
|
if (Array.isArray(e)) {
|
|
4675
4799
|
if (e.length < 2) return null;
|
|
4676
4800
|
let t = new Date(e[0]), n = new Date(e[1]);
|
|
4677
4801
|
return isNaN(t.getTime()) || isNaN(n.getTime()) ? null : [t, n];
|
|
4678
4802
|
}
|
|
4679
|
-
let t =
|
|
4680
|
-
|
|
4803
|
+
let t = Ct(e);
|
|
4804
|
+
if (t) return [t.start, t.end];
|
|
4805
|
+
let n = new Date(e);
|
|
4806
|
+
return isNaN(n.getTime()) ? null : [n, n];
|
|
4681
4807
|
}
|
|
4682
|
-
function
|
|
4808
|
+
function jt(e, t, n) {
|
|
4683
4809
|
if (!t.timeDimensions || t.timeDimensions.length === 0) return e;
|
|
4684
4810
|
let r = t.timeDimensions.filter((e) => {
|
|
4685
|
-
let
|
|
4686
|
-
return
|
|
4811
|
+
let n = e.fillMissingDates !== !1, r = !!e.granularity, i = e.dateRange || Mt(e.dimension, t.filters);
|
|
4812
|
+
return n && r && i;
|
|
4687
4813
|
});
|
|
4688
4814
|
if (r.length === 0) return e;
|
|
4689
4815
|
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;
|
|
4690
4816
|
for (let e of r) {
|
|
4691
|
-
let
|
|
4692
|
-
if (!
|
|
4693
|
-
let
|
|
4817
|
+
let r = At(e.dateRange) || Nt(e.dimension, t.filters);
|
|
4818
|
+
if (!r) continue;
|
|
4819
|
+
let a = {
|
|
4694
4820
|
timeDimensionKey: e.dimension,
|
|
4695
4821
|
granularity: e.granularity,
|
|
4696
|
-
dateRange:
|
|
4822
|
+
dateRange: r,
|
|
4697
4823
|
fillValue: i,
|
|
4698
4824
|
measures: n,
|
|
4699
4825
|
dimensions: o
|
|
4700
4826
|
};
|
|
4701
|
-
s =
|
|
4827
|
+
s = kt(s, a);
|
|
4702
4828
|
}
|
|
4703
4829
|
return s;
|
|
4704
4830
|
}
|
|
4831
|
+
function Mt(e, t) {
|
|
4832
|
+
if (!t) return null;
|
|
4833
|
+
for (let n of t) {
|
|
4834
|
+
if ("member" in n && "operator" in n && n.member === e && n.operator === "inDateRange") return n;
|
|
4835
|
+
if ("and" in n && n.and) {
|
|
4836
|
+
let t = Mt(e, n.and);
|
|
4837
|
+
if (t) return t;
|
|
4838
|
+
}
|
|
4839
|
+
if ("or" in n && n.or) {
|
|
4840
|
+
let t = Mt(e, n.or);
|
|
4841
|
+
if (t) return t;
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
return null;
|
|
4845
|
+
}
|
|
4846
|
+
function Nt(e, t) {
|
|
4847
|
+
let n = Mt(e, t);
|
|
4848
|
+
if (!n) return null;
|
|
4849
|
+
if (n.dateRange) {
|
|
4850
|
+
let e = At(n.dateRange);
|
|
4851
|
+
if (e) return e;
|
|
4852
|
+
}
|
|
4853
|
+
let r = n.values;
|
|
4854
|
+
if (!r || r.length === 0) return null;
|
|
4855
|
+
if (r.length === 1 && typeof r[0] == "string") {
|
|
4856
|
+
let e = Ct(r[0]);
|
|
4857
|
+
return e ? [e.start, e.end] : At(r);
|
|
4858
|
+
}
|
|
4859
|
+
return r.length >= 2 ? At(r) : null;
|
|
4860
|
+
}
|
|
4705
4861
|
//#endregion
|
|
4706
4862
|
//#region src/server/builders/comparison-query-builder.ts
|
|
4707
|
-
var
|
|
4863
|
+
var Pt = class {
|
|
4708
4864
|
dateTimeBuilder;
|
|
4709
4865
|
constructor(e) {
|
|
4710
4866
|
this.dateTimeBuilder = new Y(e);
|
|
@@ -4835,7 +4991,7 @@ var At = class {
|
|
|
4835
4991
|
return typeof i == "string" && typeof a == "string" ? new Date(i).getTime() - new Date(a).getTime() : 0;
|
|
4836
4992
|
});
|
|
4837
4993
|
}
|
|
4838
|
-
},
|
|
4994
|
+
}, Ft = class {
|
|
4839
4995
|
filterBuilder;
|
|
4840
4996
|
dateTimeBuilder;
|
|
4841
4997
|
constructor(e) {
|
|
@@ -4844,51 +5000,80 @@ var At = class {
|
|
|
4844
5000
|
hasFunnel(e) {
|
|
4845
5001
|
return e.funnel !== void 0 && e.funnel.steps.length >= 2;
|
|
4846
5002
|
}
|
|
4847
|
-
validateConfig(
|
|
4848
|
-
let
|
|
4849
|
-
if (
|
|
4850
|
-
let [
|
|
4851
|
-
if (!
|
|
5003
|
+
validateConfig(t, n) {
|
|
5004
|
+
let r = [];
|
|
5005
|
+
if (t.steps.length < 2 && r.push(e("server.validation.funnel.minSteps")), typeof t.bindingKey == "string") {
|
|
5006
|
+
let [i, a] = t.bindingKey.split(".");
|
|
5007
|
+
if (!i || !a) r.push(e("server.validation.funnel.invalidBindingKeyFormat", { bindingKey: t.bindingKey }));
|
|
4852
5008
|
else {
|
|
4853
|
-
let
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
5009
|
+
let t = n.get(i);
|
|
5010
|
+
t ? t.dimensions?.[a] || r.push(e("server.validation.funnel.bindingKeyDimNotFound", {
|
|
5011
|
+
dimName: a,
|
|
5012
|
+
cubeName: i
|
|
5013
|
+
})) : r.push(e("server.validation.funnel.bindingKeyCubeNotFound", { cubeName: i }));
|
|
5014
|
+
}
|
|
5015
|
+
} else if (Array.isArray(t.bindingKey)) for (let i of t.bindingKey) {
|
|
5016
|
+
let t = n.get(i.cube);
|
|
5017
|
+
if (!t) r.push(e("server.validation.funnel.bindingKeyMappingCubeNotFound", { cubeName: i.cube }));
|
|
4859
5018
|
else {
|
|
4860
|
-
let [,
|
|
4861
|
-
|
|
5019
|
+
let [, n] = i.dimension.split(".");
|
|
5020
|
+
t.dimensions?.[n] || r.push(e("server.validation.funnel.bindingKeyDimNotFound", {
|
|
5021
|
+
dimName: n,
|
|
5022
|
+
cubeName: i.cube
|
|
5023
|
+
}));
|
|
4862
5024
|
}
|
|
4863
5025
|
}
|
|
4864
|
-
if (typeof
|
|
4865
|
-
let [
|
|
4866
|
-
if (!
|
|
5026
|
+
if (typeof t.timeDimension == "string") {
|
|
5027
|
+
let [i, a] = t.timeDimension.split(".");
|
|
5028
|
+
if (!i || !a) r.push(e("server.validation.funnel.invalidTimeDimFormat", { timeDimension: t.timeDimension }));
|
|
4867
5029
|
else {
|
|
4868
|
-
let
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
5030
|
+
let t = n.get(i);
|
|
5031
|
+
t ? t.dimensions?.[a] || r.push(e("server.validation.funnel.timeDimNotFound", {
|
|
5032
|
+
dimName: a,
|
|
5033
|
+
cubeName: i
|
|
5034
|
+
})) : r.push(e("server.validation.funnel.timeDimCubeNotFound", { cubeName: i }));
|
|
5035
|
+
}
|
|
5036
|
+
}
|
|
5037
|
+
for (let i = 0; i < t.steps.length; i++) {
|
|
5038
|
+
let a = t.steps[i];
|
|
5039
|
+
if (a.name || r.push(e("server.validation.funnel.stepMustHaveName", { step: i })), "cube" in a && a.cube && (n.get(a.cube) || r.push(e("server.validation.funnel.stepCubeNotFound", {
|
|
5040
|
+
step: i,
|
|
5041
|
+
cube: a.cube
|
|
5042
|
+
}))), a.filter) {
|
|
5043
|
+
let o;
|
|
5044
|
+
"cube" in a && a.cube ? o = a.cube : typeof t.bindingKey == "string" && ([o] = t.bindingKey.split("."));
|
|
5045
|
+
let s = o ? new bt(n) : null, c = Array.isArray(a.filter) ? a.filter : [a.filter];
|
|
5046
|
+
for (let t of c) if ("member" in t) {
|
|
5047
|
+
let [a, c] = t.member.split("."), l = n.get(a);
|
|
5048
|
+
if (!l) r.push(e("server.validation.funnel.stepFilterCubeNotFound", {
|
|
5049
|
+
step: i,
|
|
5050
|
+
cubeName: a
|
|
5051
|
+
}));
|
|
5052
|
+
else if (l.dimensions?.[c] || (l.measures?.[c] ? r.push(e("server.validation.funnel.stepFilterIsMeasure", {
|
|
5053
|
+
step: i,
|
|
5054
|
+
member: `${a}.${c}`
|
|
5055
|
+
})) : r.push(e("server.validation.funnel.stepFilterMemberNotFound", {
|
|
5056
|
+
step: i,
|
|
5057
|
+
field: c,
|
|
5058
|
+
cubeName: a
|
|
5059
|
+
}))), o && a !== o && s) {
|
|
5060
|
+
let t = s.findPath(o, a);
|
|
5061
|
+
(!t || t.length === 0) && r.push(e("server.validation.funnel.stepFilterNoJoinPath", {
|
|
5062
|
+
step: i,
|
|
5063
|
+
member: `${a}.${c}`,
|
|
5064
|
+
stepCube: o
|
|
5065
|
+
}));
|
|
4884
5066
|
}
|
|
4885
5067
|
}
|
|
4886
5068
|
}
|
|
4887
|
-
|
|
5069
|
+
a.timeToConvert && i > 0 && (/^P(?:\d+Y)?(?:\d+M)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?$/.test(a.timeToConvert) || r.push(e("server.validation.funnel.stepTimeToConvertFormat", {
|
|
5070
|
+
step: i,
|
|
5071
|
+
value: a.timeToConvert
|
|
5072
|
+
})));
|
|
4888
5073
|
}
|
|
4889
5074
|
return {
|
|
4890
|
-
isValid:
|
|
4891
|
-
errors:
|
|
5075
|
+
isValid: r.length === 0,
|
|
5076
|
+
errors: r
|
|
4892
5077
|
};
|
|
4893
5078
|
}
|
|
4894
5079
|
buildFunnelQuery(e, t, n) {
|
|
@@ -4937,7 +5122,7 @@ var At = class {
|
|
|
4937
5122
|
return t;
|
|
4938
5123
|
}
|
|
4939
5124
|
resolveSteps(e, t, n) {
|
|
4940
|
-
let r = new
|
|
5125
|
+
let r = new bt(t);
|
|
4941
5126
|
return e.steps.map((i, a) => {
|
|
4942
5127
|
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 = [];
|
|
4943
5128
|
for (let e of u) if (e !== o.name) {
|
|
@@ -4962,42 +5147,42 @@ var At = class {
|
|
|
4962
5147
|
};
|
|
4963
5148
|
});
|
|
4964
5149
|
}
|
|
4965
|
-
resolveCubeForStep(
|
|
4966
|
-
if ("cube" in
|
|
4967
|
-
let
|
|
4968
|
-
if (!
|
|
4969
|
-
return
|
|
5150
|
+
resolveCubeForStep(t, n, r) {
|
|
5151
|
+
if ("cube" in t && t.cube) {
|
|
5152
|
+
let n = r.get(t.cube);
|
|
5153
|
+
if (!n) throw Error(e("server.errors.funnel.cubeNotFoundForStep", { cube: t.cube }));
|
|
5154
|
+
return n;
|
|
4970
5155
|
}
|
|
5156
|
+
if (typeof n.bindingKey == "string") {
|
|
5157
|
+
let [t] = n.bindingKey.split("."), i = r.get(t);
|
|
5158
|
+
if (!i) throw Error(e("server.errors.funnel.cubeNotFoundForBindingKey", { bindingKey: n.bindingKey }));
|
|
5159
|
+
return i;
|
|
5160
|
+
}
|
|
5161
|
+
throw Error(e("server.errors.funnel.cannotResolveCubeForStep"));
|
|
5162
|
+
}
|
|
5163
|
+
resolveBindingKey(t, n, r) {
|
|
4971
5164
|
if (typeof t.bindingKey == "string") {
|
|
4972
|
-
let [
|
|
4973
|
-
if (!
|
|
4974
|
-
return r;
|
|
4975
|
-
}
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
if (
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
if (
|
|
4992
|
-
|
|
4993
|
-
if (!i) throw Error(`Time dimension not found: ${e.timeDimension}`);
|
|
4994
|
-
return W(i.sql, n);
|
|
4995
|
-
}
|
|
4996
|
-
let r = e.timeDimension.find((e) => e.cube === t.name);
|
|
4997
|
-
if (!r) throw Error(`No time dimension mapping found for cube: ${t.name}`);
|
|
4998
|
-
let [, i] = r.dimension.split("."), a = t.dimensions?.[i];
|
|
4999
|
-
if (!a) throw Error(`Time dimension not found: ${r.dimension}`);
|
|
5000
|
-
return W(a.sql, n);
|
|
5165
|
+
let [, i] = t.bindingKey.split("."), a = n.dimensions?.[i];
|
|
5166
|
+
if (!a) throw Error(e("server.errors.funnel.bindingKeyDimNotFound", { bindingKey: t.bindingKey }));
|
|
5167
|
+
return W(a.sql, r);
|
|
5168
|
+
}
|
|
5169
|
+
let i = t.bindingKey.find((e) => e.cube === n.name);
|
|
5170
|
+
if (!i) throw Error(e("server.errors.funnel.noBindingKeyMapping", { cubeName: n.name }));
|
|
5171
|
+
let [, a] = i.dimension.split("."), o = n.dimensions?.[a];
|
|
5172
|
+
if (!o) throw Error(e("server.errors.funnel.bindingKeyMappingDimNotFound", { dimension: i.dimension }));
|
|
5173
|
+
return W(o.sql, r);
|
|
5174
|
+
}
|
|
5175
|
+
resolveTimeDimension(t, n, r) {
|
|
5176
|
+
if (typeof t.timeDimension == "string") {
|
|
5177
|
+
let [, i] = t.timeDimension.split("."), a = n.dimensions?.[i];
|
|
5178
|
+
if (!a) throw Error(e("server.errors.funnel.timeDimNotFound", { timeDimension: t.timeDimension }));
|
|
5179
|
+
return W(a.sql, r);
|
|
5180
|
+
}
|
|
5181
|
+
let i = t.timeDimension.find((e) => e.cube === n.name);
|
|
5182
|
+
if (!i) throw Error(e("server.errors.funnel.noTimeDimMapping", { cubeName: n.name }));
|
|
5183
|
+
let [, a] = i.dimension.split("."), o = n.dimensions?.[a];
|
|
5184
|
+
if (!o) throw Error(e("server.errors.funnel.timeDimMappingNotFound", { dimension: i.dimension }));
|
|
5185
|
+
return W(o.sql, r);
|
|
5001
5186
|
}
|
|
5002
5187
|
buildStepFilters(e, t, n, r) {
|
|
5003
5188
|
if (!e.filter) return [];
|
|
@@ -5028,14 +5213,14 @@ var At = class {
|
|
|
5028
5213
|
a && i.push(a);
|
|
5029
5214
|
}
|
|
5030
5215
|
}
|
|
5031
|
-
return i.length === 0 ? null : i.length === 1 ? i[0] : o ?
|
|
5216
|
+
return i.length === 0 ? null : i.length === 1 ? i[0] : o ? P(...i) : O`(${O.join(i, O` OR `)})`;
|
|
5032
5217
|
}
|
|
5033
5218
|
let o = e, [s, c] = o.member.split("."), l = o.dateRange !== void 0;
|
|
5034
5219
|
if (o.operator !== "set" && o.operator !== "notSet" && !l && (!o.values || o.values.length === 0 || o.values[0] === void 0 || o.values[0] === "")) return null;
|
|
5035
5220
|
let u = n.get(s);
|
|
5036
5221
|
if (!u) return null;
|
|
5037
5222
|
if (s !== t.name) {
|
|
5038
|
-
let e = new
|
|
5223
|
+
let e = new bt(n).findPath(t.name, s);
|
|
5039
5224
|
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;
|
|
5040
5225
|
}
|
|
5041
5226
|
let d = u.dimensions?.[c];
|
|
@@ -5054,7 +5239,7 @@ var At = class {
|
|
|
5054
5239
|
step_time: O`MIN(${e.timeExpr})`.as("step_time")
|
|
5055
5240
|
}).from(r.from);
|
|
5056
5241
|
if (a = this.addCrossJoinsToQuery(a, e, t, i), i.length > 0) {
|
|
5057
|
-
let e = i.length === 1 ? i[0] :
|
|
5242
|
+
let e = i.length === 1 ? i[0] : P(...i);
|
|
5058
5243
|
a = a.where(e);
|
|
5059
5244
|
}
|
|
5060
5245
|
return a = a.groupBy(e.bindingKeyExpr), t.db.$with(n).as(a);
|
|
@@ -5073,7 +5258,7 @@ var At = class {
|
|
|
5073
5258
|
step_time: O`MIN(${e.timeExpr})`.as("step_time")
|
|
5074
5259
|
}).from(a.from).innerJoin(n, O`${e.bindingKeyExpr} = ${O.identifier(i)}.binding_key`);
|
|
5075
5260
|
if (l = this.addCrossJoinsToQuery(l, e, t, o), o.length > 0) {
|
|
5076
|
-
let e = o.length === 1 ? o[0] :
|
|
5261
|
+
let e = o.length === 1 ? o[0] : P(...o);
|
|
5077
5262
|
l = l.where(e);
|
|
5078
5263
|
}
|
|
5079
5264
|
return l = l.groupBy(e.bindingKeyExpr), t.db.$with(r).as(l);
|
|
@@ -5082,8 +5267,8 @@ var At = class {
|
|
|
5082
5267
|
if (t.joinedCubes.length === 0) return e;
|
|
5083
5268
|
for (let i of t.joinedCubes) for (let t of i.joinPath) {
|
|
5084
5269
|
let a = t.joinDef, o = [];
|
|
5085
|
-
for (let e of a.on) e.as ? o.push(e.as(e.source, e.target)) : o.push(
|
|
5086
|
-
let s = o.length === 1 ? o[0] :
|
|
5270
|
+
for (let e of a.on) e.as ? o.push(e.as(e.source, e.target)) : o.push(M(e.source, e.target));
|
|
5271
|
+
let s = o.length === 1 ? o[0] : P(...o), c = i.cube.sql(n);
|
|
5087
5272
|
e = e.leftJoin(c.from, s), c.where && r.push(c.where);
|
|
5088
5273
|
}
|
|
5089
5274
|
return e;
|
|
@@ -5116,7 +5301,7 @@ var At = class {
|
|
|
5116
5301
|
let o = i.db.select(a).from(e);
|
|
5117
5302
|
return i.db.$with("funnel_metrics").as(o);
|
|
5118
5303
|
}
|
|
5119
|
-
},
|
|
5304
|
+
}, It = class {
|
|
5120
5305
|
filterBuilder;
|
|
5121
5306
|
dateTimeBuilder;
|
|
5122
5307
|
databaseAdapter;
|
|
@@ -5126,73 +5311,85 @@ var At = class {
|
|
|
5126
5311
|
hasFlow(e) {
|
|
5127
5312
|
return e.flow !== void 0 && e.flow.startingStep !== void 0 && e.flow.eventDimension !== void 0;
|
|
5128
5313
|
}
|
|
5129
|
-
validateConfig(
|
|
5130
|
-
let
|
|
5131
|
-
if (
|
|
5314
|
+
validateConfig(t, n) {
|
|
5315
|
+
let r = [], i = [], a = this.databaseAdapter.getEngineType(), o = this.databaseAdapter.getCapabilities().supportsLateralSubqueriesInCTE;
|
|
5316
|
+
if (a === "sqlite") return r.push(e("server.validation.flow.sqliteNotSupported")), {
|
|
5132
5317
|
isValid: !1,
|
|
5133
|
-
errors:
|
|
5134
|
-
warnings:
|
|
5318
|
+
errors: r,
|
|
5319
|
+
warnings: i
|
|
5135
5320
|
};
|
|
5136
|
-
if (typeof
|
|
5137
|
-
let [
|
|
5138
|
-
if (!
|
|
5321
|
+
if (typeof t.bindingKey == "string") {
|
|
5322
|
+
let [i, a] = t.bindingKey.split(".");
|
|
5323
|
+
if (!i || !a) r.push(e("server.validation.flow.invalidBindingKeyFormat", { bindingKey: t.bindingKey }));
|
|
5139
5324
|
else {
|
|
5140
|
-
let
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5325
|
+
let t = n.get(i);
|
|
5326
|
+
t ? t.dimensions?.[a] || r.push(e("server.validation.flow.bindingKeyDimNotFound", {
|
|
5327
|
+
dimName: a,
|
|
5328
|
+
cubeName: i
|
|
5329
|
+
})) : r.push(e("server.validation.flow.bindingKeyCubeNotFound", { cubeName: i }));
|
|
5330
|
+
}
|
|
5331
|
+
} else if (Array.isArray(t.bindingKey)) for (let i of t.bindingKey) {
|
|
5332
|
+
let t = n.get(i.cube);
|
|
5333
|
+
if (!t) r.push(e("server.validation.flow.bindingKeyMappingCubeNotFound", { cubeName: i.cube }));
|
|
5146
5334
|
else {
|
|
5147
|
-
let [,
|
|
5148
|
-
|
|
5335
|
+
let [, n] = i.dimension.split(".");
|
|
5336
|
+
t.dimensions?.[n] || r.push(e("server.validation.flow.bindingKeyDimNotFound", {
|
|
5337
|
+
dimName: n,
|
|
5338
|
+
cubeName: i.cube
|
|
5339
|
+
}));
|
|
5149
5340
|
}
|
|
5150
5341
|
}
|
|
5151
|
-
if (typeof
|
|
5152
|
-
let [
|
|
5153
|
-
if (!
|
|
5342
|
+
if (typeof t.timeDimension == "string") {
|
|
5343
|
+
let [i, a] = t.timeDimension.split(".");
|
|
5344
|
+
if (!i || !a) r.push(e("server.validation.flow.invalidTimeDimFormat", { timeDimension: t.timeDimension }));
|
|
5154
5345
|
else {
|
|
5155
|
-
let
|
|
5156
|
-
|
|
5346
|
+
let t = n.get(i);
|
|
5347
|
+
t ? t.dimensions?.[a] || r.push(e("server.validation.flow.timeDimNotFound", {
|
|
5348
|
+
dimName: a,
|
|
5349
|
+
cubeName: i
|
|
5350
|
+
})) : r.push(e("server.validation.flow.timeDimCubeNotFound", { cubeName: i }));
|
|
5157
5351
|
}
|
|
5158
5352
|
}
|
|
5159
|
-
if (
|
|
5160
|
-
let [
|
|
5161
|
-
if (!
|
|
5353
|
+
if (t.eventDimension) {
|
|
5354
|
+
let [i, a] = t.eventDimension.split(".");
|
|
5355
|
+
if (!i || !a) r.push(e("server.validation.flow.invalidEventDimFormat", { eventDimension: t.eventDimension }));
|
|
5162
5356
|
else {
|
|
5163
|
-
let
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5357
|
+
let t = n.get(i);
|
|
5358
|
+
t ? t.dimensions?.[a] || r.push(e("server.validation.flow.eventDimNotFound", {
|
|
5359
|
+
dimName: a,
|
|
5360
|
+
cubeName: i
|
|
5361
|
+
})) : r.push(e("server.validation.flow.eventDimCubeNotFound", { cubeName: i }));
|
|
5362
|
+
}
|
|
5363
|
+
} else r.push(e("server.validation.flow.eventDimRequired"));
|
|
5364
|
+
return t.startingStep ? (t.startingStep.filter || r.push(e("server.validation.flow.startingStepFilterRequired")), t.startingStep.name || i.push(e("server.validation.flow.startingStepNameMissing"))) : r.push(e("server.validation.flow.startingStepRequired")), (t.stepsBefore < 0 || t.stepsBefore > 5) && r.push(e("server.validation.flow.stepsBeforeRange", { value: t.stepsBefore })), (t.stepsAfter < 0 || t.stepsAfter > 5) && r.push(e("server.validation.flow.stepsAfterRange", { value: t.stepsAfter })), (t.stepsBefore >= 4 || t.stepsAfter >= 4) && i.push(e("server.validation.flow.highStepDepthWarning")), t.joinStrategy && ![
|
|
5168
5365
|
"auto",
|
|
5169
5366
|
"lateral",
|
|
5170
5367
|
"window"
|
|
5171
|
-
].includes(
|
|
5172
|
-
isValid:
|
|
5173
|
-
errors:
|
|
5174
|
-
warnings:
|
|
5368
|
+
].includes(t.joinStrategy) ? r.push(e("server.validation.flow.invalidJoinStrategy", { joinStrategy: t.joinStrategy })) : t.joinStrategy === "lateral" && !o && r.push(e("server.validation.flow.lateralNotSupported")), {
|
|
5369
|
+
isValid: r.length === 0,
|
|
5370
|
+
errors: r,
|
|
5371
|
+
warnings: i
|
|
5175
5372
|
};
|
|
5176
5373
|
}
|
|
5177
|
-
buildFlowQuery(
|
|
5178
|
-
if (this.databaseAdapter.getEngineType() === "sqlite") throw Error("
|
|
5179
|
-
let
|
|
5180
|
-
if (
|
|
5181
|
-
let
|
|
5182
|
-
...
|
|
5183
|
-
stepsBefore:
|
|
5184
|
-
},
|
|
5185
|
-
|
|
5186
|
-
let
|
|
5187
|
-
|
|
5188
|
-
let
|
|
5189
|
-
|
|
5190
|
-
let
|
|
5191
|
-
|
|
5192
|
-
let
|
|
5193
|
-
|
|
5194
|
-
let
|
|
5195
|
-
return
|
|
5374
|
+
buildFlowQuery(t, n, r) {
|
|
5375
|
+
if (this.databaseAdapter.getEngineType() === "sqlite") throw Error(e("server.validation.flow.sqliteNotSupported"));
|
|
5376
|
+
let i = this.databaseAdapter.getCapabilities().supportsLateralSubqueriesInCTE, a = t.joinStrategy ?? "auto", o = a === "lateral" || a === "auto" && i;
|
|
5377
|
+
if (a === "lateral" && !i) throw Error(e("server.validation.flow.lateralNotSupportedExec"));
|
|
5378
|
+
let s = {
|
|
5379
|
+
...t,
|
|
5380
|
+
stepsBefore: t.outputMode === "sunburst" ? 0 : t.stepsBefore
|
|
5381
|
+
}, c = this.resolveFlowConfig(s, n, r), l = [], u = this.buildStartingEntitiesCTE(s, c, r);
|
|
5382
|
+
l.push(u);
|
|
5383
|
+
let d = o ? this.buildBeforeCTEsLateral(s, c, r) : this.buildBeforeCTEsWindow(s, c, r);
|
|
5384
|
+
l.push(...d);
|
|
5385
|
+
let f = o ? this.buildAfterCTEsLateral(s, c, r) : this.buildAfterCTEsWindow(s, c, r);
|
|
5386
|
+
l.push(...f);
|
|
5387
|
+
let p = this.buildNodesAggregationCTE(s, r);
|
|
5388
|
+
l.push(p);
|
|
5389
|
+
let m = this.buildLinksAggregationCTE(s, r);
|
|
5390
|
+
l.push(m);
|
|
5391
|
+
let h = this.buildFinalResultCTE(r);
|
|
5392
|
+
return l.push(h), r.db.with(...l).select().from(h);
|
|
5196
5393
|
}
|
|
5197
5394
|
transformResult(e) {
|
|
5198
5395
|
if (!e || e.length === 0) return {
|
|
@@ -5229,43 +5426,43 @@ var At = class {
|
|
|
5229
5426
|
startingStepFilters: this.buildStartingStepFilters(e, r, n)
|
|
5230
5427
|
};
|
|
5231
5428
|
}
|
|
5232
|
-
resolveCube(
|
|
5233
|
-
let
|
|
5234
|
-
if (typeof
|
|
5235
|
-
else if (Array.isArray(
|
|
5236
|
-
else throw Error("
|
|
5237
|
-
let
|
|
5238
|
-
if (!
|
|
5239
|
-
return
|
|
5429
|
+
resolveCube(t, n) {
|
|
5430
|
+
let r;
|
|
5431
|
+
if (typeof t.bindingKey == "string") [r] = t.bindingKey.split(".");
|
|
5432
|
+
else if (Array.isArray(t.bindingKey) && t.bindingKey.length > 0) r = t.bindingKey[0].cube;
|
|
5433
|
+
else throw Error(e("server.errors.flow.cannotResolveCube"));
|
|
5434
|
+
let i = n.get(r);
|
|
5435
|
+
if (!i) throw Error(e("server.errors.flow.cubeNotFound", { cubeName: r }));
|
|
5436
|
+
return i;
|
|
5240
5437
|
}
|
|
5241
|
-
resolveBindingKey(
|
|
5242
|
-
if (typeof
|
|
5243
|
-
let [,
|
|
5244
|
-
if (!
|
|
5245
|
-
return W(
|
|
5246
|
-
}
|
|
5247
|
-
let
|
|
5248
|
-
if (!
|
|
5249
|
-
let [,
|
|
5250
|
-
if (!
|
|
5251
|
-
return W(
|
|
5252
|
-
}
|
|
5253
|
-
resolveTimeDimension(
|
|
5254
|
-
if (typeof
|
|
5255
|
-
let [,
|
|
5256
|
-
if (!
|
|
5257
|
-
return W(
|
|
5258
|
-
}
|
|
5259
|
-
let
|
|
5260
|
-
if (!
|
|
5261
|
-
let [,
|
|
5262
|
-
if (!
|
|
5263
|
-
return W(
|
|
5264
|
-
}
|
|
5265
|
-
resolveEventDimension(
|
|
5266
|
-
let [,
|
|
5267
|
-
if (!
|
|
5268
|
-
return W(
|
|
5438
|
+
resolveBindingKey(t, n, r) {
|
|
5439
|
+
if (typeof t.bindingKey == "string") {
|
|
5440
|
+
let [, i] = t.bindingKey.split("."), a = n.dimensions?.[i];
|
|
5441
|
+
if (!a) throw Error(e("server.errors.flow.bindingKeyDimNotFound", { bindingKey: t.bindingKey }));
|
|
5442
|
+
return W(a.sql, r);
|
|
5443
|
+
}
|
|
5444
|
+
let i = t.bindingKey.find((e) => e.cube === n.name);
|
|
5445
|
+
if (!i) throw Error(e("server.errors.flow.noBindingKeyMapping", { cubeName: n.name }));
|
|
5446
|
+
let [, a] = i.dimension.split("."), o = n.dimensions?.[a];
|
|
5447
|
+
if (!o) throw Error(e("server.errors.flow.bindingKeyMappingDimNotFound", { dimension: i.dimension }));
|
|
5448
|
+
return W(o.sql, r);
|
|
5449
|
+
}
|
|
5450
|
+
resolveTimeDimension(t, n, r) {
|
|
5451
|
+
if (typeof t.timeDimension == "string") {
|
|
5452
|
+
let [, i] = t.timeDimension.split("."), a = n.dimensions?.[i];
|
|
5453
|
+
if (!a) throw Error(e("server.errors.flow.timeDimNotFound", { timeDimension: t.timeDimension }));
|
|
5454
|
+
return W(a.sql, r);
|
|
5455
|
+
}
|
|
5456
|
+
let i = t.timeDimension.find((e) => e.cube === n.name);
|
|
5457
|
+
if (!i) throw Error(e("server.errors.flow.noTimeDimMapping", { cubeName: n.name }));
|
|
5458
|
+
let [, a] = i.dimension.split("."), o = n.dimensions?.[a];
|
|
5459
|
+
if (!o) throw Error(e("server.errors.flow.timeDimMappingNotFound", { dimension: i.dimension }));
|
|
5460
|
+
return W(o.sql, r);
|
|
5461
|
+
}
|
|
5462
|
+
resolveEventDimension(t, n, r) {
|
|
5463
|
+
let [, i] = t.eventDimension.split("."), a = n.dimensions?.[i];
|
|
5464
|
+
if (!a) throw Error(e("server.errors.flow.eventDimNotFound", { eventDimension: t.eventDimension }));
|
|
5465
|
+
return W(a.sql, r);
|
|
5269
5466
|
}
|
|
5270
5467
|
buildStartingStepFilters(e, t, n) {
|
|
5271
5468
|
if (!e.startingStep.filter) return [];
|
|
@@ -5283,7 +5480,7 @@ var At = class {
|
|
|
5283
5480
|
let r = this.buildFilterCondition(e, t, n);
|
|
5284
5481
|
r && i.push(r);
|
|
5285
5482
|
}
|
|
5286
|
-
return i.length === 0 ? null : i.length === 1 ? i[0] : "and" in e ?
|
|
5483
|
+
return i.length === 0 ? null : i.length === 1 ? i[0] : "and" in e ? P(...i) : O`(${O.join(i, O` OR `)})`;
|
|
5287
5484
|
}
|
|
5288
5485
|
if ("type" in e && "filters" in e) {
|
|
5289
5486
|
let r = e, i = [];
|
|
@@ -5291,7 +5488,7 @@ var At = class {
|
|
|
5291
5488
|
let r = this.buildFilterCondition(e, t, n);
|
|
5292
5489
|
r && i.push(r);
|
|
5293
5490
|
}
|
|
5294
|
-
return i.length === 0 ? null : i.length === 1 ? i[0] : r.type === "and" ?
|
|
5491
|
+
return i.length === 0 ? null : i.length === 1 ? i[0] : r.type === "and" ? P(...i) : O`(${O.join(i, O` OR `)})`;
|
|
5295
5492
|
}
|
|
5296
5493
|
let r = e, [, i] = r.member.split("."), a = t.dimensions?.[i];
|
|
5297
5494
|
if (!a) return null;
|
|
@@ -5308,7 +5505,7 @@ var At = class {
|
|
|
5308
5505
|
event_path: O`${o}`.as("event_path")
|
|
5309
5506
|
}).from(r.from);
|
|
5310
5507
|
if (c.length > 0) {
|
|
5311
|
-
let e = c.length === 1 ? c[0] :
|
|
5508
|
+
let e = c.length === 1 ? c[0] : P(...c);
|
|
5312
5509
|
l = l.where(e);
|
|
5313
5510
|
}
|
|
5314
5511
|
return l = l.groupBy(i, o), e.entityLimit && (l = l.limit(e.entityLimit)), n.db.$with("starting_entities").as(l);
|
|
@@ -5318,7 +5515,7 @@ var At = class {
|
|
|
5318
5515
|
for (let t = 1; t <= e.stepsBefore; t++) {
|
|
5319
5516
|
let e = t === 1 ? "starting_entities" : `before_step_${t - 1}`, l = t === 1 ? "start_time" : "step_time", u = `before_step_${t}`, d = [];
|
|
5320
5517
|
r.where && d.push(r.where), d.push(O`${i} = ${O.identifier(e)}.binding_key`, O`${a} < ${O.identifier(e)}.${O.identifier(l)}`);
|
|
5321
|
-
let f = d.length === 1 ? d[0] :
|
|
5518
|
+
let f = d.length === 1 ? d[0] : P(...d), p = c ? O`${o} || ${"→"} || ${O.identifier(e)}.event_path` : O`${o}`, m = n.db.select({
|
|
5322
5519
|
binding_key: O`${i}`.as("binding_key"),
|
|
5323
5520
|
step_time: O`${a}`.as("step_time"),
|
|
5324
5521
|
event_type: O`${o}`.as("event_type"),
|
|
@@ -5338,7 +5535,7 @@ var At = class {
|
|
|
5338
5535
|
for (let t = 1; t <= e.stepsAfter; t++) {
|
|
5339
5536
|
let e = t === 1 ? "starting_entities" : `after_step_${t - 1}`, l = t === 1 ? "start_time" : "step_time", u = `after_step_${t}`, d = [];
|
|
5340
5537
|
r.where && d.push(r.where), d.push(O`${i} = ${O.identifier(e)}.binding_key`, O`${a} > ${O.identifier(e)}.${O.identifier(l)}`);
|
|
5341
|
-
let f = d.length === 1 ? d[0] :
|
|
5538
|
+
let f = d.length === 1 ? d[0] : P(...d), p = c ? O`${O.identifier(e)}.event_path || ${"→"} || ${o}` : O`${o}`, m = n.db.select({
|
|
5342
5539
|
binding_key: O`${i}`.as("binding_key"),
|
|
5343
5540
|
step_time: O`${a}`.as("step_time"),
|
|
5344
5541
|
event_type: O`${o}`.as("event_type"),
|
|
@@ -5358,7 +5555,7 @@ var At = class {
|
|
|
5358
5555
|
for (let t = 1; t <= e.stepsBefore; t++) {
|
|
5359
5556
|
let e = t === 1 ? "starting_entities" : `before_step_${t - 1}`, l = t === 1 ? "start_time" : "step_time", u = `before_step_${t}`, d = [];
|
|
5360
5557
|
r.where && d.push(r.where), d.push(O`${a} < ${O.identifier(e)}.${O.identifier(l)}`);
|
|
5361
|
-
let f = d.length === 1 ? d[0] :
|
|
5558
|
+
let f = d.length === 1 ? d[0] : P(...d), p = c ? O`${o} || ${"→"} || ${O.identifier(e)}.event_path` : O`${o}`, m = n.db.select({
|
|
5362
5559
|
binding_key: O`${i}`.as("binding_key"),
|
|
5363
5560
|
step_time: O`${a}`.as("step_time"),
|
|
5364
5561
|
event_type: O`${o}`.as("event_type"),
|
|
@@ -5379,7 +5576,7 @@ var At = class {
|
|
|
5379
5576
|
for (let t = 1; t <= e.stepsAfter; t++) {
|
|
5380
5577
|
let e = t === 1 ? "starting_entities" : `after_step_${t - 1}`, l = t === 1 ? "start_time" : "step_time", u = `after_step_${t}`, d = [];
|
|
5381
5578
|
r.where && d.push(r.where), d.push(O`${a} > ${O.identifier(e)}.${O.identifier(l)}`);
|
|
5382
|
-
let f = d.length === 1 ? d[0] :
|
|
5579
|
+
let f = d.length === 1 ? d[0] : P(...d), p = c ? O`${O.identifier(e)}.event_path || ${"→"} || ${o}` : O`${o}`, m = n.db.select({
|
|
5383
5580
|
binding_key: O`${i}`.as("binding_key"),
|
|
5384
5581
|
step_time: O`${a}`.as("step_time"),
|
|
5385
5582
|
event_type: O`${o}`.as("event_type"),
|
|
@@ -5580,27 +5777,27 @@ var At = class {
|
|
|
5580
5777
|
};
|
|
5581
5778
|
//#endregion
|
|
5582
5779
|
//#region src/server/types/retention.ts
|
|
5583
|
-
function
|
|
5780
|
+
function Lt(e) {
|
|
5584
5781
|
return Array.isArray(e);
|
|
5585
5782
|
}
|
|
5586
|
-
function
|
|
5783
|
+
function Rt(e) {
|
|
5587
5784
|
return typeof e == "object" && !!e && "cube" in e;
|
|
5588
5785
|
}
|
|
5589
|
-
function
|
|
5590
|
-
if (
|
|
5786
|
+
function zt(e) {
|
|
5787
|
+
if (Rt(e)) return e.cube;
|
|
5591
5788
|
let t = e.indexOf(".");
|
|
5592
5789
|
if (t === -1) throw Error(`Invalid time dimension format: ${e}. Expected 'CubeName.dimensionName'`);
|
|
5593
5790
|
return e.substring(0, t);
|
|
5594
5791
|
}
|
|
5595
|
-
function
|
|
5596
|
-
if (
|
|
5792
|
+
function Bt(e) {
|
|
5793
|
+
if (Rt(e)) return e.dimension;
|
|
5597
5794
|
let t = e.indexOf(".");
|
|
5598
5795
|
if (t === -1) throw Error(`Invalid time dimension format: ${e}. Expected 'CubeName.dimensionName'`);
|
|
5599
5796
|
return e.substring(t + 1);
|
|
5600
5797
|
}
|
|
5601
5798
|
//#endregion
|
|
5602
5799
|
//#region src/server/builders/retention-query-builder.ts
|
|
5603
|
-
var
|
|
5800
|
+
var Vt = class {
|
|
5604
5801
|
filterBuilder;
|
|
5605
5802
|
dateTimeBuilder;
|
|
5606
5803
|
constructor(e) {
|
|
@@ -5609,62 +5806,71 @@ var Lt = class {
|
|
|
5609
5806
|
hasRetention(e) {
|
|
5610
5807
|
return e.retention !== void 0 && e.retention.timeDimension != null && e.retention.bindingKey != null;
|
|
5611
5808
|
}
|
|
5612
|
-
validateConfig(
|
|
5613
|
-
let
|
|
5809
|
+
validateConfig(t, n) {
|
|
5810
|
+
let r = [];
|
|
5614
5811
|
try {
|
|
5615
|
-
let
|
|
5616
|
-
|
|
5812
|
+
let i = zt(t.timeDimension), a = Bt(t.timeDimension), o = n.get(i);
|
|
5813
|
+
o ? o.dimensions?.[a] || r.push(e("server.validation.retention.timeDimNotFound", { dimName: a })) : r.push(e("server.validation.retention.cubeNotFound", { cubeName: i }));
|
|
5617
5814
|
} catch {
|
|
5618
|
-
|
|
5815
|
+
r.push(e("server.validation.retention.invalidTimeDimFormat", { timeDimension: t.timeDimension }));
|
|
5619
5816
|
}
|
|
5620
|
-
if (
|
|
5621
|
-
let
|
|
5622
|
-
if (!
|
|
5817
|
+
if (Lt(t.bindingKey)) for (let i of t.bindingKey) {
|
|
5818
|
+
let t = n.get(i.cube);
|
|
5819
|
+
if (!t) r.push(e("server.validation.retention.bindingKeyMappingCubeNotFound", { cubeName: i.cube }));
|
|
5623
5820
|
else {
|
|
5624
|
-
let
|
|
5625
|
-
|
|
5821
|
+
let n = this.extractDimensionName(i.dimension);
|
|
5822
|
+
t.dimensions?.[n] || r.push(e("server.validation.retention.bindingKeyDimNotFound", {
|
|
5823
|
+
dimName: n,
|
|
5824
|
+
cubeName: i.cube
|
|
5825
|
+
}));
|
|
5626
5826
|
}
|
|
5627
5827
|
}
|
|
5628
5828
|
else {
|
|
5629
|
-
let [
|
|
5630
|
-
if (!
|
|
5829
|
+
let [i, a] = t.bindingKey.split(".");
|
|
5830
|
+
if (!i || !a) r.push(e("server.validation.retention.invalidBindingKeyFormat", { bindingKey: t.bindingKey }));
|
|
5631
5831
|
else {
|
|
5632
|
-
let
|
|
5633
|
-
|
|
5832
|
+
let t = n.get(i);
|
|
5833
|
+
t ? t.dimensions?.[a] || r.push(e("server.validation.retention.bindingKeyDimNotFound", {
|
|
5834
|
+
dimName: a,
|
|
5835
|
+
cubeName: i
|
|
5836
|
+
})) : r.push(e("server.validation.retention.bindingKeyCubeNotFound", { cubeName: i }));
|
|
5634
5837
|
}
|
|
5635
5838
|
}
|
|
5636
|
-
if (
|
|
5637
|
-
let [
|
|
5638
|
-
if (!
|
|
5839
|
+
if (t.breakdownDimensions && t.breakdownDimensions.length > 0) for (let i of t.breakdownDimensions) {
|
|
5840
|
+
let [t, a] = i.split(".");
|
|
5841
|
+
if (!t || !a) r.push(e("server.validation.retention.invalidBreakdownDimFormat", { dimension: i }));
|
|
5639
5842
|
else {
|
|
5640
|
-
let
|
|
5641
|
-
|
|
5843
|
+
let i = n.get(t);
|
|
5844
|
+
i ? i.dimensions?.[a] || r.push(e("server.validation.retention.breakdownDimNotFound", {
|
|
5845
|
+
dimName: a,
|
|
5846
|
+
cubeName: t
|
|
5847
|
+
})) : r.push(e("server.validation.retention.breakdownDimCubeNotFound", { cubeName: t }));
|
|
5642
5848
|
}
|
|
5643
5849
|
}
|
|
5644
|
-
if (
|
|
5850
|
+
if (t.periods < 1 && r.push(e("server.validation.retention.periodsMin")), t.periods > 52 && r.push(e("server.validation.retention.periodsMax")), [
|
|
5645
5851
|
"day",
|
|
5646
5852
|
"week",
|
|
5647
5853
|
"month"
|
|
5648
|
-
].includes(
|
|
5854
|
+
].includes(t.granularity) || r.push(e("server.validation.retention.invalidGranularity", { granularity: t.granularity })), ["classic", "rolling"].includes(t.retentionType) || r.push(e("server.validation.retention.invalidRetentionType", { retentionType: t.retentionType })), !t.dateRange) r.push(e("server.validation.retention.dateRangeRequired"));
|
|
5649
5855
|
else {
|
|
5650
|
-
if (!
|
|
5856
|
+
if (!t.dateRange.start) r.push(e("server.validation.retention.dateRangeStartRequired"));
|
|
5651
5857
|
else {
|
|
5652
|
-
let
|
|
5653
|
-
isNaN(
|
|
5858
|
+
let n = new Date(t.dateRange.start);
|
|
5859
|
+
isNaN(n.getTime()) && r.push(e("server.validation.retention.dateRangeInvalidStart"));
|
|
5654
5860
|
}
|
|
5655
|
-
if (!
|
|
5861
|
+
if (!t.dateRange.end) r.push(e("server.validation.retention.dateRangeEndRequired"));
|
|
5656
5862
|
else {
|
|
5657
|
-
let
|
|
5658
|
-
isNaN(
|
|
5863
|
+
let n = new Date(t.dateRange.end);
|
|
5864
|
+
isNaN(n.getTime()) && r.push(e("server.validation.retention.dateRangeInvalidEnd"));
|
|
5659
5865
|
}
|
|
5660
|
-
if (
|
|
5661
|
-
let
|
|
5662
|
-
!isNaN(
|
|
5866
|
+
if (t.dateRange.start && t.dateRange.end) {
|
|
5867
|
+
let n = new Date(t.dateRange.start), i = new Date(t.dateRange.end);
|
|
5868
|
+
!isNaN(n.getTime()) && !isNaN(i.getTime()) && n > i && r.push(e("server.validation.retention.dateRangeStartBeforeEnd"));
|
|
5663
5869
|
}
|
|
5664
5870
|
}
|
|
5665
5871
|
return {
|
|
5666
|
-
isValid:
|
|
5667
|
-
errors:
|
|
5872
|
+
isValid: r.length === 0,
|
|
5873
|
+
errors: r
|
|
5668
5874
|
};
|
|
5669
5875
|
}
|
|
5670
5876
|
buildRetentionQuery(e, t, n) {
|
|
@@ -5704,46 +5910,52 @@ var Lt = class {
|
|
|
5704
5910
|
return t;
|
|
5705
5911
|
});
|
|
5706
5912
|
}
|
|
5707
|
-
resolveConfig(
|
|
5708
|
-
let
|
|
5709
|
-
if (!
|
|
5710
|
-
let
|
|
5711
|
-
if (!
|
|
5712
|
-
let
|
|
5713
|
-
if (
|
|
5714
|
-
let [
|
|
5913
|
+
resolveConfig(t, n, r) {
|
|
5914
|
+
let i = zt(t.timeDimension), a = Bt(t.timeDimension), o = n.get(i);
|
|
5915
|
+
if (!o) throw Error(e("server.validation.retention.cubeNotFound", { cubeName: i }));
|
|
5916
|
+
let s = o.dimensions?.[a];
|
|
5917
|
+
if (!s) throw Error(e("server.validation.retention.timeDimNotFound", { dimName: a }));
|
|
5918
|
+
let c = W(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
|
+
if (t.breakdownDimensions && t.breakdownDimensions.length > 0) for (let e of t.breakdownDimensions) {
|
|
5920
|
+
let [t, i] = e.split("."), a = n.get(t);
|
|
5715
5921
|
if (a && a.dimensions?.[i]) {
|
|
5716
|
-
let
|
|
5717
|
-
|
|
5718
|
-
dimension:
|
|
5719
|
-
expr:
|
|
5922
|
+
let t = W(a.dimensions[i].sql, r);
|
|
5923
|
+
f.push({
|
|
5924
|
+
dimension: e,
|
|
5925
|
+
expr: t
|
|
5720
5926
|
});
|
|
5721
5927
|
}
|
|
5722
5928
|
}
|
|
5723
5929
|
return {
|
|
5724
|
-
cube:
|
|
5725
|
-
bindingKeyExpr:
|
|
5726
|
-
timeExpr:
|
|
5727
|
-
cohortFilterConditions:
|
|
5728
|
-
activityFilterConditions:
|
|
5729
|
-
breakdowns:
|
|
5930
|
+
cube: o,
|
|
5931
|
+
bindingKeyExpr: l,
|
|
5932
|
+
timeExpr: c,
|
|
5933
|
+
cohortFilterConditions: u,
|
|
5934
|
+
activityFilterConditions: d,
|
|
5935
|
+
breakdowns: f
|
|
5730
5936
|
};
|
|
5731
5937
|
}
|
|
5732
|
-
resolveBindingKey(
|
|
5733
|
-
if (
|
|
5734
|
-
let
|
|
5735
|
-
if (!
|
|
5736
|
-
let
|
|
5737
|
-
if (!
|
|
5738
|
-
let
|
|
5739
|
-
if (!
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5938
|
+
resolveBindingKey(t, n, r, i) {
|
|
5939
|
+
if (Lt(t)) {
|
|
5940
|
+
let a = t.find((e) => e.cube === n.name);
|
|
5941
|
+
if (!a) throw Error(e("server.validation.retention.noBindingKeyMapping", { cubeName: n.name }));
|
|
5942
|
+
let o = this.extractDimensionName(a.dimension), s = r.get(a.cube);
|
|
5943
|
+
if (!s) throw Error(e("server.validation.retention.bindingKeyCubeNotFound", { cubeName: a.cube }));
|
|
5944
|
+
let c = s.dimensions?.[o];
|
|
5945
|
+
if (!c) throw Error(e("server.validation.retention.bindingKeyDimNotFound", {
|
|
5946
|
+
dimName: a.dimension,
|
|
5947
|
+
cubeName: a.cube
|
|
5948
|
+
}));
|
|
5949
|
+
return W(c.sql, i);
|
|
5950
|
+
}
|
|
5951
|
+
let [a, o] = t.split("."), s = r.get(a);
|
|
5952
|
+
if (!s) throw Error(e("server.validation.retention.bindingKeyCubeNotFound", { cubeName: a }));
|
|
5953
|
+
let c = s.dimensions?.[o];
|
|
5954
|
+
if (!c) throw Error(e("server.validation.retention.bindingKeyDimNotFound", {
|
|
5955
|
+
dimName: t,
|
|
5956
|
+
cubeName: a
|
|
5957
|
+
}));
|
|
5958
|
+
return W(c.sql, i);
|
|
5747
5959
|
}
|
|
5748
5960
|
buildFilterConditions(e, t, n, r) {
|
|
5749
5961
|
if (!e) return [];
|
|
@@ -5761,7 +5973,7 @@ var Lt = class {
|
|
|
5761
5973
|
let i = this.buildSingleFilterCondition(e, t, n, r);
|
|
5762
5974
|
i && a.push(i);
|
|
5763
5975
|
}
|
|
5764
|
-
return a.length === 0 ? null : a.length === 1 ? a[0] : o ?
|
|
5976
|
+
return a.length === 0 ? null : a.length === 1 ? a[0] : o ? P(...a) : O`(${O.join(a, O` OR `)})`;
|
|
5765
5977
|
}
|
|
5766
5978
|
let i = e, [a, o] = i.member.split("."), s = n.get(a);
|
|
5767
5979
|
if (!s) return null;
|
|
@@ -5786,7 +5998,7 @@ var Lt = class {
|
|
|
5786
5998
|
}
|
|
5787
5999
|
let s = n.db.select(o).from(r.from);
|
|
5788
6000
|
if (i.length > 0) {
|
|
5789
|
-
let e = i.length === 1 ? i[0] :
|
|
6001
|
+
let e = i.length === 1 ? i[0] : P(...i);
|
|
5790
6002
|
s = s.where(e);
|
|
5791
6003
|
}
|
|
5792
6004
|
let c = [t.bindingKeyExpr];
|
|
@@ -5813,7 +6025,7 @@ var Lt = class {
|
|
|
5813
6025
|
for (let e = 0; e < t.breakdowns.length; e++) s[`breakdown_${e}`] = O.raw(`cohort_base.breakdown_${e}`).as(`breakdown_${e}`);
|
|
5814
6026
|
let c = n.db.select(s).from(r.from).innerJoin(O`cohort_base`, O`${t.bindingKeyExpr} = cohort_base.binding_key`);
|
|
5815
6027
|
if (i.length > 0) {
|
|
5816
|
-
let e = i.length === 1 ? i[0] :
|
|
6028
|
+
let e = i.length === 1 ? i[0] : P(...i);
|
|
5817
6029
|
c = c.where(e);
|
|
5818
6030
|
}
|
|
5819
6031
|
let l = [O`cohort_base.binding_key`, o];
|
|
@@ -5869,64 +6081,64 @@ var Lt = class {
|
|
|
5869
6081
|
let t = e.split(".");
|
|
5870
6082
|
return t.length > 1 ? t[1] : t[0];
|
|
5871
6083
|
}
|
|
5872
|
-
},
|
|
6084
|
+
}, Ht = class {
|
|
5873
6085
|
constructor(e) {
|
|
5874
6086
|
this.queryPlanner = e;
|
|
5875
6087
|
}
|
|
5876
6088
|
plan(e, t, n) {
|
|
5877
6089
|
return this.planWithAnalysis(e, t, n).plan;
|
|
5878
6090
|
}
|
|
5879
|
-
planWithAnalysis(
|
|
5880
|
-
let
|
|
5881
|
-
if (
|
|
5882
|
-
let
|
|
5883
|
-
if (!
|
|
5884
|
-
let
|
|
5885
|
-
for (let
|
|
5886
|
-
let n =
|
|
5887
|
-
n &&
|
|
5888
|
-
}
|
|
5889
|
-
let
|
|
6091
|
+
planWithAnalysis(t, n, r) {
|
|
6092
|
+
let i = Array.from(this.queryPlanner.analyzeCubeUsage(n));
|
|
6093
|
+
if (i.length === 0) throw Error(e("server.errors.noCubesInQuery"));
|
|
6094
|
+
let a = this.queryPlanner.analyzePrimaryCube(i, n, t), o = a.selectedCube, s = t.get(o);
|
|
6095
|
+
if (!s) throw Error(e("server.errors.primaryCubeNotFound", { cubeName: o }));
|
|
6096
|
+
let c = i.filter((e) => e !== o).map((e) => this.queryPlanner.analyzeJoinPathForTarget(t, o, e, n)), l = i.length > 1 ? this.queryPlanner.buildJoinPlanForPrimary(t, s, i, r, n) : [], u = i.length > 1 ? this.queryPlanner.buildPreAggregationCTEs(t, s, l, n, r) ?? [] : [], d = this.queryPlanner.buildWarnings(n, u), f = this.buildSourceFromPhases(s, l, u, t, n, r), p = f.source, m = this.buildQueryNode(p, n, t, d), h = this.buildPreAggregationAnalysis(u), g = /* @__PURE__ */ new Map();
|
|
6097
|
+
for (let e of i) {
|
|
6098
|
+
let n = t.get(e);
|
|
6099
|
+
n && g.set(e, n);
|
|
6100
|
+
}
|
|
6101
|
+
let _ = Q.hasPostAggregationWindows(n.measures ?? [], g), v = [...c.filter((e) => !e.pathFound && e.error).map((e) => e.error), ...d.map((e) => e.message)];
|
|
5890
6102
|
return {
|
|
5891
|
-
plan:
|
|
6103
|
+
plan: m,
|
|
5892
6104
|
analysis: {
|
|
5893
6105
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5894
|
-
cubeCount:
|
|
5895
|
-
cubesInvolved: [...
|
|
5896
|
-
primaryCube:
|
|
5897
|
-
joinPaths:
|
|
5898
|
-
preAggregations:
|
|
6106
|
+
cubeCount: i.length,
|
|
6107
|
+
cubesInvolved: [...i].sort(),
|
|
6108
|
+
primaryCube: a,
|
|
6109
|
+
joinPaths: c,
|
|
6110
|
+
preAggregations: h,
|
|
5899
6111
|
querySummary: {
|
|
5900
|
-
queryType:
|
|
5901
|
-
measureStrategy:
|
|
5902
|
-
joinCount:
|
|
5903
|
-
cteCount:
|
|
5904
|
-
hasPreAggregation:
|
|
5905
|
-
hasWindowFunctions:
|
|
6112
|
+
queryType: u.length > 0 ? "multi_cube_cte" : i.length > 1 ? "multi_cube_join" : "single_cube",
|
|
6113
|
+
measureStrategy: f.strategy,
|
|
6114
|
+
joinCount: l.length,
|
|
6115
|
+
cteCount: u.length,
|
|
6116
|
+
hasPreAggregation: u.length > 0,
|
|
6117
|
+
hasWindowFunctions: _
|
|
5906
6118
|
},
|
|
5907
|
-
warnings:
|
|
6119
|
+
warnings: v.length > 0 ? v : void 0,
|
|
5908
6120
|
planningTrace: { steps: [
|
|
5909
6121
|
{
|
|
5910
6122
|
phase: "cube_usage",
|
|
5911
|
-
decision: `Identified ${
|
|
5912
|
-
details: { cubesInvolved: [...
|
|
6123
|
+
decision: `Identified ${i.length} cube${i.length === 1 ? "" : "s"} from query members`,
|
|
6124
|
+
details: { cubesInvolved: [...i].sort() }
|
|
5913
6125
|
},
|
|
5914
6126
|
{
|
|
5915
6127
|
phase: "primary_cube_selection",
|
|
5916
|
-
decision: `Selected '${
|
|
6128
|
+
decision: `Selected '${a.selectedCube}' as primary cube (${a.reason})`,
|
|
5917
6129
|
details: {
|
|
5918
|
-
selectedCube:
|
|
5919
|
-
reason:
|
|
5920
|
-
candidates:
|
|
6130
|
+
selectedCube: a.selectedCube,
|
|
6131
|
+
reason: a.reason,
|
|
6132
|
+
candidates: a.candidates?.map((e) => e.cubeName)
|
|
5921
6133
|
}
|
|
5922
6134
|
},
|
|
5923
6135
|
{
|
|
5924
6136
|
phase: "join_planning",
|
|
5925
|
-
decision: `Planned ${
|
|
6137
|
+
decision: `Planned ${l.length} join${l.length === 1 ? "" : "s"}`,
|
|
5926
6138
|
details: {
|
|
5927
|
-
joinCount:
|
|
5928
|
-
joinTargets:
|
|
5929
|
-
pathSelection:
|
|
6139
|
+
joinCount: l.length,
|
|
6140
|
+
joinTargets: l.map((e) => e.cube.name),
|
|
6141
|
+
pathSelection: c.map((e) => ({
|
|
5930
6142
|
targetCube: e.targetCube,
|
|
5931
6143
|
strategy: e.selection?.strategy,
|
|
5932
6144
|
selectedRank: e.selection?.selectedRank,
|
|
@@ -5936,27 +6148,27 @@ var Lt = class {
|
|
|
5936
6148
|
},
|
|
5937
6149
|
{
|
|
5938
6150
|
phase: "cte_planning",
|
|
5939
|
-
decision: `Planned ${
|
|
6151
|
+
decision: `Planned ${u.length} pre-aggregation CTE${u.length === 1 ? "" : "s"}`,
|
|
5940
6152
|
details: {
|
|
5941
|
-
cteCount:
|
|
5942
|
-
cubes:
|
|
6153
|
+
cteCount: u.length,
|
|
6154
|
+
cubes: u.map((e) => e.cube.name)
|
|
5943
6155
|
}
|
|
5944
6156
|
},
|
|
5945
6157
|
{
|
|
5946
6158
|
phase: "measure_strategy",
|
|
5947
|
-
decision: `Selected '${
|
|
6159
|
+
decision: `Selected '${f.strategy}' measure strategy`,
|
|
5948
6160
|
details: {
|
|
5949
|
-
strategy:
|
|
5950
|
-
regularMeasures:
|
|
5951
|
-
multipliedMeasures:
|
|
5952
|
-
deduplicationSafeMeasures:
|
|
5953
|
-
sourceType:
|
|
6161
|
+
strategy: f.strategy,
|
|
6162
|
+
regularMeasures: f.classification.regular.map((e) => e.name),
|
|
6163
|
+
multipliedMeasures: f.classification.multiplied.map((e) => e.name),
|
|
6164
|
+
deduplicationSafeMeasures: f.classification.deduplicationSafe.map((e) => e.name),
|
|
6165
|
+
sourceType: p.type
|
|
5954
6166
|
}
|
|
5955
6167
|
},
|
|
5956
6168
|
{
|
|
5957
6169
|
phase: "warnings",
|
|
5958
|
-
decision:
|
|
5959
|
-
details: { warningCodes:
|
|
6170
|
+
decision: d.length > 0 ? `Generated ${d.length} planning warning${d.length === 1 ? "" : "s"}` : "No planning warnings generated",
|
|
6171
|
+
details: { warningCodes: d.map((e) => e.code) }
|
|
5960
6172
|
}
|
|
5961
6173
|
] }
|
|
5962
6174
|
}
|
|
@@ -6238,40 +6450,49 @@ var Lt = class {
|
|
|
6238
6450
|
cteType: e.cteType
|
|
6239
6451
|
}));
|
|
6240
6452
|
}
|
|
6241
|
-
buildMeasureRefs(
|
|
6242
|
-
return
|
|
6243
|
-
let [
|
|
6244
|
-
if (!
|
|
6453
|
+
buildMeasureRefs(t, n) {
|
|
6454
|
+
return t.measures ? t.measures.map((t) => {
|
|
6455
|
+
let [r, i] = t.split("."), a = n.get(r);
|
|
6456
|
+
if (!a) throw Error(e("server.errors.cubeNotFoundForMeasure", {
|
|
6457
|
+
cubeName: r,
|
|
6458
|
+
measure: t
|
|
6459
|
+
}));
|
|
6245
6460
|
return {
|
|
6246
|
-
name:
|
|
6247
|
-
cube: this.toCubeRef(
|
|
6248
|
-
localName:
|
|
6461
|
+
name: t,
|
|
6462
|
+
cube: this.toCubeRef(a),
|
|
6463
|
+
localName: i
|
|
6249
6464
|
};
|
|
6250
6465
|
}) : [];
|
|
6251
6466
|
}
|
|
6252
|
-
buildDimensionRefs(
|
|
6253
|
-
return
|
|
6254
|
-
let [
|
|
6255
|
-
if (!
|
|
6467
|
+
buildDimensionRefs(t, n) {
|
|
6468
|
+
return t.dimensions ? t.dimensions.map((t) => {
|
|
6469
|
+
let [r, i] = t.split("."), a = n.get(r);
|
|
6470
|
+
if (!a) throw Error(e("server.errors.cubeNotFoundForDimension", {
|
|
6471
|
+
cubeName: r,
|
|
6472
|
+
dimension: t
|
|
6473
|
+
}));
|
|
6256
6474
|
return {
|
|
6257
|
-
name:
|
|
6258
|
-
cube: this.toCubeRef(
|
|
6259
|
-
localName:
|
|
6475
|
+
name: t,
|
|
6476
|
+
cube: this.toCubeRef(a),
|
|
6477
|
+
localName: i
|
|
6260
6478
|
};
|
|
6261
6479
|
}) : [];
|
|
6262
6480
|
}
|
|
6263
|
-
buildTimeDimensionRefs(
|
|
6264
|
-
return
|
|
6265
|
-
let [
|
|
6266
|
-
if (!
|
|
6481
|
+
buildTimeDimensionRefs(t, n) {
|
|
6482
|
+
return t.timeDimensions ? t.timeDimensions.map((t) => {
|
|
6483
|
+
let [r, i] = t.dimension.split("."), a = n.get(r);
|
|
6484
|
+
if (!a) throw Error(e("server.errors.cubeNotFoundForTimeDimension", {
|
|
6485
|
+
cubeName: r,
|
|
6486
|
+
timeDimension: t.dimension
|
|
6487
|
+
}));
|
|
6267
6488
|
return {
|
|
6268
|
-
name:
|
|
6269
|
-
cube: this.toCubeRef(
|
|
6270
|
-
localName:
|
|
6271
|
-
granularity:
|
|
6272
|
-
dateRange:
|
|
6273
|
-
fillMissingDates:
|
|
6274
|
-
compareDateRange:
|
|
6489
|
+
name: t.dimension,
|
|
6490
|
+
cube: this.toCubeRef(a),
|
|
6491
|
+
localName: i,
|
|
6492
|
+
granularity: t.granularity,
|
|
6493
|
+
dateRange: t.dateRange,
|
|
6494
|
+
fillMissingDates: t.fillMissingDates,
|
|
6495
|
+
compareDateRange: t.compareDateRange
|
|
6275
6496
|
};
|
|
6276
6497
|
}) : [];
|
|
6277
6498
|
}
|
|
@@ -6304,7 +6525,7 @@ var Lt = class {
|
|
|
6304
6525
|
timeDimensions: []
|
|
6305
6526
|
};
|
|
6306
6527
|
}
|
|
6307
|
-
},
|
|
6528
|
+
}, Ut = class {
|
|
6308
6529
|
name = "identity";
|
|
6309
6530
|
optimise(e) {
|
|
6310
6531
|
return e;
|
|
@@ -6312,7 +6533,7 @@ var Lt = class {
|
|
|
6312
6533
|
};
|
|
6313
6534
|
//#endregion
|
|
6314
6535
|
//#region src/server/physical-plan/processors/cte-processor.ts
|
|
6315
|
-
function
|
|
6536
|
+
function Wt(e, t, n, r) {
|
|
6316
6537
|
let i = /* @__PURE__ */ new Map();
|
|
6317
6538
|
if (e.preAggregationCTEs && e.preAggregationCTEs.length > 0) {
|
|
6318
6539
|
for (let t of e.preAggregationCTEs) if (t.propagatingFilters && t.propagatingFilters.length > 0) for (let e of t.propagatingFilters) {
|
|
@@ -6322,7 +6543,7 @@ function Bt(e, t, n, r) {
|
|
|
6322
6543
|
i.set(t, s);
|
|
6323
6544
|
}
|
|
6324
6545
|
let a = i.get(t);
|
|
6325
|
-
a && a.length > 0 && (e.preBuiltFilterSQL = a.length === 1 ? a[0] :
|
|
6546
|
+
a && a.length > 0 && (e.preBuiltFilterSQL = a.length === 1 ? a[0] : P(...a));
|
|
6326
6547
|
}
|
|
6327
6548
|
}
|
|
6328
6549
|
let a = [], o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
@@ -6342,7 +6563,7 @@ function Bt(e, t, n, r) {
|
|
|
6342
6563
|
}
|
|
6343
6564
|
//#endregion
|
|
6344
6565
|
//#region src/server/physical-plan/processors/window-processor.ts
|
|
6345
|
-
function
|
|
6566
|
+
function Gt(e, t, n, r, i, a) {
|
|
6346
6567
|
if (n.measures) for (let o of n.measures) {
|
|
6347
6568
|
let [s, c] = o.split("."), l = i.get(s);
|
|
6348
6569
|
if (!l?.measures?.[c]) continue;
|
|
@@ -6354,11 +6575,11 @@ function Vt(e, t, n, r, i, a) {
|
|
|
6354
6575
|
if (!m?.measures?.[p]) continue;
|
|
6355
6576
|
let h = m.measures[p], g = t.preAggregationCTEs?.find((e) => e.cube?.name === f && e.measures?.includes(d)), _;
|
|
6356
6577
|
_ = g ? O`sum(${O`${O.identifier(g.cteAlias)}.${O.identifier(p)}`})` : a.queryBuilder.buildMeasureExpression(h, r, m), e[d] || (e[d] = O`${_}`.as(d));
|
|
6357
|
-
let v =
|
|
6578
|
+
let v = Kt(u, _, n, r, l, t, a);
|
|
6358
6579
|
v && (e[o] = O`${v}`.as(o));
|
|
6359
6580
|
}
|
|
6360
6581
|
}
|
|
6361
|
-
function
|
|
6582
|
+
function Kt(e, t, n, r, i, a, o) {
|
|
6362
6583
|
let s = e.windowConfig || {}, c = (e, t) => {
|
|
6363
6584
|
if (!a.preAggregationCTEs) return null;
|
|
6364
6585
|
let n = a.preAggregationCTEs.find((t) => t.cube?.name === e);
|
|
@@ -6428,7 +6649,7 @@ function Ht(e, t, n, r, i, a, o) {
|
|
|
6428
6649
|
}
|
|
6429
6650
|
//#endregion
|
|
6430
6651
|
//#region src/server/physical-plan/processors/selection-processor.ts
|
|
6431
|
-
function
|
|
6652
|
+
function qt(e, t, n, r, i) {
|
|
6432
6653
|
let a = { ...i.queryBuilder.buildSelections(e.joinCubes.length > 0 ? r : e.primaryCube, t, n) };
|
|
6433
6654
|
if (e.preAggregationCTEs) for (let o of e.preAggregationCTEs) {
|
|
6434
6655
|
let e = o.cube.name;
|
|
@@ -6439,26 +6660,26 @@ function Ut(e, t, n, r, i) {
|
|
|
6439
6660
|
let u = l.measures[c], d = O`${O.identifier(o.cteAlias)}.${O.identifier(c)}`, f;
|
|
6440
6661
|
if (u.type === "calculated" && u.calculatedSql) f = i.queryBuilder.buildCTECalculatedMeasure(u, l, o, r, n);
|
|
6441
6662
|
else {
|
|
6442
|
-
let e = o.cteReason === "fanOutPrevention", n =
|
|
6663
|
+
let e = o.cteReason === "fanOutPrevention", n = Jt(o, t, r), a = e || n;
|
|
6443
6664
|
switch (u.type) {
|
|
6444
6665
|
case "count":
|
|
6445
6666
|
case "countDistinct":
|
|
6446
6667
|
case "sum":
|
|
6447
|
-
f = a ?
|
|
6668
|
+
f = a ? z(d) : R(d);
|
|
6448
6669
|
break;
|
|
6449
6670
|
case "avg":
|
|
6450
|
-
f = a ?
|
|
6671
|
+
f = a ? z(d) : i.databaseAdapter.buildAvg(d);
|
|
6451
6672
|
break;
|
|
6452
6673
|
case "min":
|
|
6453
|
-
f =
|
|
6674
|
+
f = B(d);
|
|
6454
6675
|
break;
|
|
6455
6676
|
case "max":
|
|
6456
|
-
f =
|
|
6677
|
+
f = z(d);
|
|
6457
6678
|
break;
|
|
6458
6679
|
case "number":
|
|
6459
|
-
f =
|
|
6680
|
+
f = z(d);
|
|
6460
6681
|
break;
|
|
6461
|
-
default: f = a ?
|
|
6682
|
+
default: f = a ? z(d) : R(d);
|
|
6462
6683
|
}
|
|
6463
6684
|
}
|
|
6464
6685
|
a[s] = O`${f}`.as(s);
|
|
@@ -6476,12 +6697,12 @@ function Ut(e, t, n, r, i) {
|
|
|
6476
6697
|
(u || l && s?.dimensions?.[i]) && (a[t] = O`${O.identifier(o.cteAlias)}.${O.identifier(i)}`.as(t));
|
|
6477
6698
|
}
|
|
6478
6699
|
}
|
|
6479
|
-
return
|
|
6700
|
+
return Gt(a, e, t, n, r, i), a;
|
|
6480
6701
|
}
|
|
6481
|
-
function
|
|
6482
|
-
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 &&
|
|
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));
|
|
6483
6704
|
}
|
|
6484
|
-
function
|
|
6705
|
+
function Yt(e, t, n) {
|
|
6485
6706
|
if (t.dimensions) for (let r of t.dimensions) {
|
|
6486
6707
|
let [t, i] = r.split(".");
|
|
6487
6708
|
if (n.get(t)?.dimensions?.[i]?.sql === e) return !0;
|
|
@@ -6495,7 +6716,7 @@ function Gt(e, t, n) {
|
|
|
6495
6716
|
}
|
|
6496
6717
|
//#endregion
|
|
6497
6718
|
//#region src/server/physical-plan/processors/joins-processor.ts
|
|
6498
|
-
function
|
|
6719
|
+
function Xt(e, t, n, r, i, a) {
|
|
6499
6720
|
let o = [], s = t.db.select(r).from(n.from);
|
|
6500
6721
|
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") {
|
|
6501
6722
|
case "left":
|
|
@@ -6527,9 +6748,9 @@ function Kt(e, t, n, r, i, a) {
|
|
|
6527
6748
|
let e = [];
|
|
6528
6749
|
for (let n of t.joinKeys) {
|
|
6529
6750
|
let t = O`${O.identifier(c)}.${O.identifier(n.sourceColumn)}`, r = n.targetColumnObj;
|
|
6530
|
-
r && e.push(
|
|
6751
|
+
r && e.push(M(r, t));
|
|
6531
6752
|
}
|
|
6532
|
-
e.length > 0 && (a =
|
|
6753
|
+
e.length > 0 && (a = P(...e));
|
|
6533
6754
|
}
|
|
6534
6755
|
}
|
|
6535
6756
|
let l = [];
|
|
@@ -6563,12 +6784,12 @@ function Kt(e, t, n, r, i, a) {
|
|
|
6563
6784
|
let t = [];
|
|
6564
6785
|
for (let n of e.joinKeys) {
|
|
6565
6786
|
let r = O`${O.identifier(e.cteAlias)}.${O.identifier(n.sourceColumn)}`, i = n.targetColumnObj || O.identifier(n.targetColumn);
|
|
6566
|
-
t.push(
|
|
6787
|
+
t.push(M(r, i));
|
|
6567
6788
|
}
|
|
6568
|
-
f = t.length === 1 ? t[0] :
|
|
6789
|
+
f = t.length === 1 ? t[0] : P(...t);
|
|
6569
6790
|
} else f = n.joinCondition;
|
|
6570
6791
|
}
|
|
6571
|
-
let m = n.joinType || "left", h = m !== "inner" && p ?
|
|
6792
|
+
let m = n.joinType || "left", h = m !== "inner" && p ? P(f, p) : f;
|
|
6572
6793
|
try {
|
|
6573
6794
|
switch (m) {
|
|
6574
6795
|
case "left":
|
|
@@ -6595,7 +6816,7 @@ function Kt(e, t, n, r, i, a) {
|
|
|
6595
6816
|
}
|
|
6596
6817
|
//#endregion
|
|
6597
6818
|
//#region src/server/physical-plan/processors/predicates-processor.ts
|
|
6598
|
-
function
|
|
6819
|
+
function Zt(e, t, n, r, i, a, o, s) {
|
|
6599
6820
|
let c = [...o.allWhereConditions];
|
|
6600
6821
|
if (i.where && c.push(i.where), e.joinCubes && e.joinCubes.length > 0) for (let t of e.joinCubes) {
|
|
6601
6822
|
let e = t.cube.name;
|
|
@@ -6607,14 +6828,14 @@ function qt(e, t, n, r, i, a, o, s) {
|
|
|
6607
6828
|
l.length > 0 && c.push(...l);
|
|
6608
6829
|
let u = o.drizzleQuery;
|
|
6609
6830
|
if (c.length > 0) {
|
|
6610
|
-
let e = c.length === 1 ? c[0] :
|
|
6831
|
+
let e = c.length === 1 ? c[0] : P(...c);
|
|
6611
6832
|
u = u.where(e);
|
|
6612
6833
|
}
|
|
6613
6834
|
let d = s.queryBuilder.buildGroupByFields(e.joinCubes.length > 0 ? r : e.primaryCube, t, n, e);
|
|
6614
6835
|
if (d.length > 0 && (u = u.groupBy(...d)), !t.ungrouped) {
|
|
6615
6836
|
let i = s.queryBuilder.buildHavingConditions(e.joinCubes.length > 0 ? r : e.primaryCube, t, n, e);
|
|
6616
6837
|
if (i.length > 0) {
|
|
6617
|
-
let e = i.length === 1 ? i[0] :
|
|
6838
|
+
let e = i.length === 1 ? i[0] : P(...i);
|
|
6618
6839
|
u = u.having(e);
|
|
6619
6840
|
}
|
|
6620
6841
|
}
|
|
@@ -6623,14 +6844,14 @@ function qt(e, t, n, r, i, a, o, s) {
|
|
|
6623
6844
|
}
|
|
6624
6845
|
//#endregion
|
|
6625
6846
|
//#region src/server/physical-plan/processors/shared.ts
|
|
6626
|
-
function
|
|
6847
|
+
function Qt(e) {
|
|
6627
6848
|
let t = /* @__PURE__ */ new Map();
|
|
6628
6849
|
if (t.set(e.primaryCube.name, e.primaryCube), e.joinCubes) for (let n of e.joinCubes) t.set(n.cube.name, n.cube);
|
|
6629
6850
|
return t;
|
|
6630
6851
|
}
|
|
6631
6852
|
//#endregion
|
|
6632
6853
|
//#region src/server/physical-plan/drizzle-plan-builder.ts
|
|
6633
|
-
var
|
|
6854
|
+
var $t = class {
|
|
6634
6855
|
constructor(e, t, n) {
|
|
6635
6856
|
this.queryBuilder = e, this.cteBuilder = t, this.databaseAdapter = n;
|
|
6636
6857
|
}
|
|
@@ -6770,13 +6991,13 @@ var Yt = class {
|
|
|
6770
6991
|
if (i) return i;
|
|
6771
6992
|
let a = this.tryBuildKeysDeduplicationQuery(e, t, n, r);
|
|
6772
6993
|
if (a) return a;
|
|
6773
|
-
let o =
|
|
6774
|
-
return
|
|
6994
|
+
let o = Wt(e, t, n, r), s = e.primaryCube.sql(n), c = e.joinCubes.length > 0 ? Qt(e) : new Map([[e.primaryCube.name, e.primaryCube]]);
|
|
6995
|
+
return Zt(e, t, n, c, s, o, Xt(e, n, s, qt(e, t, n, c, r), o, r), r);
|
|
6775
6996
|
}
|
|
6776
6997
|
tryBuildKeysDeduplicationQuery(e, t, n, r) {
|
|
6777
6998
|
let i = e.keysDeduplication;
|
|
6778
6999
|
if (!i?.multipliedCubeName || !t.measures?.length) return null;
|
|
6779
|
-
let a = e.joinCubes.length > 0 ?
|
|
7000
|
+
let a = e.joinCubes.length > 0 ? Qt(e) : new Map([[e.primaryCube.name, e.primaryCube]]), o = a.get(i.multipliedCubeName);
|
|
6780
7001
|
if (!o || !this.canExecuteKeysDeduplication(t, o, i.multipliedCubeName)) return null;
|
|
6781
7002
|
let s = i.primaryKeyDimensions.length > 0 ? i.primaryKeyDimensions : this.getPrimaryKeyDimensions(o);
|
|
6782
7003
|
if (s.length === 0) return null;
|
|
@@ -6822,7 +7043,7 @@ var Yt = class {
|
|
|
6822
7043
|
let e = t.cube.sql(n);
|
|
6823
7044
|
v = this.applyJoinByType(v, t.joinType ?? "left", e.from, t.joinCondition), e.where && _.push(e.where);
|
|
6824
7045
|
}
|
|
6825
|
-
_.push(...r.queryBuilder.buildWhereConditions(a, t, n)), _.length > 0 && (v = v.where(_.length === 1 ? _[0] :
|
|
7046
|
+
_.push(...r.queryBuilder.buildWhereConditions(a, t, n)), _.length > 0 && (v = v.where(_.length === 1 ? _[0] : P(..._))), d.length > 0 && (v = v.groupBy(...d));
|
|
6826
7047
|
let y = n.db.$with(c).as(v), b = o.sql(n), x = {}, S = [];
|
|
6827
7048
|
for (let e of s) {
|
|
6828
7049
|
let t = o.dimensions?.[e];
|
|
@@ -6856,24 +7077,24 @@ var Yt = class {
|
|
|
6856
7077
|
x[a] = O`sum(${i})`.as(a), x[s] = O`count(${i})`.as(s);
|
|
6857
7078
|
}
|
|
6858
7079
|
let T = n.db.select(x).from(b.from), E = [];
|
|
6859
|
-
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] :
|
|
6860
|
-
let
|
|
6861
|
-
for (let e of t.dimensions ?? [])
|
|
6862
|
-
for (let e of t.timeDimensions ?? [])
|
|
7080
|
+
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
|
+
let ee = n.db.$with(l).as(T), D = {};
|
|
7082
|
+
for (let e of t.dimensions ?? []) D[e] = O`${O.identifier(c)}.${O.identifier(e)}`.as(e);
|
|
7083
|
+
for (let e of t.timeDimensions ?? []) D[e.dimension] = O`${O.identifier(c)}.${O.identifier(e.dimension)}`.as(e.dimension);
|
|
6863
7084
|
for (let e of h) {
|
|
6864
7085
|
let [, t] = e.split("."), n = o.measures?.[t];
|
|
6865
|
-
|
|
7086
|
+
D[e] = this.buildKeysOuterAggregation(n?.type ?? "sum", l, t, e);
|
|
6866
7087
|
}
|
|
6867
7088
|
for (let e of p) {
|
|
6868
7089
|
let [t, n] = e.split("."), r = a.get(t)?.measures?.[n], i = `__reg__${e.replace(".", "__")}`;
|
|
6869
|
-
|
|
7090
|
+
D[e] = this.buildKeysOuterAggregation(r?.type ?? "sum", c, i, e);
|
|
6870
7091
|
}
|
|
6871
|
-
let
|
|
6872
|
-
|
|
6873
|
-
let
|
|
6874
|
-
|
|
6875
|
-
let
|
|
6876
|
-
return
|
|
7092
|
+
let k = n.db.with(y, ee).select(D).from(O`${O.identifier(c)}`), A = f.map((e, t) => M(O`${O.identifier(c)}.${O.identifier(e)}`, O`${O.identifier(l)}.${O.identifier(s[t])}`)), te = A.length === 1 ? A[0] : P(...A);
|
|
7093
|
+
k = k.leftJoin(O`${O.identifier(l)}`, te);
|
|
7094
|
+
let j = [...(t.dimensions ?? []).map((e) => O`${O.identifier(c)}.${O.identifier(e)}`), ...(t.timeDimensions ?? []).map((e) => O`${O.identifier(c)}.${O.identifier(e.dimension)}`)];
|
|
7095
|
+
j.length > 0 && (k = k.groupBy(...j));
|
|
7096
|
+
let N = r.queryBuilder.buildOrderBy(t, Object.keys(D));
|
|
7097
|
+
return N.length > 0 && (k = k.orderBy(...N)), k = r.queryBuilder.applyLimitAndOffset(k, t), k;
|
|
6877
7098
|
}
|
|
6878
7099
|
tryBuildMultiFactMergeQuery(e, t, n, r) {
|
|
6879
7100
|
let i = e.multiFactMerge;
|
|
@@ -6892,8 +7113,8 @@ var Yt = class {
|
|
|
6892
7113
|
let t = i.groups[e].alias, n;
|
|
6893
7114
|
if (o.length === 0) n = O`1 = 1`;
|
|
6894
7115
|
else {
|
|
6895
|
-
let e = o.map((e) =>
|
|
6896
|
-
n = e.length === 1 ? e[0] :
|
|
7116
|
+
let e = o.map((e) => M(m.get(e), O`${O.identifier(t)}.${O.identifier(e)}`));
|
|
7117
|
+
n = e.length === 1 ? e[0] : P(...e);
|
|
6897
7118
|
}
|
|
6898
7119
|
if (p = this.applyJoinByType(p, c, O`${O.identifier(t)}`, n), o.length > 0 && c === "full") for (let e of o) m.set(e, O`coalesce(${m.get(e)}, ${O`${O.identifier(t)}.${O.identifier(e)}`})`);
|
|
6899
7120
|
}
|
|
@@ -6906,7 +7127,7 @@ var Yt = class {
|
|
|
6906
7127
|
for (let e of r.groups) for (let t of e.measures) u[t] = O`coalesce(${O`${O.identifier(e.alias)}.${O.identifier(t)}`}, 0)`.as(t);
|
|
6907
7128
|
let d = t.db.with(...i, l).select(u).from(O`${O.identifier(o)}`);
|
|
6908
7129
|
for (let e of r.groups) {
|
|
6909
|
-
let t = a.map((t) =>
|
|
7130
|
+
let t = a.map((t) => M(O`${O.identifier(o)}.${O.identifier(t)}`, O`${O.identifier(e.alias)}.${O.identifier(t)}`)), n = t.length === 1 ? t[0] : P(...t);
|
|
6910
7131
|
d = d.leftJoin(O`${O.identifier(e.alias)}`, n);
|
|
6911
7132
|
}
|
|
6912
7133
|
let f = n.queryBuilder.buildOrderBy(e, Object.keys(u));
|
|
@@ -6995,7 +7216,7 @@ function $(e, t) {
|
|
|
6995
7216
|
console.log(`\n[DC_DEBUG] ${e}`), console.log(n), r.length > 0 && console.log("params:", r), console.log();
|
|
6996
7217
|
} catch {}
|
|
6997
7218
|
}
|
|
6998
|
-
var
|
|
7219
|
+
var en = class {
|
|
6999
7220
|
queryBuilder;
|
|
7000
7221
|
drizzlePlanBuilder;
|
|
7001
7222
|
databaseAdapter;
|
|
@@ -7007,29 +7228,29 @@ var Xt = class {
|
|
|
7007
7228
|
logicalPlanBuilder;
|
|
7008
7229
|
planOptimiser;
|
|
7009
7230
|
rlsSetup;
|
|
7010
|
-
constructor(
|
|
7011
|
-
if (this.dbExecutor =
|
|
7012
|
-
this.queryBuilder = new
|
|
7013
|
-
let
|
|
7014
|
-
this.drizzlePlanBuilder = new
|
|
7015
|
-
}
|
|
7016
|
-
async withRLSContext(
|
|
7017
|
-
if (!this.rlsSetup) return
|
|
7018
|
-
let
|
|
7019
|
-
if (!
|
|
7020
|
-
let
|
|
7021
|
-
return
|
|
7022
|
-
await
|
|
7023
|
-
let
|
|
7024
|
-
return
|
|
7231
|
+
constructor(t, n, r) {
|
|
7232
|
+
if (this.dbExecutor = t, this.databaseAdapter = t.databaseAdapter, !this.databaseAdapter) throw Error(e("server.errors.dbAdapterRequired"));
|
|
7233
|
+
this.queryBuilder = new yt(this.databaseAdapter);
|
|
7234
|
+
let i = new xt(), a = new St(this.queryBuilder);
|
|
7235
|
+
this.drizzlePlanBuilder = new $t(this.queryBuilder, a, this.databaseAdapter), this.comparisonQueryBuilder = new Pt(this.databaseAdapter), this.funnelQueryBuilder = new Ft(this.databaseAdapter), this.flowQueryBuilder = new It(this.databaseAdapter), this.retentionQueryBuilder = new Vt(this.databaseAdapter), this.logicalPlanBuilder = new Ht(i), this.planOptimiser = new Ut(), this.cacheConfig = n, this.rlsSetup = r;
|
|
7236
|
+
}
|
|
7237
|
+
async withRLSContext(t, n) {
|
|
7238
|
+
if (!this.rlsSetup) return n();
|
|
7239
|
+
let r = this.dbExecutor.db;
|
|
7240
|
+
if (!r.transaction) throw Error(e("server.errors.rlsRequiresTransactions"));
|
|
7241
|
+
let i = this.rlsSetup;
|
|
7242
|
+
return r.transaction(async (e) => {
|
|
7243
|
+
await i(e, t);
|
|
7244
|
+
let r = Object.create(this.dbExecutor);
|
|
7245
|
+
return r.db = e, this.dbExecutor = r, n();
|
|
7025
7246
|
});
|
|
7026
7247
|
}
|
|
7027
|
-
async execute(
|
|
7248
|
+
async execute(t, n, r, i) {
|
|
7028
7249
|
try {
|
|
7029
|
-
let
|
|
7030
|
-
this.validateQueryForMode(
|
|
7250
|
+
let e = this.resolveQueryMode(n);
|
|
7251
|
+
this.validateQueryForMode(e, t, n);
|
|
7031
7252
|
let a;
|
|
7032
|
-
if (this.cacheConfig?.enabled !== !1 && this.cacheConfig?.provider) if (a =
|
|
7253
|
+
if (this.cacheConfig?.enabled !== !1 && this.cacheConfig?.provider) if (a = st(n, r, this.cacheConfig), i?.skipCache) this.cacheConfig.onCacheEvent?.({
|
|
7033
7254
|
type: "miss",
|
|
7034
7255
|
key: a,
|
|
7035
7256
|
durationMs: 0
|
|
@@ -7062,15 +7283,15 @@ var Xt = class {
|
|
|
7062
7283
|
} catch (e) {
|
|
7063
7284
|
this.cacheConfig.onError?.(e, "get");
|
|
7064
7285
|
}
|
|
7065
|
-
return await this.withRLSContext(
|
|
7066
|
-
} catch (
|
|
7067
|
-
if (
|
|
7068
|
-
let
|
|
7069
|
-
for (;
|
|
7070
|
-
let
|
|
7071
|
-
throw
|
|
7286
|
+
return await this.withRLSContext(r, () => this.executeQueryByModeWithCache(e, t, n, r, a));
|
|
7287
|
+
} catch (t) {
|
|
7288
|
+
if (t instanceof Error) {
|
|
7289
|
+
let n = t;
|
|
7290
|
+
for (; n.cause instanceof Error;) n = n.cause;
|
|
7291
|
+
let r = n.message, i = n;
|
|
7292
|
+
throw i.code && (r += ` [${i.code}]`), i.detail && (r += ` Detail: ${i.detail}`), i.hint && (r += ` Hint: ${i.hint}`), t.message = e("server.errors.queryExecutionFailed", { message: r }), t;
|
|
7072
7293
|
}
|
|
7073
|
-
throw Error("
|
|
7294
|
+
throw Error(e("server.errors.queryExecutionUnknown"), { cause: t });
|
|
7074
7295
|
}
|
|
7075
7296
|
}
|
|
7076
7297
|
buildLogicalPlan(e, t, n) {
|
|
@@ -7096,17 +7317,17 @@ var Xt = class {
|
|
|
7096
7317
|
})), c = await Promise.all(s), l = this.comparisonQueryBuilder.mergeComparisonResults(c, r, a);
|
|
7097
7318
|
return l.data = this.comparisonQueryBuilder.sortComparisonResults(l.data, r.dimension), l;
|
|
7098
7319
|
}
|
|
7099
|
-
buildComparisonExecutionPlan(
|
|
7100
|
-
let
|
|
7101
|
-
if (!
|
|
7102
|
-
let
|
|
7103
|
-
if (
|
|
7104
|
-
let
|
|
7320
|
+
buildComparisonExecutionPlan(t) {
|
|
7321
|
+
let n = this.comparisonQueryBuilder.getComparisonTimeDimension(t);
|
|
7322
|
+
if (!n || !n.compareDateRange) throw Error(e("server.errors.noCompareDateRange"));
|
|
7323
|
+
let r = this.comparisonQueryBuilder.normalizePeriods(n.compareDateRange);
|
|
7324
|
+
if (r.length < 2) throw Error(e("server.errors.compareDateRangeInvalid"));
|
|
7325
|
+
let i = r.map((e) => this.comparisonQueryBuilder.createPeriodQuery(t, e));
|
|
7105
7326
|
return {
|
|
7106
|
-
timeDimension:
|
|
7107
|
-
granularity:
|
|
7108
|
-
periods:
|
|
7109
|
-
periodQueries:
|
|
7327
|
+
timeDimension: n,
|
|
7328
|
+
granularity: n.granularity || "day",
|
|
7329
|
+
periods: r,
|
|
7330
|
+
periodQueries: i
|
|
7110
7331
|
};
|
|
7111
7332
|
}
|
|
7112
7333
|
async executeFunnelQueryWithCache(e, t, n, r) {
|
|
@@ -7116,31 +7337,31 @@ var Xt = class {
|
|
|
7116
7337
|
cache: { hit: !1 }
|
|
7117
7338
|
};
|
|
7118
7339
|
}
|
|
7119
|
-
async executeFunnelQuery(
|
|
7120
|
-
let
|
|
7121
|
-
if (!
|
|
7122
|
-
let
|
|
7340
|
+
async executeFunnelQuery(t, n, r) {
|
|
7341
|
+
let i = n.funnel, a = this.funnelQueryBuilder.validateConfig(i, t);
|
|
7342
|
+
if (!a.isValid) throw Error(e("server.errors.funnelValidationFailed", { errors: a.errors.join(", ") }));
|
|
7343
|
+
let o = {
|
|
7123
7344
|
db: this.dbExecutor.db,
|
|
7124
7345
|
schema: this.dbExecutor.schema,
|
|
7125
|
-
securityContext:
|
|
7126
|
-
},
|
|
7127
|
-
$("funnel query",
|
|
7128
|
-
let
|
|
7346
|
+
securityContext: r
|
|
7347
|
+
}, s = this.funnelQueryBuilder.buildFunnelQuery(i, t, o);
|
|
7348
|
+
$("funnel query", s);
|
|
7349
|
+
let c = await s, l = this.funnelQueryBuilder.transformResult(c, i), u = {
|
|
7129
7350
|
measures: {},
|
|
7130
7351
|
dimensions: {},
|
|
7131
7352
|
segments: {},
|
|
7132
7353
|
timeDimensions: {}
|
|
7133
7354
|
};
|
|
7134
|
-
return
|
|
7135
|
-
config:
|
|
7136
|
-
steps:
|
|
7355
|
+
return u.funnel = {
|
|
7356
|
+
config: i,
|
|
7357
|
+
steps: i.steps.map((e, t) => ({
|
|
7137
7358
|
name: e.name,
|
|
7138
7359
|
index: t,
|
|
7139
7360
|
timeToConvert: e.timeToConvert
|
|
7140
7361
|
}))
|
|
7141
7362
|
}, {
|
|
7142
|
-
data:
|
|
7143
|
-
annotation:
|
|
7363
|
+
data: l,
|
|
7364
|
+
annotation: u
|
|
7144
7365
|
};
|
|
7145
7366
|
}
|
|
7146
7367
|
async executeFlowQueryWithCache(e, t, n, r) {
|
|
@@ -7150,29 +7371,29 @@ var Xt = class {
|
|
|
7150
7371
|
cache: { hit: !1 }
|
|
7151
7372
|
};
|
|
7152
7373
|
}
|
|
7153
|
-
async executeFlowQuery(
|
|
7154
|
-
let
|
|
7155
|
-
if (!
|
|
7156
|
-
let
|
|
7374
|
+
async executeFlowQuery(t, n, r) {
|
|
7375
|
+
let i = n.flow, a = this.flowQueryBuilder.validateConfig(i, t);
|
|
7376
|
+
if (!a.isValid) throw Error(e("server.errors.flowValidationFailed", { errors: a.errors.join(", ") }));
|
|
7377
|
+
let o = {
|
|
7157
7378
|
db: this.dbExecutor.db,
|
|
7158
7379
|
schema: this.dbExecutor.schema,
|
|
7159
|
-
securityContext:
|
|
7160
|
-
},
|
|
7161
|
-
$("flow query",
|
|
7162
|
-
let
|
|
7380
|
+
securityContext: r
|
|
7381
|
+
}, s = this.flowQueryBuilder.buildFlowQuery(i, t, o);
|
|
7382
|
+
$("flow query", s);
|
|
7383
|
+
let c = await s, l = this.flowQueryBuilder.transformResult(c), u = {
|
|
7163
7384
|
measures: {},
|
|
7164
7385
|
dimensions: {},
|
|
7165
7386
|
segments: {},
|
|
7166
7387
|
timeDimensions: {}
|
|
7167
7388
|
};
|
|
7168
|
-
return
|
|
7169
|
-
config:
|
|
7170
|
-
startingStep: { name:
|
|
7171
|
-
stepsBefore:
|
|
7172
|
-
stepsAfter:
|
|
7389
|
+
return u.flow = {
|
|
7390
|
+
config: i,
|
|
7391
|
+
startingStep: { name: i.startingStep.name },
|
|
7392
|
+
stepsBefore: i.stepsBefore,
|
|
7393
|
+
stepsAfter: i.stepsAfter
|
|
7173
7394
|
}, {
|
|
7174
|
-
data: [
|
|
7175
|
-
annotation:
|
|
7395
|
+
data: [l],
|
|
7396
|
+
annotation: u
|
|
7176
7397
|
};
|
|
7177
7398
|
}
|
|
7178
7399
|
async executeRetentionQueryWithCache(e, t, n, r) {
|
|
@@ -7182,30 +7403,30 @@ var Xt = class {
|
|
|
7182
7403
|
cache: { hit: !1 }
|
|
7183
7404
|
};
|
|
7184
7405
|
}
|
|
7185
|
-
async executeRetentionQuery(
|
|
7186
|
-
let
|
|
7187
|
-
if (!
|
|
7188
|
-
let
|
|
7406
|
+
async executeRetentionQuery(t, n, r) {
|
|
7407
|
+
let i = n.retention, a = this.retentionQueryBuilder.validateConfig(i, t);
|
|
7408
|
+
if (!a.isValid) throw Error(e("server.errors.retentionValidationFailed", { errors: a.errors.join(", ") }));
|
|
7409
|
+
let o = {
|
|
7189
7410
|
db: this.dbExecutor.db,
|
|
7190
7411
|
schema: this.dbExecutor.schema,
|
|
7191
|
-
securityContext:
|
|
7192
|
-
},
|
|
7193
|
-
$("retention query",
|
|
7194
|
-
let
|
|
7412
|
+
securityContext: r
|
|
7413
|
+
}, s = this.retentionQueryBuilder.buildRetentionQuery(i, t, o);
|
|
7414
|
+
$("retention query", s);
|
|
7415
|
+
let c = await s, l = this.retentionQueryBuilder.transformResult(c, i), u = {
|
|
7195
7416
|
measures: {},
|
|
7196
7417
|
dimensions: {},
|
|
7197
7418
|
segments: {},
|
|
7198
7419
|
timeDimensions: {}
|
|
7199
7420
|
};
|
|
7200
|
-
return
|
|
7201
|
-
config:
|
|
7202
|
-
granularity:
|
|
7203
|
-
periods:
|
|
7204
|
-
retentionType:
|
|
7205
|
-
breakdownDimensions:
|
|
7421
|
+
return u.retention = {
|
|
7422
|
+
config: i,
|
|
7423
|
+
granularity: i.granularity,
|
|
7424
|
+
periods: i.periods,
|
|
7425
|
+
retentionType: i.retentionType,
|
|
7426
|
+
breakdownDimensions: i.breakdownDimensions
|
|
7206
7427
|
}, {
|
|
7207
|
-
data:
|
|
7208
|
-
annotation:
|
|
7428
|
+
data: l,
|
|
7429
|
+
annotation: u
|
|
7209
7430
|
};
|
|
7210
7431
|
}
|
|
7211
7432
|
async executeStandardQuery(e, t, n) {
|
|
@@ -7215,7 +7436,7 @@ var Xt = class {
|
|
|
7215
7436
|
$("query", s);
|
|
7216
7437
|
let c = this.queryBuilder.collectNumericFields(e, t), l = await this.dbExecutor.execute(s, c);
|
|
7217
7438
|
return {
|
|
7218
|
-
data:
|
|
7439
|
+
data: jt(Array.isArray(l) ? l.map((e) => {
|
|
7219
7440
|
let n = { ...e };
|
|
7220
7441
|
if (t.timeDimensions) {
|
|
7221
7442
|
for (let e of t.timeDimensions) if (e.dimension in n) {
|
|
@@ -7275,46 +7496,46 @@ var Xt = class {
|
|
|
7275
7496
|
async generateMultiCubeSQL(e, t, n) {
|
|
7276
7497
|
return this.generateUnifiedSQL(e, t, n);
|
|
7277
7498
|
}
|
|
7278
|
-
async dryRunFunnel(
|
|
7279
|
-
if (!this.funnelQueryBuilder.hasFunnel(
|
|
7280
|
-
let
|
|
7281
|
-
if (!
|
|
7282
|
-
let
|
|
7499
|
+
async dryRunFunnel(t, n, r) {
|
|
7500
|
+
if (!this.funnelQueryBuilder.hasFunnel(n)) throw Error(e("server.errors.invalidFunnelConfig"));
|
|
7501
|
+
let i = n.funnel, a = this.funnelQueryBuilder.validateConfig(i, t);
|
|
7502
|
+
if (!a.isValid) throw Error(e("server.errors.funnelValidationFailed", { errors: a.errors.join(", ") }));
|
|
7503
|
+
let o = {
|
|
7283
7504
|
db: this.dbExecutor.db,
|
|
7284
7505
|
schema: this.dbExecutor.schema,
|
|
7285
|
-
securityContext:
|
|
7286
|
-
},
|
|
7506
|
+
securityContext: r
|
|
7507
|
+
}, s = this.funnelQueryBuilder.buildFunnelQuery(i, t, o).toSQL();
|
|
7287
7508
|
return {
|
|
7288
|
-
sql:
|
|
7289
|
-
params:
|
|
7509
|
+
sql: s.sql,
|
|
7510
|
+
params: s.params
|
|
7290
7511
|
};
|
|
7291
7512
|
}
|
|
7292
|
-
async dryRunFlow(
|
|
7293
|
-
if (!this.flowQueryBuilder.hasFlow(
|
|
7294
|
-
let
|
|
7295
|
-
if (!
|
|
7296
|
-
let
|
|
7513
|
+
async dryRunFlow(t, n, r) {
|
|
7514
|
+
if (!this.flowQueryBuilder.hasFlow(n)) throw Error(e("server.errors.invalidFlowConfig"));
|
|
7515
|
+
let i = n.flow, a = this.flowQueryBuilder.validateConfig(i, t);
|
|
7516
|
+
if (!a.isValid) throw Error(e("server.errors.flowValidationFailed", { errors: a.errors.join(", ") }));
|
|
7517
|
+
let o = {
|
|
7297
7518
|
db: this.dbExecutor.db,
|
|
7298
7519
|
schema: this.dbExecutor.schema,
|
|
7299
|
-
securityContext:
|
|
7300
|
-
},
|
|
7520
|
+
securityContext: r
|
|
7521
|
+
}, s = this.flowQueryBuilder.buildFlowQuery(i, t, o).toSQL();
|
|
7301
7522
|
return {
|
|
7302
|
-
sql:
|
|
7303
|
-
params:
|
|
7523
|
+
sql: s.sql,
|
|
7524
|
+
params: s.params
|
|
7304
7525
|
};
|
|
7305
7526
|
}
|
|
7306
|
-
async dryRunRetention(
|
|
7307
|
-
if (!this.retentionQueryBuilder.hasRetention(
|
|
7308
|
-
let
|
|
7309
|
-
if (!
|
|
7310
|
-
let
|
|
7527
|
+
async dryRunRetention(t, n, r) {
|
|
7528
|
+
if (!this.retentionQueryBuilder.hasRetention(n)) throw Error(e("server.errors.invalidRetentionConfig"));
|
|
7529
|
+
let i = n.retention, a = this.retentionQueryBuilder.validateConfig(i, t);
|
|
7530
|
+
if (!a.isValid) throw Error(e("server.errors.retentionValidationFailed", { errors: a.errors.join(", ") }));
|
|
7531
|
+
let o = {
|
|
7311
7532
|
db: this.dbExecutor.db,
|
|
7312
7533
|
schema: this.dbExecutor.schema,
|
|
7313
|
-
securityContext:
|
|
7314
|
-
},
|
|
7534
|
+
securityContext: r
|
|
7535
|
+
}, s = this.retentionQueryBuilder.buildRetentionQuery(i, t, o).toSQL();
|
|
7315
7536
|
return {
|
|
7316
|
-
sql:
|
|
7317
|
-
params:
|
|
7537
|
+
sql: s.sql,
|
|
7538
|
+
params: s.params
|
|
7318
7539
|
};
|
|
7319
7540
|
}
|
|
7320
7541
|
async explainQuery(e, t, n, r) {
|
|
@@ -7334,33 +7555,33 @@ var Xt = class {
|
|
|
7334
7555
|
params: s.params
|
|
7335
7556
|
};
|
|
7336
7557
|
}
|
|
7337
|
-
resolveQueryMode(
|
|
7338
|
-
let
|
|
7339
|
-
if (this.comparisonQueryBuilder.hasComparison(
|
|
7340
|
-
if (
|
|
7341
|
-
return
|
|
7342
|
-
}
|
|
7343
|
-
validateQueryForMode(
|
|
7344
|
-
let
|
|
7345
|
-
let
|
|
7346
|
-
if (!
|
|
7558
|
+
resolveQueryMode(t) {
|
|
7559
|
+
let n = [];
|
|
7560
|
+
if (this.comparisonQueryBuilder.hasComparison(t) && n.push("comparison"), this.funnelQueryBuilder.hasFunnel(t) && n.push("funnel"), this.flowQueryBuilder.hasFlow(t) && n.push("flow"), this.retentionQueryBuilder.hasRetention(t) && n.push("retention"), n.length === 0) return "regular";
|
|
7561
|
+
if (n.length > 1) throw Error(e("server.errors.queryContainsMultipleModes", { modes: n.join(", ") }));
|
|
7562
|
+
return n[0];
|
|
7563
|
+
}
|
|
7564
|
+
validateQueryForMode(t, n, r) {
|
|
7565
|
+
let i = () => {
|
|
7566
|
+
let t = rn(n, r);
|
|
7567
|
+
if (!t.isValid) throw Error(e("server.errors.queryValidationFailed", { errors: t.errors.join(", ") }));
|
|
7347
7568
|
};
|
|
7348
7569
|
({
|
|
7349
|
-
regular:
|
|
7350
|
-
comparison:
|
|
7570
|
+
regular: i,
|
|
7571
|
+
comparison: i,
|
|
7351
7572
|
funnel: () => {
|
|
7352
|
-
let
|
|
7353
|
-
if (!
|
|
7573
|
+
let t = this.funnelQueryBuilder.validateConfig(r.funnel, n);
|
|
7574
|
+
if (!t.isValid) throw Error(e("server.errors.funnelValidationFailed", { errors: t.errors.join(", ") }));
|
|
7354
7575
|
},
|
|
7355
7576
|
flow: () => {
|
|
7356
|
-
let
|
|
7357
|
-
if (!
|
|
7577
|
+
let t = this.flowQueryBuilder.validateConfig(r.flow, n);
|
|
7578
|
+
if (!t.isValid) throw Error(e("server.errors.flowValidationFailed", { errors: t.errors.join(", ") }));
|
|
7358
7579
|
},
|
|
7359
7580
|
retention: () => {
|
|
7360
|
-
let
|
|
7361
|
-
if (!
|
|
7581
|
+
let t = this.retentionQueryBuilder.validateConfig(r.retention, n);
|
|
7582
|
+
if (!t.isValid) throw Error(e("server.errors.retentionValidationFailed", { errors: t.errors.join(", ") }));
|
|
7362
7583
|
}
|
|
7363
|
-
})[
|
|
7584
|
+
})[rt(t)]();
|
|
7364
7585
|
}
|
|
7365
7586
|
async executeQueryByModeWithCache(e, t, n, r, i) {
|
|
7366
7587
|
return {
|
|
@@ -7369,7 +7590,7 @@ var Xt = class {
|
|
|
7369
7590
|
funnel: () => this.executeFunnelQueryWithCache(t, n, r, i),
|
|
7370
7591
|
flow: () => this.executeFlowQueryWithCache(t, n, r, i),
|
|
7371
7592
|
retention: () => this.executeRetentionQueryWithCache(t, n, r, i)
|
|
7372
|
-
}[
|
|
7593
|
+
}[rt(e)]();
|
|
7373
7594
|
}
|
|
7374
7595
|
async executeRegularQueryWithCache(e, t, n, r) {
|
|
7375
7596
|
let i = new K(), a = this.createQueryContext(n, i, t);
|
|
@@ -7379,7 +7600,7 @@ var Xt = class {
|
|
|
7379
7600
|
let c = this.drizzlePlanBuilder.build(s, t, a);
|
|
7380
7601
|
$("query", c);
|
|
7381
7602
|
let l = this.queryBuilder.collectNumericFields(e, t), u = await this.dbExecutor.execute(c, l), d = {
|
|
7382
|
-
data:
|
|
7603
|
+
data: jt(Array.isArray(u) ? u.map((e) => {
|
|
7383
7604
|
let n = { ...e };
|
|
7384
7605
|
if (t.timeDimensions) {
|
|
7385
7606
|
for (let e of t.timeDimensions) if (e.dimension in n) {
|
|
@@ -7417,7 +7638,7 @@ var Xt = class {
|
|
|
7417
7638
|
funnel: () => this.dryRunFunnel(t, n, r),
|
|
7418
7639
|
flow: () => this.dryRunFlow(t, n, r),
|
|
7419
7640
|
retention: () => this.dryRunRetention(t, n, r)
|
|
7420
|
-
}[
|
|
7641
|
+
}[rt(e)]();
|
|
7421
7642
|
}
|
|
7422
7643
|
async generateComparisonSQL(e, t, n) {
|
|
7423
7644
|
let r = this.buildComparisonExecutionPlan(t).periodQueries[0];
|
|
@@ -7469,7 +7690,7 @@ var Xt = class {
|
|
|
7469
7690
|
}
|
|
7470
7691
|
preloadFilterCache(e, t, n, r) {
|
|
7471
7692
|
if (e.filters && e.filters.length > 0) {
|
|
7472
|
-
let i =
|
|
7693
|
+
let i = ot(e.filters);
|
|
7473
7694
|
for (let e of i) {
|
|
7474
7695
|
let i = G(e);
|
|
7475
7696
|
if (t.has(i)) continue;
|
|
@@ -7487,7 +7708,7 @@ var Xt = class {
|
|
|
7487
7708
|
}
|
|
7488
7709
|
if (e.timeDimensions) {
|
|
7489
7710
|
for (let i of e.timeDimensions) if (i.dateRange) {
|
|
7490
|
-
let e =
|
|
7711
|
+
let e = at(i.dimension, i.dateRange);
|
|
7491
7712
|
if (t.has(e)) continue;
|
|
7492
7713
|
let [a, o] = i.dimension.split("."), s = n.get(a);
|
|
7493
7714
|
if (!s) continue;
|
|
@@ -7498,7 +7719,7 @@ var Xt = class {
|
|
|
7498
7719
|
}
|
|
7499
7720
|
}
|
|
7500
7721
|
}
|
|
7501
|
-
},
|
|
7722
|
+
}, tn = class n {
|
|
7502
7723
|
cubes = /* @__PURE__ */ new Map();
|
|
7503
7724
|
metadataCache;
|
|
7504
7725
|
cacheConfig;
|
|
@@ -7522,57 +7743,71 @@ var Xt = class {
|
|
|
7522
7743
|
return !!this.db;
|
|
7523
7744
|
}
|
|
7524
7745
|
createDbExecutor() {
|
|
7525
|
-
if (!this.db) throw Error("
|
|
7526
|
-
return
|
|
7746
|
+
if (!this.db) throw Error(e("server.errors.dbNotConfigured"));
|
|
7747
|
+
return $e(this.db, this.schema, this.engineType);
|
|
7527
7748
|
}
|
|
7528
7749
|
createQueryExecutor(e = !1) {
|
|
7529
|
-
return new
|
|
7750
|
+
return new en(this.createDbExecutor(), e ? this.cacheConfig : void 0, this.rlsSetup);
|
|
7530
7751
|
}
|
|
7531
|
-
formatSqlResult(
|
|
7752
|
+
formatSqlResult(e) {
|
|
7532
7753
|
let n = this.getEngineType() ?? "postgres";
|
|
7533
7754
|
return {
|
|
7534
|
-
sql: e
|
|
7535
|
-
params:
|
|
7755
|
+
sql: t(e.sql, n),
|
|
7756
|
+
params: e.params
|
|
7536
7757
|
};
|
|
7537
7758
|
}
|
|
7538
7759
|
registerCube(e) {
|
|
7539
7760
|
this.validateCalculatedMeasures(e), new Z(this.cubes).populateDependencies(e), this.cubes.set(e.name, e), this.invalidateMetadataCache();
|
|
7540
7761
|
}
|
|
7541
7762
|
validateCubeReferences() {
|
|
7542
|
-
let e = [];
|
|
7543
|
-
for (let [t, n] of this.cubes) if (n.joins) for (let [r, i] of Object.entries(n.joins)) typeof i.targetCube == "string" && !this.cubes.has(i.targetCube) && e.push(`${t}.joins.${r}: target cube '${i.targetCube}' is not registered`);
|
|
7544
|
-
if (e.length > 0) throw Error(`Unresolved cube references:\n${e.map((e) => ` - ${e}`).join("\n")}`);
|
|
7545
|
-
}
|
|
7546
|
-
validateCalculatedMeasures(e) {
|
|
7547
7763
|
let t = [];
|
|
7548
|
-
for (let [n, r] of Object.entries(
|
|
7549
|
-
|
|
7550
|
-
|
|
7764
|
+
for (let [n, r] of this.cubes) if (r.joins) for (let [i, a] of Object.entries(r.joins)) typeof a.targetCube == "string" && !this.cubes.has(a.targetCube) && t.push(e("server.errors.cubeRefUnresolved", {
|
|
7765
|
+
cubeName: n,
|
|
7766
|
+
joinName: i,
|
|
7767
|
+
targetCube: a.targetCube
|
|
7768
|
+
}));
|
|
7769
|
+
if (t.length > 0) throw Error(e("server.errors.unresolvedCubeRefs", { details: t.map((e) => ` - ${e}`).join("\n") }));
|
|
7770
|
+
}
|
|
7771
|
+
validateCalculatedMeasures(t) {
|
|
7772
|
+
let n = [];
|
|
7773
|
+
for (let [r, i] of Object.entries(t.measures)) if (i.type === "calculated") {
|
|
7774
|
+
if (!i.calculatedSql) {
|
|
7775
|
+
n.push(e("server.validation.calculatedMeasure.mustHaveCalculatedSql", {
|
|
7776
|
+
cubeName: t.name,
|
|
7777
|
+
fieldName: r
|
|
7778
|
+
}));
|
|
7551
7779
|
continue;
|
|
7552
7780
|
}
|
|
7553
|
-
let
|
|
7554
|
-
if (!
|
|
7555
|
-
|
|
7781
|
+
let a = gt(i.calculatedSql);
|
|
7782
|
+
if (!a.isValid) {
|
|
7783
|
+
n.push(e("server.validation.calculatedMeasure.invalidSyntax", {
|
|
7784
|
+
cubeName: t.name,
|
|
7785
|
+
fieldName: r,
|
|
7786
|
+
errors: a.errors.join(", ")
|
|
7787
|
+
}));
|
|
7556
7788
|
continue;
|
|
7557
7789
|
}
|
|
7558
|
-
let
|
|
7559
|
-
|
|
7560
|
-
let
|
|
7790
|
+
let o = new Map(this.cubes);
|
|
7791
|
+
o.set(t.name, t);
|
|
7792
|
+
let s = new Z(o);
|
|
7561
7793
|
try {
|
|
7562
|
-
|
|
7794
|
+
s.validateDependencies(t);
|
|
7563
7795
|
} catch (e) {
|
|
7564
|
-
|
|
7796
|
+
n.push(e instanceof Error ? e.message : String(e));
|
|
7565
7797
|
}
|
|
7566
7798
|
}
|
|
7567
|
-
if (
|
|
7568
|
-
let
|
|
7569
|
-
|
|
7570
|
-
let
|
|
7571
|
-
|
|
7572
|
-
let
|
|
7573
|
-
|
|
7574
|
-
}
|
|
7575
|
-
if (
|
|
7799
|
+
if (n.length === 0) {
|
|
7800
|
+
let r = new Map(this.cubes);
|
|
7801
|
+
r.set(t.name, t);
|
|
7802
|
+
let i = new Z(r);
|
|
7803
|
+
i.buildGraph(t);
|
|
7804
|
+
let a = i.detectCycle();
|
|
7805
|
+
a && n.push(e("server.validation.calculatedMeasure.circularDependency", { cycle: a.join(" -> ") }));
|
|
7806
|
+
}
|
|
7807
|
+
if (n.length > 0) throw Error(e("server.errors.calculatedMeasureValidation", {
|
|
7808
|
+
cubeName: t.name,
|
|
7809
|
+
details: n.join("\n")
|
|
7810
|
+
}));
|
|
7576
7811
|
}
|
|
7577
7812
|
getCube(e) {
|
|
7578
7813
|
return this.cubes.get(e);
|
|
@@ -7589,9 +7824,9 @@ var Xt = class {
|
|
|
7589
7824
|
async executeMultiCubeQuery(e, t, n) {
|
|
7590
7825
|
return this.execute(e, t, n);
|
|
7591
7826
|
}
|
|
7592
|
-
async executeQuery(
|
|
7593
|
-
if (!this.cubes.get(
|
|
7594
|
-
return this.execute(
|
|
7827
|
+
async executeQuery(t, n, r) {
|
|
7828
|
+
if (!this.cubes.get(t)) throw Error(e("server.errors.cubeNotFound", { cubeName: t }));
|
|
7829
|
+
return this.execute(n, r);
|
|
7595
7830
|
}
|
|
7596
7831
|
getMetadata() {
|
|
7597
7832
|
return this.metadataCache ||= Array.from(this.cubes.values()).map((e) => this.generateCubeMetadata(e)), this.metadataCache;
|
|
@@ -7615,10 +7850,10 @@ var Xt = class {
|
|
|
7615
7850
|
"hour"
|
|
7616
7851
|
];
|
|
7617
7852
|
generateCubeMetadata(e) {
|
|
7618
|
-
let
|
|
7619
|
-
for (let
|
|
7620
|
-
let r = n
|
|
7621
|
-
a.drillMembers && a.drillMembers.length > 0 && (o = a.drillMembers.map((t) => t.includes(".") ? t : `${e.name}.${t}`)), i[
|
|
7853
|
+
let t = Object.keys(e.measures), r = Object.keys(e.dimensions), i = Array(t.length), a = Array(r.length);
|
|
7854
|
+
for (let n = 0; n < t.length; n++) {
|
|
7855
|
+
let r = t[n], a = e.measures[r], o;
|
|
7856
|
+
a.drillMembers && a.drillMembers.length > 0 && (o = a.drillMembers.map((t) => t.includes(".") ? t : `${e.name}.${t}`)), i[n] = {
|
|
7622
7857
|
name: `${e.name}.${r}`,
|
|
7623
7858
|
title: a.title || r,
|
|
7624
7859
|
shortTitle: a.title || r,
|
|
@@ -7629,9 +7864,9 @@ var Xt = class {
|
|
|
7629
7864
|
drillMembers: o
|
|
7630
7865
|
};
|
|
7631
7866
|
}
|
|
7632
|
-
for (let
|
|
7633
|
-
let i = r[
|
|
7634
|
-
o.type === "time" && (s = o.granularities ||
|
|
7867
|
+
for (let t = 0; t < r.length; t++) {
|
|
7868
|
+
let i = r[t], o = e.dimensions[i], s;
|
|
7869
|
+
o.type === "time" && (s = o.granularities || n.DEFAULT_TIME_GRANULARITIES), a[t] = {
|
|
7635
7870
|
name: `${e.name}.${i}`,
|
|
7636
7871
|
title: o.title || i,
|
|
7637
7872
|
shortTitle: o.title || i,
|
|
@@ -7674,11 +7909,11 @@ var Xt = class {
|
|
|
7674
7909
|
meta: e.meta
|
|
7675
7910
|
};
|
|
7676
7911
|
}
|
|
7677
|
-
async generateSQL(
|
|
7678
|
-
let
|
|
7679
|
-
if (!
|
|
7680
|
-
let
|
|
7681
|
-
return this.formatSqlResult(
|
|
7912
|
+
async generateSQL(t, n, r) {
|
|
7913
|
+
let i = this.getCube(t);
|
|
7914
|
+
if (!i) throw Error(e("server.errors.cubeNotFound", { cubeName: t }));
|
|
7915
|
+
let a = await this.createQueryExecutor().generateSQL(i, n, r);
|
|
7916
|
+
return this.formatSqlResult(a);
|
|
7682
7917
|
}
|
|
7683
7918
|
async generateMultiCubeSQL(e, t) {
|
|
7684
7919
|
let n = await this.createQueryExecutor().generateMultiCubeSQL(this.cubes, e, t);
|
|
@@ -7720,114 +7955,134 @@ var Xt = class {
|
|
|
7720
7955
|
return Array.from(this.cubes.keys());
|
|
7721
7956
|
}
|
|
7722
7957
|
validateQuery(e) {
|
|
7723
|
-
return
|
|
7958
|
+
return rn(this.cubes, e);
|
|
7724
7959
|
}
|
|
7725
7960
|
analyzeQuery(e, t) {
|
|
7726
7961
|
return this.createQueryExecutor(!0).analyzeQuery(this.cubes, e, t);
|
|
7727
7962
|
}
|
|
7728
7963
|
};
|
|
7729
|
-
function
|
|
7964
|
+
function nn(e) {
|
|
7730
7965
|
let t = [];
|
|
7731
7966
|
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;
|
|
7732
7967
|
}
|
|
7733
|
-
function
|
|
7734
|
-
let
|
|
7735
|
-
if (
|
|
7968
|
+
function rn(t, n) {
|
|
7969
|
+
let r = [], i = nn(n);
|
|
7970
|
+
if (i.length > 1) return r.push(e("server.validation.query.multipleQueryModes", { modes: i.join(", ") })), {
|
|
7736
7971
|
isValid: !1,
|
|
7737
|
-
errors:
|
|
7972
|
+
errors: r
|
|
7738
7973
|
};
|
|
7739
|
-
let
|
|
7974
|
+
let a = {
|
|
7740
7975
|
funnel: () => {
|
|
7741
|
-
let
|
|
7742
|
-
if (typeof
|
|
7743
|
-
let [
|
|
7744
|
-
|
|
7745
|
-
} else if (Array.isArray(
|
|
7976
|
+
let i = n.funnel.bindingKey;
|
|
7977
|
+
if (typeof i == "string") {
|
|
7978
|
+
let [n] = i.split(".");
|
|
7979
|
+
n && !t.has(n) && r.push(e("server.validation.query.funnelBindingKeyCubeNotFound", { cubeName: n }));
|
|
7980
|
+
} else if (Array.isArray(i)) for (let n of i) t.has(n.cube) || r.push(e("server.validation.query.funnelBindingKeyCubeNotFound", { cubeName: n.cube }));
|
|
7746
7981
|
},
|
|
7747
7982
|
flow: () => {
|
|
7748
|
-
let
|
|
7749
|
-
if (typeof
|
|
7750
|
-
let [
|
|
7751
|
-
|
|
7983
|
+
let i = n.flow.bindingKey;
|
|
7984
|
+
if (typeof i == "string") {
|
|
7985
|
+
let [n] = i.split(".");
|
|
7986
|
+
n && !t.has(n) && r.push(e("server.validation.query.flowBindingKeyCubeNotFound", { cubeName: n }));
|
|
7752
7987
|
}
|
|
7753
7988
|
},
|
|
7754
7989
|
retention: () => {
|
|
7755
|
-
let
|
|
7756
|
-
|
|
7757
|
-
let
|
|
7758
|
-
if (typeof
|
|
7759
|
-
let [
|
|
7760
|
-
|
|
7761
|
-
} else if (Array.isArray(
|
|
7762
|
-
if (
|
|
7763
|
-
let [
|
|
7764
|
-
|
|
7990
|
+
let i = n.retention, a = on(i.timeDimension);
|
|
7991
|
+
a && !t.has(a) && r.push(e("server.validation.query.retentionCubeNotFound", { cubeName: a }));
|
|
7992
|
+
let o = i.bindingKey;
|
|
7993
|
+
if (typeof o == "string") {
|
|
7994
|
+
let [n] = o.split(".");
|
|
7995
|
+
n && !t.has(n) && r.push(e("server.validation.query.retentionBindingKeyCubeNotFound", { cubeName: n }));
|
|
7996
|
+
} else if (Array.isArray(o)) for (let n of o) t.has(n.cube) || r.push(e("server.validation.query.retentionBindingKeyCubeNotFound", { cubeName: n.cube }));
|
|
7997
|
+
if (i.breakdownDimensions && Array.isArray(i.breakdownDimensions)) for (let n of i.breakdownDimensions) {
|
|
7998
|
+
let [i] = n.split(".");
|
|
7999
|
+
i && !t.has(i) && r.push(e("server.validation.query.retentionBreakdownCubeNotFound", { cubeName: i }));
|
|
7765
8000
|
}
|
|
7766
8001
|
}
|
|
7767
8002
|
};
|
|
7768
|
-
if (
|
|
7769
|
-
isValid:
|
|
7770
|
-
errors:
|
|
8003
|
+
if (i.length === 1 && i[0] !== "comparison") return a[i[0]](), {
|
|
8004
|
+
isValid: r.length === 0,
|
|
8005
|
+
errors: r
|
|
7771
8006
|
};
|
|
7772
|
-
let
|
|
7773
|
-
if (
|
|
7774
|
-
let [
|
|
7775
|
-
if (!
|
|
7776
|
-
|
|
8007
|
+
let o = /* @__PURE__ */ new Set();
|
|
8008
|
+
if (n.measures) for (let i of n.measures) {
|
|
8009
|
+
let [n, a] = i.split(".");
|
|
8010
|
+
if (!n || !a) {
|
|
8011
|
+
r.push(e("server.validation.query.invalidMeasureFormat", { measure: i }));
|
|
7777
8012
|
continue;
|
|
7778
8013
|
}
|
|
7779
|
-
|
|
7780
|
-
let
|
|
7781
|
-
if (!
|
|
7782
|
-
|
|
8014
|
+
o.add(n);
|
|
8015
|
+
let s = t.get(n);
|
|
8016
|
+
if (!s) {
|
|
8017
|
+
r.push(e("server.validation.query.cubeNotFoundForMeasure", {
|
|
8018
|
+
cubeName: n,
|
|
8019
|
+
measure: i
|
|
8020
|
+
}));
|
|
7783
8021
|
continue;
|
|
7784
8022
|
}
|
|
7785
|
-
if (!
|
|
7786
|
-
let
|
|
7787
|
-
|
|
8023
|
+
if (!s.measures[a]) {
|
|
8024
|
+
let t = a === n ? `. Did you mean one of: ${Object.keys(s.measures).slice(0, 5).map((e) => `'${n}.${e}'`).join(", ")}?` : "";
|
|
8025
|
+
r.push(e("server.validation.query.measureNotFound", {
|
|
8026
|
+
fieldName: a,
|
|
8027
|
+
cubeName: n,
|
|
8028
|
+
hint: t
|
|
8029
|
+
}));
|
|
7788
8030
|
}
|
|
7789
8031
|
}
|
|
7790
|
-
if (
|
|
7791
|
-
let [
|
|
7792
|
-
if (!
|
|
7793
|
-
|
|
8032
|
+
if (n.dimensions) for (let i of n.dimensions) {
|
|
8033
|
+
let [n, a] = i.split(".");
|
|
8034
|
+
if (!n || !a) {
|
|
8035
|
+
r.push(e("server.validation.query.invalidDimensionFormat", { dimension: i }));
|
|
7794
8036
|
continue;
|
|
7795
8037
|
}
|
|
7796
|
-
|
|
7797
|
-
let
|
|
7798
|
-
if (!
|
|
7799
|
-
|
|
8038
|
+
o.add(n);
|
|
8039
|
+
let s = t.get(n);
|
|
8040
|
+
if (!s) {
|
|
8041
|
+
r.push(e("server.validation.query.cubeNotFoundForDimension", {
|
|
8042
|
+
cubeName: n,
|
|
8043
|
+
dimension: i
|
|
8044
|
+
}));
|
|
7800
8045
|
continue;
|
|
7801
8046
|
}
|
|
7802
|
-
if (!
|
|
7803
|
-
let
|
|
7804
|
-
|
|
8047
|
+
if (!s.dimensions[a]) {
|
|
8048
|
+
let t = a === n ? `. Did you mean one of: ${Object.keys(s.dimensions).slice(0, 5).map((e) => `'${n}.${e}'`).join(", ")}?` : "";
|
|
8049
|
+
r.push(e("server.validation.query.dimensionNotFound", {
|
|
8050
|
+
fieldName: a,
|
|
8051
|
+
cubeName: n,
|
|
8052
|
+
hint: t
|
|
8053
|
+
}));
|
|
7805
8054
|
}
|
|
7806
8055
|
}
|
|
7807
|
-
if (
|
|
7808
|
-
let [
|
|
7809
|
-
if (!
|
|
7810
|
-
|
|
8056
|
+
if (n.timeDimensions) for (let i of n.timeDimensions) {
|
|
8057
|
+
let [n, a] = i.dimension.split(".");
|
|
8058
|
+
if (!n || !a) {
|
|
8059
|
+
r.push(e("server.validation.query.invalidTimeDimensionFormat", { dimension: i.dimension }));
|
|
7811
8060
|
continue;
|
|
7812
8061
|
}
|
|
7813
|
-
|
|
7814
|
-
let
|
|
7815
|
-
if (!
|
|
7816
|
-
|
|
8062
|
+
o.add(n);
|
|
8063
|
+
let s = t.get(n);
|
|
8064
|
+
if (!s) {
|
|
8065
|
+
r.push(e("server.validation.query.cubeNotFoundForTimeDimension", {
|
|
8066
|
+
cubeName: n,
|
|
8067
|
+
dimension: i.dimension
|
|
8068
|
+
}));
|
|
7817
8069
|
continue;
|
|
7818
8070
|
}
|
|
7819
|
-
|
|
8071
|
+
s.dimensions[a] || r.push(e("server.validation.query.timeDimensionNotFound", {
|
|
8072
|
+
fieldName: a,
|
|
8073
|
+
cubeName: n
|
|
8074
|
+
}));
|
|
7820
8075
|
}
|
|
7821
|
-
if (
|
|
7822
|
-
if (
|
|
7823
|
-
|
|
7824
|
-
let
|
|
8076
|
+
if (n.filters) for (let e of n.filters) an(e, t, r, o);
|
|
8077
|
+
if (o.size === 0 && r.push(e("server.validation.query.mustReferenceAtLeastOneCube")), n.ungrouped) {
|
|
8078
|
+
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
|
+
let i = new Set([
|
|
7825
8080
|
"sum",
|
|
7826
8081
|
"avg",
|
|
7827
8082
|
"min",
|
|
7828
8083
|
"max",
|
|
7829
8084
|
"number"
|
|
7830
|
-
]),
|
|
8085
|
+
]), a = new Set([
|
|
7831
8086
|
"count",
|
|
7832
8087
|
"countDistinct",
|
|
7833
8088
|
"countDistinctApprox",
|
|
@@ -7851,55 +8106,62 @@ function $t(e, t) {
|
|
|
7851
8106
|
"movingAvg",
|
|
7852
8107
|
"movingSum"
|
|
7853
8108
|
]);
|
|
7854
|
-
if (
|
|
7855
|
-
let [
|
|
8109
|
+
if (n.measures) for (let e of n.measures) {
|
|
8110
|
+
let [n, o] = e.split("."), s = t.get(n);
|
|
7856
8111
|
if (s && s.measures[o]) {
|
|
7857
|
-
let
|
|
7858
|
-
|
|
8112
|
+
let t = s.measures[o];
|
|
8113
|
+
a.has(t.type) && r.push(`Measure '${e}' has type '${t.type}' which is incompatible with ungrouped queries. Only ${[...i].join(", ")} types are allowed.`), t.filters && t.filters.length > 0 && r.push(`Measure '${e}' has filters which are incompatible with ungrouped queries (measure filters require aggregation)`);
|
|
7859
8114
|
}
|
|
7860
8115
|
}
|
|
7861
|
-
for (let
|
|
7862
|
-
let
|
|
7863
|
-
if (
|
|
7864
|
-
for (let [i,
|
|
7865
|
-
let
|
|
7866
|
-
|
|
8116
|
+
for (let e of o) {
|
|
8117
|
+
let n = t.get(e);
|
|
8118
|
+
if (n && n.joins) {
|
|
8119
|
+
for (let [i, a] of Object.entries(n.joins)) if (a.relationship === "hasMany") {
|
|
8120
|
+
let n = U(a.targetCube, t);
|
|
8121
|
+
n && o.has(n.name) && r.push(`Ungrouped queries are incompatible with hasMany relationships (${e} → ${i} is hasMany)`);
|
|
7867
8122
|
}
|
|
7868
8123
|
}
|
|
7869
8124
|
}
|
|
7870
8125
|
}
|
|
7871
8126
|
return {
|
|
7872
|
-
isValid:
|
|
7873
|
-
errors:
|
|
8127
|
+
isValid: r.length === 0,
|
|
8128
|
+
errors: r
|
|
7874
8129
|
};
|
|
7875
8130
|
}
|
|
7876
|
-
function
|
|
7877
|
-
if ("and" in
|
|
7878
|
-
let
|
|
7879
|
-
for (let
|
|
8131
|
+
function an(t, n, r, i) {
|
|
8132
|
+
if ("and" in t || "or" in t) {
|
|
8133
|
+
let e = t.and || t.or || [];
|
|
8134
|
+
for (let t of e) an(t, n, r, i);
|
|
7880
8135
|
return;
|
|
7881
8136
|
}
|
|
7882
|
-
if (!("member" in
|
|
7883
|
-
|
|
8137
|
+
if (!("member" in t)) {
|
|
8138
|
+
r.push(e("server.validation.query.filterMustHaveMember"));
|
|
7884
8139
|
return;
|
|
7885
8140
|
}
|
|
7886
|
-
let [
|
|
7887
|
-
if (!
|
|
7888
|
-
|
|
8141
|
+
let [a, o] = t.member.split(".");
|
|
8142
|
+
if (!a || !o) {
|
|
8143
|
+
r.push(e("server.validation.query.invalidFilterMemberFormat", { member: t.member }));
|
|
7889
8144
|
return;
|
|
7890
8145
|
}
|
|
7891
|
-
|
|
7892
|
-
let
|
|
7893
|
-
if (!
|
|
7894
|
-
|
|
8146
|
+
i.add(a);
|
|
8147
|
+
let s = n.get(a);
|
|
8148
|
+
if (!s) {
|
|
8149
|
+
r.push(e("server.validation.query.cubeNotFoundForFilter", {
|
|
8150
|
+
cubeName: a,
|
|
8151
|
+
member: t.member
|
|
8152
|
+
}));
|
|
7895
8153
|
return;
|
|
7896
8154
|
}
|
|
7897
|
-
if (!
|
|
7898
|
-
let
|
|
7899
|
-
|
|
8155
|
+
if (!s.dimensions[o] && !s.measures[o]) {
|
|
8156
|
+
let t = o === a ? `. Did you mean one of: ${[...Object.keys(s.dimensions), ...Object.keys(s.measures)].slice(0, 5).map((e) => `'${a}.${e}'`).join(", ")}?` : "";
|
|
8157
|
+
r.push(e("server.validation.query.filterFieldNotFound", {
|
|
8158
|
+
fieldName: o,
|
|
8159
|
+
cubeName: a,
|
|
8160
|
+
hint: t
|
|
8161
|
+
}));
|
|
7900
8162
|
}
|
|
7901
8163
|
}
|
|
7902
|
-
function
|
|
8164
|
+
function on(e) {
|
|
7903
8165
|
if (typeof e == "string") {
|
|
7904
8166
|
let [t] = e.split(".");
|
|
7905
8167
|
return t || null;
|
|
@@ -7907,4 +8169,26 @@ function tn(e) {
|
|
|
7907
8169
|
return e.cube;
|
|
7908
8170
|
}
|
|
7909
8171
|
//#endregion
|
|
7910
|
-
|
|
8172
|
+
//#region src/adapters/locale.ts
|
|
8173
|
+
var sn = "x-dc-locale";
|
|
8174
|
+
function cn(e) {
|
|
8175
|
+
if (!e) return;
|
|
8176
|
+
let t = (Array.isArray(e) ? e[0] : e).split(",")[0]?.trim();
|
|
8177
|
+
if (t && /^[A-Za-z0-9-]{2,35}$/.test(t)) return t;
|
|
8178
|
+
}
|
|
8179
|
+
function ln(e) {
|
|
8180
|
+
return cn(e(sn));
|
|
8181
|
+
}
|
|
8182
|
+
function un(e, t) {
|
|
8183
|
+
let n = e && typeof e == "object" ? e : {}, r = typeof n.locale == "string" ? n.locale : void 0, i = t ?? r ?? "en-GB";
|
|
8184
|
+
return r === i ? n : {
|
|
8185
|
+
...n,
|
|
8186
|
+
locale: i
|
|
8187
|
+
};
|
|
8188
|
+
}
|
|
8189
|
+
function dn(e) {
|
|
8190
|
+
let t = Array.isArray(e) ? [...e] : (e ?? "").split(",").map((e) => e.trim()).filter(Boolean);
|
|
8191
|
+
return t.some((e) => e.toLowerCase() === "x-dc-locale") || t.push("X-DC-Locale"), t;
|
|
8192
|
+
}
|
|
8193
|
+
//#endregion
|
|
8194
|
+
export { tn as i, ln as n, un as r, dn as t };
|