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/mcp/resolve.mjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { HttpError } from "../http.mjs";
|
|
2
|
+
import { parseMemberId } from "derive-dashboards/core";
|
|
2
3
|
// src/mcp/resolve.ts
|
|
3
4
|
const fold = (text) => text.trim().toLowerCase();
|
|
5
|
+
/** A member id without its source: `name`, or `join.name`. */
|
|
6
|
+
function afterSource(id) {
|
|
7
|
+
const ref = parseMemberId(id);
|
|
8
|
+
if (ref === void 0) return void 0;
|
|
9
|
+
return ref.join === void 0 ? ref.name : `${ref.join}.${ref.name}`;
|
|
10
|
+
}
|
|
4
11
|
/** The one entry `name` names, by id, by the part after the source, or by label. */
|
|
5
12
|
function pick(entries, name) {
|
|
6
13
|
const wanted = fold(name);
|
|
7
|
-
return entries.find((e) => e.id === name) ?? entries.find((e) => fold(e.id
|
|
14
|
+
return entries.find((e) => e.id === name) ?? entries.find((e) => fold(afterSource(e.id) ?? "") === wanted) ?? entries.find((e) => fold(e.label) === wanted);
|
|
8
15
|
}
|
|
9
16
|
const unknown = (what, name, choices) => new HttpError(400, "QUERY_INVALID", `There is no ${what} "${name}". Use one of: ${choices.slice(0, 40).map((c) => `${c.label} (${c.id})`).join(", ")}.`);
|
|
10
17
|
/** The source a question reads, by name or label. */
|
|
@@ -21,7 +28,7 @@ function sourceOf(meta, name) {
|
|
|
21
28
|
}
|
|
22
29
|
/** A field's id: one of the source's own, by any of its names, or a joined one already by id. */
|
|
23
30
|
function memberId(source, name) {
|
|
24
|
-
if (name
|
|
31
|
+
if (parseMemberId(name)?.join !== void 0) return name;
|
|
25
32
|
const found = pick(source.dimensions, name);
|
|
26
33
|
if (found === void 0) throw unknown("field", name, source.dimensions);
|
|
27
34
|
return found.id;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { NodeRequest, nodeRequest } from "./request.mjs";
|
|
2
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
/** Anything with a fetch handler: what `deriveDashboards` returns. */
|
|
4
|
+
export type FetchHandler = {
|
|
5
|
+
handler: (request: Request) => Promise<Response>;
|
|
6
|
+
};
|
|
7
|
+
export type NodeHandlerOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Build the request's URL from `x-forwarded-proto` and `x-forwarded-host`. Set it only behind a
|
|
10
|
+
* proxy you run that sets both: any client can send them, and the handler compares the URL's
|
|
11
|
+
* origin with the browser's to refuse requests from other sites. Default `false`.
|
|
12
|
+
*/
|
|
13
|
+
trustProxy?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Where an error goes when there is no `next` to hand it to, or when part of the answer has
|
|
16
|
+
* already been sent. Default `console.error`.
|
|
17
|
+
*/
|
|
18
|
+
onError?: (error: unknown) => void;
|
|
19
|
+
};
|
|
20
|
+
/** Express's `next`: hands an error to the app's error handlers. */
|
|
21
|
+
export type NodeNext = (error?: unknown) => void;
|
|
22
|
+
/** The Node handler: Express middleware, or a `node:http` request listener. */
|
|
23
|
+
export type NodeHandler = (req: IncomingMessage, res: ServerResponse, next?: NodeNext) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Mounts the dashboards' fetch handler on Express or `node:http`: it builds a `Request` from the
|
|
26
|
+
* Node request (its full URL, every header, the body whether still a stream or already parsed
|
|
27
|
+
* onto `req.body`) and streams the `Response` back, a chunk at a time and waiting when the socket
|
|
28
|
+
* is full. When the client goes away the request's signal aborts, which stops the queries it
|
|
29
|
+
* started.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* app.use("/api/dashboards", nodeHandler(dashboards));
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function nodeHandler(dashboards: FetchHandler | FetchHandler["handler"], options?: NodeHandlerOptions): NodeHandler;
|
|
36
|
+
export { type NodeRequest, nodeRequest };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { nodeRequest, toRequest } from "./request.mjs";
|
|
2
|
+
import { writeResponse } from "./response.mjs";
|
|
3
|
+
// src/node/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Takes back what the handler's answer wrote on a response nothing of which has been sent: a
|
|
6
|
+
* header it added goes, and one it wrote over is the app's own again. The app's own headers
|
|
7
|
+
* (its request id, its CORS header) stay, so its error page still reaches the page that asked.
|
|
8
|
+
*/
|
|
9
|
+
function takeBack(res, before) {
|
|
10
|
+
for (const name of res.getHeaderNames()) {
|
|
11
|
+
const was = before[name];
|
|
12
|
+
if (was === void 0) res.removeHeader(name);
|
|
13
|
+
else res.setHeader(name, was);
|
|
14
|
+
}
|
|
15
|
+
res.statusMessage = "";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An error the answer could not get past. Before any byte is sent it goes to `next`, or without
|
|
19
|
+
* one is answered 500; once the answer has started, the connection is closed so the client sees
|
|
20
|
+
* it cut short, never a whole-looking answer. What goes out before any byte is not the handler's
|
|
21
|
+
* answer, so it carries none of the headers that answer had set (its `dd-contract`, its
|
|
22
|
+
* caching): a client reads those as the handler speaking.
|
|
23
|
+
*/
|
|
24
|
+
function failed(error, res, at) {
|
|
25
|
+
if (res.headersSent) {
|
|
26
|
+
at.report(error);
|
|
27
|
+
res.destroy();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
takeBack(res, at.before);
|
|
31
|
+
if (at.next !== void 0) {
|
|
32
|
+
at.next(error);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
at.report(error);
|
|
36
|
+
res.statusCode = 500;
|
|
37
|
+
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
38
|
+
res.end("Internal Server Error");
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The fetch handler to mount: what `deriveDashboards` returned, or its `handler` (what every
|
|
42
|
+
* other mount is handed, so the easy slip). Anything else is refused here, as the mount is
|
|
43
|
+
* made: taken, it failed every request with a bare 500 and a TypeError in the log.
|
|
44
|
+
*/
|
|
45
|
+
function handlerOf(dashboards) {
|
|
46
|
+
if (isHandler(dashboards)) return dashboards;
|
|
47
|
+
const own = typeof dashboards === "object" && dashboards !== null && "handler" in dashboards ? dashboards.handler : void 0;
|
|
48
|
+
if (isHandler(own)) return (request) => own.call(dashboards, request);
|
|
49
|
+
throw new TypeError("nodeHandler takes what deriveDashboards returned, or its handler: nodeHandler(dashboards).");
|
|
50
|
+
}
|
|
51
|
+
/** Whether a value can be called as a fetch handler: any function, since no more of one can be told. */
|
|
52
|
+
const isHandler = (value) => typeof value === "function";
|
|
53
|
+
/**
|
|
54
|
+
* Mounts the dashboards' fetch handler on Express or `node:http`: it builds a `Request` from the
|
|
55
|
+
* Node request (its full URL, every header, the body whether still a stream or already parsed
|
|
56
|
+
* onto `req.body`) and streams the `Response` back, a chunk at a time and waiting when the socket
|
|
57
|
+
* is full. When the client goes away the request's signal aborts, which stops the queries it
|
|
58
|
+
* started.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* app.use("/api/dashboards", nodeHandler(dashboards));
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function nodeHandler(dashboards, options = {}) {
|
|
65
|
+
const handler = handlerOf(dashboards);
|
|
66
|
+
const trustProxy = options.trustProxy === true;
|
|
67
|
+
const report = options.onError ?? console.error;
|
|
68
|
+
return async (req, res, next) => {
|
|
69
|
+
const controller = new AbortController();
|
|
70
|
+
res.once("close", () => {
|
|
71
|
+
if (!res.writableFinished) controller.abort();
|
|
72
|
+
});
|
|
73
|
+
const before = { ...res.getHeaders() };
|
|
74
|
+
try {
|
|
75
|
+
const request = toRequest(req, {
|
|
76
|
+
trustProxy,
|
|
77
|
+
signal: controller.signal
|
|
78
|
+
});
|
|
79
|
+
await writeResponse(await handler(request), res, report);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
failed(error, res, {
|
|
82
|
+
next,
|
|
83
|
+
report,
|
|
84
|
+
before
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export { nodeHandler, nodeRequest };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IncomingMessage } from "node:http";
|
|
2
|
+
/** A Node request, with what Express adds to one when it is Express's. */
|
|
3
|
+
export type NodeRequest = IncomingMessage & {
|
|
4
|
+
originalUrl?: string;
|
|
5
|
+
body?: unknown;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The Node request a fetch `Request` was built from; none for a `Request` this handler did not
|
|
9
|
+
* build. An app that signs its users in with middleware (`req.user`, `req.session`) reads them
|
|
10
|
+
* here in its `viewer(request)`, instead of checking the session a second time from the cookie.
|
|
11
|
+
*/
|
|
12
|
+
export declare const nodeRequest: (request: Request) => NodeRequest | undefined;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// src/node/request.ts
|
|
2
|
+
/** The Node request each fetch `Request` was built from, for as long as the `Request` lives. */
|
|
3
|
+
const BUILT_FROM = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
/**
|
|
5
|
+
* The Node request a fetch `Request` was built from; none for a `Request` this handler did not
|
|
6
|
+
* build. An app that signs its users in with middleware (`req.user`, `req.session`) reads them
|
|
7
|
+
* here in its `viewer(request)`, instead of checking the session a second time from the cookie.
|
|
8
|
+
*/
|
|
9
|
+
const nodeRequest = (request) => BUILT_FROM.get(request);
|
|
10
|
+
/** Methods whose requests carry no body. */
|
|
11
|
+
const BODILESS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
12
|
+
/**
|
|
13
|
+
* The first value of a forwarded header: a proxy chain lists one value per hop, nearest the
|
|
14
|
+
* client first.
|
|
15
|
+
*/
|
|
16
|
+
function firstForwarded(value) {
|
|
17
|
+
const first = (Array.isArray(value) ? value[0] : value)?.split(",")[0]?.trim();
|
|
18
|
+
return first === "" ? void 0 : first;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The scheme and host the client asked for. The socket says whether the connection is
|
|
22
|
+
* encrypted and the Host header names the host; `x-forwarded-proto` and `x-forwarded-host` are
|
|
23
|
+
* read only when the host says a proxy it runs sets them, since any client can send them and the
|
|
24
|
+
* handler compares the URL's origin with the browser's to refuse other sites.
|
|
25
|
+
*/
|
|
26
|
+
function originOf(req, trustProxy) {
|
|
27
|
+
const encrypted = "encrypted" in req.socket && req.socket.encrypted === true;
|
|
28
|
+
const proto = trustProxy ? firstForwarded(req.headers["x-forwarded-proto"]) : void 0;
|
|
29
|
+
const scheme = proto === "http" || proto === "https" ? proto : encrypted ? "https" : "http";
|
|
30
|
+
const host = (trustProxy ? firstForwarded(req.headers["x-forwarded-host"]) : void 0) ?? req.headers.host ?? firstForwarded(req.headers[":authority"]);
|
|
31
|
+
if (host === void 0) throw new Error("The request has no Host header, so its URL cannot be known.");
|
|
32
|
+
return `${scheme}://${host}`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Every header as the client sent it, a repeated one appended once per time it was sent. HTTP/2's
|
|
36
|
+
* pseudo-headers (`:path`, `:authority`) are not headers a `Request` can hold.
|
|
37
|
+
*/
|
|
38
|
+
function headersOf(raw) {
|
|
39
|
+
const headers = new Headers();
|
|
40
|
+
for (let at = 0; at + 1 < raw.length; at += 2) {
|
|
41
|
+
const name = raw[at];
|
|
42
|
+
const value = raw[at + 1];
|
|
43
|
+
if (name !== void 0 && value !== void 0 && !name.startsWith(":")) headers.append(name, value);
|
|
44
|
+
}
|
|
45
|
+
return headers;
|
|
46
|
+
}
|
|
47
|
+
/** One chunk of a Node stream as bytes: a Buffer is already bytes, a string is UTF-8 text. */
|
|
48
|
+
function bytesOf(chunk) {
|
|
49
|
+
if (chunk instanceof Uint8Array) return chunk;
|
|
50
|
+
if (typeof chunk === "string") return new TextEncoder().encode(chunk);
|
|
51
|
+
throw new TypeError("The request stream gave a chunk that is neither bytes nor text.");
|
|
52
|
+
}
|
|
53
|
+
/** The request body as a web stream, read from the socket only as the handler reads it. */
|
|
54
|
+
function streamOf(req) {
|
|
55
|
+
const chunks = req[Symbol.asyncIterator]();
|
|
56
|
+
return new ReadableStream({
|
|
57
|
+
async pull(controller) {
|
|
58
|
+
const next = await chunks.next();
|
|
59
|
+
if (next.done === true) controller.close();
|
|
60
|
+
else controller.enqueue(bytesOf(next.value));
|
|
61
|
+
},
|
|
62
|
+
async cancel() {
|
|
63
|
+
await chunks.return?.();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Whether a request said its body is JSON (`application/json`, or a `+json` type). */
|
|
68
|
+
const saidJson = (headers) => /^application\/(?:[\w.-]+\+)?json\b/iu.test(headers.get("content-type") ?? "");
|
|
69
|
+
/**
|
|
70
|
+
* The body to hand on. Unread, it is the stream itself. Read by a body parser (Express's
|
|
71
|
+
* `express.json()` reads the stream to its end and leaves the value on `req.body`), it is that
|
|
72
|
+
* value: bytes and text as they are, and a parsed value written out as JSON again when the
|
|
73
|
+
* request said it sent JSON. A form a parser read (`express.urlencoded()`) is no JSON body:
|
|
74
|
+
* the handler is handed an empty one, and refuses it as it refuses the form itself where
|
|
75
|
+
* nothing parsed it. The parsed body is a new body, so the old length no longer describes it.
|
|
76
|
+
*/
|
|
77
|
+
function bodyOf(req, headers) {
|
|
78
|
+
if (BODILESS.has(req.method ?? "GET")) return void 0;
|
|
79
|
+
if (!req.readableEnded) return streamOf(req);
|
|
80
|
+
if (req.body === void 0) return void 0;
|
|
81
|
+
headers.delete("content-length");
|
|
82
|
+
if (typeof req.body === "string" || req.body instanceof Uint8Array) return req.body;
|
|
83
|
+
return saidJson(headers) ? JSON.stringify(req.body) : "";
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A request's target as a path and query. It is sent so (`/path?query`) by every browser; a
|
|
87
|
+
* client or a forward proxy may send it in absolute form (`GET http://host/path`), which a
|
|
88
|
+
* server must accept (RFC 9112 3.2.2), and of which only the path and query are kept: the
|
|
89
|
+
* origin is the Host header's, never one the request line names.
|
|
90
|
+
*/
|
|
91
|
+
function targetOf(req) {
|
|
92
|
+
const target = req.originalUrl ?? req.url ?? "/";
|
|
93
|
+
if (target.startsWith("/") || !URL.canParse(target)) return target;
|
|
94
|
+
const { pathname, search } = new URL(target);
|
|
95
|
+
return `${pathname}${search}`;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The fetch `Request` for a Node request: its method, its full URL, every header, its body and
|
|
99
|
+
* a signal that aborts when the client goes away. The URL is the origin followed by the path as
|
|
100
|
+
* sent, never the path resolved against the origin, so a path starting `//other.host` cannot
|
|
101
|
+
* name another host.
|
|
102
|
+
*/
|
|
103
|
+
function toRequest(req, how) {
|
|
104
|
+
const headers = headersOf(req.rawHeaders);
|
|
105
|
+
const body = bodyOf(req, headers);
|
|
106
|
+
const url = `${originOf(req, how.trustProxy)}${targetOf(req)}`;
|
|
107
|
+
const request = new Request(url, {
|
|
108
|
+
method: req.method ?? "GET",
|
|
109
|
+
headers,
|
|
110
|
+
signal: how.signal,
|
|
111
|
+
...body === void 0 ? {} : {
|
|
112
|
+
body,
|
|
113
|
+
duplex: "half"
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
BUILT_FROM.set(request, req);
|
|
117
|
+
return request;
|
|
118
|
+
}
|
|
119
|
+
export { nodeRequest, toRequest };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/node/response.ts
|
|
2
|
+
/** Resolves when the socket can take more, or has closed and never will. */
|
|
3
|
+
function drained(res) {
|
|
4
|
+
return new Promise((done) => {
|
|
5
|
+
const finish = () => {
|
|
6
|
+
res.off("drain", finish);
|
|
7
|
+
res.off("close", finish);
|
|
8
|
+
done();
|
|
9
|
+
};
|
|
10
|
+
res.on("drain", finish);
|
|
11
|
+
res.on("close", finish);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/** The status and every header; each `set-cookie` stays a header of its own. */
|
|
15
|
+
function writeHead(response, res) {
|
|
16
|
+
res.statusCode = response.status;
|
|
17
|
+
if (response.statusText !== "") res.statusMessage = response.statusText;
|
|
18
|
+
for (const [name, value] of response.headers) if (name !== "set-cookie") res.setHeader(name, value);
|
|
19
|
+
const cookies = response.headers.getSetCookie();
|
|
20
|
+
if (cookies.length > 0) res.setHeader("set-cookie", cookies);
|
|
21
|
+
}
|
|
22
|
+
/** Writes each chunk as it comes, waiting whenever the socket is full, until the stream ends. */
|
|
23
|
+
async function writeAll(reader, res) {
|
|
24
|
+
for (;;) {
|
|
25
|
+
const next = await reader.read();
|
|
26
|
+
if (next.done) return;
|
|
27
|
+
if (!res.write(next.value) && !res.destroyed) await drained(res);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Writes the body chunk by chunk as the handler makes it (the tiles endpoint sends a line as
|
|
32
|
+
* each tile is ready), never holding more than the socket will take. When the client goes away
|
|
33
|
+
* the stream is cancelled, so the handler stops the work nobody will read.
|
|
34
|
+
*/
|
|
35
|
+
async function pipe(body, res, report) {
|
|
36
|
+
const reader = body.getReader();
|
|
37
|
+
const stop = () => {
|
|
38
|
+
reader.cancel().catch(report);
|
|
39
|
+
};
|
|
40
|
+
res.once("close", stop);
|
|
41
|
+
try {
|
|
42
|
+
await writeAll(reader, res);
|
|
43
|
+
if (!res.destroyed) res.end();
|
|
44
|
+
} finally {
|
|
45
|
+
res.off("close", stop);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Writes a fetch `Response` to a Node response, streaming its body. */
|
|
49
|
+
async function writeResponse(response, res, report) {
|
|
50
|
+
if (res.destroyed) {
|
|
51
|
+
await response.body?.cancel();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
writeHead(response, res);
|
|
55
|
+
if (response.body === null) res.end();
|
|
56
|
+
else await pipe(response.body, res, report);
|
|
57
|
+
}
|
|
58
|
+
export { writeResponse };
|
package/dist/principal.mjs
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { HttpError } from "./http.mjs";
|
|
2
|
+
import { missingTenantKey, tenantValues } from "derive-dashboards/core";
|
|
3
|
+
import { viewerSchema } from "derive-dashboards/core/schema";
|
|
2
4
|
// src/principal.ts
|
|
5
|
+
const invalid = (message) => new HttpError(500, "VIEWER_INVALID", message);
|
|
6
|
+
/** What `viewer()` returned, checked: a viewer, or null for nobody; any other shape is refused by the field. */
|
|
7
|
+
function checked(value) {
|
|
8
|
+
if (value === null) return null;
|
|
9
|
+
if (typeof value !== "object") throw invalid(`viewer() returned ${value === void 0 ? "undefined" : `a ${typeof value}`}: return the viewer, { id, tenant }, or null when no one is signed in.`);
|
|
10
|
+
const parsed = viewerSchema.safeParse(value);
|
|
11
|
+
if (parsed.success) return parsed.data;
|
|
12
|
+
const problems = parsed.error.issues.map((issue) => issue.path.length === 0 ? issue.message : `${issue.path.join(".")}: ${issue.message}`);
|
|
13
|
+
throw invalid(`viewer() returned a viewer the server cannot read. ${problems.join(" ")}`);
|
|
14
|
+
}
|
|
3
15
|
/**
|
|
4
16
|
* The signed-in viewer, its tenant narrowed to the model's keys: what the store and the cache
|
|
5
17
|
* scope by is exactly what queries are scoped by, and `{}` in an app of one tenant.
|
|
6
18
|
*/
|
|
7
19
|
async function principalOf(options, request, given) {
|
|
8
|
-
const viewer = given ?? await options.viewer(request);
|
|
20
|
+
const viewer = checked(given ?? await options.viewer(request));
|
|
9
21
|
if (viewer === null) return null;
|
|
10
|
-
const
|
|
11
|
-
const tenant = Object.fromEntries((options.model.tenant?.keys ?? []).flatMap((k) => {
|
|
12
|
-
const value = values[k] ?? "";
|
|
13
|
-
return value === "" ? [] : [[k, value]];
|
|
14
|
-
}));
|
|
22
|
+
const tenant = tenantValues(options.model, viewer.tenant ?? {});
|
|
15
23
|
return {
|
|
16
24
|
channel: "user",
|
|
17
25
|
viewer: {
|
|
@@ -22,7 +30,7 @@ async function principalOf(options, request, given) {
|
|
|
22
30
|
}
|
|
23
31
|
/** With tenant keys, a viewer without a value for each reads and writes nothing, stored or not. */
|
|
24
32
|
function checkTenant(options, principal) {
|
|
25
|
-
const missing = (options.model
|
|
33
|
+
const missing = missingTenantKey(options.model, principal.viewer.tenant ?? {});
|
|
26
34
|
if (missing !== void 0) throw new HttpError(403, "TENANT_MISSING", `The viewer has no value for the tenant key "${missing}": viewer() must return it in the viewer's tenant.`);
|
|
27
35
|
}
|
|
28
36
|
export { checkTenant, principalOf };
|
package/dist/react/Canvas.mjs
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { datesKey, datesShown, useDatesKept } from "./dates-shown.mjs";
|
|
2
3
|
import { Grid } from "./Grid.mjs";
|
|
3
4
|
import { Header } from "./Header.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { SaysDatesContext, useDatesSaid, useSaid } from "./says-dates.mjs";
|
|
6
|
+
import { TabStrip } from "./TabStrip.mjs";
|
|
5
7
|
import { linkTo } from "./view.mjs";
|
|
6
|
-
import {
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
// src/Canvas.tsx
|
|
8
|
-
function Tabs({ doc, current, onSelect }) {
|
|
9
|
-
if (doc.tabs.length < 2) return null;
|
|
10
|
-
return /* @__PURE__ */ jsx("div", {
|
|
11
|
-
className: "dd-tabs",
|
|
12
|
-
role: "tablist",
|
|
13
|
-
children: doc.tabs.map((t) => /* @__PURE__ */ jsx("button", {
|
|
14
|
-
type: "button",
|
|
15
|
-
role: "tab",
|
|
16
|
-
"aria-selected": t.id === current.id,
|
|
17
|
-
onClick: () => {
|
|
18
|
-
onSelect(t.id);
|
|
19
|
-
},
|
|
20
|
-
children: t.title
|
|
21
|
-
}, t.id))
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
10
|
/** The filters a link carried that this dashboard does not have, named once. */
|
|
25
11
|
function Dropped({ names }) {
|
|
26
12
|
const { messages } = useDashboards();
|
|
@@ -49,23 +35,45 @@ function EmptyTab({ onAdd }) {
|
|
|
49
35
|
function answeredZone(results) {
|
|
50
36
|
for (const result of results.values()) if (!("error" in result)) return result.receipt.calendar.timezone;
|
|
51
37
|
}
|
|
52
|
-
/**
|
|
53
|
-
|
|
38
|
+
/** Whether the dashboard has a control that picks its dates. */
|
|
39
|
+
const pickedDates = (doc) => doc.controls.some((control) => control.kind === "date_range");
|
|
40
|
+
/**
|
|
41
|
+
* The dates the dashboard says it is showing: those most of its tiles cover, of the answers to
|
|
42
|
+
* the picks as they are now. Null while they are not known yet; kept through a filter's pick,
|
|
43
|
+
* which changes no dates. One value, for the date control and for the line under the tabs.
|
|
44
|
+
*/
|
|
45
|
+
function useDatesText(board, tab) {
|
|
46
|
+
const format = useDashboards();
|
|
47
|
+
return useDatesKept(datesShown(board.tiles, format), datesKey(tab.id, board.view.picks));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The host's filter bar (the built-in one by default), told the zone dates are read in and
|
|
51
|
+
* the dates most tiles cover, which its date control says.
|
|
52
|
+
*/
|
|
53
|
+
function Filters(props) {
|
|
54
|
+
const { board, doc } = props;
|
|
54
55
|
const Bar = useDashboards().components.FilterBar;
|
|
55
56
|
return /* @__PURE__ */ jsx(Bar, {
|
|
57
|
+
...props.options,
|
|
56
58
|
controls: doc.controls,
|
|
57
59
|
picks: board.view.picks,
|
|
58
60
|
onChange: board.view.setPicks,
|
|
59
|
-
timezone: doc.scope.timezone ?? answeredZone(board.tiles.results)
|
|
61
|
+
timezone: doc.scope.timezone ?? answeredZone(board.tiles.results),
|
|
62
|
+
span: props.span
|
|
60
63
|
});
|
|
61
64
|
}
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The dates most tiles cover, said once over the grid, unless the date control says them; the
|
|
67
|
+
* tiles that cover them leave them out. The same dates the control would say, known as it
|
|
68
|
+
* knows them: nothing while the tiles that could say are still waiting.
|
|
69
|
+
*/
|
|
70
|
+
function DashboardSpan(props) {
|
|
71
|
+
return useSaid(props.dates) && pickedDates(props.doc) || typeof props.span !== "string" ? null : /* @__PURE__ */ jsx("div", {
|
|
67
72
|
className: "dd-span-all",
|
|
68
|
-
children: /* @__PURE__ */ jsx(
|
|
73
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
74
|
+
className: "dd-tile-span",
|
|
75
|
+
children: props.span
|
|
76
|
+
})
|
|
69
77
|
});
|
|
70
78
|
}
|
|
71
79
|
/** The canvas: the header with the filters in it, the tabs, and the grid with its marks. */
|
|
@@ -75,46 +83,59 @@ function Canvas(props) {
|
|
|
75
83
|
const add = () => {
|
|
76
84
|
props.onBuild({});
|
|
77
85
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
const dates = useDatesSaid();
|
|
87
|
+
const span = useDatesText(board, shown.tab);
|
|
88
|
+
return /* @__PURE__ */ jsxs(SaysDatesContext.Provider, {
|
|
89
|
+
value: dates.claim,
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ jsx(Header, {
|
|
92
|
+
doc: shown.doc,
|
|
93
|
+
version: board.version,
|
|
94
|
+
unpublished: board.unpublished,
|
|
95
|
+
canEdit: board.canEdit && panels.previewing === void 0,
|
|
96
|
+
waiting: board.waiting,
|
|
97
|
+
edit,
|
|
98
|
+
historyOpen: panels.panel === "history",
|
|
99
|
+
onAdd: add,
|
|
100
|
+
onHistory: panels.toggleHistory,
|
|
101
|
+
link: () => linkTo(view.current, props.dashboard.linkFor),
|
|
102
|
+
filters: /* @__PURE__ */ jsx(Filters, {
|
|
103
|
+
board,
|
|
104
|
+
doc: shown.doc,
|
|
105
|
+
span,
|
|
106
|
+
options: props.dashboard.filterBar
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
/* @__PURE__ */ jsx(Dropped, { names: view.dropped }),
|
|
110
|
+
/* @__PURE__ */ jsx(TabStrip, {
|
|
111
|
+
doc: shown.doc,
|
|
112
|
+
current: shown.tab,
|
|
113
|
+
onSelect: view.setTab,
|
|
114
|
+
edit,
|
|
115
|
+
readOnly: panels.previewing !== void 0
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx(DashboardSpan, {
|
|
118
|
+
doc: shown.doc,
|
|
119
|
+
dates,
|
|
120
|
+
span
|
|
121
|
+
}),
|
|
122
|
+
edit.draft === void 0 || !emptyTab(shown) ? null : /* @__PURE__ */ jsx(EmptyTab, { onAdd: add }),
|
|
123
|
+
/* @__PURE__ */ jsx(Grid, {
|
|
124
|
+
doc: shown.doc,
|
|
125
|
+
tab: shown.tab,
|
|
126
|
+
edit,
|
|
127
|
+
results: board.tiles.results,
|
|
128
|
+
pending: board.tiles.pending,
|
|
129
|
+
marks: shown.marks,
|
|
130
|
+
ghosts: shown.ghosts,
|
|
131
|
+
highlight: panels.point,
|
|
132
|
+
fresh: props.fresh,
|
|
133
|
+
arrangeable: shown.arrangeable,
|
|
134
|
+
onEdit: (widgetId) => {
|
|
135
|
+
props.onBuild({ widgetId });
|
|
136
|
+
}
|
|
93
137
|
})
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/* @__PURE__ */ jsx(Tabs, {
|
|
97
|
-
doc: shown.doc,
|
|
98
|
-
current: shown.tab,
|
|
99
|
-
onSelect: view.setTab
|
|
100
|
-
}),
|
|
101
|
-
/* @__PURE__ */ jsx(DashboardSpan, { results: board.tiles.results }),
|
|
102
|
-
edit.draft === void 0 || !emptyTab(shown) ? null : /* @__PURE__ */ jsx(EmptyTab, { onAdd: add }),
|
|
103
|
-
/* @__PURE__ */ jsx(Grid, {
|
|
104
|
-
doc: shown.doc,
|
|
105
|
-
tab: shown.tab,
|
|
106
|
-
edit,
|
|
107
|
-
results: board.tiles.results,
|
|
108
|
-
pending: board.tiles.pending,
|
|
109
|
-
marks: shown.marks,
|
|
110
|
-
ghosts: shown.ghosts,
|
|
111
|
-
highlight: panels.point,
|
|
112
|
-
fresh: props.fresh,
|
|
113
|
-
arrangeable: shown.arrangeable,
|
|
114
|
-
onEdit: (widgetId) => {
|
|
115
|
-
props.onBuild({ widgetId });
|
|
116
|
-
}
|
|
117
|
-
})
|
|
118
|
-
] });
|
|
138
|
+
]
|
|
139
|
+
});
|
|
119
140
|
}
|
|
120
141
|
export { Canvas };
|
package/dist/react/Cell.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FilterBarOptions } from "./filters/context.mjs";
|
|
2
2
|
import { DashboardDrillProps } from "./drill/board.mjs";
|
|
3
|
+
import { ViewChange } from "./view.mjs";
|
|
4
|
+
import "./FilterBar.mjs";
|
|
3
5
|
import { DashboardEvents } from "./useDashboard.mjs";
|
|
4
6
|
import { ViewState } from "derive-dashboards/core";
|
|
5
7
|
/**
|
|
@@ -34,6 +36,12 @@ export type DashboardProps = {
|
|
|
34
36
|
* While editing they are always cards, with room to drag into.
|
|
35
37
|
*/
|
|
36
38
|
tiles?: "sheet" | "cards";
|
|
39
|
+
/**
|
|
40
|
+
* Options for the dashboard's filter bar, the built-in one's (`pinned`, `shortcuts`, `icons`,
|
|
41
|
+
* ...): `filterBar={{ shortcuts: false }}` on a page with keys of its own. A bar of your own
|
|
42
|
+
* (`components.FilterBar`) is handed them as props too.
|
|
43
|
+
*/
|
|
44
|
+
filterBar?: FilterBarOptions;
|
|
37
45
|
} & DashboardEvents & DashboardDrillProps;
|
|
38
46
|
/**
|
|
39
47
|
* One dashboard. Everything drawn in it, the builder's preview too, shares one book of series
|