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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Model } from "../model/types.mjs";
|
|
2
|
+
import { Offer } from "../query/closure.mjs";
|
|
3
|
+
import { Control } from "../query/types.mjs";
|
|
4
|
+
import { Issue } from "../types/primitives.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* The members a refusal of these controls' fields could name: for each name that is no field,
|
|
7
|
+
* the name itself when it is a measure, and the five fields nearest a typo. A caller whose
|
|
8
|
+
* `offer` asks its host asks about these alone, however many members the model has.
|
|
9
|
+
* `controlFieldIssues` says the same with only these offered as with every member offered,
|
|
10
|
+
* unless the asker may read none of a typo's five nearest: then it offers no name.
|
|
11
|
+
*/
|
|
12
|
+
export declare function controlFieldOffers(controls: readonly Control[], model: Model): string[];
|
|
13
|
+
/**
|
|
14
|
+
* What is wrong with a dashboard's filter controls against the model, each at its place in
|
|
15
|
+
* `controls`: a field the model does not have; a second field on a source one of the control's
|
|
16
|
+
* fields already covers, which no tile would ever use; and a field holding another type of
|
|
17
|
+
* value than the control's own, which one pick cannot narrow. A mistyped field is offered its
|
|
18
|
+
* nearest name only among fields `offer` allows: none by default.
|
|
19
|
+
*/
|
|
20
|
+
export declare function controlFieldIssues(controls: readonly Control[], model: Model, offer?: Offer): Issue[];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { dimensionValueType, memberIdOf, parseMemberId, resolveDimension, resolveMeasure, sourceOf } from "../model/member.mjs";
|
|
2
|
+
import { didYouMean, nearTo } from "../model/validate/fields.mjs";
|
|
3
|
+
// src/document/control-fields.ts
|
|
4
|
+
/** The source and value type of a field the model has; none for a name that is not one. */
|
|
5
|
+
function fieldOf(model, id) {
|
|
6
|
+
const source = parseMemberId(id)?.source;
|
|
7
|
+
const found = source === void 0 ? void 0 : resolveDimension(model, source, id);
|
|
8
|
+
return found === void 0 || source === void 0 ? void 0 : {
|
|
9
|
+
source,
|
|
10
|
+
type: dimensionValueType(found.dimension)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const issue = (path, message) => ({
|
|
14
|
+
code: "CONTROL_FIELD",
|
|
15
|
+
message,
|
|
16
|
+
path
|
|
17
|
+
});
|
|
18
|
+
/** The dimensions of a name's source that a refusal may offer: those the model shows, never a hidden or sensitive one. */
|
|
19
|
+
function shownFields(model, id) {
|
|
20
|
+
const source = parseMemberId(id)?.source ?? "";
|
|
21
|
+
return Object.entries(sourceOf(model, source)?.dimensions ?? {}).filter(([, d]) => d.hidden !== true && d.sensitive !== true).map(([name]) => memberIdOf(source, name));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The field a mistyped one most likely meant, among its source's own dimensions the model shows
|
|
25
|
+
* and the asker may read (`offer`), as `didYouMean` words it.
|
|
26
|
+
*/
|
|
27
|
+
const meantField = (model, id, offer) => didYouMean(id, shownFields(model, id).filter((field) => offer(field)));
|
|
28
|
+
/** Whether a name is a measure of the model: a number added up over rows, which no filter narrows by. */
|
|
29
|
+
function isMeasure(model, id) {
|
|
30
|
+
const source = parseMemberId(id)?.source;
|
|
31
|
+
return source !== void 0 && resolveMeasure(model, source, id) !== void 0;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A name that is no field of the model. A measure the asker may read (`offer`) is said to be
|
|
35
|
+
* one: it is in the model, so "not a field" would read as a typo that is not there. Any other
|
|
36
|
+
* name is offered the field it most likely meant.
|
|
37
|
+
*/
|
|
38
|
+
function missing(model, named, offer) {
|
|
39
|
+
if (isMeasure(model, named.id) && offer(named.id)) return issue(named.path, `"${named.id}" is a measure, and a filter narrows by a dimension: a field of the rows themselves.`);
|
|
40
|
+
return issue(named.path, `"${named.id}" is not a field of the model.${meantField(model, named.id, offer)}`);
|
|
41
|
+
}
|
|
42
|
+
/** A value type in a message: what a field of it is. */
|
|
43
|
+
const valueWords = {
|
|
44
|
+
string: "a string",
|
|
45
|
+
number: "a number",
|
|
46
|
+
boolean: "a boolean",
|
|
47
|
+
time: "a time"
|
|
48
|
+
};
|
|
49
|
+
/** What is wrong with one more field of a control, given the fields named before it. */
|
|
50
|
+
function alsoIssue(named, field, before) {
|
|
51
|
+
const covers = before.covered.get(field.source);
|
|
52
|
+
if (covers !== void 0) return issue(named.path, `"${named.id}" is on "${field.source}", which "${covers}" already covers: a tile on "${field.source}" would never use it.`);
|
|
53
|
+
if (before.type === void 0 || before.type === field.type) return;
|
|
54
|
+
return issue(named.path, `"${named.id}" is ${valueWords[field.type]}, and "${before.first}" is ${valueWords[before.type]}: one pick cannot narrow both.`);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* What is wrong with one filter control's fields, at `path`. Each field is read from the model
|
|
58
|
+
* once, and the sources covered so far are kept by name, so a control over many sources costs
|
|
59
|
+
* as many lookups as it names fields.
|
|
60
|
+
*/
|
|
61
|
+
function filterIssues(model, control, path, offer) {
|
|
62
|
+
const own = fieldOf(model, control.member);
|
|
63
|
+
const issues = own === void 0 ? [missing(model, {
|
|
64
|
+
id: control.member,
|
|
65
|
+
path: [...path, "member"]
|
|
66
|
+
}, offer)] : [];
|
|
67
|
+
const covered = new Map(own === void 0 ? [] : [[own.source, control.member]]);
|
|
68
|
+
const before = {
|
|
69
|
+
first: control.member,
|
|
70
|
+
type: own?.type,
|
|
71
|
+
covered
|
|
72
|
+
};
|
|
73
|
+
for (const [at, id] of (control.also ?? []).entries()) {
|
|
74
|
+
const named = {
|
|
75
|
+
id,
|
|
76
|
+
path: [
|
|
77
|
+
...path,
|
|
78
|
+
"also",
|
|
79
|
+
at
|
|
80
|
+
]
|
|
81
|
+
};
|
|
82
|
+
const field = fieldOf(model, id);
|
|
83
|
+
const found = field === void 0 ? missing(model, named, offer) : alsoIssue(named, field, before);
|
|
84
|
+
if (found !== void 0) issues.push(found);
|
|
85
|
+
if (field !== void 0 && !covered.has(field.source)) covered.set(field.source, id);
|
|
86
|
+
}
|
|
87
|
+
return issues;
|
|
88
|
+
}
|
|
89
|
+
/** The most fields a typo is weighed against where each costs a question of the host: its nearest. */
|
|
90
|
+
const MOST_MEANT = 5;
|
|
91
|
+
/** The members a refusal of one name may offer: itself when it is a measure, else the fields nearest it. */
|
|
92
|
+
function offersOf(model, id) {
|
|
93
|
+
if (fieldOf(model, id) !== void 0) return [];
|
|
94
|
+
return isMeasure(model, id) ? [id] : nearTo(id, shownFields(model, id)).slice(0, MOST_MEANT);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The members a refusal of these controls' fields could name: for each name that is no field,
|
|
98
|
+
* the name itself when it is a measure, and the five fields nearest a typo. A caller whose
|
|
99
|
+
* `offer` asks its host asks about these alone, however many members the model has.
|
|
100
|
+
* `controlFieldIssues` says the same with only these offered as with every member offered,
|
|
101
|
+
* unless the asker may read none of a typo's five nearest: then it offers no name.
|
|
102
|
+
*/
|
|
103
|
+
function controlFieldOffers(controls, model) {
|
|
104
|
+
const named = controls.flatMap((control) => control.kind === "filter" ? [control.member, ...control.also ?? []] : []);
|
|
105
|
+
return [...new Set(named.flatMap((id) => offersOf(model, id)))];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* What is wrong with a dashboard's filter controls against the model, each at its place in
|
|
109
|
+
* `controls`: a field the model does not have; a second field on a source one of the control's
|
|
110
|
+
* fields already covers, which no tile would ever use; and a field holding another type of
|
|
111
|
+
* value than the control's own, which one pick cannot narrow. A mistyped field is offered its
|
|
112
|
+
* nearest name only among fields `offer` allows: none by default.
|
|
113
|
+
*/
|
|
114
|
+
function controlFieldIssues(controls, model, offer = () => false) {
|
|
115
|
+
return controls.flatMap((control, at) => control.kind === "filter" ? filterIssues(model, control, [at], offer) : []);
|
|
116
|
+
}
|
|
117
|
+
export { controlFieldIssues, controlFieldOffers };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StoredQuery } from "../query/types.mjs";
|
|
2
|
+
import { ComparisonFields } from "./display.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* What a table's comparisons cannot be by its query alone, with no model: any at all when the
|
|
5
|
+
* query groups by nothing, since a comparison opens from a row's group; else a comparison by a
|
|
6
|
+
* field the query groups by, since a row's selection fixes it. `fixed` is the fields the query
|
|
7
|
+
* groups by, and `refused` each comparison key with one of them, in the order given.
|
|
8
|
+
*/
|
|
9
|
+
export type ByQuery = {
|
|
10
|
+
grouped: false;
|
|
11
|
+
} | {
|
|
12
|
+
grouped: true;
|
|
13
|
+
fixed: ReadonlySet<string>;
|
|
14
|
+
refused: readonly string[];
|
|
15
|
+
};
|
|
16
|
+
/** The comparisons a table's query alone refuses, as `ByQuery` says. */
|
|
17
|
+
export declare function comparisonsByQuery(query: StoredQuery | undefined, comparisons: Readonly<Record<string, ComparisonFields>>): ByQuery;
|
|
@@ -17,17 +17,28 @@ function authorHint(model, source, field, groups) {
|
|
|
17
17
|
const { fixed, choices } = groups;
|
|
18
18
|
return [fixed.has(field) ? "The table already groups by it." : fieldReason(model, source, field, choices), choices.length > 0 ? `Available fields: ${choices.join(", ")}.` : "The model offers no other breakdown fields."].filter(Boolean).join(" ");
|
|
19
19
|
}
|
|
20
|
+
/** The comparisons a table's query alone refuses, as `ByQuery` says. */
|
|
21
|
+
function comparisonsByQuery(query, comparisons) {
|
|
22
|
+
const groups = query?.dimensions ?? [];
|
|
23
|
+
if (groups.length === 0) return { grouped: false };
|
|
24
|
+
const fixed = new Set(groups.map((group) => group.member));
|
|
25
|
+
return {
|
|
26
|
+
grouped: true,
|
|
27
|
+
fixed,
|
|
28
|
+
refused: Object.keys(comparisons).filter((key) => (comparisons[key] ?? []).some((field) => fixed.has(field)))
|
|
29
|
+
};
|
|
30
|
+
}
|
|
20
31
|
/** A row's sealed selection fixes its grouping fields. Its comparison needs another breakdown field. */
|
|
21
32
|
function comparisonIssues(query, comparisons, model, options) {
|
|
22
33
|
const { path, author } = options;
|
|
23
|
-
const
|
|
24
|
-
if (!query ||
|
|
34
|
+
const byQuery = comparisonsByQuery(query, comparisons);
|
|
35
|
+
if (!query || !byQuery.grouped) return [{
|
|
25
36
|
code: "DISPLAY_INVALID",
|
|
26
37
|
path,
|
|
27
38
|
message: "A table with comparisons needs a grouping dimension in its main query."
|
|
28
39
|
}];
|
|
29
40
|
const offered = drillMembers(model, query.source, () => true);
|
|
30
|
-
const fixed =
|
|
41
|
+
const { fixed } = byQuery;
|
|
31
42
|
const choices = offered.filter((field) => !fixed.has(field));
|
|
32
43
|
return Object.entries(comparisons).flatMap(([key, fields]) => fields.flatMap((field, index) => {
|
|
33
44
|
if (choices.includes(field)) return [];
|
|
@@ -46,4 +57,4 @@ function comparisonIssues(query, comparisons, model, options) {
|
|
|
46
57
|
};
|
|
47
58
|
}));
|
|
48
59
|
}
|
|
49
|
-
export { comparisonIssues };
|
|
60
|
+
export { comparisonIssues, comparisonsByQuery };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EntryId, StoredQuery } from "../query/types.mjs";
|
|
2
|
+
import { Widget } from "./types.mjs";
|
|
3
|
+
/** Whether an option of a kind names values of the widget's query: a measure or a calc. */
|
|
4
|
+
export declare const namesValues: (kind: string, option: string) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The entries of a query an option's value names, by their own ids, in the order named; a name
|
|
7
|
+
* the query does not have is left out. Names are read by `entryNamed`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function entriesNamed(query: StoredQuery | undefined, value: unknown): EntryId[];
|
|
10
|
+
/**
|
|
11
|
+
* The options of a widget's display that name what is no value of its query, each by its name
|
|
12
|
+
* once: what an editor drops before it saves, so it never saves a display this check refuses.
|
|
13
|
+
*/
|
|
14
|
+
export declare const refusedDisplayOptions: (widget: Widget) => string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { entryAliases } from "../query/to-wire.mjs";
|
|
1
|
+
import { entryAliases, entryNamed } from "../query/to-wire.mjs";
|
|
2
2
|
// src/document/display-entries.ts
|
|
3
3
|
/** The options of each kind that name values of the widget's query. */
|
|
4
4
|
const NAMES_VALUES = {
|
|
@@ -6,26 +6,37 @@ const NAMES_VALUES = {
|
|
|
6
6
|
table: ["bars", "heat"],
|
|
7
7
|
bar: ["against"]
|
|
8
8
|
};
|
|
9
|
+
/** The options of a kind that name values; none for a host's own kind. */
|
|
10
|
+
const valueOptions = (kind) => Object.hasOwn(NAMES_VALUES, kind) ? NAMES_VALUES[kind] ?? [] : [];
|
|
11
|
+
/** Whether an option of a kind names values of the widget's query: a measure or a calc. */
|
|
12
|
+
const namesValues = (kind, option) => valueOptions(kind).includes(option);
|
|
9
13
|
/** The names an option holds: its text, or each text of its list; none for a value of another type, which its type check refuses. */
|
|
10
14
|
function namesIn(value) {
|
|
11
15
|
if (typeof value === "string") return [value];
|
|
12
16
|
return Array.isArray(value) ? value.filter((name) => typeof name === "string") : [];
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
19
|
+
* The entries of a query an option's value names, by their own ids, in the order named; a name
|
|
20
|
+
* the query does not have is left out. Names are read by `entryNamed`.
|
|
21
|
+
*/
|
|
22
|
+
function entriesNamed(query, value) {
|
|
23
|
+
if (query === void 0) return [];
|
|
24
|
+
return namesIn(value).flatMap((name) => entryNamed(query, name) ?? []);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
15
27
|
* The names a display may give a value of the widget's query: each measure and calc by its
|
|
16
|
-
* own id, and by the id its column has in an answer (m1, c1). A name is read as
|
|
17
|
-
* reads it
|
|
18
|
-
* value.
|
|
28
|
+
* own id, and by the id its column has in an answer (m1, c1). A name is read as `entryNamed`
|
|
29
|
+
* reads it, so a group whose own id is "m1" is that group, and no value.
|
|
19
30
|
*/
|
|
20
31
|
function valuesOf(widget) {
|
|
21
32
|
const query = widget.queries["main"];
|
|
22
33
|
if (query === void 0) return void 0;
|
|
23
34
|
const ids = [...query.measures, ...query.calc ?? []].map((entry) => entry.id);
|
|
24
35
|
const aliases = entryAliases(query);
|
|
25
|
-
const answered =
|
|
36
|
+
const answered = ids.flatMap((id) => aliases.get(id) ?? []);
|
|
26
37
|
return {
|
|
27
|
-
has: (name) =>
|
|
28
|
-
names: [...ids, ...answered]
|
|
38
|
+
has: (name) => ids.includes(entryNamed(query, name) ?? ""),
|
|
39
|
+
names: [.../* @__PURE__ */ new Set([...ids, ...answered])]
|
|
29
40
|
};
|
|
30
41
|
}
|
|
31
42
|
/**
|
|
@@ -38,7 +49,7 @@ function displayEntryIssues(widget, path) {
|
|
|
38
49
|
const known = valuesOf(widget);
|
|
39
50
|
const display = widget.display;
|
|
40
51
|
if (known === void 0 || typeof display !== "object" || display === null) return [];
|
|
41
|
-
const options =
|
|
52
|
+
const options = valueOptions(widget.kind);
|
|
42
53
|
const held = { ...display };
|
|
43
54
|
return options.flatMap((option) => namesIn(held[option]).filter((name) => !known.has(name)).map((name) => ({
|
|
44
55
|
code: "DISPLAY_INVALID",
|
|
@@ -46,4 +57,9 @@ function displayEntryIssues(widget, path) {
|
|
|
46
57
|
path: [...path, option]
|
|
47
58
|
})));
|
|
48
59
|
}
|
|
49
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The options of a widget's display that name what is no value of its query, each by its name
|
|
62
|
+
* once: what an editor drops before it saves, so it never saves a display this check refuses.
|
|
63
|
+
*/
|
|
64
|
+
const refusedDisplayOptions = (widget) => [...new Set(displayEntryIssues(widget, []).map((issue) => String(issue.path[0])))];
|
|
65
|
+
export { displayEntryIssues, entriesNamed, namesValues, refusedDisplayOptions };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Model } from "../model/types.mjs";
|
|
2
2
|
import { Issue } from "../types/primitives.mjs";
|
|
3
3
|
import { Doc } from "./types.mjs";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Check each widget's options, a code dashboard's at start: strictly, so an option a built-in
|
|
6
|
+
* kind does not take is named too. A host with a model also checks the drill fields its rows
|
|
7
|
+
* can open. An edit (`editedDisplayIssues`) leaves an unknown option alone.
|
|
8
|
+
*/
|
|
5
9
|
export declare function documentDisplayIssues(doc: Doc, model?: Model): Issue[];
|
|
6
10
|
/**
|
|
7
11
|
* What an edit did wrong to a display: each option of the wrong type that the edit set or
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { canonical } from "../value/canonical.mjs";
|
|
2
|
-
import { displayIssues, displayOf, isRecord } from "./display.mjs";
|
|
2
|
+
import { displayIssues, displayOf, isRecord, unknownDisplayIssues } from "./display.mjs";
|
|
3
3
|
import { comparisonIssues } from "./display-comparisons.mjs";
|
|
4
4
|
import { displayEntryIssues } from "./display-entries.mjs";
|
|
5
5
|
// src/document/display-validation.ts
|
|
@@ -17,13 +17,20 @@ function widgetDisplayIssues(widget, path, model, author = false) {
|
|
|
17
17
|
author
|
|
18
18
|
})];
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Check each widget's options, a code dashboard's at start: strictly, so an option a built-in
|
|
22
|
+
* kind does not take is named too. A host with a model also checks the drill fields its rows
|
|
23
|
+
* can open. An edit (`editedDisplayIssues`) leaves an unknown option alone.
|
|
24
|
+
*/
|
|
21
25
|
function documentDisplayIssues(doc, model) {
|
|
22
|
-
return Object.entries(doc.widgets).flatMap(([id, widget]) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
return Object.entries(doc.widgets).flatMap(([id, widget]) => {
|
|
27
|
+
const path = [
|
|
28
|
+
"widgets",
|
|
29
|
+
id,
|
|
30
|
+
"display"
|
|
31
|
+
];
|
|
32
|
+
return [...unknownDisplayIssues(widget.kind, widget.display, path), ...widgetDisplayIssues(widget, path, model, true)];
|
|
33
|
+
});
|
|
27
34
|
}
|
|
28
35
|
/** An option as an object holds it: none when it has no such option, which is not the same as holding null. */
|
|
29
36
|
const held = (display, option) => Object.hasOwn(display, option) ? { is: display[option] ?? null } : null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/** The types an option may have. */
|
|
2
|
+
export type OptionType = "boolean" | "text" | "texts" | "colors" | "comparisons";
|
|
2
3
|
/** The first field groups the selected row; the second optionally groups its children. */
|
|
3
4
|
type DistinctPair<First extends string, All extends string = First> = First extends unknown ? readonly [First, Exclude<All, First>] : never;
|
|
4
5
|
export type ComparisonFields<Field extends string = string> = readonly [Field] | (string extends Field ? readonly [Field, Field] : DistinctPair<Field>);
|
|
@@ -8,11 +9,15 @@ declare const SHARED: {
|
|
|
8
9
|
readonly keepDateRange: "boolean";
|
|
9
10
|
readonly empty: "text";
|
|
10
11
|
};
|
|
12
|
+
/** The names of the options every widget takes, a host's own kind's too. */
|
|
13
|
+
export declare const SHARED_OPTIONS: readonly string[];
|
|
11
14
|
/** The options of each kind of widget the library draws, and each option's type. */
|
|
12
15
|
export declare const DISPLAY_OPTIONS: {
|
|
13
16
|
readonly number: {
|
|
14
17
|
readonly value: "text";
|
|
15
18
|
readonly secondary: "text";
|
|
19
|
+
readonly full: "boolean";
|
|
20
|
+
readonly colors: "colors";
|
|
16
21
|
readonly keepDateRange: "boolean";
|
|
17
22
|
readonly empty: "text";
|
|
18
23
|
};
|
|
@@ -21,6 +26,7 @@ export declare const DISPLAY_OPTIONS: {
|
|
|
21
26
|
readonly heat: "texts";
|
|
22
27
|
readonly compact: "boolean";
|
|
23
28
|
readonly comparisons: "comparisons";
|
|
29
|
+
readonly full: "boolean";
|
|
24
30
|
readonly keepDateRange: "boolean";
|
|
25
31
|
readonly empty: "text";
|
|
26
32
|
};
|
|
@@ -65,17 +71,14 @@ export declare const DISPLAY_OPTIONS: {
|
|
|
65
71
|
readonly empty: "text";
|
|
66
72
|
};
|
|
67
73
|
};
|
|
68
|
-
/** What each option does, for the builder and for an agent reading a tool definition. */
|
|
69
|
-
export declare const DISPLAY_HELP: Readonly<Record<string, string>>;
|
|
70
74
|
/** A kind of widget the library draws. A host's own kind is not here: its options are its own. */
|
|
71
75
|
export type DisplayKind = keyof typeof DISPLAY_OPTIONS;
|
|
76
|
+
/** The name of an option of any kind of widget the library draws, the shared ones among them. */
|
|
77
|
+
export type DisplayOptionName = { [K in DisplayKind]: keyof (typeof DISPLAY_OPTIONS)[K]; }[DisplayKind];
|
|
72
78
|
/** The options a kind of widget reads, each of its type. */
|
|
73
79
|
export type DisplayOf<K extends DisplayKind, Field extends string = string> = { readonly [P in keyof (typeof DISPLAY_OPTIONS)[K]]?: ValueOf<(typeof DISPLAY_OPTIONS)[K][P], Field>; };
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
* path. None for a kind the library does not draw, and none for an option it does not know.
|
|
77
|
-
*/
|
|
78
|
-
export declare function displayIssues(kind: string, display: unknown, path?: Issue["path"]): Issue[];
|
|
80
|
+
/** The options a kind takes, each with its type: a host's own kind takes the ones every kind does. */
|
|
81
|
+
export declare const displayOptionsOf: (kind: string) => Readonly<Record<string, OptionType>>;
|
|
79
82
|
/**
|
|
80
83
|
* A widget's options as its kind reads them: each option it knows, when it is of its type. A
|
|
81
84
|
* stored option of the wrong type (written before options were checked, or by hand) is left
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { didYouMean } from "../model/validate/fields.mjs";
|
|
1
2
|
// src/document/display.ts
|
|
2
3
|
/** Options every widget takes. */
|
|
3
4
|
const SHARED = {
|
|
@@ -8,19 +9,24 @@ const CHART = {
|
|
|
8
9
|
...SHARED,
|
|
9
10
|
colors: "colors"
|
|
10
11
|
};
|
|
12
|
+
/** The names of the options every widget takes, a host's own kind's too. */
|
|
13
|
+
const SHARED_OPTIONS = Object.keys(SHARED);
|
|
11
14
|
/** The options of each kind of widget the library draws, and each option's type. */
|
|
12
15
|
const DISPLAY_OPTIONS = {
|
|
13
16
|
number: {
|
|
14
17
|
...SHARED,
|
|
15
18
|
value: "text",
|
|
16
|
-
secondary: "text"
|
|
19
|
+
secondary: "text",
|
|
20
|
+
full: "boolean",
|
|
21
|
+
colors: "colors"
|
|
17
22
|
},
|
|
18
23
|
table: {
|
|
19
24
|
...SHARED,
|
|
20
25
|
bars: "texts",
|
|
21
26
|
heat: "texts",
|
|
22
27
|
compact: "boolean",
|
|
23
|
-
comparisons: "comparisons"
|
|
28
|
+
comparisons: "comparisons",
|
|
29
|
+
full: "boolean"
|
|
24
30
|
},
|
|
25
31
|
list: {
|
|
26
32
|
...SHARED,
|
|
@@ -52,6 +58,7 @@ const DISPLAY_HELP = {
|
|
|
52
58
|
empty: "What the tile says when its answer has no rows.",
|
|
53
59
|
value: "The query entry a number tile shows large. Without it: a calc when the query has one, else its first value.",
|
|
54
60
|
secondary: "A query entry a number tile shows as a second, smaller figure under the number, beside its label.",
|
|
61
|
+
full: "Write amounts in full: a number tile's large value, and a table's column of amounts that are all a thousand or more, are otherwise rounded to whole units.",
|
|
55
62
|
bars: "Query entries drawn with a bar in each cell, as long as the value is beside the column's largest.",
|
|
56
63
|
heat: "Query entries whose cells are shaded by their value, darker for more.",
|
|
57
64
|
comparisons: "For a value of the first grouping column, name the drill field for its comparison table and optionally the field to expand each group by.",
|
|
@@ -101,6 +108,8 @@ function usable(type, value) {
|
|
|
101
108
|
function optionsOf(kind) {
|
|
102
109
|
return Object.hasOwn(DISPLAY_OPTIONS, kind) ? DISPLAY_OPTIONS[kind] : void 0;
|
|
103
110
|
}
|
|
111
|
+
/** The options a kind takes, each with its type: a host's own kind takes the ones every kind does. */
|
|
112
|
+
const displayOptionsOf = (kind) => optionsOf(kind) ?? SHARED;
|
|
104
113
|
/** The options a display sets that are not of their type, by name. */
|
|
105
114
|
function misfits(options, display) {
|
|
106
115
|
return Object.entries(options).filter(([name, type]) => display[name] !== void 0 && !TYPES[type].fits(display[name]));
|
|
@@ -133,6 +142,20 @@ function displayIssues(kind, display, path = []) {
|
|
|
133
142
|
});
|
|
134
143
|
}
|
|
135
144
|
/**
|
|
145
|
+
* Each option a display sets that its kind does not take, at its path, with the option it most
|
|
146
|
+
* likely meant. None for a kind the library does not draw: a host's own kind keeps its own.
|
|
147
|
+
*/
|
|
148
|
+
function unknownDisplayIssues(kind, display, path) {
|
|
149
|
+
const options = optionsOf(kind);
|
|
150
|
+
if (options === void 0 || !isRecord(display)) return [];
|
|
151
|
+
const known = Object.keys(options);
|
|
152
|
+
return Object.keys(display).filter((name) => !Object.hasOwn(options, name)).map((name) => ({
|
|
153
|
+
code: "DISPLAY_INVALID",
|
|
154
|
+
message: `A ${kind} has no option "${name}".${didYouMean(name, known)} Its options are ${known.join(", ")}.`,
|
|
155
|
+
path: [...path, name]
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
136
159
|
* A widget's options as its kind reads them: each option it knows, when it is of its type. A
|
|
137
160
|
* stored option of the wrong type (written before options were checked, or by hand) is left
|
|
138
161
|
* out, never guessed at, so a renderer needs no check of its own; of a map of colours, the
|
|
@@ -151,4 +174,4 @@ function read(options, display) {
|
|
|
151
174
|
}
|
|
152
175
|
/** The options every widget takes, whatever draws it: `keepDateRange` and `empty`, and no option of any one kind. */
|
|
153
176
|
const sharedDisplay = (display) => read(SHARED, display);
|
|
154
|
-
export { DISPLAY_HELP, DISPLAY_OPTIONS, displayIssues, displayOf, isRecord, sharedDisplay };
|
|
177
|
+
export { DISPLAY_HELP, DISPLAY_OPTIONS, SHARED_OPTIONS, displayIssues, displayOf, displayOptionsOf, isRecord, sharedDisplay, unknownDisplayIssues };
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { CommandBody,
|
|
1
|
+
import { CommandBody, LayoutItem, Tab } from "./types.mjs";
|
|
2
2
|
/** The grid is 12 columns wide; rows are as many as the widgets need. */
|
|
3
3
|
export declare const GRID_COLUMNS = 12;
|
|
4
|
+
/**
|
|
5
|
+
* The most characters a title holds: a dashboard's, a widget's, a tab's. Every command that
|
|
6
|
+
* sets a title refuses a longer one, and a field a title is typed in takes no more. A document
|
|
7
|
+
* read from storage or made in code is not held to it: what was once kept is not refused.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TITLE_MOST = 500;
|
|
4
10
|
/**
|
|
5
11
|
* A tab's layout with one item put at a place and size, the way a grid editor drags: it is
|
|
6
12
|
* fitted inside the grid. A move dropped onto other tiles swaps places with the one it covers
|
|
@@ -41,11 +47,4 @@ export declare function closeGapsCommands(tab: Tab): Extract<CommandBody, {
|
|
|
41
47
|
export declare function freeSpot(layout: readonly LayoutItem[], size: {
|
|
42
48
|
w: number;
|
|
43
49
|
h: number;
|
|
44
|
-
}): Omit<LayoutItem, "widget">;
|
|
45
|
-
/**
|
|
46
|
-
* A saved layout as it can be drawn. Each widget appears once: an item for a missing widget,
|
|
47
|
-
* or a second item for one already placed, is dropped. Sizes are whole grid units inside the
|
|
48
|
-
* grid. Overlapping items move down. A widget on no tab is added under the last tab's widgets,
|
|
49
|
-
* so a repair never hides one. Nothing else changes, and a valid layout is returned as it was.
|
|
50
|
-
*/
|
|
51
|
-
export declare function repairLayout(doc: Doc): Doc;
|
|
50
|
+
}): Omit<LayoutItem, "widget">;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
// src/document/layout.ts
|
|
2
2
|
/** The grid is 12 columns wide; rows are as many as the widgets need. */
|
|
3
3
|
const GRID_COLUMNS = 12;
|
|
4
|
+
/**
|
|
5
|
+
* The most characters a title holds: a dashboard's, a widget's, a tab's. Every command that
|
|
6
|
+
* sets a title refuses a longer one, and a field a title is typed in takes no more. A document
|
|
7
|
+
* read from storage or made in code is not held to it: what was once kept is not refused.
|
|
8
|
+
*/
|
|
9
|
+
const TITLE_MOST = 500;
|
|
4
10
|
const MAX_HEIGHT = 48;
|
|
11
|
+
/** A widget on no tab is placed at a size by its kind: a number is small, anything else half the width. */
|
|
5
12
|
const ORPHAN = {
|
|
6
13
|
w: 6,
|
|
7
14
|
h: 4
|
|
8
15
|
};
|
|
16
|
+
const NUMBER_TILE = {
|
|
17
|
+
w: 3,
|
|
18
|
+
h: 2
|
|
19
|
+
};
|
|
9
20
|
const clamp = (n, low, high) => Math.min(Math.max(Math.trunc(n), low), high);
|
|
10
21
|
function overlaps(a, b) {
|
|
11
22
|
return a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
|
|
@@ -211,11 +222,17 @@ function repairLayout(doc) {
|
|
|
211
222
|
tabs
|
|
212
223
|
};
|
|
213
224
|
const bottom = Math.max(0, ...last.layout.map((i) => i.y + i.h));
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
225
|
+
const placed = [];
|
|
226
|
+
for (const widget of orphans) {
|
|
227
|
+
const size = doc.widgets[widget]?.kind === "number" ? NUMBER_TILE : ORPHAN;
|
|
228
|
+
placed.push({
|
|
229
|
+
widget,
|
|
230
|
+
...freeSpot(placed, size)
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const added = placed.map((item) => ({
|
|
234
|
+
...item,
|
|
235
|
+
y: bottom + item.y
|
|
219
236
|
}));
|
|
220
237
|
return {
|
|
221
238
|
...doc,
|
|
@@ -225,4 +242,4 @@ function repairLayout(doc) {
|
|
|
225
242
|
}]
|
|
226
243
|
};
|
|
227
244
|
}
|
|
228
|
-
export { GRID_COLUMNS, closeGaps, closeGapsCommands, compact, freeSpot, layoutGaps, overlaps, packInto, placeItem, repairLayout };
|
|
245
|
+
export { GRID_COLUMNS, TITLE_MOST, closeGaps, closeGapsCommands, compact, freeSpot, layoutGaps, overlaps, packInto, placeItem, repairLayout };
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { CommandBody, LayoutItem, Tab } from "./types.mjs";
|
|
2
2
|
/** Top to bottom, then left to right: the order tiles stack in on a narrow screen. */
|
|
3
3
|
export declare function readingOrder(layout: readonly LayoutItem[]): LayoutItem[];
|
|
4
|
-
/**
|
|
5
|
-
* The moves that pass a tile over its neighbour in reading order, `by` one place up (-1) or
|
|
6
|
-
* down (1), and change nothing else about the order: the first of a few ways to do it, by
|
|
7
|
-
* the rule a drag follows, whose result stacks exactly so. None at an end. Where no single
|
|
8
|
-
* way gives exactly that order (tiles of other sizes beside them on a row), the nearest one.
|
|
9
|
-
*/
|
|
10
|
-
export declare function stepMoves(layout: readonly LayoutItem[], widget: string, by: -1 | 1): LayoutItem[];
|
|
11
4
|
/** `stepMoves` as the `widget.move` commands of one edit. */
|
|
12
5
|
export declare function stepCommands(tab: Tab, widget: string, by: -1 | 1): Extract<CommandBody, {
|
|
13
6
|
type: "widget.move";
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// src/document/types.ts
|
|
2
|
+
/** A document's first tab, empty: what a new document has, and a document written with no tabs. */
|
|
3
|
+
const firstTab = () => ({
|
|
4
|
+
id: "main",
|
|
5
|
+
title: "Overview",
|
|
6
|
+
layout: []
|
|
7
|
+
});
|
|
2
8
|
function emptyDoc(title) {
|
|
3
9
|
return {
|
|
4
10
|
specVersion: 1,
|
|
5
11
|
meta: { title },
|
|
6
|
-
tabs: [
|
|
7
|
-
id: "main",
|
|
8
|
-
title: "Overview",
|
|
9
|
-
layout: []
|
|
10
|
-
}],
|
|
12
|
+
tabs: [firstTab()],
|
|
11
13
|
widgets: {},
|
|
12
14
|
controls: [],
|
|
13
15
|
scope: { bySource: {} }
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
|
-
export { emptyDoc };
|
|
18
|
+
export { emptyDoc, firstTab };
|
|
@@ -21,5 +21,6 @@ export type Loaded = {
|
|
|
21
21
|
* A stored document as this version reads it: brought up to the current spec version one step
|
|
22
22
|
* at a time, checked against the schema, and its layout repaired. A document a newer library
|
|
23
23
|
* wrote is refused (DOCUMENT_TOO_NEW), never guessed at; an invalid one returns every problem.
|
|
24
|
+
* One written with no specVersion is at the current one, as the schema defaults it.
|
|
24
25
|
*/
|
|
25
26
|
export declare function loadDocument(raw: unknown, upgrades?: readonly Upgrade[]): Loaded;
|
|
@@ -10,9 +10,11 @@ const isRecord = (value) => typeof value === "object" && value !== null && !Arra
|
|
|
10
10
|
* A stored document as this version reads it: brought up to the current spec version one step
|
|
11
11
|
* at a time, checked against the schema, and its layout repaired. A document a newer library
|
|
12
12
|
* wrote is refused (DOCUMENT_TOO_NEW), never guessed at; an invalid one returns every problem.
|
|
13
|
+
* One written with no specVersion is at the current one, as the schema defaults it.
|
|
13
14
|
*/
|
|
14
15
|
function loadDocument(raw, upgrades = DOCUMENT_UPGRADES) {
|
|
15
|
-
|
|
16
|
+
const given = isRecord(raw) ? raw["specVersion"] ?? 1 : void 0;
|
|
17
|
+
if (!isRecord(raw) || typeof given !== "number") return {
|
|
16
18
|
ok: false,
|
|
17
19
|
issues: [{
|
|
18
20
|
code: "DOCUMENT_INVALID",
|
|
@@ -21,7 +23,7 @@ function loadDocument(raw, upgrades = DOCUMENT_UPGRADES) {
|
|
|
21
23
|
}]
|
|
22
24
|
};
|
|
23
25
|
let doc = raw;
|
|
24
|
-
let version =
|
|
26
|
+
let version = given;
|
|
25
27
|
if (version > 1) return {
|
|
26
28
|
ok: false,
|
|
27
29
|
issues: [{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EngineError } from "../error/refusal.mjs";
|
|
2
|
-
import { policyBinding, tenantBinding, tenantKeys } from "../model/defaults.mjs";
|
|
2
|
+
import { policyBinding, tenantBinding, tenantEntry, tenantKeys } from "../model/defaults.mjs";
|
|
3
3
|
import { bindPolicy, grantsNothingYet, namedPolicy } from "../policy/bind.mjs";
|
|
4
4
|
import { isBound } from "../query/filter.mjs";
|
|
5
5
|
import { principalTenant } from "../types/viewer.mjs";
|
|
@@ -38,8 +38,8 @@ const tenantTerms = (input, name) => {
|
|
|
38
38
|
return tenantKeys(input.model).map((key) => ({
|
|
39
39
|
kind: "tenant",
|
|
40
40
|
key,
|
|
41
|
-
column: tenant.columns
|
|
42
|
-
value: values
|
|
41
|
+
column: tenantEntry(tenant.columns, key) ?? "",
|
|
42
|
+
value: tenantEntry(values, key) ?? ""
|
|
43
43
|
}));
|
|
44
44
|
};
|
|
45
45
|
const policyTerms = (input, name) => {
|
|
@@ -80,12 +80,14 @@ function checkTenant(model, name, terms, ctx) {
|
|
|
80
80
|
}
|
|
81
81
|
for (const key of model.tenant?.keys ?? []) if (!hasTenantKey(terms, {
|
|
82
82
|
key,
|
|
83
|
-
column: tenant.columns
|
|
83
|
+
column: own(tenant.columns, key),
|
|
84
84
|
principal: ctx.principal
|
|
85
85
|
})) fail(`the tenant "${key}" on "${name}"`);
|
|
86
86
|
}
|
|
87
|
+
/** A tenant record's own entry: a key named `toString` is never the inherited function. */
|
|
88
|
+
const own = (record, key) => Object.hasOwn(record, key) ? record[key] : void 0;
|
|
87
89
|
function hasTenantKey(terms, want) {
|
|
88
|
-
const value = principalTenant(want.principal)
|
|
90
|
+
const value = own(principalTenant(want.principal), want.key) ?? "";
|
|
89
91
|
return value !== "" && terms.some((t) => t.kind === "tenant" && t.key === want.key && t.column === want.column && t.value === value);
|
|
90
92
|
}
|
|
91
93
|
function checkPolicy(model, name, terms, ctx) {
|