@sqlrooms/pivot 0.29.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/PivotCellContent.d.ts +10 -0
- package/dist/PivotCellContent.d.ts.map +1 -0
- package/dist/PivotCellContent.js +37 -0
- package/dist/PivotCellContent.js.map +1 -0
- package/dist/PivotCoreSlice.d.ts +73 -0
- package/dist/PivotCoreSlice.d.ts.map +1 -0
- package/dist/PivotCoreSlice.js +175 -0
- package/dist/PivotCoreSlice.js.map +1 -0
- package/dist/PivotEditor.d.ts +66 -0
- package/dist/PivotEditor.d.ts.map +1 -0
- package/dist/PivotEditor.js +341 -0
- package/dist/PivotEditor.js.map +1 -0
- package/dist/PivotResults.d.ts +15 -0
- package/dist/PivotResults.d.ts.map +1 -0
- package/dist/PivotResults.js +102 -0
- package/dist/PivotResults.js.map +1 -0
- package/dist/PivotSlice.d.ts +7 -0
- package/dist/PivotSlice.d.ts.map +1 -0
- package/dist/PivotSlice.js +353 -0
- package/dist/PivotSlice.js.map +1 -0
- package/dist/PivotView.d.ts +3 -0
- package/dist/PivotView.d.ts.map +1 -0
- package/dist/PivotView.js +39 -0
- package/dist/PivotView.js.map +1 -0
- package/dist/TableRenderer.d.ts +14 -0
- package/dist/TableRenderer.d.ts.map +1 -0
- package/dist/TableRenderer.js +100 -0
- package/dist/TableRenderer.js.map +1 -0
- package/dist/TsvRenderer.d.ts +7 -0
- package/dist/TsvRenderer.d.ts.map +1 -0
- package/dist/TsvRenderer.js +26 -0
- package/dist/TsvRenderer.js.map +1 -0
- package/dist/aggregators.d.ts +24 -0
- package/dist/aggregators.d.ts.map +1 -0
- package/dist/aggregators.js +232 -0
- package/dist/aggregators.js.map +1 -0
- package/dist/helpers.d.ts +85 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +348 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/pivotCellRegistryEntry.d.ts +4 -0
- package/dist/pivotCellRegistryEntry.d.ts.map +1 -0
- package/dist/pivotCellRegistryEntry.js +137 -0
- package/dist/pivotCellRegistryEntry.js.map +1 -0
- package/dist/pivotCellTypes.d.ts +23 -0
- package/dist/pivotCellTypes.d.ts.map +1 -0
- package/dist/pivotCellTypes.js +14 -0
- package/dist/pivotCellTypes.js.map +1 -0
- package/dist/pivotExecution.d.ts +16 -0
- package/dist/pivotExecution.d.ts.map +1 -0
- package/dist/pivotExecution.js +49 -0
- package/dist/pivotExecution.js.map +1 -0
- package/dist/sql.d.ts +17 -0
- package/dist/sql.d.ts.map +1 -0
- package/dist/sql.js +278 -0
- package/dist/sql.js.map +1 -0
- package/dist/types.d.ts +513 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +107 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { getAggregatorLabel } from './aggregators';
|
|
2
|
+
import { buildRendererTitle } from './sql';
|
|
3
|
+
/**
|
|
4
|
+
* Sorts two arbitrary values using a null-safe natural string comparison.
|
|
5
|
+
*
|
|
6
|
+
* Numeric substrings are compared numerically so labels like `item2` sort before
|
|
7
|
+
* `item10`.
|
|
8
|
+
*/
|
|
9
|
+
export function naturalSort(a, b) {
|
|
10
|
+
if (a === b) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
if (a === null || a === undefined) {
|
|
14
|
+
return -1;
|
|
15
|
+
}
|
|
16
|
+
if (b === null || b === undefined) {
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
return String(a).localeCompare(String(b), undefined, {
|
|
20
|
+
numeric: true,
|
|
21
|
+
sensitivity: 'base',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compares two pivot key tuples segment-by-segment using natural sorting.
|
|
26
|
+
*/
|
|
27
|
+
export function compareKeyArrays(a, b) {
|
|
28
|
+
const length = Math.max(a.length, b.length);
|
|
29
|
+
for (let index = 0; index < length; index += 1) {
|
|
30
|
+
const comparison = naturalSort(a[index] ?? '', b[index] ?? '');
|
|
31
|
+
if (comparison !== 0) {
|
|
32
|
+
return comparison;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Encodes a composite pivot key as a stable string suitable for `Map` keys.
|
|
39
|
+
*/
|
|
40
|
+
export function keyId(key) {
|
|
41
|
+
return key.join('\u0000');
|
|
42
|
+
}
|
|
43
|
+
function getPivotKey(columns, index) {
|
|
44
|
+
return columns.map((column) => String(column?.get(index) ?? ''));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Builds a lookup of axis totals keyed by the requested row or column aliases.
|
|
48
|
+
*
|
|
49
|
+
* The map values come directly from the Arrow `value` column to avoid converting
|
|
50
|
+
* the result set into row objects first.
|
|
51
|
+
*/
|
|
52
|
+
export function buildPivotTotalsMap(table, keyAliases) {
|
|
53
|
+
const keyColumns = keyAliases.map((alias) => table?.getChild(alias));
|
|
54
|
+
const valueColumn = table?.getChild('value');
|
|
55
|
+
const map = new Map();
|
|
56
|
+
const rowCount = table?.numRows ?? 0;
|
|
57
|
+
for (let index = 0; index < rowCount; index += 1) {
|
|
58
|
+
map.set(keyId(getPivotKey(keyColumns, index)), valueColumn?.get(index) ?? null);
|
|
59
|
+
}
|
|
60
|
+
return map;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Extracts the distinct row or column keys present in a pivot result table.
|
|
64
|
+
*
|
|
65
|
+
* Keys are returned in encounter order so callers can apply their own sorting.
|
|
66
|
+
*/
|
|
67
|
+
export function buildPivotUniqueKeys(table, keyAliases) {
|
|
68
|
+
const keyColumns = keyAliases.map((alias) => table?.getChild(alias));
|
|
69
|
+
const unique = new Map();
|
|
70
|
+
const rowCount = table?.numRows ?? 0;
|
|
71
|
+
for (let index = 0; index < rowCount; index += 1) {
|
|
72
|
+
const key = getPivotKey(keyColumns, index);
|
|
73
|
+
unique.set(keyId(key), key);
|
|
74
|
+
}
|
|
75
|
+
return Array.from(unique.values());
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Builds a lookup of pivot cell values keyed by `rowKey::colKey`.
|
|
79
|
+
*
|
|
80
|
+
* This is the main columnar access path used by `TableRenderer`.
|
|
81
|
+
*/
|
|
82
|
+
export function buildPivotCellMap(table, rowAliases, colAliases) {
|
|
83
|
+
const rowColumns = rowAliases.map((alias) => table?.getChild(alias));
|
|
84
|
+
const colColumns = colAliases.map((alias) => table?.getChild(alias));
|
|
85
|
+
const valueColumn = table?.getChild('value');
|
|
86
|
+
const map = new Map();
|
|
87
|
+
const rowCount = table?.numRows ?? 0;
|
|
88
|
+
for (let index = 0; index < rowCount; index += 1) {
|
|
89
|
+
map.set(`${keyId(getPivotKey(rowColumns, index))}::${keyId(getPivotKey(colColumns, index))}`, valueColumn?.get(index) ?? null);
|
|
90
|
+
}
|
|
91
|
+
return map;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns the unique stringified values for a single Arrow column.
|
|
95
|
+
*
|
|
96
|
+
* Used by export and chart helpers that only need one label column.
|
|
97
|
+
*/
|
|
98
|
+
export function getUniqueStringColumnValues(table, columnName) {
|
|
99
|
+
const column = table?.getChild(columnName);
|
|
100
|
+
const unique = new Set();
|
|
101
|
+
const rowCount = table?.numRows ?? 0;
|
|
102
|
+
for (let index = 0; index < rowCount; index += 1) {
|
|
103
|
+
unique.add(String(column?.get(index) ?? ''));
|
|
104
|
+
}
|
|
105
|
+
return Array.from(unique);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Calculates the rowspan or colspan for a grouped header cell.
|
|
109
|
+
*
|
|
110
|
+
* Returns `-1` when the cell should be skipped because an earlier header already
|
|
111
|
+
* spans across it.
|
|
112
|
+
*/
|
|
113
|
+
export function spanSize(arr, rowIndex, columnIndex) {
|
|
114
|
+
if (rowIndex !== 0) {
|
|
115
|
+
let noDraw = true;
|
|
116
|
+
for (let index = 0; index <= columnIndex; index += 1) {
|
|
117
|
+
if (arr[rowIndex - 1]?.[index] !== arr[rowIndex]?.[index]) {
|
|
118
|
+
noDraw = false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (noDraw) {
|
|
122
|
+
return -1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
let length = 0;
|
|
126
|
+
while (rowIndex + length < arr.length) {
|
|
127
|
+
let stop = false;
|
|
128
|
+
for (let index = 0; index <= columnIndex; index += 1) {
|
|
129
|
+
if (arr[rowIndex]?.[index] !== arr[rowIndex + length]?.[index]) {
|
|
130
|
+
stop = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (stop) {
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
length += 1;
|
|
137
|
+
}
|
|
138
|
+
return length;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Produces a simple red-tinted heatmap background for a numeric value.
|
|
142
|
+
*
|
|
143
|
+
* The value is normalized against the provided scale values.
|
|
144
|
+
*/
|
|
145
|
+
export function makeHeatColor(value, values) {
|
|
146
|
+
if (value === null || values.length === 0) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
const min = Math.min(...values);
|
|
150
|
+
const max = Math.max(...values);
|
|
151
|
+
if (!Number.isFinite(min) || !Number.isFinite(max)) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
if (min === max) {
|
|
155
|
+
return { backgroundColor: 'rgb(255,220,220)' };
|
|
156
|
+
}
|
|
157
|
+
const nonRed = 255 - Math.round((255 * (value - min)) / (max - min));
|
|
158
|
+
return { backgroundColor: `rgb(255,${nonRed},${nonRed})` };
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Converts a mixed collection of values into the finite numeric subset.
|
|
162
|
+
*/
|
|
163
|
+
export function toNumericValues(values) {
|
|
164
|
+
return values
|
|
165
|
+
.map((value) => Number(value))
|
|
166
|
+
.filter((value) => Number.isFinite(value));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Builds the Vega-Lite spec for chart-based pivot renderers.
|
|
170
|
+
*
|
|
171
|
+
* The generated spec derives display-friendly series/category labels from the
|
|
172
|
+
* pivot result's `row_label` and `col_label` columns.
|
|
173
|
+
*/
|
|
174
|
+
export function buildChartSpec(config, rendererName) {
|
|
175
|
+
const fullAggName = getAggregatorLabel(config.aggregatorName, config.vals);
|
|
176
|
+
const defaultSeries = JSON.stringify(fullAggName);
|
|
177
|
+
const defaultCategory = JSON.stringify(' ');
|
|
178
|
+
const rowTitle = config.rows.join(', ') || undefined;
|
|
179
|
+
const colTitle = config.cols.join(', ') || undefined;
|
|
180
|
+
const verticalTransform = [
|
|
181
|
+
{
|
|
182
|
+
calculate: `datum.row_label && datum.row_label !== '' ? datum.row_label : ${defaultSeries}`,
|
|
183
|
+
as: 'series_label',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
calculate: `datum.col_label && datum.col_label !== '' ? datum.col_label : ${defaultCategory}`,
|
|
187
|
+
as: 'category_label',
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
const horizontalTransform = [
|
|
191
|
+
{
|
|
192
|
+
calculate: `datum.col_label && datum.col_label !== '' ? datum.col_label : ${defaultSeries}`,
|
|
193
|
+
as: 'series_label',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
calculate: `datum.row_label && datum.row_label !== '' ? datum.row_label : ${defaultCategory}`,
|
|
197
|
+
as: 'category_label',
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
const tooltip = [
|
|
201
|
+
{ field: 'row_label', type: 'nominal', title: rowTitle ?? 'Rows' },
|
|
202
|
+
{ field: 'col_label', type: 'nominal', title: colTitle ?? 'Columns' },
|
|
203
|
+
{ field: 'value', type: 'quantitative', title: fullAggName },
|
|
204
|
+
];
|
|
205
|
+
switch (rendererName) {
|
|
206
|
+
case 'Grouped Column Chart':
|
|
207
|
+
return {
|
|
208
|
+
title: buildRendererTitle(config),
|
|
209
|
+
transform: verticalTransform,
|
|
210
|
+
mark: { type: 'bar' },
|
|
211
|
+
encoding: {
|
|
212
|
+
x: { field: 'category_label', type: 'nominal', title: colTitle },
|
|
213
|
+
xOffset: { field: 'series_label' },
|
|
214
|
+
y: { field: 'value', type: 'quantitative', title: fullAggName },
|
|
215
|
+
color: { field: 'series_label', type: 'nominal', title: rowTitle },
|
|
216
|
+
tooltip,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
case 'Stacked Column Chart':
|
|
220
|
+
return {
|
|
221
|
+
title: buildRendererTitle(config),
|
|
222
|
+
transform: verticalTransform,
|
|
223
|
+
mark: { type: 'bar' },
|
|
224
|
+
encoding: {
|
|
225
|
+
x: { field: 'category_label', type: 'nominal', title: colTitle },
|
|
226
|
+
y: {
|
|
227
|
+
field: 'value',
|
|
228
|
+
type: 'quantitative',
|
|
229
|
+
title: fullAggName,
|
|
230
|
+
stack: 'zero',
|
|
231
|
+
},
|
|
232
|
+
color: { field: 'series_label', type: 'nominal', title: rowTitle },
|
|
233
|
+
tooltip,
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
case 'Grouped Bar Chart':
|
|
237
|
+
return {
|
|
238
|
+
title: buildRendererTitle(config, true),
|
|
239
|
+
transform: horizontalTransform,
|
|
240
|
+
mark: { type: 'bar' },
|
|
241
|
+
encoding: {
|
|
242
|
+
y: { field: 'category_label', type: 'nominal', title: rowTitle },
|
|
243
|
+
yOffset: { field: 'series_label' },
|
|
244
|
+
x: { field: 'value', type: 'quantitative', title: fullAggName },
|
|
245
|
+
color: { field: 'series_label', type: 'nominal', title: colTitle },
|
|
246
|
+
tooltip,
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
case 'Stacked Bar Chart':
|
|
250
|
+
return {
|
|
251
|
+
title: buildRendererTitle(config, true),
|
|
252
|
+
transform: horizontalTransform,
|
|
253
|
+
mark: { type: 'bar' },
|
|
254
|
+
encoding: {
|
|
255
|
+
y: { field: 'category_label', type: 'nominal', title: rowTitle },
|
|
256
|
+
x: {
|
|
257
|
+
field: 'value',
|
|
258
|
+
type: 'quantitative',
|
|
259
|
+
title: fullAggName,
|
|
260
|
+
stack: 'zero',
|
|
261
|
+
},
|
|
262
|
+
color: { field: 'series_label', type: 'nominal', title: colTitle },
|
|
263
|
+
tooltip,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
case 'Line Chart':
|
|
267
|
+
return {
|
|
268
|
+
title: buildRendererTitle(config),
|
|
269
|
+
transform: verticalTransform,
|
|
270
|
+
mark: { type: 'line', point: true },
|
|
271
|
+
encoding: {
|
|
272
|
+
x: { field: 'category_label', type: 'nominal', title: colTitle },
|
|
273
|
+
y: { field: 'value', type: 'quantitative', title: fullAggName },
|
|
274
|
+
color: { field: 'series_label', type: 'nominal', title: rowTitle },
|
|
275
|
+
tooltip,
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
case 'Dot Chart':
|
|
279
|
+
return {
|
|
280
|
+
title: buildRendererTitle(config, true),
|
|
281
|
+
transform: horizontalTransform,
|
|
282
|
+
mark: { type: 'point', filled: true, size: 90 },
|
|
283
|
+
encoding: {
|
|
284
|
+
x: { field: 'value', type: 'quantitative', title: fullAggName },
|
|
285
|
+
y: { field: 'category_label', type: 'nominal', title: rowTitle },
|
|
286
|
+
color: { field: 'series_label', type: 'nominal', title: colTitle },
|
|
287
|
+
tooltip,
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
case 'Area Chart':
|
|
291
|
+
return {
|
|
292
|
+
title: buildRendererTitle(config),
|
|
293
|
+
transform: verticalTransform,
|
|
294
|
+
mark: { type: 'area', opacity: 0.7 },
|
|
295
|
+
encoding: {
|
|
296
|
+
x: { field: 'category_label', type: 'nominal', title: colTitle },
|
|
297
|
+
y: {
|
|
298
|
+
field: 'value',
|
|
299
|
+
type: 'quantitative',
|
|
300
|
+
title: fullAggName,
|
|
301
|
+
stack: 'zero',
|
|
302
|
+
},
|
|
303
|
+
color: { field: 'series_label', type: 'nominal', title: rowTitle },
|
|
304
|
+
tooltip,
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
case 'Scatter Chart':
|
|
308
|
+
return {
|
|
309
|
+
title: `${config.rows.join(', ') || 'Rows'} vs ${config.cols.join(', ') || 'Columns'}`,
|
|
310
|
+
mark: { type: 'point', filled: true },
|
|
311
|
+
encoding: {
|
|
312
|
+
x: { field: 'col_label', type: 'nominal', title: colTitle },
|
|
313
|
+
y: { field: 'row_label', type: 'nominal', title: rowTitle },
|
|
314
|
+
size: { field: 'value', type: 'quantitative', title: fullAggName },
|
|
315
|
+
color: { field: 'value', type: 'quantitative', title: fullAggName },
|
|
316
|
+
tooltip,
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
case 'Multiple Pie Chart':
|
|
320
|
+
return {
|
|
321
|
+
title: buildRendererTitle(config, true),
|
|
322
|
+
transform: horizontalTransform,
|
|
323
|
+
facet: { field: 'series_label', type: 'nominal', title: colTitle },
|
|
324
|
+
columns: 3,
|
|
325
|
+
spec: {
|
|
326
|
+
mark: { type: 'arc', innerRadius: 24 },
|
|
327
|
+
encoding: {
|
|
328
|
+
theta: { field: 'value', type: 'quantitative' },
|
|
329
|
+
color: { field: 'category_label', type: 'nominal', title: rowTitle },
|
|
330
|
+
tooltip,
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
default:
|
|
335
|
+
return {
|
|
336
|
+
title: buildRendererTitle(config),
|
|
337
|
+
transform: verticalTransform,
|
|
338
|
+
mark: { type: 'bar' },
|
|
339
|
+
encoding: {
|
|
340
|
+
x: { field: 'category_label', type: 'nominal' },
|
|
341
|
+
y: { field: 'value', type: 'quantitative' },
|
|
342
|
+
color: { field: 'series_label', type: 'nominal' },
|
|
343
|
+
tooltip,
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,OAAO,CAAC;AAyBzC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU,EAAE,CAAU;IAChD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE;QACnD,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,MAAM;KACpB,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAW,EAAE,CAAW;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAC5C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE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YACvB,OAAO;gBACL,KAAK,EAAE,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC;gBACvC,SAAS,EAAE,mBAAmB;gBAC9B,KAAK,EAAE,EAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAC;gBAChE,OAAO,EAAE,CAAC;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,EAAC,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAC;oBACpC,QAAQ,EAAE;wBACR,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAC;wBAC7C,KAAK,EAAE,EAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAC;wBAClE,OAAO;qBACR;iBACF;aACF,CAAC;QACJ;YACE,OAAO;gBACL,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC;gBACjC,SAAS,EAAE,iBAAiB;gBAC5B,IAAI,EAAE,EAAC,IAAI,EAAE,KAAK,EAAC;gBACnB,QAAQ,EAAE;oBACR,CAAC,EAAE,EAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC7C,CAAC,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAC;oBACzC,KAAK,EAAE,EAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC/C,OAAO;iBACR;aACF,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["import {getAggregatorLabel} from './aggregators';\nimport {buildRendererTitle} from './sql';\nimport {PivotConfig} from './types';\nimport {VisualizationSpec} from '@sqlrooms/vega';\nimport * as arrow from 'apache-arrow';\n\n/**\n * Optional Arrow table input used by pivot renderers while query results are loading.\n */\nexport type PivotArrowTable = arrow.Table | undefined;\n\n/**\n * Cell value type produced by pivot queries.\n *\n * Values may be numeric, strings, bigint-backed Arrow scalars, or null-like values\n * depending on the selected aggregator.\n */\nexport type PivotCellValue = unknown;\n\ntype PivotColumn = ReturnType<arrow.Table['getChild']> | undefined;\n\n/**\n * Supported heatmap rendering modes for the pivot table renderer.\n */\nexport type HeatmapMode = 'full' | 'row' | 'col' | undefined;\n\n/**\n * Sorts two arbitrary values using a null-safe natural string comparison.\n *\n * Numeric substrings are compared numerically so labels like `item2` sort before\n * `item10`.\n */\nexport function naturalSort(a: unknown, b: unknown) {\n if (a === b) {\n return 0;\n }\n if (a === null || a === undefined) {\n return -1;\n }\n if (b === null || b === undefined) {\n return 1;\n }\n return String(a).localeCompare(String(b), undefined, {\n numeric: true,\n sensitivity: 'base',\n });\n}\n\n/**\n * Compares two pivot key tuples segment-by-segment using natural sorting.\n */\nexport function compareKeyArrays(a: string[], b: string[]) {\n const length = Math.max(a.length, b.length);\n for (let index = 0; index < length; index += 1) {\n const comparison = naturalSort(a[index] ?? '', b[index] ?? '');\n if (comparison !== 0) {\n return comparison;\n }\n }\n return 0;\n}\n\n/**\n * Encodes a composite pivot key as a stable string suitable for `Map` keys.\n */\nexport function keyId(key: string[]) {\n return key.join('\\u0000');\n}\n\nfunction getPivotKey(columns: PivotColumn[], index: number) {\n return columns.map((column) => String(column?.get(index) ?? ''));\n}\n\n/**\n * Builds a lookup of axis totals keyed by the requested row or column aliases.\n *\n * The map values come directly from the Arrow `value` column to avoid converting\n * the result set into row objects first.\n */\nexport function buildPivotTotalsMap(\n table: PivotArrowTable,\n keyAliases: string[],\n): Map<string, PivotCellValue> {\n const keyColumns = keyAliases.map((alias) => table?.getChild(alias));\n const valueColumn = table?.getChild('value');\n const map = new Map<string, PivotCellValue>();\n const rowCount = table?.numRows ?? 0;\n for (let index = 0; index < rowCount; index += 1) {\n map.set(\n keyId(getPivotKey(keyColumns, index)),\n valueColumn?.get(index) ?? null,\n );\n }\n return map;\n}\n\n/**\n * Extracts the distinct row or column keys present in a pivot result table.\n *\n * Keys are returned in encounter order so callers can apply their own sorting.\n */\nexport function buildPivotUniqueKeys(\n table: PivotArrowTable,\n keyAliases: string[],\n) {\n const keyColumns = keyAliases.map((alias) => table?.getChild(alias));\n const unique = new Map<string, string[]>();\n const rowCount = table?.numRows ?? 0;\n for (let index = 0; index < rowCount; index += 1) {\n const key = getPivotKey(keyColumns, index);\n unique.set(keyId(key), key);\n }\n return Array.from(unique.values());\n}\n\n/**\n * Builds a lookup of pivot cell values keyed by `rowKey::colKey`.\n *\n * This is the main columnar access path used by `TableRenderer`.\n */\nexport function buildPivotCellMap(\n table: PivotArrowTable,\n rowAliases: string[],\n colAliases: string[],\n): Map<string, PivotCellValue> {\n const rowColumns = rowAliases.map((alias) => table?.getChild(alias));\n const colColumns = colAliases.map((alias) => table?.getChild(alias));\n const valueColumn = table?.getChild('value');\n const map = new Map<string, PivotCellValue>();\n const rowCount = table?.numRows ?? 0;\n for (let index = 0; index < rowCount; index += 1) {\n map.set(\n `${keyId(getPivotKey(rowColumns, index))}::${keyId(getPivotKey(colColumns, index))}`,\n valueColumn?.get(index) ?? null,\n );\n }\n return map;\n}\n\n/**\n * Returns the unique stringified values for a single Arrow column.\n *\n * Used by export and chart helpers that only need one label column.\n */\nexport function getUniqueStringColumnValues(\n table: PivotArrowTable,\n columnName: string,\n) {\n const column = table?.getChild(columnName);\n const unique = new Set<string>();\n const rowCount = table?.numRows ?? 0;\n for (let index = 0; index < rowCount; index += 1) {\n unique.add(String(column?.get(index) ?? ''));\n }\n return Array.from(unique);\n}\n\n/**\n * Calculates the rowspan or colspan for a grouped header cell.\n *\n * Returns `-1` when the cell should be skipped because an earlier header already\n * spans across it.\n */\nexport function spanSize(\n arr: string[][],\n rowIndex: number,\n columnIndex: number,\n) {\n if (rowIndex !== 0) {\n let noDraw = true;\n for (let index = 0; index <= columnIndex; index += 1) {\n if (arr[rowIndex - 1]?.[index] !== arr[rowIndex]?.[index]) {\n noDraw = false;\n }\n }\n if (noDraw) {\n return -1;\n }\n }\n\n let length = 0;\n while (rowIndex + length < arr.length) {\n let stop = false;\n for (let index = 0; index <= columnIndex; index += 1) {\n if (arr[rowIndex]?.[index] !== arr[rowIndex + length]?.[index]) {\n stop = true;\n }\n }\n if (stop) {\n break;\n }\n length += 1;\n }\n return length;\n}\n\n/**\n * Produces a simple red-tinted heatmap background for a numeric value.\n *\n * The value is normalized against the provided scale values.\n */\nexport function makeHeatColor(value: number | null, values: number[]) {\n if (value === null || values.length === 0) {\n return undefined;\n }\n const min = Math.min(...values);\n const max = Math.max(...values);\n if (!Number.isFinite(min) || !Number.isFinite(max)) {\n return undefined;\n }\n if (min === max) {\n return {backgroundColor: 'rgb(255,220,220)'};\n }\n const nonRed = 255 - Math.round((255 * (value - min)) / (max - min));\n return {backgroundColor: `rgb(255,${nonRed},${nonRed})`};\n}\n\n/**\n * Converts a mixed collection of values into the finite numeric subset.\n */\nexport function toNumericValues(values: unknown[]) {\n return values\n .map((value) => Number(value))\n .filter((value) => Number.isFinite(value));\n}\n\n/**\n * Builds the Vega-Lite spec for chart-based pivot renderers.\n *\n * The generated spec derives display-friendly series/category labels from the\n * pivot result's `row_label` and `col_label` columns.\n */\nexport function buildChartSpec(\n config: PivotConfig,\n rendererName: PivotConfig['rendererName'],\n): VisualizationSpec {\n const fullAggName = getAggregatorLabel(config.aggregatorName, config.vals);\n const defaultSeries = JSON.stringify(fullAggName);\n const defaultCategory = JSON.stringify(' ');\n const rowTitle = config.rows.join(', ') || undefined;\n const colTitle = config.cols.join(', ') || undefined;\n\n const verticalTransform = [\n {\n calculate: `datum.row_label && datum.row_label !== '' ? datum.row_label : ${defaultSeries}`,\n as: 'series_label',\n },\n {\n calculate: `datum.col_label && datum.col_label !== '' ? datum.col_label : ${defaultCategory}`,\n as: 'category_label',\n },\n ];\n const horizontalTransform = [\n {\n calculate: `datum.col_label && datum.col_label !== '' ? datum.col_label : ${defaultSeries}`,\n as: 'series_label',\n },\n {\n calculate: `datum.row_label && datum.row_label !== '' ? datum.row_label : ${defaultCategory}`,\n as: 'category_label',\n },\n ];\n\n const tooltip: Array<{\n field: 'row_label' | 'col_label' | 'value';\n type: 'nominal' | 'quantitative';\n title: string;\n }> = [\n {field: 'row_label', type: 'nominal', title: rowTitle ?? 'Rows'},\n {field: 'col_label', type: 'nominal', title: colTitle ?? 'Columns'},\n {field: 'value', type: 'quantitative', title: fullAggName},\n ];\n\n switch (rendererName) {\n case 'Grouped Column Chart':\n return {\n title: buildRendererTitle(config),\n transform: verticalTransform,\n mark: {type: 'bar'},\n encoding: {\n x: {field: 'category_label', type: 'nominal', title: colTitle},\n xOffset: {field: 'series_label'},\n y: {field: 'value', type: 'quantitative', title: fullAggName},\n color: {field: 'series_label', type: 'nominal', title: rowTitle},\n tooltip,\n },\n };\n case 'Stacked Column Chart':\n return {\n title: buildRendererTitle(config),\n transform: verticalTransform,\n mark: {type: 'bar'},\n encoding: {\n x: {field: 'category_label', type: 'nominal', title: colTitle},\n y: {\n field: 'value',\n type: 'quantitative',\n title: fullAggName,\n stack: 'zero',\n },\n color: {field: 'series_label', type: 'nominal', title: rowTitle},\n tooltip,\n },\n };\n case 'Grouped Bar Chart':\n return {\n title: buildRendererTitle(config, true),\n transform: horizontalTransform,\n mark: {type: 'bar'},\n encoding: {\n y: {field: 'category_label', type: 'nominal', title: rowTitle},\n yOffset: {field: 'series_label'},\n x: {field: 'value', type: 'quantitative', title: fullAggName},\n color: {field: 'series_label', type: 'nominal', title: colTitle},\n tooltip,\n },\n };\n case 'Stacked Bar Chart':\n return {\n title: buildRendererTitle(config, true),\n transform: horizontalTransform,\n mark: {type: 'bar'},\n encoding: {\n y: {field: 'category_label', type: 'nominal', title: rowTitle},\n x: {\n field: 'value',\n type: 'quantitative',\n title: fullAggName,\n stack: 'zero',\n },\n color: {field: 'series_label', type: 'nominal', title: colTitle},\n tooltip,\n },\n };\n case 'Line Chart':\n return {\n title: buildRendererTitle(config),\n transform: verticalTransform,\n mark: {type: 'line', point: true},\n encoding: {\n x: {field: 'category_label', type: 'nominal', title: colTitle},\n y: {field: 'value', type: 'quantitative', title: fullAggName},\n color: {field: 'series_label', type: 'nominal', title: rowTitle},\n tooltip,\n },\n };\n case 'Dot Chart':\n return {\n title: buildRendererTitle(config, true),\n transform: horizontalTransform,\n mark: {type: 'point', filled: true, size: 90},\n encoding: {\n x: {field: 'value', type: 'quantitative', title: fullAggName},\n y: {field: 'category_label', type: 'nominal', title: rowTitle},\n color: {field: 'series_label', type: 'nominal', title: colTitle},\n tooltip,\n },\n };\n case 'Area Chart':\n return {\n title: buildRendererTitle(config),\n transform: verticalTransform,\n mark: {type: 'area', opacity: 0.7},\n encoding: {\n x: {field: 'category_label', type: 'nominal', title: colTitle},\n y: {\n field: 'value',\n type: 'quantitative',\n title: fullAggName,\n stack: 'zero',\n },\n color: {field: 'series_label', type: 'nominal', title: rowTitle},\n tooltip,\n },\n };\n case 'Scatter Chart':\n return {\n title: `${config.rows.join(', ') || 'Rows'} vs ${config.cols.join(', ') || 'Columns'}`,\n mark: {type: 'point', filled: true},\n encoding: {\n x: {field: 'col_label', type: 'nominal', title: colTitle},\n y: {field: 'row_label', type: 'nominal', title: rowTitle},\n size: {field: 'value', type: 'quantitative', title: fullAggName},\n color: {field: 'value', type: 'quantitative', title: fullAggName},\n tooltip,\n },\n };\n case 'Multiple Pie Chart':\n return {\n title: buildRendererTitle(config, true),\n transform: horizontalTransform,\n facet: {field: 'series_label', type: 'nominal', title: colTitle},\n columns: 3,\n spec: {\n mark: {type: 'arc', innerRadius: 24},\n encoding: {\n theta: {field: 'value', type: 'quantitative'},\n color: {field: 'category_label', type: 'nominal', title: rowTitle},\n tooltip,\n },\n },\n };\n default:\n return {\n title: buildRendererTitle(config),\n transform: verticalTransform,\n mark: {type: 'bar'},\n encoding: {\n x: {field: 'category_label', type: 'nominal'},\n y: {field: 'value', type: 'quantitative'},\n color: {field: 'series_label', type: 'nominal'},\n tooltip,\n },\n };\n }\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@include ../README.md}
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
export { createPivotSlice } from './PivotSlice';
|
|
6
|
+
export { addAttributeFilterValuesInConfig, clearAttributeFilterInConfig, createDefaultPivotConfig, createPivotCoreStore, normalizePivotConfig, removeAttributeFilterValuesInConfig, setAttributeFilterValuesInConfig, } from './PivotCoreSlice';
|
|
7
|
+
export { PivotEditor } from './PivotEditor';
|
|
8
|
+
export { PivotView } from './PivotView';
|
|
9
|
+
export { PivotResults } from './PivotResults';
|
|
10
|
+
export { createOrReplacePivotRelations, createPivotRelationViews, dropPivotRelations, } from './pivotExecution';
|
|
11
|
+
export { DEFAULT_PIVOT_AGGREGATOR, PIVOT_AGGREGATORS, formatAggregatorValue, getAggregatorLabel, getDefaultValuesForAggregator, getPivotAggregator, } from './aggregators';
|
|
12
|
+
export { buildCellsQuery, buildColTotalsQuery, buildDistinctValuesQuery, buildGrandTotalQuery, buildPivotExportQuery, buildRendererTitle, buildRowTotalsQuery, createPivotQuerySource, createPivotQuerySourceFromTable, } from './sql';
|
|
13
|
+
export { pivotCellRegistryEntry } from './pivotCellRegistryEntry';
|
|
14
|
+
export { PivotCellContent } from './PivotCellContent';
|
|
15
|
+
export { PivotCellData, PivotCell, PivotCellSchema, isPivotCell, } from './pivotCellTypes';
|
|
16
|
+
export type { PivotAggregatorDefinition } from './aggregators';
|
|
17
|
+
export type { PivotInstanceSnapshot, PivotInstanceState, PivotInstanceStore, } from './PivotCoreSlice';
|
|
18
|
+
export type { PivotConfig, PivotRelationViews, PivotRunState, PivotSliceItem, PivotDropZone, PivotField, PivotFilterMap, PivotOutputCell, PivotQuerySource, PivotRendererName, PivotSource, PivotStatus, PivotSliceState, PivotSortOrder, PivotValueFilter, } from './types';
|
|
19
|
+
export { PIVOT_RENDERER_NAMES, PivotConfig as PivotConfigSchema, PivotFilterMapSchema, PivotRelationViews as PivotRelationViewsSchema, PivotRunState as PivotRunStateSchema, PivotSource as PivotSourceSchema, PivotStatus as PivotStatusSchema, PivotSliceConfig, PivotValueFilterSchema, } from './types';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,mCAAmC,EACnC,gCAAgC,GACjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,OAAO,CAAC;AAEf,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAC7D,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,oBAAoB,EACpB,WAAW,IAAI,iBAAiB,EAChC,oBAAoB,EACpB,kBAAkB,IAAI,wBAAwB,EAC9C,aAAa,IAAI,mBAAmB,EACpC,WAAW,IAAI,iBAAiB,EAChC,WAAW,IAAI,iBAAiB,EAChC,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@include ../README.md}
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
export { createPivotSlice } from './PivotSlice';
|
|
6
|
+
export { addAttributeFilterValuesInConfig, clearAttributeFilterInConfig, createDefaultPivotConfig, createPivotCoreStore, normalizePivotConfig, removeAttributeFilterValuesInConfig, setAttributeFilterValuesInConfig, } from './PivotCoreSlice';
|
|
7
|
+
export { PivotEditor } from './PivotEditor';
|
|
8
|
+
export { PivotView } from './PivotView';
|
|
9
|
+
export { PivotResults } from './PivotResults';
|
|
10
|
+
export { createOrReplacePivotRelations, createPivotRelationViews, dropPivotRelations, } from './pivotExecution';
|
|
11
|
+
export { DEFAULT_PIVOT_AGGREGATOR, PIVOT_AGGREGATORS, formatAggregatorValue, getAggregatorLabel, getDefaultValuesForAggregator, getPivotAggregator, } from './aggregators';
|
|
12
|
+
export { buildCellsQuery, buildColTotalsQuery, buildDistinctValuesQuery, buildGrandTotalQuery, buildPivotExportQuery, buildRendererTitle, buildRowTotalsQuery, createPivotQuerySource, createPivotQuerySourceFromTable, } from './sql';
|
|
13
|
+
export { pivotCellRegistryEntry } from './pivotCellRegistryEntry';
|
|
14
|
+
export { PivotCellContent } from './PivotCellContent';
|
|
15
|
+
export { PivotCellData, PivotCell, PivotCellSchema, isPivotCell, } from './pivotCellTypes';
|
|
16
|
+
export { PIVOT_RENDERER_NAMES, PivotConfig as PivotConfigSchema, PivotFilterMapSchema, PivotRelationViews as PivotRelationViewsSchema, PivotRunState as PivotRunStateSchema, PivotSource as PivotSourceSchema, PivotStatus as PivotStatusSchema, PivotSliceConfig, PivotValueFilterSchema, } from './types';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,mCAAmC,EACnC,gCAAgC,GACjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,OAAO,CAAC;AAEf,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAyB1B,OAAO,EACL,oBAAoB,EACpB,WAAW,IAAI,iBAAiB,EAChC,oBAAoB,EACpB,kBAAkB,IAAI,wBAAwB,EAC9C,aAAa,IAAI,mBAAmB,EACpC,WAAW,IAAI,iBAAiB,EAChC,WAAW,IAAI,iBAAiB,EAChC,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,SAAS,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nexport {createPivotSlice} from './PivotSlice';\nexport {\n addAttributeFilterValuesInConfig,\n clearAttributeFilterInConfig,\n createDefaultPivotConfig,\n createPivotCoreStore,\n normalizePivotConfig,\n removeAttributeFilterValuesInConfig,\n setAttributeFilterValuesInConfig,\n} from './PivotCoreSlice';\nexport {PivotEditor} from './PivotEditor';\nexport {PivotView} from './PivotView';\nexport {PivotResults} from './PivotResults';\nexport {\n createOrReplacePivotRelations,\n createPivotRelationViews,\n dropPivotRelations,\n} from './pivotExecution';\nexport {\n DEFAULT_PIVOT_AGGREGATOR,\n PIVOT_AGGREGATORS,\n formatAggregatorValue,\n getAggregatorLabel,\n getDefaultValuesForAggregator,\n getPivotAggregator,\n} from './aggregators';\nexport {\n buildCellsQuery,\n buildColTotalsQuery,\n buildDistinctValuesQuery,\n buildGrandTotalQuery,\n buildPivotExportQuery,\n buildRendererTitle,\n buildRowTotalsQuery,\n createPivotQuerySource,\n createPivotQuerySourceFromTable,\n} from './sql';\n\nexport {pivotCellRegistryEntry} from './pivotCellRegistryEntry';\nexport {PivotCellContent} from './PivotCellContent';\nexport {\n PivotCellData,\n PivotCell,\n PivotCellSchema,\n isPivotCell,\n} from './pivotCellTypes';\n\nexport type {PivotAggregatorDefinition} from './aggregators';\nexport type {\n PivotInstanceSnapshot,\n PivotInstanceState,\n PivotInstanceStore,\n} from './PivotCoreSlice';\nexport type {\n PivotConfig,\n PivotRelationViews,\n PivotRunState,\n PivotSliceItem,\n PivotDropZone,\n PivotField,\n PivotFilterMap,\n PivotOutputCell,\n PivotQuerySource,\n PivotRendererName,\n PivotSource,\n PivotStatus,\n PivotSliceState,\n PivotSortOrder,\n PivotValueFilter,\n} from './types';\nexport {\n PIVOT_RENDERER_NAMES,\n PivotConfig as PivotConfigSchema,\n PivotFilterMapSchema,\n PivotRelationViews as PivotRelationViewsSchema,\n PivotRunState as PivotRunStateSchema,\n PivotSource as PivotSourceSchema,\n PivotStatus as PivotStatusSchema,\n PivotSliceConfig,\n PivotValueFilterSchema,\n} from './types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pivotCellRegistryEntry.d.ts","sourceRoot":"","sources":["../src/pivotCellRegistryEntry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAIjB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAc,KAAK,SAAS,EAAC,MAAM,kBAAkB,CAAC;AA2C7D,eAAO,MAAM,sBAAsB,EAAE,gBAAgB,CAAC,SAAS,CAwH9D,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { findSheetIdForCell, resolveSheetSchemaName } from '@sqlrooms/cells';
|
|
3
|
+
import { produce } from 'immer';
|
|
4
|
+
import { PivotCellContent } from './PivotCellContent';
|
|
5
|
+
import { isPivotCell } from './pivotCellTypes';
|
|
6
|
+
import { createPivotQuerySource } from './sql';
|
|
7
|
+
function pivotStatusToCellStatus(pivotStatus) {
|
|
8
|
+
const statusMap = {
|
|
9
|
+
idle: 'idle',
|
|
10
|
+
running: 'running',
|
|
11
|
+
success: 'success',
|
|
12
|
+
error: 'error',
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
type: 'pivot',
|
|
16
|
+
status: statusMap[pivotStatus.state] ?? 'idle',
|
|
17
|
+
stale: pivotStatus.stale,
|
|
18
|
+
lastError: pivotStatus.lastError,
|
|
19
|
+
lastRunTime: pivotStatus.lastRunTime,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function resolveSqlQuerySource(state, sqlId) {
|
|
23
|
+
const sourceStatus = state.cells.status[sqlId];
|
|
24
|
+
const resultView = sourceStatus?.type === 'sql'
|
|
25
|
+
? sourceStatus.resultView
|
|
26
|
+
: undefined;
|
|
27
|
+
if (!resultView)
|
|
28
|
+
return undefined;
|
|
29
|
+
const sourceResult = state.cells.getCellResult(sqlId)?.arrowTable;
|
|
30
|
+
const columns = sourceResult?.schema.fields.map((field) => ({
|
|
31
|
+
name: field.name,
|
|
32
|
+
type: String(field.type),
|
|
33
|
+
}));
|
|
34
|
+
if (!columns?.length)
|
|
35
|
+
return undefined;
|
|
36
|
+
return createPivotQuerySource(resultView, columns);
|
|
37
|
+
}
|
|
38
|
+
export const pivotCellRegistryEntry = {
|
|
39
|
+
type: 'pivot',
|
|
40
|
+
title: 'Pivot Table',
|
|
41
|
+
createCell: ({ id, get }) => {
|
|
42
|
+
const state = get();
|
|
43
|
+
const pivotId = state.pivot.addPivot({ title: 'Pivot' });
|
|
44
|
+
return {
|
|
45
|
+
id,
|
|
46
|
+
type: 'pivot',
|
|
47
|
+
data: { pivotId },
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
renderCell: ({ id, cell, renderContainer }) => (_jsx(PivotCellContent, { id: id, cell: cell, renderContainer: renderContainer })),
|
|
51
|
+
findDependencies: async () => {
|
|
52
|
+
// We can't access PivotSlice from here (only cell data + cells map).
|
|
53
|
+
// Pivot source info lives in PivotSlice, not in cell data.
|
|
54
|
+
// TODO: if dependency tracking is needed, extend findDependencies args
|
|
55
|
+
// to include the full store, or store the source kind in cell data.
|
|
56
|
+
return [];
|
|
57
|
+
},
|
|
58
|
+
createStatus: () => ({
|
|
59
|
+
type: 'pivot',
|
|
60
|
+
status: 'idle',
|
|
61
|
+
stale: true,
|
|
62
|
+
}),
|
|
63
|
+
onInitialize: () => {
|
|
64
|
+
// PivotSlice.initialize() handles runtime resets.
|
|
65
|
+
},
|
|
66
|
+
onRemove: async ({ id, get }) => {
|
|
67
|
+
const state = get();
|
|
68
|
+
const cell = state.cells.config.data[id];
|
|
69
|
+
if (!cell || !isPivotCell(cell))
|
|
70
|
+
return;
|
|
71
|
+
state.pivot.removePivot(cell.data.pivotId);
|
|
72
|
+
},
|
|
73
|
+
hasSemanticChange: (oldCell, newCell) => {
|
|
74
|
+
if (!isPivotCell(oldCell) || !isPivotCell(newCell))
|
|
75
|
+
return false;
|
|
76
|
+
return oldCell.data.pivotId !== newCell.data.pivotId;
|
|
77
|
+
},
|
|
78
|
+
invalidateStatus: (currentStatus) => ({
|
|
79
|
+
type: 'pivot',
|
|
80
|
+
status: 'idle',
|
|
81
|
+
stale: true,
|
|
82
|
+
lastRunTime: currentStatus.lastRunTime,
|
|
83
|
+
}),
|
|
84
|
+
getRelationsToDrop: () => {
|
|
85
|
+
// PivotSlice.removePivot() handles relation cleanup
|
|
86
|
+
return [];
|
|
87
|
+
},
|
|
88
|
+
recordError: (currentStatus, message) => ({
|
|
89
|
+
...currentStatus,
|
|
90
|
+
status: 'error',
|
|
91
|
+
stale: true,
|
|
92
|
+
lastError: message,
|
|
93
|
+
}),
|
|
94
|
+
runCell: async ({ id, opts, get, set }) => {
|
|
95
|
+
const state = get();
|
|
96
|
+
const cell = state.cells.config.data[id];
|
|
97
|
+
if (!cell || !isPivotCell(cell))
|
|
98
|
+
return;
|
|
99
|
+
const pivotId = cell.data.pivotId;
|
|
100
|
+
const pivot = state.pivot.config.pivots[pivotId];
|
|
101
|
+
if (!pivot)
|
|
102
|
+
return;
|
|
103
|
+
const sheetId = findSheetIdForCell(state, id);
|
|
104
|
+
const sheet = sheetId ? state.cells.config.sheets[sheetId] : undefined;
|
|
105
|
+
const schemaName = sheet
|
|
106
|
+
? resolveSheetSchemaName(sheet)
|
|
107
|
+
: opts?.schemaName || '__sqlrooms_pivot';
|
|
108
|
+
let querySource;
|
|
109
|
+
if (pivot.source?.kind === 'sql') {
|
|
110
|
+
querySource = resolveSqlQuerySource(state, pivot.source.sqlId);
|
|
111
|
+
if (!querySource) {
|
|
112
|
+
set((s) => produce(s, (draft) => {
|
|
113
|
+
draft.cells.status[id] = {
|
|
114
|
+
type: 'pivot',
|
|
115
|
+
status: 'error',
|
|
116
|
+
stale: true,
|
|
117
|
+
lastError: 'Pivot source SQL cell has no results. Run it first.',
|
|
118
|
+
};
|
|
119
|
+
}));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
await state.pivot.runPivot(pivotId, {
|
|
124
|
+
cascade: opts?.cascade,
|
|
125
|
+
schemaName,
|
|
126
|
+
querySource,
|
|
127
|
+
});
|
|
128
|
+
const updatedState = get();
|
|
129
|
+
const updatedPivot = updatedState.pivot.config.pivots[pivotId];
|
|
130
|
+
if (updatedPivot) {
|
|
131
|
+
set((s) => produce(s, (draft) => {
|
|
132
|
+
draft.cells.status[id] = pivotStatusToCellStatus(updatedPivot.status);
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=pivotCellRegistryEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pivotCellRegistryEntry.js","sourceRoot":"","sources":["../src/pivotCellRegistryEntry.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,WAAW,EAAiB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAC,sBAAsB,EAAC,MAAM,OAAO,CAAC;AAK7C,SAAS,uBAAuB,CAAC,WAAwB;IACvD,M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,CAAC,CAAC;YACxE,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type {\n Cell,\n CellRegistryItem,\n CellsRootState,\n CellStatus,\n SqlCellStatus,\n} from '@sqlrooms/cells';\nimport {findSheetIdForCell, resolveSheetSchemaName} from '@sqlrooms/cells';\nimport {produce} from 'immer';\nimport {PivotCellContent} from './PivotCellContent';\nimport {isPivotCell, type PivotCell} from './pivotCellTypes';\nimport {createPivotQuerySource} from './sql';\nimport type {PivotQuerySource, PivotSliceState, PivotStatus} from './types';\n\ntype PivotRootState = CellsRootState & PivotSliceState;\n\nfunction pivotStatusToCellStatus(pivotStatus: PivotStatus): CellStatus {\n const statusMap: Record<string, string> = {\n idle: 'idle',\n running: 'running',\n success: 'success',\n error: 'error',\n };\n return {\n type: 'pivot',\n status: statusMap[pivotStatus.state] ?? 'idle',\n stale: pivotStatus.stale,\n lastError: pivotStatus.lastError,\n lastRunTime: pivotStatus.lastRunTime,\n };\n}\n\nfunction resolveSqlQuerySource(\n state: CellsRootState,\n sqlId: string,\n): PivotQuerySource | undefined {\n const sourceStatus = state.cells.status[sqlId];\n const resultView =\n sourceStatus?.type === 'sql'\n ? (sourceStatus as SqlCellStatus).resultView\n : undefined;\n if (!resultView) return undefined;\n\n const sourceResult = state.cells.getCellResult(sqlId)?.arrowTable;\n const columns = sourceResult?.schema.fields.map((field) => ({\n name: field.name,\n type: String(field.type),\n }));\n if (!columns?.length) return undefined;\n\n return createPivotQuerySource(resultView, columns);\n}\n\nexport const pivotCellRegistryEntry: CellRegistryItem<PivotCell> = {\n type: 'pivot',\n title: 'Pivot Table',\n\n createCell: ({id, get}) => {\n const state = get() as PivotRootState;\n const pivotId = state.pivot.addPivot({title: 'Pivot'});\n return {\n id,\n type: 'pivot',\n data: {pivotId},\n };\n },\n\n renderCell: ({id, cell, renderContainer}) => (\n <PivotCellContent\n id={id}\n cell={cell as PivotCell}\n renderContainer={renderContainer}\n />\n ),\n\n findDependencies: async () => {\n // We can't access PivotSlice from here (only cell data + cells map).\n // Pivot source info lives in PivotSlice, not in cell data.\n // TODO: if dependency tracking is needed, extend findDependencies args\n // to include the full store, or store the source kind in cell data.\n return [];\n },\n\n createStatus: (): CellStatus => ({\n type: 'pivot',\n status: 'idle',\n stale: true,\n }),\n\n onInitialize: () => {\n // PivotSlice.initialize() handles runtime resets.\n },\n\n onRemove: async ({id, get}) => {\n const state = get() as PivotRootState;\n const cell = state.cells.config.data[id];\n if (!cell || !isPivotCell(cell)) return;\n state.pivot.removePivot(cell.data.pivotId);\n },\n\n hasSemanticChange: (oldCell: Cell, newCell: Cell): boolean => {\n if (!isPivotCell(oldCell) || !isPivotCell(newCell)) return false;\n return oldCell.data.pivotId !== newCell.data.pivotId;\n },\n\n invalidateStatus: (currentStatus): CellStatus => ({\n type: 'pivot',\n status: 'idle',\n stale: true,\n lastRunTime: (currentStatus as {lastRunTime?: number}).lastRunTime,\n }),\n\n getRelationsToDrop: (): string[] => {\n // PivotSlice.removePivot() handles relation cleanup\n return [];\n },\n\n recordError: (currentStatus, message): CellStatus => ({\n ...currentStatus,\n status: 'error',\n stale: true,\n lastError: message,\n }),\n\n runCell: async ({id, opts, get, set}) => {\n const state = get() as PivotRootState;\n const cell = state.cells.config.data[id];\n if (!cell || !isPivotCell(cell)) return;\n\n const pivotId = cell.data.pivotId;\n const pivot = state.pivot.config.pivots[pivotId];\n if (!pivot) return;\n\n const sheetId = findSheetIdForCell(state, id);\n const sheet = sheetId ? state.cells.config.sheets[sheetId] : undefined;\n const schemaName = sheet\n ? resolveSheetSchemaName(sheet)\n : opts?.schemaName || '__sqlrooms_pivot';\n\n let querySource: PivotQuerySource | undefined;\n if (pivot.source?.kind === 'sql') {\n querySource = resolveSqlQuerySource(state, pivot.source.sqlId);\n if (!querySource) {\n set((s) =>\n produce(s, (draft) => {\n draft.cells.status[id] = {\n type: 'pivot',\n status: 'error',\n stale: true,\n lastError: 'Pivot source SQL cell has no results. Run it first.',\n };\n }),\n );\n return;\n }\n }\n\n await state.pivot.runPivot(pivotId, {\n cascade: opts?.cascade,\n schemaName,\n querySource,\n });\n\n const updatedState = get() as PivotRootState;\n const updatedPivot = updatedState.pivot.config.pivots[pivotId];\n if (updatedPivot) {\n set((s) =>\n produce(s, (draft) => {\n draft.cells.status[id] = pivotStatusToCellStatus(updatedPivot.status);\n }),\n );\n }\n },\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Cell } from '@sqlrooms/cells';
|
|
3
|
+
export declare const PivotCellData: z.ZodObject<{
|
|
4
|
+
pivotId: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export type PivotCellData = z.infer<typeof PivotCellData>;
|
|
7
|
+
export declare const PivotCell: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
type: z.ZodLiteral<"pivot">;
|
|
10
|
+
data: z.ZodObject<{
|
|
11
|
+
pivotId: z.ZodString;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type PivotCell = z.infer<typeof PivotCell>;
|
|
15
|
+
export declare const PivotCellSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
type: z.ZodLiteral<"pivot">;
|
|
18
|
+
data: z.ZodObject<{
|
|
19
|
+
pivotId: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export declare function isPivotCell(cell: Cell): cell is PivotCell;
|
|
23
|
+
//# sourceMappingURL=pivotCellTypes.d.ts.map
|