derive-dashboards 0.8.0 → 0.9.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/CHANGELOG.md +513 -0
- package/README.md +8 -2
- package/dist/adapter/statement.mjs +9 -7
- package/dist/authorize.mjs +27 -6
- package/dist/body.mjs +28 -25
- package/dist/cache.d.mts +2 -2
- package/dist/charts/data/buckets.d.mts +25 -7
- package/dist/charts/data/buckets.mjs +92 -15
- package/dist/charts/data/clean.mjs +254 -12
- package/dist/charts/data/format.d.mts +7 -2
- package/dist/charts/data/format.mjs +68 -70
- package/dist/charts/data/input-error.d.mts +2 -0
- package/dist/charts/data/input-error.mjs +2 -0
- package/dist/charts/data/rows.d.mts +3 -1
- package/dist/charts/data/rows.mjs +4 -2
- package/dist/charts/data/types.d.mts +50 -7
- package/dist/charts/data/words.d.mts +13 -0
- package/dist/charts/data/words.mjs +8 -1
- package/dist/charts/describe.mjs +6 -6
- package/dist/charts/index.d.mts +14 -14
- package/dist/charts/index.mjs +4 -1
- package/dist/charts/kinds/area-marks.mjs +67 -26
- package/dist/charts/kinds/area.d.mts +3 -3
- package/dist/charts/kinds/area.mjs +32 -11
- package/dist/charts/kinds/bars-data.d.mts +3 -3
- package/dist/charts/kinds/bars-data.mjs +12 -6
- package/dist/charts/kinds/bars-layout.mjs +60 -6
- package/dist/charts/kinds/bars-marks.mjs +6 -6
- package/dist/charts/kinds/bars.d.mts +5 -3
- package/dist/charts/kinds/bars.mjs +39 -6
- package/dist/charts/kinds/columns-data.mjs +14 -5
- package/dist/charts/kinds/columns-marks.mjs +52 -23
- package/dist/charts/kinds/columns.d.mts +2 -2
- package/dist/charts/kinds/columns.mjs +36 -10
- package/dist/charts/kinds/course-data.mjs +44 -0
- package/dist/charts/kinds/course-layout.mjs +77 -0
- package/dist/charts/kinds/course-marks.mjs +52 -0
- package/dist/charts/kinds/course-words.mjs +64 -0
- package/dist/charts/kinds/course.d.mts +10 -0
- package/dist/charts/kinds/course.mjs +55 -0
- package/dist/charts/kinds/dumbbell-data.d.mts +4 -4
- package/dist/charts/kinds/dumbbell-data.mjs +3 -3
- package/dist/charts/kinds/dumbbell-layout.mjs +17 -8
- package/dist/charts/kinds/dumbbell.d.mts +5 -3
- package/dist/charts/kinds/dumbbell.mjs +35 -4
- package/dist/charts/kinds/funnel-data.d.mts +3 -3
- package/dist/charts/kinds/funnel-data.mjs +11 -16
- package/dist/charts/kinds/funnel-layout.mjs +7 -6
- package/dist/charts/kinds/funnel.d.mts +5 -4
- package/dist/charts/kinds/funnel.mjs +33 -6
- package/dist/charts/kinds/grid-data.d.mts +3 -3
- package/dist/charts/kinds/grid-data.mjs +55 -13
- package/dist/charts/kinds/grid-layout.mjs +88 -13
- package/dist/charts/kinds/grid-legend.mjs +60 -0
- package/dist/charts/kinds/grid-marks.mjs +81 -30
- package/dist/charts/kinds/grid-time.mjs +19 -5
- package/dist/charts/kinds/grid-words.mjs +57 -35
- package/dist/charts/kinds/grid.d.mts +7 -4
- package/dist/charts/kinds/grid.mjs +49 -8
- package/dist/charts/kinds/histogram-data.mjs +68 -26
- package/dist/charts/kinds/histogram-layout.mjs +4 -3
- package/dist/charts/kinds/histogram-words.mjs +2 -3
- package/dist/charts/kinds/histogram.d.mts +2 -2
- package/dist/charts/kinds/histogram.mjs +17 -1
- package/dist/charts/kinds/line-marks.mjs +19 -11
- package/dist/charts/kinds/line.d.mts +2 -2
- package/dist/charts/kinds/line.mjs +21 -3
- package/dist/charts/kinds/multiples-grid.mjs +57 -27
- package/dist/charts/kinds/multiples-head.mjs +52 -22
- package/dist/charts/kinds/multiples-layout.mjs +106 -52
- package/dist/charts/kinds/multiples-marks.mjs +6 -5
- package/dist/charts/kinds/multiples-words.mjs +53 -38
- package/dist/charts/kinds/multiples.d.mts +2 -2
- package/dist/charts/kinds/multiples.mjs +35 -7
- package/dist/charts/kinds/row-chart.d.mts +7 -0
- package/dist/charts/kinds/row-chart.mjs +47 -10
- package/dist/charts/kinds/row-marks.mjs +5 -5
- package/dist/charts/kinds/scatter-data.d.mts +5 -5
- package/dist/charts/kinds/scatter-data.mjs +6 -6
- package/dist/charts/kinds/scatter-marks.mjs +46 -19
- package/dist/charts/kinds/scatter-words.mjs +8 -8
- package/dist/charts/kinds/scatter.d.mts +5 -3
- package/dist/charts/kinds/scatter.mjs +18 -0
- package/dist/charts/kinds/stat-data.mjs +7 -7
- package/dist/charts/kinds/stat-marks.mjs +2 -2
- package/dist/charts/kinds/stat.d.mts +4 -4
- package/dist/charts/kinds/stat.mjs +19 -0
- package/dist/charts/kinds/time-chart.mjs +13 -4
- package/dist/charts/kinds/time-frame.mjs +50 -19
- package/dist/charts/kinds/time-plan.mjs +29 -2
- package/dist/charts/kinds/time-plot.mjs +1 -1
- package/dist/charts/kinds/time-stops.mjs +58 -29
- package/dist/charts/kinds/waterfall-data.d.mts +3 -3
- package/dist/charts/kinds/waterfall-data.mjs +2 -2
- package/dist/charts/kinds/waterfall.d.mts +5 -4
- package/dist/charts/kinds/waterfall.mjs +29 -2
- package/dist/charts/layout/frame.mjs +5 -3
- package/dist/charts/layout/stack.mjs +43 -22
- package/dist/charts/marks/axes.mjs +10 -5
- package/dist/charts/marks/budget.mjs +14 -0
- package/dist/charts/marks/end-labels.mjs +24 -10
- package/dist/charts/marks/legend.mjs +19 -8
- package/dist/charts/marks/lines.mjs +3 -3
- package/dist/charts/marks/more.mjs +79 -13
- package/dist/charts/marks/notes.mjs +12 -6
- package/dist/charts/marks/series-line.mjs +14 -10
- package/dist/charts/marks/thin.mjs +16 -33
- package/dist/charts/scale/calendar.mjs +41 -26
- package/dist/charts/scale/linear.mjs +58 -0
- package/dist/charts/scale/value.d.mts +21 -0
- package/dist/charts/scale/value.mjs +67 -9
- package/dist/charts/scene/lazy.mjs +27 -0
- package/dist/charts/scene/markup.mjs +2 -1
- package/dist/charts/scene/svg.mjs +20 -8
- package/dist/charts/scene/types.d.mts +34 -0
- package/dist/charts/text/measure.mjs +33 -3
- package/dist/charts/theme.mjs +13 -4
- package/dist/charts-react/Chart.d.mts +20 -0
- package/dist/charts-react/Chart.mjs +9 -67
- package/dist/charts-react/Reader.mjs +50 -96
- package/dist/charts-react/box.mjs +106 -0
- package/dist/charts-react/bucket-names.mjs +9 -24
- package/dist/charts-react/columns-picture.mjs +12 -0
- package/dist/charts-react/exact-sum.mjs +4 -7
- package/dist/charts-react/from-answer.mjs +9 -4
- package/dist/charts-react/index.d.mts +9 -2
- package/dist/charts-react/index.mjs +9 -2
- package/dist/charts-react/kinds/area.d.mts +4 -0
- package/dist/charts-react/kinds/area.mjs +38 -0
- package/dist/charts-react/kinds/bar.d.mts +4 -0
- package/dist/charts-react/kinds/bar.mjs +15 -0
- package/dist/charts-react/kinds/funnel.d.mts +4 -0
- package/dist/charts-react/kinds/funnel.mjs +13 -0
- package/dist/charts-react/kinds/heatmap.d.mts +4 -0
- package/dist/charts-react/kinds/heatmap.mjs +13 -0
- package/dist/charts-react/kinds/line.d.mts +4 -0
- package/dist/charts-react/kinds/line.mjs +20 -0
- package/dist/charts-react/kinds/multiples.d.mts +4 -0
- package/dist/charts-react/kinds/multiples.mjs +33 -0
- package/dist/charts-react/kinds/number.d.mts +5 -0
- package/dist/charts-react/kinds/number.mjs +86 -0
- package/dist/charts-react/plan-bars.mjs +15 -8
- package/dist/charts-react/plan-funnel.mjs +3 -1
- package/dist/charts-react/plan-grid.mjs +14 -5
- package/dist/charts-react/plan-of.mjs +17 -0
- package/dist/charts-react/plan-parts.mjs +16 -5
- package/dist/charts-react/plan-time.mjs +4 -53
- package/dist/charts-react/reader-page.d.mts +1 -1
- package/dist/charts-react/reader-page.mjs +19 -9
- package/dist/charts-react/renderers.d.mts +14 -0
- package/dist/charts-react/renderers.mjs +22 -0
- package/dist/charts-react/table.d.mts +1 -0
- package/dist/charts-react/table.mjs +108 -0
- package/dist/charts-react/tiles.mjs +21 -49
- package/dist/charts-react/useScene.mjs +45 -17
- package/dist/charts-react/words.mjs +19 -0
- package/dist/checks.mjs +97 -19
- package/dist/cli/add.mjs +4 -3
- package/dist/cli/doctor.mjs +2 -2
- package/dist/core/conformance/index.d.mts +5 -2
- package/dist/core/conformance/index.mjs +5 -2
- package/dist/core/conformance/memory/aggregate.mjs +11 -6
- package/dist/core/conformance/memory/rows.d.mts +7 -3
- package/dist/core/conformance/memory/rows.mjs +19 -13
- package/dist/core/conformance/memory/source.mjs +4 -4
- package/dist/core/document/control-fields.d.mts +20 -0
- package/dist/core/document/control-fields.mjs +117 -0
- package/dist/core/document/display-comparisons.d.mts +17 -0
- package/dist/core/document/display-comparisons.mjs +15 -4
- package/dist/core/document/display-entries.d.mts +14 -0
- package/dist/core/document/display-entries.mjs +25 -9
- package/dist/core/document/display-validation.d.mts +5 -1
- package/dist/core/document/display-validation.mjs +14 -7
- package/dist/core/document/display.d.mts +10 -8
- package/dist/core/document/display.mjs +25 -4
- package/dist/core/document/layout.d.mts +8 -9
- package/dist/core/document/layout.mjs +23 -6
- package/dist/core/document/stacked.d.mts +0 -7
- package/dist/core/document/types.mjs +8 -6
- package/dist/core/document/upgrade.d.mts +1 -0
- package/dist/core/document/upgrade.mjs +4 -2
- package/dist/core/engine/access.mjs +3 -3
- package/dist/core/engine/assert.mjs +4 -2
- package/dist/core/engine/bucket.mjs +2 -2
- package/dist/core/engine/checks.mjs +6 -7
- package/dist/core/engine/custom/ask.mjs +22 -2
- package/dist/core/engine/custom/cells.mjs +22 -22
- package/dist/core/engine/custom/level.mjs +12 -13
- package/dist/core/engine/custom/measures.mjs +12 -9
- package/dist/core/engine/custom/reader.mjs +3 -1
- package/dist/core/engine/custom/records.mjs +8 -7
- package/dist/core/engine/custom/unread.mjs +78 -0
- package/dist/core/engine/custom/where.mjs +15 -10
- package/dist/core/engine/index.d.mts +2 -13
- package/dist/core/engine/index.mjs +2 -12
- package/dist/core/engine/measure.mjs +1 -0
- package/dist/core/engine/members.mjs +7 -3
- package/dist/core/engine/nan.mjs +10 -1
- package/dist/core/engine/native.mjs +2 -20
- package/dist/core/engine/numbers.mjs +26 -14
- package/dist/core/engine/postgres.mjs +9 -5
- package/dist/core/engine/prepare.mjs +4 -4
- package/dist/core/engine/rank-sets.mjs +1 -1
- package/dist/core/engine/read.mjs +5 -4
- package/dist/core/engine/reader.d.mts +6 -0
- package/dist/core/engine/record-layout.mjs +3 -3
- package/dist/core/engine/run.mjs +77 -20
- package/dist/core/engine/segmented.d.mts +2 -1
- package/dist/core/engine/segmented.mjs +19 -12
- package/dist/core/engine/series.mjs +1 -1
- package/dist/core/engine/shape.mjs +8 -8
- package/dist/core/engine/sql-partition.mjs +2 -2
- package/dist/core/engine/sql-pass.mjs +3 -2
- package/dist/core/engine/sql-reader.mjs +13 -5
- package/dist/core/engine/sql-reads.mjs +2 -1
- package/dist/core/engine/sql-records.mjs +2 -2
- package/dist/core/engine/sql-split.mjs +1 -1
- package/dist/core/engine/sql-unread.mjs +70 -0
- package/dist/core/engine/time.mjs +2 -1
- package/dist/core/engine/types.d.mts +17 -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 +24 -1
- package/dist/core/error/codes.mjs +23 -3
- package/dist/core/error/refusal.d.mts +8 -3
- package/dist/core/error/refusal.mjs +6 -1
- package/dist/core/exact/decimal.d.mts +1 -14
- package/dist/core/exact/decimal.mjs +9 -19
- package/dist/core/exact/stored.d.mts +9 -0
- package/dist/core/exact/stored.mjs +38 -0
- package/dist/core/exact/text.d.mts +16 -1
- package/dist/core/exact/text.mjs +50 -1
- package/dist/core/format/digits.mjs +55 -0
- package/dist/core/format/index.d.mts +16 -0
- package/dist/core/format/index.mjs +27 -0
- package/dist/core/format/number.d.mts +27 -0
- package/dist/core/format/number.mjs +158 -0
- package/dist/core/format/write.d.mts +6 -0
- package/dist/core/format/write.mjs +57 -0
- package/dist/core/index.d.mts +43 -33
- package/dist/core/index.mjs +31 -28
- package/dist/core/model/defaults.d.mts +18 -1
- package/dist/core/model/defaults.mjs +19 -1
- package/dist/core/model/define.d.mts +17 -8
- package/dist/core/model/define.mjs +2 -0
- package/dist/core/model/member.d.mts +5 -3
- package/dist/core/model/member.mjs +33 -6
- package/dist/core/model/storage.mjs +40 -12
- package/dist/core/model/types.d.mts +17 -1
- package/dist/core/model/types.mjs +5 -0
- package/dist/core/model/validate/expr.d.mts +1 -7
- package/dist/core/model/validate/fields.d.mts +2 -0
- package/dist/core/model/validate/fields.mjs +14 -7
- package/dist/core/model/validate/issues.mjs +5 -1
- package/dist/core/model/validate/known-members.mjs +6 -5
- package/dist/core/model/validate/shape.mjs +36 -3
- package/dist/core/model/validate/source.mjs +2 -2
- package/dist/core/oracle/data.d.mts +4 -2
- package/dist/core/oracle/evaluate.d.mts +19 -1
- package/dist/core/oracle/evaluate.mjs +56 -10
- package/dist/core/oracle/expr.mjs +1 -1
- package/dist/core/oracle/facts.mjs +12 -5
- package/dist/core/oracle/measure.mjs +1 -1
- package/dist/core/oracle/request.mjs +39 -4
- package/dist/core/oracle/segmented.d.mts +3 -1
- package/dist/core/oracle/segmented.mjs +19 -13
- package/dist/core/oracle/unread.mjs +32 -0
- package/dist/core/oracle/visibility.mjs +4 -3
- package/dist/core/policy/bind.d.mts +2 -11
- package/dist/core/policy/bind.mjs +1 -1
- package/dist/core/policy/match.mjs +1 -1
- package/dist/core/query/closure.d.mts +7 -2
- package/dist/core/query/closure.mjs +29 -12
- package/dist/core/query/compose-tile.d.mts +3 -2
- package/dist/core/query/compose-tile.mjs +32 -13
- package/dist/core/query/compose.d.mts +0 -5
- package/dist/core/query/drill/internal.d.mts +5 -5
- package/dist/core/query/drill/internal.mjs +11 -0
- package/dist/core/query/drill/links.d.mts +2 -3
- package/dist/core/query/drill/links.mjs +18 -4
- package/dist/core/query/drill/selection.d.mts +8 -2
- package/dist/core/query/drill/selection.mjs +14 -3
- package/dist/core/query/drill/synthetic.mjs +1 -1
- package/dist/core/query/drill/time.mjs +11 -10
- package/dist/core/query/filter.d.mts +1 -6
- package/dist/core/query/filter.mjs +1 -4
- package/dist/core/query/fold.mjs +23 -0
- package/dist/core/query/segments.mjs +42 -3
- package/dist/core/query/to-wire.d.mts +7 -0
- package/dist/core/query/to-wire.mjs +14 -2
- package/dist/core/query/types.d.mts +30 -13
- package/dist/core/result/columns.mjs +23 -13
- package/dist/core/result/number.mjs +3 -3
- package/dist/core/result/status.d.mts +13 -0
- package/dist/core/result/status.mjs +18 -0
- package/dist/core/result/time-axis.d.mts +14 -13
- package/dist/core/result/time-axis.mjs +20 -2
- package/dist/core/result/types.d.mts +33 -3
- package/dist/core/result/whole.d.mts +23 -0
- package/dist/core/result/whole.mjs +27 -0
- package/dist/core/schema/agent-query.d.mts +89 -0
- package/dist/core/schema/agent-query.mjs +115 -0
- package/dist/core/schema/aliases.mjs +1 -52
- package/dist/core/schema/answer-parts.mjs +17 -13
- package/dist/core/schema/answers.d.mts +787 -319
- package/dist/core/schema/commands.d.mts +33 -23
- package/dist/core/schema/commands.mjs +26 -18
- package/dist/core/schema/custom.mjs +46 -45
- package/dist/core/schema/document.d.mts +32 -27
- package/dist/core/schema/document.mjs +61 -81
- package/dist/core/schema/drill-answers.mjs +4 -1
- package/dist/core/schema/drill.d.mts +14 -9
- package/dist/core/schema/drill.mjs +23 -22
- package/dist/core/schema/index.d.mts +5 -3
- package/dist/core/schema/index.mjs +5 -3
- package/dist/core/schema/options.d.mts +92 -0
- package/dist/core/schema/options.mjs +104 -0
- package/dist/core/schema/picks.d.mts +2 -2
- package/dist/core/schema/picks.mjs +7 -6
- package/dist/core/schema/query.d.mts +9 -83
- package/dist/core/schema/query.mjs +49 -73
- package/dist/core/schema/strict.d.mts +3 -0
- package/dist/core/schema/strict.mjs +91 -0
- package/dist/core/schema/union-error.mjs +30 -7
- package/dist/core/schema/view.d.mts +4 -3
- package/dist/core/schema/view.mjs +16 -11
- package/dist/core/store/ddl.d.mts +0 -2
- package/dist/core/store/ddl.mjs +1 -5
- package/dist/core/time/bucket.d.mts +1 -19
- package/dist/core/time/bucket.mjs +6 -6
- package/dist/core/time/compare.mjs +3 -2
- package/dist/core/time/index.d.mts +7 -8
- package/dist/core/time/instant.d.mts +15 -9
- package/dist/core/time/instant.mjs +23 -9
- package/dist/core/time/range.d.mts +3 -15
- package/dist/core/time/range.mjs +17 -7
- package/dist/core/time/stored.d.mts +8 -5
- package/dist/core/time/stored.mjs +51 -15
- package/dist/core/time/temporal.d.mts +1 -5
- package/dist/core/time/temporal.mjs +9 -4
- package/dist/core/time/text-time.d.mts +31 -2
- package/dist/core/time/text-time.mjs +139 -22
- package/dist/core/time/zone.mjs +2 -2
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/dashboard.d.mts +185 -0
- package/dist/core/types/dashboard.mjs +26 -0
- package/dist/core/types/drill-api.d.mts +14 -2
- package/dist/core/types/infer.d.mts +0 -4
- package/dist/core/types/options-check.d.mts +42 -0
- package/dist/core/types/options-check.mjs +90 -0
- package/dist/core/types/options.d.mts +14 -8
- package/dist/core/value/casefold.d.mts +1 -3
- package/dist/core/value/stored.d.mts +26 -0
- package/dist/core/value/stored.mjs +28 -0
- package/dist/cursor-seal.mjs +37 -9
- package/dist/dashboard-documents.d.mts +14 -6
- package/dist/dashboard-documents.mjs +32 -12
- package/dist/dashboards.mjs +10 -9
- package/dist/drill-access.mjs +6 -6
- package/dist/drill-change.mjs +18 -20
- package/dist/drill-comparison.mjs +2 -1
- package/dist/drill-crumbs.mjs +63 -28
- package/dist/drill-distinct.mjs +2 -1
- package/dist/drill-explain.mjs +1 -1
- package/dist/drill-items.mjs +1 -1
- package/dist/drill-open.mjs +39 -23
- package/dist/drill-seal.mjs +41 -13
- package/dist/drill-share.mjs +1 -1
- package/dist/drill-summary.mjs +2 -1
- package/dist/drill-targets.mjs +4 -4
- package/dist/drill-views.mjs +4 -3
- package/dist/drill.mjs +1 -1
- package/dist/editing.mjs +5 -3
- package/dist/endpoints/index.d.mts +29 -8
- package/dist/endpoints/index.mjs +4 -1
- package/dist/endpoints/meta.mjs +4 -3
- package/dist/endpoints/query.mjs +5 -2
- package/dist/endpoints/read.mjs +7 -6
- package/dist/endpoints/versions.mjs +2 -1
- package/dist/execute.d.mts +3 -0
- package/dist/execute.mjs +23 -12
- package/dist/grant.d.mts +9 -0
- package/dist/grant.mjs +43 -0
- package/dist/handler.mjs +8 -13
- package/dist/http.d.mts +6 -2
- package/dist/http.mjs +6 -2
- package/dist/index.d.mts +25 -4
- package/dist/index.mjs +91 -40
- package/dist/llms.txt +3 -3
- package/dist/mcp/api.mjs +2 -1
- package/dist/mcp/query.mjs +3 -8
- package/dist/mcp/resolve.mjs +9 -2
- package/dist/node/index.d.mts +36 -0
- package/dist/node/index.mjs +89 -0
- package/dist/node/request.d.mts +12 -0
- package/dist/node/request.mjs +119 -0
- package/dist/node/response.mjs +58 -0
- package/dist/principal.mjs +15 -7
- package/dist/react/Canvas.mjs +88 -67
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +9 -1
- package/dist/react/Dashboard.mjs +42 -42
- package/dist/react/DashboardList.mjs +9 -4
- package/dist/react/Editing.d.mts +9 -0
- package/dist/react/Editing.mjs +8 -3
- package/dist/react/Grid.mjs +1 -1
- package/dist/react/Header.mjs +4 -35
- package/dist/react/History.mjs +3 -2
- package/dist/react/LoadFailed.mjs +59 -0
- package/dist/react/Panel.d.mts +1 -1
- package/dist/react/Panel.mjs +1 -1
- package/dist/react/Parts.d.mts +34 -0
- package/dist/react/Parts.mjs +9 -6
- package/dist/react/ReviewPanel.mjs +1 -1
- package/dist/react/RowBody.d.mts +2 -0
- package/dist/react/RowBody.mjs +5 -1
- package/dist/react/Share.mjs +153 -0
- package/dist/react/TabStrip.mjs +37 -0
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +89 -92
- package/dist/react/TileState.mjs +117 -0
- package/dist/react/ago.mjs +45 -0
- package/dist/react/arrange.mjs +1 -1
- package/dist/react/board.mjs +2 -2
- package/dist/react/bucket-name.d.mts +8 -0
- package/dist/react/bucket-name.mjs +13 -0
- package/dist/react/builder/DisplayOptions.mjs +219 -0
- package/dist/react/builder/Preview.mjs +13 -13
- package/dist/react/builder/RangeEditor.mjs +4 -3
- package/dist/react/builder/WidgetBuilder.d.mts +1 -7
- package/dist/react/builder/WidgetBuilder.mjs +12 -3
- package/dist/react/builder/base.d.mts +13 -2
- package/dist/react/builder/base.mjs +70 -12
- package/dist/react/builder/display.d.mts +3 -0
- package/dist/react/builder/display.mjs +256 -0
- package/dist/react/builder/labels.mjs +19 -5
- package/dist/react/builder/options.mjs +11 -6
- package/dist/react/builder/state.mjs +25 -3
- package/dist/react/builder/useBuilder.d.mts +7 -1
- package/dist/react/builder/useBuilder.mjs +6 -9
- package/dist/react/builder/usePreview.mjs +3 -2
- package/dist/react/builder/words.d.mts +16 -1
- package/dist/react/builder/words.mjs +41 -1
- package/dist/react/change-text.mjs +149 -0
- package/dist/react/client.d.mts +9 -0
- package/dist/react/client.mjs +105 -14
- package/dist/react/context.d.mts +24 -3
- package/dist/react/context.mjs +23 -7
- package/dist/react/dates-shown.mjs +76 -0
- package/dist/react/draft.mjs +3 -2
- package/dist/react/drill/Bars.mjs +12 -16
- package/dist/react/drill/Comparison.mjs +1 -1
- package/dist/react/drill/DrillPanel.d.mts +1 -1
- package/dist/react/drill/DrillPanel.mjs +2 -1
- package/dist/react/drill/Header.mjs +65 -12
- package/dist/react/drill/Items.d.mts +1 -1
- package/dist/react/drill/Notes.mjs +10 -7
- package/dist/react/drill/PanelStates.mjs +8 -1
- package/dist/react/drill/Trend.mjs +10 -5
- package/dist/react/drill/board.d.mts +1 -1
- package/dist/react/drill/host.mjs +4 -1
- package/dist/react/drill/lazy.mjs +2 -27
- package/dist/react/drill/props.d.mts +17 -7
- package/dist/react/drill/props.mjs +55 -14
- package/dist/react/drill/state.d.mts +15 -5
- package/dist/react/drill/state.mjs +12 -3
- package/dist/react/drill/words.d.mts +46 -3
- package/dist/react/drill/words.mjs +30 -5
- package/dist/react/english.mjs +33 -8
- package/dist/react/export/ExportButton.mjs +4 -1
- package/dist/react/export/csv.d.mts +7 -2
- package/dist/react/export/csv.mjs +24 -7
- package/dist/react/failure-words.mjs +60 -0
- package/dist/react/filters/bar.d.mts +1 -1
- package/dist/react/filters/bar.mjs +4 -1
- package/dist/react/filters/calendar.mjs +23 -8
- package/dist/react/filters/chip.mjs +7 -3
- package/dist/react/filters/context.d.mts +13 -1
- package/dist/react/filters/context.mjs +1 -1
- package/dist/react/filters/dates-said.mjs +57 -0
- package/dist/react/filters/days.d.mts +3 -4
- package/dist/react/filters/days.mjs +10 -17
- package/dist/react/filters/hooks.d.mts +11 -0
- package/dist/react/filters/hooks.mjs +10 -6
- package/dist/react/filters/menu-search.mjs +17 -9
- package/dist/react/filters/menu.mjs +10 -8
- package/dist/react/filters/phone.mjs +41 -16
- package/dist/react/filters/place.mjs +40 -0
- package/dist/react/filters/popover.mjs +18 -13
- package/dist/react/filters/rules.d.mts +4 -3
- package/dist/react/filters/rules.mjs +3 -3
- package/dist/react/filters/sheet.mjs +7 -3
- package/dist/react/filters/state.mjs +6 -1
- package/dist/react/filters/values.mjs +24 -7
- package/dist/react/filters/words.d.mts +13 -0
- package/dist/react/filters/words.mjs +5 -0
- package/dist/react/format-time.d.mts +17 -6
- package/dist/react/format-time.mjs +152 -33
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +27 -133
- package/dist/react/headline.d.mts +6 -3
- package/dist/react/headline.mjs +81 -25
- package/dist/react/index.d.mts +19 -17
- package/dist/react/index.mjs +12 -10
- package/dist/react/lazy.mjs +38 -0
- package/dist/react/messages.d.mts +78 -2
- package/dist/react/now.mjs +38 -0
- package/dist/react/read.d.mts +1 -0
- package/dist/react/read.mjs +140 -9
- package/dist/react/renderers/exact.mjs +31 -59
- package/dist/react/renderers/index.d.mts +27 -6
- package/dist/react/renderers/index.mjs +141 -102
- package/dist/react/renderers/list-parts.mjs +24 -0
- package/dist/react/renderers/list.d.mts +1 -0
- package/dist/react/renderers/list.mjs +99 -43
- package/dist/react/renderers/more-rows.mjs +75 -0
- package/dist/react/renderers/number-before.mjs +320 -0
- package/dist/react/renderers/number-period.mjs +54 -0
- package/dist/react/renderers/number-whole.mjs +29 -0
- package/dist/react/renderers/props.d.mts +24 -1
- package/dist/react/renderers/props.mjs +8 -0
- package/dist/react/renderers/table-cells.mjs +137 -31
- package/dist/react/renderers/table-fit.mjs +55 -10
- package/dist/react/renderers/table-measure.mjs +29 -9
- package/dist/react/renderers/table-row.mjs +14 -9
- package/dist/react/renderers/table-scale.mjs +2 -3
- package/dist/react/renderers/table-sort.mjs +3 -2
- package/dist/react/renderers/table-whole.mjs +37 -0
- package/dist/react/renderers/table.mjs +73 -53
- package/dist/react/review.d.mts +7 -0
- package/dist/react/review.mjs +35 -8
- package/dist/react/roving.d.mts +6 -0
- package/dist/react/roving.mjs +123 -0
- package/dist/react/says-dates.d.mts +7 -0
- package/dist/react/says-dates.mjs +51 -0
- package/dist/react/series.mjs +5 -6
- package/dist/react/stable.mjs +1 -1
- package/dist/react/tabs/EditTabs.mjs +125 -0
- package/dist/react/tabs/NameField.mjs +72 -0
- package/dist/react/tabs/TabMenu.mjs +175 -0
- package/dist/react/tabs/actions.mjs +37 -0
- package/dist/react/tabs/commands.mjs +76 -0
- package/dist/react/tabs/focus.mjs +22 -0
- package/dist/react/tabs/keys.mjs +28 -0
- package/dist/react/theme-unlayered.css +1 -1
- package/dist/react/theme.css +1 -1
- package/dist/react/tile-store.d.mts +4 -0
- package/dist/react/tile-store.mjs +93 -13
- package/dist/react/touch.d.mts +16 -0
- package/dist/react/touch.mjs +39 -0
- package/dist/react/useBoard.d.mts +6 -0
- package/dist/react/useBoard.mjs +1 -0
- package/dist/react/useDashboard.d.mts +2 -0
- package/dist/react/useDashboard.mjs +5 -2
- package/dist/react/useTiles.d.mts +3 -0
- package/dist/react/useTiles.mjs +73 -17
- package/dist/react/view-grid.mjs +2 -2
- package/dist/react/view.mjs +1 -1
- package/dist/recharts/axes.mjs +1 -1
- package/dist/recharts/axis.mjs +23 -73
- package/dist/recharts/bar.d.mts +2 -1
- package/dist/recharts/bar.mjs +140 -64
- package/dist/recharts/fit.mjs +33 -0
- package/dist/recharts/line.mjs +21 -15
- package/dist/recharts/marks.mjs +2 -1
- package/dist/recharts/parts.mjs +16 -13
- package/dist/recharts/table.mjs +8 -3
- package/dist/refusal.mjs +46 -0
- package/dist/registry/filter-bar.json +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +23 -8
- package/dist/tile-doc.mjs +1 -1
- package/package.json +21 -6
- package/dist/charts-react/plan.d.mts +0 -3
- package/dist/charts-react/plan.mjs +0 -37
- package/dist/charts-react/tiles.d.mts +0 -24
- package/dist/core/policy/match.d.mts +0 -16
- package/dist/core/schema/aliases.d.mts +0 -7
- package/dist/core/time/compare.d.mts +0 -30
- package/dist/react/EditBar.d.mts +0 -16
- package/dist/react/History.d.mts +0 -30
- package/dist/react/ReviewPanel.d.mts +0 -15
- package/dist/react/digits.mjs +0 -46
- package/dist/react/drill/trend-touch.mjs +0 -33
- package/dist/react/renderers/exact.d.mts +0 -6
package/dist/endpoints/read.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { bodies, parseWith } from "../body.mjs";
|
|
2
2
|
import { listDashboards, loadDashboard } from "../dashboards.mjs";
|
|
3
3
|
import { hasOpenDraft, ownUnpublished, unpublishedFor } from "../editing.mjs";
|
|
4
|
+
import { allows } from "../grant.mjs";
|
|
4
5
|
import { HttpError } from "../http.mjs";
|
|
5
6
|
import { dashboardResource } from "../owner.mjs";
|
|
6
7
|
import { userOf } from "../request.mjs";
|
|
@@ -10,7 +11,7 @@ import { createDashEndpoint } from "derive-dashboards/core";
|
|
|
10
11
|
/** A dashboard as its viewer sees it, or the caller's own unpublished one from their draft. */
|
|
11
12
|
async function loadOrDraft(rt, request, user, id) {
|
|
12
13
|
try {
|
|
13
|
-
return await loadDashboard(rt
|
|
14
|
+
return await loadDashboard(rt, request, user, { id });
|
|
14
15
|
} catch (error) {
|
|
15
16
|
if (!(error instanceof HttpError) || error.code !== "NOT_FOUND") throw error;
|
|
16
17
|
const draft = await unpublishedFor(rt, request, user, id);
|
|
@@ -30,14 +31,14 @@ async function loadOrDraft(rt, request, user, id) {
|
|
|
30
31
|
async function listFor(rt, request, user) {
|
|
31
32
|
const { options } = rt;
|
|
32
33
|
const { viewer } = user;
|
|
33
|
-
const all = await listDashboards(
|
|
34
|
-
const allowed = await Promise.all(all.map(({ owner, ...d }) =>
|
|
34
|
+
const all = await listDashboards(rt, request, user);
|
|
35
|
+
const allowed = await Promise.all(all.map(({ owner, ...d }) => allows(options.access, viewer, "view", {
|
|
35
36
|
kind: "dashboard",
|
|
36
37
|
id: d.id,
|
|
37
38
|
...owner === void 0 ? {} : { owner }
|
|
38
|
-
})))
|
|
39
|
+
})));
|
|
39
40
|
const own = await ownUnpublished(rt, request, user);
|
|
40
|
-
const create = options.database !== void 0 && await options.access
|
|
41
|
+
const create = options.database !== void 0 && await allows(options.access, viewer, "edit", { kind: "tenant" });
|
|
41
42
|
return {
|
|
42
43
|
dashboards: [...all.filter((_d, i) => allowed[i] === true).map(({ owner: _o, ...d }) => d), ...own],
|
|
43
44
|
can: { create }
|
|
@@ -61,7 +62,7 @@ function readEndpoints(rt) {
|
|
|
61
62
|
const user = userOf(principal);
|
|
62
63
|
const loaded = await loadOrDraft(rt, request, user, body.dashboardId);
|
|
63
64
|
const resource = await dashboardResource(options, request, user, body.dashboardId);
|
|
64
|
-
const [edit, manage] = await Promise.all([options.access
|
|
65
|
+
const [edit, manage] = await Promise.all([allows(options.access, user.viewer, "edit", resource), allows(options.access, user.viewer, "manage", resource)]);
|
|
65
66
|
const canEdit = edit && options.database !== void 0;
|
|
66
67
|
const waiting = canEdit && await hasOpenDraft(rt, request, user, body.dashboardId);
|
|
67
68
|
return {
|
|
@@ -2,6 +2,7 @@ import { bodies, parseWith } from "../body.mjs";
|
|
|
2
2
|
import { checkDocument, versionDoc } from "../checks.mjs";
|
|
3
3
|
import { servedAs } from "../dashboard-id.mjs";
|
|
4
4
|
import { editorOf, storeFor, storedId } from "../editing.mjs";
|
|
5
|
+
import { allows } from "../grant.mjs";
|
|
5
6
|
import { HttpError } from "../http.mjs";
|
|
6
7
|
import { dashboardResource } from "../owner.mjs";
|
|
7
8
|
import { userOf } from "../request.mjs";
|
|
@@ -91,7 +92,7 @@ function versionEndpoints(rt) {
|
|
|
91
92
|
const next = versions.length === page && last !== void 0 ? { next: last.version } : {};
|
|
92
93
|
const resource = await dashboardResource(rt.options, request, user, body.dashboardId);
|
|
93
94
|
return {
|
|
94
|
-
versions: await rt.options.access
|
|
95
|
+
versions: await allows(rt.options.access, user.viewer, "edit", resource) ? versions : versions.map(({ author: _a, ...v }) => v),
|
|
95
96
|
...next
|
|
96
97
|
};
|
|
97
98
|
}
|
package/dist/execute.d.mts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import "./reading.mjs";
|
|
2
2
|
import { Cache } from "./cache.mjs";
|
|
3
3
|
import { cursorKey, macKey } from "./cursor-seal.mjs";
|
|
4
|
+
import { CheckedDashboard } from "./dashboard-documents.mjs";
|
|
4
5
|
import { Cuts, DashOptions, Model, Principal, Result, WireQuery } from "derive-dashboards/core";
|
|
5
6
|
import "derive-dashboards/core/engine";
|
|
6
7
|
/** The runtime's state for one handler: its options and its result cache. */
|
|
7
8
|
export type Runtime = {
|
|
8
9
|
options: DashOptions;
|
|
10
|
+
/** The code dashboards, as checked at start (`checkedDashboards`). */
|
|
11
|
+
dashboards: readonly CheckedDashboard[];
|
|
9
12
|
cache: Cache | undefined;
|
|
10
13
|
/** Seals records cursors and a drill's parts (`cursor-seal`). */
|
|
11
14
|
cursorKey: ReturnType<typeof cursorKey>;
|
package/dist/execute.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { macHex } from "./cursor-seal.mjs";
|
|
|
4
4
|
import { adapterFor } from "./dashboards.mjs";
|
|
5
5
|
import { withReader } from "./reading.mjs";
|
|
6
6
|
import { logQuery } from "./store/log.mjs";
|
|
7
|
-
import { bindQueryViewer, bindViewer, canonical, isBound, markedRows, resultColumns, withTime } from "derive-dashboards/core";
|
|
7
|
+
import { answerStatus, bindQueryViewer, bindViewer, canonical, formatTextTime, isBound, markedRows, markedWhole, requestInstant, resultColumns, unreadWarnings, withTime } from "derive-dashboards/core";
|
|
8
8
|
import { EngineError, readQuery } from "derive-dashboards/core/engine";
|
|
9
9
|
// src/execute.ts
|
|
10
10
|
/** An answer as a client reads it: without what only the server reads. */
|
|
@@ -74,32 +74,44 @@ const reading = (x, maxRows, fn) => withReader({
|
|
|
74
74
|
source: x.query.source,
|
|
75
75
|
maxRows
|
|
76
76
|
}, fn);
|
|
77
|
+
/** A whole as the answer carries it (`Result.whole`), marked as its rows are; none when absent. */
|
|
78
|
+
function wholeOf(query, whole) {
|
|
79
|
+
const rows = markedWhole(query, whole);
|
|
80
|
+
return rows === void 0 ? {} : { whole: { rows } };
|
|
81
|
+
}
|
|
82
|
+
/** The comparison period as the answer carries it: its rows marked and timed, its range, its whole. */
|
|
83
|
+
function comparisonOf(query, compare, timed) {
|
|
84
|
+
if (compare === void 0) return void 0;
|
|
85
|
+
return {
|
|
86
|
+
...timed(markedRows(query, compare), compare.range),
|
|
87
|
+
range: compare.range,
|
|
88
|
+
...wholeOf(query, compare.whole)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
77
91
|
/** Runs the engine and shapes its answer as the plan's `Result`, with a receipt of what was read. */
|
|
78
92
|
async function compute(x, bound) {
|
|
79
93
|
const started = performance.now();
|
|
80
94
|
const computedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
81
95
|
const { value, consistency, custom } = await reading(x, bound.maxRows, (reader) => readQuery(bound.input, reader));
|
|
82
96
|
const cuts = value.cuts === void 0 ? {} : { cuts: value.cuts };
|
|
83
|
-
const { truncated, unreadable, compare, ...levels } = value.answer;
|
|
84
|
-
const warnings = truncated === true ? [{
|
|
97
|
+
const { truncated, unreadable, compare, unread, whole, ...levels } = value.answer;
|
|
98
|
+
const warnings = [...truncated === true ? [{
|
|
85
99
|
code: "ROW_CAP",
|
|
86
100
|
message: `The answer was cut at ${bound.maxRows} rows.`,
|
|
87
101
|
path: []
|
|
88
|
-
}] : [];
|
|
102
|
+
}] : [], ...unreadWarnings(unread)];
|
|
89
103
|
const columns = resultColumns(x.rt.options.model, x.query);
|
|
90
104
|
const timed = (rows, range) => withTime(columns, rows, {
|
|
91
105
|
range,
|
|
92
106
|
calendar: x.calendar
|
|
93
107
|
});
|
|
94
|
-
const before = compare
|
|
95
|
-
...timed(markedRows(x.query, compare), compare.range),
|
|
96
|
-
range: compare.range
|
|
97
|
-
};
|
|
108
|
+
const before = comparisonOf(x.query, compare, timed);
|
|
98
109
|
return {
|
|
99
110
|
columns,
|
|
100
111
|
...timed(markedRows(x.query, levels), value.range),
|
|
112
|
+
...wholeOf(x.query, whole),
|
|
101
113
|
...before === void 0 ? {} : { compare: before },
|
|
102
|
-
status:
|
|
114
|
+
status: answerStatus(value.answer),
|
|
103
115
|
...unreadable === true ? { unreadable } : {},
|
|
104
116
|
...cuts,
|
|
105
117
|
receipt: {
|
|
@@ -119,7 +131,7 @@ async function compute(x, bound) {
|
|
|
119
131
|
computedAt,
|
|
120
132
|
consistency,
|
|
121
133
|
durationMs: Math.round(performance.now() - started),
|
|
122
|
-
rowsReturned: levels.rows.length,
|
|
134
|
+
rowsReturned: levels.rows.length + (whole?.rows.length ?? 0),
|
|
123
135
|
filter: receiptFilter(bound),
|
|
124
136
|
coverage: x.coverage,
|
|
125
137
|
warnings
|
|
@@ -148,7 +160,6 @@ function answered(x) {
|
|
|
148
160
|
const bound = bind(x);
|
|
149
161
|
const { cache, options } = x.rt;
|
|
150
162
|
if (cache === void 0) return compute(x, bound);
|
|
151
|
-
const quantum = (options.cache?.quantum ?? 60) * 1e3;
|
|
152
163
|
const on = [...bound.lock, ...bound.required].map((e) => e.on);
|
|
153
164
|
const key = {
|
|
154
165
|
principal: x.principal,
|
|
@@ -157,7 +168,7 @@ function answered(x) {
|
|
|
157
168
|
required: bound.required,
|
|
158
169
|
calendar: x.calendar,
|
|
159
170
|
maxRows: bound.maxRows,
|
|
160
|
-
now: x.now
|
|
171
|
+
now: formatTextTime(requestInstant(x.now, bound.input.quantumSeconds)),
|
|
161
172
|
sources: manifest(options.model, bound.input.query, on)
|
|
162
173
|
};
|
|
163
174
|
return cache.answer(key, () => compute(x, bound));
|
package/dist/grant.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DashOptions, StartError, Viewer } from "derive-dashboards/core";
|
|
2
|
+
/**
|
|
3
|
+
* The `access` option is not one the server can ask: it names the option and what it must be. A
|
|
4
|
+
* kind of `StartError`, code ACCESS_INVALID.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AccessOptionError extends StartError {
|
|
7
|
+
readonly option: "access" | "access.can" | "access.sensitive";
|
|
8
|
+
constructor(option: AccessOptionError["option"], message: string);
|
|
9
|
+
}
|
package/dist/grant.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { StartError } from "derive-dashboards/core";
|
|
2
|
+
// src/grant.ts
|
|
3
|
+
/** Whether the host grants this viewer the verb on the resource: its `can` answered `true`. */
|
|
4
|
+
async function allows(access, viewer, verb, resource) {
|
|
5
|
+
return await access.can(viewer, verb, resource) === true;
|
|
6
|
+
}
|
|
7
|
+
/** The most questions asked of a host at once: a pool of connections is not handed a whole document's fields. */
|
|
8
|
+
const MOST_AT_ONCE = 16;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the host grants this viewer the verb on each of `resources`, in their order. They are
|
|
11
|
+
* asked together, since a host's check may read its own database and a document names many
|
|
12
|
+
* fields, but at most sixteen at a time: every field at once would queue behind a host's pool,
|
|
13
|
+
* or open a query for each where there is none.
|
|
14
|
+
*/
|
|
15
|
+
async function allowsEach(asked, resources) {
|
|
16
|
+
const granted = [];
|
|
17
|
+
const todo = resources.entries();
|
|
18
|
+
const work = async () => {
|
|
19
|
+
for (const [at, resource] of todo) granted[at] = await allows(asked.access, asked.viewer, asked.verb, resource);
|
|
20
|
+
};
|
|
21
|
+
await Promise.all(Array.from({ length: Math.min(MOST_AT_ONCE, resources.length) }, work));
|
|
22
|
+
return granted;
|
|
23
|
+
}
|
|
24
|
+
/** Whether the host lets this viewer read a member the model marks sensitive: `sensitive` answered `true`. */
|
|
25
|
+
function allowsSensitive(access, viewer, member) {
|
|
26
|
+
return access.sensitive?.(viewer, member) === true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The `access` option is not one the server can ask: it names the option and what it must be. A
|
|
30
|
+
* kind of `StartError`, code ACCESS_INVALID.
|
|
31
|
+
*/
|
|
32
|
+
var AccessOptionError = class extends StartError {
|
|
33
|
+
option;
|
|
34
|
+
constructor(option, message) {
|
|
35
|
+
super("ACCESS_INVALID", [{
|
|
36
|
+
path: option.split("."),
|
|
37
|
+
message
|
|
38
|
+
}], { message });
|
|
39
|
+
this.name = "AccessOptionError";
|
|
40
|
+
this.option = option;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export { AccessOptionError, allows, allowsEach, allowsSensitive };
|
package/dist/handler.mjs
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { coreEndpoints } from "./endpoints/index.mjs";
|
|
2
|
+
import { allows } from "./grant.mjs";
|
|
2
3
|
import { HttpError, errorResponse, json, ndjson } from "./http.mjs";
|
|
3
4
|
import { dashboardResource } from "./owner.mjs";
|
|
4
5
|
import { checkTenant, principalOf } from "./principal.mjs";
|
|
6
|
+
import { refusalBoundary } from "./refusal.mjs";
|
|
5
7
|
import { BASE_ERROR_CODES, CONTRACT_VERSION } from "derive-dashboards/core";
|
|
6
|
-
import { EngineError } from "derive-dashboards/core/engine";
|
|
7
8
|
import { addRoute, createRouter, findRoute } from "rou3";
|
|
8
9
|
// src/handler.ts
|
|
9
|
-
/** Engine refusals the caller can fix are 400s; a plan that fails its own check is a 500. */
|
|
10
|
-
function engineStatus(error) {
|
|
11
|
-
if (error.code === "PLAN_ASSERTION" || error.code === "NUMERIC_STORAGE") return 500;
|
|
12
|
-
return error.code === "TENANT_MISSING" ? 403 : 400;
|
|
13
|
-
}
|
|
14
10
|
async function authorize(options, endpoint, ctx) {
|
|
15
11
|
const { access } = endpoint;
|
|
16
12
|
if (access.kind === "public") return;
|
|
@@ -19,7 +15,7 @@ async function authorize(options, endpoint, ctx) {
|
|
|
19
15
|
if (access.kind === "signed_in") return;
|
|
20
16
|
const named = access.resource(ctx.body);
|
|
21
17
|
const resource = named.kind === "dashboard" ? await dashboardResource(options, ctx.request, ctx.principal, named.id) : named;
|
|
22
|
-
if (!await options.access
|
|
18
|
+
if (!await allows(options.access, ctx.principal.viewer, access.verb, resource)) throw new HttpError(403, "FORBIDDEN", BASE_ERROR_CODES.FORBIDDEN.message);
|
|
23
19
|
}
|
|
24
20
|
/**
|
|
25
21
|
* A browser sends its page's origin with every POST. One that is neither this server's nor a
|
|
@@ -44,7 +40,7 @@ async function runHooks(hooks, path, ctx) {
|
|
|
44
40
|
for (const hook of hooks.filter((h) => h.matcher(path))) await hook.handler(ctx);
|
|
45
41
|
}
|
|
46
42
|
/** One endpoint for one request: the viewer, access, the body, hooks, then the handler's answer. */
|
|
47
|
-
async function
|
|
43
|
+
async function answer(rt, hooks, endpoint, call) {
|
|
48
44
|
const { request } = call;
|
|
49
45
|
const principal = await principalOf(rt.options, request, call.viewer);
|
|
50
46
|
const raw = await readBody(request);
|
|
@@ -74,6 +70,8 @@ async function run(rt, hooks, endpoint, call) {
|
|
|
74
70
|
await runHooks(hooks.after, endpoint.path, answered);
|
|
75
71
|
return output;
|
|
76
72
|
}
|
|
73
|
+
/** `answer` behind the one boundary every refusal passes, over HTTP and as `api.<name>` alike. */
|
|
74
|
+
const run = refusalBoundary(answer);
|
|
77
75
|
async function dispatch(rt, hooks, endpoint, request) {
|
|
78
76
|
checkOrigin(rt.options, endpoint, request);
|
|
79
77
|
const output = await run(rt, hooks, endpoint, { request });
|
|
@@ -110,7 +108,8 @@ function serverCall(rt, endpoint) {
|
|
|
110
108
|
};
|
|
111
109
|
}
|
|
112
110
|
/**
|
|
113
|
-
* A refusal answers with its own code; what it keeps
|
|
111
|
+
* A refusal (`run` has made every one an `HttpError`) answers with its own code; what it keeps
|
|
112
|
+
* for the host alone goes to `onError`.
|
|
114
113
|
* Anything else is the library's or the host's bug: it
|
|
115
114
|
* goes to `onError` (the console by default) and answers 500 `INTERNAL`, never a stack.
|
|
116
115
|
*/
|
|
@@ -119,10 +118,6 @@ function errorOf(rt, error, request) {
|
|
|
119
118
|
if (error.cause !== void 0) (rt.options.onError ?? console.error)(error.cause, request);
|
|
120
119
|
return errorResponse(error);
|
|
121
120
|
}
|
|
122
|
-
if (error instanceof EngineError) return json(engineStatus(error), { error: {
|
|
123
|
-
code: error.code,
|
|
124
|
-
message: error.message
|
|
125
|
-
} });
|
|
126
121
|
if (request.signal.aborted) return json(499, { error: {
|
|
127
122
|
code: "CANCELLED",
|
|
128
123
|
message: BASE_ERROR_CODES.CANCELLED.message
|
package/dist/http.d.mts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Issue, RuntimeErrorCode } from "derive-dashboards/core";
|
|
2
|
-
|
|
2
|
+
import { EngineErrorCode } from "derive-dashboards/core/engine";
|
|
3
|
+
/**
|
|
4
|
+
* A refusal: the handler answers it as a JSON error with its status, and `api.<name>` throws it.
|
|
5
|
+
* An engine refusal arrives as one too, with its own code (`refusal.ts`).
|
|
6
|
+
*/
|
|
3
7
|
export declare class HttpError extends Error {
|
|
4
8
|
readonly status: number;
|
|
5
|
-
readonly code: RuntimeErrorCode;
|
|
9
|
+
readonly code: RuntimeErrorCode | EngineErrorCode;
|
|
6
10
|
readonly issues: readonly Issue[] | undefined;
|
|
7
11
|
/**
|
|
8
12
|
* `issues`: what was wrong, item by item. `cause`: what only the host should see (a
|
package/dist/http.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/http.ts
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A refusal: the handler answers it as a JSON error with its status, and `api.<name>` throws it.
|
|
4
|
+
* An engine refusal arrives as one too, with its own code (`refusal.ts`).
|
|
5
|
+
*/
|
|
3
6
|
var HttpError = class extends Error {
|
|
4
7
|
status;
|
|
5
8
|
code;
|
|
@@ -35,6 +38,7 @@ function errorResponse(error) {
|
|
|
35
38
|
...issues
|
|
36
39
|
} });
|
|
37
40
|
}
|
|
41
|
+
/** Whether an answer is a stream of lines (`ndjson`) rather than one value. */
|
|
38
42
|
function isAsyncIterable(value) {
|
|
39
43
|
return typeof value === "object" && value !== null && Symbol.asyncIterator in value;
|
|
40
44
|
}
|
|
@@ -64,4 +68,4 @@ function ndjson(lines) {
|
|
|
64
68
|
}
|
|
65
69
|
});
|
|
66
70
|
}
|
|
67
|
-
export { HttpError, errorResponse, json, ndjson };
|
|
71
|
+
export { HttpError, errorResponse, isAsyncIterable, json, ndjson };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { coreEndpoints } from "./endpoints/index.mjs";
|
|
2
2
|
import { DashboardDocumentError } from "./dashboard-documents.mjs";
|
|
3
|
+
import { AccessOptionError } from "./grant.mjs";
|
|
3
4
|
import { CustomSourceOptions, customSource } from "./custom-source.mjs";
|
|
4
5
|
import { HttpError } from "./http.mjs";
|
|
5
6
|
import { PgPool, PgQueryable, nodePostgres } from "./node-postgres.mjs";
|
|
@@ -7,12 +8,29 @@ import { PostgresConnectionOptions, RunSql, postgresConnection } from "./postgre
|
|
|
7
8
|
import { PostgresStoreOptions, RunRows, postgresStore } from "./postgres-store.mjs";
|
|
8
9
|
import { memoryStorage } from "./storage.mjs";
|
|
9
10
|
import { SchemaDiff, SchemaMismatchError, createTables, schemaDiff } from "./store/create-tables.mjs";
|
|
10
|
-
import { Awaitable, Dash, DashOptions, ItemLinksFor, UniqueIds, ViewerFor } from "derive-dashboards/core";
|
|
11
|
+
import { Awaitable, CodeDashboard, Dash, DashOptions, Doc, ItemLinksFor, START_REFUSALS, StartError, StartIssue, StartRefusalCode, UniqueIds, ViewerFor, defineDashboard } from "derive-dashboards/core";
|
|
12
|
+
/** The kinds `widgetKinds` names. */
|
|
13
|
+
type KindsOf<O extends DashOptions> = O["widgetKinds"] extends readonly (infer K extends string)[] ? K : never;
|
|
14
|
+
/**
|
|
15
|
+
* Code dashboards typed by the model: a document written in place, or typed with
|
|
16
|
+
* `defineDashboard`, names only the model's sources and members, the kinds there are and its own
|
|
17
|
+
* widgets in its layout. One
|
|
18
|
+
* typed as the wide `Doc` passes here and is checked when the server starts.
|
|
19
|
+
*/
|
|
20
|
+
type DashboardsFor<O extends DashOptions, L = NonNullable<O["dashboards"]>> = { readonly [I in keyof L]: L[I] extends {
|
|
21
|
+
document: infer D;
|
|
22
|
+
} ? Doc extends D ? L[I] : CodeDashboard<O["model"], KindsOf<O>, keyof D["widgets" & keyof D] & string> : L[I]; };
|
|
23
|
+
/** A connection for each name the model's sources read (`in`): a misspelt `mian` does not compile. */
|
|
24
|
+
type ConnectionsFor<M extends DashOptions["model"]> = { readonly [C in M["sources"][keyof M["sources"]]["in"]]: DashOptions["connections"][C]; };
|
|
25
|
+
/** An option `DashOptions` does not have: a misspelt `secrt` does not compile. */
|
|
26
|
+
type NoOtherOptions<O> = { readonly [K in Exclude<keyof O, keyof DashOptions>]: never; };
|
|
11
27
|
/** What `deriveDashboards` returns: `api` calls every endpoint; `$Infer.Endpoints` types a client. */
|
|
12
28
|
export type DashServer<O extends DashOptions> = Dash<O, ReturnType<typeof coreEndpoints>>;
|
|
13
29
|
/**
|
|
14
30
|
* Embedded dashboards for your product. Pass the model, how to read the viewer, who may see
|
|
15
|
-
* what, and the connections the model reads; mount the returned handler.
|
|
31
|
+
* what, and the connections the model reads; mount the returned handler. An option it does
|
|
32
|
+
* not have, a secret too short to be a key, or a dashboard that does not fit the model is
|
|
33
|
+
* refused, at compile time where the type can say it and when the server starts. Everything it
|
|
16
34
|
* returns is typed from the options: `$Infer.Member` and `$Infer.Query` from the model,
|
|
17
35
|
* `$ERROR_CODES` from the plugins, and `api`: every endpoint, the library's by name and each
|
|
18
36
|
* plugin's under its id, as a server-side call.
|
|
@@ -21,7 +39,10 @@ export declare function deriveDashboards<const O extends DashOptions>(options: O
|
|
|
21
39
|
plugins?: UniqueIds<O["plugins"]>;
|
|
22
40
|
/** Typed from the model: with tenant keys, the viewer must carry a value for each. */
|
|
23
41
|
viewer: (request: Request) => Awaitable<ViewerFor<O["model"]> | null>;
|
|
42
|
+
connections: ConnectionsFor<O["model"]>;
|
|
24
43
|
/** Typed from the model: a template per source, and no source the model lacks. */
|
|
25
44
|
itemLinks?: ItemLinksFor<O["model"], O["itemLinks"]>;
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
/** Typed from the model: each document's sources, members and widget kinds. */
|
|
46
|
+
dashboards?: DashboardsFor<O>;
|
|
47
|
+
} & NoOtherOptions<O>): DashServer<O>;
|
|
48
|
+
export { AccessOptionError, type CustomSourceOptions, DashboardDocumentError, HttpError, type PgPool, type PgQueryable, type PostgresConnectionOptions, type PostgresStoreOptions, type RunRows, type RunSql, START_REFUSALS, type SchemaDiff, SchemaMismatchError, StartError, type StartIssue, type StartRefusalCode, createTables, customSource, defineDashboard, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
|
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,9 @@ import { cursorKey, macKey } from "./cursor-seal.mjs";
|
|
|
3
3
|
import { DashboardDocumentError, checkedDashboards } from "./dashboard-documents.mjs";
|
|
4
4
|
import { warnSecretAtStart } from "./drill-secret.mjs";
|
|
5
5
|
import { coreEndpoints } from "./endpoints/index.mjs";
|
|
6
|
+
import { AccessOptionError } from "./grant.mjs";
|
|
6
7
|
import { createHandler, serverCall } from "./handler.mjs";
|
|
7
|
-
import { HttpError } from "./http.mjs";
|
|
8
|
+
import { HttpError, isAsyncIterable } from "./http.mjs";
|
|
8
9
|
import { isSource } from "./reading.mjs";
|
|
9
10
|
import { customSource } from "./custom-source.mjs";
|
|
10
11
|
import { nodePostgres } from "./node-postgres.mjs";
|
|
@@ -12,18 +13,24 @@ import { postgresConnection } from "./postgres-connection.mjs";
|
|
|
12
13
|
import { postgresStore } from "./postgres-store.mjs";
|
|
13
14
|
import { memoryStorage } from "./storage.mjs";
|
|
14
15
|
import { SchemaMismatchError, createTables, schemaDiff } from "./store/create-tables.mjs";
|
|
15
|
-
import { BASE_ERROR_CODES,
|
|
16
|
-
import { drillModel } from "
|
|
16
|
+
import { BASE_ERROR_CODES, START_REFUSALS, StartError, defineDashboard, linkTemplateIssues, refuseStart, validateModel, widgetKindIssues } from "derive-dashboards/core";
|
|
17
|
+
import { drillModel } from "#core/internal";
|
|
18
|
+
import { dashOptionIssues } from "derive-dashboards/core/schema";
|
|
17
19
|
// src/index.ts
|
|
18
20
|
/**
|
|
19
21
|
* Every connection the model's sources read is given, and each one given as it is (not per
|
|
20
22
|
* request) is a connection, or the server does not start.
|
|
21
23
|
*/
|
|
22
|
-
function
|
|
23
|
-
const missing = [...new Set(Object.values(options.model.sources).map((s) => s.in))].filter((id) => !Object.hasOwn(options.connections, id))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
function connectionIssues(options) {
|
|
25
|
+
const missing = [...new Set(Object.values(options.model.sources).map((s) => s.in))].filter((id) => !Object.hasOwn(options.connections, id)).map((id) => ({
|
|
26
|
+
path: ["connections", id],
|
|
27
|
+
message: `The model reads "${id}", which \`connections\` does not have. Add it as a key of \`connections\`.`
|
|
28
|
+
}));
|
|
29
|
+
const wrong = Object.entries(options.connections).filter(([, c]) => typeof c !== "function" && !isSource(c)).map(([id]) => ({
|
|
30
|
+
path: ["connections", id],
|
|
31
|
+
message: `\`connections.${id}\` is not a connection. Wrap your database client, postgresConnection({ run, transaction }), or your own data layer, customSource({ answer, records }).`
|
|
32
|
+
}));
|
|
33
|
+
return [...missing, ...wrong];
|
|
27
34
|
}
|
|
28
35
|
/**
|
|
29
36
|
* Two plugins with one id would answer each other's paths, and a plugin named like one of the
|
|
@@ -31,62 +38,106 @@ function checkConnections(options) {
|
|
|
31
38
|
*/
|
|
32
39
|
function checkPluginIds(options, taken) {
|
|
33
40
|
const ids = (options.plugins ?? []).map((p) => p.id);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
const issues = ids.flatMap((id, at) => {
|
|
42
|
+
const path = [
|
|
43
|
+
"plugins",
|
|
44
|
+
at,
|
|
45
|
+
"id"
|
|
46
|
+
];
|
|
47
|
+
if (ids.indexOf(id) !== at) return [{
|
|
48
|
+
path,
|
|
49
|
+
message: `Two plugins have the id "${id}"; each plugin has its own.`
|
|
50
|
+
}];
|
|
51
|
+
return taken.includes(id) ? [{
|
|
52
|
+
path,
|
|
53
|
+
message: `A plugin's id "${id}" is a name the library uses under \`api\`.`
|
|
54
|
+
}] : [];
|
|
55
|
+
});
|
|
56
|
+
refuseStart("PLUGIN_ID_INVALID", issues);
|
|
38
57
|
}
|
|
39
|
-
/** Whether an endpoint's answer is a stream of lines (`ndjson`) rather than one value. */
|
|
40
|
-
function isStream(output) {
|
|
41
|
-
return typeof output === "object" && output !== null && typeof Reflect.get(output, Symbol.asyncIterator) === "function";
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Each `itemLinks` template names a source of the model and only parts its items have: `{id}`,
|
|
45
|
-
* or `{key.<column>}` for a column of the source's key. A misspelled source or column would
|
|
46
|
-
* otherwise only show as links that never appear: refuse to start.
|
|
47
|
-
*/
|
|
48
58
|
/**
|
|
49
59
|
* Each `itemLinks` template names a source of the model and is one core's link filler reads:
|
|
50
60
|
* it starts with "/" or a scheme, and names only {id} and {key.<column>} of that source's key. A
|
|
51
61
|
* misspelling would otherwise only show as links that never appear: refuse to start.
|
|
52
62
|
*/
|
|
53
|
-
function
|
|
54
|
-
|
|
63
|
+
function itemLinkIssues(options) {
|
|
64
|
+
return Object.entries(options.itemLinks ?? {}).flatMap(([source, template]) => {
|
|
65
|
+
const path = ["itemLinks", source];
|
|
55
66
|
const def = options.model.sources[source];
|
|
56
|
-
if (def === void 0)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
if (def === void 0) return [{
|
|
68
|
+
path,
|
|
69
|
+
message: `itemLinks names "${source}", which is not a source of the model.`
|
|
70
|
+
}];
|
|
71
|
+
return linkTemplateIssues(template, def.key).map((message) => ({
|
|
72
|
+
path,
|
|
73
|
+
message
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Access first: with no way to answer who may do what, nothing else is worth checking. Its
|
|
79
|
+
* problem is refused as `AccessOptionError`, naming the option; access is never open by default.
|
|
80
|
+
*/
|
|
81
|
+
function refuseAccess(options, issues) {
|
|
82
|
+
const at = issues.find(({ path }) => path[0] === "access");
|
|
83
|
+
if (at === void 0) return;
|
|
84
|
+
const [, part] = at.path;
|
|
85
|
+
if (part === "can" || part === "sensitive") throw new AccessOptionError(`access.${part}`, at.message);
|
|
86
|
+
const none = typeof options.access !== "object" || options.access === null;
|
|
87
|
+
throw new AccessOptionError("access", none ? "deriveDashboards needs `access: { can(viewer, verb, resource) }`: it decides who may do what, and there is no default." : at.message);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The options checked as the server starts: every option against the one options schema (a
|
|
91
|
+
* misspelt key named with the one meant, a value of the wrong type, a secret too short to be a
|
|
92
|
+
* key), the model, the connections, the item links and the code dashboards, each widget of a kind
|
|
93
|
+
* a renderer draws.
|
|
94
|
+
*/
|
|
95
|
+
function checkedOptions(options) {
|
|
96
|
+
const issues = dashOptionIssues(options);
|
|
97
|
+
refuseAccess(options, issues);
|
|
98
|
+
refuseStart("OPTIONS_INVALID", issues);
|
|
99
|
+
refuseStart("MODEL_INVALID", validateModel(options.model).map(({ path, message }) => ({
|
|
100
|
+
path: ["model", ...path],
|
|
101
|
+
message
|
|
102
|
+
})));
|
|
103
|
+
refuseStart("CONNECTIONS_INVALID", connectionIssues(options));
|
|
104
|
+
refuseStart("ITEM_LINK_INVALID", itemLinkIssues(options));
|
|
105
|
+
const model = drillModel(options.model);
|
|
106
|
+
const dashboards = checkedDashboards(options, model);
|
|
107
|
+
refuseStart("WIDGET_KIND_UNKNOWN", widgetKindIssues({
|
|
108
|
+
...options,
|
|
109
|
+
dashboards
|
|
110
|
+
}));
|
|
111
|
+
return {
|
|
112
|
+
dashboards,
|
|
113
|
+
model
|
|
114
|
+
};
|
|
60
115
|
}
|
|
61
116
|
/** One endpoint by path; a streamed answer is read to its end and comes back as its lines. */
|
|
62
117
|
async function callPath(byPath, path, input) {
|
|
63
118
|
const call = byPath.get(path);
|
|
64
119
|
if (call === void 0) throw new HttpError(404, "NOT_FOUND", `There is no endpoint at ${path}. routes lists them.`);
|
|
65
120
|
const output = await call(input);
|
|
66
|
-
if (!
|
|
121
|
+
if (!isAsyncIterable(output)) return output;
|
|
67
122
|
const lines = [];
|
|
68
123
|
for await (const line of output) lines.push(line);
|
|
69
124
|
return lines;
|
|
70
125
|
}
|
|
71
126
|
/**
|
|
72
127
|
* Embedded dashboards for your product. Pass the model, how to read the viewer, who may see
|
|
73
|
-
* what, and the connections the model reads; mount the returned handler.
|
|
128
|
+
* what, and the connections the model reads; mount the returned handler. An option it does
|
|
129
|
+
* not have, a secret too short to be a key, or a dashboard that does not fit the model is
|
|
130
|
+
* refused, at compile time where the type can say it and when the server starts. Everything it
|
|
74
131
|
* returns is typed from the options: `$Infer.Member` and `$Infer.Query` from the model,
|
|
75
132
|
* `$ERROR_CODES` from the plugins, and `api`: every endpoint, the library's by name and each
|
|
76
133
|
* plugin's under its id, as a server-side call.
|
|
77
134
|
*/
|
|
78
135
|
function deriveDashboards(options) {
|
|
79
|
-
|
|
80
|
-
checkConnections(options);
|
|
81
|
-
checkItemLinks(options);
|
|
82
|
-
const model = drillModel(options.model);
|
|
83
|
-
const checked = {
|
|
84
|
-
...options,
|
|
85
|
-
dashboards: checkedDashboards(options, model)
|
|
86
|
-
};
|
|
136
|
+
const { dashboards, model } = checkedOptions(options);
|
|
87
137
|
const rt = {
|
|
88
|
-
options
|
|
89
|
-
|
|
138
|
+
options,
|
|
139
|
+
dashboards,
|
|
140
|
+
cache: createCache(options),
|
|
90
141
|
cursorKey: cursorKey(options.secret),
|
|
91
142
|
macKey: macKey(options.secret),
|
|
92
143
|
drillModel: model,
|
|
@@ -123,4 +174,4 @@ function deriveDashboards(options) {
|
|
|
123
174
|
options
|
|
124
175
|
};
|
|
125
176
|
}
|
|
126
|
-
export { DashboardDocumentError, HttpError, SchemaMismatchError, createTables, customSource, deriveDashboards, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
|
|
177
|
+
export { AccessOptionError, DashboardDocumentError, HttpError, START_REFUSALS, SchemaMismatchError, StartError, createTables, customSource, defineDashboard, deriveDashboards, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
|
package/dist/llms.txt
CHANGED
|
@@ -6,10 +6,10 @@ Install skill for coding agents: `npx skills add derive-to/dashboards --skill de
|
|
|
6
6
|
|
|
7
7
|
## Docs
|
|
8
8
|
|
|
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.
|
|
9
|
+
- [Quick start](https://github.com/derive-to/dashboards/blob/main/docs/quick-start.md): install, describe your data, mount the handler (a fetch handler; on Express or `node:http` use `nodeHandler` from `derive-dashboards/node`), 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
|
-
- [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 (`tiles="sheet"` or `"cards"`), editing UI, URL state, drill parts, widget builder; the tiles and their `display` options (a number's `value`, `secondary` and `full`, with `formatHeadline` for a tile of your own, 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, heatmap, 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.
|
|
11
|
+
- [Filters](https://github.com/derive-to/dashboards/blob/main/docs/filters.md): the built-in filter bar, a filter that names the same field on several sources (`also`), theming, options (`pinned`, `shortcuts`, `futureDays` for a calendar that picks days to come), words, the shadcn copy, custom bars (`FilterBarProps.span` is the dates the dashboard shows; a bar that says them calls `useSaysDates()`).
|
|
12
|
+
- [React](https://github.com/derive-to/dashboards/blob/main/docs/react.md): provider, Dashboard (`tiles="sheet"` or `"cards"`), editing UI, URL state, drill parts, widget builder; the tiles and their `display` options (a number's `value`, `secondary` and `full`, with `formatHeadline` for a tile of your own, a table's `bars`, `heat`, `compact`, `full` and `comparisons` for grouped drill-down (a table too wide for its tile tightens, then becomes cards, and says which in `data-layout`), 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, heatmap, 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.compareGroups` on a row in a custom renderer. Catch `DashboardDocumentError` for invalid code dashboards. Translate drill labels with `messages.drillMetricTotal`, `drillCompareGroup`, `drillGroupedBy`, `drillRecordPages` and `drillTrendWindow`. A renderer of your own: spread `fitted(props.fit)` on its root to be as tall as what it draws (`<Chart fit>` for a chart of rows; `--dd-fit-most` caps it), and pass its props to `formatCell(cell, column, props)` so times are written in the dashboard's zone (`props.timeZone`). What a failed load says: `messages.dashboardSignedOut`, `dashboardSetup`, `serverUnreachable`; a dashboard already shown when the session ends says `dashboardSignedOutShown`, and each tile `tileNotUpdated` (`tileNotUpdatedYet` where its request failed and is asked again). Send a signed-out viewer to sign in with `createDashboardsClient({ onSignedOut })`. A number tile's line against the period before is `messages.changeSeen`, `changeSaid` and `changeNone` (whole sentences), with `changeUp`, `changeDown`, `changeBetter`, `changeWorse`, `changePoints` and `changeUnder` inside them, and is green or red only where the model's measure (or the query's calc) says `better: "higher"` or `"lower"`; a lifetime tile says `messages.tileAllTime`. While editing, tabs are added, renamed, moved and removed in the page and the widget builder's Options set a tile's `display`; their words are `messages.addTab`, `newTab`, `tabName`, `tabNameEmpty`, `tabNameTaken`, `tabOptions`, `renameTab`, `moveTabLeft`, `moveTabRight`, `removeTab`, `removeTabAsk`, `removeTabYes`, `lastTab`, `optionNames` and `optionHelp` (by option name; give only the ones you translate), `optionAutomatic`, `optionNone`, `nothingToSet` and `optionsCleared`. An editor of your own reads a kind's options from `displayOptionsOf(kind)` in `derive-dashboards/core`.
|
|
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/mcp/api.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ok } from "./format.mjs";
|
|
2
|
+
import { strict } from "derive-dashboards/core/schema";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
// src/mcp/api.ts
|
|
4
5
|
/** The longest answer handed back as text; the whole answer is always in the structured content. */
|
|
@@ -7,7 +8,7 @@ const MOST_TEXT = 2e4;
|
|
|
7
8
|
function apiInput(routes) {
|
|
8
9
|
const [first, ...rest] = routes.map((r) => r.path);
|
|
9
10
|
if (first === void 0) throw new Error("The dashboards server has no endpoints.");
|
|
10
|
-
return
|
|
11
|
+
return strict({
|
|
11
12
|
path: z.enum([first, ...rest]).describe("The endpoint to call."),
|
|
12
13
|
body: z.record(z.string(), z.unknown()).optional().describe("The endpoint's body (none for a GET). GET /meta/schemas lists every body's JSON Schema.")
|
|
13
14
|
});
|
package/dist/mcp/query.mjs
CHANGED
|
@@ -2,15 +2,10 @@ import { HttpError } from "../http.mjs";
|
|
|
2
2
|
import { drillRows } from "./drill.mjs";
|
|
3
3
|
import { answerText, ok, table } from "./format.mjs";
|
|
4
4
|
import { dashboardOf, resolveQuery, sourceOf } from "./resolve.mjs";
|
|
5
|
-
import { drillStateSchema, picksSchema,
|
|
5
|
+
import { agentQuerySchema, drillStateSchema, picksSchema, strict } from "derive-dashboards/core/schema";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
// src/mcp/query.ts
|
|
8
|
-
|
|
9
|
-
const question = wireQueryShape.extend({ kind: z.literal("aggregate").optional() }).transform((query) => positional({
|
|
10
|
-
...query,
|
|
11
|
-
kind: "aggregate"
|
|
12
|
-
}));
|
|
13
|
-
const queryInput = z.strictObject({
|
|
8
|
+
const queryInput = strict({
|
|
14
9
|
op: z.enum([
|
|
15
10
|
"describe",
|
|
16
11
|
"ask",
|
|
@@ -18,7 +13,7 @@ const queryInput = z.strictObject({
|
|
|
18
13
|
"list",
|
|
19
14
|
"open"
|
|
20
15
|
]).describe("describe: what can be asked (sources, measures, fields). ask: answer a question. rows: the records behind a question, or behind a mark (drill). list: the dashboards. open: one dashboard, every tile answered."),
|
|
21
|
-
query:
|
|
16
|
+
query: agentQuerySchema.optional().describe("For ask and rows. Sources, measures and fields may be named by id or label. An entry's id is optional: any ids given are renumbered by position (m1, d1, c1...), and references to them in order, rankBy and formulas follow."),
|
|
22
17
|
source: z.string().optional().describe("For describe: one source only."),
|
|
23
18
|
dashboard: z.string().optional().describe("For open: the dashboard's title or id."),
|
|
24
19
|
filters: picksSchema.optional().describe("For open: values for the dashboard's filters, by control id."),
|