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
|
@@ -6,6 +6,7 @@ import { Calendar, Cell, ResolvedRange, WireQuery } from "../query/types.mjs";
|
|
|
6
6
|
import { Moment } from "../time/temporal.mjs";
|
|
7
7
|
import { SourceName } from "../types/primitives.mjs";
|
|
8
8
|
import { Principal } from "../types/viewer.mjs";
|
|
9
|
+
import { Unread } from "../value/stored.mjs";
|
|
9
10
|
export type EngineInput = {
|
|
10
11
|
model: Model;
|
|
11
12
|
query: WireQuery;
|
|
@@ -27,11 +28,23 @@ export type EngineInput = {
|
|
|
27
28
|
/** A range that includes the current unit ends at `now` floored to this many seconds. */
|
|
28
29
|
quantumSeconds?: number;
|
|
29
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* With `time.whole`: the answer of the query without its grain (`withoutGrain`), read in the
|
|
33
|
+
* same session. Rows are `[...dimensions, ...measures, ...calcs]`; Other and totals one row each.
|
|
34
|
+
*/
|
|
35
|
+
export type Whole = {
|
|
36
|
+
rows: Cell[][];
|
|
37
|
+
other?: Cell[][];
|
|
38
|
+
totals?: Cell[][];
|
|
39
|
+
segmentOther?: Cell[][];
|
|
40
|
+
};
|
|
30
41
|
/** Rows are `[bucket?, ...dimensions, ...measures, ...calcs]`, the layout the oracle uses. */
|
|
31
42
|
export type Answer = {
|
|
32
43
|
rows: Cell[][];
|
|
33
44
|
other?: Cell[][];
|
|
34
45
|
totals?: Cell[][];
|
|
46
|
+
/** With `time.whole`: the answer of the query without its grain. */
|
|
47
|
+
whole?: Whole;
|
|
35
48
|
compare?: {
|
|
36
49
|
rows: Cell[][];
|
|
37
50
|
totals?: Cell[][];
|
|
@@ -40,6 +53,8 @@ export type Answer = {
|
|
|
40
53
|
from: string;
|
|
41
54
|
to: string;
|
|
42
55
|
};
|
|
56
|
+
/** With `time.whole`: the comparison's whole, cut to the groups the main whole has. */
|
|
57
|
+
whole?: Omit<Whole, "other">;
|
|
43
58
|
};
|
|
44
59
|
/** With a dimension's `other`: the values its limit left out. */
|
|
45
60
|
segmentOther?: Cell[][];
|
|
@@ -47,6 +62,8 @@ export type Answer = {
|
|
|
47
62
|
unreadable?: true;
|
|
48
63
|
/** Set when the answer hit `maxRows` and is not every row. */
|
|
49
64
|
truncated?: true;
|
|
65
|
+
/** Stored values left out because they do not read as their column's storage, by column. */
|
|
66
|
+
unread?: readonly Unread[];
|
|
50
67
|
};
|
|
51
68
|
/** An answer, and what was read to give it: every source the plan touched and the resolved range. */
|
|
52
69
|
export type Ran = {
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
|
|
6
6
|
* against the files and prints the new value when they change.
|
|
7
7
|
*/
|
|
8
|
-
export declare const ENGINE_VERSION = "
|
|
8
|
+
export declare const ENGINE_VERSION = "19f3d940fdf90e87";
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
|
|
7
7
|
* against the files and prints the new value when they change.
|
|
8
8
|
*/
|
|
9
|
-
const ENGINE_VERSION = "
|
|
9
|
+
const ENGINE_VERSION = "19f3d940fdf90e87";
|
|
10
10
|
export { ENGINE_VERSION };
|
|
@@ -99,6 +99,7 @@ export declare const QUERY_REFUSALS: {
|
|
|
99
99
|
readonly SELECTION_INVALID: "A drill's selection, execution or path does not open, does not fit the tile, or is longer than a path holds.";
|
|
100
100
|
readonly DRILL_UNSUPPORTED: "The drill asks for a view its line cannot show (a formula's items, a snapshot measure, a field it cannot be broken down by); the message says why.";
|
|
101
101
|
readonly CURSOR_INVALID: "A records page names a cursor that is not the `next` an earlier page of the same view gave.";
|
|
102
|
+
readonly QUANTUM_INVALID: "The request's quantum (`cache.quantum`) is not a whole number of seconds, 1 or more; the options schema refuses it at start.";
|
|
102
103
|
readonly RANGE_INVALID: "The date range is not valid.";
|
|
103
104
|
readonly RECORDS_UNAVAILABLE: "The source reads through a custom data layer that does not serve the rows behind an answer.";
|
|
104
105
|
readonly SOURCE_UNKNOWN: "The query names a source that does not exist.";
|
|
@@ -109,6 +110,7 @@ export declare const QUERY_REFUSALS: {
|
|
|
109
110
|
/** A result that answered, with something the viewer should know. Carried in the receipt. */
|
|
110
111
|
export declare const RESULT_WARNINGS: {
|
|
111
112
|
readonly ROW_CAP: "The answer has more groups or rows than the row cap; it is cut and marked truncated.";
|
|
113
|
+
readonly VALUE_UNREAD: "Some stored values do not read as their column's storage; each is read as no value (its row stays, and counts in every measure that does not read it), counted by column, and the answer is marked partial.";
|
|
112
114
|
};
|
|
113
115
|
/**
|
|
114
116
|
* Why a drill cannot show a view, or a mark does not open. Each is a code a host can translate
|
|
@@ -132,9 +134,10 @@ export declare const DRILL_REASONS: {
|
|
|
132
134
|
readonly ROW_CAP: "Only the first rows of this answer open; narrow the filters to open the rest.";
|
|
133
135
|
readonly SOURCE_OFF: "The model turns drilling off for this source.";
|
|
134
136
|
};
|
|
135
|
-
/**
|
|
137
|
+
/** Why an edit to a dashboard is refused: by the document reducer, or as an issue inside `EDIT_REFUSED`. */
|
|
136
138
|
export declare const DOCUMENT_REFUSALS: {
|
|
137
139
|
readonly CONTROL_EXISTS: "A control with that id already exists.";
|
|
140
|
+
readonly CONTROL_FIELD: "A filter control names a field the model does not have, a second field on a source it already covers, or a field holding another type of value than its own. Named in the issues of EDIT_REFUSED on an edit or a restore, and of DOCUMENT_INVALID when a code dashboard starts; the reducer itself does not read the model, so a draft's stored commands replay.";
|
|
138
141
|
readonly DOCUMENT_INVALID: "A dashboard document does not match its schema, or a code-defined dashboard has a display option its widget or query cannot use.";
|
|
139
142
|
readonly DOCUMENT_TOO_NEW: "A dashboard document was written by a newer version of the library than this one.";
|
|
140
143
|
readonly CONTROL_UNKNOWN: "The edit names a control that does not exist.";
|
|
@@ -147,17 +150,33 @@ export declare const DOCUMENT_REFUSALS: {
|
|
|
147
150
|
readonly WIDGET_EXISTS: "A widget with that id already exists.";
|
|
148
151
|
readonly WIDGET_UNKNOWN: "The edit names a widget that does not exist.";
|
|
149
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* Why `deriveDashboards` refuses to start. Each is thrown as a `StartError` with this code and every problem at its path; a code
|
|
155
|
+
* dashboard's document is refused as DOCUMENT_INVALID (`DashboardDocumentError`).
|
|
156
|
+
*/
|
|
157
|
+
export declare const START_REFUSALS: {
|
|
158
|
+
readonly ACCESS_INVALID: "The access option is missing, or its can or sensitive is not a function.";
|
|
159
|
+
readonly CONNECTIONS_INVALID: "The model reads a connection that is missing, or one given is not one.";
|
|
160
|
+
readonly DASHBOARD_KEY_DUPLICATE: "Two code dashboards have the same key.";
|
|
161
|
+
readonly ITEM_LINK_INVALID: "An item link names a source or key part that does not exist, holds a space or control character, or does not start with one / or an http(s) host.";
|
|
162
|
+
readonly MODEL_INVALID: "The model is not valid; the issues are the model check's. defineModel throws it as a ModelError.";
|
|
163
|
+
readonly OPTIONS_INVALID: "An option that does not exist at any depth, or of the wrong type or value: a secret under 32 bytes, a cache quantum that is not a whole number of seconds.";
|
|
164
|
+
readonly PLUGIN_ID_INVALID: "Two plugins have one id, or a plugin's id is a name the library uses.";
|
|
165
|
+
readonly WIDGET_KIND_UNKNOWN: "A code dashboard's widget is of a kind no renderer draws.";
|
|
166
|
+
};
|
|
150
167
|
/** Returned to a client by the request handler. Plugins add their own with `defineErrorCodes`. */
|
|
151
168
|
export declare const BASE_ERROR_CODES: {
|
|
152
169
|
QUERY_INVALID: RawError<"QUERY_INVALID">;
|
|
153
170
|
QUERY_REFERENCE: RawError<"QUERY_REFERENCE">;
|
|
154
171
|
TENANT_MISSING: RawError<"TENANT_MISSING">;
|
|
155
172
|
UNAUTHORIZED: RawError<"UNAUTHORIZED">;
|
|
173
|
+
VIEWER_INVALID: RawError<"VIEWER_INVALID">;
|
|
156
174
|
FORBIDDEN: RawError<"FORBIDDEN">;
|
|
157
175
|
NOT_FOUND: RawError<"NOT_FOUND">;
|
|
158
176
|
PLAN_ASSERTION: RawError<"PLAN_ASSERTION">;
|
|
159
177
|
LOCK_NOT_APPLICABLE: RawError<"LOCK_NOT_APPLICABLE">;
|
|
160
178
|
NUMERIC_STORAGE: RawError<"NUMERIC_STORAGE">;
|
|
179
|
+
ANSWER_INVALID: RawError<"ANSWER_INVALID">;
|
|
161
180
|
VERSION_CONFLICT: RawError<"VERSION_CONFLICT">;
|
|
162
181
|
DRAFT_CONFLICT: RawError<"DRAFT_CONFLICT">;
|
|
163
182
|
DRAFT_CLOSED: RawError<"DRAFT_CLOSED">;
|
|
@@ -182,6 +201,10 @@ export type ModelIssueCode = keyof typeof MODEL_ISSUES;
|
|
|
182
201
|
export type CatalogIssueCode = keyof typeof CATALOG_ISSUES;
|
|
183
202
|
export type QueryRefusalCode = keyof typeof QUERY_REFUSALS;
|
|
184
203
|
export type DocumentRefusalCode = keyof typeof DOCUMENT_REFUSALS;
|
|
204
|
+
/** A check `deriveDashboards` makes as it starts. */
|
|
205
|
+
export type StartCheckCode = keyof typeof START_REFUSALS;
|
|
206
|
+
/** Why `deriveDashboards` refused to start: `StartError.code`. */
|
|
207
|
+
export type StartRefusalCode = StartCheckCode | "DOCUMENT_INVALID";
|
|
185
208
|
export type ResultWarningCode = keyof typeof RESULT_WARNINGS;
|
|
186
209
|
/** Why a drill cannot show a view, or a mark does not open. */
|
|
187
210
|
export type DrillReason = keyof typeof DRILL_REASONS;
|
|
@@ -87,7 +87,10 @@ const CATALOG_ISSUES = {
|
|
|
87
87
|
TABLE_NOT_FOUND: "The model reads a table the database does not have."
|
|
88
88
|
};
|
|
89
89
|
/** A result that answered, with something the viewer should know. Carried in the receipt. */
|
|
90
|
-
const RESULT_WARNINGS = {
|
|
90
|
+
const RESULT_WARNINGS = {
|
|
91
|
+
ROW_CAP: "The answer has more groups or rows than the row cap; it is cut and marked truncated.",
|
|
92
|
+
VALUE_UNREAD: "Some stored values do not read as their column's storage; each is read as no value (its row stays, and counts in every measure that does not read it), counted by column, and the answer is marked partial."
|
|
93
|
+
};
|
|
91
94
|
/**
|
|
92
95
|
* Why a drill cannot show a view, or a mark does not open. Each is a code a host can translate
|
|
93
96
|
* (the React package's `messages.drillReasons`); the English text is the default.
|
|
@@ -110,9 +113,10 @@ const DRILL_REASONS = {
|
|
|
110
113
|
ROW_CAP: "Only the first rows of this answer open; narrow the filters to open the rest.",
|
|
111
114
|
SOURCE_OFF: "The model turns drilling off for this source."
|
|
112
115
|
};
|
|
113
|
-
/**
|
|
116
|
+
/** Why an edit to a dashboard is refused: by the document reducer, or as an issue inside `EDIT_REFUSED`. */
|
|
114
117
|
const DOCUMENT_REFUSALS = {
|
|
115
118
|
CONTROL_EXISTS: "A control with that id already exists.",
|
|
119
|
+
CONTROL_FIELD: "A filter control names a field the model does not have, a second field on a source it already covers, or a field holding another type of value than its own. Named in the issues of EDIT_REFUSED on an edit or a restore, and of DOCUMENT_INVALID when a code dashboard starts; the reducer itself does not read the model, so a draft's stored commands replay.",
|
|
116
120
|
DOCUMENT_INVALID: "A dashboard document does not match its schema, or a code-defined dashboard has a display option its widget or query cannot use.",
|
|
117
121
|
DOCUMENT_TOO_NEW: "A dashboard document was written by a newer version of the library than this one.",
|
|
118
122
|
CONTROL_UNKNOWN: "The edit names a control that does not exist.",
|
|
@@ -125,17 +129,33 @@ const DOCUMENT_REFUSALS = {
|
|
|
125
129
|
WIDGET_EXISTS: "A widget with that id already exists.",
|
|
126
130
|
WIDGET_UNKNOWN: "The edit names a widget that does not exist."
|
|
127
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Why `deriveDashboards` refuses to start. Each is thrown as a `StartError` with this code and every problem at its path; a code
|
|
134
|
+
* dashboard's document is refused as DOCUMENT_INVALID (`DashboardDocumentError`).
|
|
135
|
+
*/
|
|
136
|
+
const START_REFUSALS = {
|
|
137
|
+
ACCESS_INVALID: "The access option is missing, or its can or sensitive is not a function.",
|
|
138
|
+
CONNECTIONS_INVALID: "The model reads a connection that is missing, or one given is not one.",
|
|
139
|
+
DASHBOARD_KEY_DUPLICATE: "Two code dashboards have the same key.",
|
|
140
|
+
ITEM_LINK_INVALID: "An item link names a source or key part that does not exist, holds a space or control character, or does not start with one / or an http(s) host.",
|
|
141
|
+
MODEL_INVALID: "The model is not valid; the issues are the model check's. defineModel throws it as a ModelError.",
|
|
142
|
+
OPTIONS_INVALID: "An option that does not exist at any depth, or of the wrong type or value: a secret under 32 bytes, a cache quantum that is not a whole number of seconds.",
|
|
143
|
+
PLUGIN_ID_INVALID: "Two plugins have one id, or a plugin's id is a name the library uses.",
|
|
144
|
+
WIDGET_KIND_UNKNOWN: "A code dashboard's widget is of a kind no renderer draws."
|
|
145
|
+
};
|
|
128
146
|
/** Returned to a client by the request handler. Plugins add their own with `defineErrorCodes`. */
|
|
129
147
|
const BASE_ERROR_CODES = defineErrorCodes({
|
|
130
148
|
QUERY_INVALID: "The query is not valid.",
|
|
131
149
|
QUERY_REFERENCE: "The query refers to an entry that does not exist.",
|
|
132
150
|
TENANT_MISSING: "The request has no value for a tenant key.",
|
|
133
151
|
UNAUTHORIZED: "The request has no signed-in viewer.",
|
|
152
|
+
VIEWER_INVALID: "The host's viewer() returned something that is neither a viewer nor null; the message names the field.",
|
|
134
153
|
FORBIDDEN: "You do not have access to this.",
|
|
135
154
|
NOT_FOUND: "There is no such endpoint, dashboard or control.",
|
|
136
155
|
PLAN_ASSERTION: "The query plan is missing a required tenant, policy or lock filter.",
|
|
137
156
|
LOCK_NOT_APPLICABLE: "A lock on this dashboard cannot be applied to this tile.",
|
|
138
157
|
NUMERIC_STORAGE: "A column declared as an exact number holds a value that is not one.",
|
|
158
|
+
ANSWER_INVALID: "A custom source or a database driver answered a value that breaks the contract, a bug in the host; the message names the column.",
|
|
139
159
|
VERSION_CONFLICT: "The dashboard changed since this draft was started.",
|
|
140
160
|
DRAFT_CONFLICT: "The draft changed since this edit was made. Reload the draft and try again.",
|
|
141
161
|
DRAFT_CLOSED: "The draft was published or discarded. Start a new edit.",
|
|
@@ -156,4 +176,4 @@ const BASE_ERROR_CODES = defineErrorCodes({
|
|
|
156
176
|
DRILL_STALE: "The dashboard changed since the drill was opened. Open it again from the chart.",
|
|
157
177
|
CONTRACT_MISMATCH: "This page and the dashboards server are from different releases. Reload the page."
|
|
158
178
|
});
|
|
159
|
-
export { BASE_ERROR_CODES, CATALOG_ISSUES, DOCUMENT_REFUSALS, DRILL_REASONS, MODEL_ISSUES, RESULT_WARNINGS, defineErrorCodes };
|
|
179
|
+
export { BASE_ERROR_CODES, CATALOG_ISSUES, DOCUMENT_REFUSALS, DRILL_REASONS, MODEL_ISSUES, RESULT_WARNINGS, START_REFUSALS, defineErrorCodes };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { QueryRefusalCode } from "./codes.mjs";
|
|
2
|
-
/** Why an engine refused or failed a query. The codes are the oracle's, plus
|
|
3
|
-
export type EngineErrorCode = QueryRefusalCode | "PLAN_ASSERTION" | "NUMERIC_STORAGE";
|
|
2
|
+
/** Why an engine refused or failed a query. The codes are the oracle's, plus three of its own. */
|
|
3
|
+
export type EngineErrorCode = QueryRefusalCode | "PLAN_ASSERTION" | "NUMERIC_STORAGE" | "ANSWER_INVALID";
|
|
4
4
|
/** Thrown by the engine. A host maps `code` to its response; the message names the value. */
|
|
5
5
|
export declare class EngineError extends Error {
|
|
6
6
|
readonly code: EngineErrorCode;
|
|
7
7
|
constructor(code: EngineErrorCode, message: string);
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A value a host's custom source or its database driver answered that breaks the contract: a
|
|
11
|
+
* bug in the host, not a refusal, named by the column it came in.
|
|
12
|
+
*/
|
|
13
|
+
export declare const answerInvalid: (column: string, message: string) => EngineError;
|
|
@@ -8,4 +8,9 @@ var EngineError = class extends Error {
|
|
|
8
8
|
this.code = code;
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A value a host's custom source or its database driver answered that breaks the contract: a
|
|
13
|
+
* bug in the host, not a refusal, named by the column it came in.
|
|
14
|
+
*/
|
|
15
|
+
const answerInvalid = (column, message) => new EngineError("ANSWER_INVALID", `Column "${column}": ${message}`);
|
|
16
|
+
export { EngineError, answerInvalid };
|
|
@@ -3,17 +3,4 @@ import { formatExact, parseExact } from "./text.mjs";
|
|
|
3
3
|
* Exact numbers are whole numbers of minor units (cents at scale 2). They are `bigint` from
|
|
4
4
|
* the aggregate to the cell, where they become text. They never pass through a `number`.
|
|
5
5
|
*/
|
|
6
|
-
export type Exact = bigint;
|
|
7
|
-
/** The size no aggregate can reach (see lean/Kernel/Exact.lean) and no cell may pass. */
|
|
8
|
-
export declare const EXACT_LIMIT: Exact;
|
|
9
|
-
/**
|
|
10
|
-
* `numerator / denominator` to `places` decimal places, as a whole number of 10^-places,
|
|
11
|
-
* rounded half to even in one step. Null when the denominator is zero.
|
|
12
|
-
*/
|
|
13
|
-
export declare function divideExact(numerator: Exact, denominator: Exact, places: number): Exact | null;
|
|
14
|
-
/**
|
|
15
|
-
* A stored exact value as minor units. `minor_units` columns hold whole numbers (as a number
|
|
16
|
-
* or, past 2^53, as digit text); `decimal` columns hold decimal text at the declared scale.
|
|
17
|
-
* Anything else is null: it is not an exact value of that column.
|
|
18
|
-
*/
|
|
19
|
-
export declare function storedExact(value: string | number | boolean | null, stored: "decimal" | "minor_units", scale: number): Exact | null;
|
|
6
|
+
export type Exact = bigint;
|
|
@@ -3,18 +3,21 @@ import { Big } from "big.js";
|
|
|
3
3
|
// src/exact/decimal.ts
|
|
4
4
|
/** The size no aggregate can reach (see lean/Kernel/Exact.lean) and no cell may pass. */
|
|
5
5
|
const EXACT_LIMIT = 10n ** 100n;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Rounding mode 1 in big.js: half away from zero, the rule every number on screen is written
|
|
8
|
+
* with too (Intl's `halfExpand`, `format/write.ts`), so a value rounds one way wherever it is.
|
|
9
|
+
*/
|
|
10
|
+
const HALF_AWAY_FROM_ZERO = 1;
|
|
11
|
+
/** A big.js constructor that rounds every division to `places` decimal places, half away from zero. */
|
|
9
12
|
function decimalAt(places) {
|
|
10
13
|
const D = Big();
|
|
11
14
|
D.DP = places;
|
|
12
|
-
D.RM =
|
|
15
|
+
D.RM = HALF_AWAY_FROM_ZERO;
|
|
13
16
|
return D;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* `numerator / denominator` to `places` decimal places, as a whole number of 10^-places,
|
|
17
|
-
* rounded half
|
|
20
|
+
* rounded half away from zero in one step. Null when the denominator is zero.
|
|
18
21
|
*/
|
|
19
22
|
function divideExact(numerator, denominator, places) {
|
|
20
23
|
if (denominator === 0n) return null;
|
|
@@ -22,17 +25,4 @@ function divideExact(numerator, denominator, places) {
|
|
|
22
25
|
const quotient = D(numerator).div(D(denominator));
|
|
23
26
|
return BigInt(quotient.times(D(10).pow(places)).toFixed(0));
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
* A stored exact value as minor units. `minor_units` columns hold whole numbers (as a number
|
|
27
|
-
* or, past 2^53, as digit text); `decimal` columns hold decimal text at the declared scale.
|
|
28
|
-
* Anything else is null: it is not an exact value of that column.
|
|
29
|
-
*/
|
|
30
|
-
function storedExact(value, stored, scale) {
|
|
31
|
-
if (stored === "minor_units") {
|
|
32
|
-
if (typeof value === "number") return Number.isSafeInteger(value) ? BigInt(value) : null;
|
|
33
|
-
return typeof value === "string" && /^-?\d+$/u.test(value) ? BigInt(value) : null;
|
|
34
|
-
}
|
|
35
|
-
if (typeof value !== "string" && typeof value !== "number") return null;
|
|
36
|
-
return parseExact(String(value), scale) ?? null;
|
|
37
|
-
}
|
|
38
|
-
export { EXACT_LIMIT, divideExact, formatExact, parseExact, storedExact };
|
|
28
|
+
export { EXACT_LIMIT, divideExact, formatExact, parseExact };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Reading, StoredValue } from "../value/stored.mjs";
|
|
2
|
+
import { Exact } from "./decimal.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The one reader of a stored exact value, as minor units, for every source. `minor_units`
|
|
5
|
+
* columns hold whole numbers (a number, a `bigint`, or digit text past 2^53); `decimal` columns
|
|
6
|
+
* hold decimal text, a number or a `bigint`, at the declared scale. Either is below 10^38 minor
|
|
7
|
+
* units (`OPERAND_LIMIT`). Anything else is unread, with its reason: never null unless stored null.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readExact(value: StoredValue | undefined, stored: "decimal" | "minor_units", scale: number): Reading<Exact>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { readValue, wholeNumber } from "../value/stored.mjs";
|
|
2
|
+
import { parseExact, plainDecimal } from "./text.mjs";
|
|
3
|
+
// src/exact/stored.ts
|
|
4
|
+
/**
|
|
5
|
+
* The size every operand is below: lean/Kernel/Exact.lean proves sums of such operands stay
|
|
6
|
+
* below 10^70, inside `EXACT_LIMIT`. A larger stored value is unread, in every engine.
|
|
7
|
+
*/
|
|
8
|
+
const OPERAND_LIMIT = 10n ** 38n;
|
|
9
|
+
const unread = (why) => ({ unread: why });
|
|
10
|
+
/** A whole number of minor units. */
|
|
11
|
+
function minorUnits(value) {
|
|
12
|
+
const units = wholeNumber(value);
|
|
13
|
+
return units === void 0 ? unread("is not a whole number of minor units") : { value: units };
|
|
14
|
+
}
|
|
15
|
+
/** Decimal text, a number or a `bigint`, at most at the declared scale. */
|
|
16
|
+
function decimalUnits(value, scale) {
|
|
17
|
+
if (typeof value === "bigint") return { value: value * 10n ** BigInt(scale) };
|
|
18
|
+
if (typeof value !== "string" && typeof value !== "number") return unread(`is a ${typeof value}`);
|
|
19
|
+
const text = typeof value === "number" ? plainDecimal(value) : value;
|
|
20
|
+
if (text === void 0) return unread("is not a finite number");
|
|
21
|
+
const units = parseExact(text, scale);
|
|
22
|
+
return units === void 0 ? unread(`is not a number with at most ${scale} places`) : { value: units };
|
|
23
|
+
}
|
|
24
|
+
/** A value inside the operand bound the aggregate bound is proven for, else unread. */
|
|
25
|
+
const bounded = (read) => "value" in read && read.value !== null && (read.value < 0n ? -read.value : read.value) >= OPERAND_LIMIT ? unread("is not below 10^38 minor units, the operand bound exact sums are proven for") : read;
|
|
26
|
+
/**
|
|
27
|
+
* The one reader of a stored exact value, as minor units, for every source. `minor_units`
|
|
28
|
+
* columns hold whole numbers (a number, a `bigint`, or digit text past 2^53); `decimal` columns
|
|
29
|
+
* hold decimal text, a number or a `bigint`, at the declared scale. Either is below 10^38 minor
|
|
30
|
+
* units (`OPERAND_LIMIT`). Anything else is unread, with its reason: never null unless stored null.
|
|
31
|
+
*/
|
|
32
|
+
function readExact(value, stored, scale) {
|
|
33
|
+
if (value === null || value === void 0) return { value: null };
|
|
34
|
+
return bounded(stored === "minor_units" ? minorUnits(value) : decimalUnits(value, scale));
|
|
35
|
+
}
|
|
36
|
+
/** A stored exact value as minor units: null when stored null or unread. */
|
|
37
|
+
const storedExact = (value, stored, scale) => readValue(readExact(value, stored, scale));
|
|
38
|
+
export { OPERAND_LIMIT, readExact, storedExact };
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
import { ResultCell } from "../result/types.mjs";
|
|
1
2
|
import { Exact } from "./decimal.mjs";
|
|
2
3
|
/** Minor units as decimal text: 1234 at scale 2 is "12.34"; -5 at scale 2 is "-0.05". */
|
|
3
4
|
export declare function formatExact(value: Exact, scale: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* A plain decimal with its point moved `by` places to the right (to the left when negative):
|
|
7
|
+
* "0.425" by 2 is "42.5". Only the point moves: every digit is kept, and no float is made.
|
|
8
|
+
*/
|
|
9
|
+
export declare function movePoint(digits: string, by: number): string;
|
|
4
10
|
/** Decimal text as minor units. Undefined when it is not a number with at most `scale` places. */
|
|
5
|
-
export declare function parseExact(text: string, scale: number): Exact | undefined;
|
|
11
|
+
export declare function parseExact(text: string, scale: number): Exact | undefined;
|
|
12
|
+
/** How many places after the point a plain decimal has: "12.50" has two, "12" none. */
|
|
13
|
+
export declare const decimalPlaces: (digits: string) => number;
|
|
14
|
+
/**
|
|
15
|
+
* A cell's number as plain decimal text: an exact cell's digits (an exponent written out), the
|
|
16
|
+
* digits a float is written in, or a text that is a number's (a driver may hand a number over
|
|
17
|
+
* as its text). Undefined for a cell that is not a finite number: a float that is not one, a
|
|
18
|
+
* text that is no number, a mark, a yes or no, or nothing. The one reader of a cell's digits.
|
|
19
|
+
*/
|
|
20
|
+
export declare function cellDigits(cell: ResultCell | undefined): string | undefined;
|
package/dist/core/exact/text.mjs
CHANGED
|
@@ -8,6 +8,42 @@ function formatExact(value, scale) {
|
|
|
8
8
|
}
|
|
9
9
|
/** The one form of decimal text, as Postgres prints `numeric`: no exponent, no bare point. */
|
|
10
10
|
const DECIMAL_TEXT = /^-?\d+(?:\.\d+)?$/u;
|
|
11
|
+
/**
|
|
12
|
+
* A plain decimal with its point moved `by` places to the right (to the left when negative):
|
|
13
|
+
* "0.425" by 2 is "42.5". Only the point moves: every digit is kept, and no float is made.
|
|
14
|
+
*/
|
|
15
|
+
function movePoint(digits, by) {
|
|
16
|
+
const [whole = "0", part = ""] = digits.replace("-", "").split(".");
|
|
17
|
+
const all = `${whole}${part}`;
|
|
18
|
+
const at = whole.length + by;
|
|
19
|
+
const padded = at <= 0 ? `${"0".repeat(1 - at)}${all}` : all.padEnd(at, "0");
|
|
20
|
+
const cut = Math.max(at, 1);
|
|
21
|
+
const left = padded.slice(0, cut).replace(/^0+(?=\d)/u, "");
|
|
22
|
+
const right = padded.slice(cut);
|
|
23
|
+
return `${digits.startsWith("-") && /[1-9]/u.test(all) ? "-" : ""}${left}${right === "" ? "" : `.${right}`}`;
|
|
24
|
+
}
|
|
25
|
+
/** Decimal text with an exponent: digits, maybe a fraction, then the power ("1.5e-7", "2E+3"). */
|
|
26
|
+
const EXPONENT_TEXT = /^(?<digits>-?\d+(?:\.\d+)?)e(?<power>[+-]?\d+)$/iu;
|
|
27
|
+
/** The largest power of ten written out: past it a text is not taken for a number worth its zeros. */
|
|
28
|
+
const MOST_POWER = 400;
|
|
29
|
+
/**
|
|
30
|
+
* Decimal text as a plain decimal: itself when it is one, and with its exponent written out
|
|
31
|
+
* when it has one ("1e-7" is "0.0000001"). Undefined for a text that is no number. The one
|
|
32
|
+
* place an exponent is written out.
|
|
33
|
+
*/
|
|
34
|
+
function plainDecimalText(text) {
|
|
35
|
+
if (DECIMAL_TEXT.test(text)) return text;
|
|
36
|
+
const found = EXPONENT_TEXT.exec(text)?.groups;
|
|
37
|
+
const power = Number(found?.["power"]);
|
|
38
|
+
if (found === void 0 || Math.abs(power) > MOST_POWER) return void 0;
|
|
39
|
+
return movePoint(found["digits"] ?? "0", power);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A float as plain decimal text: the shortest digits that read back as it (JavaScript's own),
|
|
43
|
+
* with an exponent written out, so 1e21 is "1000000000000000000000" and 1e-7 is "0.0000001".
|
|
44
|
+
* The one place a float becomes decimal text. Undefined for NaN and the infinities.
|
|
45
|
+
*/
|
|
46
|
+
const plainDecimal = (value) => Number.isFinite(value) ? plainDecimalText(String(value)) : void 0;
|
|
11
47
|
/** Decimal text as minor units. Undefined when it is not a number with at most `scale` places. */
|
|
12
48
|
function parseExact(text, scale) {
|
|
13
49
|
if (!DECIMAL_TEXT.test(text)) return void 0;
|
|
@@ -16,4 +52,17 @@ function parseExact(text, scale) {
|
|
|
16
52
|
const units = BigInt(`${whole}${fraction.slice(0, scale).padEnd(scale, "0")}`);
|
|
17
53
|
return text.startsWith("-") ? -units : units;
|
|
18
54
|
}
|
|
19
|
-
|
|
55
|
+
/** How many places after the point a plain decimal has: "12.50" has two, "12" none. */
|
|
56
|
+
const decimalPlaces = (digits) => digits.split(".")[1]?.length ?? 0;
|
|
57
|
+
/**
|
|
58
|
+
* A cell's number as plain decimal text: an exact cell's digits (an exponent written out), the
|
|
59
|
+
* digits a float is written in, or a text that is a number's (a driver may hand a number over
|
|
60
|
+
* as its text). Undefined for a cell that is not a finite number: a float that is not one, a
|
|
61
|
+
* text that is no number, a mark, a yes or no, or nothing. The one reader of a cell's digits.
|
|
62
|
+
*/
|
|
63
|
+
function cellDigits(cell) {
|
|
64
|
+
if (typeof cell === "number") return plainDecimal(cell);
|
|
65
|
+
if (typeof cell === "string") return plainDecimalText(cell.trim());
|
|
66
|
+
if (cell !== null && typeof cell === "object" && "v" in cell) return plainDecimalText(cell.v);
|
|
67
|
+
}
|
|
68
|
+
export { cellDigits, decimalPlaces, formatExact, movePoint, parseExact, plainDecimal, plainDecimalText };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/format/digits.ts
|
|
2
|
+
/** The most rounding moves a number that is not zero, as a fraction of itself. */
|
|
3
|
+
const MOST_MOVED = .1;
|
|
4
|
+
/** Under this size a number that is not zero is written by its power of ten: a row of zeros is not read. */
|
|
5
|
+
const MINUTE = 1e-6;
|
|
6
|
+
/** From this size a plain number's tick is written by its power of ten: past a thousand trillion the short scale has no word. */
|
|
7
|
+
const VAST = 0x38d7ea4c68000;
|
|
8
|
+
/**
|
|
9
|
+
* Whether `places` after the point write a number of this size within `MOST_MOVED` of itself:
|
|
10
|
+
* half a unit of the last place is at most that fraction of it. 0.05 holds two places; 0.045
|
|
11
|
+
* does not ("0.05" would move it by a ninth), nor 0.0051 ("0.01" would nearly double it).
|
|
12
|
+
*/
|
|
13
|
+
const holds = (size, places) => size >= .5 / MOST_MOVED * 10 ** -places;
|
|
14
|
+
/** A number too small for its places: its first two figures (0.0049), and under a millionth those and its power of ten (5.6E-17). Two figures move it by a twentieth at most. */
|
|
15
|
+
const fine = (size, minute = MINUTE) => size < minute ? {
|
|
16
|
+
notation: "scientific",
|
|
17
|
+
maximumSignificantDigits: 2
|
|
18
|
+
} : { maximumSignificantDigits: 2 };
|
|
19
|
+
/** The digits a number is written in: `places` after the point while they hold it, else its first figures. */
|
|
20
|
+
const digitsFor = (value, places) => value === 0 || holds(Math.abs(value), places) ? { maximumFractionDigits: places } : fine(Math.abs(value));
|
|
21
|
+
/**
|
|
22
|
+
* The digits an axis tick is written in, for a value, the whole it is a part of (1, or 100 for
|
|
23
|
+
* percent points), and whether it is money. Three figures hold every round step an axis takes
|
|
24
|
+
* (0.025, 12.5, 1.25K), where one decimal wrote 0.05, 0.1 and 0.15 all as 0.1, and move a tick
|
|
25
|
+
* by a two-hundredth of itself at most. A number under a millionth of the whole comes with its
|
|
26
|
+
* power of ten, as does a plain one past a thousand trillion; an amount of money that large is
|
|
27
|
+
* read in its currency's short form ($15,000T), never as "$1.5E16".
|
|
28
|
+
*/
|
|
29
|
+
function tickDigits(value, whole, money) {
|
|
30
|
+
const size = Math.abs(value);
|
|
31
|
+
return value !== 0 && (size < MINUTE * whole || size >= VAST * whole && !money) ? {
|
|
32
|
+
notation: "scientific",
|
|
33
|
+
maximumSignificantDigits: 3
|
|
34
|
+
} : {
|
|
35
|
+
notation: "compact",
|
|
36
|
+
maximumSignificantDigits: 3
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The digits a percent is written in, from its value and the whole it is a part of (1 for a
|
|
41
|
+
* fraction, 100 for points). Whole percents read cleanly (67%); below 10% one decimal keeps
|
|
42
|
+
* small rates apart (4.5%); a percent one decimal would move by more than a tenth of itself
|
|
43
|
+
* (under 0.5%) keeps its first figures (`fine`), never "0.1%" for 0.06%. The value is weighed
|
|
44
|
+
* against the whole, never divided by it: the smallest float divided by a hundred is zero.
|
|
45
|
+
*/
|
|
46
|
+
function percentDigits(value, whole) {
|
|
47
|
+
const points = Math.abs(value) * (100 / whole);
|
|
48
|
+
const places = points >= 10 || value === 0 ? 0 : 1;
|
|
49
|
+
if (value !== 0 && !holds(points, places)) return fine(Math.abs(value), MINUTE * .01 * whole);
|
|
50
|
+
return {
|
|
51
|
+
minimumFractionDigits: places,
|
|
52
|
+
maximumFractionDigits: places
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export { MOST_MOVED, digitsFor, fine, holds, percentDigits, tickDigits };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NumberShape, NumberValue, durationUnits, signOf } from "./number.mjs";
|
|
2
|
+
import { MINUS, Writable, currencyOf } from "./write.mjs";
|
|
3
|
+
/** How numbers are written in one locale. */
|
|
4
|
+
export type NumberWriter = {
|
|
5
|
+
/** A number in full, by its column's shape: a percent, a duration, money or a plain number. */
|
|
6
|
+
text: (value: NumberValue, shape?: NumberShape) => string;
|
|
7
|
+
/** A short axis label (12K, $1.25M, 0.025): three figures, which hold every round step an axis takes. */
|
|
8
|
+
tick: (value: number, shape?: NumberShape) => string;
|
|
9
|
+
/** A number in a style of the caller's, with the sign rule (a headline's whole units). */
|
|
10
|
+
styled: (style: Intl.NumberFormatOptions, value: Writable) => string;
|
|
11
|
+
/** The places a currency's amounts are written to: two, or its own where that has more. */
|
|
12
|
+
places: (currency: string | undefined) => number;
|
|
13
|
+
};
|
|
14
|
+
/** A writer for each locale, each made once and held by the caller: a table must not make one per cell. */
|
|
15
|
+
export declare function numberWriters(): (locale?: string) => NumberWriter;
|
|
16
|
+
export { MINUS, type NumberShape, currencyOf, durationUnits, signOf };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { durationUnits, signOf, textOf, tickOf } from "./number.mjs";
|
|
2
|
+
import { MINUS, currencyOf, formatsIn, placesIn, writeStyled } from "./write.mjs";
|
|
3
|
+
// src/format/index.ts
|
|
4
|
+
/** A writer for each locale, each made once and held by the caller: a table must not make one per cell. */
|
|
5
|
+
function numberWriters() {
|
|
6
|
+
const made = /* @__PURE__ */ new Map();
|
|
7
|
+
return (locale) => {
|
|
8
|
+
const found = made.get(locale ?? "");
|
|
9
|
+
if (found !== void 0) return found;
|
|
10
|
+
const formats = formatsIn(locale);
|
|
11
|
+
const places = /* @__PURE__ */ new Map();
|
|
12
|
+
const placesOf = (currency) => {
|
|
13
|
+
const known = places.get(currency) ?? placesIn(formats, currency);
|
|
14
|
+
places.set(currency, known);
|
|
15
|
+
return known;
|
|
16
|
+
};
|
|
17
|
+
const writer = {
|
|
18
|
+
text: (value, shape = {}) => textOf(value, shape, formats),
|
|
19
|
+
tick: (value, shape = {}) => tickOf(value, shape, formats),
|
|
20
|
+
styled: (style, value) => writeStyled(formats, style, value),
|
|
21
|
+
places: placesOf
|
|
22
|
+
};
|
|
23
|
+
made.set(locale ?? "", writer);
|
|
24
|
+
return writer;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export { MINUS, currencyOf, durationUnits, numberWriters, signOf };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ResultColumn } from "../result/types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* What a number's column says of how it is written. A duration's `unit` is what its values
|
|
4
|
+
* count (seconds when left out, `microsecond` for an `elapsed`); `beside` is a value it is
|
|
5
|
+
* written next to, counted alike: a duration is then written in that value's unit, so a change
|
|
6
|
+
* reads "+0.8 days" beside "4.8 days", never "+19.2 hr", and an axis's ticks read in the one
|
|
7
|
+
* unit it steps in.
|
|
8
|
+
*/
|
|
9
|
+
export type NumberShape = Partial<Pick<ResultColumn, "format" | "unit" | "signed" | "fraction">> & {
|
|
10
|
+
beside?: number;
|
|
11
|
+
};
|
|
12
|
+
/** A number to write: a float, or an exact amount's decimal text. */
|
|
13
|
+
export type NumberValue = number | {
|
|
14
|
+
v: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The sign a column's numbers are written with. A change (`signed`) says which way it went,
|
|
18
|
+
* so a rise has its plus (+2.32, +$340.03) and nothing has neither; anything else has a sign
|
|
19
|
+
* only when it is below nothing.
|
|
20
|
+
*/
|
|
21
|
+
export declare const signOf: (shape: NumberShape) => Intl.NumberFormatOptions;
|
|
22
|
+
/**
|
|
23
|
+
* The sizes of the units a duration is written in (a day, an hour, a minute, a second), largest
|
|
24
|
+
* first, counted as its values are; none for a value that is no duration. An axis steps in
|
|
25
|
+
* whole numbers of one of them.
|
|
26
|
+
*/
|
|
27
|
+
export declare function durationUnits(shape: NumberShape): readonly number[] | undefined;
|