derive-dashboards 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/body.mjs +2 -2
- package/dist/charts/data/buckets.d.mts +11 -0
- package/dist/charts/data/buckets.mjs +66 -0
- package/dist/charts/data/clean.mjs +55 -0
- package/dist/charts/data/format.d.mts +19 -0
- package/dist/charts/data/format.mjs +174 -0
- package/dist/charts/data/input-error.d.mts +5 -0
- package/dist/charts/data/input-error.mjs +11 -0
- package/dist/charts/data/range.mjs +14 -0
- package/dist/charts/data/rows.d.mts +13 -0
- package/dist/charts/data/rows.mjs +31 -0
- package/dist/charts/data/shares.mjs +55 -0
- package/dist/charts/data/types.d.mts +106 -0
- package/dist/charts/data/words.d.mts +44 -0
- package/dist/charts/data/words.mjs +31 -0
- package/dist/charts/describe.mjs +110 -0
- package/dist/charts/index.d.mts +34 -0
- package/dist/charts/index.mjs +24 -0
- package/dist/charts/kinds/area-marks.mjs +120 -0
- package/dist/charts/kinds/area.d.mts +23 -0
- package/dist/charts/kinds/area.mjs +71 -0
- package/dist/charts/kinds/bars-data.d.mts +11 -0
- package/dist/charts/kinds/bars-data.mjs +30 -0
- package/dist/charts/kinds/bars-layout.mjs +30 -0
- package/dist/charts/kinds/bars-marks.mjs +93 -0
- package/dist/charts/kinds/bars-words.mjs +56 -0
- package/dist/charts/kinds/bars.d.mts +17 -0
- package/dist/charts/kinds/bars.mjs +68 -0
- package/dist/charts/kinds/columns-data.mjs +116 -0
- package/dist/charts/kinds/columns-layout.mjs +29 -0
- package/dist/charts/kinds/columns-marks.mjs +200 -0
- package/dist/charts/kinds/columns-words.mjs +26 -0
- package/dist/charts/kinds/columns.d.mts +13 -0
- package/dist/charts/kinds/columns.mjs +80 -0
- package/dist/charts/kinds/dumbbell-data.d.mts +22 -0
- package/dist/charts/kinds/dumbbell-data.mjs +59 -0
- package/dist/charts/kinds/dumbbell-layout.mjs +113 -0
- package/dist/charts/kinds/dumbbell-marks.mjs +119 -0
- package/dist/charts/kinds/dumbbell-words.d.mts +7 -0
- package/dist/charts/kinds/dumbbell-words.mjs +94 -0
- package/dist/charts/kinds/dumbbell.d.mts +14 -0
- package/dist/charts/kinds/dumbbell.mjs +67 -0
- package/dist/charts/kinds/funnel-data.d.mts +11 -0
- package/dist/charts/kinds/funnel-data.mjs +70 -0
- package/dist/charts/kinds/funnel-layout.mjs +32 -0
- package/dist/charts/kinds/funnel-marks.mjs +204 -0
- package/dist/charts/kinds/funnel-words.mjs +77 -0
- package/dist/charts/kinds/funnel.d.mts +11 -0
- package/dist/charts/kinds/funnel.mjs +75 -0
- package/dist/charts/kinds/grid-data.d.mts +18 -0
- package/dist/charts/kinds/grid-data.mjs +35 -0
- package/dist/charts/kinds/grid-layout.mjs +77 -0
- package/dist/charts/kinds/grid-marks.mjs +140 -0
- package/dist/charts/kinds/grid-time.mjs +41 -0
- package/dist/charts/kinds/grid-words.mjs +86 -0
- package/dist/charts/kinds/grid.d.mts +22 -0
- package/dist/charts/kinds/grid.mjs +55 -0
- package/dist/charts/kinds/histogram-data.mjs +142 -0
- package/dist/charts/kinds/histogram-layout.mjs +144 -0
- package/dist/charts/kinds/histogram-marks.mjs +110 -0
- package/dist/charts/kinds/histogram-words.mjs +104 -0
- package/dist/charts/kinds/histogram.d.mts +15 -0
- package/dist/charts/kinds/histogram.mjs +47 -0
- package/dist/charts/kinds/line-marks.mjs +36 -0
- package/dist/charts/kinds/line.d.mts +17 -0
- package/dist/charts/kinds/line.mjs +52 -0
- package/dist/charts/kinds/multiples-grid.mjs +107 -0
- package/dist/charts/kinds/multiples-head.mjs +44 -0
- package/dist/charts/kinds/multiples-layout.mjs +159 -0
- package/dist/charts/kinds/multiples-marks.mjs +95 -0
- package/dist/charts/kinds/multiples-words.mjs +110 -0
- package/dist/charts/kinds/multiples.d.mts +26 -0
- package/dist/charts/kinds/multiples.mjs +42 -0
- package/dist/charts/kinds/row-chart.mjs +112 -0
- package/dist/charts/kinds/row-marks.mjs +121 -0
- package/dist/charts/kinds/scatter-data.d.mts +18 -0
- package/dist/charts/kinds/scatter-data.mjs +123 -0
- package/dist/charts/kinds/scatter-layout.mjs +189 -0
- package/dist/charts/kinds/scatter-marks.mjs +149 -0
- package/dist/charts/kinds/scatter-words.mjs +80 -0
- package/dist/charts/kinds/scatter.d.mts +21 -0
- package/dist/charts/kinds/scatter.mjs +72 -0
- package/dist/charts/kinds/stat-data.mjs +91 -0
- package/dist/charts/kinds/stat-layout.mjs +108 -0
- package/dist/charts/kinds/stat-marks.mjs +85 -0
- package/dist/charts/kinds/stat-words.mjs +57 -0
- package/dist/charts/kinds/stat.d.mts +28 -0
- package/dist/charts/kinds/stat.mjs +35 -0
- package/dist/charts/kinds/time-chart.mjs +74 -0
- package/dist/charts/kinds/time-frame.mjs +113 -0
- package/dist/charts/kinds/time-notes.mjs +36 -0
- package/dist/charts/kinds/time-plan.d.mts +8 -0
- package/dist/charts/kinds/time-plan.mjs +57 -0
- package/dist/charts/kinds/time-plot.mjs +56 -0
- package/dist/charts/kinds/time-stops.mjs +56 -0
- package/dist/charts/kinds/value-plot.mjs +33 -0
- package/dist/charts/kinds/waterfall-data.d.mts +7 -0
- package/dist/charts/kinds/waterfall-data.mjs +71 -0
- package/dist/charts/kinds/waterfall-layout.mjs +38 -0
- package/dist/charts/kinds/waterfall-marks.mjs +82 -0
- package/dist/charts/kinds/waterfall-words.mjs +118 -0
- package/dist/charts/kinds/waterfall.d.mts +17 -0
- package/dist/charts/kinds/waterfall.mjs +66 -0
- package/dist/charts/layout/boxes.mjs +28 -0
- package/dist/charts/layout/dodge.mjs +75 -0
- package/dist/charts/layout/extent.mjs +25 -0
- package/dist/charts/layout/frame.mjs +97 -0
- package/dist/charts/layout/place-labels.mjs +101 -0
- package/dist/charts/layout/stack.mjs +31 -0
- package/dist/charts/marks/axes.mjs +137 -0
- package/dist/charts/marks/dot.mjs +31 -0
- package/dist/charts/marks/end-labels.mjs +124 -0
- package/dist/charts/marks/legend.mjs +141 -0
- package/dist/charts/marks/lines.d.mts +2 -0
- package/dist/charts/marks/lines.mjs +38 -0
- package/dist/charts/marks/lit.d.mts +3 -0
- package/dist/charts/marks/lit.mjs +63 -0
- package/dist/charts/marks/more.mjs +18 -0
- package/dist/charts/marks/notes.mjs +253 -0
- package/dist/charts/marks/series-line.mjs +110 -0
- package/dist/charts/marks/thin.mjs +138 -0
- package/dist/charts/marks/x-axis.mjs +32 -0
- package/dist/charts/scale/calendar.mjs +174 -0
- package/dist/charts/scale/time-ticks.mjs +154 -0
- package/dist/charts/scale/time.mjs +33 -0
- package/dist/charts/scale/value.mjs +161 -0
- package/dist/charts/scene/defs.mjs +33 -0
- package/dist/charts/scene/markup.mjs +35 -0
- package/dist/charts/scene/nearest.d.mts +11 -0
- package/dist/charts/scene/nearest.mjs +49 -0
- package/dist/charts/scene/paint.d.mts +12 -0
- package/dist/charts/scene/paint.mjs +13 -0
- package/dist/charts/scene/svg.d.mts +18 -0
- package/dist/charts/scene/svg.mjs +185 -0
- package/dist/charts/scene/types.d.mts +177 -0
- package/dist/charts/text/measure.d.mts +9 -0
- package/dist/charts/text/measure.mjs +123 -0
- package/dist/charts/theme.d.mts +47 -0
- package/dist/charts/theme.mjs +239 -0
- package/dist/charts-react/Chart.d.mts +91 -0
- package/dist/charts-react/Chart.mjs +166 -0
- package/dist/charts-react/Overlay.mjs +171 -0
- package/dist/charts-react/Picture.mjs +22 -0
- package/dist/charts-react/Reader.mjs +147 -0
- package/dist/charts-react/bucket-names.mjs +29 -0
- package/dist/charts-react/chart-unlayered.css +1 -0
- package/dist/charts-react/chart-unlayered.css.d.ts +1 -0
- package/dist/charts-react/chart.css +1 -0
- package/dist/charts-react/chart.css.d.ts +1 -0
- package/dist/charts-react/events.mjs +72 -0
- package/dist/charts-react/exact-sum.mjs +24 -0
- package/dist/charts-react/from-answer.mjs +185 -0
- package/dist/charts-react/index.d.mts +3 -0
- package/dist/charts-react/index.mjs +4 -0
- package/dist/charts-react/keys.mjs +117 -0
- package/dist/charts-react/opens.mjs +28 -0
- package/dist/charts-react/plan-bars.mjs +95 -0
- package/dist/charts-react/plan-funnel.mjs +120 -0
- package/dist/charts-react/plan-grid.mjs +121 -0
- package/dist/charts-react/plan-parts.d.mts +2 -0
- package/dist/charts-react/plan-parts.mjs +30 -0
- package/dist/charts-react/plan-time.mjs +84 -0
- package/dist/charts-react/plan.d.mts +3 -0
- package/dist/charts-react/plan.mjs +37 -0
- package/dist/charts-react/point-keys.mjs +22 -0
- package/dist/charts-react/pointer.mjs +99 -0
- package/dist/charts-react/reader-page.d.mts +8 -0
- package/dist/charts-react/reader-page.mjs +116 -0
- package/dist/charts-react/tiles.d.mts +24 -0
- package/dist/charts-react/tiles.mjs +142 -0
- package/dist/charts-react/tip-place.mjs +107 -0
- package/dist/charts-react/tip-room.mjs +31 -0
- package/dist/charts-react/useClientLayoutEffect.mjs +8 -0
- package/dist/charts-react/useScene.mjs +76 -0
- package/dist/charts-react/useSize.mjs +44 -0
- package/dist/charts-react/useStop.mjs +68 -0
- package/dist/core/conformance/memory/aggregate.mjs +2 -1
- package/dist/core/conformance/memory/rows.mjs +1 -1
- package/dist/core/conformance/memory/source.mjs +3 -2
- package/dist/core/document/display-comparisons.mjs +49 -0
- package/dist/core/document/display-entries.mjs +2 -1
- package/dist/core/document/display-validation.d.mts +12 -0
- package/dist/core/document/display-validation.mjs +56 -0
- package/dist/core/document/display.d.mts +27 -12
- package/dist/core/document/display.mjs +40 -49
- package/dist/core/document/view-layout.mjs +16 -0
- package/dist/core/engine/access.mjs +4 -2
- package/dist/core/engine/context.mjs +5 -7
- package/dist/core/engine/custom/cells.mjs +1 -1
- package/dist/core/engine/custom/records.mjs +2 -1
- package/dist/core/engine/dialect.d.mts +2 -0
- package/dist/core/engine/index.mjs +1 -1
- package/dist/core/engine/levels.mjs +33 -1
- package/dist/core/engine/plan.d.mts +2 -0
- package/dist/core/engine/postgres.mjs +1 -0
- package/dist/core/engine/rank.mjs +1 -1
- package/dist/core/engine/reader.d.mts +4 -0
- package/dist/core/engine/sql-partition.mjs +45 -0
- package/dist/core/engine/sql-reads.mjs +4 -1
- package/dist/core/engine/statement.mjs +4 -4
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +1 -1
- package/dist/core/error/codes.mjs +1 -1
- package/dist/core/exact/decimal.d.mts +1 -4
- package/dist/core/exact/decimal.mjs +1 -14
- package/dist/core/exact/text.d.mts +5 -0
- package/dist/core/exact/text.mjs +19 -0
- package/dist/core/index.d.mts +9 -6
- package/dist/core/index.mjs +11 -8
- package/dist/core/model/types.d.mts +2 -0
- package/dist/core/model/validate/fields.mjs +1 -1
- package/dist/core/model/validate/known-members.mjs +2 -0
- package/dist/core/model/validate/shape.mjs +5 -1
- package/dist/core/oracle/visibility.mjs +2 -2
- package/dist/core/policy/bind.mjs +29 -1
- package/dist/core/query/drill/compose.d.mts +2 -0
- package/dist/core/query/drill/compose.mjs +1 -1
- package/dist/core/query/drill/synthetic.mjs +2 -1
- package/dist/core/query/drill/types.d.mts +7 -0
- package/dist/core/query/drill/types.mjs +3 -1
- package/dist/core/result/number.mjs +2 -1
- package/dist/core/result/time-axis.mjs +2 -1
- package/dist/core/schema/answers.d.mts +1176 -362
- package/dist/core/schema/commands.mjs +2 -1
- package/dist/core/schema/document.mjs +27 -2
- package/dist/core/schema/drill-answers.mjs +19 -1
- package/dist/core/schema/drill.d.mts +21 -6
- package/dist/core/schema/drill.mjs +7 -1
- package/dist/core/schema/index.d.mts +2 -1
- package/dist/core/schema/index.mjs +2 -1
- package/dist/core/schema/null-ops.d.mts +6 -0
- package/dist/core/schema/null-ops.mjs +18 -0
- package/dist/core/schema/query.mjs +30 -4
- package/dist/core/schema/tools.mjs +13 -0
- package/dist/core/schema/union-error.mjs +38 -0
- package/dist/core/time/bucket.mjs +2 -1
- package/dist/core/time/index.d.mts +3 -2
- package/dist/core/time/instant.d.mts +1 -2
- package/dist/core/time/instant.mjs +2 -30
- package/dist/core/time/range.mjs +2 -1
- package/dist/core/time/stored.mjs +2 -1
- package/dist/core/time/text-time.d.mts +10 -0
- package/dist/core/time/text-time.mjs +80 -0
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +22 -2
- package/dist/dashboard-documents.d.mts +8 -0
- package/dist/dashboard-documents.mjs +52 -0
- package/dist/drill-access.mjs +40 -3
- package/dist/drill-comparison.mjs +71 -0
- package/dist/drill-crumbs.mjs +21 -2
- package/dist/drill-group-seal.mjs +13 -0
- package/dist/drill-open.mjs +7 -1
- package/dist/drill-seal.mjs +4 -6
- package/dist/drill-views.mjs +5 -13
- package/dist/drill.mjs +28 -58
- package/dist/editing.mjs +1 -1
- package/dist/endpoints/drill.mjs +2 -3
- package/dist/endpoints/index.d.mts +20 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +6 -27
- package/dist/llms.txt +1 -1
- package/dist/react/Cell.mjs +2 -2
- package/dist/react/DashboardList.mjs +3 -3
- package/dist/react/Editing.mjs +3 -3
- package/dist/react/Header.mjs +2 -2
- package/dist/react/History.mjs +3 -3
- package/dist/react/Parts.mjs +2 -2
- package/dist/react/RowBody.d.mts +2 -4
- package/dist/react/RowBody.mjs +14 -39
- package/dist/react/Tile.mjs +4 -5
- package/dist/react/builder/FilterEditor.mjs +2 -2
- package/dist/react/builder/Picker.mjs +3 -3
- package/dist/react/builder/RangeEditor.mjs +3 -3
- package/dist/react/builder/Time.mjs +3 -3
- package/dist/react/builder/Values.mjs +2 -2
- package/dist/react/builder/WidgetBuilder.mjs +2 -2
- package/dist/react/digits.mjs +1 -1
- package/dist/react/drill/Bars.mjs +34 -38
- package/dist/react/drill/Comparison.mjs +204 -0
- package/dist/react/drill/Controls.mjs +8 -12
- package/dist/react/drill/DrillDrawer.mjs +42 -0
- package/dist/react/drill/DrillPanel.mjs +61 -41
- package/dist/react/drill/Header.mjs +65 -35
- package/dist/react/drill/ItemLink.mjs +40 -0
- package/dist/react/drill/Items.d.mts +2 -1
- package/dist/react/drill/Items.mjs +126 -99
- package/dist/react/drill/ItemsBody.mjs +38 -0
- package/dist/react/drill/ItemsFoot.mjs +24 -19
- package/dist/react/drill/Notes.mjs +23 -13
- package/dist/react/drill/PanelBody.mjs +7 -25
- package/dist/react/drill/RecordRow.mjs +47 -0
- package/dist/react/drill/Trend.mjs +186 -0
- package/dist/react/drill/board.mjs +21 -11
- package/dist/react/drill/drawer-context.mjs +5 -0
- package/dist/react/drill/item-parts.mjs +53 -35
- package/dist/react/drill/item-type.d.mts +2 -2
- package/dist/react/drill/lazy.d.mts +1 -4
- package/dist/react/drill/lazy.mjs +29 -11
- package/dist/react/drill/panel-focus.mjs +18 -7
- package/dist/react/drill/props.d.mts +7 -1
- package/dist/react/drill/props.mjs +39 -8
- package/dist/react/drill/record-page.mjs +61 -0
- package/dist/react/drill/state.mjs +17 -2
- package/dist/react/drill/trend-touch.mjs +33 -0
- package/dist/react/drill/useDrill.d.mts +3 -3
- package/dist/react/drill/useDrill.mjs +35 -15
- package/dist/react/drill/words.d.mts +14 -0
- package/dist/react/drill/words.mjs +20 -8
- package/dist/react/english.d.mts +4 -1
- package/dist/react/english.mjs +17 -2
- package/dist/react/filters/chip.mjs +2 -2
- package/dist/react/filters/menu-search.mjs +5 -5
- package/dist/react/filters/menu.mjs +2 -2
- package/dist/react/filters/number.mjs +2 -2
- package/dist/react/filters/operator.mjs +2 -2
- package/dist/react/filters/phone.mjs +2 -2
- package/dist/react/filters/values.mjs +4 -4
- package/dist/react/format-time.d.mts +2 -1
- package/dist/react/format-time.mjs +42 -34
- package/dist/react/format.mjs +15 -3
- package/dist/react/index.d.mts +4 -3
- package/dist/react/index.mjs +4 -3
- package/dist/react/messages.d.mts +23 -2
- package/dist/react/renderers/entries.d.mts +11 -0
- package/dist/react/renderers/list.mjs +8 -10
- package/dist/react/renderers/table-cells.mjs +38 -9
- package/dist/react/renderers/table-measure.mjs +2 -0
- package/dist/react/renderers/table-row.mjs +64 -7
- package/dist/react/renderers/table-sort.mjs +2 -8
- package/dist/react/renderers/table.mjs +16 -15
- package/dist/react/series.mjs +8 -3
- package/dist/react/theme-unlayered.css +1 -3144
- package/dist/react/theme.css +1 -3146
- package/dist/recharts/parts.mjs +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +10 -5
- package/dist/store/apply.mjs +2 -2
- package/dist/store/editor.mjs +2 -2
- package/dist/store/writer.mjs +2 -2
- package/package.json +27 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { displayOf, documentDisplayIssues, resolveDimension } from "derive-dashboards/core";
|
|
2
|
+
import { loadDocument } from "derive-dashboards/core/schema";
|
|
3
|
+
// src/dashboard-documents.ts
|
|
4
|
+
function declaredValues(model, source, member) {
|
|
5
|
+
const dimension = resolveDimension(model, source, member)?.dimension;
|
|
6
|
+
if (dimension?.kind !== "string" || typeof dimension.values === "string") return;
|
|
7
|
+
return dimension.values;
|
|
8
|
+
}
|
|
9
|
+
/** Declared filter choices can catch an authoring typo. Rows may still contain other values. */
|
|
10
|
+
function comparisonKeyHints(doc, model) {
|
|
11
|
+
return Object.entries(doc.widgets).flatMap(([id, widget]) => {
|
|
12
|
+
if (widget.kind !== "table") return [];
|
|
13
|
+
const groups = displayOf("table", widget.display).comparisons;
|
|
14
|
+
const query = widget.queries["main"];
|
|
15
|
+
const member = query?.dimensions?.[0]?.member;
|
|
16
|
+
if (!groups || !query || member === void 0) return [];
|
|
17
|
+
const choices = declaredValues(model, query.source, member);
|
|
18
|
+
if (!choices) return [];
|
|
19
|
+
return Object.keys(groups).filter((key) => !choices.includes(key)).map((key) => `widgets.${id}.display.comparisons: "${key}" is outside the declared choices for "${member}" (${choices.join(", ")}). This action appears only on an exact group value match.`);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** A host configuration error raised before the server handles any request. */
|
|
23
|
+
var DashboardDocumentError = class extends Error {
|
|
24
|
+
dashboardKey;
|
|
25
|
+
issues;
|
|
26
|
+
code = "DOCUMENT_INVALID";
|
|
27
|
+
constructor(dashboardKey, reason, issues) {
|
|
28
|
+
const problems = issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
|
|
29
|
+
super(`The dashboard "${dashboardKey}" ${reason}: ${problems}`);
|
|
30
|
+
this.dashboardKey = dashboardKey;
|
|
31
|
+
this.issues = issues;
|
|
32
|
+
this.name = "DashboardDocumentError";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Code-defined dashboards are checked when the handler is made, not when a viewer opens one: an
|
|
37
|
+
* invalid document stops the server with every problem named, and a layout is repaired once.
|
|
38
|
+
*/
|
|
39
|
+
function checkedDashboards(options, model) {
|
|
40
|
+
return (options.dashboards ?? []).map((d) => {
|
|
41
|
+
const loaded = loadDocument(d.document);
|
|
42
|
+
if (!loaded.ok) throw new DashboardDocumentError(d.key, "is not a valid document", loaded.issues);
|
|
43
|
+
const wrong = documentDisplayIssues(loaded.doc, model);
|
|
44
|
+
if (wrong.length > 0) throw new DashboardDocumentError(d.key, "has display options to fix", wrong);
|
|
45
|
+
for (const hint of comparisonKeyHints(loaded.doc, model)) console.warn(`Dashboard "${d.key}": ${hint}`);
|
|
46
|
+
return {
|
|
47
|
+
key: d.key,
|
|
48
|
+
document: loaded.doc
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export { DashboardDocumentError, checkedDashboards };
|
package/dist/drill-access.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execute } from "./execute.mjs";
|
|
2
2
|
import { HttpError } from "./http.mjs";
|
|
3
|
-
import { queryClosure } from "derive-dashboards/core";
|
|
4
|
-
import { drillOwner, stepMembers } from "derive-dashboards/core/engine";
|
|
3
|
+
import { queryClosure, resultColumns } from "derive-dashboards/core";
|
|
4
|
+
import { drillOwner, lineFilter, offeredMembers, pathFields, stepMembers } from "derive-dashboards/core/engine";
|
|
5
5
|
// src/drill-access.ts
|
|
6
6
|
/** Which fields this viewer may see in a drill: never a sensitive one (Rules, section 6). */
|
|
7
7
|
const readableFor = (_x) => (_member, def) => def.sensitive !== true;
|
|
@@ -90,4 +90,41 @@ function mayList(o, source) {
|
|
|
90
90
|
source
|
|
91
91
|
}));
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
/** Label the offered dimensions in the same context as the result columns. */
|
|
94
|
+
function labelledFields(o, kept) {
|
|
95
|
+
const model = o.x.rt.options.model;
|
|
96
|
+
const dimensions = kept.map((member, i) => ({
|
|
97
|
+
id: `d${i + 1}`,
|
|
98
|
+
member
|
|
99
|
+
}));
|
|
100
|
+
const columns = resultColumns(model, {
|
|
101
|
+
...o.x.query,
|
|
102
|
+
dimensions
|
|
103
|
+
});
|
|
104
|
+
return kept.map((id, i) => ({
|
|
105
|
+
id,
|
|
106
|
+
label: columns.find((c) => c.id === `d${i + 1}`)?.label ?? id
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
/** A comparison reads all measures. A single-measure breakdown also excludes fields fixed by that line. */
|
|
110
|
+
function offeredIds(o, set) {
|
|
111
|
+
const model = o.x.rt.options.model;
|
|
112
|
+
const where = set && lineFilter(model, set, o.drill, { operand: false });
|
|
113
|
+
return offeredMembers(model, o.x.query, {
|
|
114
|
+
...pathFields(o.drill.steps),
|
|
115
|
+
where
|
|
116
|
+
}, readableFor(o.x));
|
|
117
|
+
}
|
|
118
|
+
async function readableIds(o, ids) {
|
|
119
|
+
const allowed = await Promise.all(ids.map((id) => mayRead(o, id)));
|
|
120
|
+
return ids.filter((_id, i) => allowed[i] === true);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The fields Breakdown offers this viewer at this step, each labelled as a column of the tile
|
|
124
|
+
* would read it: the model's preferred and small-valued fields the tile, the path and the line's
|
|
125
|
+
* own measure do not fix, the field an Other was cut on first, each one the viewer may read.
|
|
126
|
+
*/
|
|
127
|
+
async function offeredFields(o, set) {
|
|
128
|
+
return labelledFields(o, await readableIds(o, offeredIds(o, set)));
|
|
129
|
+
}
|
|
130
|
+
export { clockOf, drillRead, labelledFields, mayList, mayRead, offeredFields, offeredIds, readableColumns, readableFor, readableIds, running };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { clockOf, drillRead, labelledFields, mayRead, offeredIds, readableFor, readableIds } from "./drill-access.mjs";
|
|
2
|
+
import { crumbs, forOpener, normalizedDrillState } from "./drill-crumbs.mjs";
|
|
3
|
+
import { sealedView } from "./drill-group-seal.mjs";
|
|
4
|
+
import { visibleSelection } from "./drill-open.mjs";
|
|
5
|
+
import { numberOf } from "./drill-totals.mjs";
|
|
6
|
+
import { wire } from "./execute.mjs";
|
|
7
|
+
import { EngineError, breakdownQuery, composeDrill, countQuery } from "derive-dashboards/core/engine";
|
|
8
|
+
// src/drill-comparison.ts
|
|
9
|
+
/** A shared group must contain rows visible to its opener before its name can be shown. */
|
|
10
|
+
function comparisonScope(scope) {
|
|
11
|
+
return visibleSelection(scope, async (o, checkRows) => {
|
|
12
|
+
const set = composeDrill({
|
|
13
|
+
model: o.x.rt.options.model,
|
|
14
|
+
query: o.x.query,
|
|
15
|
+
drill: o.drill,
|
|
16
|
+
comparison: true,
|
|
17
|
+
readable: readableFor(o.x),
|
|
18
|
+
clock: clockOf(o.x)
|
|
19
|
+
});
|
|
20
|
+
const count = checkRows ? await drillRead(o, countQuery(set)) : void 0;
|
|
21
|
+
return {
|
|
22
|
+
value: {
|
|
23
|
+
o,
|
|
24
|
+
set
|
|
25
|
+
},
|
|
26
|
+
empty: (numberOf(count?.rows[0]?.[0]) ?? 0) <= 0
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function fieldsFor(o, view) {
|
|
31
|
+
const offered = offeredIds(o);
|
|
32
|
+
const check = async (field) => {
|
|
33
|
+
if (offered.includes(field) && await mayRead(o, field)) return;
|
|
34
|
+
const choices = await readableIds(o, offered);
|
|
35
|
+
const hint = choices.length > 0 ? `Available breakdown fields: ${choices.join(", ")}.` : "No breakdown fields are available.";
|
|
36
|
+
throw new EngineError("DRILL_UNSUPPORTED", `Cannot group this selection by "${field}". ${hint}`);
|
|
37
|
+
};
|
|
38
|
+
await check(view.member);
|
|
39
|
+
const id = view.thenBy;
|
|
40
|
+
if (id === void 0) return;
|
|
41
|
+
if (id === view.member) throw new EngineError("DRILL_UNSUPPORTED", "Choose a different field to expand the group.");
|
|
42
|
+
await check(id);
|
|
43
|
+
return labelledFields(o, [id])[0];
|
|
44
|
+
}
|
|
45
|
+
/** Regroup the selected rows. Every measure keeps its own filter and denominator. */
|
|
46
|
+
async function compareGroups(opened, state, requested) {
|
|
47
|
+
const { o, set } = await comparisonScope(opened);
|
|
48
|
+
const thenBy = await fieldsFor(o, requested);
|
|
49
|
+
const view = {
|
|
50
|
+
by: "comparison",
|
|
51
|
+
member: requested.member,
|
|
52
|
+
...thenBy && { thenBy: thenBy.id }
|
|
53
|
+
};
|
|
54
|
+
const query = breakdownQuery(set, view.member, { steps: [] });
|
|
55
|
+
const answer = await drillRead(o, {
|
|
56
|
+
...query,
|
|
57
|
+
total: true
|
|
58
|
+
}, [view.member]);
|
|
59
|
+
return forOpener({
|
|
60
|
+
state: normalizedDrillState(state, o.path, view),
|
|
61
|
+
path: crumbs(o),
|
|
62
|
+
view: {
|
|
63
|
+
by: "comparison",
|
|
64
|
+
answer: wire(answer),
|
|
65
|
+
drill: await sealedView(o, answer, { limited: true }),
|
|
66
|
+
...thenBy && { thenBy },
|
|
67
|
+
...o.omitted && { omitted: true }
|
|
68
|
+
}
|
|
69
|
+
}, o.foreign);
|
|
70
|
+
}
|
|
71
|
+
export { compareGroups };
|
package/dist/drill-crumbs.mjs
CHANGED
|
@@ -108,6 +108,25 @@ function openerReceipts(value) {
|
|
|
108
108
|
* rows and counts are already theirs.
|
|
109
109
|
*/
|
|
110
110
|
function forOpener(answer, foreign) {
|
|
111
|
-
|
|
111
|
+
if (!foreign) return answer;
|
|
112
|
+
const trimmed = openerReceipts(answer);
|
|
113
|
+
return trimmed.view.by === "comparison" ? {
|
|
114
|
+
...trimmed,
|
|
115
|
+
view: {
|
|
116
|
+
...trimmed.view,
|
|
117
|
+
foreign: true
|
|
118
|
+
}
|
|
119
|
+
} : trimmed;
|
|
112
120
|
}
|
|
113
|
-
|
|
121
|
+
/** Keep only the navigation history for the steps this viewer can still open. */
|
|
122
|
+
function normalizedDrillState(state, path, view) {
|
|
123
|
+
const { views, ...rest } = state;
|
|
124
|
+
const kept = views?.slice(0, Math.max(0, path.length - 1));
|
|
125
|
+
return {
|
|
126
|
+
...rest,
|
|
127
|
+
path,
|
|
128
|
+
view,
|
|
129
|
+
...kept !== void 0 && kept.length > 0 && { views: kept }
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export { crumbs, forOpener, normalizedDrillState };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { pathDigest } from "./drill-identity.mjs";
|
|
2
|
+
import { drawnOf, sealAnswer } from "./drill-seal.mjs";
|
|
3
|
+
// src/drill-group-seal.ts
|
|
4
|
+
/** An answer of a view sealed once, under this drill's execution and path. */
|
|
5
|
+
async function sealedView(o, answer, extra) {
|
|
6
|
+
const parent = await pathDigest(o.drill.steps);
|
|
7
|
+
const range = answer.receipt.range;
|
|
8
|
+
return sealAnswer(o.scope, drawnOf(answer, answer.rows, range, extra), {
|
|
9
|
+
exec: o.pinned.id,
|
|
10
|
+
parent
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export { sealedView };
|
package/dist/drill-open.mjs
CHANGED
|
@@ -166,4 +166,10 @@ function cutTo(o, steps) {
|
|
|
166
166
|
omitted: true
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
/** A shared link opens at the deepest selection containing rows visible to its new viewer. */
|
|
170
|
+
async function visibleSelection(scope, read) {
|
|
171
|
+
const checkRows = scope.foreign && scope.selections.length > 0;
|
|
172
|
+
const { value, empty } = await read(scope, checkRows);
|
|
173
|
+
return checkRows && empty ? visibleSelection(cutTo(scope, scope.selections.length - 1), read) : value;
|
|
174
|
+
}
|
|
175
|
+
export { cutTo, openDrill, visibleSelection };
|
package/dist/drill-seal.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { base64url, seal, unseal } from "./cursor-seal.mjs";
|
|
2
2
|
import { fingerprint, pathDigest, revisionOf } from "./drill-identity.mjs";
|
|
3
3
|
import { warnSecret } from "./drill-secret.mjs";
|
|
4
|
-
import { DRILL_REASONS, parseTextTime } from "derive-dashboards/core";
|
|
4
|
+
import { DRILL_REASONS, MAX_DRILL_ROWS, parseTextTime } from "derive-dashboards/core";
|
|
5
5
|
import { EngineError, rowSelection } from "derive-dashboards/core/engine";
|
|
6
6
|
import { pinnedSchema, selectionSchema } from "derive-dashboards/core/schema";
|
|
7
7
|
// src/drill-seal.ts
|
|
8
|
-
/** An answer drills only when it is small enough to read row by row. */
|
|
9
|
-
const MAX_SELECTIONS = 1e3;
|
|
10
8
|
const bindingOf = (scope, purpose) => ({
|
|
11
9
|
purpose,
|
|
12
10
|
principal: scope.principal,
|
|
@@ -33,7 +31,7 @@ const slim = (c) => ({
|
|
|
33
31
|
/** What a drawn answer's rows open to, and why the others do not. */
|
|
34
32
|
function closedRows(drawn) {
|
|
35
33
|
return drawn.rows.flatMap((row, i) => {
|
|
36
|
-
if (i >=
|
|
34
|
+
if (i >= MAX_DRILL_ROWS) return [];
|
|
37
35
|
const picked = rowSelection(drawn, row);
|
|
38
36
|
return "refused" in picked ? [{
|
|
39
37
|
row: i,
|
|
@@ -48,7 +46,7 @@ async function sealAnswer(scope, drawn, at) {
|
|
|
48
46
|
drawn: {
|
|
49
47
|
...drawn,
|
|
50
48
|
columns: drawn.columns.map((c) => slim(c)),
|
|
51
|
-
rows: drawn.rows.slice(0,
|
|
49
|
+
rows: drawn.rows.slice(0, MAX_DRILL_ROWS)
|
|
52
50
|
},
|
|
53
51
|
...at
|
|
54
52
|
};
|
|
@@ -113,7 +111,7 @@ async function issueDrill(scope, answer, at) {
|
|
|
113
111
|
previous: true
|
|
114
112
|
})
|
|
115
113
|
]);
|
|
116
|
-
const cut = answer.rows.length >
|
|
114
|
+
const cut = answer.rows.length > MAX_DRILL_ROWS;
|
|
117
115
|
return {
|
|
118
116
|
execution,
|
|
119
117
|
...sealed,
|
package/dist/drill-views.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { clockOf, drillRead } from "./drill-access.mjs";
|
|
2
2
|
import { otherChange } from "./drill-change.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { drawnOf, sealAnswer } from "./drill-seal.mjs";
|
|
3
|
+
import { sealedView } from "./drill-group-seal.mjs";
|
|
5
4
|
import { numberOf } from "./drill-totals.mjs";
|
|
5
|
+
import { compareGroups } from "./drill-comparison.mjs";
|
|
6
6
|
import { isMark, parseTextTime, resolveDimension } from "derive-dashboards/core";
|
|
7
7
|
import { EngineError, breakdownQuery, population, trendQuery } from "derive-dashboards/core/engine";
|
|
8
8
|
// src/drill-views.ts
|
|
@@ -58,15 +58,6 @@ function grainsFor(range) {
|
|
|
58
58
|
["year", 365]
|
|
59
59
|
].filter(([, d]) => days / d >= 2 && days / d <= 400).map(([g]) => g);
|
|
60
60
|
}
|
|
61
|
-
/** An answer of a view sealed once, under this drill's execution and path. */
|
|
62
|
-
async function sealedView(o, answer, extra) {
|
|
63
|
-
const parent = await pathDigest(o.drill.steps);
|
|
64
|
-
const range = answer.receipt.range;
|
|
65
|
-
return sealAnswer(o.scope, drawnOf(answer, answer.rows, range, extra), {
|
|
66
|
-
exec: o.pinned.id,
|
|
67
|
-
parent
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
61
|
/** Over time: the line's population by its time field, at a grain that fits, its range and grains. */
|
|
71
62
|
async function trendView(o, rows, view, offered) {
|
|
72
63
|
const query = trendQuery(o.x.rt.options.model, rows, clockOf(o.x), view.grain);
|
|
@@ -80,7 +71,8 @@ async function trendView(o, rows, view, offered) {
|
|
|
80
71
|
offered,
|
|
81
72
|
...time?.grain === void 0 ? {} : { grain: time.grain },
|
|
82
73
|
...range === void 0 ? {} : { range },
|
|
83
|
-
grains: grainsFor(range)
|
|
74
|
+
grains: grainsFor(range),
|
|
75
|
+
throughNow: time !== void 0 && "last" in time.range && time.range.includeCurrent
|
|
84
76
|
};
|
|
85
77
|
}
|
|
86
78
|
/** A Breakdown or Over time of the line's population, its answer sealed once for its clicks. */
|
|
@@ -172,4 +164,4 @@ async function readBreakdown(o, ask) {
|
|
|
172
164
|
compared: compare !== void 0
|
|
173
165
|
};
|
|
174
166
|
}
|
|
175
|
-
export { chosenView, groupedView };
|
|
167
|
+
export { chosenView, compareGroups, groupedView };
|
package/dist/drill.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { clockOf, mayRead, readableFor } from "./drill-access.mjs";
|
|
2
|
-
import { crumbs, forOpener } from "./drill-crumbs.mjs";
|
|
1
|
+
import { clockOf, mayRead, offeredFields, readableFor } from "./drill-access.mjs";
|
|
2
|
+
import { crumbs, forOpener, normalizedDrillState } from "./drill-crumbs.mjs";
|
|
3
3
|
import { explanationView } from "./drill-explain.mjs";
|
|
4
4
|
import { drillItems } from "./drill-items.mjs";
|
|
5
|
-
import { cutTo, openDrill } from "./drill-open.mjs";
|
|
5
|
+
import { cutTo, openDrill, visibleSelection } from "./drill-open.mjs";
|
|
6
6
|
import { abilities, holdsNoRows, summarize } from "./drill-summary.mjs";
|
|
7
7
|
import { chosenView, groupedView } from "./drill-views.mjs";
|
|
8
|
+
import { compareGroups } from "./drill-comparison.mjs";
|
|
8
9
|
import { wire } from "./execute.mjs";
|
|
9
10
|
import { resultColumns } from "derive-dashboards/core";
|
|
10
|
-
import { composeDrill, drillMeasure,
|
|
11
|
+
import { composeDrill, drillMeasure, lineSemantics, stepMembers } from "derive-dashboards/core/engine";
|
|
11
12
|
// src/drill.ts
|
|
12
13
|
/** The drill's query and its line, for the path as it stands. */
|
|
13
14
|
function composed(o) {
|
|
@@ -25,34 +26,6 @@ function composed(o) {
|
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
* The fields Breakdown offers this viewer at this step, each labelled as a column of the tile
|
|
29
|
-
* would read it: the model's preferred and small-valued fields the tile, the path and the line's
|
|
30
|
-
* own measure do not fix, the field an Other was cut on first, each one the viewer may read.
|
|
31
|
-
*/
|
|
32
|
-
async function offeredFields(o, set) {
|
|
33
|
-
const { model } = o.x.rt.options;
|
|
34
|
-
const where = lineFilter(model, set, o.drill, { operand: false });
|
|
35
|
-
const path = {
|
|
36
|
-
...pathFields(o.drill.steps),
|
|
37
|
-
where
|
|
38
|
-
};
|
|
39
|
-
const ids = offeredMembers(model, o.x.query, path, readableFor(o.x));
|
|
40
|
-
const allowed = await Promise.all(ids.map((id) => mayRead(o, id)));
|
|
41
|
-
const kept = ids.filter((_id, i) => allowed[i] === true);
|
|
42
|
-
const dimensions = kept.map((member, i) => ({
|
|
43
|
-
id: `d${i + 1}`,
|
|
44
|
-
member
|
|
45
|
-
}));
|
|
46
|
-
const columns = resultColumns(model, {
|
|
47
|
-
...o.x.query,
|
|
48
|
-
dimensions
|
|
49
|
-
});
|
|
50
|
-
return kept.map((id, i) => ({
|
|
51
|
-
id,
|
|
52
|
-
label: columns.find((c) => c.id === `d${i + 1}`)?.label ?? id
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
29
|
* The path cut at its first step on a field this viewer may not read: a link opened with less
|
|
57
30
|
* access opens at the deepest step it can, and says part of it was left out.
|
|
58
31
|
*/
|
|
@@ -68,18 +41,23 @@ const needsSummary = (body) => body.summary !== false || body.state.view.by ===
|
|
|
68
41
|
* holds no row this viewer can see, so nothing about rows they cannot see is shown, not even
|
|
69
42
|
* that there are some.
|
|
70
43
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
44
|
+
function ready(scope, body) {
|
|
45
|
+
return visibleSelection(scope, async (o) => {
|
|
46
|
+
const { set, line } = composed(o);
|
|
47
|
+
const offered = await offeredFields(o, set);
|
|
48
|
+
const summed = o.foreign || needsSummary(body) ? await summarize(o, set, line, offered) : void 0;
|
|
49
|
+
const empty = summed !== void 0 && holdsNoRows(summed.summary);
|
|
50
|
+
return {
|
|
51
|
+
value: {
|
|
52
|
+
o,
|
|
53
|
+
set,
|
|
54
|
+
line,
|
|
55
|
+
offered,
|
|
56
|
+
...summed === void 0 ? {} : { summed }
|
|
57
|
+
},
|
|
58
|
+
empty
|
|
59
|
+
};
|
|
60
|
+
});
|
|
83
61
|
}
|
|
84
62
|
/** The view as the drill shows it, and what it shows. */
|
|
85
63
|
async function shownView(r, view, page) {
|
|
@@ -94,10 +72,7 @@ async function shownView(r, view, page) {
|
|
|
94
72
|
column,
|
|
95
73
|
only: view.numerator === true
|
|
96
74
|
}, page ?? {}),
|
|
97
|
-
view
|
|
98
|
-
by: "items",
|
|
99
|
-
numerator: true
|
|
100
|
-
} : { by: "items" }
|
|
75
|
+
view
|
|
101
76
|
};
|
|
102
77
|
}
|
|
103
78
|
if (view.by === "explanation") {
|
|
@@ -126,12 +101,14 @@ async function shownView(r, view, page) {
|
|
|
126
101
|
* numbers kept apart, its path as breadcrumbs, its state normalized, and the view it shows.
|
|
127
102
|
*/
|
|
128
103
|
async function runDrill(rt, principal, request, body) {
|
|
129
|
-
const
|
|
104
|
+
const opened = await permitted(await openDrill({
|
|
130
105
|
rt,
|
|
131
106
|
principal,
|
|
132
107
|
request,
|
|
133
108
|
state: body.state
|
|
134
|
-
}))
|
|
109
|
+
}));
|
|
110
|
+
if (body.state.view.by === "comparison") return compareGroups(opened, body.state, body.state.view);
|
|
111
|
+
const r = await ready(opened, body);
|
|
135
112
|
const can = r.summed?.summary.can ?? await abilities(r.o, r.line, r.offered);
|
|
136
113
|
const choice = r.summed?.summary ?? {
|
|
137
114
|
can,
|
|
@@ -139,14 +116,7 @@ async function runDrill(rt, principal, request, body) {
|
|
|
139
116
|
};
|
|
140
117
|
const { shown, view } = await shownView(r, chosenView(body.state.view, choice), body.page);
|
|
141
118
|
const { first: _first, ...plain } = view;
|
|
142
|
-
const
|
|
143
|
-
const { views: _v, ...rest } = body.state;
|
|
144
|
-
const state = {
|
|
145
|
-
...rest,
|
|
146
|
-
path: r.o.path,
|
|
147
|
-
view: plain,
|
|
148
|
-
...views === void 0 || views.length === 0 ? {} : { views }
|
|
149
|
-
};
|
|
119
|
+
const state = normalizedDrillState(body.state, r.o.path, plain);
|
|
150
120
|
return forOpener({
|
|
151
121
|
...r.summed === void 0 ? {} : { summary: r.summed.summary },
|
|
152
122
|
path: crumbs(r.o),
|
package/dist/editing.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { principalTenant } from "derive-dashboards/core";
|
|
|
11
11
|
function storeFor(rt, request) {
|
|
12
12
|
const adapter = adapterFor(rt.options, request);
|
|
13
13
|
if (adapter === void 0) throw new HttpError(400, "STORE_REQUIRED", "Editing dashboards needs a store: pass `database` to deriveDashboards.");
|
|
14
|
-
return createStore(adapter);
|
|
14
|
+
return createStore(adapter, rt.drillModel);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* What a draft of `id` starts from: a built-in by its key, or a stored dashboard by the one id
|
package/dist/endpoints/drill.mjs
CHANGED
|
@@ -5,9 +5,8 @@ import { createDashEndpoint } from "derive-dashboards/core";
|
|
|
5
5
|
// src/endpoints/drill.ts
|
|
6
6
|
/** The dashboard a drill body starts from, before its schema checks it. */
|
|
7
7
|
function dashboardOf(body) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
if (origin?.kind !== "dashboard") throw new HttpError(400, "BODY_INVALID", "state.origin: a dashboard's tile is required here.");
|
|
8
|
+
const { origin } = parseWith(bodies.drill, body).state;
|
|
9
|
+
if (origin.kind !== "dashboard") throw new HttpError(400, "BODY_INVALID", "state.origin: a dashboard's tile is required here.");
|
|
11
10
|
return {
|
|
12
11
|
kind: "dashboard",
|
|
13
12
|
id: origin.dashboardId
|
|
@@ -113,11 +113,16 @@ export declare function coreEndpoints(rt: Runtime): {
|
|
|
113
113
|
by: "breakdown";
|
|
114
114
|
member?: string;
|
|
115
115
|
search?: string;
|
|
116
|
+
} | {
|
|
117
|
+
by: "comparison";
|
|
118
|
+
member: string;
|
|
119
|
+
thenBy?: string;
|
|
116
120
|
} | {
|
|
117
121
|
by: "trend";
|
|
118
122
|
grain?: "hour" | "day" | "week" | "month" | "quarter" | "year";
|
|
119
123
|
} | {
|
|
120
124
|
by: "items";
|
|
125
|
+
fields?: true;
|
|
121
126
|
numerator?: true;
|
|
122
127
|
} | {
|
|
123
128
|
by: "explanation";
|
|
@@ -127,11 +132,16 @@ export declare function coreEndpoints(rt: Runtime): {
|
|
|
127
132
|
by: "breakdown";
|
|
128
133
|
member?: string;
|
|
129
134
|
search?: string;
|
|
135
|
+
} | {
|
|
136
|
+
by: "comparison";
|
|
137
|
+
member: string;
|
|
138
|
+
thenBy?: string;
|
|
130
139
|
} | {
|
|
131
140
|
by: "trend";
|
|
132
141
|
grain?: "hour" | "day" | "week" | "month" | "quarter" | "year";
|
|
133
142
|
} | {
|
|
134
143
|
by: "items";
|
|
144
|
+
fields?: true;
|
|
135
145
|
numerator?: true;
|
|
136
146
|
} | {
|
|
137
147
|
by: "explanation";
|
|
@@ -223,11 +233,16 @@ export declare function coreEndpoints(rt: Runtime): {
|
|
|
223
233
|
by: "breakdown";
|
|
224
234
|
member?: string;
|
|
225
235
|
search?: string;
|
|
236
|
+
} | {
|
|
237
|
+
by: "comparison";
|
|
238
|
+
member: string;
|
|
239
|
+
thenBy?: string;
|
|
226
240
|
} | {
|
|
227
241
|
by: "trend";
|
|
228
242
|
grain?: "hour" | "day" | "week" | "month" | "quarter" | "year";
|
|
229
243
|
} | {
|
|
230
244
|
by: "items";
|
|
245
|
+
fields?: true;
|
|
231
246
|
numerator?: true;
|
|
232
247
|
} | {
|
|
233
248
|
by: "explanation";
|
|
@@ -237,11 +252,16 @@ export declare function coreEndpoints(rt: Runtime): {
|
|
|
237
252
|
by: "breakdown";
|
|
238
253
|
member?: string;
|
|
239
254
|
search?: string;
|
|
255
|
+
} | {
|
|
256
|
+
by: "comparison";
|
|
257
|
+
member: string;
|
|
258
|
+
thenBy?: string;
|
|
240
259
|
} | {
|
|
241
260
|
by: "trend";
|
|
242
261
|
grain?: "hour" | "day" | "week" | "month" | "quarter" | "year";
|
|
243
262
|
} | {
|
|
244
263
|
by: "items";
|
|
264
|
+
fields?: true;
|
|
245
265
|
numerator?: true;
|
|
246
266
|
} | {
|
|
247
267
|
by: "explanation";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { coreEndpoints } from "./endpoints/index.mjs";
|
|
2
|
+
import { DashboardDocumentError } from "./dashboard-documents.mjs";
|
|
2
3
|
import { CustomSourceOptions, customSource } from "./custom-source.mjs";
|
|
3
4
|
import { HttpError } from "./http.mjs";
|
|
4
5
|
import { PgPool, PgQueryable, nodePostgres } from "./node-postgres.mjs";
|
|
@@ -23,4 +24,4 @@ export declare function deriveDashboards<const O extends DashOptions>(options: O
|
|
|
23
24
|
/** Typed from the model: a template per source, and no source the model lacks. */
|
|
24
25
|
itemLinks?: ItemLinksFor<O["model"], O["itemLinks"]>;
|
|
25
26
|
}): DashServer<O>;
|
|
26
|
-
export { type CustomSourceOptions, HttpError, type PgPool, type PgQueryable, type PostgresConnectionOptions, type PostgresStoreOptions, type RunRows, type RunSql, type SchemaDiff, SchemaMismatchError, createTables, customSource, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
|
|
27
|
+
export { type CustomSourceOptions, DashboardDocumentError, HttpError, type PgPool, type PgQueryable, type PostgresConnectionOptions, type PostgresStoreOptions, type RunRows, type RunSql, type SchemaDiff, SchemaMismatchError, createTables, customSource, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createCache } from "./cache.mjs";
|
|
2
2
|
import { cursorKey, macKey } from "./cursor-seal.mjs";
|
|
3
|
+
import { DashboardDocumentError, checkedDashboards } from "./dashboard-documents.mjs";
|
|
3
4
|
import { warnSecretAtStart } from "./drill-secret.mjs";
|
|
4
5
|
import { coreEndpoints } from "./endpoints/index.mjs";
|
|
5
6
|
import { createHandler, serverCall } from "./handler.mjs";
|
|
@@ -11,33 +12,10 @@ import { postgresConnection } from "./postgres-connection.mjs";
|
|
|
11
12
|
import { postgresStore } from "./postgres-store.mjs";
|
|
12
13
|
import { memoryStorage } from "./storage.mjs";
|
|
13
14
|
import { SchemaMismatchError, createTables, schemaDiff } from "./store/create-tables.mjs";
|
|
14
|
-
import { BASE_ERROR_CODES, defineModel,
|
|
15
|
+
import { BASE_ERROR_CODES, defineModel, linkTemplateIssues } from "derive-dashboards/core";
|
|
15
16
|
import { drillModel } from "derive-dashboards/core/engine";
|
|
16
|
-
import { loadDocument } from "derive-dashboards/core/schema";
|
|
17
17
|
// src/index.ts
|
|
18
18
|
/**
|
|
19
|
-
* Code-defined dashboards are checked when the handler is made, not when a viewer opens one: an
|
|
20
|
-
* invalid document stops the server with every problem named, and a layout is repaired once.
|
|
21
|
-
*/
|
|
22
|
-
function checkedDashboards(options) {
|
|
23
|
-
return (options.dashboards ?? []).map((d) => {
|
|
24
|
-
const loaded = loadDocument(d.document);
|
|
25
|
-
if (!loaded.ok) {
|
|
26
|
-
const problems = loaded.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
|
|
27
|
-
throw new Error(`The dashboard "${d.key}" is not a valid document: ${problems}`);
|
|
28
|
-
}
|
|
29
|
-
const wrong = documentDisplayIssues(loaded.doc);
|
|
30
|
-
if (wrong.length > 0) {
|
|
31
|
-
const problems = wrong.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
|
|
32
|
-
throw new Error(`The dashboard "${d.key}" has display options to fix: ${problems}`);
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
key: d.key,
|
|
36
|
-
document: loaded.doc
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
19
|
* Every connection the model's sources read is given, and each one given as it is (not per
|
|
42
20
|
* request) is a connection, or the server does not start.
|
|
43
21
|
*/
|
|
@@ -101,16 +79,17 @@ function deriveDashboards(options) {
|
|
|
101
79
|
defineModel(options.model);
|
|
102
80
|
checkConnections(options);
|
|
103
81
|
checkItemLinks(options);
|
|
82
|
+
const model = drillModel(options.model);
|
|
104
83
|
const checked = {
|
|
105
84
|
...options,
|
|
106
|
-
dashboards: checkedDashboards(options)
|
|
85
|
+
dashboards: checkedDashboards(options, model)
|
|
107
86
|
};
|
|
108
87
|
const rt = {
|
|
109
88
|
options: checked,
|
|
110
89
|
cache: createCache(checked),
|
|
111
90
|
cursorKey: cursorKey(options.secret),
|
|
112
91
|
macKey: macKey(options.secret),
|
|
113
|
-
drillModel:
|
|
92
|
+
drillModel: model,
|
|
114
93
|
warned: { secret: false }
|
|
115
94
|
};
|
|
116
95
|
warnSecretAtStart(rt);
|
|
@@ -144,4 +123,4 @@ function deriveDashboards(options) {
|
|
|
144
123
|
options
|
|
145
124
|
};
|
|
146
125
|
}
|
|
147
|
-
export { HttpError, SchemaMismatchError, createTables, customSource, deriveDashboards, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
|
|
126
|
+
export { DashboardDocumentError, HttpError, SchemaMismatchError, createTables, customSource, deriveDashboards, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
|
package/dist/llms.txt
CHANGED
|
@@ -9,7 +9,7 @@ Install skill for coding agents: `npx skills add derive-to/dashboards --skill de
|
|
|
9
9
|
- [Quick start](https://github.com/derive-to/dashboards/blob/main/docs/quick-start.md): install, describe your data, mount the handler, show a dashboard, drill in.
|
|
10
10
|
- [Concepts](https://github.com/derive-to/dashboards/blob/main/docs/concepts.md): the model, measures, joins, tenancy and row policies, access, documents, drill-in.
|
|
11
11
|
- [Filters](https://github.com/derive-to/dashboards/blob/main/docs/filters.md): the built-in filter bar, theming, options, words, the shadcn copy, custom bars.
|
|
12
|
-
- [React](https://github.com/derive-to/dashboards/blob/main/docs/react.md): provider, Dashboard, editing UI, URL state, drill parts, widget builder; the tiles and their `display` options (a number's `value` and `secondary`, a table's `bars`, `heat` and `
|
|
12
|
+
- [React](https://github.com/derive-to/dashboards/blob/main/docs/react.md): provider, Dashboard, editing UI, URL state, drill parts, widget builder; the tiles and their `display` options (a number's `value` and `secondary`, a table's `bars`, `heat`, `compact` and `comparisons` for grouped drill-down, a list's lines); plain SVG functions in `derive-dashboards/charts`, the two chart kits and what each kind draws (`CHARTS_RENDERERS` from `derive-dashboards/charts-react`: line, bar, area, small multiples, heat grid, funnel; a bar's `against`, an area's `share`, small multiples' `ownScales`); a table a viewer sorts; a tile's answer as CSV (`csv={false}` turns the button off, `downloadCsv` and `csvOf` for your own). Use `drill.compare` on a row in a custom renderer. Catch `DashboardDocumentError` for invalid code dashboards. Translate drill labels with `messages.drillMetricTotal`, `drillCompareGroup`, `drillGroupedBy`, `drillRecordPages` and `drillTrendWindow`.
|
|
13
13
|
- [CLI](https://github.com/derive-to/dashboards/blob/main/docs/cli.md): init, check, generate, create-tables, add, importing from dbt or Cube.
|
|
14
14
|
- [Endpoints](https://github.com/derive-to/dashboards/blob/main/docs/endpoints.md): every handler endpoint, its body and answer.
|
|
15
15
|
- [MCP](https://github.com/derive-to/dashboards/blob/main/docs/mcp.md): tools that let agents query and edit dashboards as themselves.
|
package/dist/react/Cell.mjs
CHANGED
|
@@ -3,12 +3,12 @@ import { TileActions } from "./Editing.mjs";
|
|
|
3
3
|
import { placeOf, useBringIntoView } from "./place.mjs";
|
|
4
4
|
import { Tile } from "./Tile.mjs";
|
|
5
5
|
import { memo, useEffect, useMemo } from "react";
|
|
6
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
// src/Cell.tsx
|
|
8
8
|
/** The grip that moves a tile, and the corner that resizes it, while the dashboard is a draft. */
|
|
9
9
|
function Handles(props) {
|
|
10
10
|
const { messages } = useDashboards();
|
|
11
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
11
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
12
12
|
type: "button",
|
|
13
13
|
className: "dd-move",
|
|
14
14
|
"aria-label": messages.moveWidget(props.title),
|