derive-dashboards 0.1.1 → 0.3.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/README.md +5 -3
- package/dist/cache.mjs +2 -1
- package/dist/cli/add.mjs +130 -0
- package/dist/cli/cli.mjs +14 -12
- package/dist/cli/config.mjs +12 -1
- package/dist/cli/doctor.mjs +162 -0
- package/dist/cli/init.mjs +3 -2
- package/dist/cli/json.mjs +21 -0
- package/dist/cli/layers.mjs +33 -0
- package/dist/core/document/display.d.mts +63 -0
- package/dist/core/document/display.mjs +139 -0
- package/dist/core/document/layout.mjs +1 -1
- package/dist/core/document/view-layout.d.mts +14 -0
- package/dist/core/document/view-layout.mjs +157 -0
- package/dist/core/engine/filter.mjs +2 -2
- package/dist/core/engine/leaf.mjs +9 -4
- package/dist/core/engine/members.mjs +1 -1
- package/dist/core/engine/version.d.mts +5 -4
- package/dist/core/engine/version.mjs +5 -4
- package/dist/core/error/codes.d.mts +4 -1
- package/dist/core/error/codes.mjs +4 -1
- package/dist/core/index.d.mts +12 -8
- package/dist/core/index.mjs +11 -7
- package/dist/core/model/member.mjs +5 -2
- package/dist/core/model/types.d.mts +13 -13
- package/dist/core/model/validate/drill.mjs +6 -15
- package/dist/core/model/validate/fields.mjs +130 -0
- package/dist/core/model/validate/index.mjs +11 -3
- package/dist/core/model/validate/known-members.mjs +133 -0
- package/dist/core/model/validate/known-nested.mjs +85 -0
- package/dist/core/model/validate/known.mjs +94 -0
- package/dist/core/model/validate/members.mjs +7 -4
- package/dist/core/model/validate/source.mjs +8 -1
- package/dist/core/policy/bind-query.d.mts +12 -0
- package/dist/core/policy/bind-query.mjs +53 -0
- package/dist/core/query/alias.mjs +11 -1
- package/dist/core/query/drill/selection.d.mts +7 -2
- package/dist/core/query/drill/selection.mjs +18 -15
- package/dist/core/query/filter.d.mts +6 -0
- package/dist/core/query/picks.d.mts +8 -2
- package/dist/core/query/picks.mjs +11 -4
- package/dist/core/query/segments.mjs +2 -1
- package/dist/core/result/columns.d.mts +10 -1
- package/dist/core/result/columns.mjs +27 -5
- package/dist/core/result/time-axis.d.mts +23 -0
- package/dist/core/result/time-axis.mjs +72 -0
- package/dist/core/result/types.d.mts +36 -1
- package/dist/core/schema/aliases.d.mts +7 -0
- package/dist/core/schema/aliases.mjs +77 -0
- package/dist/core/schema/answer-parts.mjs +23 -1
- package/dist/core/schema/answers.d.mts +204 -0
- package/dist/core/schema/answers.mjs +2 -0
- package/dist/core/schema/index.d.mts +3 -2
- package/dist/core/schema/index.mjs +3 -2
- package/dist/core/schema/query.d.mts +81 -0
- package/dist/core/schema/query.mjs +9 -5
- package/dist/core/schema/tools.d.mts +2 -0
- package/dist/core/schema/tools.mjs +27 -1
- package/dist/core/time/bucket.mjs +8 -2
- package/dist/core/types/api.d.mts +7 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/dashboards.mjs +4 -0
- package/dist/drill-change.mjs +1 -1
- package/dist/drill-seal.mjs +1 -0
- package/dist/editing.mjs +2 -2
- package/dist/endpoints/dashboards.mjs +17 -2
- package/dist/endpoints/index.d.mts +15 -2
- package/dist/endpoints/meta.mjs +10 -1
- package/dist/execute.mjs +32 -17
- package/dist/handler.mjs +5 -1
- package/dist/index.mjs +6 -1
- package/dist/llms.txt +22 -0
- package/dist/mcp/format.mjs +42 -8
- package/dist/mcp/query.mjs +34 -4
- package/dist/postgres-store.mjs +1 -0
- package/dist/react/Canvas.mjs +28 -5
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +4 -0
- package/dist/react/Dashboard.mjs +27 -4
- package/dist/react/DashboardList.mjs +22 -22
- package/dist/react/DashboardListRow.mjs +49 -0
- package/dist/react/Discard.mjs +5 -2
- package/dist/react/Editing.mjs +19 -5
- package/dist/react/FilterBar.d.mts +7 -9
- package/dist/react/Grid.mjs +7 -19
- package/dist/react/Header.mjs +1 -1
- package/dist/react/History.mjs +5 -0
- package/dist/react/ReadFailed.mjs +23 -0
- package/dist/react/Spaces.mjs +15 -1
- package/dist/react/Tile.d.mts +2 -0
- package/dist/react/Tile.mjs +45 -10
- package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/react/arrange-steps.mjs +16 -13
- package/dist/react/arrange.mjs +10 -3
- package/dist/react/builder/Calcs.mjs +35 -11
- package/dist/react/builder/FilterEditor.mjs +196 -0
- package/dist/react/builder/Filters.mjs +172 -116
- package/dist/react/builder/Formula.mjs +82 -0
- package/dist/react/builder/Groups.mjs +1 -0
- package/dist/react/builder/Preview.mjs +1 -1
- package/dist/react/builder/RangeEditor.mjs +184 -0
- package/dist/react/builder/Sections.mjs +41 -6
- package/dist/react/builder/Time.mjs +138 -60
- package/dist/react/builder/Values.mjs +85 -0
- package/dist/react/builder/WidgetBuilder.mjs +50 -49
- package/dist/react/builder/base.d.mts +5 -0
- package/dist/react/builder/base.mjs +33 -8
- package/dist/react/builder/calc.mjs +15 -1
- package/dist/react/builder/escape.d.mts +1 -0
- package/dist/react/builder/escape.mjs +62 -0
- package/dist/react/builder/filter-tree.d.mts +9 -0
- package/dist/react/builder/filter-tree.mjs +186 -0
- package/dist/react/builder/formula-parse.d.mts +18 -0
- package/dist/react/builder/formula-parse.mjs +136 -0
- package/dist/react/builder/labels.d.mts +1 -1
- package/dist/react/builder/state.d.mts +2 -1
- package/dist/react/builder/state.mjs +23 -37
- package/dist/react/builder/useBuilder.d.mts +12 -1
- package/dist/react/builder/useBuilder.mjs +6 -3
- package/dist/react/builder/words.d.mts +59 -0
- package/dist/react/builder/words.mjs +73 -0
- package/dist/react/context.d.mts +15 -1
- package/dist/react/context.mjs +9 -3
- package/dist/react/drill/Bars.mjs +2 -2
- package/dist/react/drill/props.mjs +2 -1
- package/dist/react/drill/useDrill.d.mts +1 -1
- package/dist/react/drill/words.d.mts +3 -0
- package/dist/react/drill/words.mjs +2 -0
- package/dist/react/english.mjs +20 -5
- package/dist/react/filters/bar.d.mts +12 -0
- package/dist/react/filters/bar.mjs +135 -0
- package/dist/react/filters/calendar.mjs +193 -0
- package/dist/react/filters/chip.mjs +174 -0
- package/dist/react/filters/context.d.mts +22 -0
- package/dist/react/filters/context.mjs +78 -0
- package/dist/react/filters/dates.mjs +89 -0
- package/dist/react/filters/days.d.mts +36 -0
- package/dist/react/filters/days.mjs +87 -0
- package/dist/react/filters/field-step.mjs +81 -0
- package/dist/react/filters/hooks.d.mts +34 -0
- package/dist/react/filters/hooks.mjs +94 -0
- package/dist/react/filters/listbox.mjs +131 -0
- package/dist/react/filters/logic.d.mts +59 -0
- package/dist/react/filters/logic.mjs +109 -0
- package/dist/react/filters/menu-search.mjs +211 -0
- package/dist/react/filters/menu.mjs +85 -0
- package/dist/react/filters/number.mjs +127 -0
- package/dist/react/filters/numbers.d.mts +47 -0
- package/dist/react/filters/numbers.mjs +151 -0
- package/dist/react/filters/operator.mjs +104 -0
- package/dist/react/filters/phone.mjs +104 -0
- package/dist/react/filters/popover.d.mts +19 -0
- package/dist/react/filters/popover.mjs +153 -0
- package/dist/react/filters/rules.d.mts +8 -0
- package/dist/react/filters/rules.mjs +55 -0
- package/dist/react/filters/sheet.mjs +196 -0
- package/dist/react/filters/state.mjs +132 -0
- package/dist/react/filters/suggest.d.mts +47 -0
- package/dist/react/filters/suggest.mjs +97 -0
- package/dist/react/filters/values.mjs +166 -0
- package/dist/react/filters/words.d.mts +81 -0
- package/dist/react/filters/words.mjs +73 -0
- package/dist/react/format.mjs +11 -4
- package/dist/react/index.d.mts +15 -6
- package/dist/react/index.mjs +10 -4
- package/dist/react/messages.d.mts +34 -2
- package/dist/react/place.mjs +7 -3
- package/dist/react/renderers/index.d.mts +3 -21
- package/dist/react/renderers/index.mjs +68 -6
- package/dist/react/renderers/list.d.mts +2 -1
- package/dist/react/renderers/list.mjs +9 -12
- package/dist/react/renderers/props.d.mts +26 -0
- package/dist/react/scope.d.mts +4 -0
- package/dist/react/scope.mjs +19 -2
- package/dist/react/series-slots.d.mts +37 -0
- package/dist/react/series-slots.mjs +71 -0
- package/dist/react/series.d.mts +39 -9
- package/dist/react/series.mjs +144 -47
- package/dist/react/theme.css +930 -19
- package/dist/react/useBoard.d.mts +2 -0
- package/dist/react/useDashboard.d.mts +3 -0
- package/dist/react/useDashboard.mjs +6 -0
- package/dist/react/view-grid.mjs +16 -0
- package/dist/recharts/axes.mjs +28 -0
- package/dist/recharts/axis.mjs +84 -0
- package/dist/recharts/bar.d.mts +7 -0
- package/dist/recharts/bar.mjs +141 -0
- package/dist/recharts/charts.d.mts +4 -5
- package/dist/recharts/charts.mjs +2 -208
- package/dist/recharts/index.d.mts +3 -1
- package/dist/recharts/index.mjs +4 -1
- package/dist/recharts/line.d.mts +2 -0
- package/dist/recharts/line.mjs +112 -0
- package/dist/recharts/marks.mjs +47 -18
- package/dist/recharts/parts.mjs +103 -0
- package/dist/recharts/table.mjs +71 -0
- package/dist/records-read.mjs +1 -1
- package/dist/registry/filter-bar.json +26 -0
- package/dist/skills/derive-dashboards/SKILL.md +69 -0
- package/dist/store/apply.mjs +3 -1
- package/package.json +6 -2
- package/dist/react/FilterBar.mjs +0 -119
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { viewerValues } from "./bind.mjs";
|
|
2
|
+
// src/policy/bind-query.ts
|
|
3
|
+
/** No rows: what a filter is when a viewer value it needs is missing. */
|
|
4
|
+
const NOTHING = { any: [] };
|
|
5
|
+
var Missing = class extends Error {};
|
|
6
|
+
function walk(filter, viewer) {
|
|
7
|
+
if ("all" in filter) return { all: filter.all.map((f) => walk(f, viewer)) };
|
|
8
|
+
if ("any" in filter) return { any: filter.any.map((f) => walk(f, viewer)) };
|
|
9
|
+
if ("not" in filter) return { not: walk(filter.not, viewer) };
|
|
10
|
+
if ("some" in filter) return { some: {
|
|
11
|
+
...filter.some,
|
|
12
|
+
where: walk(filter.some.where, viewer)
|
|
13
|
+
} };
|
|
14
|
+
if ("none" in filter) return { none: {
|
|
15
|
+
...filter.none,
|
|
16
|
+
where: walk(filter.none.where, viewer)
|
|
17
|
+
} };
|
|
18
|
+
if (!("viewer" in filter)) return filter;
|
|
19
|
+
const values = viewer === void 0 ? [] : viewerValues(viewer, filter.viewer);
|
|
20
|
+
if (values.length === 0) throw new Missing();
|
|
21
|
+
return {
|
|
22
|
+
member: filter.member,
|
|
23
|
+
op: filter.op,
|
|
24
|
+
values
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The filter with every viewer reference (`{ viewer: "id" }`) replaced by the signed-in viewer's
|
|
29
|
+
* values, as a row policy binds them. When a value is missing (a public link, a viewer without
|
|
30
|
+
* that attribute), the whole filter matches no rows: a missing value never makes a negated leaf
|
|
31
|
+
* true. Variables are left as they are.
|
|
32
|
+
*/
|
|
33
|
+
function bindViewer(filter, principal) {
|
|
34
|
+
const viewer = principal.channel === "user" ? principal.viewer : void 0;
|
|
35
|
+
try {
|
|
36
|
+
return walk(filter, viewer);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error instanceof Missing) return NOTHING;
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** The query with the viewer bound in its filters and in each measure's own filter. */
|
|
43
|
+
function bindQueryViewer(query, principal) {
|
|
44
|
+
return {
|
|
45
|
+
...query,
|
|
46
|
+
...query.filters === void 0 ? {} : { filters: bindViewer(query.filters, principal) },
|
|
47
|
+
measures: query.measures.map((m) => m.filter === void 0 ? m : {
|
|
48
|
+
...m,
|
|
49
|
+
filter: bindViewer(m.filter, principal)
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export { bindQueryViewer, bindViewer };
|
|
@@ -17,4 +17,14 @@ function lineAlias(text) {
|
|
|
17
17
|
const n = Number(text.slice(1));
|
|
18
18
|
return text.startsWith("m") ? `m${n}` : `c${n}`;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* What a result column's id names: `t` is the time bucket, any other id the query's alias for
|
|
22
|
+
* it. Only for a column drawn before columns carried their `role` (a drill link sealed by an
|
|
23
|
+
* earlier release); every other reader reads the role.
|
|
24
|
+
*/
|
|
25
|
+
function idRole(id) {
|
|
26
|
+
if (id === "t") return "time";
|
|
27
|
+
if (id.startsWith("m")) return "measure";
|
|
28
|
+
return id.startsWith("d") ? "dimension" : "calc";
|
|
29
|
+
}
|
|
30
|
+
export { aliasPart, idRole, lineAlias };
|
|
@@ -3,9 +3,13 @@ import { ResultCell, ResultColumn, ResultRows } from "../../result/types.mjs";
|
|
|
3
3
|
import { Span } from "../../time/range.mjs";
|
|
4
4
|
import { Calendar } from "../types.mjs";
|
|
5
5
|
import { Cuts, Selection } from "./types.mjs";
|
|
6
|
+
/** A drawn answer's column. One sealed by an earlier release has no `role`, only its id. */
|
|
7
|
+
type DrawnColumn = Omit<ResultColumn, "role"> & {
|
|
8
|
+
role?: ResultColumn["role"];
|
|
9
|
+
};
|
|
6
10
|
/** An answer as it was drawn: its columns and rows, its resolved range and its calendar. */
|
|
7
11
|
export type Drawn = {
|
|
8
|
-
columns: readonly
|
|
12
|
+
columns: readonly DrawnColumn[];
|
|
9
13
|
rows: ResultRows;
|
|
10
14
|
span?: Span;
|
|
11
15
|
calendar: Calendar;
|
|
@@ -34,4 +38,5 @@ export type Picked = {
|
|
|
34
38
|
* reason, for a row that cannot drill: a field the answer does not name, or an Other whose
|
|
35
39
|
* kept set is too large or not whole.
|
|
36
40
|
*/
|
|
37
|
-
export declare function rowSelection(
|
|
41
|
+
export declare function rowSelection(given: Drawn, row: readonly ResultCell[]): Picked;
|
|
42
|
+
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import { roleOf } from "../../result/columns.mjs";
|
|
1
2
|
import { isMark } from "../../result/marks.mjs";
|
|
2
|
-
import { nextBucketStart } from "../../time/bucket.mjs";
|
|
3
|
-
import { formatTextTime
|
|
4
|
-
import { startOfDate } from "../../time/zone.mjs";
|
|
3
|
+
import { labelStart, nextBucketStart } from "../../time/bucket.mjs";
|
|
4
|
+
import { formatTextTime } from "../../time/instant.mjs";
|
|
5
5
|
// src/query/drill/selection.ts
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
6
|
+
/** A drawn column with its role: its own, or for one an earlier release sealed, its id's. */
|
|
7
|
+
const withRole = (c) => ({
|
|
8
|
+
...c,
|
|
9
|
+
role: roleOf(c)
|
|
10
|
+
});
|
|
12
11
|
/** A time point's step: its bucket's exact window from the engine's calendar, cut to the range. */
|
|
13
12
|
function bucketStep(drawn, column, cell) {
|
|
14
13
|
if (column.member === void 0 || column.grain === void 0 || typeof cell !== "string") return void 0;
|
|
@@ -32,7 +31,7 @@ function groupParts(columns, row) {
|
|
|
32
31
|
};
|
|
33
32
|
for (const [i, column] of columns.entries()) {
|
|
34
33
|
const cell = row[i] ?? null;
|
|
35
|
-
if (
|
|
34
|
+
if (column.role !== "dimension") continue;
|
|
36
35
|
if (column.member === void 0) return void 0;
|
|
37
36
|
if (isMark(cell)) {
|
|
38
37
|
if (cell.mark === "other") parts.others.push(i);
|
|
@@ -63,7 +62,7 @@ function keptStep(members, kept) {
|
|
|
63
62
|
/** A dimension's own limit's Other: the rows outside every value the engine kept for it. */
|
|
64
63
|
function segmentStep(drawn, at) {
|
|
65
64
|
const column = drawn.columns[at];
|
|
66
|
-
const index = drawn.columns.slice(0, at).filter((c) => c.
|
|
65
|
+
const index = drawn.columns.slice(0, at).filter((c) => c.role === "dimension").length;
|
|
67
66
|
const kept = drawn.cuts?.segments.find(([i]) => i === index)?.[1];
|
|
68
67
|
if (column?.member === void 0 || kept === void 0) return { refused: "OTHER_CUT" };
|
|
69
68
|
const values = kept.flatMap((v) => typeof v === "object" && v !== null ? [] : [[v]]);
|
|
@@ -106,7 +105,7 @@ function clickedOf(columns, row) {
|
|
|
106
105
|
const clicked = {};
|
|
107
106
|
for (const [i, column] of columns.entries()) {
|
|
108
107
|
const cell = row[i] ?? null;
|
|
109
|
-
if ((column.
|
|
108
|
+
if ((column.role === "measure" || column.role === "calc") && !isMark(cell)) clicked[column.id] = cell;
|
|
110
109
|
}
|
|
111
110
|
return clicked;
|
|
112
111
|
}
|
|
@@ -117,11 +116,15 @@ function clickedOf(columns, row) {
|
|
|
117
116
|
* reason, for a row that cannot drill: a field the answer does not name, or an Other whose
|
|
118
117
|
* kept set is too large or not whole.
|
|
119
118
|
*/
|
|
120
|
-
function rowSelection(
|
|
119
|
+
function rowSelection(given, row) {
|
|
120
|
+
const drawn = {
|
|
121
|
+
...given,
|
|
122
|
+
columns: given.columns.map((c) => withRole(c))
|
|
123
|
+
};
|
|
121
124
|
const time = timeSteps(drawn, row);
|
|
122
125
|
const parts = groupParts(drawn.columns, row);
|
|
123
126
|
if (time === void 0 || parts === void 0) return { refused: "OTHER_CUT" };
|
|
124
|
-
const dims = drawn.columns.filter((c) => c.
|
|
127
|
+
const dims = drawn.columns.filter((c) => c.role === "dimension").length;
|
|
125
128
|
const other = parts.others.length === 0 ? { steps: [] } : otherSteps(drawn, parts.others, dims);
|
|
126
129
|
if ("refused" in other) return other;
|
|
127
130
|
return { selection: {
|
|
@@ -135,7 +138,7 @@ function rowSelection(drawn, row) {
|
|
|
135
138
|
}
|
|
136
139
|
/** A row's time step, if the answer has a bucket column; undefined when its label does not read. */
|
|
137
140
|
function timeSteps(drawn, row) {
|
|
138
|
-
const at = drawn.columns.findIndex((c) => c.
|
|
141
|
+
const at = drawn.columns.findIndex((c) => c.role === "time");
|
|
139
142
|
const bucket = drawn.columns[at];
|
|
140
143
|
if (bucket === void 0) return [];
|
|
141
144
|
const step = bucketStep(drawn, bucket, row[at] ?? null);
|
|
@@ -15,6 +15,12 @@ export type ValueLeaf<Member extends string = string> = {
|
|
|
15
15
|
member: Member;
|
|
16
16
|
op: Op;
|
|
17
17
|
values: readonly Primitive[];
|
|
18
|
+
/**
|
|
19
|
+
* Set only by the engine, on a limited dimension's kept values: a test that keeps most rows,
|
|
20
|
+
* which no index would answer, so its SQL leaves out the tests that are there for an index.
|
|
21
|
+
* The wire schema refuses it, and it changes no answer.
|
|
22
|
+
*/
|
|
23
|
+
broad?: true;
|
|
18
24
|
};
|
|
19
25
|
export type ViewerLeaf<Member extends string = string> = {
|
|
20
26
|
member: Member;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { Primitive } from "../types/primitives.mjs";
|
|
1
2
|
import { Control, DateRange, Picks } from "./types.mjs";
|
|
2
3
|
/** Whether a pick is a date range: the last N units, or from and to. */
|
|
3
4
|
export declare function isDateRange(pick: Picks[string]): pick is DateRange;
|
|
5
|
+
/** Whether a pick is a filter's: an operator and its values. */
|
|
6
|
+
export declare function isValuePick(pick: Picks[string] | undefined): pick is Extract<Picks[string], {
|
|
7
|
+
values: readonly Primitive[];
|
|
8
|
+
}>;
|
|
4
9
|
/**
|
|
5
10
|
* Why a viewer's pick does not fit its control, or undefined when it does: the one rule the
|
|
6
11
|
* tiles and a shared link both apply. A filter takes values with one of its operators, from
|
|
7
|
-
* its own list when it has one, at least one value
|
|
8
|
-
* range control takes a range; any other control takes
|
|
12
|
+
* its own list when it has one, at least one value (none for set and notSet, which test null),
|
|
13
|
+
* and only one unless it is multi; a date range control takes a range; any other control takes
|
|
14
|
+
* no pick yet.
|
|
9
15
|
*/
|
|
10
16
|
export declare function pickProblem(control: Control, pick: Picks[string]): string | undefined;
|
|
@@ -3,18 +3,25 @@
|
|
|
3
3
|
function isDateRange(pick) {
|
|
4
4
|
return typeof pick === "object" && pick !== null && ("last" in pick || "from" in pick);
|
|
5
5
|
}
|
|
6
|
+
/** Whether a pick is a filter's: an operator and its values. */
|
|
7
|
+
function isValuePick(pick) {
|
|
8
|
+
return typeof pick === "object" && pick !== null && "values" in pick;
|
|
9
|
+
}
|
|
6
10
|
/** Whether a filter pick fits its filter: one of its operators, its own values, one unless multi. */
|
|
7
11
|
function filterFits(control, pick) {
|
|
12
|
+
if (!control.ops.some((op) => op === pick.op)) return false;
|
|
13
|
+
if (pick.op === "set" || pick.op === "notSet") return pick.values.length === 0;
|
|
8
14
|
const allowed = Array.isArray(control.values) ? control.values : void 0;
|
|
9
15
|
const inList = allowed === void 0 || pick.values.every((v) => allowed.includes(v));
|
|
10
16
|
const count = pick.values.length > 0 && (control.multi || pick.values.length === 1);
|
|
11
|
-
return
|
|
17
|
+
return inList && count;
|
|
12
18
|
}
|
|
13
19
|
/**
|
|
14
20
|
* Why a viewer's pick does not fit its control, or undefined when it does: the one rule the
|
|
15
21
|
* tiles and a shared link both apply. A filter takes values with one of its operators, from
|
|
16
|
-
* its own list when it has one, at least one value
|
|
17
|
-
* range control takes a range; any other control takes
|
|
22
|
+
* its own list when it has one, at least one value (none for set and notSet, which test null),
|
|
23
|
+
* and only one unless it is multi; a date range control takes a range; any other control takes
|
|
24
|
+
* no pick yet.
|
|
18
25
|
*/
|
|
19
26
|
function pickProblem(control, pick) {
|
|
20
27
|
if (control.kind === "date_range") return isDateRange(pick) ? void 0 : `The pick for "${control.id}" is not a date range.`;
|
|
@@ -22,4 +29,4 @@ function pickProblem(control, pick) {
|
|
|
22
29
|
if (typeof pick !== "object" || pick === null || !("op" in pick)) return `The pick for "${control.id}" is not a filter.`;
|
|
23
30
|
return filterFits(control, pick) ? void 0 : `The pick for "${control.id}" is not one the control allows.`;
|
|
24
31
|
}
|
|
25
|
-
export { isDateRange, pickProblem };
|
|
32
|
+
export { isDateRange, isValuePick, pickProblem };
|
|
@@ -64,7 +64,8 @@ function keptFilter(member, values) {
|
|
|
64
64
|
const leaves = [{
|
|
65
65
|
member,
|
|
66
66
|
op: "in",
|
|
67
|
-
values: values.filter((v) => v !== null && typeof v !== "object")
|
|
67
|
+
values: values.filter((v) => v !== null && typeof v !== "object"),
|
|
68
|
+
broad: true
|
|
68
69
|
}];
|
|
69
70
|
if (values.includes(null)) leaves.push({
|
|
70
71
|
member,
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { Model } from "../model/types.mjs";
|
|
2
2
|
import { WireQuery } from "../query/types.mjs";
|
|
3
|
-
import { RecordColumn, ResultColumn } from "./types.mjs";
|
|
3
|
+
import { ColumnRole, RecordColumn, ResultColumn } from "./types.mjs";
|
|
4
4
|
/** A member's label: the model's, or its name in words. */
|
|
5
5
|
export declare function memberLabel(id: string, label?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* What a column is: its `role`, or for a column that has none, what its id names. Every answer
|
|
8
|
+
* this release makes carries roles; one made a release back does not, and a browser can meet it
|
|
9
|
+
* while a deploy rolls out, so every reader asks here and none reads the id itself.
|
|
10
|
+
*/
|
|
11
|
+
export declare function roleOf(column: {
|
|
12
|
+
id: string;
|
|
13
|
+
role?: ColumnRole;
|
|
14
|
+
}): ColumnRole;
|
|
6
15
|
/**
|
|
7
16
|
* The columns of a query's rows, in row order: the time bucket, the dimensions, the measures
|
|
8
17
|
* and the calcs. Labels come from the model; a member reached through a join is named by the
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveDimension, resolveMeasure } from "../model/member.mjs";
|
|
2
|
+
import { idRole } from "../query/alias.mjs";
|
|
2
3
|
import { formulaRefs } from "../query/formulas.mjs";
|
|
3
4
|
// src/result/columns.ts
|
|
4
5
|
/** "createdAt" reads "Created at". */
|
|
@@ -11,16 +12,19 @@ const lastPart = (id) => id.split(".").at(-1) ?? id;
|
|
|
11
12
|
function memberLabel(id, label) {
|
|
12
13
|
return label ?? words(lastPart(id));
|
|
13
14
|
}
|
|
14
|
-
/** How a measure's values read: its unit,
|
|
15
|
+
/** How a measure's values read: its unit, a ratio the model reads as a percent of one, a duration in seconds. */
|
|
15
16
|
function readsAs(def) {
|
|
16
17
|
const unit = def !== void 0 && "unit" in def ? def.unit : void 0;
|
|
17
|
-
const
|
|
18
|
+
const format = def !== void 0 && "format" in def ? def.format : void 0;
|
|
19
|
+
const percent = def?.kind === "ratio" && format === "percent";
|
|
20
|
+
const duration = format === "duration";
|
|
18
21
|
return {
|
|
19
22
|
...unit === void 0 ? {} : { unit },
|
|
20
23
|
...percent ? {
|
|
21
24
|
format: "percent",
|
|
22
25
|
fraction: true
|
|
23
|
-
} : {}
|
|
26
|
+
} : {},
|
|
27
|
+
...duration ? { format: "duration" } : {}
|
|
24
28
|
};
|
|
25
29
|
}
|
|
26
30
|
/** A measure's cell type: counts are integers, percentiles float, the rest as declared. */
|
|
@@ -64,12 +68,27 @@ function dimensionColumns(model, query) {
|
|
|
64
68
|
const label = join === void 0 ? own : (perJoin.get(join) ?? 0) > 1 ? `${words(join)} ${own.toLowerCase()}` : words(join);
|
|
65
69
|
return {
|
|
66
70
|
id: d.id,
|
|
71
|
+
role: "dimension",
|
|
67
72
|
label,
|
|
68
73
|
type: dimensionType(resolved?.dimension),
|
|
69
|
-
member: d.member
|
|
74
|
+
member: d.member,
|
|
75
|
+
...declaredValues(resolved?.dimension)
|
|
70
76
|
};
|
|
71
77
|
});
|
|
72
78
|
}
|
|
79
|
+
/** The values a string dimension declares, for a chart to colour by; none for a lookup or a free field. */
|
|
80
|
+
function declaredValues(def) {
|
|
81
|
+
const values = def?.kind === "string" ? def.values : void 0;
|
|
82
|
+
return values === void 0 || values === "lookup" ? {} : { values };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* What a column is: its `role`, or for a column that has none, what its id names. Every answer
|
|
86
|
+
* this release makes carries roles; one made a release back does not, and a browser can meet it
|
|
87
|
+
* while a deploy rolls out, so every reader asks here and none reads the id itself.
|
|
88
|
+
*/
|
|
89
|
+
function roleOf(column) {
|
|
90
|
+
return column.role ?? idRole(column.id);
|
|
91
|
+
}
|
|
73
92
|
/**
|
|
74
93
|
* The columns of a query's rows, in row order: the time bucket, the dimensions, the measures
|
|
75
94
|
* and the calcs. Labels come from the model; a member reached through a join is named by the
|
|
@@ -79,6 +98,7 @@ function resultColumns(model, query) {
|
|
|
79
98
|
const grain = query.time?.grain;
|
|
80
99
|
const bucket = grain === void 0 || query.time === void 0 ? [] : [{
|
|
81
100
|
id: "t",
|
|
101
|
+
role: "time",
|
|
82
102
|
label: words(grain),
|
|
83
103
|
type: "time",
|
|
84
104
|
member: query.time.dimension,
|
|
@@ -89,6 +109,7 @@ function resultColumns(model, query) {
|
|
|
89
109
|
const def = resolveMeasure(model, query.source, m.measure);
|
|
90
110
|
return {
|
|
91
111
|
id: m.id,
|
|
112
|
+
role: "measure",
|
|
92
113
|
label: m.label ?? memberLabel(m.measure, def?.label),
|
|
93
114
|
type: def === void 0 ? "float" : measureType(model, query.source, def),
|
|
94
115
|
...readsAs(def)
|
|
@@ -103,6 +124,7 @@ function resultColumns(model, query) {
|
|
|
103
124
|
if (unit !== void 0) units.set(c.id, unit);
|
|
104
125
|
return {
|
|
105
126
|
id: c.id,
|
|
127
|
+
role: "calc",
|
|
106
128
|
label: c.label ?? `Calc ${i + 1}`,
|
|
107
129
|
type,
|
|
108
130
|
...c.format === void 0 ? {} : { format: c.format },
|
|
@@ -128,4 +150,4 @@ function recordColumns(model, source, ids) {
|
|
|
128
150
|
};
|
|
129
151
|
});
|
|
130
152
|
}
|
|
131
|
-
export { memberLabel, recordColumns, resultColumns };
|
|
153
|
+
export { memberLabel, recordColumns, resultColumns, roleOf };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Calendar, ResolvedRange } from "../query/types.mjs";
|
|
2
|
+
import { ResultColumn, ResultRows, TimeAxis } from "./types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The time buckets an answer's rows name, as instants, in time order. Each runs from its first
|
|
5
|
+
* instant to the next bucket's by the answer's calendar, so a day is 23 or 25 hours across a
|
|
6
|
+
* clock change and a week starts on the calendar's day. A bucket the answer's range covers only
|
|
7
|
+
* part of is marked: the week still running, or a first month the range starts inside. The
|
|
8
|
+
* engine's own calendar decides both, so no client works a bucket's end out again.
|
|
9
|
+
*
|
|
10
|
+
* None for an answer with no time bucket column.
|
|
11
|
+
*/
|
|
12
|
+
export declare function timeAxis(answer: {
|
|
13
|
+
columns: readonly ResultColumn[];
|
|
14
|
+
rows: ResultRows;
|
|
15
|
+
}, range: ResolvedRange | undefined, calendar: Calendar): TimeAxis | undefined;
|
|
16
|
+
/** Rows with the time buckets they name, when their answer has a time bucket column. */
|
|
17
|
+
export declare function withTime(columns: readonly ResultColumn[], rows: ResultRows, at: {
|
|
18
|
+
range: ResolvedRange | undefined;
|
|
19
|
+
calendar: Calendar;
|
|
20
|
+
}): {
|
|
21
|
+
rows: ResultRows;
|
|
22
|
+
time?: TimeAxis;
|
|
23
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { labelStart, nextBucketStart } from "../time/bucket.mjs";
|
|
2
|
+
import { formatTextTime, parseTextTime } from "../time/instant.mjs";
|
|
3
|
+
// src/result/time-axis.ts
|
|
4
|
+
/** A resolved range as instants; none when it is absent or does not read. */
|
|
5
|
+
function spanOf(range) {
|
|
6
|
+
const from = range === void 0 ? void 0 : parseTextTime(range.from);
|
|
7
|
+
const to = range === void 0 ? void 0 : parseTextTime(range.to);
|
|
8
|
+
return from === void 0 || to === void 0 ? void 0 : {
|
|
9
|
+
from,
|
|
10
|
+
to
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Which end of a bucket a range leaves out, when it leaves any out. */
|
|
14
|
+
function partialOf(bucket, range) {
|
|
15
|
+
if (range === void 0) return {};
|
|
16
|
+
const start = range.from > bucket.from;
|
|
17
|
+
const end = range.to < bucket.to;
|
|
18
|
+
if (start && end) return { partial: "both" };
|
|
19
|
+
if (start) return { partial: "start" };
|
|
20
|
+
return end ? { partial: "end" } : {};
|
|
21
|
+
}
|
|
22
|
+
/** The bucket labels the rows name, each once, in the order they first appear. */
|
|
23
|
+
function labelsOf(rows, at) {
|
|
24
|
+
const cells = rows.flatMap((row) => {
|
|
25
|
+
const cell = row[at];
|
|
26
|
+
return typeof cell === "string" ? [cell] : [];
|
|
27
|
+
});
|
|
28
|
+
return [...new Set(cells)];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The time buckets an answer's rows name, as instants, in time order. Each runs from its first
|
|
32
|
+
* instant to the next bucket's by the answer's calendar, so a day is 23 or 25 hours across a
|
|
33
|
+
* clock change and a week starts on the calendar's day. A bucket the answer's range covers only
|
|
34
|
+
* part of is marked: the week still running, or a first month the range starts inside. The
|
|
35
|
+
* engine's own calendar decides both, so no client works a bucket's end out again.
|
|
36
|
+
*
|
|
37
|
+
* None for an answer with no time bucket column.
|
|
38
|
+
*/
|
|
39
|
+
function timeAxis(answer, range, calendar) {
|
|
40
|
+
const at = answer.columns.findIndex((c) => c.role === "time");
|
|
41
|
+
const grain = answer.columns[at]?.grain;
|
|
42
|
+
if (grain === void 0) return void 0;
|
|
43
|
+
const span = spanOf(range);
|
|
44
|
+
return {
|
|
45
|
+
grain,
|
|
46
|
+
buckets: labelsOf(answer.rows, at).flatMap((label) => {
|
|
47
|
+
const from = labelStart(label, grain, calendar);
|
|
48
|
+
return from === void 0 ? [] : [{
|
|
49
|
+
label,
|
|
50
|
+
from,
|
|
51
|
+
to: nextBucketStart(from, grain, calendar)
|
|
52
|
+
}];
|
|
53
|
+
}).toSorted((a, b) => a.from - b.from).map((b) => ({
|
|
54
|
+
label: b.label,
|
|
55
|
+
from: formatTextTime(b.from),
|
|
56
|
+
to: formatTextTime(b.to),
|
|
57
|
+
...partialOf(b, span)
|
|
58
|
+
}))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Rows with the time buckets they name, when their answer has a time bucket column. */
|
|
62
|
+
function withTime(columns, rows, at) {
|
|
63
|
+
const time = timeAxis({
|
|
64
|
+
columns,
|
|
65
|
+
rows
|
|
66
|
+
}, at.range, at.calendar);
|
|
67
|
+
return time === void 0 ? { rows } : {
|
|
68
|
+
rows,
|
|
69
|
+
time
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export { timeAxis, withTime };
|
|
@@ -3,9 +3,13 @@ import { BoundFilter } from "../query/filter.mjs";
|
|
|
3
3
|
import { Calendar, Cell, Format, Grain, ResolvedRange, ScopeCoverage } from "../query/types.mjs";
|
|
4
4
|
import { IsoInstant, Issue, SourceName } from "../types/primitives.mjs";
|
|
5
5
|
/** The answer's shape: its columns, its rows in one layout, and the receipt of what was read. */
|
|
6
|
+
/** What a column is: the time bucket, a field the rows are grouped by, a measure, or a calc. */
|
|
7
|
+
export type ColumnRole = "time" | "dimension" | "measure" | "calc";
|
|
6
8
|
export type ResultColumn = {
|
|
7
9
|
/** The query's id for this column: `m1`, `d1`, `c1`, or `t` for the time bucket. */
|
|
8
10
|
id: string;
|
|
11
|
+
/** What the column is. Read this, never the id's first letter. */
|
|
12
|
+
role: ColumnRole;
|
|
9
13
|
label: string;
|
|
10
14
|
type: "string" | "number" | "boolean" | "time" | "int" | "decimal" | "float";
|
|
11
15
|
unit?: Unit;
|
|
@@ -13,6 +17,11 @@ export type ResultColumn = {
|
|
|
13
17
|
member?: string;
|
|
14
18
|
/** On the time bucket column: the grain its labels name. */
|
|
15
19
|
grain?: Grain;
|
|
20
|
+
/**
|
|
21
|
+
* On a dimension whose model declares its values: those values, in the model's order. A chart
|
|
22
|
+
* gives each a colour by its place here, so a value keeps its colour whatever else is drawn.
|
|
23
|
+
*/
|
|
24
|
+
values?: readonly string[];
|
|
16
25
|
/** On a calc's column, or a ratio the model reads as a percent: how its values read. */
|
|
17
26
|
format?: Format;
|
|
18
27
|
/** On a calc that reads the comparison period: a change, shown with its sign (+3.2%). */
|
|
@@ -45,6 +54,29 @@ export type Receipt = {
|
|
|
45
54
|
coverage: ScopeCoverage;
|
|
46
55
|
warnings: readonly Issue[];
|
|
47
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* One time bucket of an answer, as instants: where a chart draws it on a time axis, and whether
|
|
59
|
+
* its value is whole.
|
|
60
|
+
*/
|
|
61
|
+
export type TimeBucket = {
|
|
62
|
+
/** The bucket's name: the value of the rows' time column. */
|
|
63
|
+
label: string;
|
|
64
|
+
/** Its first instant. */
|
|
65
|
+
from: IsoInstant;
|
|
66
|
+
/** The first instant of the bucket after it. */
|
|
67
|
+
to: IsoInstant;
|
|
68
|
+
/**
|
|
69
|
+
* Set when the answer's range covers only part of the bucket, so its value is not the whole
|
|
70
|
+
* bucket's: the range starts after `from` ("start"), ends before `to` ("end", as the week
|
|
71
|
+
* still running does), or both.
|
|
72
|
+
*/
|
|
73
|
+
partial?: "start" | "end" | "both";
|
|
74
|
+
};
|
|
75
|
+
/** The time buckets an answer's rows name, in time order. */
|
|
76
|
+
export type TimeAxis = {
|
|
77
|
+
grain: Grain;
|
|
78
|
+
buckets: readonly TimeBucket[];
|
|
79
|
+
};
|
|
48
80
|
/** A dimension cell for many values: `other`, those a limit left out; `all`, every one (a total). */
|
|
49
81
|
export type Mark = {
|
|
50
82
|
mark: "other" | "all";
|
|
@@ -60,10 +92,13 @@ export type ResultRows = readonly (readonly ResultCell[])[];
|
|
|
60
92
|
export type Result = {
|
|
61
93
|
rows: ResultRows;
|
|
62
94
|
columns: readonly ResultColumn[];
|
|
63
|
-
/**
|
|
95
|
+
/** With a time grain: the buckets the rows name, as instants. */
|
|
96
|
+
time?: TimeAxis;
|
|
97
|
+
/** The comparison period's rows, in the same layout, and with a time grain its own buckets. */
|
|
64
98
|
compare?: {
|
|
65
99
|
rows: ResultRows;
|
|
66
100
|
range: ResolvedRange;
|
|
101
|
+
time?: TimeAxis;
|
|
67
102
|
};
|
|
68
103
|
status: "complete" | "truncated";
|
|
69
104
|
receipt: Receipt;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WireQuery } from "../query/types.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* The query with each id renumbered to its position and every reference following it: for an
|
|
5
|
+
* agent's tool, which takes any ids and answers in text, so the ids never show.
|
|
6
|
+
*/
|
|
7
|
+
export declare function positional<Q extends WireQuery>(query: Q): Q;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/schema/aliases.ts
|
|
2
|
+
const LISTS = [
|
|
3
|
+
["measures", "m"],
|
|
4
|
+
["dimensions", "d"],
|
|
5
|
+
["calc", "c"]
|
|
6
|
+
];
|
|
7
|
+
/**
|
|
8
|
+
* Each entry's id is its position from 1 (the second dimension is d2): the engine, a drill and
|
|
9
|
+
* an answer's columns all read entries by it, so a query has one id space. References to the
|
|
10
|
+
* ids are checked with the rest of the query's closure.
|
|
11
|
+
*/
|
|
12
|
+
function checkPositions(query, ctx) {
|
|
13
|
+
for (const [key, prefix] of LISTS) for (const [i, entry] of (query[key] ?? []).entries()) {
|
|
14
|
+
const want = `${prefix}${i + 1}`;
|
|
15
|
+
if (entry.id !== want) ctx.addIssue({
|
|
16
|
+
code: "custom",
|
|
17
|
+
path: [
|
|
18
|
+
key,
|
|
19
|
+
i,
|
|
20
|
+
"id"
|
|
21
|
+
],
|
|
22
|
+
message: `Entry ${i + 1} of ${key} is "${want}", not "${entry.id}": an id is its entry's position from 1.`
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The query with each id renumbered to its position and every reference following it: for an
|
|
28
|
+
* agent's tool, which takes any ids and answers in text, so the ids never show.
|
|
29
|
+
*/
|
|
30
|
+
function positional(query) {
|
|
31
|
+
const to = /* @__PURE__ */ new Map();
|
|
32
|
+
for (const [key, prefix] of LISTS) for (const [i, entry] of (query[key] ?? []).entries()) to.set(entry.id, `${prefix}${i + 1}`);
|
|
33
|
+
const alias = (id) => to.get(id) ?? id;
|
|
34
|
+
const formula = (node) => {
|
|
35
|
+
if ("ref" in node) return {
|
|
36
|
+
...node,
|
|
37
|
+
ref: alias(node.ref)
|
|
38
|
+
};
|
|
39
|
+
if (!("args" in node)) return node;
|
|
40
|
+
if (node.op === "abs") return {
|
|
41
|
+
op: "abs",
|
|
42
|
+
args: [formula(node.args[0])]
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
op: node.op,
|
|
46
|
+
args: [formula(node.args[0]), formula(node.args[1])]
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const dimensions = query.dimensions?.map((d) => ({
|
|
50
|
+
...d,
|
|
51
|
+
id: alias(d.id),
|
|
52
|
+
...d.rankBy === void 0 ? {} : { rankBy: {
|
|
53
|
+
...d.rankBy,
|
|
54
|
+
by: alias(d.rankBy.by)
|
|
55
|
+
} }
|
|
56
|
+
}));
|
|
57
|
+
const calc = query.calc?.map((c) => ({
|
|
58
|
+
...c,
|
|
59
|
+
id: alias(c.id),
|
|
60
|
+
formula: formula(c.formula)
|
|
61
|
+
}));
|
|
62
|
+
const order = query.order?.map((o) => ({
|
|
63
|
+
...o,
|
|
64
|
+
by: alias(o.by)
|
|
65
|
+
}));
|
|
66
|
+
return {
|
|
67
|
+
...query,
|
|
68
|
+
measures: query.measures.map((m) => ({
|
|
69
|
+
...m,
|
|
70
|
+
id: alias(m.id)
|
|
71
|
+
})),
|
|
72
|
+
...dimensions === void 0 ? {} : { dimensions },
|
|
73
|
+
...calc === void 0 ? {} : { calc },
|
|
74
|
+
...order === void 0 ? {} : { order }
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export { checkPositions, positional };
|
|
@@ -25,11 +25,18 @@ const columnType = z.enum([
|
|
|
25
25
|
]);
|
|
26
26
|
const column = z.looseObject({
|
|
27
27
|
id: z.string(),
|
|
28
|
+
role: z.enum([
|
|
29
|
+
"time",
|
|
30
|
+
"dimension",
|
|
31
|
+
"measure",
|
|
32
|
+
"calc"
|
|
33
|
+
]),
|
|
28
34
|
label: z.string(),
|
|
29
35
|
type: columnType,
|
|
30
36
|
unit: z.string().exactOptional(),
|
|
31
37
|
member: z.string().exactOptional(),
|
|
32
38
|
grain: grain.exactOptional(),
|
|
39
|
+
values: z.array(z.string()).readonly().exactOptional(),
|
|
33
40
|
format: z.enum([
|
|
34
41
|
"number",
|
|
35
42
|
"percent",
|
|
@@ -43,6 +50,19 @@ const resolvedRange = z.looseObject({
|
|
|
43
50
|
from: z.string(),
|
|
44
51
|
to: z.string()
|
|
45
52
|
});
|
|
53
|
+
const timeAxis = z.looseObject({
|
|
54
|
+
grain,
|
|
55
|
+
buckets: z.array(z.looseObject({
|
|
56
|
+
label: z.string(),
|
|
57
|
+
from: z.string(),
|
|
58
|
+
to: z.string(),
|
|
59
|
+
partial: z.enum([
|
|
60
|
+
"start",
|
|
61
|
+
"end",
|
|
62
|
+
"both"
|
|
63
|
+
]).exactOptional()
|
|
64
|
+
})).readonly()
|
|
65
|
+
});
|
|
46
66
|
const boundFilter = z.lazy(() => z.union([
|
|
47
67
|
z.looseObject({ all: z.array(boundFilter).readonly() }),
|
|
48
68
|
z.looseObject({ any: z.array(boundFilter).readonly() }),
|
|
@@ -102,9 +122,11 @@ const receipt = z.looseObject({
|
|
|
102
122
|
const result = z.looseObject({
|
|
103
123
|
rows,
|
|
104
124
|
columns: z.array(column).readonly(),
|
|
125
|
+
time: timeAxis.exactOptional(),
|
|
105
126
|
compare: z.looseObject({
|
|
106
127
|
rows,
|
|
107
|
-
range: resolvedRange
|
|
128
|
+
range: resolvedRange,
|
|
129
|
+
time: timeAxis.exactOptional()
|
|
108
130
|
}).exactOptional(),
|
|
109
131
|
status: z.enum(["complete", "truncated"]),
|
|
110
132
|
receipt
|