derive-dashboards 0.2.0 → 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/dist/cache.mjs +2 -1
- package/dist/cli/add.mjs +1 -1
- package/dist/cli/doctor.mjs +39 -24
- package/dist/core/document/display.d.mts +63 -0
- package/dist/core/document/display.mjs +139 -0
- package/dist/core/engine/version.d.mts +5 -4
- package/dist/core/engine/version.mjs +5 -4
- package/dist/core/error/codes.d.mts +2 -0
- package/dist/core/error/codes.mjs +2 -0
- package/dist/core/index.d.mts +9 -7
- package/dist/core/index.mjs +7 -5
- 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/source.mjs +8 -1
- 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/result/columns.d.mts +10 -1
- package/dist/core/result/columns.mjs +21 -2
- 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/answer-parts.mjs +23 -1
- package/dist/core/schema/answers.d.mts +203 -0
- package/dist/core/schema/answers.mjs +1 -0
- 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 +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/drill-change.mjs +1 -1
- package/dist/drill-seal.mjs +1 -0
- package/dist/endpoints/index.d.mts +3 -0
- package/dist/execute.mjs +13 -7
- package/dist/index.mjs +6 -1
- package/dist/react/Dashboard.d.mts +4 -0
- package/dist/react/Dashboard.mjs +12 -1
- package/dist/react/Tile.mjs +11 -4
- package/dist/react/context.d.mts +2 -1
- package/dist/react/drill/Bars.mjs +2 -2
- package/dist/react/drill/props.mjs +2 -1
- package/dist/react/index.d.mts +5 -2
- package/dist/react/index.mjs +4 -2
- package/dist/react/renderers/index.d.mts +3 -21
- package/dist/react/renderers/index.mjs +3 -3
- package/dist/react/renderers/list.d.mts +2 -1
- package/dist/react/renderers/list.mjs +8 -11
- 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 +19 -6
- package/dist/react/series.mjs +75 -74
- package/dist/recharts/bar.mjs +5 -4
- package/dist/recharts/line.mjs +5 -4
- package/dist/recharts/parts.mjs +29 -14
- package/dist/skills/derive-dashboards/SKILL.md +1 -1
- package/dist/store/apply.mjs +3 -1
- package/package.json +4 -4
|
@@ -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". */
|
|
@@ -67,12 +68,27 @@ function dimensionColumns(model, query) {
|
|
|
67
68
|
const label = join === void 0 ? own : (perJoin.get(join) ?? 0) > 1 ? `${words(join)} ${own.toLowerCase()}` : words(join);
|
|
68
69
|
return {
|
|
69
70
|
id: d.id,
|
|
71
|
+
role: "dimension",
|
|
70
72
|
label,
|
|
71
73
|
type: dimensionType(resolved?.dimension),
|
|
72
|
-
member: d.member
|
|
74
|
+
member: d.member,
|
|
75
|
+
...declaredValues(resolved?.dimension)
|
|
73
76
|
};
|
|
74
77
|
});
|
|
75
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
|
+
}
|
|
76
92
|
/**
|
|
77
93
|
* The columns of a query's rows, in row order: the time bucket, the dimensions, the measures
|
|
78
94
|
* and the calcs. Labels come from the model; a member reached through a join is named by the
|
|
@@ -82,6 +98,7 @@ function resultColumns(model, query) {
|
|
|
82
98
|
const grain = query.time?.grain;
|
|
83
99
|
const bucket = grain === void 0 || query.time === void 0 ? [] : [{
|
|
84
100
|
id: "t",
|
|
101
|
+
role: "time",
|
|
85
102
|
label: words(grain),
|
|
86
103
|
type: "time",
|
|
87
104
|
member: query.time.dimension,
|
|
@@ -92,6 +109,7 @@ function resultColumns(model, query) {
|
|
|
92
109
|
const def = resolveMeasure(model, query.source, m.measure);
|
|
93
110
|
return {
|
|
94
111
|
id: m.id,
|
|
112
|
+
role: "measure",
|
|
95
113
|
label: m.label ?? memberLabel(m.measure, def?.label),
|
|
96
114
|
type: def === void 0 ? "float" : measureType(model, query.source, def),
|
|
97
115
|
...readsAs(def)
|
|
@@ -106,6 +124,7 @@ function resultColumns(model, query) {
|
|
|
106
124
|
if (unit !== void 0) units.set(c.id, unit);
|
|
107
125
|
return {
|
|
108
126
|
id: c.id,
|
|
127
|
+
role: "calc",
|
|
109
128
|
label: c.label ?? `Calc ${i + 1}`,
|
|
110
129
|
type,
|
|
111
130
|
...c.format === void 0 ? {} : { format: c.format },
|
|
@@ -131,4 +150,4 @@ function recordColumns(model, source, ids) {
|
|
|
131
150
|
};
|
|
132
151
|
});
|
|
133
152
|
}
|
|
134
|
-
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;
|
|
@@ -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
|
|
@@ -23,6 +23,12 @@ export declare const tileLineSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
23
23
|
}, z.core.$loose>]>>>>>;
|
|
24
24
|
columns: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
25
25
|
id: z.ZodString;
|
|
26
|
+
role: z.ZodEnum<{
|
|
27
|
+
time: "time";
|
|
28
|
+
dimension: "dimension";
|
|
29
|
+
measure: "measure";
|
|
30
|
+
calc: "calc";
|
|
31
|
+
}>;
|
|
26
32
|
label: z.ZodString;
|
|
27
33
|
type: z.ZodEnum<{
|
|
28
34
|
string: "string";
|
|
@@ -43,6 +49,7 @@ export declare const tileLineSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
43
49
|
quarter: "quarter";
|
|
44
50
|
year: "year";
|
|
45
51
|
}>>;
|
|
52
|
+
values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
46
53
|
format: z.ZodExactOptional<z.ZodEnum<{
|
|
47
54
|
number: "number";
|
|
48
55
|
percent: "percent";
|
|
@@ -52,6 +59,26 @@ export declare const tileLineSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
52
59
|
signed: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
53
60
|
fraction: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
54
61
|
}, z.core.$loose>>>;
|
|
62
|
+
time: z.ZodExactOptional<z.ZodObject<{
|
|
63
|
+
grain: z.ZodEnum<{
|
|
64
|
+
hour: "hour";
|
|
65
|
+
day: "day";
|
|
66
|
+
week: "week";
|
|
67
|
+
month: "month";
|
|
68
|
+
quarter: "quarter";
|
|
69
|
+
year: "year";
|
|
70
|
+
}>;
|
|
71
|
+
buckets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
72
|
+
label: z.ZodString;
|
|
73
|
+
from: z.ZodString;
|
|
74
|
+
to: z.ZodString;
|
|
75
|
+
partial: z.ZodExactOptional<z.ZodEnum<{
|
|
76
|
+
start: "start";
|
|
77
|
+
end: "end";
|
|
78
|
+
both: "both";
|
|
79
|
+
}>>;
|
|
80
|
+
}, z.core.$loose>>>;
|
|
81
|
+
}, z.core.$loose>>;
|
|
55
82
|
compare: z.ZodExactOptional<z.ZodObject<{
|
|
56
83
|
rows: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
57
84
|
t: z.ZodEnum<{
|
|
@@ -69,6 +96,26 @@ export declare const tileLineSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
69
96
|
from: z.ZodString;
|
|
70
97
|
to: z.ZodString;
|
|
71
98
|
}, z.core.$loose>;
|
|
99
|
+
time: z.ZodExactOptional<z.ZodObject<{
|
|
100
|
+
grain: z.ZodEnum<{
|
|
101
|
+
hour: "hour";
|
|
102
|
+
day: "day";
|
|
103
|
+
week: "week";
|
|
104
|
+
month: "month";
|
|
105
|
+
quarter: "quarter";
|
|
106
|
+
year: "year";
|
|
107
|
+
}>;
|
|
108
|
+
buckets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
109
|
+
label: z.ZodString;
|
|
110
|
+
from: z.ZodString;
|
|
111
|
+
to: z.ZodString;
|
|
112
|
+
partial: z.ZodExactOptional<z.ZodEnum<{
|
|
113
|
+
start: "start";
|
|
114
|
+
end: "end";
|
|
115
|
+
both: "both";
|
|
116
|
+
}>>;
|
|
117
|
+
}, z.core.$loose>>>;
|
|
118
|
+
}, z.core.$loose>>;
|
|
72
119
|
}, z.core.$loose>>;
|
|
73
120
|
status: z.ZodEnum<{
|
|
74
121
|
complete: "complete";
|
|
@@ -1841,6 +1888,7 @@ export declare const answerSchemas: {
|
|
|
1841
1888
|
command: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1842
1889
|
query: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1843
1890
|
picks: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1891
|
+
display: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1844
1892
|
bodies: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1845
1893
|
}, z.core.$loose>;
|
|
1846
1894
|
"/meta/values": z.ZodObject<{
|
|
@@ -2224,6 +2272,12 @@ export declare const answerSchemas: {
|
|
|
2224
2272
|
}, z.core.$loose>;
|
|
2225
2273
|
column: z.ZodExactOptional<z.ZodObject<{
|
|
2226
2274
|
id: z.ZodString;
|
|
2275
|
+
role: z.ZodEnum<{
|
|
2276
|
+
time: "time";
|
|
2277
|
+
dimension: "dimension";
|
|
2278
|
+
measure: "measure";
|
|
2279
|
+
calc: "calc";
|
|
2280
|
+
}>;
|
|
2227
2281
|
label: z.ZodString;
|
|
2228
2282
|
type: z.ZodEnum<{
|
|
2229
2283
|
string: "string";
|
|
@@ -2244,6 +2298,7 @@ export declare const answerSchemas: {
|
|
|
2244
2298
|
quarter: "quarter";
|
|
2245
2299
|
year: "year";
|
|
2246
2300
|
}>>;
|
|
2301
|
+
values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
2247
2302
|
format: z.ZodExactOptional<z.ZodEnum<{
|
|
2248
2303
|
number: "number";
|
|
2249
2304
|
percent: "percent";
|
|
@@ -2507,6 +2562,12 @@ export declare const answerSchemas: {
|
|
|
2507
2562
|
}, z.core.$loose>]>>>>>;
|
|
2508
2563
|
columns: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
2509
2564
|
id: z.ZodString;
|
|
2565
|
+
role: z.ZodEnum<{
|
|
2566
|
+
time: "time";
|
|
2567
|
+
dimension: "dimension";
|
|
2568
|
+
measure: "measure";
|
|
2569
|
+
calc: "calc";
|
|
2570
|
+
}>;
|
|
2510
2571
|
label: z.ZodString;
|
|
2511
2572
|
type: z.ZodEnum<{
|
|
2512
2573
|
string: "string";
|
|
@@ -2527,6 +2588,7 @@ export declare const answerSchemas: {
|
|
|
2527
2588
|
quarter: "quarter";
|
|
2528
2589
|
year: "year";
|
|
2529
2590
|
}>>;
|
|
2591
|
+
values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
2530
2592
|
format: z.ZodExactOptional<z.ZodEnum<{
|
|
2531
2593
|
number: "number";
|
|
2532
2594
|
percent: "percent";
|
|
@@ -2536,6 +2598,26 @@ export declare const answerSchemas: {
|
|
|
2536
2598
|
signed: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
2537
2599
|
fraction: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
2538
2600
|
}, z.core.$loose>>>;
|
|
2601
|
+
time: z.ZodExactOptional<z.ZodObject<{
|
|
2602
|
+
grain: z.ZodEnum<{
|
|
2603
|
+
hour: "hour";
|
|
2604
|
+
day: "day";
|
|
2605
|
+
week: "week";
|
|
2606
|
+
month: "month";
|
|
2607
|
+
quarter: "quarter";
|
|
2608
|
+
year: "year";
|
|
2609
|
+
}>;
|
|
2610
|
+
buckets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
2611
|
+
label: z.ZodString;
|
|
2612
|
+
from: z.ZodString;
|
|
2613
|
+
to: z.ZodString;
|
|
2614
|
+
partial: z.ZodExactOptional<z.ZodEnum<{
|
|
2615
|
+
start: "start";
|
|
2616
|
+
end: "end";
|
|
2617
|
+
both: "both";
|
|
2618
|
+
}>>;
|
|
2619
|
+
}, z.core.$loose>>>;
|
|
2620
|
+
}, z.core.$loose>>;
|
|
2539
2621
|
compare: z.ZodExactOptional<z.ZodObject<{
|
|
2540
2622
|
rows: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
2541
2623
|
t: z.ZodEnum<{
|
|
@@ -2553,6 +2635,26 @@ export declare const answerSchemas: {
|
|
|
2553
2635
|
from: z.ZodString;
|
|
2554
2636
|
to: z.ZodString;
|
|
2555
2637
|
}, z.core.$loose>;
|
|
2638
|
+
time: z.ZodExactOptional<z.ZodObject<{
|
|
2639
|
+
grain: z.ZodEnum<{
|
|
2640
|
+
hour: "hour";
|
|
2641
|
+
day: "day";
|
|
2642
|
+
week: "week";
|
|
2643
|
+
month: "month";
|
|
2644
|
+
quarter: "quarter";
|
|
2645
|
+
year: "year";
|
|
2646
|
+
}>;
|
|
2647
|
+
buckets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
2648
|
+
label: z.ZodString;
|
|
2649
|
+
from: z.ZodString;
|
|
2650
|
+
to: z.ZodString;
|
|
2651
|
+
partial: z.ZodExactOptional<z.ZodEnum<{
|
|
2652
|
+
start: "start";
|
|
2653
|
+
end: "end";
|
|
2654
|
+
both: "both";
|
|
2655
|
+
}>>;
|
|
2656
|
+
}, z.core.$loose>>>;
|
|
2657
|
+
}, z.core.$loose>>;
|
|
2556
2658
|
}, z.core.$loose>>;
|
|
2557
2659
|
status: z.ZodEnum<{
|
|
2558
2660
|
complete: "complete";
|
|
@@ -2963,6 +3065,12 @@ export declare const answerSchemas: {
|
|
|
2963
3065
|
}, z.core.$loose>]>>>>>;
|
|
2964
3066
|
columns: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
2965
3067
|
id: z.ZodString;
|
|
3068
|
+
role: z.ZodEnum<{
|
|
3069
|
+
time: "time";
|
|
3070
|
+
dimension: "dimension";
|
|
3071
|
+
measure: "measure";
|
|
3072
|
+
calc: "calc";
|
|
3073
|
+
}>;
|
|
2966
3074
|
label: z.ZodString;
|
|
2967
3075
|
type: z.ZodEnum<{
|
|
2968
3076
|
string: "string";
|
|
@@ -2983,6 +3091,7 @@ export declare const answerSchemas: {
|
|
|
2983
3091
|
quarter: "quarter";
|
|
2984
3092
|
year: "year";
|
|
2985
3093
|
}>>;
|
|
3094
|
+
values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
2986
3095
|
format: z.ZodExactOptional<z.ZodEnum<{
|
|
2987
3096
|
number: "number";
|
|
2988
3097
|
percent: "percent";
|
|
@@ -2992,6 +3101,26 @@ export declare const answerSchemas: {
|
|
|
2992
3101
|
signed: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
2993
3102
|
fraction: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
2994
3103
|
}, z.core.$loose>>>;
|
|
3104
|
+
time: z.ZodExactOptional<z.ZodObject<{
|
|
3105
|
+
grain: z.ZodEnum<{
|
|
3106
|
+
hour: "hour";
|
|
3107
|
+
day: "day";
|
|
3108
|
+
week: "week";
|
|
3109
|
+
month: "month";
|
|
3110
|
+
quarter: "quarter";
|
|
3111
|
+
year: "year";
|
|
3112
|
+
}>;
|
|
3113
|
+
buckets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
3114
|
+
label: z.ZodString;
|
|
3115
|
+
from: z.ZodString;
|
|
3116
|
+
to: z.ZodString;
|
|
3117
|
+
partial: z.ZodExactOptional<z.ZodEnum<{
|
|
3118
|
+
start: "start";
|
|
3119
|
+
end: "end";
|
|
3120
|
+
both: "both";
|
|
3121
|
+
}>>;
|
|
3122
|
+
}, z.core.$loose>>>;
|
|
3123
|
+
}, z.core.$loose>>;
|
|
2995
3124
|
compare: z.ZodExactOptional<z.ZodObject<{
|
|
2996
3125
|
rows: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
2997
3126
|
t: z.ZodEnum<{
|
|
@@ -3009,6 +3138,26 @@ export declare const answerSchemas: {
|
|
|
3009
3138
|
from: z.ZodString;
|
|
3010
3139
|
to: z.ZodString;
|
|
3011
3140
|
}, z.core.$loose>;
|
|
3141
|
+
time: z.ZodExactOptional<z.ZodObject<{
|
|
3142
|
+
grain: z.ZodEnum<{
|
|
3143
|
+
hour: "hour";
|
|
3144
|
+
day: "day";
|
|
3145
|
+
week: "week";
|
|
3146
|
+
month: "month";
|
|
3147
|
+
quarter: "quarter";
|
|
3148
|
+
year: "year";
|
|
3149
|
+
}>;
|
|
3150
|
+
buckets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
3151
|
+
label: z.ZodString;
|
|
3152
|
+
from: z.ZodString;
|
|
3153
|
+
to: z.ZodString;
|
|
3154
|
+
partial: z.ZodExactOptional<z.ZodEnum<{
|
|
3155
|
+
start: "start";
|
|
3156
|
+
end: "end";
|
|
3157
|
+
both: "both";
|
|
3158
|
+
}>>;
|
|
3159
|
+
}, z.core.$loose>>>;
|
|
3160
|
+
}, z.core.$loose>>;
|
|
3012
3161
|
}, z.core.$loose>>;
|
|
3013
3162
|
status: z.ZodEnum<{
|
|
3014
3163
|
complete: "complete";
|
|
@@ -3324,6 +3473,12 @@ export declare const answerSchemas: {
|
|
|
3324
3473
|
}, z.core.$loose>;
|
|
3325
3474
|
column: z.ZodExactOptional<z.ZodObject<{
|
|
3326
3475
|
id: z.ZodString;
|
|
3476
|
+
role: z.ZodEnum<{
|
|
3477
|
+
time: "time";
|
|
3478
|
+
dimension: "dimension";
|
|
3479
|
+
measure: "measure";
|
|
3480
|
+
calc: "calc";
|
|
3481
|
+
}>;
|
|
3327
3482
|
label: z.ZodString;
|
|
3328
3483
|
type: z.ZodEnum<{
|
|
3329
3484
|
string: "string";
|
|
@@ -3344,6 +3499,7 @@ export declare const answerSchemas: {
|
|
|
3344
3499
|
quarter: "quarter";
|
|
3345
3500
|
year: "year";
|
|
3346
3501
|
}>>;
|
|
3502
|
+
values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
3347
3503
|
format: z.ZodExactOptional<z.ZodEnum<{
|
|
3348
3504
|
number: "number";
|
|
3349
3505
|
percent: "percent";
|
|
@@ -3607,6 +3763,12 @@ export declare const answerSchemas: {
|
|
|
3607
3763
|
}, z.core.$loose>]>>>>>;
|
|
3608
3764
|
columns: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
3609
3765
|
id: z.ZodString;
|
|
3766
|
+
role: z.ZodEnum<{
|
|
3767
|
+
time: "time";
|
|
3768
|
+
dimension: "dimension";
|
|
3769
|
+
measure: "measure";
|
|
3770
|
+
calc: "calc";
|
|
3771
|
+
}>;
|
|
3610
3772
|
label: z.ZodString;
|
|
3611
3773
|
type: z.ZodEnum<{
|
|
3612
3774
|
string: "string";
|
|
@@ -3627,6 +3789,7 @@ export declare const answerSchemas: {
|
|
|
3627
3789
|
quarter: "quarter";
|
|
3628
3790
|
year: "year";
|
|
3629
3791
|
}>>;
|
|
3792
|
+
values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
3630
3793
|
format: z.ZodExactOptional<z.ZodEnum<{
|
|
3631
3794
|
number: "number";
|
|
3632
3795
|
percent: "percent";
|
|
@@ -3636,6 +3799,26 @@ export declare const answerSchemas: {
|
|
|
3636
3799
|
signed: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
3637
3800
|
fraction: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
3638
3801
|
}, z.core.$loose>>>;
|
|
3802
|
+
time: z.ZodExactOptional<z.ZodObject<{
|
|
3803
|
+
grain: z.ZodEnum<{
|
|
3804
|
+
hour: "hour";
|
|
3805
|
+
day: "day";
|
|
3806
|
+
week: "week";
|
|
3807
|
+
month: "month";
|
|
3808
|
+
quarter: "quarter";
|
|
3809
|
+
year: "year";
|
|
3810
|
+
}>;
|
|
3811
|
+
buckets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
3812
|
+
label: z.ZodString;
|
|
3813
|
+
from: z.ZodString;
|
|
3814
|
+
to: z.ZodString;
|
|
3815
|
+
partial: z.ZodExactOptional<z.ZodEnum<{
|
|
3816
|
+
start: "start";
|
|
3817
|
+
end: "end";
|
|
3818
|
+
both: "both";
|
|
3819
|
+
}>>;
|
|
3820
|
+
}, z.core.$loose>>>;
|
|
3821
|
+
}, z.core.$loose>>;
|
|
3639
3822
|
compare: z.ZodExactOptional<z.ZodObject<{
|
|
3640
3823
|
rows: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
3641
3824
|
t: z.ZodEnum<{
|
|
@@ -3653,6 +3836,26 @@ export declare const answerSchemas: {
|
|
|
3653
3836
|
from: z.ZodString;
|
|
3654
3837
|
to: z.ZodString;
|
|
3655
3838
|
}, z.core.$loose>;
|
|
3839
|
+
time: z.ZodExactOptional<z.ZodObject<{
|
|
3840
|
+
grain: z.ZodEnum<{
|
|
3841
|
+
hour: "hour";
|
|
3842
|
+
day: "day";
|
|
3843
|
+
week: "week";
|
|
3844
|
+
month: "month";
|
|
3845
|
+
quarter: "quarter";
|
|
3846
|
+
year: "year";
|
|
3847
|
+
}>;
|
|
3848
|
+
buckets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
3849
|
+
label: z.ZodString;
|
|
3850
|
+
from: z.ZodString;
|
|
3851
|
+
to: z.ZodString;
|
|
3852
|
+
partial: z.ZodExactOptional<z.ZodEnum<{
|
|
3853
|
+
start: "start";
|
|
3854
|
+
end: "end";
|
|
3855
|
+
both: "both";
|
|
3856
|
+
}>>;
|
|
3857
|
+
}, z.core.$loose>>>;
|
|
3858
|
+
}, z.core.$loose>>;
|
|
3656
3859
|
}, z.core.$loose>>;
|
|
3657
3860
|
status: z.ZodEnum<{
|
|
3658
3861
|
complete: "complete";
|
|
@@ -100,6 +100,7 @@ const answerSchemas = {
|
|
|
100
100
|
command: z.record(z.string(), z.unknown()),
|
|
101
101
|
query: z.record(z.string(), z.unknown()),
|
|
102
102
|
picks: z.record(z.string(), z.unknown()),
|
|
103
|
+
display: z.record(z.string(), z.record(z.string(), z.unknown())),
|
|
103
104
|
bodies: z.record(z.string(), z.record(z.string(), z.unknown()))
|
|
104
105
|
}),
|
|
105
106
|
"/meta/values": values,
|
|
@@ -12,6 +12,8 @@ export declare function toolSchemas(): {
|
|
|
12
12
|
command: JsonSchema;
|
|
13
13
|
query: JsonSchema;
|
|
14
14
|
picks: JsonSchema;
|
|
15
|
+
/** The display options of each kind of widget the library draws, by kind. */
|
|
16
|
+
display: Record<string, JsonSchema>;
|
|
15
17
|
};
|
|
16
18
|
/** A Zod schema as JSON Schema, as an agent sends it (the input side). */
|
|
17
19
|
export declare function jsonSchema(schema: z.ZodType): JsonSchema;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DISPLAY_HELP, DISPLAY_OPTIONS } from "../document/display.mjs";
|
|
1
2
|
import { commandSchema } from "./commands.mjs";
|
|
2
3
|
import { picksSchema } from "./picks.mjs";
|
|
3
4
|
import { wireQuerySchema } from "./query.mjs";
|
|
@@ -14,7 +15,32 @@ function toolSchemas() {
|
|
|
14
15
|
return {
|
|
15
16
|
command: described(jsonSchema(commandSchema)),
|
|
16
17
|
query: jsonSchema(wireQuerySchema),
|
|
17
|
-
picks: jsonSchema(picksSchema)
|
|
18
|
+
picks: jsonSchema(picksSchema),
|
|
19
|
+
display: Object.fromEntries(Object.entries(DISPLAY_OPTIONS).map(([kind, options]) => [kind, optionsSchema(options)]))
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** What each type of display option is, as JSON Schema. */
|
|
23
|
+
const OPTION_TYPES = {
|
|
24
|
+
boolean: { type: "boolean" },
|
|
25
|
+
text: { type: "string" },
|
|
26
|
+
texts: {
|
|
27
|
+
type: "array",
|
|
28
|
+
items: { type: "string" }
|
|
29
|
+
},
|
|
30
|
+
colors: {
|
|
31
|
+
type: "object",
|
|
32
|
+
additionalProperties: { type: "string" }
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/** A kind's display options as JSON Schema: each option typed and described, any other left open. */
|
|
36
|
+
function optionsSchema(options) {
|
|
37
|
+
return {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: Object.fromEntries(Object.entries(options).map(([name, type]) => [name, {
|
|
40
|
+
...OPTION_TYPES[type],
|
|
41
|
+
description: DISPLAY_HELP[name]
|
|
42
|
+
}])),
|
|
43
|
+
additionalProperties: true
|
|
18
44
|
};
|
|
19
45
|
}
|
|
20
46
|
/** A Zod schema as JSON Schema, as an agent sends it (the input side). */
|