@quillsql/react 2.11.28 → 2.11.30
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/cjs/Chart.d.ts +4 -0
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +20 -7
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +81 -48
- package/dist/cjs/Dashboard.js +2 -2
- package/dist/cjs/ReportBuilder.d.ts +22 -1
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +562 -527
- package/dist/cjs/components/Chart/LineChart.d.ts +2 -1
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +19 -11
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +1 -2
- package/dist/cjs/hooks/useDashboard.d.ts +1 -1
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +4 -4
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts +28 -0
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -0
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +58 -0
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +3 -1
- package/dist/cjs/utils/astProcessing.d.ts +23 -0
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +241 -1
- package/dist/cjs/utils/tableProcessing.d.ts +1 -0
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +16 -1
- package/dist/esm/Chart.d.ts +4 -0
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +20 -7
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +81 -48
- package/dist/esm/Dashboard.js +2 -2
- package/dist/esm/ReportBuilder.d.ts +22 -1
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +563 -528
- package/dist/esm/components/Chart/LineChart.d.ts +2 -1
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +19 -11
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +1 -2
- package/dist/esm/hooks/useDashboard.d.ts +1 -1
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +4 -4
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts +28 -0
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -0
- package/dist/esm/internals/ReportBuilder/PivotForm.js +55 -0
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +3 -1
- package/dist/esm/utils/astProcessing.d.ts +23 -0
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +231 -0
- package/dist/esm/utils/tableProcessing.d.ts +1 -0
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +14 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type ColorMapType } from '../../Chart';
|
|
3
|
-
export default function LineChart({ colors, colorMap, yAxisFields, data, containerStyle, className, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, hideHorizontalCartesianGrid, hideVerticalCartesianGrid, hideSubsequentXAxisTicks, cartesianGridLineStyle, comparisonLineStyle, }: {
|
|
3
|
+
export default function LineChart({ colors, colorMap, yAxisFields, data, containerStyle, className, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, hideHorizontalCartesianGrid, hideVerticalCartesianGrid, hideSubsequentXAxisTicks, cartesianGridLineStyle, comparisonLineStyle, cartesianGridLineColor, }: {
|
|
4
4
|
colors?: string[];
|
|
5
5
|
colorMap?: ColorMapType;
|
|
6
6
|
yAxisFields: any[];
|
|
@@ -21,5 +21,6 @@ export default function LineChart({ colors, colorMap, yAxisFields, data, contain
|
|
|
21
21
|
hideSubsequentXAxisTicks: boolean;
|
|
22
22
|
cartesianGridLineStyle: 'solid' | 'dashed';
|
|
23
23
|
comparisonLineStyle: 'solid' | 'dashed';
|
|
24
|
+
cartesianGridLineColor?: string;
|
|
24
25
|
}): import("react/jsx-runtime").JSX.Element;
|
|
25
26
|
//# sourceMappingURL=LineChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,QAAa,EACb,WAAW,EACX,IAAI,EACJ,cAAc,EACd,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,2BAAmC,EACnC,yBAAgC,EAChC,wBAAgC,EAChC,sBAAgC,EAChC,mBAA6B,
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,QAAa,EACb,WAAW,EACX,IAAI,EACJ,cAAc,EACd,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,2BAAmC,EACnC,yBAAgC,EAChC,wBAAgC,EAChC,sBAAgC,EAChC,mBAA6B,EAC7B,sBAAsB,GACvB,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2BAA2B,EAAE,OAAO,CAAC;IACrC,yBAAyB,EAAE,OAAO,CAAC;IACnC,wBAAwB,EAAE,OAAO,CAAC;IAClC,sBAAsB,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC3C,mBAAmB,EAAE,OAAO,GAAG,QAAQ,CAAC;IACxC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,2CA8PA"}
|
|
@@ -13,7 +13,7 @@ const ChartTooltip_1 = __importDefault(require("../../components/Chart/ChartTool
|
|
|
13
13
|
const getDomain_1 = __importDefault(require("../../utils/getDomain"));
|
|
14
14
|
const react_1 = require("react");
|
|
15
15
|
const crypto_1 = require("../../utils/crypto");
|
|
16
|
-
function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, className, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', comparisonLineStyle = 'solid', }) {
|
|
16
|
+
function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, className, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', comparisonLineStyle = 'solid', cartesianGridLineColor, }) {
|
|
17
17
|
const [formattedData, setFormattedData] = (0, react_1.useState)([]);
|
|
18
18
|
(0, react_1.useEffect)(() => {
|
|
19
19
|
if (!data || data.length === 0) {
|
|
@@ -51,28 +51,36 @@ function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, c
|
|
|
51
51
|
}
|
|
52
52
|
// Allows the users to override the color scheme on a per-chart basis.
|
|
53
53
|
const getCustomColor = (index, field, gradient) => {
|
|
54
|
-
let key = index === 0 ? '
|
|
54
|
+
let key = index === 0 ? 'comparison' : 'primary';
|
|
55
55
|
field = field.replace('comparison_', '');
|
|
56
56
|
if (colorMap && colorMap[field]) {
|
|
57
|
-
if (index ===
|
|
57
|
+
if (index === 1 && gradient === 'start')
|
|
58
58
|
key = 'primaryGradientStart';
|
|
59
|
-
if (index ===
|
|
59
|
+
if (index === 1 && gradient === 'stop')
|
|
60
60
|
key = 'primaryGradientStop';
|
|
61
|
-
if (index ===
|
|
61
|
+
if (index === 0 && gradient === 'start')
|
|
62
62
|
key = 'comparisonGradientStart';
|
|
63
|
-
if (index ===
|
|
63
|
+
if (index === 0 && gradient === 'stop')
|
|
64
64
|
key = 'comparisonGradientStop';
|
|
65
65
|
return colorMap[field][key];
|
|
66
66
|
}
|
|
67
67
|
return undefined; // use the default colors from the theme
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
const numComparisons = yAxisFields.reduce((sum, x) => {
|
|
70
|
+
if (x.field?.startsWith('comparison_'))
|
|
71
|
+
return sum + 1;
|
|
72
|
+
return sum;
|
|
73
|
+
}, 0);
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { ...containerStyle }, className: className, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: '100%', children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: formattedData, children: [!hideCartesianGrid && ((0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { horizontal: !hideHorizontalCartesianGrid, vertical: !hideVerticalCartesianGrid, stroke: cartesianGridLineColor ?? '#e5e7eb', strokeDasharray: cartesianGridLineStyle === 'dashed' ? '5 5' : undefined })), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: xAxisField, hide: hideXAxis, tick: { transform: 'translate(0, 6)' }, style: {
|
|
70
75
|
fontSize: '12px',
|
|
71
76
|
fontFamily: theme?.chartLabelFontFamily ||
|
|
72
77
|
theme?.fontFamily ||
|
|
73
78
|
'Inter; Helvetica',
|
|
74
79
|
color: theme?.chartLabelColor || '#666666',
|
|
75
|
-
},
|
|
80
|
+
}, tickLine: false, axisLine: false, minTickGap: 5, tickFormatter: (tick, i) => {
|
|
81
|
+
// Don't display subsequent ticks when hideSubXAxisTicks is true
|
|
82
|
+
if (hideSubsequentXAxisTicks && i !== 0)
|
|
83
|
+
return '';
|
|
76
84
|
return (0, axisFormatter_1.axisFormatter)({
|
|
77
85
|
value: tick,
|
|
78
86
|
field: xAxisField,
|
|
@@ -117,7 +125,7 @@ function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, c
|
|
|
117
125
|
// hash the color stops so they're stable, valid html ids
|
|
118
126
|
const gradientStart = getCustomColor(index, elem.field, 'start') ??
|
|
119
127
|
getCustomColor(index, elem.field) ??
|
|
120
|
-
(0, color_1.selectColor)(elem, colors, index);
|
|
128
|
+
(0, color_1.selectColor)(elem, colors, index - numComparisons);
|
|
121
129
|
const gradientStop = getCustomColor(index, elem.field, 'stop') ?? '#00000000';
|
|
122
130
|
const uniqueId = `gradient_${(0, crypto_1.hashCode)(gradientStart)}_${(0, crypto_1.hashCode)(gradientStop)}`;
|
|
123
131
|
return ((0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsxs)("linearGradient", { id: uniqueId, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "5%", stopColor: gradientStart, stopOpacity: 0.4 }), (0, jsx_runtime_1.jsx)("stop", { offset: "95%", stopColor: gradientStop, stopOpacity: 0 })] }) }, `defs_${uniqueId}_${index}`));
|
|
@@ -125,11 +133,11 @@ function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, c
|
|
|
125
133
|
yAxisFields.map((elem, index) => {
|
|
126
134
|
const gradientStart = (0, crypto_1.hashCode)(getCustomColor(index, elem.field, 'start') ??
|
|
127
135
|
getCustomColor(index, elem.field) ??
|
|
128
|
-
(0, color_1.selectColor)(elem, colors, index));
|
|
136
|
+
(0, color_1.selectColor)(elem, colors, index - numComparisons));
|
|
129
137
|
const gradientStop = (0, crypto_1.hashCode)(getCustomColor(index, elem.field, 'stop') ?? '#00000000');
|
|
130
138
|
const uniqueId = `gradient_${gradientStart}_${gradientStop}`;
|
|
131
139
|
return ((0, jsx_runtime_1.jsx)(recharts_1.Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: getCustomColor(index, elem.field) ??
|
|
132
|
-
(0, color_1.selectColor)(elem, colors, index), fill: `url(#${uniqueId})`, strokeWidth: 2, dot: false, strokeDasharray: comparison && comparisonLineStyle === 'dashed' && index > 0
|
|
140
|
+
(0, color_1.selectColor)(elem, colors, index - numComparisons), fill: `url(#${uniqueId})`, strokeWidth: 2, dot: false, strokeDasharray: comparison && comparisonLineStyle === 'dashed' && index > 0
|
|
133
141
|
? '5 5'
|
|
134
142
|
: undefined, isAnimationActive: isAnimationActive }, elem.field));
|
|
135
143
|
})] }) }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components/UiComponents.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components/UiComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,WAAW,EAEX,SAAS,EAMV,MAAM,OAAO,CAAC;AAOf,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAChE;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SA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K,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,GAAG,CAAC,OAAO,CA4Fd;AAED,eAAO,MAAM,oBAAoB,iBAE9B,0BAA0B,4CAyB5B,CAAC;AAEF,eAAO,MAAM,cAAc,+CAwD1B,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,CAAC;IAC/B,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,kCAI7B,mBAAmB,4CASrB,CAAC;AAEF,eAAO,MAAM,4BAA4B,+CAAgB,CAAC;AAE1D,eAAO,MAAM,kCAAkC;cAGnC,SAAS;6CAapB,CAAC;AAEF,eAAO,MAAM,qCAAqC;cAGtC,SAAS;6CAapB,CAAC;AAEF,eAAO,MAAM,sBAAsB;cAGvB,SAAS;6CAapB,CAAC;AAEF,eAAO,MAAM,yBAAyB;cAG1B,SAAS;6CAapB,CAAC;AAEF,eAAO,MAAM,6BAA6B;cAG9B,SAAS;6CAgBpB,CAAC;AAEF,eAAO,MAAM,8BAA8B;cAG/B,SAAS;6CAepB,CAAC;AAEF,eAAO,MAAM,0BAA0B;kBAGvB,MAAM;6CAuBrB,CAAC;AAEF,eAAO,MAAM,2BAA2B,+CAGvC,CAAC;AAEF,eAAO,MAAM,qBAAqB,+CA+DjC,CAAC"}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.QuillLoadingComponent = exports.QuillColumnSearchEmptyState = exports.QuillErrorMessageComponent = exports.QuillChartBuilderFormContainer = exports.QuillFilterContainerComponent = exports.QuillPivotColumnContainer = exports.QuillPivotRowContainer = exports.QuillChartBuilderInputColumnContainer = exports.QuillChartBuilderInputRowContainer = exports.QuillEmptyDashboardComponent = exports.QuillTableComponent = exports.LoadingSpinner = exports.MemoizedDeleteButton = exports.MemoizedModal = exports.MemoizedPopover = exports.MemoizedText = exports.QuillTabs = exports.DEFAULT_TAB_OPTIONS = exports.MemoizedCheckbox = exports.MemoizedLabel = exports.MemoizedSubHeader = exports.MemoizedHeader = exports.MemoizedSecondaryButton = exports.MemoizedButton = exports.QuillTextInput = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
// @ts-nocheck
|
|
9
8
|
const react_1 = require("react");
|
|
10
9
|
const assets_1 = require("../assets");
|
|
11
10
|
const Context_1 = require("../Context");
|
|
@@ -266,6 +265,7 @@ exports.MemoizedPopover = MemoizedPopover;
|
|
|
266
265
|
function MemoizedModal({ isOpen, setIsOpen, title, children, width, height, }) {
|
|
267
266
|
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
268
267
|
if (!isOpen) {
|
|
268
|
+
// @ts-ignore
|
|
269
269
|
return null;
|
|
270
270
|
}
|
|
271
271
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
@@ -439,7 +439,6 @@ exports.QuillColumnSearchEmptyState = QuillColumnSearchEmptyState;
|
|
|
439
439
|
const QuillLoadingComponent = () => {
|
|
440
440
|
const theme = (0, hooks_1.useTheme)();
|
|
441
441
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
442
|
-
background: theme.backgroundColor,
|
|
443
442
|
width: 250,
|
|
444
443
|
minWidth: 250,
|
|
445
444
|
height: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,kBAAmB,MAAM
|
|
1
|
+
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,kBAAmB,MAAM;;;;qCASF,MAAM;CAiDrD,CAAC"}
|
|
@@ -12,10 +12,10 @@ const useDashboard = (dashboardName) => {
|
|
|
12
12
|
const [error, setError] = (0, react_1.useState)(null);
|
|
13
13
|
const [data, setData] = (0, react_1.useState)(null);
|
|
14
14
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
15
|
-
const handleReload = () => {
|
|
16
|
-
getDashboards();
|
|
15
|
+
const handleReload = (overrideDashboardName) => {
|
|
16
|
+
getDashboards(overrideDashboardName ?? dashboardName);
|
|
17
17
|
};
|
|
18
|
-
async function getDashboards() {
|
|
18
|
+
async function getDashboards(dashboardName) {
|
|
19
19
|
if (dashboardName === null || dashboardName === undefined)
|
|
20
20
|
return;
|
|
21
21
|
setIsLoading(true);
|
|
@@ -47,7 +47,7 @@ const useDashboard = (dashboardName) => {
|
|
|
47
47
|
setIsLoading(false);
|
|
48
48
|
}
|
|
49
49
|
(0, react_1.useEffect)(() => {
|
|
50
|
-
getDashboards();
|
|
50
|
+
getDashboards(dashboardName);
|
|
51
51
|
}, [dashboardName, client]);
|
|
52
52
|
return { data, isLoading, error, reload: handleReload };
|
|
53
53
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Column } from '../../models/Columns';
|
|
3
|
+
interface PivotFormProps {
|
|
4
|
+
pivotRowField: any;
|
|
5
|
+
setPivotRowField: any;
|
|
6
|
+
pivotColumnField: any;
|
|
7
|
+
setPivotColumnField: any;
|
|
8
|
+
pivotValueField: any;
|
|
9
|
+
setPivotValueField: any;
|
|
10
|
+
pivotAggregation: any;
|
|
11
|
+
setPivotAggregation: any;
|
|
12
|
+
columns: Column[];
|
|
13
|
+
uniqueValues?: any;
|
|
14
|
+
onDelete: any;
|
|
15
|
+
SecondaryButtonComponent: (props: {
|
|
16
|
+
onClick: () => void;
|
|
17
|
+
label: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
icon?: ReactNode;
|
|
20
|
+
}) => JSX.Element;
|
|
21
|
+
SelectComponent: any;
|
|
22
|
+
PivotColumnContainer?: (props: {
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}) => JSX.Element;
|
|
25
|
+
}
|
|
26
|
+
export default function PivotForm({ pivotRowField, setPivotRowField, pivotColumnField, setPivotColumnField, pivotValueField, setPivotValueField, pivotAggregation, setPivotAggregation, columns, uniqueValues, onDelete, SecondaryButtonComponent, SelectComponent, PivotColumnContainer, }: PivotFormProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=PivotForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PivotForm.d.ts","sourceRoot":"","sources":["../../../../src/internals/ReportBuilder/PivotForm.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAQ9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,UAAU,cAAc;IACtB,aAAa,EAAE,GAAG,CAAC;IACnB,gBAAgB,EAAE,GAAG,CAAC;IACtB,gBAAgB,EAAE,GAAG,CAAC;IACtB,mBAAmB,EAAE,GAAG,CAAC;IACzB,eAAe,EAAE,GAAG,CAAC;IACrB,kBAAkB,EAAE,GAAG,CAAC;IACxB,gBAAgB,EAAE,GAAG,CAAC;IACtB,mBAAmB,EAAE,GAAG,CAAC;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,QAAQ,EAAE,GAAG,CAAC;IACd,wBAAwB,EAAE,CAAC,KAAK,EAAE;QAChC,OAAO,EAAE,MAAM,IAAI,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE,SAAS,CAAC;KAClB,KAAK,GAAG,CAAC,OAAO,CAAC;IAClB,eAAe,EAAE,GAAG,CAAC;IACrB,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,CAAC;CACxE;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,wBAAwB,EACxB,eAAe,EACf,oBAAgD,GACjD,EAAE,cAAc,2CAmGhB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const UiComponents_1 = require("../../components/UiComponents");
|
|
6
|
+
const textProcessing_1 = require("../../utils/textProcessing");
|
|
7
|
+
const ChartBuilder_1 = require("../../ChartBuilder");
|
|
8
|
+
const pivotProcessing_1 = require("../../utils/pivotProcessing");
|
|
9
|
+
function PivotForm({ pivotRowField, setPivotRowField, pivotColumnField, setPivotColumnField, pivotValueField, setPivotValueField, pivotAggregation, setPivotAggregation, columns, uniqueValues, onDelete, SecondaryButtonComponent, SelectComponent, PivotColumnContainer = UiComponents_1.QuillPivotColumnContainer, }) {
|
|
10
|
+
const [allowedColumnFields, setAllowedColumnFields] = (0, react_1.useState)([]);
|
|
11
|
+
const [allowedRowFields, setAllowedRowFields] = (0, react_1.useState)([]);
|
|
12
|
+
const [allowedValueFields, setAllowedValueFields] = (0, react_1.useState)([]);
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
const possibleColumns = (0, pivotProcessing_1.getPossiblePivotFieldOptions)(columns, uniqueValues);
|
|
15
|
+
setAllowedRowFields(possibleColumns.rowFields);
|
|
16
|
+
setAllowedColumnFields(possibleColumns.columnFields);
|
|
17
|
+
setAllowedValueFields(possibleColumns.valueFields);
|
|
18
|
+
}, [columns, uniqueValues]);
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)(PivotColumnContainer, { children: [(0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", label: "Row field", value: pivotRowField, onChange: (e) => {
|
|
20
|
+
setPivotRowField(e.target.value === '' ? undefined : e.target.value);
|
|
21
|
+
}, options: allowedRowFields.map((field) => {
|
|
22
|
+
return {
|
|
23
|
+
label: (0, textProcessing_1.snakeCaseToTitleCase)(field),
|
|
24
|
+
value: field,
|
|
25
|
+
};
|
|
26
|
+
}), width: 200 }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", label: "Column field", value: pivotColumnField, onChange: (e) => {
|
|
27
|
+
setPivotColumnField(e.target.value === '' ? undefined : e.target.value);
|
|
28
|
+
}, options: allowedColumnFields.map((field) => {
|
|
29
|
+
return {
|
|
30
|
+
label: (0, textProcessing_1.snakeCaseToTitleCase)(field),
|
|
31
|
+
value: field,
|
|
32
|
+
};
|
|
33
|
+
}), width: 200 }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", label: "Value field", value: pivotValueField, onChange: (e) => {
|
|
34
|
+
setPivotValueField(e.target.value === '' ? undefined : e.target.value);
|
|
35
|
+
}, options: allowedValueFields.map((field) => {
|
|
36
|
+
return {
|
|
37
|
+
label: (0, textProcessing_1.snakeCaseToTitleCase)(field),
|
|
38
|
+
value: field,
|
|
39
|
+
};
|
|
40
|
+
}), width: 200 }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", label: "Aggregation type", value: pivotAggregation, onChange: (e) => {
|
|
41
|
+
if (e.target.value !== 'count' &&
|
|
42
|
+
pivotValueField &&
|
|
43
|
+
!ChartBuilder_1.numberFormatOptions.includes(columns.find((col) => col.field === pivotValueField)
|
|
44
|
+
.format)) {
|
|
45
|
+
setPivotValueField(null);
|
|
46
|
+
}
|
|
47
|
+
setPivotAggregation(e.target.value === '' ? undefined : e.target.value);
|
|
48
|
+
}, options: [
|
|
49
|
+
...['sum', 'average', 'count', 'max', 'min'].map((option) => {
|
|
50
|
+
return { label: option, value: option };
|
|
51
|
+
}),
|
|
52
|
+
], width: 200 }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'flex-start',
|
|
55
|
+
flexDirection: 'column',
|
|
56
|
+
}, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: onDelete, label: "Delete Pivot" }) })] }));
|
|
57
|
+
}
|
|
58
|
+
exports.default = PivotForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotModal.d.ts","sourceRoot":"","sources":["../../../../src/internals/ReportBuilder/PivotModal.tsx"],"names":[],"mappings":"AAAA,OAAc,EAOZ,SAAS,EACV,MAAM,OAAO,CAAC;AAoBf,OAAO,EACL,oBAAoB,EAKrB,MAAM,+BAA+B,CAAC;AAgBvC,OAAO,EAAE,MAAM,EAAkB,MAAM,sBAAsB,CAAC;AAE9D,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAkBD,MAAM,W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E,KAAK,EACZ,IAAI,EAAE,GAAG,EACT,SAAS,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,EACjD,YAAY,EAAE,OAAO,EACrB,QAAQ,SAAK,EACb,SAAS,GAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,SAAqB;;;;;;EA0c9D"}
|
|
@@ -211,6 +211,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
211
211
|
setPopUpTitle('Add pivot');
|
|
212
212
|
};
|
|
213
213
|
const onEditPivot = (pivot, index) => {
|
|
214
|
+
setIsLoading(false);
|
|
214
215
|
setPivotRowField(pivot.rowField);
|
|
215
216
|
setPivotColumnField(pivot.columnField);
|
|
216
217
|
setPivotValueField(pivot.valueField);
|
|
@@ -295,6 +296,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
295
296
|
allowedValueFields,
|
|
296
297
|
]);
|
|
297
298
|
const pivotFieldChange = async (field, value) => {
|
|
299
|
+
setErrors([]);
|
|
298
300
|
setIsLoading(true);
|
|
299
301
|
const pivot = {
|
|
300
302
|
rowField: pivotRowField,
|
|
@@ -388,7 +390,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
388
390
|
}, children: [isLoading && (0, jsx_runtime_1.jsx)(LoadingComponent, {}), samplePivotTable && !isLoading && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
389
391
|
width: pivotCardWidth,
|
|
390
392
|
minHeight: 160,
|
|
391
|
-
}, children: (0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: samplePivotTable, theme: theme, index: 0, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, clickable: false, minHeight:
|
|
393
|
+
}, children: (0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: samplePivotTable, theme: theme, index: 0, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, clickable: false, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent, CardComponent: CardComponent, onSelectPivot: () => { }, onClose: () => {
|
|
392
394
|
setPivotAggregation(null);
|
|
393
395
|
setPivotRowField(null);
|
|
394
396
|
setPivotValueField(null);
|
|
@@ -1,3 +1,26 @@
|
|
|
1
1
|
import { Column } from '../models/Columns';
|
|
2
|
+
export declare function getSelectFromAST(ast: any): any;
|
|
2
3
|
export declare function processStarColumn(ast: any, columns: Column[]): any;
|
|
4
|
+
export declare function recursiveSearchByKey(node: any, searchKey: string): any;
|
|
5
|
+
export declare function recursiveSearchByKeys(node: any, searchKeys: string[]): any;
|
|
6
|
+
export declare function createTableNameToTableAliasMap(ast: any): {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function getColumnsByTableName(ast: any, tableName: string): {
|
|
10
|
+
columns: {
|
|
11
|
+
field: string;
|
|
12
|
+
}[];
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function processApostrophe(node: any, searchKeys: string[]): any;
|
|
16
|
+
export declare function recursiveSearchByKeysFindAllOccurances(node: any, searchKeys: string[], results: any[]): any;
|
|
17
|
+
export declare function getColumnAndTableInfo(tableAliasMap: {
|
|
18
|
+
[alias: string]: string;
|
|
19
|
+
}, column: any, schemaInfo: any): {
|
|
20
|
+
tableName: string;
|
|
21
|
+
columnName: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
export declare function getColumnsByTableFromASTAndSchema(ast: any, tables: any, tableAliasMap: any): {
|
|
24
|
+
[table: string]: string[];
|
|
25
|
+
};
|
|
3
26
|
//# sourceMappingURL=astProcessing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/astProcess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AS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAgCvD;AAED,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,GAAG,EACX,aAAa,EAAE,GAAG,GACjB;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE,CAoG/B"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processStarColumn = void 0;
|
|
3
|
+
exports.getColumnsByTableFromASTAndSchema = exports.getColumnAndTableInfo = exports.recursiveSearchByKeysFindAllOccurances = exports.processApostrophe = exports.getColumnsByTableName = exports.createTableNameToTableAliasMap = exports.recursiveSearchByKeys = exports.recursiveSearchByKey = exports.processStarColumn = exports.getSelectFromAST = void 0;
|
|
4
|
+
function getSelectFromAST(ast) {
|
|
5
|
+
if (Array.isArray(ast)) {
|
|
6
|
+
return ast[0];
|
|
7
|
+
}
|
|
8
|
+
else if (ast.select) {
|
|
9
|
+
return ast.select;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return ast;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.getSelectFromAST = getSelectFromAST;
|
|
4
16
|
function processStarColumn(ast, columns) {
|
|
5
17
|
if (ast.columns === '*') {
|
|
6
18
|
ast.columns = columns.map((column) => {
|
|
@@ -18,3 +30,231 @@ function processStarColumn(ast, columns) {
|
|
|
18
30
|
return ast;
|
|
19
31
|
}
|
|
20
32
|
exports.processStarColumn = processStarColumn;
|
|
33
|
+
// a useful function to search for a specific keywork and return the value
|
|
34
|
+
function recursiveSearchByKey(node, searchKey) {
|
|
35
|
+
let result = undefined;
|
|
36
|
+
if (!node || typeof node !== 'object') {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
if (node[searchKey]) {
|
|
40
|
+
return node[searchKey];
|
|
41
|
+
}
|
|
42
|
+
const keys = Object.keys(node);
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
result = recursiveSearchByKey(node[key], searchKey);
|
|
45
|
+
if (result) {
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
exports.recursiveSearchByKey = recursiveSearchByKey;
|
|
52
|
+
// If the object has all the requested keys, return the object
|
|
53
|
+
function recursiveSearchByKeys(node, searchKeys) {
|
|
54
|
+
let result = undefined;
|
|
55
|
+
if (!node || typeof node !== 'object') {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const nodeKeys = Object.keys(node);
|
|
59
|
+
if (searchKeys.every((key) => nodeKeys.includes(key))) {
|
|
60
|
+
return node;
|
|
61
|
+
}
|
|
62
|
+
for (const key of nodeKeys) {
|
|
63
|
+
result = recursiveSearchByKeys(node[key], searchKeys);
|
|
64
|
+
if (result) {
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
exports.recursiveSearchByKeys = recursiveSearchByKeys;
|
|
71
|
+
function createTableNameToTableAliasMap(ast) {
|
|
72
|
+
const tableNameToTableAliasMap = {};
|
|
73
|
+
if (ast.from) {
|
|
74
|
+
for (const table of ast.from) {
|
|
75
|
+
const tableObject = recursiveSearchByKeys(table, ['table', 'as']);
|
|
76
|
+
if (tableObject.as) {
|
|
77
|
+
tableNameToTableAliasMap[tableObject.as] = tableObject.table;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
tableNameToTableAliasMap[tableObject.table] = tableObject.table;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (ast.with) {
|
|
85
|
+
for (const withStmt of ast.with) {
|
|
86
|
+
if (withStmt.stmt.ast.from) {
|
|
87
|
+
for (const table of withStmt.stmt.ast.from) {
|
|
88
|
+
const tableObject = recursiveSearchByKeys(table, ['table', 'as']);
|
|
89
|
+
if (tableObject.as) {
|
|
90
|
+
tableNameToTableAliasMap[tableObject.as] = tableObject.table;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
tableNameToTableAliasMap[tableObject.table] = tableObject.table;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return tableNameToTableAliasMap;
|
|
100
|
+
}
|
|
101
|
+
exports.createTableNameToTableAliasMap = createTableNameToTableAliasMap;
|
|
102
|
+
function getColumnsByTableName(ast, tableName) {
|
|
103
|
+
const tableNameToTableAliasMap = createTableNameToTableAliasMap(ast);
|
|
104
|
+
const columns = [];
|
|
105
|
+
ast.columns.forEach((col) => {
|
|
106
|
+
const columnInfo = recursiveSearchByKeys(col, ['table', 'column']);
|
|
107
|
+
if (columnInfo.table === tableName ||
|
|
108
|
+
columnInfo.table === tableNameToTableAliasMap[tableName]) {
|
|
109
|
+
columns.push({ field: columnInfo.column });
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return { columns, name: tableName };
|
|
113
|
+
}
|
|
114
|
+
exports.getColumnsByTableName = getColumnsByTableName;
|
|
115
|
+
function processApostrophe(node, searchKeys) {
|
|
116
|
+
if (!node || typeof node !== 'object') {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const nodeKeys = Object.keys(node);
|
|
120
|
+
if (searchKeys.every((key) => nodeKeys.includes(key))) {
|
|
121
|
+
if (node.type === 'single_quote_string') {
|
|
122
|
+
node.value = node.value.replace("''", "'").replace("\\'", "'");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const key of nodeKeys) {
|
|
126
|
+
processApostrophe(node[key], searchKeys);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
exports.processApostrophe = processApostrophe;
|
|
131
|
+
function recursiveSearchByKeysFindAllOccurances(node, searchKeys, results) {
|
|
132
|
+
if (!node || typeof node !== 'object') {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const nodeKeys = Object.keys(node);
|
|
136
|
+
if (searchKeys.every((key) => nodeKeys.includes(key))) {
|
|
137
|
+
return results.push(node);
|
|
138
|
+
}
|
|
139
|
+
for (const key of nodeKeys) {
|
|
140
|
+
recursiveSearchByKeysFindAllOccurances(node[key], searchKeys, results);
|
|
141
|
+
}
|
|
142
|
+
return results;
|
|
143
|
+
}
|
|
144
|
+
exports.recursiveSearchByKeysFindAllOccurances = recursiveSearchByKeysFindAllOccurances;
|
|
145
|
+
function getColumnAndTableInfo(tableAliasMap, column, schemaInfo) {
|
|
146
|
+
let columnsInfo = recursiveSearchByKeys(column, ['table', 'column']);
|
|
147
|
+
if (!columnsInfo) {
|
|
148
|
+
const quoteStringColumn = recursiveSearchByKeys(column, ['type', 'value']);
|
|
149
|
+
columnsInfo = { table: null, column: quoteStringColumn.value };
|
|
150
|
+
}
|
|
151
|
+
let columnName = columnsInfo.column;
|
|
152
|
+
if (typeof columnsInfo.column !== 'string') {
|
|
153
|
+
columnName = columnsInfo.column.expr.value;
|
|
154
|
+
}
|
|
155
|
+
let tableName = '';
|
|
156
|
+
if (columnsInfo.table) {
|
|
157
|
+
tableName = tableAliasMap[columnsInfo.table];
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// If there is no column name search through the schemaInfo to find an accurate table name
|
|
161
|
+
const tableNames = Object.values(tableAliasMap);
|
|
162
|
+
for (const table of tableNames) {
|
|
163
|
+
const tableInfo = schemaInfo.find((tableInfo) => tableInfo.name === table);
|
|
164
|
+
const columnNames = tableInfo.columns.map((column) => column.name);
|
|
165
|
+
if (columnNames.includes(columnName)) {
|
|
166
|
+
tableName = table;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// const tableName = columnsInfo.table
|
|
172
|
+
// ? tableAliasMap[columnsInfo.table]
|
|
173
|
+
// : //@ts-ignore
|
|
174
|
+
// tableAliasMap[Object.keys(tableAliasMap)[0]];
|
|
175
|
+
return { tableName, columnName };
|
|
176
|
+
}
|
|
177
|
+
exports.getColumnAndTableInfo = getColumnAndTableInfo;
|
|
178
|
+
function getColumnsByTableFromASTAndSchema(ast, tables, tableAliasMap) {
|
|
179
|
+
let referencedColumns = {};
|
|
180
|
+
if (ast.columns === '*' || ast.columns[0].expr.column === '*') {
|
|
181
|
+
// Be sure to select everything from stars
|
|
182
|
+
const tableList = ast.from.map((table) => recursiveSearchByKey(table, 'table'));
|
|
183
|
+
tableList.forEach((table) => {
|
|
184
|
+
const tableInfo = tables.find((tableInfo) => tableInfo.name === table);
|
|
185
|
+
if (tableInfo) {
|
|
186
|
+
if (!referencedColumns[table]) {
|
|
187
|
+
referencedColumns[table] = [];
|
|
188
|
+
}
|
|
189
|
+
referencedColumns[table] = tableInfo.columns.map((column) => column.name || '');
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// look through all the columns
|
|
195
|
+
ast.columns.forEach((column) => {
|
|
196
|
+
const result = getColumnAndTableInfo(tableAliasMap, column, tables);
|
|
197
|
+
if (!result || !result.tableName)
|
|
198
|
+
return;
|
|
199
|
+
if (!referencedColumns[result.tableName]) {
|
|
200
|
+
referencedColumns[result.tableName] = [];
|
|
201
|
+
}
|
|
202
|
+
// @ts-ignore
|
|
203
|
+
referencedColumns[result.tableName].push(result.columnName);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// Look through every join reference
|
|
207
|
+
if (ast.from) {
|
|
208
|
+
const allColumnReferncesInFrom = recursiveSearchByKeysFindAllOccurances(ast.from, ['column', 'table'], []);
|
|
209
|
+
allColumnReferncesInFrom.forEach((column) => {
|
|
210
|
+
const result = getColumnAndTableInfo(tableAliasMap, column, tables);
|
|
211
|
+
if (!result || !result.tableName)
|
|
212
|
+
return;
|
|
213
|
+
if (!referencedColumns[result.tableName]) {
|
|
214
|
+
referencedColumns[result.tableName] = [];
|
|
215
|
+
}
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
referencedColumns[result.tableName].push(result.columnName);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
// Look through the where's
|
|
221
|
+
if (ast.where) {
|
|
222
|
+
let allColumnReferncesInWhere = recursiveSearchByKeysFindAllOccurances(ast.where, ['column', 'table'], []);
|
|
223
|
+
allColumnReferncesInWhere.forEach((column) => {
|
|
224
|
+
const result = getColumnAndTableInfo(tableAliasMap, column, tables);
|
|
225
|
+
if (!result || !result.tableName || !result.columnName)
|
|
226
|
+
return;
|
|
227
|
+
if (!referencedColumns[result.tableName]) {
|
|
228
|
+
referencedColumns[result.tableName] = [];
|
|
229
|
+
}
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
referencedColumns[result.tableName].push(result.columnName);
|
|
232
|
+
});
|
|
233
|
+
// NEED TO SEARCH FOR ALL DOUBLE QUOTE STRINGS AS WELL
|
|
234
|
+
allColumnReferncesInWhere = recursiveSearchByKeysFindAllOccurances(ast.where, ['type', 'value'], []);
|
|
235
|
+
allColumnReferncesInWhere.forEach((column) => {
|
|
236
|
+
if (column.type === 'double_quote_string') {
|
|
237
|
+
let tableName = '';
|
|
238
|
+
const tableNames = Object.values(tableAliasMap);
|
|
239
|
+
for (const table of tableNames) {
|
|
240
|
+
const tableInfo = tables.find((tableInfo) => tableInfo.name === table);
|
|
241
|
+
const columnNames = tableInfo.columns.map((column) => column.name);
|
|
242
|
+
if (columnNames.includes(column.value)) {
|
|
243
|
+
tableName = table;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (!referencedColumns[tableName]) {
|
|
248
|
+
referencedColumns[tableName] = [];
|
|
249
|
+
}
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
referencedColumns[tableName].push(column.value);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
for (const table in referencedColumns) {
|
|
256
|
+
referencedColumns[table] = Array.from(new Set(referencedColumns[table]));
|
|
257
|
+
}
|
|
258
|
+
return referencedColumns;
|
|
259
|
+
}
|
|
260
|
+
exports.getColumnsByTableFromASTAndSchema = getColumnsByTableFromASTAndSchema;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Column } from '../models/Columns';
|
|
2
|
+
export declare const hasColumnAlias: (columns: Column[], referencedColumns: string[]) => boolean;
|
|
2
3
|
export declare const getUniqueValuesByColumns: (columns: Column[], query: string, rows: any, client: any) => Promise<{
|
|
3
4
|
[column: string]: {
|
|
4
5
|
[value: string]: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/tableProcessing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,eAAO,MAAM,wBAAwB,YAC1B,MAAM,EAAE,SACV,MAAM,QACP,GAAG,UACD,GAAG;;;;
|
|
1
|
+
{"version":3,"file":"tableProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/tableProcessing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,eAAO,MAAM,cAAc,YAChB,MAAM,EAAE,qBACE,MAAM,EAAE,KAC1B,OAUF,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,MAAM,EAAE,SACV,MAAM,QACP,GAAG,UACD,GAAG;;;;SA2DZ,CAAC"}
|