derive-dashboards 0.7.1 → 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 +86 -44
- 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 -32
- 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 +51 -9
- 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 +12 -6
- 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/marks/x-axis.mjs +3 -2
- 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.d.mts +25 -25
- package/dist/charts/theme.mjs +47 -30
- 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 +11 -8
- package/dist/core/document/display.mjs +26 -3
- 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 -18
- package/dist/core/time/bucket.mjs +12 -8
- 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.d.mts +6 -1
- package/dist/core/time/zone.mjs +13 -4
- 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 +90 -69
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +15 -1
- package/dist/react/Dashboard.mjs +43 -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 +25 -52
- 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/columns.mjs +9 -1
- 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/board.mjs +1 -0
- package/dist/react/drill/host.mjs +4 -1
- package/dist/react/drill/lazy.mjs +2 -27
- package/dist/react/drill/props.d.mts +19 -8
- package/dist/react/drill/props.mjs +62 -18
- 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 +35 -122
- package/dist/react/headline.d.mts +12 -0
- package/dist/react/headline.mjs +107 -0
- package/dist/react/index.d.mts +20 -17
- package/dist/react/index.mjs +13 -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/place.mjs +4 -2
- 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 +154 -92
- 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 +23 -17
- package/dist/recharts/marks.mjs +2 -1
- package/dist/recharts/parts.mjs +19 -14
- 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 +25 -9
- 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
|
@@ -3,7 +3,7 @@ import { Noun, NumberFormat, Tone } from "../model/hints.mjs";
|
|
|
3
3
|
import { ItemsOrder } from "../query/drill/items.mjs";
|
|
4
4
|
import { DrillCan, DrillField, DrillSemantics, DrillState } from "../query/drill/types.mjs";
|
|
5
5
|
import { Cell, Grain, ResolvedRange } from "../query/types.mjs";
|
|
6
|
-
import { Receipt, RecordColumn, Result, ResultColumn } from "../result/types.mjs";
|
|
6
|
+
import { Receipt, RecordColumn, Result, ResultColumn, TimeBucket } from "../result/types.mjs";
|
|
7
7
|
import { Primitive } from "./primitives.mjs";
|
|
8
8
|
/** Rows of an answer that do not open, each with why (a code a host can translate, and its text). */
|
|
9
9
|
export type ClosedRow = {
|
|
@@ -28,6 +28,14 @@ export type AnswerDrill = SealedAnswer & {
|
|
|
28
28
|
execution: string;
|
|
29
29
|
/** The comparison period's rows (`compare.rows`), when there is one. */
|
|
30
30
|
previous?: SealedAnswer;
|
|
31
|
+
/**
|
|
32
|
+
* With `time.whole`: the answer's whole (`whole.rows`), sealed under the same execution. A
|
|
33
|
+
* whole row opens the rows its row in the answer without the grain opens: its groups over
|
|
34
|
+
* the whole range.
|
|
35
|
+
*/
|
|
36
|
+
whole?: SealedAnswer;
|
|
37
|
+
/** The comparison period's whole (`compare.whole.rows`), when there is one. */
|
|
38
|
+
previousWhole?: SealedAnswer;
|
|
31
39
|
/** Why some rows do not open (`code` for a client to word it, `reason` in English). */
|
|
32
40
|
code?: DrillReason;
|
|
33
41
|
reason?: string;
|
|
@@ -98,7 +106,9 @@ export type DrillSummary = {
|
|
|
98
106
|
/**
|
|
99
107
|
* One selection of the path as a breadcrumb reads it: its fields and its values. A total (the
|
|
100
108
|
* whole tile, a row's or a column's) is `total`, with no label of its own. A selection of more
|
|
101
|
-
* than one
|
|
109
|
+
* than one field (a row of several fields, a segment and its Other) lists each in `parts`, one
|
|
110
|
+
* level deep, each with its own label and value; the crumb itself then has `value: null` and a
|
|
111
|
+
* label that joins its parts' ("Offer type · Coupon"). Read `parts` where there are any.
|
|
102
112
|
*/
|
|
103
113
|
export type DrillCrumb = {
|
|
104
114
|
label: string;
|
|
@@ -106,6 +116,8 @@ export type DrillCrumb = {
|
|
|
106
116
|
kind?: "group" | "time" | "other" | "total" | "search";
|
|
107
117
|
/** A time step's grain, to name it as the chart does ("Week of Nov 9"). */
|
|
108
118
|
grain?: Grain;
|
|
119
|
+
/** A time step's part read: its own range, marked `partial` as `TimeBucket`s are ("so far"). */
|
|
120
|
+
bucket?: ResolvedRange & Pick<TimeBucket, "partial">;
|
|
109
121
|
parts?: DrillCrumb[];
|
|
110
122
|
/** A mark of the period before. */
|
|
111
123
|
previous?: true;
|
|
@@ -84,8 +84,4 @@ export type ServerCallInput = {
|
|
|
84
84
|
request?: Request;
|
|
85
85
|
viewer?: Viewer;
|
|
86
86
|
};
|
|
87
|
-
/** The shape of the entry function, `deriveDashboards(options)`. */
|
|
88
|
-
export type CreateDash = <const O extends DashOptions>(options: O & {
|
|
89
|
-
plugins?: UniqueIds<O["plugins"]>;
|
|
90
|
-
}) => Dash<O>;
|
|
91
87
|
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Doc } from "../document/types.mjs";
|
|
2
|
+
import { StartCheckCode, StartRefusalCode } from "../error/codes.mjs";
|
|
3
|
+
import { DashOptions } from "./options.mjs";
|
|
4
|
+
import { Issue } from "./primitives.mjs";
|
|
5
|
+
/** The shortest `secret` taken: as many bytes as the 256-bit keys made from it. */
|
|
6
|
+
export declare const MIN_SECRET_BYTES = 32;
|
|
7
|
+
/** One problem with the options, at its path from the options' root. */
|
|
8
|
+
export type StartIssue = {
|
|
9
|
+
readonly path: readonly (string | number)[];
|
|
10
|
+
readonly message: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Why `deriveDashboards` did not start: `code` says which check refused (`START_REFUSALS`, or
|
|
14
|
+
* `DOCUMENT_INVALID` for a code dashboard), and `issues` each problem at its path in the options.
|
|
15
|
+
* Every start-up refusal is one of these; `AccessOptionError` and `DashboardDocumentError` are
|
|
16
|
+
* kinds of it.
|
|
17
|
+
*/
|
|
18
|
+
export declare class StartError extends Error {
|
|
19
|
+
readonly code: StartRefusalCode;
|
|
20
|
+
readonly issues: readonly StartIssue[];
|
|
21
|
+
constructor(code: StartRefusalCode, issues: readonly StartIssue[], options?: {
|
|
22
|
+
message?: string;
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** Refuses to start with these issues, under this code; nothing when there are none. */
|
|
27
|
+
export declare function refuseStart(code: StartCheckCode, issues: readonly StartIssue[]): void;
|
|
28
|
+
/** Each code dashboard whose key another one before it has, at its key: the second is never shown. */
|
|
29
|
+
export declare function dashboardKeyIssues(dashboards: readonly {
|
|
30
|
+
key: string;
|
|
31
|
+
}[]): StartIssue[];
|
|
32
|
+
/**
|
|
33
|
+
* Each layout entry of a document that names a widget the document does not have, at its path,
|
|
34
|
+
* with the widget it most likely meant. A stored document's layout is repaired when it is read; a
|
|
35
|
+
* code dashboard's is the host's own code, so the entry is a mistake to fix.
|
|
36
|
+
*/
|
|
37
|
+
export declare function layoutWidgetIssues(doc: Doc): Issue[];
|
|
38
|
+
/**
|
|
39
|
+
* Each code dashboard's widget whose kind no renderer draws: neither the library's nor one of
|
|
40
|
+
* `widgetKinds`. Left alone it would be drawn as a table, with no word.
|
|
41
|
+
*/
|
|
42
|
+
export declare function widgetKindIssues(options: DashOptions): StartIssue[];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { didYouMean } from "../model/validate/fields.mjs";
|
|
2
|
+
import { LIBRARY_WIDGET_KINDS } from "./dashboard.mjs";
|
|
3
|
+
// src/types/options-check.ts
|
|
4
|
+
/** The shortest `secret` taken: as many bytes as the 256-bit keys made from it. */
|
|
5
|
+
const MIN_SECRET_BYTES = 32;
|
|
6
|
+
/** The issues as lines, each led by its path. */
|
|
7
|
+
function lines(issues) {
|
|
8
|
+
return issues.map(({ path, message }) => path.length === 0 ? message : `${path.join(".")}: ${message}`).join("\n");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Why `deriveDashboards` did not start: `code` says which check refused (`START_REFUSALS`, or
|
|
12
|
+
* `DOCUMENT_INVALID` for a code dashboard), and `issues` each problem at its path in the options.
|
|
13
|
+
* Every start-up refusal is one of these; `AccessOptionError` and `DashboardDocumentError` are
|
|
14
|
+
* kinds of it.
|
|
15
|
+
*/
|
|
16
|
+
var StartError = class extends Error {
|
|
17
|
+
code;
|
|
18
|
+
issues;
|
|
19
|
+
constructor(code, issues, options) {
|
|
20
|
+
super(options?.message ?? lines(issues), { cause: options?.cause });
|
|
21
|
+
this.name = "StartError";
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.issues = issues;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** Refuses to start with these issues, under this code; nothing when there are none. */
|
|
27
|
+
function refuseStart(code, issues) {
|
|
28
|
+
if (issues.length > 0) throw new StartError(code, issues);
|
|
29
|
+
}
|
|
30
|
+
/** Each code dashboard whose key another one before it has, at its key: the second is never shown. */
|
|
31
|
+
function dashboardKeyIssues(dashboards) {
|
|
32
|
+
const keys = dashboards.map((d) => d.key);
|
|
33
|
+
return keys.flatMap((key, at) => {
|
|
34
|
+
const first = keys.indexOf(key);
|
|
35
|
+
return first === at ? [] : [{
|
|
36
|
+
path: [
|
|
37
|
+
"dashboards",
|
|
38
|
+
at,
|
|
39
|
+
"key"
|
|
40
|
+
],
|
|
41
|
+
message: `The dashboard "${key}" is defined twice (dashboards ${first} and ${at}); each code dashboard has its own key.`
|
|
42
|
+
}];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Each layout entry of a document that names a widget the document does not have, at its path,
|
|
47
|
+
* with the widget it most likely meant. A stored document's layout is repaired when it is read; a
|
|
48
|
+
* code dashboard's is the host's own code, so the entry is a mistake to fix.
|
|
49
|
+
*/
|
|
50
|
+
function layoutWidgetIssues(doc) {
|
|
51
|
+
const ids = Object.keys(doc.widgets);
|
|
52
|
+
return doc.tabs.flatMap((tab, t) => tab.layout.flatMap(({ widget }, at) => {
|
|
53
|
+
if (Object.hasOwn(doc.widgets, widget)) return [];
|
|
54
|
+
const meant = didYouMean(widget, ids);
|
|
55
|
+
const there = ids.length === 0 ? "It has none." : `Its widgets are ${ids.join(", ")}.`;
|
|
56
|
+
return [{
|
|
57
|
+
code: "DOCUMENT_INVALID",
|
|
58
|
+
path: [
|
|
59
|
+
"tabs",
|
|
60
|
+
t,
|
|
61
|
+
"layout",
|
|
62
|
+
at,
|
|
63
|
+
"widget"
|
|
64
|
+
],
|
|
65
|
+
message: `"${widget}" is not a widget of the dashboard.${meant} ${there}`
|
|
66
|
+
}];
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Each code dashboard's widget whose kind no renderer draws: neither the library's nor one of
|
|
71
|
+
* `widgetKinds`. Left alone it would be drawn as a table, with no word.
|
|
72
|
+
*/
|
|
73
|
+
function widgetKindIssues(options) {
|
|
74
|
+
const kinds = [...LIBRARY_WIDGET_KINDS, ...options.widgetKinds ?? []];
|
|
75
|
+
return (options.dashboards ?? []).flatMap(({ key, document: doc }, at) => Object.entries(doc.widgets).filter(([, widget]) => !kinds.includes(widget.kind)).map(([id, { kind }]) => {
|
|
76
|
+
const meant = didYouMean(kind, kinds);
|
|
77
|
+
return {
|
|
78
|
+
path: [
|
|
79
|
+
"dashboards",
|
|
80
|
+
at,
|
|
81
|
+
"document",
|
|
82
|
+
"widgets",
|
|
83
|
+
id,
|
|
84
|
+
"kind"
|
|
85
|
+
],
|
|
86
|
+
message: `The dashboard "${key}" has a widget "${id}" of kind "${kind}", which no renderer draws.${meant} The kinds are ${kinds.join(", ")}; add your own renderers' kinds to \`widgetKinds\`.`
|
|
87
|
+
};
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
export { MIN_SECRET_BYTES, StartError, dashboardKeyIssues, layoutWidgetIssues, refuseStart, widgetKindIssues };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Doc } from "../document/types.mjs";
|
|
2
1
|
import { CustomSource } from "../engine/custom/request.mjs";
|
|
3
2
|
import { Model } from "../model/types.mjs";
|
|
4
3
|
import { CompositionPolicy } from "../query/compose.mjs";
|
|
5
4
|
import { ItemLinks } from "../query/drill/links.mjs";
|
|
5
|
+
import { CodeDashboard } from "./dashboard.mjs";
|
|
6
6
|
import { DashPlugin } from "./plugin.mjs";
|
|
7
7
|
import { Awaitable, ConnectionId, IanaZone, WeekStart } from "./primitives.mjs";
|
|
8
8
|
import { QueryConnection } from "./source.mjs";
|
|
@@ -18,11 +18,6 @@ export type SecondaryStorage = {
|
|
|
18
18
|
set(key: string, value: string, ttl?: number): Awaitable<void>;
|
|
19
19
|
delete(key: string): Awaitable<void>;
|
|
20
20
|
};
|
|
21
|
-
/** A dashboard defined in code, with a stable key and stable widget and control ids. */
|
|
22
|
-
export type CodeDashboard = {
|
|
23
|
-
key: string;
|
|
24
|
-
document: Doc;
|
|
25
|
-
};
|
|
26
21
|
export type DashOptions = {
|
|
27
22
|
basePath?: string;
|
|
28
23
|
/**
|
|
@@ -33,8 +28,16 @@ export type DashOptions = {
|
|
|
33
28
|
database?: DashAdapter | ((request: Request) => DashAdapter);
|
|
34
29
|
/** Off by default. Writes one `dd_query_log` row per answered query, for `check --perf`. */
|
|
35
30
|
queryLog?: boolean;
|
|
36
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Dashboards defined in code: every tenant sees them at version 0 until it customizes one.
|
|
33
|
+
* Typed by the model (`defineDashboard`), and each widget's kind is checked at start.
|
|
34
|
+
*/
|
|
37
35
|
dashboards?: readonly CodeDashboard[];
|
|
36
|
+
/**
|
|
37
|
+
* The kinds your own renderers draw, besides the library's (`LIBRARY_WIDGET_KINDS`): a code
|
|
38
|
+
* dashboard's widget of any other kind is refused at start, naming the kinds there are.
|
|
39
|
+
*/
|
|
40
|
+
widgetKinds?: readonly string[];
|
|
38
41
|
model: Model;
|
|
39
42
|
/**
|
|
40
43
|
* The connections the model's sources read, by the name each source gives (`in`): a
|
|
@@ -49,6 +52,8 @@ export type DashOptions = {
|
|
|
49
52
|
* each process makes its own key, so a drill link or cursor opens only on the process that
|
|
50
53
|
* gave it and stops working after a restart. Set one shared secret in production, and
|
|
51
54
|
* whenever several instances serve the same app; the server warns at startup without one.
|
|
55
|
+
* At least `MIN_SECRET_BYTES` (32) bytes, such as `openssl rand -base64 32`: it is hashed
|
|
56
|
+
* into 256-bit keys, so a shorter one is a weaker key than they hold, and is refused.
|
|
52
57
|
*/
|
|
53
58
|
secret?: string;
|
|
54
59
|
/** `can` is required. Access is never open by default. */
|
|
@@ -71,7 +76,8 @@ export type DashOptions = {
|
|
|
71
76
|
/**
|
|
72
77
|
* The result cache: off unless given. A result is fresh for `ttl` seconds and served stale,
|
|
73
78
|
* while it refreshes, for `staleTtl` more. A range that includes the current unit ends at
|
|
74
|
-
* now floored to `quantum` seconds (default 60
|
|
79
|
+
* now floored to `quantum` seconds (default 60; a whole number of seconds, 1 or more), so
|
|
80
|
+
* equal requests share one answer.
|
|
75
81
|
* `api.cache.invalidate` drops a tenant's results for the sources that changed.
|
|
76
82
|
*/
|
|
77
83
|
cache?: {
|
|
@@ -3,6 +3,4 @@
|
|
|
3
3
|
* uses, in the oracle and, built from the same table, in every database. It maps one code
|
|
4
4
|
* point to one code point, so lengths and positions never change.
|
|
5
5
|
*/
|
|
6
|
-
export declare function fold(text: string): string;
|
|
7
|
-
/** Every code point the table changes, for the database functions built from it. */
|
|
8
|
-
export declare function foldingPairs(): readonly (readonly [number, number])[];
|
|
6
|
+
export declare function fold(text: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Column, Primitive, SourceName } from "../types/primitives.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* A value as a source's column holds it: what a driver or a host's own rows give. Beside the
|
|
4
|
+
* plain values, a `bigint` (node-postgres and most drivers give `int8` so) and a `Date` (a
|
|
5
|
+
* `timestamptz` read by node-postgres).
|
|
6
|
+
*/
|
|
7
|
+
export type StoredValue = Primitive | bigint | Date;
|
|
8
|
+
/**
|
|
9
|
+
* A stored value read by its column's declared storage: its value (null for a stored null), or
|
|
10
|
+
* the reason it is not a value of that storage. A value that does not read is never guessed and
|
|
11
|
+
* never silently null: the answer reads it as no value, counts it (`Unread`) and keeps its row.
|
|
12
|
+
*/
|
|
13
|
+
export type Reading<T> = {
|
|
14
|
+
readonly value: T | null;
|
|
15
|
+
} | {
|
|
16
|
+
readonly unread: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Values of one column the answer's rows hold that do not read as that column's storage: read
|
|
20
|
+
* as no value, counted here, and named in its warnings. `column` is the stored column.
|
|
21
|
+
*/
|
|
22
|
+
export type Unread = {
|
|
23
|
+
readonly source: SourceName;
|
|
24
|
+
readonly column: Column;
|
|
25
|
+
readonly count: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/value/stored.ts
|
|
2
|
+
/**
|
|
3
|
+
* A whole number as a driver or a host gives one: a `bigint`, a safe integer, or its digits as
|
|
4
|
+
* text (node-postgres's `int8`, past 2^53). Undefined for anything else, never rounded. The one
|
|
5
|
+
* reader of a whole number from outside: counts, minor units, microseconds and epochs.
|
|
6
|
+
*/
|
|
7
|
+
function wholeNumber(value) {
|
|
8
|
+
if (typeof value === "bigint") return value;
|
|
9
|
+
if (typeof value === "number") return Number.isSafeInteger(value) ? BigInt(value) : void 0;
|
|
10
|
+
return typeof value === "string" && /^-?\d+$/u.test(value) ? BigInt(value) : void 0;
|
|
11
|
+
}
|
|
12
|
+
/** The value a reading gives the rows it places: null for a stored null and for an unread one. */
|
|
13
|
+
const readValue = (reading) => "value" in reading ? reading.value : null;
|
|
14
|
+
/** Whether a stored value is there but does not read as a value of its column's storage. */
|
|
15
|
+
const isUnread = (reading) => "unread" in reading;
|
|
16
|
+
/**
|
|
17
|
+
* A stored value as a plain value, for a column read as it is (a dimension, a filter): a
|
|
18
|
+
* `bigint` as its digits, a `Date` as its text (an invalid one too, so it is counted unread, never null) and a NaN as
|
|
19
|
+
* `"NaN"`, the forms a SQL source gives them (a NaN in a decimal column is refused, as in Postgres).
|
|
20
|
+
*/
|
|
21
|
+
function plainStored(value) {
|
|
22
|
+
if (value === void 0) return null;
|
|
23
|
+
if (typeof value === "bigint") return value.toString();
|
|
24
|
+
if (typeof value === "number" && Number.isNaN(value)) return "NaN";
|
|
25
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
export { isUnread, plainStored, readValue, wholeNumber };
|
package/dist/cursor-seal.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { canonical, principalTenant } from "derive-dashboards/core";
|
|
2
2
|
import { EngineError } from "derive-dashboards/core/engine";
|
|
3
3
|
// src/cursor-seal.ts
|
|
4
|
+
/** One encoder for every text sealed, signed or hashed here. */
|
|
5
|
+
const utf8 = new TextEncoder();
|
|
4
6
|
/** 32 bytes from the secret for one use, or random ones for this process when there is none. */
|
|
5
7
|
async function keyBytes(secret, use) {
|
|
6
8
|
if (secret === void 0) return crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32));
|
|
7
9
|
const text = use === "" ? secret : `${use}\u0000${secret}`;
|
|
8
|
-
return new Uint8Array(await crypto.subtle.digest("SHA-256",
|
|
10
|
+
return new Uint8Array(await crypto.subtle.digest("SHA-256", utf8.encode(text)));
|
|
9
11
|
}
|
|
10
12
|
/** The key that seals: from `options.secret`, or one made for this process. */
|
|
11
13
|
async function cursorKey(secret) {
|
|
@@ -20,22 +22,48 @@ async function macKey(secret) {
|
|
|
20
22
|
hash: "SHA-256"
|
|
21
23
|
}, false, ["sign"]);
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
25
|
+
/** Each 6-bit value's character code in the URL-safe alphabet. */
|
|
26
|
+
const ALPHABET = Uint8Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", (c) => c.codePointAt(0) ?? 0);
|
|
27
|
+
const ascii = new TextDecoder();
|
|
28
|
+
/** The character code of 6 bits of a 24-bit group, the `k`th from the left. */
|
|
29
|
+
const codeAt = (group, k) => ALPHABET[group >> 18 - 6 * k & 63] ?? 0;
|
|
30
|
+
/** Bytes as URL-safe base64 with no padding, in every runtime. */
|
|
31
|
+
function base64url(bytes) {
|
|
32
|
+
const out = new Uint8Array(Math.ceil(bytes.length * 4 / 3));
|
|
33
|
+
const whole = bytes.length - bytes.length % 3;
|
|
34
|
+
for (let at = 0, to = 0; at < whole; at += 3, to += 4) {
|
|
35
|
+
const group = (bytes[at] ?? 0) << 16 | (bytes[at + 1] ?? 0) << 8 | (bytes[at + 2] ?? 0);
|
|
36
|
+
out[to] = codeAt(group, 0);
|
|
37
|
+
out[to + 1] = codeAt(group, 1);
|
|
38
|
+
out[to + 2] = codeAt(group, 2);
|
|
39
|
+
out[to + 3] = codeAt(group, 3);
|
|
40
|
+
}
|
|
41
|
+
const rest = (bytes[whole] ?? 0) << 16 | (bytes[whole + 1] ?? 0) << 8;
|
|
42
|
+
const done = whole / 3 * 4;
|
|
43
|
+
for (let k = 0; done + k < out.length; k++) out[done + k] = codeAt(rest, k);
|
|
44
|
+
return ascii.decode(out);
|
|
45
|
+
}
|
|
46
|
+
/** URL-safe base64 read back to its bytes. */
|
|
47
|
+
function fromBase64url(text) {
|
|
48
|
+
const raw = atob(text.replaceAll("-", "+").replaceAll("_", "/"));
|
|
49
|
+
const bytes = new Uint8Array(raw.length);
|
|
50
|
+
for (let at = 0; at < raw.length; at++) bytes[at] = raw.codePointAt(at) ?? 0;
|
|
51
|
+
return bytes;
|
|
52
|
+
}
|
|
26
53
|
/**
|
|
27
54
|
* A keyed digest in hex: what a receipt names its query by. Keyed, so a person who can guess the
|
|
28
55
|
* query's hidden parts (an Other step's kept names) cannot test a guess against it offline.
|
|
29
56
|
*/
|
|
30
57
|
async function macHex(key, text) {
|
|
31
|
-
const signed = await crypto.subtle.sign("HMAC", key,
|
|
58
|
+
const signed = await crypto.subtle.sign("HMAC", key, utf8.encode(text));
|
|
32
59
|
return Array.from(new Uint8Array(signed), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
33
60
|
}
|
|
61
|
+
/** A text's HMAC under the key, as 22 URL-safe characters (128 bits): stable, and not reversible without the key. */
|
|
34
62
|
async function mac(key, text) {
|
|
35
|
-
const signed = await crypto.subtle.sign("HMAC", key,
|
|
63
|
+
const signed = await crypto.subtle.sign("HMAC", key, utf8.encode(text));
|
|
36
64
|
return base64url(new Uint8Array(signed).slice(0, 16));
|
|
37
65
|
}
|
|
38
|
-
const boundTo = (b) =>
|
|
66
|
+
const boundTo = (b) => utf8.encode(canonical({
|
|
39
67
|
purpose: b.purpose,
|
|
40
68
|
tenant: principalTenant(b.principal),
|
|
41
69
|
on: b.on
|
|
@@ -44,7 +72,7 @@ const boundTo = (b) => new TextEncoder().encode(canonical({
|
|
|
44
72
|
const PAD_BLOCK = 256;
|
|
45
73
|
const PAD_MARK = "\0";
|
|
46
74
|
function padded(text) {
|
|
47
|
-
const bytes =
|
|
75
|
+
const bytes = utf8.encode(`${text}${PAD_MARK}`);
|
|
48
76
|
const size = Math.ceil(bytes.length / PAD_BLOCK) * PAD_BLOCK;
|
|
49
77
|
const out = new Uint8Array(size).fill(32);
|
|
50
78
|
out.set(bytes);
|
|
@@ -95,4 +123,4 @@ async function openCursor(key, sealed, at) {
|
|
|
95
123
|
if (opened !== void 0) return opened;
|
|
96
124
|
throw new EngineError("CURSOR_INVALID", "The records cursor is not one this view gave, or it has expired: start again from the first page.");
|
|
97
125
|
}
|
|
98
|
-
export { base64url, cursorKey, mac, macHex, macKey, openCursor, seal, sealCursor, unseal };
|
|
126
|
+
export { base64url, cursorKey, fromBase64url, mac, macHex, macKey, openCursor, seal, sealCursor, unseal };
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { DashOptions, Issue } from "derive-dashboards/core";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { DashOptions, Doc, Issue, StartError } from "derive-dashboards/core";
|
|
2
|
+
/**
|
|
3
|
+
* A code dashboard's document the server cannot start with: a kind of `StartError`, code
|
|
4
|
+
* DOCUMENT_INVALID, its issues at their paths in the document.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DashboardDocumentError extends StartError {
|
|
6
7
|
readonly code = "DOCUMENT_INVALID";
|
|
8
|
+
readonly issues: readonly Issue[];
|
|
9
|
+
readonly dashboardKey: string;
|
|
7
10
|
constructor(dashboardKey: string, reason: string, issues: readonly Issue[]);
|
|
8
|
-
}
|
|
11
|
+
}
|
|
12
|
+
/** A code dashboard as the server checked it at start: its document loaded, every default filled in. */
|
|
13
|
+
export type CheckedDashboard = {
|
|
14
|
+
key: string;
|
|
15
|
+
document: Doc;
|
|
16
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { displayOf, documentDisplayIssues, resolveDimension } from "derive-dashboards/core";
|
|
2
|
-
import { loadDocument } from "derive-dashboards/core/schema";
|
|
1
|
+
import { StartError, controlFieldIssues, dashboardKeyIssues, displayOf, documentDisplayIssues, layoutWidgetIssues, refuseStart, resolveDimension } from "derive-dashboards/core";
|
|
2
|
+
import { loadDocument, parseDocument } from "derive-dashboards/core/schema";
|
|
3
3
|
// src/dashboard-documents.ts
|
|
4
4
|
function declaredValues(model, source, member) {
|
|
5
5
|
const dimension = resolveDimension(model, source, member)?.dimension;
|
|
@@ -19,29 +19,47 @@ function comparisonKeyHints(doc, model) {
|
|
|
19
19
|
return Object.keys(groups).filter((key) => !choices.includes(key)).map((key) => `widgets.${id}.display.comparisons: "${key}" is outside the declared choices for "${member}" (${choices.join(", ")}). This action appears only on an exact group value match.`);
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
/**
|
|
23
|
+
* A code dashboard's document the server cannot start with: a kind of `StartError`, code
|
|
24
|
+
* DOCUMENT_INVALID, its issues at their paths in the document.
|
|
25
|
+
*/
|
|
26
|
+
var DashboardDocumentError = class extends StartError {
|
|
26
27
|
code = "DOCUMENT_INVALID";
|
|
28
|
+
issues;
|
|
29
|
+
dashboardKey;
|
|
27
30
|
constructor(dashboardKey, reason, issues) {
|
|
28
31
|
const problems = issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
|
|
29
|
-
super(`The dashboard "${dashboardKey}" ${reason}: ${problems}`);
|
|
30
|
-
this.dashboardKey = dashboardKey;
|
|
31
|
-
this.issues = issues;
|
|
32
|
+
super("DOCUMENT_INVALID", issues, { message: `The dashboard "${dashboardKey}" ${reason}: ${problems}` });
|
|
32
33
|
this.name = "DashboardDocumentError";
|
|
34
|
+
this.issues = issues;
|
|
35
|
+
this.dashboardKey = dashboardKey;
|
|
33
36
|
}
|
|
34
37
|
};
|
|
38
|
+
/** Each layout entry naming a widget the document lacks, read before a layout is repaired. */
|
|
39
|
+
function missingWidgets(document) {
|
|
40
|
+
const parsed = parseDocument(document);
|
|
41
|
+
return parsed.ok ? layoutWidgetIssues(parsed.doc) : [];
|
|
42
|
+
}
|
|
35
43
|
/**
|
|
36
44
|
* Code-defined dashboards are checked when the handler is made, not when a viewer opens one: an
|
|
37
|
-
* invalid document
|
|
45
|
+
* invalid document, a layout entry for a widget it lacks, or a key another one has stops the
|
|
46
|
+
* server with every problem named.
|
|
38
47
|
*/
|
|
39
48
|
function checkedDashboards(options, model) {
|
|
40
|
-
|
|
49
|
+
const dashboards = options.dashboards ?? [];
|
|
50
|
+
refuseStart("DASHBOARD_KEY_DUPLICATE", dashboardKeyIssues(dashboards));
|
|
51
|
+
return dashboards.map((d) => {
|
|
41
52
|
const loaded = loadDocument(d.document);
|
|
42
53
|
if (!loaded.ok) throw new DashboardDocumentError(d.key, "is not a valid document", loaded.issues);
|
|
54
|
+
const missing = missingWidgets(d.document);
|
|
55
|
+
if (missing.length > 0) throw new DashboardDocumentError(d.key, "lays out widgets it does not have", missing);
|
|
43
56
|
const wrong = documentDisplayIssues(loaded.doc, model);
|
|
44
57
|
if (wrong.length > 0) throw new DashboardDocumentError(d.key, "has display options to fix", wrong);
|
|
58
|
+
const fields = controlFieldIssues(loaded.doc.controls, model, () => true).map((found) => ({
|
|
59
|
+
...found,
|
|
60
|
+
path: ["controls", ...found.path]
|
|
61
|
+
}));
|
|
62
|
+
if (fields.length > 0) throw new DashboardDocumentError(d.key, "has filters to fix", fields);
|
|
45
63
|
for (const hint of comparisonKeyHints(loaded.doc, model)) console.warn(`Dashboard "${d.key}": ${hint}`);
|
|
46
64
|
return {
|
|
47
65
|
key: d.key,
|
|
@@ -49,4 +67,6 @@ function checkedDashboards(options, model) {
|
|
|
49
67
|
};
|
|
50
68
|
});
|
|
51
69
|
}
|
|
52
|
-
|
|
70
|
+
/** A checked code dashboard's document by key; none when no code dashboard has the key. */
|
|
71
|
+
const codeDocument = (dashboards, key) => dashboards.find((d) => d.key === key)?.document;
|
|
72
|
+
export { DashboardDocumentError, checkedDashboards, codeDocument };
|
package/dist/dashboards.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { codeDocument } from "./dashboard-documents.mjs";
|
|
1
2
|
import { builtInId, parseDashboardId } from "./dashboard-id.mjs";
|
|
2
3
|
import { HttpError } from "./http.mjs";
|
|
3
4
|
import { requestDashboardRow } from "./request-rows.mjs";
|
|
@@ -32,11 +33,11 @@ function adapterFor(options, request) {
|
|
|
32
33
|
}
|
|
33
34
|
/** A description the list carries only when there is one to show. */
|
|
34
35
|
const described = (description) => description === void 0 || description.trim() === "" ? {} : { description };
|
|
35
|
-
async function listDashboards(
|
|
36
|
-
const adapter = adapterFor(options, request);
|
|
36
|
+
async function listDashboards(rt, request, principal) {
|
|
37
|
+
const adapter = adapterFor(rt.options, request);
|
|
37
38
|
const stored = adapter === void 0 ? [] : await allStored(adapter, principalTenant(principal));
|
|
38
39
|
const customized = new Set(stored.flatMap((d) => d.defaultOf === void 0 ? [] : [d.defaultOf]));
|
|
39
|
-
const defaults =
|
|
40
|
+
const defaults = rt.dashboards.filter((d) => !customized.has(d.key)).map((d) => ({
|
|
40
41
|
id: builtInId(d.key),
|
|
41
42
|
title: d.document.meta.title,
|
|
42
43
|
...described(d.document.meta.description),
|
|
@@ -53,8 +54,8 @@ async function listDashboards(options, request, principal) {
|
|
|
53
54
|
} } : {}
|
|
54
55
|
})), ...defaults];
|
|
55
56
|
}
|
|
56
|
-
async function find(
|
|
57
|
-
const adapter = adapterFor(options, request);
|
|
57
|
+
async function find(rt, request, principal, id) {
|
|
58
|
+
const adapter = adapterFor(rt.options, request);
|
|
58
59
|
const ref = parseDashboardId(id);
|
|
59
60
|
const tenant = principalTenant(principal);
|
|
60
61
|
const stored = adapter === void 0 ? null : await storedHead(adapter, await requestDashboardRow(request, adapter, tenant, ref), tenant);
|
|
@@ -64,12 +65,12 @@ async function find(options, request, principal, id) {
|
|
|
64
65
|
document: stored.doc
|
|
65
66
|
};
|
|
66
67
|
const key = "key" in ref ? ref.key : void 0;
|
|
67
|
-
const code = key === void 0 ? void 0 : (
|
|
68
|
+
const code = key === void 0 ? void 0 : codeDocument(rt.dashboards, key);
|
|
68
69
|
if (code === void 0) throw new HttpError(404, "NOT_FOUND", `There is no dashboard "${id}". A built-in one's id is "default:" and its key; /dashboards/list gives every id.`);
|
|
69
70
|
return {
|
|
70
71
|
id,
|
|
71
72
|
version: 0,
|
|
72
|
-
document: code
|
|
73
|
+
document: code
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
@@ -79,8 +80,8 @@ async function find(options, request, principal, id) {
|
|
|
79
80
|
* different current version is a 409, so a client never runs tiles against a dashboard that
|
|
80
81
|
* changed under it.
|
|
81
82
|
*/
|
|
82
|
-
async function loadDashboard(
|
|
83
|
-
const loaded = await find(
|
|
83
|
+
async function loadDashboard(rt, request, principal, ref) {
|
|
84
|
+
const loaded = await find(rt, request, principal, ref.id);
|
|
84
85
|
const expected = ref.version;
|
|
85
86
|
if (expected !== void 0 && expected !== loaded.version) throw new HttpError(409, "VERSION_CONFLICT", "The dashboard changed. Reload it.");
|
|
86
87
|
return loaded;
|
package/dist/drill-access.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { execute } from "./execute.mjs";
|
|
2
|
+
import { allows } from "./grant.mjs";
|
|
2
3
|
import { HttpError } from "./http.mjs";
|
|
3
4
|
import { queryClosure, resultColumns } from "derive-dashboards/core";
|
|
4
|
-
import { drillOwner, lineFilter, offeredMembers, pathFields, stepMembers } from "
|
|
5
|
+
import { drillOwner, lineFilter, offeredMembers, pathFields, stepMembers } from "#core/internal";
|
|
5
6
|
// src/drill-access.ts
|
|
6
7
|
/** Which fields this viewer may see in a drill: never a sensitive one (Rules, section 6). */
|
|
7
8
|
const readableFor = (_x) => (_member, def) => def.sensitive !== true;
|
|
@@ -32,10 +33,10 @@ function mayRead(o, member) {
|
|
|
32
33
|
const asked = o.reads.get(member);
|
|
33
34
|
if (asked !== void 0) return asked;
|
|
34
35
|
const { principal } = o.scope;
|
|
35
|
-
const answer = principal.channel === "user" ?
|
|
36
|
+
const answer = principal.channel === "user" ? allows(o.x.rt.options.access, principal.viewer, "view", {
|
|
36
37
|
kind: "member",
|
|
37
38
|
id: member
|
|
38
|
-
})
|
|
39
|
+
}) : Promise.resolve(false);
|
|
39
40
|
o.reads.set(member, answer);
|
|
40
41
|
return answer;
|
|
41
42
|
}
|
|
@@ -84,11 +85,10 @@ async function readableColumns(o, source, names) {
|
|
|
84
85
|
function mayList(o, source) {
|
|
85
86
|
const { principal } = o.scope;
|
|
86
87
|
if (principal.channel !== "user") return Promise.resolve(false);
|
|
87
|
-
|
|
88
|
-
return Promise.resolve(can(principal.viewer, "view", {
|
|
88
|
+
return allows(o.x.rt.options.access, principal.viewer, "view", {
|
|
89
89
|
kind: "records",
|
|
90
90
|
source
|
|
91
|
-
})
|
|
91
|
+
});
|
|
92
92
|
}
|
|
93
93
|
/** Label the offered dimensions in the same context as the result columns. */
|
|
94
94
|
function labelledFields(o, kept) {
|
package/dist/drill-change.mjs
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import { formatExact, isMark, parseExact } from "derive-dashboards/core";
|
|
1
|
+
import { cellDigits, decimalPlaces, formatExact, isMark, parseExact } from "derive-dashboards/core";
|
|
2
2
|
// src/drill-change.ts
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* A cell's number as whole units of 10^-scale, or undefined for anything else. Its digits are
|
|
5
|
+
* read by core's one reader (`cellDigits`): a float's shortest decimal text is exact, 1.15 is
|
|
6
|
+
* "1.15", where multiplying it is not.
|
|
7
|
+
*/
|
|
4
8
|
function units(cell, scale) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
/** A float's shortest decimal text, written out where JavaScript would use an exponent (1e-7). */
|
|
9
|
-
const plainText = (n) => {
|
|
10
|
-
const text = String(n);
|
|
11
|
-
return /e/iu.test(text) ? n.toFixed(Math.min(decimalsOf(text), 100)) : text;
|
|
12
|
-
};
|
|
13
|
-
/** The decimal places a number's text holds, an exponent's included ("1e-7" has 7, "1.25e-3" has 5). */
|
|
14
|
-
function decimalsOf(text) {
|
|
15
|
-
const [mantissa = "", exponent = "0"] = text.toLowerCase().split("e");
|
|
16
|
-
const places = mantissa.includes(".") ? mantissa.split(".")[1]?.length ?? 0 : 0;
|
|
17
|
-
return Math.max(0, places - Number(exponent));
|
|
9
|
+
const digits = cellDigits(cell);
|
|
10
|
+
return digits === void 0 ? void 0 : parseExact(digits, scale);
|
|
18
11
|
}
|
|
19
12
|
/** The places a set of cells needs to be added exactly: the most any of them has. */
|
|
20
|
-
const placesOf = (cells) => Math.max(0, ...cells.
|
|
21
|
-
|
|
13
|
+
const placesOf = (cells) => Math.max(0, ...cells.flatMap((c) => {
|
|
14
|
+
const digits = cellDigits(c);
|
|
15
|
+
return digits === void 0 ? [] : [decimalPlaces(digits)];
|
|
22
16
|
}));
|
|
23
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* A sum of units at a scale as a cell like the inputs: exact text, or the float nearest the
|
|
19
|
+
* exact value (read from its text, so no power of ten overflows or rounds twice).
|
|
20
|
+
*/
|
|
24
21
|
function cellAt(value, scale, exact) {
|
|
25
|
-
|
|
22
|
+
const text = formatExact(value, scale);
|
|
23
|
+
if (!exact) return Number(text);
|
|
26
24
|
return {
|
|
27
25
|
t: scale === 0 ? "int" : "decimal",
|
|
28
|
-
v:
|
|
26
|
+
v: text
|
|
29
27
|
};
|
|
30
28
|
}
|
|
31
29
|
const isOther = (row) => row.some((c) => isMark(c) && c.mark === "other");
|
|
@@ -4,7 +4,8 @@ import { sealedView } from "./drill-group-seal.mjs";
|
|
|
4
4
|
import { visibleSelection } from "./drill-open.mjs";
|
|
5
5
|
import { numberOf } from "./drill-totals.mjs";
|
|
6
6
|
import { wire } from "./execute.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { breakdownQuery, composeDrill, countQuery } from "#core/internal";
|
|
8
|
+
import { EngineError } from "derive-dashboards/core/engine";
|
|
8
9
|
// src/drill-comparison.ts
|
|
9
10
|
/** A shared group must contain rows visible to its opener before its name can be shown. */
|
|
10
11
|
function comparisonScope(scope) {
|