derive-dashboards 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/kinds/area-marks.mjs +2 -1
- package/dist/charts/kinds/funnel-words.mjs +1 -1
- package/dist/charts/kinds/grid-marks.mjs +9 -4
- package/dist/charts/theme.d.mts +13 -13
- package/dist/charts/theme.mjs +17 -14
- package/dist/charts-react/Overlay.mjs +1 -0
- package/dist/charts-react/chart-unlayered.css +1 -107
- package/dist/charts-react/chart.css +1 -121
- package/dist/charts-react/tip-place.mjs +30 -15
- package/dist/core/document/display-comparisons.mjs +49 -0
- package/dist/core/document/display-validation.d.mts +12 -0
- package/dist/core/document/display-validation.mjs +56 -0
- package/dist/core/document/display.d.mts +6 -12
- package/dist/core/document/display.mjs +23 -48
- package/dist/core/engine/dialect.d.mts +2 -0
- package/dist/core/engine/index.mjs +1 -1
- package/dist/core/engine/levels.mjs +33 -1
- package/dist/core/engine/postgres.mjs +1 -0
- package/dist/core/engine/rank.mjs +1 -1
- package/dist/core/engine/reader.d.mts +4 -0
- package/dist/core/engine/sql-partition.mjs +45 -0
- package/dist/core/engine/sql-reads.mjs +4 -1
- package/dist/core/engine/statement.mjs +4 -4
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +1 -1
- package/dist/core/error/codes.mjs +1 -1
- package/dist/core/index.d.mts +6 -5
- package/dist/core/index.mjs +8 -7
- package/dist/core/model/validate/fields.mjs +1 -1
- package/dist/core/query/drill/compose.d.mts +2 -0
- package/dist/core/query/drill/compose.mjs +1 -1
- package/dist/core/query/drill/synthetic.mjs +1 -1
- package/dist/core/query/drill/types.d.mts +7 -0
- package/dist/core/query/drill/types.mjs +3 -1
- package/dist/core/schema/answers.d.mts +1176 -362
- package/dist/core/schema/drill-answers.mjs +19 -1
- package/dist/core/schema/drill.d.mts +21 -6
- package/dist/core/schema/drill.mjs +7 -1
- package/dist/core/schema/tools.mjs +13 -0
- package/dist/core/time/index.d.mts +2 -2
- package/dist/core/time/text-time.d.mts +9 -2
- package/dist/core/time/text-time.mjs +18 -3
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +22 -2
- package/dist/dashboard-documents.d.mts +8 -0
- package/dist/dashboard-documents.mjs +52 -0
- package/dist/drill-access.mjs +40 -3
- package/dist/drill-comparison.mjs +71 -0
- package/dist/drill-crumbs.mjs +21 -2
- package/dist/drill-group-seal.mjs +13 -0
- package/dist/drill-open.mjs +7 -1
- package/dist/drill-seal.mjs +4 -6
- package/dist/drill-views.mjs +5 -13
- package/dist/drill.mjs +28 -58
- package/dist/editing.mjs +1 -1
- package/dist/endpoints/drill.mjs +2 -3
- package/dist/endpoints/index.d.mts +20 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +6 -27
- package/dist/llms.txt +1 -1
- package/dist/react/Cell.mjs +2 -2
- package/dist/react/DashboardList.mjs +3 -3
- package/dist/react/Editing.mjs +3 -3
- package/dist/react/Header.mjs +2 -2
- package/dist/react/History.mjs +3 -3
- package/dist/react/Parts.mjs +2 -2
- package/dist/react/RowBody.d.mts +2 -4
- package/dist/react/RowBody.mjs +14 -39
- package/dist/react/Tile.mjs +4 -5
- package/dist/react/builder/FilterEditor.mjs +2 -2
- package/dist/react/builder/Picker.mjs +3 -3
- package/dist/react/builder/RangeEditor.mjs +3 -3
- package/dist/react/builder/Time.mjs +3 -3
- package/dist/react/builder/Values.mjs +2 -2
- package/dist/react/builder/WidgetBuilder.mjs +2 -2
- package/dist/react/drill/Bars.mjs +34 -38
- package/dist/react/drill/Comparison.mjs +204 -0
- package/dist/react/drill/Controls.mjs +8 -12
- package/dist/react/drill/DrillDrawer.mjs +42 -0
- package/dist/react/drill/DrillPanel.mjs +61 -41
- package/dist/react/drill/Header.mjs +65 -35
- package/dist/react/drill/ItemLink.mjs +40 -0
- package/dist/react/drill/Items.d.mts +2 -1
- package/dist/react/drill/Items.mjs +126 -99
- package/dist/react/drill/ItemsBody.mjs +38 -0
- package/dist/react/drill/ItemsFoot.mjs +24 -19
- package/dist/react/drill/Notes.mjs +23 -13
- package/dist/react/drill/PanelBody.mjs +7 -25
- package/dist/react/drill/RecordRow.mjs +47 -0
- package/dist/react/drill/Trend.mjs +186 -0
- package/dist/react/drill/board.mjs +21 -11
- package/dist/react/drill/drawer-context.mjs +5 -0
- package/dist/react/drill/item-parts.mjs +53 -35
- package/dist/react/drill/item-type.d.mts +2 -2
- package/dist/react/drill/lazy.d.mts +1 -4
- package/dist/react/drill/lazy.mjs +29 -11
- package/dist/react/drill/panel-focus.mjs +18 -7
- package/dist/react/drill/props.d.mts +7 -1
- package/dist/react/drill/props.mjs +39 -8
- package/dist/react/drill/record-page.mjs +61 -0
- package/dist/react/drill/state.mjs +17 -2
- package/dist/react/drill/trend-touch.mjs +33 -0
- package/dist/react/drill/useDrill.d.mts +3 -3
- package/dist/react/drill/useDrill.mjs +35 -15
- package/dist/react/drill/words.d.mts +14 -0
- package/dist/react/drill/words.mjs +19 -7
- package/dist/react/english.d.mts +1 -0
- package/dist/react/english.mjs +1 -0
- package/dist/react/filters/chip.mjs +2 -2
- package/dist/react/filters/menu-search.mjs +5 -5
- package/dist/react/filters/menu.mjs +2 -2
- package/dist/react/filters/number.mjs +2 -2
- package/dist/react/filters/operator.mjs +2 -2
- package/dist/react/filters/phone.mjs +2 -2
- package/dist/react/filters/values.mjs +4 -4
- package/dist/react/format-time.d.mts +1 -0
- package/dist/react/format-time.mjs +39 -33
- package/dist/react/format.mjs +10 -1
- package/dist/react/renderers/list.mjs +8 -10
- package/dist/react/renderers/table-cells.mjs +38 -9
- package/dist/react/renderers/table-measure.mjs +2 -0
- package/dist/react/renderers/table-row.mjs +64 -7
- package/dist/react/renderers/table-sort.mjs +2 -8
- package/dist/react/renderers/table.mjs +16 -15
- package/dist/react/theme-unlayered.css +1 -3148
- package/dist/react/theme.css +1 -3150
- package/dist/recharts/parts.mjs +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +4 -2
- package/dist/store/apply.mjs +2 -2
- package/dist/store/editor.mjs +2 -2
- package/dist/store/writer.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { canonical } from "../value/canonical.mjs";
|
|
2
|
-
import { displayEntryIssues } from "./display-entries.mjs";
|
|
3
1
|
// src/document/display.ts
|
|
4
2
|
/** Options every widget takes. */
|
|
5
3
|
const SHARED = {
|
|
@@ -21,7 +19,8 @@ const DISPLAY_OPTIONS = {
|
|
|
21
19
|
...SHARED,
|
|
22
20
|
bars: "texts",
|
|
23
21
|
heat: "texts",
|
|
24
|
-
compact: "boolean"
|
|
22
|
+
compact: "boolean",
|
|
23
|
+
comparisons: "comparisons"
|
|
25
24
|
},
|
|
26
25
|
list: {
|
|
27
26
|
...SHARED,
|
|
@@ -55,6 +54,7 @@ const DISPLAY_HELP = {
|
|
|
55
54
|
secondary: "A query entry a number tile shows as a second, smaller figure under the number, beside its label.",
|
|
56
55
|
bars: "Query entries drawn with a bar in each cell, as long as the value is beside the column's largest.",
|
|
57
56
|
heat: "Query entries whose cells are shaded by their value, darker for more.",
|
|
57
|
+
comparisons: "For a value of the first grouping column, name the drill field for its comparison table and optionally the field to expand each group by.",
|
|
58
58
|
compact: "Draw a table's rows closer together.",
|
|
59
59
|
colors: "A colour per series, by the series' label: any CSS colour.",
|
|
60
60
|
against: "The query entry each bar is read against (a goal, the average of all): drawn as a tick on the bar, not as a bar of its own.",
|
|
@@ -68,6 +68,7 @@ const DISPLAY_HELP = {
|
|
|
68
68
|
};
|
|
69
69
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
70
70
|
const isText = (value) => typeof value === "string";
|
|
71
|
+
const isComparisonFields = (fields) => Array.isArray(fields) && fields.length > 0 && fields.length <= 2 && Array.from(fields).every((field) => typeof field === "string" && field.trim().length > 0) && new Set(fields).size === fields.length;
|
|
71
72
|
const TYPES = {
|
|
72
73
|
boolean: {
|
|
73
74
|
fits: (v) => typeof v === "boolean",
|
|
@@ -81,6 +82,10 @@ const TYPES = {
|
|
|
81
82
|
fits: (v) => Array.isArray(v) && v.every((entry) => isText(entry)),
|
|
82
83
|
takes: "a list of texts"
|
|
83
84
|
},
|
|
85
|
+
comparisons: {
|
|
86
|
+
fits: (v) => isRecord(v) && Object.values(v).every((fields) => isComparisonFields(fields)),
|
|
87
|
+
takes: "one or two distinct drill fields for each group value"
|
|
88
|
+
},
|
|
84
89
|
colors: {
|
|
85
90
|
fits: (v) => isRecord(v) && Object.values(v).every((color) => isText(color)),
|
|
86
91
|
takes: "a colour for each series label, as text",
|
|
@@ -112,26 +117,20 @@ function displayIssues(kind, display, path = []) {
|
|
|
112
117
|
message: "display is an object of options.",
|
|
113
118
|
path
|
|
114
119
|
}];
|
|
115
|
-
return misfits(options, display).
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function documentDisplayIssues(doc) {
|
|
130
|
-
return Object.entries(doc.widgets).flatMap(([id, widget]) => widgetDisplayIssues(widget, [
|
|
131
|
-
"widgets",
|
|
132
|
-
id,
|
|
133
|
-
"display"
|
|
134
|
-
]));
|
|
120
|
+
return misfits(options, display).flatMap(([name, type]) => {
|
|
121
|
+
const value = display[name];
|
|
122
|
+
const pathToOption = [...path, name];
|
|
123
|
+
if (type === "comparisons" && isRecord(value)) return Object.keys(value).filter((key) => !isComparisonFields(value[key])).map((key) => ({
|
|
124
|
+
code: "DISPLAY_INVALID",
|
|
125
|
+
message: `The comparison for "${key}" needs one or two distinct drill fields.`,
|
|
126
|
+
path: [...pathToOption, key]
|
|
127
|
+
}));
|
|
128
|
+
return [{
|
|
129
|
+
code: "DISPLAY_INVALID",
|
|
130
|
+
message: `A ${kind}'s ${name} is ${TYPES[type].takes}.`,
|
|
131
|
+
path: pathToOption
|
|
132
|
+
}];
|
|
133
|
+
});
|
|
135
134
|
}
|
|
136
135
|
/**
|
|
137
136
|
* A widget's options as its kind reads them: each option it knows, when it is of its type. A
|
|
@@ -150,30 +149,6 @@ function read(options, display) {
|
|
|
150
149
|
return value === void 0 ? [] : [[name, value]];
|
|
151
150
|
}));
|
|
152
151
|
}
|
|
153
|
-
/** An option as an object holds it: none when it has no such option, which is not the same as holding null. */
|
|
154
|
-
const held = (display, option) => Object.hasOwn(display, option) ? { is: display[option] ?? null } : null;
|
|
155
|
-
/**
|
|
156
|
-
* What an edit did wrong to a display: each option of the wrong type that the edit set or
|
|
157
|
-
* changed, at `widgets.<id>.display.<option>`. Only what the edit touched is checked: an option
|
|
158
|
-
* stored before options were typed stays as it is, so it never blocks an edit of something
|
|
159
|
-
* else, and replaying a draft's own commands never refuses one that was accepted.
|
|
160
|
-
*/
|
|
161
|
-
function editedDisplayIssues(before, after) {
|
|
162
|
-
return Object.entries(after.widgets).flatMap(([id, widget]) => {
|
|
163
|
-
const was = before.widgets[id]?.display;
|
|
164
|
-
const old = isRecord(was) ? was : {};
|
|
165
|
-
const now = widget.display;
|
|
166
|
-
return widgetDisplayIssues(widget, [
|
|
167
|
-
"widgets",
|
|
168
|
-
id,
|
|
169
|
-
"display"
|
|
170
|
-
]).filter((found) => {
|
|
171
|
-
const option = String(found.path.at(-1));
|
|
172
|
-
const [set, had] = isRecord(now) ? [held(now, option), held(old, option)] : [now, was];
|
|
173
|
-
return canonical(set ?? null) !== canonical(had ?? null);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
152
|
/** The options every widget takes, whatever draws it: `keepDateRange` and `empty`, and no option of any one kind. */
|
|
178
153
|
const sharedDisplay = (display) => read(SHARED, display);
|
|
179
|
-
export { DISPLAY_HELP, DISPLAY_OPTIONS, displayIssues, displayOf,
|
|
154
|
+
export { DISPLAY_HELP, DISPLAY_OPTIONS, displayIssues, displayOf, isRecord, sharedDisplay };
|
|
@@ -12,6 +12,8 @@ export type SqlType = "text" | "float" | "boolean" | "numeric" | "bigint" | "dat
|
|
|
12
12
|
*/
|
|
13
13
|
export interface Dialect {
|
|
14
14
|
readonly id: "postgres" | "sqlite";
|
|
15
|
+
/** Supports GROUPING SETS and GROUPING() for one-statement top groups, Other and the total. */
|
|
16
|
+
readonly groupingSets?: true;
|
|
15
17
|
compile(fragment: Fragment): Sql;
|
|
16
18
|
cast(value: Fragment, type: SqlType): Fragment;
|
|
17
19
|
/** Unicode simple case folding, from core's table. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { offeredMembers, trendDimension } from "../query/drill/fields.mjs";
|
|
1
2
|
import { EngineError } from "../error/refusal.mjs";
|
|
2
3
|
import { limitedDimensions, rankQuery, segmentCuts } from "../query/segments.mjs";
|
|
3
|
-
import { offeredMembers, trendDimension } from "../query/drill/fields.mjs";
|
|
4
4
|
import { formulaParts, lineScopes, measuresOnly, scopeSteps, scopedLines } from "../query/drill/scopes.mjs";
|
|
5
5
|
import { keptPath, pathFields, stepMembers } from "../query/drill/steps.mjs";
|
|
6
6
|
import { trendQuery } from "../query/drill/time.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readsTotal } from "../result/calc.mjs";
|
|
2
2
|
import { canonical } from "../value/canonical.mjs";
|
|
3
3
|
import { otherOf, restriction } from "./other.mjs";
|
|
4
|
-
import { ranked, readGroups, readSeries } from "./rank.mjs";
|
|
4
|
+
import { rankOrder, ranked, readGroups, readSeries } from "./rank.mjs";
|
|
5
5
|
import { both, levelRows } from "./reader.mjs";
|
|
6
6
|
import { bucketRefs, refsOf, totalRefs } from "./refs.mjs";
|
|
7
7
|
import { fill, perBucketRows, sortSplit, withCalcs } from "./shape.mjs";
|
|
@@ -99,6 +99,10 @@ const NOT_RANKED = {
|
|
|
99
99
|
async function answered(pass) {
|
|
100
100
|
const { query } = pass;
|
|
101
101
|
const grouped = (query.dimensions ?? []).length > 0;
|
|
102
|
+
if (grouped) {
|
|
103
|
+
const combined = await partitioned(pass);
|
|
104
|
+
if (combined !== void 0) return combined;
|
|
105
|
+
}
|
|
102
106
|
if (grouped && totalsInGroups(pass)) {
|
|
103
107
|
const read = await readGroups(pass, true);
|
|
104
108
|
const { refs, own, ...totals } = await totalsFrom(pass, read.total === void 0 ? [] : [read.total]);
|
|
@@ -125,6 +129,34 @@ async function answered(pass) {
|
|
|
125
129
|
...grouped ? { groups } : {}
|
|
126
130
|
};
|
|
127
131
|
}
|
|
132
|
+
/** A limited, uncut breakdown whose ranking, Other and total cover the same population. */
|
|
133
|
+
function partitionLimit({ query, whole, within, input }) {
|
|
134
|
+
if (whole !== void 0 || within !== void 0 || query.time?.grain !== void 0) return;
|
|
135
|
+
const capped = query.limit !== void 0 && query.limit <= (input.maxRows ?? Infinity);
|
|
136
|
+
return query.total === true && query.other === true && capped ? query.limit : void 0;
|
|
137
|
+
}
|
|
138
|
+
async function partitioned(pass) {
|
|
139
|
+
const { query, reads } = pass;
|
|
140
|
+
const limit = partitionLimit(pass);
|
|
141
|
+
if (reads.partition === void 0 || limit === void 0) return;
|
|
142
|
+
const order = rankOrder(pass);
|
|
143
|
+
if (order === void 0) return;
|
|
144
|
+
const parts = await reads.partition(order, limit);
|
|
145
|
+
const { refs, totals } = await totalsFrom(pass, parts.total === void 0 ? [] : [parts.total]);
|
|
146
|
+
const r = await ranked(pass, refs, {
|
|
147
|
+
groups: parts.rows,
|
|
148
|
+
order
|
|
149
|
+
});
|
|
150
|
+
const other = parts.other === void 0 ? {} : { other: perBucketRows(query, [parts.other], (b) => bucketRefs(refs, b, false)) };
|
|
151
|
+
return {
|
|
152
|
+
answer: {
|
|
153
|
+
rows: keptRows(r),
|
|
154
|
+
...totals === void 0 ? {} : { totals },
|
|
155
|
+
...other
|
|
156
|
+
},
|
|
157
|
+
groups: r.kept.map((g) => g.key)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
128
160
|
/**
|
|
129
161
|
* The read besides the totals: the groups (of a time series, with its rows by bucket, when
|
|
130
162
|
* every measure merges), the one row of a query with neither, or nothing yet.
|
|
@@ -97,6 +97,7 @@ const DATE_PARTS = {
|
|
|
97
97
|
const recheck = (test) => sql`(nullif(${test}, FALSE) IS NOT NULL)`;
|
|
98
98
|
const postgres = {
|
|
99
99
|
id: "postgres",
|
|
100
|
+
groupingSets: true,
|
|
100
101
|
compile: compilePostgres,
|
|
101
102
|
cast: (value, type) => sql`CAST(${value} AS ${keyword(TYPES[type])})`,
|
|
102
103
|
fold: (text) => sql`${keyword(FOLD_FUNCTION)}(${text})`,
|
|
@@ -61,6 +61,10 @@ export type Reads = {
|
|
|
61
61
|
* and a time series its groups (`Level.series`).
|
|
62
62
|
*/
|
|
63
63
|
windowTotals: boolean;
|
|
64
|
+
/** Named groups, Other and the whole population aggregated directly from the contributing rows. */
|
|
65
|
+
partition?: (order: readonly OrderBy[], limit: number) => Promise<LevelRead & {
|
|
66
|
+
other?: Decoded;
|
|
67
|
+
}>;
|
|
64
68
|
/** Other as the total less the kept groups, column by column, when every measure adds up. */
|
|
65
69
|
lessKept?: (total: Decoded, kept: readonly (readonly unknown[])[]) => Decoded;
|
|
66
70
|
/**
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { refuseNaN } from "./nan.mjs";
|
|
2
|
+
import { layoutOf, read } from "./read.mjs";
|
|
3
|
+
import { decodeRow } from "./shape.mjs";
|
|
4
|
+
import { ident, join, sql } from "./sql.mjs";
|
|
5
|
+
import { keyFill, orderSql } from "./statement.mjs";
|
|
6
|
+
import { positions } from "./two-step.mjs";
|
|
7
|
+
// src/engine/sql-partition.ts
|
|
8
|
+
/** Rank just the keys, then aggregate the named groups, the remainder and the total in one pass. */
|
|
9
|
+
function partitionSql({ b, p }, order, limit) {
|
|
10
|
+
const keys = p.keys.map((_, i) => ident("kept", `k${i}`));
|
|
11
|
+
const names = p.keys.map((k, i) => sql`${k.sql} AS ${ident(`k${i}`)}`);
|
|
12
|
+
const ranked = sql`SELECT ${join(names)}, TRUE AS named FROM ${p.keyed} WHERE ${p.where}
|
|
13
|
+
${positions(keys.length)} ORDER BY ${join(order.map((o) => orderSql(p, o)))} LIMIT ${limit}`;
|
|
14
|
+
const matches = p.keys.map((k, i) => {
|
|
15
|
+
const key = ident("kept", `k${i}`);
|
|
16
|
+
const fill = keyFill(b, k.type);
|
|
17
|
+
return sql`((${key} IS NULL) = (${k.sql} IS NULL) AND COALESCE(${key}, ${fill}) = COALESCE(${k.sql}, ${fill}))`;
|
|
18
|
+
});
|
|
19
|
+
const group = [ident("kept", "named"), ...keys];
|
|
20
|
+
const cells = [
|
|
21
|
+
...group,
|
|
22
|
+
...p.keys.flatMap((k) => k.label === void 0 ? [] : [k.label]),
|
|
23
|
+
...p.measures.flatMap((m) => m.sql)
|
|
24
|
+
];
|
|
25
|
+
if (p.nan !== void 0) cells.push(p.nan.agg);
|
|
26
|
+
return sql`SELECT GROUPING(kept.named), ${join(cells)} FROM ${p.keyed}
|
|
27
|
+
LEFT JOIN (${ranked}) AS kept ON ${join(matches, sql` AND `)}
|
|
28
|
+
WHERE ${p.where} GROUP BY GROUPING SETS ((${join(group)}), ()) HAVING ${p.count} > 0`;
|
|
29
|
+
}
|
|
30
|
+
async function readPartition(pass, order, limit) {
|
|
31
|
+
const result = { rows: [] };
|
|
32
|
+
const layout = layoutOf(pass, pass.p, {
|
|
33
|
+
keys: true,
|
|
34
|
+
bucket: false
|
|
35
|
+
});
|
|
36
|
+
for (const raw of await read(pass, partitionSql(pass, order, limit))) {
|
|
37
|
+
if (pass.p.nan !== void 0) refuseNaN(raw.at(-1));
|
|
38
|
+
const group = decodeRow(layout, raw.slice(2, pass.p.nan === void 0 ? void 0 : -1));
|
|
39
|
+
if (Number(raw[0]) === 1) result.total = group;
|
|
40
|
+
else if (raw[1] === null) result.other = group;
|
|
41
|
+
else result.rows.push(group);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
export { readPartition };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { columnsLess } from "./numbers.mjs";
|
|
2
2
|
import { measureLayout, readLevel } from "./read.mjs";
|
|
3
3
|
import { decodeCells } from "./shape.mjs";
|
|
4
|
+
import { readPartition } from "./sql-partition.mjs";
|
|
4
5
|
// src/engine/sql-reads.ts
|
|
5
6
|
/**
|
|
6
7
|
* The SQL reads of one query: every level a statement, with the shapes SQL gives besides:
|
|
@@ -9,6 +10,7 @@ import { decodeCells } from "./shape.mjs";
|
|
|
9
10
|
*/
|
|
10
11
|
function sqlReads(pass) {
|
|
11
12
|
const { p } = pass;
|
|
13
|
+
const additive = p.measures.every((m) => m.additive === true);
|
|
12
14
|
const lessKept = (total, kept) => {
|
|
13
15
|
const raw = columnsLess(total.raw, kept);
|
|
14
16
|
return {
|
|
@@ -21,8 +23,9 @@ function sqlReads(pass) {
|
|
|
21
23
|
level: (level) => readLevel(pass, level),
|
|
22
24
|
ranks: (index) => p.measures[index]?.order !== void 0,
|
|
23
25
|
windowTotals: p.measures.every((m) => m.parts !== void 0),
|
|
26
|
+
...pass.b.dialect.groupingSets === true && p.staged === void 0 && !additive ? { partition: (order, limit) => readPartition(pass, order, limit) } : {},
|
|
24
27
|
narrows: p.nan === void 0,
|
|
25
|
-
...
|
|
28
|
+
...additive ? { lessKept } : {}
|
|
26
29
|
};
|
|
27
30
|
}
|
|
28
31
|
export { sqlReads };
|
|
@@ -38,17 +38,17 @@ function plainMatch(b, p, keys) {
|
|
|
38
38
|
const match = p.keys.map((k, i) => sql`${ident("kept", `k${i}`)} IS NOT DISTINCT FROM ${k.sql}`);
|
|
39
39
|
return sql`EXISTS (SELECT 1 FROM (VALUES ${join(rows)}) AS kept(${join(names)}) WHERE ${and(match)})`;
|
|
40
40
|
}
|
|
41
|
+
const keyFill = (b, type) => b.dialect.cast(sql`${FILL[type]}`, TYPES[type]);
|
|
41
42
|
function hashedMatch(b, p, keys) {
|
|
42
|
-
const fill = (type) => b.dialect.cast(sql`${FILL[type]}`, TYPES[type]);
|
|
43
43
|
const rows = keys.map((key) => {
|
|
44
44
|
const cells = p.keys.flatMap((k, i) => {
|
|
45
45
|
const value = key[i] ?? null;
|
|
46
|
-
return [value === null ? sql`TRUE` : sql`FALSE`, value === null ?
|
|
46
|
+
return [value === null ? sql`TRUE` : sql`FALSE`, value === null ? keyFill(b, k.type) : b.dialect.cast(sql`${value}`, TYPES[k.type])];
|
|
47
47
|
});
|
|
48
48
|
return sql`(${join(cells)})`;
|
|
49
49
|
});
|
|
50
50
|
const names = p.keys.flatMap((_k, i) => [ident(`n${i}`), ident(`k${i}`)]);
|
|
51
|
-
const match = p.keys.flatMap((k, i) => [sql`${ident("kept", `n${i}`)} = (${k.sql} IS NULL)`, sql`${ident("kept", `k${i}`)} = COALESCE(${k.sql}, ${
|
|
51
|
+
const match = p.keys.flatMap((k, i) => [sql`${ident("kept", `n${i}`)} = (${k.sql} IS NULL)`, sql`${ident("kept", `k${i}`)} = COALESCE(${k.sql}, ${keyFill(b, k.type)})`]);
|
|
52
52
|
return sql`EXISTS (SELECT 1 FROM (VALUES ${join(rows)}) AS kept(${join(names)}) WHERE ${and(match)})`;
|
|
53
53
|
}
|
|
54
54
|
const DIR = {
|
|
@@ -109,4 +109,4 @@ function groupedSql(b, p, level) {
|
|
|
109
109
|
const from = fromOf(p, level, level.keys || level.restrict !== void 0 ? p.keyed : p.from);
|
|
110
110
|
return sql`SELECT ${join(select)} FROM ${from} WHERE ${and([p.where, ...restrict])}${rest}`;
|
|
111
111
|
}
|
|
112
|
-
export { levelSql };
|
|
112
|
+
export { keyFill, levelSql, orderSql };
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
|
|
6
6
|
* against the files and prints the new value when they change.
|
|
7
7
|
*/
|
|
8
|
-
export declare const ENGINE_VERSION = "
|
|
8
|
+
export declare const ENGINE_VERSION = "f390ec5ebe464f91";
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
|
|
7
7
|
* against the files and prints the new value when they change.
|
|
8
8
|
*/
|
|
9
|
-
const ENGINE_VERSION = "
|
|
9
|
+
const ENGINE_VERSION = "f390ec5ebe464f91";
|
|
10
10
|
export { ENGINE_VERSION };
|
|
@@ -135,7 +135,7 @@ export declare const DRILL_REASONS: {
|
|
|
135
135
|
/** A dashboard edit the document reducer refuses. */
|
|
136
136
|
export declare const DOCUMENT_REFUSALS: {
|
|
137
137
|
readonly CONTROL_EXISTS: "A control with that id already exists.";
|
|
138
|
-
readonly DOCUMENT_INVALID: "A
|
|
138
|
+
readonly DOCUMENT_INVALID: "A dashboard document does not match its schema, or a code-defined dashboard has a display option its widget or query cannot use.";
|
|
139
139
|
readonly DOCUMENT_TOO_NEW: "A dashboard document was written by a newer version of the library than this one.";
|
|
140
140
|
readonly CONTROL_UNKNOWN: "The edit names a control that does not exist.";
|
|
141
141
|
readonly DISPLAY_INVALID: "An edit sets a widget's display option to the wrong type for its kind (a line's colors that is not a map of colours). Named in the issues of EDIT_REFUSED; the reducer itself applies any display, so a draft's stored commands replay.";
|
|
@@ -113,7 +113,7 @@ const DRILL_REASONS = {
|
|
|
113
113
|
/** A dashboard edit the document reducer refuses. */
|
|
114
114
|
const DOCUMENT_REFUSALS = {
|
|
115
115
|
CONTROL_EXISTS: "A control with that id already exists.",
|
|
116
|
-
DOCUMENT_INVALID: "A
|
|
116
|
+
DOCUMENT_INVALID: "A dashboard document does not match its schema, or a code-defined dashboard has a display option its widget or query cannot use.",
|
|
117
117
|
DOCUMENT_TOO_NEW: "A dashboard document was written by a newer version of the library than this one.",
|
|
118
118
|
CONTROL_UNKNOWN: "The edit names a control that does not exist.",
|
|
119
119
|
DISPLAY_INVALID: "An edit sets a widget's display option to the wrong type for its kind (a line's colors that is not a map of colours). Named in the issues of EDIT_REFUSED; the reducer itself applies any display, so a draft's stored commands replay.",
|
package/dist/core/index.d.mts
CHANGED
|
@@ -7,13 +7,13 @@ import { DimensionId, JoinedDimensionId, MeasureId, MemberId, ModelError, OwnDim
|
|
|
7
7
|
import { DimensionHints, Noun, NumberFormat, RecordsHint, Tone } from "./model/hints.mjs";
|
|
8
8
|
import { MemberRef, ResolvedDimension, parseMemberId, recordDimensions, resolveDimension, resolveMeasure } from "./model/member.mjs";
|
|
9
9
|
import { Moment, isZone, momentMicros } from "./time/temporal.mjs";
|
|
10
|
-
import { parseTextTime } from "./time/text-time.mjs";
|
|
10
|
+
import { lastIncludedMillisecond, parseTextTime } from "./time/text-time.mjs";
|
|
11
11
|
import { MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, Micros, formatTextTime, parseDate, parseNaiveTime } from "./time/instant.mjs";
|
|
12
12
|
import { bucketLabel, bucketLabels, bucketStart, nextBucketStart, shiftBucket } from "./time/bucket.mjs";
|
|
13
13
|
import { DatePart, DimensionDef, EXPR_FUNCTIONS, Expr, ExprCondition, ExprFunction, JoinDef, MeasureDef, MemberMeta, Model, Numeric, PolicyBinding, PolicyFilter, PolicyRule, Relationship, RowPolicy, SourceDef, TenantBinding, TimeStorage, Unit, ViewerMatch } from "./model/types.mjs";
|
|
14
14
|
import { LinearTerm, linearTerms } from "./model/validate/expr.mjs";
|
|
15
15
|
import { validateModel } from "./model/validate/index.mjs";
|
|
16
|
-
import { Cuts, Drill, DrillCan, DrillField, DrillOrigin, DrillSemantics, DrillState, DrillStep, DrillView, MAX_DRILL_STEPS, PinnedExecution, Selection } from "./query/drill/types.mjs";
|
|
16
|
+
import { Cuts, Drill, DrillCan, DrillField, DrillOrigin, DrillSemantics, DrillState, DrillStep, DrillView, MAX_DRILL_ROWS, MAX_DRILL_STEPS, PinnedExecution, Selection } from "./query/drill/types.mjs";
|
|
17
17
|
import { ColumnRole, Mark, Receipt, RecordColumn, Result, ResultCell, ResultColumn, ResultRows, TimeAxis, TimeBucket } from "./result/types.mjs";
|
|
18
18
|
import { Span, inSpan, resolveRange } from "./time/range.mjs";
|
|
19
19
|
import { NaiveRule, OffsetSegment, offsetSegments, resolveNaive, startOfDate } from "./time/zone.mjs";
|
|
@@ -21,7 +21,8 @@ import { viaJoins } from "./model/validate/via.mjs";
|
|
|
21
21
|
import { BoundRule, bindFilter, bindPolicy, namedPolicy, viewerValues } from "./policy/bind.mjs";
|
|
22
22
|
import { Command, CommandBody, CommandId, Display, Doc, LayoutItem, Scope, Tab, TabId, Widget, WidgetId, emptyDoc } from "./document/types.mjs";
|
|
23
23
|
import { Change, Placement, WidgetPart, changedWidget, diffDocs, markShifted, placementOf, widgetDiff } from "./document/diff.mjs";
|
|
24
|
-
import { DISPLAY_HELP, DISPLAY_OPTIONS, DisplayKind, DisplayOf, SharedDisplay, displayIssues, displayOf,
|
|
24
|
+
import { ComparisonFields, DISPLAY_HELP, DISPLAY_OPTIONS, DisplayKind, DisplayOf, SharedDisplay, displayIssues, displayOf, sharedDisplay } from "./document/display.mjs";
|
|
25
|
+
import { documentDisplayIssues, editedDisplayIssues } from "./document/display-validation.mjs";
|
|
25
26
|
import { GRID_COLUMNS, Gap, closeGaps, closeGapsCommands, freeSpot, layoutGaps, placeItem, repairLayout } from "./document/layout.mjs";
|
|
26
27
|
import { Outcome } from "./document/outcome.mjs";
|
|
27
28
|
import { lockChanged, reduce, reduceAll } from "./document/reduce.mjs";
|
|
@@ -46,7 +47,7 @@ import { CalcAlias, Calendar, Cell, Control, ControlId, DateRange, DimensionAlia
|
|
|
46
47
|
import "./time/index.mjs";
|
|
47
48
|
import { ItemLinks, ItemLinksFor, LINK_PART, itemLink, linkTemplateIssues } from "./query/drill/links.mjs";
|
|
48
49
|
import { ApiError, CONTRACT_VERSION, CoreContract, DashboardListResponse, DashboardResponse, DraftResponse, MetaJoin, MetaMember, MetaResponse, PublishResponse, QueryAnswer, QueryLine, RecordsResponse, TileAnswer, TileLine, TileRequest, TileResult, TilesRequest, ValidateResponse, ValuesResponse } from "./types/api.mjs";
|
|
49
|
-
import { AnswerDrill, ClosedRow, DrillAbilities, DrillAnswer, DrillBody, DrillCrumb, DrillExplanationView, DrillGroupedView, DrillItem, DrillItemsView, DrillOperand, DrillSummary, ItemColumn, SealedAnswer } from "./types/drill-api.mjs";
|
|
50
|
+
import { AnswerDrill, ClosedRow, DrillAbilities, DrillAnswer, DrillBody, DrillComparisonView, DrillCrumb, DrillExplanationView, DrillGroupedView, DrillItem, DrillItemsView, DrillOperand, DrillSummary, ItemColumn, SealedAnswer } from "./types/drill-api.mjs";
|
|
50
51
|
import { CoreApi, CreateDash, Dash, EndpointsByPath, HeadersLike, PluginEndpoints, PluginErrorCodes, ServerCall, ServerCallInput, ServerCalls, UniqueIds } from "./types/infer.mjs";
|
|
51
52
|
import { CodeDashboard, DashOptions, SecondaryStorage } from "./types/options.mjs";
|
|
52
53
|
import { addsUp } from "./result/additive.mjs";
|
|
@@ -64,4 +65,4 @@ import { Author, DashAdapter, DashboardHead, DashboardReader, DashboardStore, Da
|
|
|
64
65
|
import { CanFn, Channel, Principal, Resource, TenantKeysOf, Verb, Viewer, ViewerFor, principalTenant } from "./types/viewer.mjs";
|
|
65
66
|
import { canonical } from "./value/canonical.mjs";
|
|
66
67
|
import { fold, foldingPairs } from "./value/casefold.mjs";
|
|
67
|
-
export { type AccessParts, type Alias, type AnswerDrill, type ApiError, type AssertionContext, type Author, type Awaitable, BASE_ERROR_CODES, type BoundFilter, type BoundPolicy, type BoundPolicyFilter, type BoundRule, CATALOG, CONTRACT_VERSION, type CalcAlias, type Calendar, type CanFn, type Catalog, type CatalogIssueCode, type Cell, type Change, type Channel, type ClosedRow, type Closure, type CodeDashboard, type Column, type ColumnRole, type ColumnType, type Command, type CommandBody, type CommandId, type ComposeCtx, type ComposeDelta, type ComposedQuery, type ComposedTile, type CompositionPolicy, type ConnectionId, type Control, type ControlId, type CoreApi, type CoreContract, type CreateDash, type CustomSource, type Cuts, DEFAULT_COMPOSITION_POLICY, DISPLAY_HELP, DISPLAY_OPTIONS, DRILL_REASONS, type Dash, type DashAdapter, type DashEndpoint, type DashHook, type DashOptions, type DashPlugin, type DashboardHead, type DashboardListResponse, type DashboardReader, type DashboardResponse, type DashboardStore, type DashboardSummary, type DatePart, type DateRange, type DbSchema, type DimensionAlias, type DimensionCut, type DimensionDef, type DimensionHints, type DimensionId, type DimensionName, type Display, type DisplayKind, type DisplayOf, type Doc, type DocumentRefusalCode, type DocumentSlice, type Draft, type DraftResponse, type DraftTarget, type Drill, type DrillAbilities, type DrillAnswer, type DrillBody, type DrillCan, type DrillCrumb, type DrillExplanationView, type DrillField, type DrillGroupedView, type DrillItem, type DrillItemsView, type DrillOperand, type DrillOrigin, type DrillReason, type DrillSemantics, type DrillState, type DrillStep, type DrillSummary, type DrillView, EXACT_LIMIT, EXPR_FUNCTIONS, type EncodeOptions, type EndpointAccess, type EndpointContext, type EndpointsByPath, type EntryId, type Exact, type ExactSum, type Explanation, type ExplicitRange, type Expr, type ExprCondition, type ExprFunction, type Field, type FieldType, type Format, type Formula, type FormulaNode, type FormulaRef, GRID_COLUMNS, type Gap, type Grain, type GroupedRead, type HeadersLike, type HookContext, type HostCell, type HostRows, type IanaZone, type IntrospectingConnection, type IsoInstant, type Issue, type IssueCode, type ItemColumn, type ItemLinks, type ItemLinksFor, type JoinDef, type JoinName, type JoinedDimensionId, LINK_PART, type LayoutItem, type Leaf, type LinearTerm, type LockEntry, MAX_DRILL_STEPS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, type Mark, type MeasureAlias, type MeasureDef, type MeasureId, type MeasureName, type MemberId, type MemberMeta, type MemberRef, type MetaJoin, type MetaMember, type MetaResponse, type Micros, type Model, ModelError, type ModelIssueCode, type Moment, NEGATION_OF, NEGATIVE_OPS, NULL_OPS, type NaiveRule, type NegativeOp, type NodeId, type Noun, type NullOp, type NumberFormat, type Numeric, type OffsetSegment, type Op, type Operands, type Outcome, type OverlapPart, type OwnDimensionId, POSITIVE_OPS, type PageRequest, type Param, type Picks, type PinnedExecution, type Placement, type PluginEndpoints, type PluginErrorCodes, type PolicyBinding, type PolicyFilter, type PolicyName, type PolicyRule, type PositiveOp, type Preview, type Primitive, type Principal, type PublishResponse, type Published, type QueryAnswer, type QueryConnection, type QueryCtx, type QueryLine, QueryReferenceError, type QueryRefusalCode, type RawError, type RawLevels, type RawResult, type ReadContext, type ReadField, type ReadFilter, type ReadMeasure, type ReadSession, type Receipt, type RecordColumn, type RecordPage, type Recorded, type RecordsHint, type RecordsRead, type RecordsResponse, type RefOf, type Refusal, type Relationship, type RelativeRange, type Replayed, type RequiredEntry, type ResolvedDimension, type ResolvedRange, type Resource, type Result, type ResultCell, type ResultColumn, type ResultRows, type ResultWarningCode, type Row, type RowPolicy, type RunOptions, type RuntimeErrorCode, type SchemaDriver, type Scope, type ScopeCoverage, type SealedAnswer, type SecondaryStorage, type Selection, type SemanticProvider, type ServerCall, type ServerCallInput, type ServerCalls, type SharedDisplay, type SourceDef, type SourceName, type SourceNameOf, type Span, type Sql, type StoreDialect, type StoredFilter, type StoredFormulaNode, type StoredLockEntry, type StoredQuery, type StoredVersion, TABLES, type Tab, type TabId, type TableCheck, type TableDef, type TableName, type Tenant, type TenantBinding, type TenantKey, type TenantKeysOf, type TileAnswer, type TileInput, type TileLine, type TileRef, type TileRequest, type TileResult, type TilesRequest, type TimeAxis, type TimeBucket, type TimeStorage, type Token, type Tone, type TypedFilter, type TypedQuery, type UniqueIds, type Unit, type UnpublishedDraft, VIEW_PREFIX, type ValidateResponse, type ValueLeaf, type ValuesResponse, type VariableLeaf, type Verb, type VersionEntry, type ViewState, type Viewer, type ViewerFor, type ViewerLeaf, type ViewerMatch, type ViewerRef, type WeekStart, type Where, type Widget, type WidgetId, type WidgetPart, type WireFilter, type WireQuery, addsUp, bindFilter, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketLabels, bucketStart, canonical, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonQuery, comparisonSpan, composeTile, createDashEndpoint, createTable, defineErrorCodes, defineModel, describeQueries, diffDocs, displayIssues, displayOf, divideExact, documentDisplayIssues, documentLock, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entryAliases, fold, foldingPairs, formatExact, formatTextTime, formulaRefs, freeSpot, inSpan, isBound, isDateRange, isLeaf, isMark, isValuePick, isZone, itemLink, layoutGaps, linearTerms, linkTemplateIssues, lockChanged, markShifted, markedRows, memberLabel, momentMicros, namedPolicy, nextBucketStart, offsetSegments, parseDate, parseExact, parseMemberId, parseNaiveTime, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, repairLayout, replay, resolveDimension, resolveMeasure, resolveNaive, resolveRange, resultColumns, roleOf, rowValue, ruleMatches, schemaChecks, schemaStatements, selectRule, shareOf, sharedDisplay, shiftBucket, shiftInstant, smallestFor, startOfDate, stepCommands, stepMoves, storedExact, stripIds, sumLinear, tileInputs, timeAxis, toWire, validateModel, viaJoins, viewFor, viewLayout, viewerValues, widgetDiff, withTime, withView };
|
|
68
|
+
export { type AccessParts, type Alias, type AnswerDrill, type ApiError, type AssertionContext, type Author, type Awaitable, BASE_ERROR_CODES, type BoundFilter, type BoundPolicy, type BoundPolicyFilter, type BoundRule, CATALOG, CONTRACT_VERSION, type CalcAlias, type Calendar, type CanFn, type Catalog, type CatalogIssueCode, type Cell, type Change, type Channel, type ClosedRow, type Closure, type CodeDashboard, type Column, type ColumnRole, type ColumnType, type Command, type CommandBody, type CommandId, type ComparisonFields, type ComposeCtx, type ComposeDelta, type ComposedQuery, type ComposedTile, type CompositionPolicy, type ConnectionId, type Control, type ControlId, type CoreApi, type CoreContract, type CreateDash, type CustomSource, type Cuts, DEFAULT_COMPOSITION_POLICY, DISPLAY_HELP, DISPLAY_OPTIONS, DRILL_REASONS, type Dash, type DashAdapter, type DashEndpoint, type DashHook, type DashOptions, type DashPlugin, type DashboardHead, type DashboardListResponse, type DashboardReader, type DashboardResponse, type DashboardStore, type DashboardSummary, type DatePart, type DateRange, type DbSchema, type DimensionAlias, type DimensionCut, type DimensionDef, type DimensionHints, type DimensionId, type DimensionName, type Display, type DisplayKind, type DisplayOf, type Doc, type DocumentRefusalCode, type DocumentSlice, type Draft, type DraftResponse, type DraftTarget, type Drill, type DrillAbilities, type DrillAnswer, type DrillBody, type DrillCan, type DrillComparisonView, type DrillCrumb, type DrillExplanationView, type DrillField, type DrillGroupedView, type DrillItem, type DrillItemsView, type DrillOperand, type DrillOrigin, type DrillReason, type DrillSemantics, type DrillState, type DrillStep, type DrillSummary, type DrillView, EXACT_LIMIT, EXPR_FUNCTIONS, type EncodeOptions, type EndpointAccess, type EndpointContext, type EndpointsByPath, type EntryId, type Exact, type ExactSum, type Explanation, type ExplicitRange, type Expr, type ExprCondition, type ExprFunction, type Field, type FieldType, type Format, type Formula, type FormulaNode, type FormulaRef, GRID_COLUMNS, type Gap, type Grain, type GroupedRead, type HeadersLike, type HookContext, type HostCell, type HostRows, type IanaZone, type IntrospectingConnection, type IsoInstant, type Issue, type IssueCode, type ItemColumn, type ItemLinks, type ItemLinksFor, type JoinDef, type JoinName, type JoinedDimensionId, LINK_PART, type LayoutItem, type Leaf, type LinearTerm, type LockEntry, MAX_DRILL_ROWS, MAX_DRILL_STEPS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, type Mark, type MeasureAlias, type MeasureDef, type MeasureId, type MeasureName, type MemberId, type MemberMeta, type MemberRef, type MetaJoin, type MetaMember, type MetaResponse, type Micros, type Model, ModelError, type ModelIssueCode, type Moment, NEGATION_OF, NEGATIVE_OPS, NULL_OPS, type NaiveRule, type NegativeOp, type NodeId, type Noun, type NullOp, type NumberFormat, type Numeric, type OffsetSegment, type Op, type Operands, type Outcome, type OverlapPart, type OwnDimensionId, POSITIVE_OPS, type PageRequest, type Param, type Picks, type PinnedExecution, type Placement, type PluginEndpoints, type PluginErrorCodes, type PolicyBinding, type PolicyFilter, type PolicyName, type PolicyRule, type PositiveOp, type Preview, type Primitive, type Principal, type PublishResponse, type Published, type QueryAnswer, type QueryConnection, type QueryCtx, type QueryLine, QueryReferenceError, type QueryRefusalCode, type RawError, type RawLevels, type RawResult, type ReadContext, type ReadField, type ReadFilter, type ReadMeasure, type ReadSession, type Receipt, type RecordColumn, type RecordPage, type Recorded, type RecordsHint, type RecordsRead, type RecordsResponse, type RefOf, type Refusal, type Relationship, type RelativeRange, type Replayed, type RequiredEntry, type ResolvedDimension, type ResolvedRange, type Resource, type Result, type ResultCell, type ResultColumn, type ResultRows, type ResultWarningCode, type Row, type RowPolicy, type RunOptions, type RuntimeErrorCode, type SchemaDriver, type Scope, type ScopeCoverage, type SealedAnswer, type SecondaryStorage, type Selection, type SemanticProvider, type ServerCall, type ServerCallInput, type ServerCalls, type SharedDisplay, type SourceDef, type SourceName, type SourceNameOf, type Span, type Sql, type StoreDialect, type StoredFilter, type StoredFormulaNode, type StoredLockEntry, type StoredQuery, type StoredVersion, TABLES, type Tab, type TabId, type TableCheck, type TableDef, type TableName, type Tenant, type TenantBinding, type TenantKey, type TenantKeysOf, type TileAnswer, type TileInput, type TileLine, type TileRef, type TileRequest, type TileResult, type TilesRequest, type TimeAxis, type TimeBucket, type TimeStorage, type Token, type Tone, type TypedFilter, type TypedQuery, type UniqueIds, type Unit, type UnpublishedDraft, VIEW_PREFIX, type ValidateResponse, type ValueLeaf, type ValuesResponse, type VariableLeaf, type Verb, type VersionEntry, type ViewState, type Viewer, type ViewerFor, type ViewerLeaf, type ViewerMatch, type ViewerRef, type WeekStart, type Where, type Widget, type WidgetId, type WidgetPart, type WireFilter, type WireQuery, addsUp, bindFilter, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketLabels, bucketStart, canonical, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonQuery, comparisonSpan, composeTile, createDashEndpoint, createTable, defineErrorCodes, defineModel, describeQueries, diffDocs, displayIssues, displayOf, divideExact, documentDisplayIssues, documentLock, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entryAliases, fold, foldingPairs, formatExact, formatTextTime, formulaRefs, freeSpot, inSpan, isBound, isDateRange, isLeaf, isMark, isValuePick, isZone, itemLink, lastIncludedMillisecond, layoutGaps, linearTerms, linkTemplateIssues, lockChanged, markShifted, markedRows, memberLabel, momentMicros, namedPolicy, nextBucketStart, offsetSegments, parseDate, parseExact, parseMemberId, parseNaiveTime, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, repairLayout, replay, resolveDimension, resolveMeasure, resolveNaive, resolveRange, resultColumns, roleOf, rowValue, ruleMatches, schemaChecks, schemaStatements, selectRule, shareOf, sharedDisplay, shiftBucket, shiftInstant, smallestFor, startOfDate, stepCommands, stepMoves, storedExact, stripIds, sumLinear, tileInputs, timeAxis, toWire, validateModel, viaJoins, viewFor, viewLayout, viewerValues, widgetDiff, withTime, withView };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { BASE_ERROR_CODES, DRILL_REASONS, defineErrorCodes } from "./error/codes.mjs";
|
|
2
2
|
import { changedWidget, diffDocs, markShifted, placementOf, widgetDiff } from "./document/diff.mjs";
|
|
3
|
+
import { DISPLAY_HELP, DISPLAY_OPTIONS, displayIssues, displayOf, sharedDisplay } from "./document/display.mjs";
|
|
3
4
|
import { checkCatalog } from "./model/catalog/check.mjs";
|
|
4
5
|
import { describeQueries } from "./model/catalog/queries.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { policyBinding } from "./model/defaults.mjs";
|
|
7
|
+
import { documentDisplayIssues, editedDisplayIssues } from "./document/display-validation.mjs";
|
|
6
8
|
import { GRID_COLUMNS, closeGaps, closeGapsCommands, freeSpot, layoutGaps, placeItem, repairLayout } from "./document/layout.mjs";
|
|
7
9
|
import { lockChanged, reduce, reduceAll } from "./document/reduce.mjs";
|
|
8
10
|
import { commandWidget, replay } from "./document/replay.mjs";
|
|
9
11
|
import { readingOrder, stepCommands, stepMoves } from "./document/stacked.mjs";
|
|
10
12
|
import { emptyDoc } from "./document/types.mjs";
|
|
11
|
-
import {
|
|
13
|
+
import { ModelError, defineModel } from "./model/define.mjs";
|
|
12
14
|
import { VIEW_PREFIX, encodeView, viewFor, withView } from "./document/view.mjs";
|
|
13
15
|
import { smallestFor, viewLayout } from "./document/view-layout.mjs";
|
|
14
|
-
import {
|
|
16
|
+
import { parseMemberId, recordDimensions, resolveDimension, resolveMeasure } from "./model/member.mjs";
|
|
15
17
|
import { formatExact, parseExact } from "./exact/text.mjs";
|
|
16
18
|
import { EXACT_LIMIT, divideExact, storedExact } from "./exact/decimal.mjs";
|
|
17
19
|
import { rowValue, sumLinear } from "./exact/sum.mjs";
|
|
18
|
-
import { parseMemberId, recordDimensions, resolveDimension, resolveMeasure } from "./model/member.mjs";
|
|
19
20
|
import { EXPR_FUNCTIONS } from "./model/types.mjs";
|
|
20
21
|
import { linearTerms } from "./model/validate/expr.mjs";
|
|
21
22
|
import { validateModel } from "./model/validate/index.mjs";
|
|
@@ -33,12 +34,12 @@ import { changeOf, formulaRefs, shareOf } from "./query/formulas.mjs";
|
|
|
33
34
|
import { isDateRange, isValuePick, pickProblem } from "./query/picks.mjs";
|
|
34
35
|
import { QueryReferenceError, entryAliases, toWire } from "./query/to-wire.mjs";
|
|
35
36
|
import { LINK_PART, itemLink, linkTemplateIssues } from "./query/drill/links.mjs";
|
|
36
|
-
import { MAX_DRILL_STEPS } from "./query/drill/types.mjs";
|
|
37
|
+
import { MAX_DRILL_ROWS, MAX_DRILL_STEPS } from "./query/drill/types.mjs";
|
|
37
38
|
import { CONTRACT_VERSION } from "./types/api.mjs";
|
|
38
39
|
import { addsUp } from "./result/additive.mjs";
|
|
39
40
|
import { memberLabel, recordColumns, resultColumns, roleOf } from "./result/columns.mjs";
|
|
40
41
|
import { isMark, markedRows } from "./result/marks.mjs";
|
|
41
|
-
import { parseTextTime } from "./time/text-time.mjs";
|
|
42
|
+
import { lastIncludedMillisecond, parseTextTime } from "./time/text-time.mjs";
|
|
42
43
|
import { MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, formatTextTime, parseDate, parseNaiveTime } from "./time/instant.mjs";
|
|
43
44
|
import { offsetSegments, resolveNaive, startOfDate } from "./time/zone.mjs";
|
|
44
45
|
import { bucketLabel, bucketLabels, bucketStart, nextBucketStart, shiftBucket } from "./time/bucket.mjs";
|
|
@@ -51,4 +52,4 @@ import { createDashEndpoint } from "./types/plugin.mjs";
|
|
|
51
52
|
import { principalTenant } from "./types/viewer.mjs";
|
|
52
53
|
import { canonical } from "./value/canonical.mjs";
|
|
53
54
|
import { fold, foldingPairs } from "./value/casefold.mjs";
|
|
54
|
-
export { BASE_ERROR_CODES, CATALOG, CONTRACT_VERSION, DEFAULT_COMPOSITION_POLICY, DISPLAY_HELP, DISPLAY_OPTIONS, DRILL_REASONS, EXACT_LIMIT, EXPR_FUNCTIONS, GRID_COLUMNS, LINK_PART, MAX_DRILL_STEPS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, ModelError, NEGATION_OF, NEGATIVE_OPS, NULL_OPS, POSITIVE_OPS, QueryReferenceError, TABLES, VIEW_PREFIX, addsUp, bindFilter, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketLabels, bucketStart, canonical, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonQuery, comparisonSpan, composeTile, createDashEndpoint, createTable, defineErrorCodes, defineModel, describeQueries, diffDocs, displayIssues, displayOf, divideExact, documentDisplayIssues, documentLock, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entryAliases, fold, foldingPairs, formatExact, formatTextTime, formulaRefs, freeSpot, inSpan, isBound, isDateRange, isLeaf, isMark, isValuePick, isZone, itemLink, layoutGaps, linearTerms, linkTemplateIssues, lockChanged, markShifted, markedRows, memberLabel, momentMicros, namedPolicy, nextBucketStart, offsetSegments, parseDate, parseExact, parseMemberId, parseNaiveTime, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, repairLayout, replay, resolveDimension, resolveMeasure, resolveNaive, resolveRange, resultColumns, roleOf, rowValue, ruleMatches, schemaChecks, schemaStatements, selectRule, shareOf, sharedDisplay, shiftBucket, shiftInstant, smallestFor, startOfDate, stepCommands, stepMoves, storedExact, stripIds, sumLinear, tileInputs, timeAxis, toWire, validateModel, viaJoins, viewFor, viewLayout, viewerValues, widgetDiff, withTime, withView };
|
|
55
|
+
export { BASE_ERROR_CODES, CATALOG, CONTRACT_VERSION, DEFAULT_COMPOSITION_POLICY, DISPLAY_HELP, DISPLAY_OPTIONS, DRILL_REASONS, EXACT_LIMIT, EXPR_FUNCTIONS, GRID_COLUMNS, LINK_PART, MAX_DRILL_ROWS, MAX_DRILL_STEPS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, ModelError, NEGATION_OF, NEGATIVE_OPS, NULL_OPS, POSITIVE_OPS, QueryReferenceError, TABLES, VIEW_PREFIX, addsUp, bindFilter, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketLabels, bucketStart, canonical, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonQuery, comparisonSpan, composeTile, createDashEndpoint, createTable, defineErrorCodes, defineModel, describeQueries, diffDocs, displayIssues, displayOf, divideExact, documentDisplayIssues, documentLock, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entryAliases, fold, foldingPairs, formatExact, formatTextTime, formulaRefs, freeSpot, inSpan, isBound, isDateRange, isLeaf, isMark, isValuePick, isZone, itemLink, lastIncludedMillisecond, layoutGaps, linearTerms, linkTemplateIssues, lockChanged, markShifted, markedRows, memberLabel, momentMicros, namedPolicy, nextBucketStart, offsetSegments, parseDate, parseExact, parseMemberId, parseNaiveTime, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, repairLayout, replay, resolveDimension, resolveMeasure, resolveNaive, resolveRange, resultColumns, roleOf, rowValue, ruleMatches, schemaChecks, schemaStatements, selectRule, shareOf, sharedDisplay, shiftBucket, shiftInstant, smallestFor, startOfDate, stepCommands, stepMoves, storedExact, stripIds, sumLinear, tileInputs, timeAxis, toWire, validateModel, viaJoins, viewFor, viewLayout, viewerValues, widgetDiff, withTime, withView };
|
|
@@ -127,4 +127,4 @@ function lacking(what, keys) {
|
|
|
127
127
|
return [issue("MODEL_SHAPE", path, `${what} holds one of ${keys.join(", ")}.${meant(near)}`)];
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
export { byKey, byKind, fields, lacking, listOf, mapOf, orFalse, orWord, orWords, wordOrList };
|
|
130
|
+
export { byKey, byKind, fields, lacking, listOf, mapOf, nearest, orFalse, orWord, orWords, wordOrList };
|
|
@@ -10,6 +10,8 @@ export type DrillInput = {
|
|
|
10
10
|
drill: Drill;
|
|
11
11
|
readable: Readable;
|
|
12
12
|
clock: DrillClock;
|
|
13
|
+
/** A group comparison reads every line together. */
|
|
14
|
+
comparison?: true;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* The rows behind a drill, as a query with no grouping: the tile's own query (its filters,
|
|
@@ -71,7 +71,7 @@ function composeDrill(input) {
|
|
|
71
71
|
const [only, ...more] = parts;
|
|
72
72
|
const around = aroundCalcs(query);
|
|
73
73
|
const calc = (query.calc ?? []).filter((c) => !around.has(c.id));
|
|
74
|
-
checkLine(query, drill);
|
|
74
|
+
if (!input.comparison || drill.measure !== void 0) checkLine(query, drill);
|
|
75
75
|
const time = drilledTime(input.model, query, drill.steps, input.clock);
|
|
76
76
|
return {
|
|
77
77
|
kind: query.kind,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { formatExact } from "../../exact/text.mjs";
|
|
2
1
|
import { storedExact } from "../../exact/decimal.mjs";
|
|
2
|
+
import { formatExact } from "../../exact/text.mjs";
|
|
3
3
|
import { parseMemberId } from "../../model/member.mjs";
|
|
4
4
|
import { memberLabel } from "../../result/columns.mjs";
|
|
5
5
|
import { operandColumn } from "./operand.mjs";
|
|
@@ -101,6 +101,10 @@ export type DrillView = {
|
|
|
101
101
|
by: "breakdown";
|
|
102
102
|
member?: string;
|
|
103
103
|
search?: string;
|
|
104
|
+
} | {
|
|
105
|
+
by: "comparison";
|
|
106
|
+
member: string;
|
|
107
|
+
thenBy?: string;
|
|
104
108
|
} | {
|
|
105
109
|
by: "trend";
|
|
106
110
|
grain?: Grain;
|
|
@@ -109,6 +113,7 @@ export type DrillView = {
|
|
|
109
113
|
{
|
|
110
114
|
by: "items";
|
|
111
115
|
numerator?: true;
|
|
116
|
+
fields?: true;
|
|
112
117
|
} | {
|
|
113
118
|
by: "explanation";
|
|
114
119
|
};
|
|
@@ -138,6 +143,8 @@ export type Cuts = {
|
|
|
138
143
|
};
|
|
139
144
|
/** A path is at most this many selections; a deeper one is refused. */
|
|
140
145
|
export declare const MAX_DRILL_STEPS = 8;
|
|
146
|
+
/** Maximum number of rows a sealed answer can open, counted from the start of the answer. */
|
|
147
|
+
export declare const MAX_DRILL_ROWS = 1000;
|
|
141
148
|
/** A field a drill can be broken down by, as a viewer reads it. */
|
|
142
149
|
export type DrillField = {
|
|
143
150
|
id: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// src/query/drill/types.ts
|
|
2
2
|
/** A path is at most this many selections; a deeper one is refused. */
|
|
3
3
|
const MAX_DRILL_STEPS = 8;
|
|
4
|
-
|
|
4
|
+
/** Maximum number of rows a sealed answer can open, counted from the start of the answer. */
|
|
5
|
+
const MAX_DRILL_ROWS = 1e3;
|
|
6
|
+
export { MAX_DRILL_ROWS, MAX_DRILL_STEPS };
|