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
|
@@ -14,17 +14,34 @@ function parseMemberId(id) {
|
|
|
14
14
|
name: third
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
/** The id of a source's own member: the one place a member id is written from its parts. */
|
|
18
|
+
const memberIdOf = (source, name) => `${source}.${name}`;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a member id is on `source`: it starts with the source's name and a point. It says
|
|
21
|
+
* nothing of whether the member exists; it only spares parsing an id that cannot be the
|
|
22
|
+
* source's, where one is sought among many.
|
|
23
|
+
*/
|
|
24
|
+
const isOnSource = (id, source) => id.startsWith(source) && id.charAt(source.length) === ".";
|
|
25
|
+
/**
|
|
26
|
+
* The entry a name from outside the model names in one of its maps: only the map's own, so
|
|
27
|
+
* `toString`, `constructor` or `__proto__` never reads what every object inherits.
|
|
28
|
+
*/
|
|
29
|
+
function ownEntry(map, name) {
|
|
30
|
+
return map !== void 0 && Object.hasOwn(map, name) ? map[name] : void 0;
|
|
31
|
+
}
|
|
32
|
+
/** The source a name from outside the model names; none for a name the model does not have. */
|
|
33
|
+
const sourceOf = (model, name) => ownEntry(model.sources, name);
|
|
17
34
|
function ownDimension(model, source, name) {
|
|
18
|
-
const dimension = model
|
|
35
|
+
const dimension = ownEntry(sourceOf(model, source)?.dimensions, name);
|
|
19
36
|
return dimension === void 0 ? void 0 : {
|
|
20
37
|
source,
|
|
21
38
|
dimension
|
|
22
39
|
};
|
|
23
40
|
}
|
|
24
41
|
function joinedDimension(model, source, join, name) {
|
|
25
|
-
const def = model
|
|
42
|
+
const def = ownEntry(sourceOf(model, source)?.joins, join);
|
|
26
43
|
if (def === void 0 || def.relationship === "one_to_many") return void 0;
|
|
27
|
-
const dimension = model
|
|
44
|
+
const dimension = ownEntry(sourceOf(model, def.to)?.dimensions, name);
|
|
28
45
|
return dimension === void 0 ? void 0 : {
|
|
29
46
|
source: def.to,
|
|
30
47
|
join,
|
|
@@ -32,6 +49,16 @@ function joinedDimension(model, source, join, name) {
|
|
|
32
49
|
};
|
|
33
50
|
}
|
|
34
51
|
/**
|
|
52
|
+
* The type of value a dimension holds, the one owner of it: a number, a boolean or a time as
|
|
53
|
+
* declared, an expression as its `type`, and text for the rest (a string, a ref to a joined
|
|
54
|
+
* label, a bucket's labels).
|
|
55
|
+
*/
|
|
56
|
+
function dimensionValueType(def) {
|
|
57
|
+
if (def.kind === "number" || def.kind === "boolean" || def.kind === "time") return def.kind;
|
|
58
|
+
if (def.kind === "expr") return def.type;
|
|
59
|
+
return "string";
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
35
62
|
* The dimension a member id names, seen from `sourceName`: own, or one hop through a join
|
|
36
63
|
* that reaches at most one row. Undefined when it does not exist.
|
|
37
64
|
*/
|
|
@@ -44,7 +71,7 @@ function resolveDimension(model, sourceName, id) {
|
|
|
44
71
|
function resolveMeasure(model, sourceName, id) {
|
|
45
72
|
const ref = parseMemberId(id);
|
|
46
73
|
if (ref === void 0 || ref.source !== sourceName || ref.join !== void 0) return void 0;
|
|
47
|
-
return model
|
|
74
|
+
return ownEntry(sourceOf(model, sourceName)?.measures, ref.name);
|
|
48
75
|
}
|
|
49
76
|
/** A dimension's place in a default records view: text first, then time, then the rest. */
|
|
50
77
|
function shownRank(def, isTime) {
|
|
@@ -61,7 +88,7 @@ const DEFAULT_RECORD_COLUMNS = 12;
|
|
|
61
88
|
* records endpoint and a drill's Items.
|
|
62
89
|
*/
|
|
63
90
|
function recordDimensions(model, sourceName) {
|
|
64
|
-
const def = model
|
|
91
|
+
const def = sourceOf(model, sourceName);
|
|
65
92
|
if (def === void 0) return [];
|
|
66
93
|
const title = def.records?.title;
|
|
67
94
|
const named = title !== void 0 && def.dimensions[title] !== void 0 ? title : void 0;
|
|
@@ -76,4 +103,4 @@ function recordDimensions(model, sourceName) {
|
|
|
76
103
|
* check holds a merge to the measure's kind, so this is true only of a count or a sum.
|
|
77
104
|
*/
|
|
78
105
|
const mergesBySum = (def) => def.merge === "sum";
|
|
79
|
-
export { mergesBySum, parseMemberId, recordDimensions, resolveDimension, resolveMeasure };
|
|
106
|
+
export { dimensionValueType, isOnSource, memberIdOf, mergesBySum, ownEntry, parseMemberId, recordDimensions, resolveDimension, resolveMeasure, sourceOf };
|
|
@@ -1,17 +1,49 @@
|
|
|
1
|
-
import { resolveMeasure } from "./member.mjs";
|
|
1
|
+
import { resolveDimension, resolveMeasure } from "./member.mjs";
|
|
2
2
|
import { exprLinearTerms } from "./validate/expr.mjs";
|
|
3
3
|
// src/model/storage.ts
|
|
4
|
-
function
|
|
4
|
+
function exactOf(model, source, def) {
|
|
5
5
|
if (def.kind === "ratio") {
|
|
6
6
|
const measures = model.sources[source]?.measures ?? {};
|
|
7
7
|
return [def.numerator, def.denominator].flatMap((name) => {
|
|
8
8
|
const operand = measures[name];
|
|
9
|
-
return operand === void 0 ? [] :
|
|
9
|
+
return operand === void 0 ? [] : exactOf(model, source, operand);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
if (def.kind === "count" || def.kind === "percentile") return [];
|
|
13
|
-
|
|
14
|
-
return exprLinearTerms(def.of).map((t) =>
|
|
12
|
+
if (def.kind === "count" || def.kind === "percentile" || def.numeric === "float") return [];
|
|
13
|
+
const numeric = def.numeric;
|
|
14
|
+
return exprLinearTerms(def.of).map((t) => ({
|
|
15
|
+
kind: "exact",
|
|
16
|
+
column: t.column,
|
|
17
|
+
numeric
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
function timeOf(model, query) {
|
|
21
|
+
if (query.time === void 0) return [];
|
|
22
|
+
const resolved = resolveDimension(model, query.source, query.time.dimension);
|
|
23
|
+
if (resolved?.join !== void 0 || resolved?.dimension.kind !== "time") return [];
|
|
24
|
+
return [{
|
|
25
|
+
kind: "time",
|
|
26
|
+
column: resolved.dimension.column,
|
|
27
|
+
storage: resolved.dimension.storage
|
|
28
|
+
}];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The stored columns a query reads by their storage, each once, in the one order every engine
|
|
32
|
+
* counts them in: its time dimension's column, then each exact measure's columns. A value of
|
|
33
|
+
* one of them that does not read is left out of the answer and counted (`Unread`).
|
|
34
|
+
*/
|
|
35
|
+
function readColumns(model, query) {
|
|
36
|
+
const exact = query.measures.flatMap((m) => {
|
|
37
|
+
const def = resolveMeasure(model, query.source, m.measure);
|
|
38
|
+
return def === void 0 ? [] : exactOf(model, query.source, def);
|
|
39
|
+
});
|
|
40
|
+
const seen = /* @__PURE__ */ new Set();
|
|
41
|
+
return [...timeOf(model, query), ...exact].filter((c) => {
|
|
42
|
+
const id = `${c.kind} ${c.column}`;
|
|
43
|
+
if (seen.has(id)) return false;
|
|
44
|
+
seen.add(id);
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
15
47
|
}
|
|
16
48
|
/**
|
|
17
49
|
* The `decimal` columns a query's exact measures read. A Postgres `numeric` column can hold
|
|
@@ -19,10 +51,6 @@ function decimalOf(model, source, def) {
|
|
|
19
51
|
* filtered rows and refuses with NUMERIC_STORAGE before any answer is returned.
|
|
20
52
|
*/
|
|
21
53
|
function decimalColumns(model, query) {
|
|
22
|
-
|
|
23
|
-
const def = resolveMeasure(model, query.source, m.measure);
|
|
24
|
-
return def === void 0 ? [] : decimalOf(model, query.source, def);
|
|
25
|
-
});
|
|
26
|
-
return [...new Set(columns)];
|
|
54
|
+
return readColumns(model, query).flatMap((c) => c.kind === "exact" && c.numeric.stored === "decimal" ? [c.column] : []);
|
|
27
55
|
}
|
|
28
|
-
export { decimalColumns };
|
|
56
|
+
export { decimalColumns, readColumns };
|
|
@@ -140,6 +140,8 @@ export type SourceDef = SourceRelation & {
|
|
|
140
140
|
prefer: readonly string[];
|
|
141
141
|
};
|
|
142
142
|
};
|
|
143
|
+
/** Which way a measure's or a calc's change is for the better. */
|
|
144
|
+
export type Better = "higher" | "lower";
|
|
143
145
|
export type MemberMeta = {
|
|
144
146
|
label?: string;
|
|
145
147
|
description?: string;
|
|
@@ -161,7 +163,10 @@ export type Numeric = "float" | {
|
|
|
161
163
|
type OverColumn = {
|
|
162
164
|
of: Column | Expr;
|
|
163
165
|
where?: WireFilter;
|
|
164
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* `duration`: the values are seconds, shown as "3.7 days", "2 h". A measure over an `elapsed`
|
|
168
|
+
* alone is a duration without saying so, read in the microseconds it counts.
|
|
169
|
+
*/
|
|
165
170
|
format?: "duration";
|
|
166
171
|
/** Reserved for snapshot measures (the last value per partition). Refused by the model check until computed. */
|
|
167
172
|
partitionBy?: DimensionName;
|
|
@@ -170,6 +175,12 @@ type OverColumn = {
|
|
|
170
175
|
export type MeasureDef = MemberMeta & {
|
|
171
176
|
/** How partial results combine. `none` means they cannot be combined. */
|
|
172
177
|
merge: "sum" | "min" | "max" | "none";
|
|
178
|
+
/**
|
|
179
|
+
* Which way a change of it is for the better: more revenue is better, more churn is worse.
|
|
180
|
+
* A change is coloured only where this is said; the library never guesses it. A ratio's is
|
|
181
|
+
* its own, never its numerator's.
|
|
182
|
+
*/
|
|
183
|
+
better?: Better;
|
|
173
184
|
} & ({
|
|
174
185
|
kind: "count";
|
|
175
186
|
distinct?: Column;
|
|
@@ -234,6 +245,11 @@ export type DimensionDef = MemberMeta & DimensionHints & ({
|
|
|
234
245
|
expr: Expr;
|
|
235
246
|
type: "string" | "number" | "boolean";
|
|
236
247
|
});
|
|
248
|
+
/**
|
|
249
|
+
* `round` is to the nearest whole number, a half toward +∞ (JavaScript's `Math.round`): it is
|
|
250
|
+
* `floor(x)`, or `ceil(x)` when `x - floor(x) >= 0.5`, a difference that is exact in a double.
|
|
251
|
+
* Every engine writes it so; `floor(x + 0.5)` is not it, as that sum is itself rounded.
|
|
252
|
+
*/
|
|
237
253
|
export declare const EXPR_FUNCTIONS: readonly ["coalesce", "abs", "round", "length", "lower_fold"];
|
|
238
254
|
export type ExprFunction = (typeof EXPR_FUNCTIONS)[number];
|
|
239
255
|
export type DatePart = "year" | "quarter" | "month" | "week" | "day" | "hour" | "dow";
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
// src/model/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* `round` is to the nearest whole number, a half toward +∞ (JavaScript's `Math.round`): it is
|
|
4
|
+
* `floor(x)`, or `ceil(x)` when `x - floor(x) >= 0.5`, a difference that is exact in a double.
|
|
5
|
+
* Every engine writes it so; `floor(x + 0.5)` is not it, as that sum is itself rounded.
|
|
6
|
+
*/
|
|
2
7
|
const EXPR_FUNCTIONS = [
|
|
3
8
|
"coalesce",
|
|
4
9
|
"abs",
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { Expr } from "../types.mjs";
|
|
2
1
|
export type LinearTerm = {
|
|
3
2
|
coefficient: number;
|
|
4
3
|
column: string;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Reads an expression as c1*x1 + c2*x2 + ... with whole-number coefficients. Returns
|
|
8
|
-
* undefined when it is anything else.
|
|
9
|
-
*/
|
|
10
|
-
export declare function linearTerms(expr: Expr): LinearTerm[] | undefined;
|
|
4
|
+
};
|
|
@@ -17,17 +17,24 @@ function distance(a, b) {
|
|
|
17
17
|
}
|
|
18
18
|
return row[across.length] ?? 0;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The known fields a misspelled one may have meant, the likeliest first: each at most two edits
|
|
22
|
+
* away, and under half its letters.
|
|
23
|
+
*/
|
|
24
|
+
function nearTo(key, known) {
|
|
25
|
+
return known.map((name) => ({
|
|
23
26
|
name,
|
|
24
27
|
edits: distance(key.toLowerCase(), name.toLowerCase())
|
|
25
|
-
})).toSorted((x, y) => x.edits - y.edits);
|
|
26
|
-
return best !== void 0 && best.edits <= 2 && best.edits * 2 <= key.length ? best.name : void 0;
|
|
28
|
+
})).filter(({ edits }) => edits <= 2 && edits * 2 <= key.length).toSorted((x, y) => x.edits - y.edits).map(({ name }) => name);
|
|
27
29
|
}
|
|
30
|
+
/** The known field a misspelled one most likely meant (`nearTo`); none when none is near. */
|
|
31
|
+
const nearest = (key, known) => nearTo(key, known)[0];
|
|
32
|
+
/** The one way a message offers a name: ` Did you mean "x"?`, or nothing when there is none. */
|
|
28
33
|
const meant = (near) => near === void 0 ? "" : ` Did you mean "${near}"?`;
|
|
34
|
+
/** The offer for a mistyped name: the known name it most likely meant, in `meant`'s words. */
|
|
35
|
+
const didYouMean = (key, known) => meant(nearest(key, known));
|
|
29
36
|
function unknownField(what, key, known) {
|
|
30
|
-
return `"${key}" is not a field of ${what}.${
|
|
37
|
+
return `"${key}" is not a field of ${what}.${didYouMean(key, known)} Its fields are ${known.join(", ")}.`;
|
|
31
38
|
}
|
|
32
39
|
/** What a value is, in a word, for a message that says what it should have been. */
|
|
33
40
|
function kindOf(value) {
|
|
@@ -127,4 +134,4 @@ function lacking(what, keys) {
|
|
|
127
134
|
return [issue("MODEL_SHAPE", path, `${what} holds one of ${keys.join(", ")}.${meant(near)}`)];
|
|
128
135
|
};
|
|
129
136
|
}
|
|
130
|
-
export { byKey, byKind, fields, lacking, listOf, mapOf, nearest, orFalse, orWord, orWords, wordOrList };
|
|
137
|
+
export { byKey, byKind, didYouMean, fields, lacking, listOf, mapOf, meant, nearTo, nearest, orFalse, orWord, orWords, wordOrList };
|
|
@@ -11,7 +11,11 @@ function when(condition, code, path, message) {
|
|
|
11
11
|
return condition ? [issue(code, path, message)] : [];
|
|
12
12
|
}
|
|
13
13
|
const IDENTIFIER = /^[a-z][a-z0-9_]*$/iu;
|
|
14
|
+
/** Names JavaScript objects reserve: as a key they would set or shadow an object's prototype. */
|
|
15
|
+
const RESERVED_KEY = /^(?:__proto__|constructor|prototype)$/u;
|
|
16
|
+
/** A model name: an identifier, and never a name objects reserve (input map keys share the list). */
|
|
14
17
|
function nameIssues(name, path) {
|
|
18
|
+
if (RESERVED_KEY.test(name)) return [issue("NAME_INVALID", path, `"${name}" is reserved and cannot be a name; pick another.`)];
|
|
15
19
|
return when(!IDENTIFIER.test(name), "NAME_INVALID", path, `"${name}" is not a valid name.`);
|
|
16
20
|
}
|
|
17
|
-
export { issue, nameIssues, when };
|
|
21
|
+
export { RESERVED_KEY, issue, nameIssues, when };
|
|
@@ -7,6 +7,7 @@ const META = [
|
|
|
7
7
|
"sensitive",
|
|
8
8
|
"hidden"
|
|
9
9
|
];
|
|
10
|
+
const MEASURE_META = [...META, "better"];
|
|
10
11
|
const HINTS = [
|
|
11
12
|
"drill",
|
|
12
13
|
"format",
|
|
@@ -31,7 +32,7 @@ const SUMMED = fields("a sum, min or max measure", fieldsOf()([
|
|
|
31
32
|
"numeric",
|
|
32
33
|
"unit",
|
|
33
34
|
...OVER,
|
|
34
|
-
...
|
|
35
|
+
...MEASURE_META
|
|
35
36
|
]), over);
|
|
36
37
|
const MEASURE = byKind("a measure", {
|
|
37
38
|
count: fields("a count measure", fieldsOf()([
|
|
@@ -39,7 +40,7 @@ const MEASURE = byKind("a measure", {
|
|
|
39
40
|
"merge",
|
|
40
41
|
"distinct",
|
|
41
42
|
"where",
|
|
42
|
-
...
|
|
43
|
+
...MEASURE_META
|
|
43
44
|
]), { where: filter }),
|
|
44
45
|
sum: SUMMED,
|
|
45
46
|
min: SUMMED,
|
|
@@ -50,7 +51,7 @@ const MEASURE = byKind("a measure", {
|
|
|
50
51
|
"numeric",
|
|
51
52
|
"unit",
|
|
52
53
|
...OVER,
|
|
53
|
-
...
|
|
54
|
+
...MEASURE_META
|
|
54
55
|
]), over),
|
|
55
56
|
percentile: fields("a percentile measure", fieldsOf()([
|
|
56
57
|
"kind",
|
|
@@ -58,7 +59,7 @@ const MEASURE = byKind("a measure", {
|
|
|
58
59
|
"p",
|
|
59
60
|
"unit",
|
|
60
61
|
...OVER,
|
|
61
|
-
...
|
|
62
|
+
...MEASURE_META
|
|
62
63
|
]), over),
|
|
63
64
|
ratio: fields("a ratio measure", fieldsOf()([
|
|
64
65
|
"kind",
|
|
@@ -66,7 +67,7 @@ const MEASURE = byKind("a measure", {
|
|
|
66
67
|
"numerator",
|
|
67
68
|
"denominator",
|
|
68
69
|
"format",
|
|
69
|
-
...
|
|
70
|
+
...MEASURE_META
|
|
70
71
|
]))
|
|
71
72
|
});
|
|
72
73
|
const STORAGE = byKey("a time storage", {
|
|
@@ -42,6 +42,28 @@ const isObject = (v) => typeof v === "object" && v !== null;
|
|
|
42
42
|
const known = (list, value) => list.includes(value);
|
|
43
43
|
const shape = (path, message) => issue("MODEL_SHAPE", path, message);
|
|
44
44
|
const oneOf = (list) => list.map((v) => JSON.stringify(v)).join(", ");
|
|
45
|
+
const MEASURE_KIND = {
|
|
46
|
+
field: "kind",
|
|
47
|
+
what: "measure kind",
|
|
48
|
+
list: MEASURE_KINDS
|
|
49
|
+
};
|
|
50
|
+
const MERGE = {
|
|
51
|
+
field: "merge",
|
|
52
|
+
what: "merge",
|
|
53
|
+
list: MERGES
|
|
54
|
+
};
|
|
55
|
+
const DIMENSION_KIND = {
|
|
56
|
+
field: "kind",
|
|
57
|
+
what: "dimension kind",
|
|
58
|
+
list: DIMENSION_KINDS
|
|
59
|
+
};
|
|
60
|
+
/** A field that is one of a list: named as missing when it is, else its value is named. */
|
|
61
|
+
function oneOfField(m, { field, what, list }, path) {
|
|
62
|
+
const value = m[field];
|
|
63
|
+
if (known(list, value)) return [];
|
|
64
|
+
const message = value === void 0 ? `"${field}" is missing: one of ${oneOf(list)}.` : `${JSON.stringify(value)} is not a ${what}: ${oneOf(list)}.`;
|
|
65
|
+
return [shape([...path, field], message)];
|
|
66
|
+
}
|
|
45
67
|
/** Fields a kind needs, each named when missing. */
|
|
46
68
|
function needs(m, fields, path) {
|
|
47
69
|
return fields.flatMap((f) => m[f] === void 0 ? [shape([...path, f], `A ${String(m["kind"])} needs "${f}".`)] : []);
|
|
@@ -49,11 +71,21 @@ function needs(m, fields, path) {
|
|
|
49
71
|
function unitShape(unit, path) {
|
|
50
72
|
return unit === void 0 || typeof unit === "string" ? [] : [shape([...path, "unit"], "A measure unit is a string, such as \"USD\".")];
|
|
51
73
|
}
|
|
74
|
+
const BETTER = ["higher", "lower"];
|
|
75
|
+
/** Which way is better, when a measure says: a renderer colours a change by it, so it must be one it reads. */
|
|
76
|
+
function betterShape(better, path) {
|
|
77
|
+
return better === void 0 || known(BETTER, better) ? [] : [shape([...path, "better"], "A measure's better is \"higher\" or \"lower\".")];
|
|
78
|
+
}
|
|
52
79
|
function measureShape(m, path) {
|
|
53
80
|
if (!isObject(m)) return [shape(path, "A measure is an object.")];
|
|
54
|
-
|
|
81
|
+
const kind = oneOfField(m, MEASURE_KIND, path);
|
|
82
|
+
if (kind.length > 0) return kind;
|
|
83
|
+
return [...kindShape(m, path), ...betterShape(m["better"], path)];
|
|
84
|
+
}
|
|
85
|
+
/** The fields a measure's kind needs, and the values they may take. */
|
|
86
|
+
function kindShape(m, path) {
|
|
55
87
|
if (m["kind"] === "ratio") return needs(m, ["numerator", "denominator"], path);
|
|
56
|
-
const merge =
|
|
88
|
+
const merge = oneOfField(m, MERGE, path);
|
|
57
89
|
if (m["kind"] === "count") return merge;
|
|
58
90
|
const fields = m["kind"] === "percentile" ? ["of", "p"] : ["of", "numeric"];
|
|
59
91
|
const p = m["kind"] === "percentile" && m["p"] !== void 0 && !known(PERCENTILES, m["p"]) ? [shape([...path, "p"], `A percentile is one of ${oneOf(PERCENTILES)}.`)] : [];
|
|
@@ -85,7 +117,8 @@ const DIMENSION_NEEDS = {
|
|
|
85
117
|
function dimensionShape(d, path) {
|
|
86
118
|
if (!isObject(d)) return [shape(path, "A dimension is an object.")];
|
|
87
119
|
const kind = d["kind"];
|
|
88
|
-
|
|
120
|
+
const unknown = oneOfField(d, DIMENSION_KIND, path);
|
|
121
|
+
if (typeof kind !== "string" || unknown.length > 0) return unknown;
|
|
89
122
|
const missing = needs(d, DIMENSION_NEEDS[kind] ?? [], path);
|
|
90
123
|
if (missing.length > 0) return missing;
|
|
91
124
|
if (kind === "time") return storageShape(d["storage"], [...path, "storage"]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tenantKeys } from "../defaults.mjs";
|
|
1
|
+
import { tenantEntry, tenantKeys } from "../defaults.mjs";
|
|
2
2
|
import { drillIssues } from "./drill.mjs";
|
|
3
3
|
import { modelFilterIssues } from "./filter.mjs";
|
|
4
4
|
import { issue, nameIssues, when } from "./issues.mjs";
|
|
@@ -61,7 +61,7 @@ function tenantIssues(model, source, path) {
|
|
|
61
61
|
if (tenant === void 0) return when(keys.length > 0, "TENANT_BINDING_MISSING", path, "The model has tenant keys, so every source must say how it is tied to them (or that it is shared).");
|
|
62
62
|
if ("via" in tenant) return viaJoinIssues(source, tenant.via, [...path, "via"]);
|
|
63
63
|
if (!("columns" in tenant)) return sharedIssues(tenant, path);
|
|
64
|
-
return [...keys.flatMap((key) => when((tenant.columns
|
|
64
|
+
return [...keys.flatMap((key) => when((tenantEntry(tenant.columns, key) ?? "") === "", "TENANT_COLUMN_MISSING", [
|
|
65
65
|
...path,
|
|
66
66
|
"columns",
|
|
67
67
|
key
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { QueryRefusalCode } from "../error/codes.mjs";
|
|
2
2
|
import { Model } from "../model/types.mjs";
|
|
3
|
+
import { Unread } from "../value/stored.mjs";
|
|
3
4
|
import { LockEntry } from "../query/compose.mjs";
|
|
4
5
|
import { BoundFilter } from "../query/filter.mjs";
|
|
5
6
|
import { Calendar, WireQuery } from "../query/types.mjs";
|
|
@@ -32,6 +33,7 @@ export type OracleInput = {
|
|
|
32
33
|
calendar: Calendar;
|
|
33
34
|
};
|
|
34
35
|
export declare class OracleError extends Error {
|
|
35
|
-
readonly code: QueryRefusalCode | "NUMERIC_STORAGE" | "PLAN_ASSERTION";
|
|
36
|
+
readonly code: QueryRefusalCode | "NUMERIC_STORAGE" | "PLAN_ASSERTION" | "QUERY_INVALID";
|
|
36
37
|
constructor(code: OracleError["code"], message: string);
|
|
37
|
-
}
|
|
38
|
+
}
|
|
39
|
+
export type { Unread };
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
import { Unread } from "../value/stored.mjs";
|
|
1
2
|
import { Cell } from "../query/types.mjs";
|
|
2
3
|
import "./data.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* With `time.whole`: the answer of the query without its grain (`withoutGrain`), its rows in
|
|
6
|
+
* the layout `[...dimensions, ...measures, ...calcs]`, Other and totals one row each.
|
|
7
|
+
*/
|
|
8
|
+
type OracleWhole = {
|
|
9
|
+
rows: Cell[][];
|
|
10
|
+
other?: Cell[][];
|
|
11
|
+
totals?: Cell[][];
|
|
12
|
+
segmentOther?: Cell[][];
|
|
13
|
+
};
|
|
3
14
|
/** Rows are `[bucket?, ...dimensions, ...measures, ...calcs]`; Other and totals have one row per bucket. */
|
|
4
15
|
export type OracleResult = {
|
|
5
16
|
columns: string[];
|
|
@@ -8,6 +19,8 @@ export type OracleResult = {
|
|
|
8
19
|
totals?: Cell[][];
|
|
9
20
|
/** With a dimension's `other`: the values its limit left out. */
|
|
10
21
|
segmentOther?: Cell[][];
|
|
22
|
+
/** With `time.whole`: the answer of the query without its grain. */
|
|
23
|
+
whole?: OracleWhole;
|
|
11
24
|
/** The comparison period, restricted to the groups the main result has. */
|
|
12
25
|
compare?: {
|
|
13
26
|
rows: Cell[][];
|
|
@@ -17,7 +30,12 @@ export type OracleResult = {
|
|
|
17
30
|
from: string;
|
|
18
31
|
to: string;
|
|
19
32
|
};
|
|
33
|
+
/** With `time.whole`: the comparison's whole, restricted to the groups the main whole has. */
|
|
34
|
+
whole?: Omit<OracleWhole, "other">;
|
|
20
35
|
};
|
|
21
36
|
/** Set when the principal can read no row of the fact source: no rows, not zeros. */
|
|
22
37
|
unreadable?: true;
|
|
23
|
-
|
|
38
|
+
/** Stored values left out because they do not read as their column's storage, by column. */
|
|
39
|
+
unread?: readonly Unread[];
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { answersWhole, withoutGrain } from "../query/fold.mjs";
|
|
1
2
|
import { readsPrevious } from "../result/calc.mjs";
|
|
2
3
|
import { comparator } from "../result/order.mjs";
|
|
3
4
|
import { canonical } from "../value/canonical.mjs";
|
|
@@ -76,7 +77,9 @@ function secondOf(input) {
|
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
79
|
* `whole`: the query whose rows the totals and `total` refs read, when not `input.query`
|
|
79
|
-
* (the uncut query, for a query whose dimensions have cuts).
|
|
80
|
+
* (the uncut query, for a query whose dimensions have cuts). With `time.whole`, the answer also
|
|
81
|
+
* holds the query without its grain, read from the same rows, and so does its comparison: the
|
|
82
|
+
* comparison query without its grain, so it reads the span the comparison's rows read.
|
|
80
83
|
*/
|
|
81
84
|
function evaluatePlain(input, whole) {
|
|
82
85
|
if (unreadable(input)) return {
|
|
@@ -88,29 +91,72 @@ function evaluatePlain(input, whole) {
|
|
|
88
91
|
...input,
|
|
89
92
|
query: whole
|
|
90
93
|
};
|
|
91
|
-
const
|
|
94
|
+
const reads = {
|
|
95
|
+
own: readOf(input),
|
|
96
|
+
whole: wholeInput && readOf(wholeInput)
|
|
97
|
+
};
|
|
98
|
+
const main = withWhole(answer(input, reads.own, reads.whole), foldOf(input, reads));
|
|
92
99
|
const second = comparisonQuery(input);
|
|
93
100
|
if (second === void 0) return main;
|
|
94
|
-
|
|
101
|
+
const before = {
|
|
102
|
+
own: { rows: factRows({
|
|
103
|
+
...input,
|
|
104
|
+
query: second.query
|
|
105
|
+
}) },
|
|
106
|
+
whole: wholeInput && secondOf(wholeInput)
|
|
107
|
+
};
|
|
108
|
+
const previous = answer({
|
|
95
109
|
...input,
|
|
96
110
|
query: second.query
|
|
97
|
-
},
|
|
111
|
+
}, before.own, before.whole);
|
|
112
|
+
const folded = foldOf({
|
|
98
113
|
...input,
|
|
99
114
|
query: second.query
|
|
100
|
-
}
|
|
115
|
+
}, before, answersWhole(input.query));
|
|
116
|
+
return withCompare(input, main, withWhole(previous, folded), second.range);
|
|
101
117
|
}
|
|
102
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* The answer of the query without its grain over the same rows, when the query asks for its
|
|
120
|
+
* whole (`asked`, by default its own `time.whole`). A comparison query has no `time.whole` of
|
|
121
|
+
* its own: the query it compares for asks.
|
|
122
|
+
*/
|
|
123
|
+
function foldOf(input, reads, asked = answersWhole(input.query)) {
|
|
124
|
+
if (!asked) return void 0;
|
|
125
|
+
const { columns: _columns, ...fold } = answer({
|
|
126
|
+
...input,
|
|
127
|
+
query: withoutGrain(input.query)
|
|
128
|
+
}, reads.own, reads.whole);
|
|
129
|
+
return fold;
|
|
130
|
+
}
|
|
131
|
+
const withWhole = (result, whole) => whole === void 0 ? result : {
|
|
132
|
+
...result,
|
|
133
|
+
whole
|
|
134
|
+
};
|
|
135
|
+
/** A comparison's rows cut to the groups `keys` holds, by their dimension cells after `offset`. */
|
|
136
|
+
function cutTo(rows, keys, offset, width) {
|
|
137
|
+
return rows.filter((row) => keys.has(canonical(row.slice(offset, offset + width))));
|
|
138
|
+
}
|
|
139
|
+
/** The groups of an answer's rows, by their dimension cells after `offset`. */
|
|
140
|
+
const groupKeys = (rows, offset, width) => new Set(rows.map((row) => canonical(row.slice(offset, offset + width))));
|
|
141
|
+
/**
|
|
142
|
+
* The comparison period's answer beside the main one, cut to the groups the main one has, and
|
|
143
|
+
* its whole cut to the groups the main whole has.
|
|
144
|
+
*/
|
|
103
145
|
function withCompare(input, main, previous, range) {
|
|
104
146
|
const offset = input.query.time?.grain === void 0 ? 0 : 1;
|
|
105
147
|
const width = (input.query.dimensions ?? []).length;
|
|
106
|
-
const
|
|
107
|
-
const
|
|
148
|
+
const kept = groupKeys(main.rows, offset, width);
|
|
149
|
+
const whole = previous.whole === void 0 || main.whole === void 0 ? {} : { whole: {
|
|
150
|
+
rows: cutTo(previous.whole.rows, groupKeys(main.whole.rows, 0, width), 0, width),
|
|
151
|
+
...previous.whole.totals === void 0 ? {} : { totals: previous.whole.totals }
|
|
152
|
+
} };
|
|
108
153
|
return {
|
|
109
154
|
...main,
|
|
110
155
|
compare: {
|
|
111
|
-
rows: previous.rows
|
|
156
|
+
rows: cutTo(previous.rows, kept, offset, width),
|
|
112
157
|
...previous.totals === void 0 ? {} : { totals: previous.totals },
|
|
113
|
-
range
|
|
158
|
+
range,
|
|
159
|
+
...whole
|
|
114
160
|
}
|
|
115
161
|
};
|
|
116
162
|
}
|
|
@@ -60,7 +60,7 @@ function timeExpr(ctx, expr) {
|
|
|
60
60
|
}
|
|
61
61
|
const start = instantOf(ctx, expr.elapsed.start);
|
|
62
62
|
const end = instantOf(ctx, expr.elapsed.end);
|
|
63
|
-
return start === null || end === null ? null : end - start;
|
|
63
|
+
return start === null || end === null ? null : Number(end - start);
|
|
64
64
|
}
|
|
65
65
|
/** The value of a model expression on one row. Null in, null out, as in SQL. */
|
|
66
66
|
function evalExpr(ctx, expr) {
|
|
@@ -41,6 +41,15 @@ function inRange(input, row) {
|
|
|
41
41
|
* in any of those rows refuses the query (NUMERIC_STORAGE).
|
|
42
42
|
*/
|
|
43
43
|
function factRows(input) {
|
|
44
|
+
const facts = scopedRows(input, true);
|
|
45
|
+
checkStorage(input, facts);
|
|
46
|
+
return facts;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The fact rows a query reads, by the same tests, with or without its range: without it, the
|
|
50
|
+
* rows whose time could not be placed in or out of the range are among them.
|
|
51
|
+
*/
|
|
52
|
+
function scopedRows(input, ranged) {
|
|
44
53
|
checkRequest(input);
|
|
45
54
|
const filters = input.query.filters;
|
|
46
55
|
if (filters !== void 0 && !isBound(filters)) throw new OracleError("FILTER_UNBOUND", "Resolve viewer values and variables before asking the oracle.");
|
|
@@ -53,20 +62,18 @@ function factRows(input) {
|
|
|
53
62
|
policy: (row) => allowed(input, row),
|
|
54
63
|
locks: (input.locks ?? []).map((e) => entry(e)),
|
|
55
64
|
required: [...where, ...(input.required ?? []).map((e) => entry(e))],
|
|
56
|
-
query: (row) => (filters === void 0 || evaluateFilter(filters, row, reader)) && inRange(input, row),
|
|
65
|
+
query: (row) => (filters === void 0 || evaluateFilter(filters, row, reader)) && (!ranged || inRange(input, row)),
|
|
57
66
|
deltas: []
|
|
58
67
|
};
|
|
59
68
|
const tests = effectiveFilter(parts).all;
|
|
60
|
-
|
|
69
|
+
return (input.data[source] ?? []).map((data) => ({
|
|
61
70
|
source,
|
|
62
71
|
data
|
|
63
72
|
})).filter((row) => tests.every((test) => test(row)));
|
|
64
|
-
checkStorage(input, facts);
|
|
65
|
-
return facts;
|
|
66
73
|
}
|
|
67
74
|
/** Checks the request like `factRows`, then says whether the principal can read no row of the fact. */
|
|
68
75
|
function unreadable(input) {
|
|
69
76
|
factRows(input);
|
|
70
77
|
return !readable(input, input.query.source);
|
|
71
78
|
}
|
|
72
|
-
export { factRows, unreadable };
|
|
79
|
+
export { factRows, scopedRows, unreadable };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { storedExact } from "../exact/
|
|
1
|
+
import { storedExact } from "../exact/stored.mjs";
|
|
2
2
|
import { sumLinear } from "../exact/sum.mjs";
|
|
3
3
|
import { exprLinearTerms } from "../model/validate/expr.mjs";
|
|
4
4
|
import { cellOf, divide, exactNum, numOf } from "../result/number.mjs";
|