derive-dashboards 0.1.0 → 0.1.1
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 +4 -3
- package/dist/adapter/sql-adapter.mjs +4 -4
- package/dist/body.mjs +11 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cli/check.mjs +14 -1
- package/dist/cli/import/dbt-schema.mjs +2 -2
- package/dist/cli/import/index.mjs +2 -2
- package/dist/core/conformance/cases.d.mts +3 -0
- package/dist/core/conformance/cases.mjs +20 -4
- package/dist/core/conformance/check.mjs +6 -3
- package/dist/core/conformance/drill-cases.mjs +120 -0
- package/dist/core/document/view.d.mts +26 -7
- package/dist/core/document/view.mjs +42 -11
- package/dist/core/engine/index.d.mts +14 -2
- package/dist/core/engine/index.mjs +12 -1
- package/dist/core/engine/members.mjs +1 -1
- package/dist/core/engine/postgres.mjs +1 -1
- package/dist/core/engine/record-layout.d.mts +11 -0
- package/dist/core/engine/record-layout.mjs +7 -7
- package/dist/core/engine/records.d.mts +3 -2
- package/dist/core/engine/records.mjs +2 -1
- package/dist/core/engine/segmented.mjs +5 -2
- package/dist/core/engine/sql-records.mjs +2 -1
- package/dist/core/engine/statement.mjs +37 -3
- package/dist/core/engine/types.d.mts +3 -0
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +31 -0
- package/dist/core/error/codes.mjs +28 -1
- package/dist/core/index.d.mts +9 -5
- package/dist/core/index.mjs +5 -3
- package/dist/core/model/catalog/check.mjs +1 -1
- package/dist/core/model/hints.d.mts +36 -0
- package/dist/core/model/member.d.mts +4 -2
- package/dist/core/model/member.mjs +16 -3
- package/dist/core/model/types.d.mts +8 -6
- package/dist/core/model/validate/drill.mjs +70 -0
- package/dist/core/model/validate/index.mjs +3 -0
- package/dist/core/model/validate/shape.mjs +150 -0
- package/dist/core/model/validate/source.mjs +5 -3
- package/dist/core/query/alias.mjs +7 -1
- package/dist/core/query/drill/compose.d.mts +22 -0
- package/dist/core/query/drill/compose.mjs +85 -0
- package/dist/core/query/drill/fields.d.mts +21 -0
- package/dist/core/query/drill/fields.mjs +91 -0
- package/dist/core/query/drill/internal.d.mts +11 -0
- package/dist/core/query/drill/items.d.mts +29 -0
- package/dist/core/query/drill/items.mjs +98 -0
- package/dist/core/query/drill/line.d.mts +31 -0
- package/dist/core/query/drill/line.mjs +183 -0
- package/dist/core/query/drill/links.d.mts +33 -0
- package/dist/core/query/drill/links.mjs +31 -0
- package/dist/core/query/drill/operand.mjs +7 -0
- package/dist/core/query/drill/scopes.d.mts +22 -0
- package/dist/core/query/drill/scopes.mjs +58 -0
- package/dist/core/query/drill/selection.d.mts +37 -0
- package/dist/core/query/drill/selection.mjs +144 -0
- package/dist/core/query/drill/steps.d.mts +14 -0
- package/dist/core/query/drill/steps.mjs +35 -0
- package/dist/core/query/drill/synthetic-expr.mjs +85 -0
- package/dist/core/query/drill/synthetic.d.mts +22 -0
- package/dist/core/query/drill/synthetic.mjs +165 -0
- package/dist/core/query/drill/time.d.mts +11 -0
- package/dist/core/query/drill/time.mjs +71 -0
- package/dist/core/query/drill/types.d.mts +155 -0
- package/dist/core/query/drill/types.mjs +4 -0
- package/dist/core/query/drill/views.d.mts +62 -0
- package/dist/core/query/drill/views.mjs +257 -0
- package/dist/core/query/segments.d.mts +12 -2
- package/dist/core/query/segments.mjs +3 -1
- package/dist/core/result/columns.mjs +17 -4
- package/dist/core/result/types.d.mts +5 -1
- package/dist/core/schema/answer-parts.mjs +117 -0
- package/dist/core/schema/answers.d.mts +2108 -128
- package/dist/core/schema/answers.mjs +10 -113
- package/dist/core/schema/commands.d.mts +2 -2
- package/dist/core/schema/document.d.mts +1 -1
- package/dist/core/schema/drill-answers.mjs +179 -0
- package/dist/core/schema/drill.d.mts +260 -0
- package/dist/core/schema/drill.mjs +107 -0
- package/dist/core/schema/index.d.mts +4 -2
- package/dist/core/schema/index.mjs +4 -2
- package/dist/core/schema/picks.d.mts +35 -0
- package/dist/core/schema/picks.mjs +23 -0
- package/dist/core/schema/query.d.mts +1 -1
- package/dist/core/schema/tools.mjs +1 -1
- package/dist/core/schema/view.d.mts +0 -35
- package/dist/core/schema/view.mjs +19 -24
- package/dist/core/store/schema.d.mts +5 -0
- package/dist/core/store/schema.mjs +10 -0
- package/dist/core/types/api.d.mts +15 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +210 -0
- package/dist/core/types/options.d.mts +21 -0
- package/dist/core/types/viewer.d.mts +5 -0
- package/dist/cursor-seal.d.mts +8 -0
- package/dist/cursor-seal.mjs +98 -0
- package/dist/dashboard-id.mjs +1 -1
- package/dist/drill-access.mjs +93 -0
- package/dist/drill-change.mjs +76 -0
- package/dist/drill-crumbs.mjs +113 -0
- package/dist/drill-distinct.mjs +130 -0
- package/dist/drill-explain.mjs +64 -0
- package/dist/drill-identity.mjs +35 -0
- package/dist/drill-item-id.mjs +35 -0
- package/dist/drill-items.mjs +132 -0
- package/dist/drill-open.mjs +169 -0
- package/dist/drill-seal.mjs +170 -0
- package/dist/drill-secret.mjs +14 -0
- package/dist/drill-share.mjs +53 -0
- package/dist/drill-summary.mjs +158 -0
- package/dist/drill-targets.mjs +53 -0
- package/dist/drill-totals.mjs +8 -0
- package/dist/drill-views.mjs +175 -0
- package/dist/drill.mjs +157 -0
- package/dist/editing.mjs +2 -2
- package/dist/endpoints/dashboards.mjs +11 -3
- package/dist/endpoints/drill.mjs +55 -0
- package/dist/endpoints/index.d.mts +233 -2
- package/dist/endpoints/index.mjs +5 -1
- package/dist/endpoints/query.mjs +26 -4
- package/dist/execute.d.mts +19 -1
- package/dist/execute.mjs +15 -17
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +29 -2
- package/dist/mcp/drill.mjs +61 -0
- package/dist/mcp/format.mjs +27 -3
- package/dist/mcp/index.d.mts +15 -4
- package/dist/mcp/index.mjs +13 -7
- package/dist/mcp/query.d.mts +7 -2
- package/dist/mcp/query.mjs +7 -3
- package/dist/node-postgres.d.mts +8 -4
- package/dist/node-postgres.mjs +29 -6
- package/dist/owner.mjs +3 -3
- package/dist/postgres-connection.d.mts +8 -2
- package/dist/postgres-connection.mjs +2 -1
- package/dist/react/Dashboard.d.mts +10 -5
- package/dist/react/Dashboard.mjs +51 -23
- package/dist/react/DashboardList.mjs +30 -2
- package/dist/react/Discard.mjs +7 -2
- package/dist/react/Grid.mjs +12 -5
- package/dist/react/Header.mjs +9 -0
- package/dist/react/Parts.mjs +6 -2
- package/dist/react/ReviewPanel.mjs +13 -2
- package/dist/react/RowBody.d.mts +19 -0
- package/dist/react/RowBody.mjs +55 -0
- package/dist/react/Tile.d.mts +1 -1
- package/dist/react/Tile.mjs +54 -30
- package/dist/react/builder/state.d.mts +1 -1
- package/dist/react/client.d.mts +2 -0
- package/dist/react/client.mjs +1 -0
- package/dist/react/context.d.mts +15 -1
- package/dist/react/context.mjs +19 -4
- package/dist/react/drill/Bars.mjs +179 -0
- package/dist/react/drill/Controls.mjs +173 -0
- package/dist/react/drill/DashboardTile.d.mts +18 -0
- package/dist/react/drill/DashboardTile.mjs +107 -0
- package/dist/react/drill/DrillPanel.d.mts +31 -0
- package/dist/react/drill/DrillPanel.mjs +104 -0
- package/dist/react/drill/DrillTabs.mjs +52 -0
- package/dist/react/drill/Header.mjs +131 -0
- package/dist/react/drill/Items.d.mts +22 -0
- package/dist/react/drill/Items.mjs +164 -0
- package/dist/react/drill/ItemsFoot.mjs +60 -0
- package/dist/react/drill/Notes.mjs +58 -0
- package/dist/react/drill/PanelBody.mjs +74 -0
- package/dist/react/drill/PanelStates.mjs +37 -0
- package/dist/react/drill/board.d.mts +18 -0
- package/dist/react/drill/board.mjs +91 -0
- package/dist/react/drill/counts.mjs +14 -0
- package/dist/react/drill/host.mjs +26 -0
- package/dist/react/drill/item-parts.d.mts +5 -0
- package/dist/react/drill/item-parts.mjs +76 -0
- package/dist/react/drill/item-type.d.mts +26 -0
- package/dist/react/drill/item-type.mjs +7 -0
- package/dist/react/drill/lazy.d.mts +6 -0
- package/dist/react/drill/lazy.mjs +17 -0
- package/dist/react/drill/pages.mjs +48 -0
- package/dist/react/drill/panel-focus.mjs +51 -0
- package/dist/react/drill/props.d.mts +25 -0
- package/dist/react/drill/props.mjs +72 -0
- package/dist/react/drill/state.d.mts +18 -0
- package/dist/react/drill/state.mjs +68 -0
- package/dist/react/drill/useDrill.d.mts +46 -0
- package/dist/react/drill/useDrill.mjs +194 -0
- package/dist/react/drill/words.d.mts +98 -0
- package/dist/react/drill/words.mjs +77 -0
- package/dist/react/english.mjs +9 -1
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +34 -12
- package/dist/react/index.d.mts +27 -4
- package/dist/react/index.mjs +10 -3
- package/dist/react/messages.d.mts +14 -1
- package/dist/react/renderers/index.d.mts +10 -2
- package/dist/react/renderers/index.mjs +54 -14
- package/dist/react/renderers/list.d.mts +22 -0
- package/dist/react/renderers/list.mjs +118 -0
- package/dist/react/review-words.mjs +1 -1
- package/dist/react/review.mjs +2 -2
- package/dist/react/scope.mjs +2 -7
- package/dist/react/series.d.mts +37 -0
- package/dist/react/series.mjs +95 -0
- package/dist/react/theme.css +1823 -1296
- package/dist/react/theme.css.d.ts +1 -0
- package/dist/react/tile-store.mjs +15 -3
- package/dist/react/useBoard.d.mts +5 -0
- package/dist/react/useBoard.mjs +4 -1
- package/dist/react/useDashboard.d.mts +1 -0
- package/dist/react/useDashboard.mjs +2 -1
- package/dist/react/useTiles.mjs +50 -15
- package/dist/react/view.d.mts +9 -0
- package/dist/react/view.mjs +22 -10
- package/dist/reading.d.mts +2 -0
- package/dist/reading.mjs +9 -1
- package/dist/recharts/charts.d.mts +0 -1
- package/dist/recharts/charts.mjs +128 -34
- package/dist/recharts/index.d.mts +2 -2
- package/dist/recharts/index.mjs +2 -2
- package/dist/recharts/marks.mjs +83 -0
- package/dist/recharts/series.d.mts +2 -22
- package/dist/recharts/series.mjs +1 -64
- package/dist/records-read.mjs +44 -0
- package/dist/store/apply.mjs +5 -5
- package/dist/store/commands.mjs +4 -4
- package/dist/store/discard.mjs +7 -7
- package/dist/store/drafts.mjs +5 -5
- package/dist/store/editor.mjs +1 -1
- package/dist/store/publish.mjs +12 -12
- package/dist/store/reader.mjs +41 -22
- package/dist/store/review.mjs +16 -16
- package/dist/store/rows.mjs +20 -20
- package/dist/store/undo.mjs +3 -3
- package/dist/store/unpublished.mjs +4 -4
- package/dist/store/versions.mjs +14 -14
- package/dist/testing/adapter-suite.mjs +4 -4
- package/dist/tiles.mjs +37 -3
- package/package.json +8 -10
- package/dist/react/Records.d.mts +0 -12
- package/dist/react/Records.mjs +0 -97
- package/src/adapter/sql-adapter.ts +0 -95
- package/src/adapter/statement.ts +0 -185
- package/src/authorize.ts +0 -73
- package/src/body.ts +0 -169
- package/src/bounded.ts +0 -43
- package/src/cache.ts +0 -192
- package/src/checks.ts +0 -170
- package/src/custom-source.ts +0 -59
- package/src/dashboard-id.ts +0 -36
- package/src/dashboards.ts +0 -132
- package/src/editing.ts +0 -148
- package/src/endpoints/access.ts +0 -41
- package/src/endpoints/dashboards.ts +0 -92
- package/src/endpoints/drafts.ts +0 -138
- package/src/endpoints/index.ts +0 -21
- package/src/endpoints/meta.ts +0 -137
- package/src/endpoints/query.ts +0 -86
- package/src/endpoints/read.ts +0 -92
- package/src/endpoints/review.ts +0 -89
- package/src/endpoints/values.ts +0 -62
- package/src/endpoints/versions.ts +0 -104
- package/src/execute.ts +0 -207
- package/src/handler.ts +0 -232
- package/src/http.ts +0 -66
- package/src/index.ts +0 -163
- package/src/introspect.ts +0 -205
- package/src/mcp/api.ts +0 -59
- package/src/mcp/format.ts +0 -67
- package/src/mcp/index.ts +0 -151
- package/src/mcp/query.ts +0 -153
- package/src/mcp/resolve.ts +0 -114
- package/src/node-postgres.ts +0 -81
- package/src/owner.ts +0 -36
- package/src/postgres-connection.ts +0 -143
- package/src/postgres-store.ts +0 -82
- package/src/principal.ts +0 -39
- package/src/reading.ts +0 -56
- package/src/request-rows.ts +0 -23
- package/src/request.ts +0 -22
- package/src/storage.ts +0 -63
- package/src/store/apply.ts +0 -129
- package/src/store/commands.ts +0 -75
- package/src/store/conflicts.ts +0 -98
- package/src/store/create-tables.ts +0 -104
- package/src/store/discard.ts +0 -42
- package/src/store/drafts.ts +0 -133
- package/src/store/editor.ts +0 -28
- package/src/store/log.ts +0 -28
- package/src/store/publish.ts +0 -199
- package/src/store/publisher.ts +0 -21
- package/src/store/reader.ts +0 -139
- package/src/store/review.ts +0 -239
- package/src/store/rows.ts +0 -250
- package/src/store/tenant.ts +0 -28
- package/src/store/undo.ts +0 -56
- package/src/store/unpublished.ts +0 -33
- package/src/store/versions.ts +0 -106
- package/src/store/writer.ts +0 -19
- package/src/testing/adapter-suite.ts +0 -239
- package/src/testing/index.ts +0 -2
- package/src/tile-doc.ts +0 -46
- package/src/tiles.ts +0 -120
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import "../query/drill/types.mjs";
|
|
2
|
+
import { picksSchema } from "./picks.mjs";
|
|
3
|
+
import { grain, name, primitive, wireQuerySchema } from "./query.mjs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
// src/schema/drill.ts
|
|
6
|
+
/** What a drill shows. */
|
|
7
|
+
const drillViewSchema = z.union([
|
|
8
|
+
z.strictObject({
|
|
9
|
+
by: z.literal("breakdown"),
|
|
10
|
+
member: name.exactOptional(),
|
|
11
|
+
search: z.string().max(200).exactOptional()
|
|
12
|
+
}),
|
|
13
|
+
z.strictObject({
|
|
14
|
+
by: z.literal("trend"),
|
|
15
|
+
grain: grain.exactOptional()
|
|
16
|
+
}),
|
|
17
|
+
z.strictObject({
|
|
18
|
+
by: z.literal("items"),
|
|
19
|
+
numerator: z.literal(true).exactOptional()
|
|
20
|
+
}),
|
|
21
|
+
z.strictObject({ by: z.literal("explanation") })
|
|
22
|
+
]);
|
|
23
|
+
const sealed = z.string().min(1).max(8e3);
|
|
24
|
+
/**
|
|
25
|
+
* A step of a path: a sealed selection, or, for a click the server has not normalized yet, a
|
|
26
|
+
* row of a sealed answer (`<answer>#<row>`, `#p<row>` for the comparison period's). The server
|
|
27
|
+
* answers with the path normalized to sealed selections, so only the first request carries one.
|
|
28
|
+
*/
|
|
29
|
+
const pathEntry = z.union([sealed, z.string().max(4e6).regex(/^[\w.-]+#p?\d{1,6}$/u)]);
|
|
30
|
+
const origin = z.union([z.strictObject({
|
|
31
|
+
kind: z.literal("dashboard"),
|
|
32
|
+
dashboardId: name,
|
|
33
|
+
widgetId: name,
|
|
34
|
+
query: z.string().max(100).exactOptional(),
|
|
35
|
+
picks: picksSchema,
|
|
36
|
+
document: z.union([z.strictObject({ version: z.int().min(0) }), z.strictObject({ draft: z.literal(true) })]).exactOptional()
|
|
37
|
+
}), z.strictObject({
|
|
38
|
+
kind: z.literal("query"),
|
|
39
|
+
query: wireQuerySchema
|
|
40
|
+
})]);
|
|
41
|
+
/** A drill as plain data: its origin, line, sealed execution and path, and the view open. */
|
|
42
|
+
const drillStateSchema = z.strictObject({
|
|
43
|
+
origin,
|
|
44
|
+
entry: z.string().regex(/^[mc][1-9]\d{0,2}$/u).exactOptional(),
|
|
45
|
+
execution: sealed,
|
|
46
|
+
path: z.array(pathEntry).max(8).readonly(),
|
|
47
|
+
view: drillViewSchema,
|
|
48
|
+
views: z.array(drillViewSchema).max(8).readonly().exactOptional()
|
|
49
|
+
});
|
|
50
|
+
const step = z.union([
|
|
51
|
+
z.strictObject({ group: z.array(z.strictObject({
|
|
52
|
+
member: name,
|
|
53
|
+
value: primitive
|
|
54
|
+
})).readonly() }),
|
|
55
|
+
z.strictObject({ bucket: z.strictObject({
|
|
56
|
+
member: name,
|
|
57
|
+
from: z.string(),
|
|
58
|
+
to: z.string(),
|
|
59
|
+
grain: grain.exactOptional()
|
|
60
|
+
}) }),
|
|
61
|
+
z.strictObject({ other: z.strictObject({
|
|
62
|
+
members: z.array(name).readonly(),
|
|
63
|
+
kept: z.array(z.array(primitive).readonly()).readonly()
|
|
64
|
+
}) }),
|
|
65
|
+
z.strictObject({ search: z.strictObject({
|
|
66
|
+
member: name,
|
|
67
|
+
text: z.string().max(200)
|
|
68
|
+
}) })
|
|
69
|
+
]);
|
|
70
|
+
const cell = z.union([primitive, z.strictObject({
|
|
71
|
+
t: z.enum(["int", "decimal"]),
|
|
72
|
+
v: z.string()
|
|
73
|
+
})]);
|
|
74
|
+
/** What a sealed selection opens to, checked again after it opens. */
|
|
75
|
+
const selectionSchema = z.strictObject({
|
|
76
|
+
steps: z.array(step).readonly(),
|
|
77
|
+
clicked: z.record(z.string(), cell).exactOptional(),
|
|
78
|
+
previous: z.literal(true).exactOptional(),
|
|
79
|
+
exec: z.string().max(100).exactOptional(),
|
|
80
|
+
parent: z.string().max(100).exactOptional()
|
|
81
|
+
});
|
|
82
|
+
/** What a sealed execution opens to. */
|
|
83
|
+
const pinnedSchema = z.strictObject({
|
|
84
|
+
id: z.string().max(100),
|
|
85
|
+
by: z.string().max(100),
|
|
86
|
+
revision: z.string().max(100).exactOptional(),
|
|
87
|
+
range: z.strictObject({
|
|
88
|
+
from: z.string(),
|
|
89
|
+
to: z.string()
|
|
90
|
+
}).exactOptional(),
|
|
91
|
+
compare: z.strictObject({
|
|
92
|
+
from: z.string(),
|
|
93
|
+
to: z.string()
|
|
94
|
+
}).exactOptional(),
|
|
95
|
+
now: z.string().max(40).exactOptional(),
|
|
96
|
+
calendar: z.strictObject({
|
|
97
|
+
timezone: z.string(),
|
|
98
|
+
weekStart: z.union([
|
|
99
|
+
z.literal(0),
|
|
100
|
+
z.literal(1),
|
|
101
|
+
z.literal(6)
|
|
102
|
+
]),
|
|
103
|
+
fiscalYearStartMonth: z.int().min(1).max(12)
|
|
104
|
+
}),
|
|
105
|
+
version: z.int().min(0).exactOptional()
|
|
106
|
+
});
|
|
107
|
+
export { drillStateSchema, drillViewSchema, pinnedSchema, selectionSchema };
|
|
@@ -3,7 +3,9 @@ import { AnswerSchemas, answerSchemas, tileLineSchema } from "./answers.mjs";
|
|
|
3
3
|
import { ParsedCommands, commandSchema, parseCommands } from "./commands.mjs";
|
|
4
4
|
import { customReadSchemas, groupedReadSchema, recordsReadSchema } from "./custom.mjs";
|
|
5
5
|
import { ParsedDocument, documentSchema, parseDocument } from "./document.mjs";
|
|
6
|
+
import { drillStateSchema, drillViewSchema, pinnedSchema, selectionSchema } from "./drill.mjs";
|
|
7
|
+
import { picksSchema } from "./picks.mjs";
|
|
6
8
|
import { ParsedQuery, parseWireQuery, wireQuerySchema } from "./query.mjs";
|
|
7
9
|
import { JsonSchema, jsonSchema, toolSchemas } from "./tools.mjs";
|
|
8
|
-
import { decodeView
|
|
9
|
-
export { type AnswerSchemas, DOCUMENT_UPGRADES, type JsonSchema, type Loaded, type ParsedCommands, type ParsedDocument, type ParsedQuery, SPEC_VERSION, type Upgrade, answerSchemas, commandSchema, customReadSchemas, decodeView, documentSchema, groupedReadSchema, jsonSchema, loadDocument, parseCommands, parseDocument, parseWireQuery, picksSchema, recordsReadSchema, tileLineSchema, toolSchemas, wireQuerySchema };
|
|
10
|
+
import { decodeView } from "./view.mjs";
|
|
11
|
+
export { type AnswerSchemas, DOCUMENT_UPGRADES, type JsonSchema, type Loaded, type ParsedCommands, type ParsedDocument, type ParsedQuery, SPEC_VERSION, type Upgrade, answerSchemas, commandSchema, customReadSchemas, decodeView, documentSchema, drillStateSchema, drillViewSchema, groupedReadSchema, jsonSchema, loadDocument, parseCommands, parseDocument, parseWireQuery, picksSchema, pinnedSchema, recordsReadSchema, selectionSchema, tileLineSchema, toolSchemas, wireQuerySchema };
|
|
@@ -3,7 +3,9 @@ import { answerSchemas, tileLineSchema } from "./answers.mjs";
|
|
|
3
3
|
import { commandSchema, parseCommands } from "./commands.mjs";
|
|
4
4
|
import { customReadSchemas, groupedReadSchema, recordsReadSchema } from "./custom.mjs";
|
|
5
5
|
import { documentSchema, parseDocument } from "./document.mjs";
|
|
6
|
+
import { drillStateSchema, drillViewSchema, pinnedSchema, selectionSchema } from "./drill.mjs";
|
|
7
|
+
import { picksSchema } from "./picks.mjs";
|
|
6
8
|
import { parseWireQuery, wireQuerySchema } from "./query.mjs";
|
|
7
9
|
import { jsonSchema, toolSchemas } from "./tools.mjs";
|
|
8
|
-
import { decodeView
|
|
9
|
-
export { DOCUMENT_UPGRADES, SPEC_VERSION, answerSchemas, commandSchema, customReadSchemas, decodeView, documentSchema, groupedReadSchema, jsonSchema, loadDocument, parseCommands, parseDocument, parseWireQuery, picksSchema, recordsReadSchema, tileLineSchema, toolSchemas, wireQuerySchema };
|
|
10
|
+
import { decodeView } from "./view.mjs";
|
|
11
|
+
export { DOCUMENT_UPGRADES, SPEC_VERSION, answerSchemas, commandSchema, customReadSchemas, decodeView, documentSchema, drillStateSchema, drillViewSchema, groupedReadSchema, jsonSchema, loadDocument, parseCommands, parseDocument, parseWireQuery, picksSchema, pinnedSchema, recordsReadSchema, selectionSchema, tileLineSchema, toolSchemas, wireQuerySchema };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A viewer's picks by control id, as the tile endpoints and a shared link accept them. */
|
|
3
|
+
export declare const picksSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
4
|
+
op: z.ZodEnum<{
|
|
5
|
+
equals: "equals";
|
|
6
|
+
in: "in";
|
|
7
|
+
contains: "contains";
|
|
8
|
+
startsWith: "startsWith";
|
|
9
|
+
gt: "gt";
|
|
10
|
+
gte: "gte";
|
|
11
|
+
lt: "lt";
|
|
12
|
+
lte: "lte";
|
|
13
|
+
between: "between";
|
|
14
|
+
notEquals: "notEquals";
|
|
15
|
+
notIn: "notIn";
|
|
16
|
+
notContains: "notContains";
|
|
17
|
+
set: "set";
|
|
18
|
+
notSet: "notSet";
|
|
19
|
+
}>;
|
|
20
|
+
values: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
21
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
22
|
+
last: z.ZodInt;
|
|
23
|
+
unit: z.ZodEnum<{
|
|
24
|
+
hour: "hour";
|
|
25
|
+
day: "day";
|
|
26
|
+
week: "week";
|
|
27
|
+
month: "month";
|
|
28
|
+
quarter: "quarter";
|
|
29
|
+
year: "year";
|
|
30
|
+
}>;
|
|
31
|
+
includeCurrent: z.ZodBoolean;
|
|
32
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
33
|
+
from: z.ZodString;
|
|
34
|
+
to: z.ZodString;
|
|
35
|
+
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>]>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { grain, name, op, primitive } from "./query.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/schema/picks.ts
|
|
4
|
+
/** One control's pick as a viewer sends it: values with an operator, a date range, or one value. */
|
|
5
|
+
const pick = z.union([
|
|
6
|
+
z.strictObject({
|
|
7
|
+
op,
|
|
8
|
+
values: z.array(primitive).max(100).readonly()
|
|
9
|
+
}),
|
|
10
|
+
z.strictObject({
|
|
11
|
+
last: z.int().min(1).max(1e4),
|
|
12
|
+
unit: grain,
|
|
13
|
+
includeCurrent: z.boolean()
|
|
14
|
+
}),
|
|
15
|
+
z.strictObject({
|
|
16
|
+
from: z.string().max(40),
|
|
17
|
+
to: z.string().max(40)
|
|
18
|
+
}),
|
|
19
|
+
primitive
|
|
20
|
+
]);
|
|
21
|
+
/** A viewer's picks by control id, as the tile endpoints and a shared link accept them. */
|
|
22
|
+
const picksSchema = z.record(name, pick);
|
|
23
|
+
export { pick, picksSchema };
|
|
@@ -77,8 +77,8 @@ export declare const wireQuerySchema: z.ZodObject<{
|
|
|
77
77
|
other: z.ZodExactOptional<z.ZodBoolean>;
|
|
78
78
|
total: z.ZodExactOptional<z.ZodBoolean>;
|
|
79
79
|
fill: z.ZodExactOptional<z.ZodEnum<{
|
|
80
|
-
zero: "zero";
|
|
81
80
|
none: "none";
|
|
81
|
+
zero: "zero";
|
|
82
82
|
}>>;
|
|
83
83
|
}, z.core.$strict>;
|
|
84
84
|
export type ParsedQuery = {
|
|
@@ -1,39 +1,4 @@
|
|
|
1
1
|
import { ViewState } from "../document/view.mjs";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
/** A viewer's picks by control id, as the tile endpoints and a shared link accept them. */
|
|
4
|
-
export declare const picksSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
5
|
-
op: z.ZodEnum<{
|
|
6
|
-
equals: "equals";
|
|
7
|
-
in: "in";
|
|
8
|
-
contains: "contains";
|
|
9
|
-
startsWith: "startsWith";
|
|
10
|
-
gt: "gt";
|
|
11
|
-
gte: "gte";
|
|
12
|
-
lt: "lt";
|
|
13
|
-
lte: "lte";
|
|
14
|
-
between: "between";
|
|
15
|
-
notEquals: "notEquals";
|
|
16
|
-
notIn: "notIn";
|
|
17
|
-
notContains: "notContains";
|
|
18
|
-
set: "set";
|
|
19
|
-
notSet: "notSet";
|
|
20
|
-
}>;
|
|
21
|
-
values: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
22
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
23
|
-
last: z.ZodInt;
|
|
24
|
-
unit: z.ZodEnum<{
|
|
25
|
-
hour: "hour";
|
|
26
|
-
day: "day";
|
|
27
|
-
week: "week";
|
|
28
|
-
month: "month";
|
|
29
|
-
quarter: "quarter";
|
|
30
|
-
year: "year";
|
|
31
|
-
}>;
|
|
32
|
-
includeCurrent: z.ZodBoolean;
|
|
33
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
34
|
-
from: z.ZodString;
|
|
35
|
-
to: z.ZodString;
|
|
36
|
-
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>]>>;
|
|
37
2
|
/**
|
|
38
3
|
* A view read back from URL search parameters (`encodeView` wrote them): each pick checked as
|
|
39
4
|
* the tile endpoints check one, and a parameter that is not a view's left out and named in
|
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
import { VIEW_KEYS } from "../document/view.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { drillStateSchema } from "./drill.mjs";
|
|
3
|
+
import { pick } from "./picks.mjs";
|
|
4
|
+
import { name } from "./query.mjs";
|
|
4
5
|
// src/schema/view.ts
|
|
5
|
-
/** One control's pick as a viewer sends it: values with an operator, a date range, or one value. */
|
|
6
|
-
const pick = z.union([
|
|
7
|
-
z.strictObject({
|
|
8
|
-
op,
|
|
9
|
-
values: z.array(primitive).max(100).readonly()
|
|
10
|
-
}),
|
|
11
|
-
z.strictObject({
|
|
12
|
-
last: z.int().min(1).max(1e4),
|
|
13
|
-
unit: grain,
|
|
14
|
-
includeCurrent: z.boolean()
|
|
15
|
-
}),
|
|
16
|
-
z.strictObject({
|
|
17
|
-
from: z.string().max(40),
|
|
18
|
-
to: z.string().max(40)
|
|
19
|
-
}),
|
|
20
|
-
primitive
|
|
21
|
-
]);
|
|
22
|
-
/** A viewer's picks by control id, as the tile endpoints and a shared link accept them. */
|
|
23
|
-
const picksSchema = z.record(name, pick);
|
|
24
6
|
/** A pick from its JSON, or null when it is not JSON or not a pick. */
|
|
25
7
|
function readPick(text) {
|
|
26
8
|
try {
|
|
@@ -30,9 +12,19 @@ function readPick(text) {
|
|
|
30
12
|
return null;
|
|
31
13
|
}
|
|
32
14
|
}
|
|
33
|
-
/**
|
|
15
|
+
/** A drill from its JSON, or null when it is not one. */
|
|
16
|
+
function readDrill(text) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = drillStateSchema.safeParse(JSON.parse(text));
|
|
19
|
+
return parsed.success ? { drill: parsed.data } : null;
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** One parameter of a view: a tab, a pick, a drill, or something that is neither. */
|
|
34
25
|
function readParam(rest, text) {
|
|
35
26
|
if (rest === VIEW_KEYS.tab) return { tab: text };
|
|
27
|
+
if (rest === VIEW_KEYS.drill) return readDrill(text);
|
|
36
28
|
const id = rest.startsWith(VIEW_KEYS.filter) ? rest.slice(VIEW_KEYS.filter.length) : "";
|
|
37
29
|
const read = readPick(text);
|
|
38
30
|
if (!name.safeParse(id).success || read === null) return null;
|
|
@@ -52,20 +44,23 @@ function decodeView(params, prefix = "dd.") {
|
|
|
52
44
|
const picks = {};
|
|
53
45
|
const dropped = [];
|
|
54
46
|
let tab;
|
|
47
|
+
let drill;
|
|
55
48
|
for (const [key, text] of params) {
|
|
56
49
|
if (!key.startsWith(prefix)) continue;
|
|
57
50
|
const rest = key.slice(prefix.length);
|
|
58
51
|
const read = readParam(rest, text);
|
|
59
52
|
if (read === null) dropped.push(rest.startsWith(VIEW_KEYS.filter) ? rest.slice(VIEW_KEYS.filter.length) : rest);
|
|
60
53
|
else if ("tab" in read) tab = read.tab;
|
|
54
|
+
else if ("drill" in read) drill = read.drill;
|
|
61
55
|
else picks[read.pick.id] = read.pick.value;
|
|
62
56
|
}
|
|
63
57
|
return {
|
|
64
58
|
view: {
|
|
65
59
|
...tab === void 0 ? {} : { tab },
|
|
66
|
-
picks
|
|
60
|
+
picks,
|
|
61
|
+
drill
|
|
67
62
|
},
|
|
68
63
|
dropped
|
|
69
64
|
};
|
|
70
65
|
}
|
|
71
|
-
export { decodeView
|
|
66
|
+
export { decodeView };
|
|
@@ -242,6 +242,11 @@ export declare const TABLES: {
|
|
|
242
242
|
readonly name: "dd_dashboard_draft_author";
|
|
243
243
|
readonly fields: readonly ["dashboard_id", "author_kind", "author_id"];
|
|
244
244
|
}];
|
|
245
|
+
/** A person's open drafts in their tenant, for the dashboard list, without a scan of every tenant's. */
|
|
246
|
+
readonly indexes: readonly [{
|
|
247
|
+
readonly name: "dd_dashboard_draft_open";
|
|
248
|
+
readonly fields: readonly ["tenant_hash", "author_kind", "author_id", "state"];
|
|
249
|
+
}];
|
|
245
250
|
};
|
|
246
251
|
/**
|
|
247
252
|
* The commands a draft applied, in order, with their bodies: a retry is acknowledged and
|
|
@@ -140,6 +140,16 @@ const TABLES = {
|
|
|
140
140
|
"author_kind",
|
|
141
141
|
"author_id"
|
|
142
142
|
]
|
|
143
|
+
}],
|
|
144
|
+
/** A person's open drafts in their tenant, for the dashboard list, without a scan of every tenant's. */
|
|
145
|
+
indexes: [{
|
|
146
|
+
name: "dd_dashboard_draft_open",
|
|
147
|
+
fields: [
|
|
148
|
+
"tenant_hash",
|
|
149
|
+
"author_kind",
|
|
150
|
+
"author_id",
|
|
151
|
+
"state"
|
|
152
|
+
]
|
|
143
153
|
}]
|
|
144
154
|
},
|
|
145
155
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command, CommandBody, Doc } from "../document/types.mjs";
|
|
2
2
|
import { Cell, Picks, WireQuery } from "../query/types.mjs";
|
|
3
3
|
import { RecordColumn, Result } from "../result/types.mjs";
|
|
4
|
+
import { AnswerDrill, DrillAnswer, DrillBody } from "./drill-api.mjs";
|
|
4
5
|
import { Issue, Primitive } from "./primitives.mjs";
|
|
5
6
|
import { Draft, Preview, Published, VersionEntry } from "./store.mjs";
|
|
6
7
|
/** The HTTP contract between the handler and its clients. */
|
|
@@ -83,6 +84,7 @@ export type RecordsResponse = {
|
|
|
83
84
|
/** A free query's answer. */
|
|
84
85
|
export type QueryAnswer = Result & {
|
|
85
86
|
unreadable?: true;
|
|
87
|
+
drill?: AnswerDrill;
|
|
86
88
|
};
|
|
87
89
|
/** One line of the `/query/batch` stream, as `/dashboards/tiles` streams tiles. */
|
|
88
90
|
export type QueryLine = {
|
|
@@ -124,6 +126,8 @@ export type TileAnswer = Result & {
|
|
|
124
126
|
widgetId: string;
|
|
125
127
|
/** The viewer can read no row of this tile's source. */
|
|
126
128
|
unreadable?: true;
|
|
129
|
+
/** What a click on a row sends to drill into it; absent where drilling is off. */
|
|
130
|
+
drill?: AnswerDrill;
|
|
127
131
|
};
|
|
128
132
|
/** One tile's answer, or why it was refused; the other tiles still answer. */
|
|
129
133
|
export type TileResult = TileAnswer | {
|
|
@@ -209,12 +213,22 @@ export type CoreContract = {
|
|
|
209
213
|
};
|
|
210
214
|
answer: RecordsResponse;
|
|
211
215
|
};
|
|
216
|
+
/** The rows behind a mark of a tile: broken down, over time, or as its items. */
|
|
217
|
+
"/dashboards/drill": {
|
|
218
|
+
body: DrillBody;
|
|
219
|
+
answer: DrillAnswer;
|
|
220
|
+
};
|
|
212
221
|
"/query/run": {
|
|
213
222
|
body: {
|
|
214
223
|
query: WireQuery;
|
|
215
224
|
};
|
|
216
225
|
answer: QueryAnswer;
|
|
217
226
|
};
|
|
227
|
+
/** The rows behind a mark of a free query, as `/dashboards/drill`. */
|
|
228
|
+
"/query/drill": {
|
|
229
|
+
body: DrillBody;
|
|
230
|
+
answer: DrillAnswer;
|
|
231
|
+
};
|
|
218
232
|
"/dashboards/draft/start": {
|
|
219
233
|
body: {
|
|
220
234
|
dashboardId: string;
|
|
@@ -324,4 +338,4 @@ export type CoreContract = {
|
|
|
324
338
|
* than reading a shape it does not know. A test recomputes it from the answer schemas, so a
|
|
325
339
|
* change to an answer fails until this is updated.
|
|
326
340
|
*/
|
|
327
|
-
export declare const CONTRACT_VERSION = "
|
|
341
|
+
export declare const CONTRACT_VERSION = "1a5793ca2a46d9e9";
|
package/dist/core/types/api.mjs
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* than reading a shape it does not know. A test recomputes it from the answer schemas, so a
|
|
6
6
|
* change to an answer fails until this is updated.
|
|
7
7
|
*/
|
|
8
|
-
const CONTRACT_VERSION = "
|
|
8
|
+
const CONTRACT_VERSION = "1a5793ca2a46d9e9";
|
|
9
9
|
export { CONTRACT_VERSION };
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { DrillReason } from "../error/codes.mjs";
|
|
2
|
+
import { Noun, NumberFormat, Tone } from "../model/hints.mjs";
|
|
3
|
+
import { ItemsOrder } from "../query/drill/items.mjs";
|
|
4
|
+
import { DrillCan, DrillField, DrillSemantics, DrillState } from "../query/drill/types.mjs";
|
|
5
|
+
import { Cell, Grain, ResolvedRange } from "../query/types.mjs";
|
|
6
|
+
import { Receipt, RecordColumn, Result, ResultColumn } from "../result/types.mjs";
|
|
7
|
+
import { Primitive } from "./primitives.mjs";
|
|
8
|
+
/** Rows of an answer that do not open, each with why (a code a host can translate, and its text). */
|
|
9
|
+
export type ClosedRow = {
|
|
10
|
+
row: number;
|
|
11
|
+
code: DrillReason;
|
|
12
|
+
reason: string;
|
|
13
|
+
};
|
|
14
|
+
/** One answer as a drill reads it: sealed once, so a click names one of its rows. */
|
|
15
|
+
export type SealedAnswer = {
|
|
16
|
+
/** The answer's rows as drawn (their groups, buckets and the kept sets of Other), sealed. */
|
|
17
|
+
answer: string;
|
|
18
|
+
/** The rows that do not open, with why; every other row opens. */
|
|
19
|
+
closed?: ClosedRow[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* What an answer gives a client to drill with: the execution it ran under (its range, calendar
|
|
23
|
+
* and version, sealed), and the answer itself sealed once (`SealedAnswer`). A click sends back
|
|
24
|
+
* the answer and a row's place (`drillFrom` writes it); the server reads the row's selection
|
|
25
|
+
* from it and answers with the path normalized to one sealed selection per step.
|
|
26
|
+
*/
|
|
27
|
+
export type AnswerDrill = SealedAnswer & {
|
|
28
|
+
execution: string;
|
|
29
|
+
/** The comparison period's rows (`compare.rows`), when there is one. */
|
|
30
|
+
previous?: SealedAnswer;
|
|
31
|
+
/** Why some rows do not open (`code` for a client to word it, `reason` in English). */
|
|
32
|
+
code?: DrillReason;
|
|
33
|
+
reason?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A drill request: the drill, and for Items the page asked for. `summary: false` says the
|
|
37
|
+
* client already has this path's summary (another view, the next page), so it is not read again.
|
|
38
|
+
*/
|
|
39
|
+
export type DrillBody = {
|
|
40
|
+
state: DrillState;
|
|
41
|
+
page?: {
|
|
42
|
+
after?: string;
|
|
43
|
+
limit?: number;
|
|
44
|
+
};
|
|
45
|
+
summary?: false;
|
|
46
|
+
};
|
|
47
|
+
/** Whether a drill can show each view, and why not. */
|
|
48
|
+
export type DrillAbilities = {
|
|
49
|
+
breakdown: DrillCan;
|
|
50
|
+
trend: DrillCan;
|
|
51
|
+
items: DrillCan;
|
|
52
|
+
explanation: DrillCan;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The numbers a drill keeps apart: its line's value now (`value`), its value when the chart
|
|
56
|
+
* was drawn (`clicked`, only for the viewer who drew it), how many rows are behind it
|
|
57
|
+
* (`itemCount`), what those rows are, and its share of the step before when its line adds up
|
|
58
|
+
* and no row can be negative.
|
|
59
|
+
*/
|
|
60
|
+
export type DrillSummary = {
|
|
61
|
+
value: Cell;
|
|
62
|
+
clicked?: Cell;
|
|
63
|
+
itemCount?: Cell;
|
|
64
|
+
/**
|
|
65
|
+
* For a line that counts only rows whose field is set (an average, a sum): the rows behind
|
|
66
|
+
* the mark whether or not it is set, so "396 tasks with hours (57 without)" can be said.
|
|
67
|
+
*/
|
|
68
|
+
rows?: Cell;
|
|
69
|
+
/** The field those rows have set, by its label ("Hours"). */
|
|
70
|
+
operand?: string;
|
|
71
|
+
semantics: DrillSemantics;
|
|
72
|
+
/** The line counts rows (a count, not a sum that may equal one): its value is its rows. */
|
|
73
|
+
counted?: true;
|
|
74
|
+
/** `parent`: of the step before; `tile`: of the whole chart. */
|
|
75
|
+
share?: {
|
|
76
|
+
value: number;
|
|
77
|
+
of: "parent" | "tile";
|
|
78
|
+
};
|
|
79
|
+
can: DrillAbilities;
|
|
80
|
+
/** The fields Breakdown may group by at this step, first the one it opens on. */
|
|
81
|
+
offered: DrillField[];
|
|
82
|
+
receipt: Receipt;
|
|
83
|
+
/** The line's column: its label, type and unit, to format the value. */
|
|
84
|
+
column?: ResultColumn;
|
|
85
|
+
/** What one row of the source is called, to say how many there are. */
|
|
86
|
+
noun?: Noun;
|
|
87
|
+
/** The window read: the tile's range, or the period before for a mark of it (`previous`). */
|
|
88
|
+
range?: ResolvedRange;
|
|
89
|
+
previous?: true;
|
|
90
|
+
/**
|
|
91
|
+
* The link was drawn by another viewer: nothing it saw travels (no clicked value), and the
|
|
92
|
+
* counts are of the rows this viewer can see.
|
|
93
|
+
*/
|
|
94
|
+
foreign?: true;
|
|
95
|
+
/** Part of the link was left out: a step this viewer may not open. Never how many rows. */
|
|
96
|
+
omitted?: true;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* One selection of the path as a breadcrumb reads it: its fields and its values. A total (the
|
|
100
|
+
* whole tile, a row's or a column's) is `total`, with no label of its own. A selection of more
|
|
101
|
+
* than one step (a segment and its Other) lists each in `parts`.
|
|
102
|
+
*/
|
|
103
|
+
export type DrillCrumb = {
|
|
104
|
+
label: string;
|
|
105
|
+
value: Cell;
|
|
106
|
+
kind?: "group" | "time" | "other" | "total" | "search";
|
|
107
|
+
/** A time step's grain, to name it as the chart does ("Week of Nov 9"). */
|
|
108
|
+
grain?: Grain;
|
|
109
|
+
parts?: DrillCrumb[];
|
|
110
|
+
/** A mark of the period before. */
|
|
111
|
+
previous?: true;
|
|
112
|
+
};
|
|
113
|
+
/** One row behind a drill: its source, an opaque stable id, its key (unless the model hides it) and its values by member. */
|
|
114
|
+
export type DrillItem = {
|
|
115
|
+
source: string;
|
|
116
|
+
id: string;
|
|
117
|
+
key?: Record<string, Primitive>;
|
|
118
|
+
values: Record<string, Cell>;
|
|
119
|
+
/** Where it opens in the host's app, from the server's `itemLinks`. */
|
|
120
|
+
link?: string;
|
|
121
|
+
};
|
|
122
|
+
/** A Breakdown or Over time: an answer, sealed once for its clicks, and the fields offered. */
|
|
123
|
+
export type DrillGroupedView = {
|
|
124
|
+
by: "breakdown" | "trend";
|
|
125
|
+
answer: Result & {
|
|
126
|
+
unreadable?: true;
|
|
127
|
+
};
|
|
128
|
+
drill: SealedAnswer;
|
|
129
|
+
offered: DrillField[];
|
|
130
|
+
member?: string;
|
|
131
|
+
grain?: Grain;
|
|
132
|
+
/** Over time: the range it draws, and the grains it may be drawn at. */
|
|
133
|
+
range?: ResolvedRange;
|
|
134
|
+
grains?: Grain[];
|
|
135
|
+
/** A Breakdown of the change: each group now (the line), before (`c1`) and its change (`c2`). */
|
|
136
|
+
change?: true;
|
|
137
|
+
/** The field has more values than a Breakdown draws: a search narrows them. */
|
|
138
|
+
searchable?: true;
|
|
139
|
+
search?: string;
|
|
140
|
+
/** A Breakdown of a line that does not add up ranks its groups by their rows (`m<n>`). */
|
|
141
|
+
rankedBy?: string;
|
|
142
|
+
};
|
|
143
|
+
/** A record column as Items show it: with its number format when the model gives one. */
|
|
144
|
+
export type ItemColumn = RecordColumn & {
|
|
145
|
+
format?: NumberFormat;
|
|
146
|
+
unit?: string;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* A page of Items: the columns each item has, labelled and typed; the items; the page after;
|
|
150
|
+
* the field each item shows as its value (a sum's, an average's) and how they are sorted.
|
|
151
|
+
*/
|
|
152
|
+
export type DrillItemsView = {
|
|
153
|
+
by: "items";
|
|
154
|
+
source: string;
|
|
155
|
+
columns: ItemColumn[];
|
|
156
|
+
items: DrillItem[];
|
|
157
|
+
next?: string;
|
|
158
|
+
value?: string;
|
|
159
|
+
sort: "records" | "value" | "count";
|
|
160
|
+
/** The records order, when `sort` is `records`: "newest first", "by priority". */
|
|
161
|
+
sorted?: ItemsOrder;
|
|
162
|
+
/** The fields the path fixes: the same on every item, so a list does not repeat them. */
|
|
163
|
+
fixed?: string[];
|
|
164
|
+
/** The field that names each item in a list. */
|
|
165
|
+
title?: string;
|
|
166
|
+
/** The field shown as each item's badge, and the tone of each of its values. */
|
|
167
|
+
badge?: {
|
|
168
|
+
member: string;
|
|
169
|
+
tones?: Readonly<Record<string, Tone>>;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* A ratio's numerator: its label, how many of the rows it counts, the field that marks each row
|
|
173
|
+
* it counts, and whether the list shows only those (`only`). Without `flag`, rows carry no
|
|
174
|
+
* mark, and `unmarked` is set (its reason is `DRILL_REASONS.RATIO_UNMARKED`).
|
|
175
|
+
*/
|
|
176
|
+
numerator?: {
|
|
177
|
+
label: string;
|
|
178
|
+
count?: Cell;
|
|
179
|
+
flag?: string;
|
|
180
|
+
only?: true;
|
|
181
|
+
unmarked?: true;
|
|
182
|
+
};
|
|
183
|
+
/** A percentile's fraction (90 for p90), for the marker row. */
|
|
184
|
+
percentile?: number;
|
|
185
|
+
/** A list cut at the row cap: more values exist than it can page through. */
|
|
186
|
+
truncated?: true;
|
|
187
|
+
};
|
|
188
|
+
/** One part of a formula, in its own scope: its value, and its own drill when it has one. */
|
|
189
|
+
export type DrillOperand = {
|
|
190
|
+
entry: string;
|
|
191
|
+
scope: "row" | "total" | "bucket" | "previous";
|
|
192
|
+
label: string;
|
|
193
|
+
value: Cell;
|
|
194
|
+
/** The drill that opens this part on its own, already sealed; absent when it cannot open. */
|
|
195
|
+
state?: DrillState;
|
|
196
|
+
can: DrillCan;
|
|
197
|
+
};
|
|
198
|
+
/** A formula's parts: each operand with its own scope and value, each drillable on its own. */
|
|
199
|
+
export type DrillExplanationView = {
|
|
200
|
+
by: "explanation";
|
|
201
|
+
operands: DrillOperand[];
|
|
202
|
+
};
|
|
203
|
+
/** A drill's answer: its summary, its path as breadcrumbs, its state normalized, and its view. */
|
|
204
|
+
export type DrillAnswer = {
|
|
205
|
+
/** Absent when the request said it already has it (`summary: false`). */
|
|
206
|
+
summary?: DrillSummary;
|
|
207
|
+
path: DrillCrumb[];
|
|
208
|
+
state: DrillState;
|
|
209
|
+
view: DrillGroupedView | DrillItemsView | DrillExplanationView;
|
|
210
|
+
};
|
|
@@ -2,6 +2,7 @@ import { Doc } from "../document/types.mjs";
|
|
|
2
2
|
import { CustomSource } from "../engine/custom/request.mjs";
|
|
3
3
|
import { Model } from "../model/types.mjs";
|
|
4
4
|
import { CompositionPolicy } from "../query/compose.mjs";
|
|
5
|
+
import { ItemLinks } from "../query/drill/links.mjs";
|
|
5
6
|
import { DashPlugin } from "./plugin.mjs";
|
|
6
7
|
import { Awaitable, ConnectionId, IanaZone, WeekStart } from "./primitives.mjs";
|
|
7
8
|
import { QueryConnection } from "./source.mjs";
|
|
@@ -42,6 +43,14 @@ export type DashOptions = {
|
|
|
42
43
|
*/
|
|
43
44
|
connections: Record<ConnectionId, QueryConnection | CustomSource | ((request: Request) => QueryConnection | CustomSource)>;
|
|
44
45
|
viewer: (request: Request) => Awaitable<Viewer | null>;
|
|
46
|
+
/**
|
|
47
|
+
* The key for everything the server seals or signs: records and Items cursors, a drill's
|
|
48
|
+
* execution, its sealed answers and selections, and hidden item ids. Optional: without it,
|
|
49
|
+
* each process makes its own key, so a drill link or cursor opens only on the process that
|
|
50
|
+
* gave it and stops working after a restart. Set one shared secret in production, and
|
|
51
|
+
* whenever several instances serve the same app; the server warns at startup without one.
|
|
52
|
+
*/
|
|
53
|
+
secret?: string;
|
|
45
54
|
/** `can` is required. Access is never open by default. */
|
|
46
55
|
access: {
|
|
47
56
|
can: CanFn;
|
|
@@ -91,4 +100,16 @@ export type DashOptions = {
|
|
|
91
100
|
now?: () => Date;
|
|
92
101
|
compose?: CompositionPolicy;
|
|
93
102
|
trustedOrigins?: readonly string[];
|
|
103
|
+
/**
|
|
104
|
+
* Where each source's items open in your app, `{ order: "/orders/{id}" }`: the links an agent's
|
|
105
|
+
* drill answers carry (`dashboards_query` rows). The React UI takes the same map as a prop.
|
|
106
|
+
*/
|
|
107
|
+
itemLinks?: ItemLinks;
|
|
108
|
+
/**
|
|
109
|
+
* Drill-in: answers carry what a click drills, and the drill endpoints answer. On by default;
|
|
110
|
+
* `false` turns it off for the whole server: answers carry nothing to drill, the drill
|
|
111
|
+
* endpoints refuse (`DRILL_DENIED`, naming this option) and the React UI shows no drill and no
|
|
112
|
+
* Rows. A source or field with `drill: false` in the model is kept out on its own.
|
|
113
|
+
*/
|
|
114
|
+
drill?: boolean;
|
|
94
115
|
};
|