derive-dashboards 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +513 -0
- package/README.md +8 -2
- package/dist/adapter/statement.mjs +9 -7
- package/dist/authorize.mjs +27 -6
- package/dist/body.mjs +28 -25
- package/dist/cache.d.mts +2 -2
- package/dist/charts/data/buckets.d.mts +25 -7
- package/dist/charts/data/buckets.mjs +92 -15
- package/dist/charts/data/clean.mjs +254 -12
- package/dist/charts/data/format.d.mts +7 -2
- package/dist/charts/data/format.mjs +68 -70
- package/dist/charts/data/input-error.d.mts +2 -0
- package/dist/charts/data/input-error.mjs +2 -0
- package/dist/charts/data/rows.d.mts +3 -1
- package/dist/charts/data/rows.mjs +4 -2
- package/dist/charts/data/types.d.mts +50 -7
- package/dist/charts/data/words.d.mts +13 -0
- package/dist/charts/data/words.mjs +8 -1
- package/dist/charts/describe.mjs +6 -6
- package/dist/charts/index.d.mts +14 -14
- package/dist/charts/index.mjs +4 -1
- package/dist/charts/kinds/area-marks.mjs +86 -44
- package/dist/charts/kinds/area.d.mts +3 -3
- package/dist/charts/kinds/area.mjs +32 -11
- package/dist/charts/kinds/bars-data.d.mts +3 -3
- package/dist/charts/kinds/bars-data.mjs +12 -6
- package/dist/charts/kinds/bars-layout.mjs +60 -6
- package/dist/charts/kinds/bars-marks.mjs +6 -6
- package/dist/charts/kinds/bars.d.mts +5 -3
- package/dist/charts/kinds/bars.mjs +39 -6
- package/dist/charts/kinds/columns-data.mjs +14 -5
- package/dist/charts/kinds/columns-marks.mjs +52 -23
- package/dist/charts/kinds/columns.d.mts +2 -2
- package/dist/charts/kinds/columns.mjs +36 -10
- package/dist/charts/kinds/course-data.mjs +44 -0
- package/dist/charts/kinds/course-layout.mjs +77 -0
- package/dist/charts/kinds/course-marks.mjs +52 -0
- package/dist/charts/kinds/course-words.mjs +64 -0
- package/dist/charts/kinds/course.d.mts +10 -0
- package/dist/charts/kinds/course.mjs +55 -0
- package/dist/charts/kinds/dumbbell-data.d.mts +4 -4
- package/dist/charts/kinds/dumbbell-data.mjs +3 -3
- package/dist/charts/kinds/dumbbell-layout.mjs +17 -8
- package/dist/charts/kinds/dumbbell.d.mts +5 -3
- package/dist/charts/kinds/dumbbell.mjs +35 -4
- package/dist/charts/kinds/funnel-data.d.mts +3 -3
- package/dist/charts/kinds/funnel-data.mjs +11 -16
- package/dist/charts/kinds/funnel-layout.mjs +7 -6
- package/dist/charts/kinds/funnel.d.mts +5 -4
- package/dist/charts/kinds/funnel.mjs +33 -6
- package/dist/charts/kinds/grid-data.d.mts +3 -3
- package/dist/charts/kinds/grid-data.mjs +55 -13
- package/dist/charts/kinds/grid-layout.mjs +88 -13
- package/dist/charts/kinds/grid-legend.mjs +60 -0
- package/dist/charts/kinds/grid-marks.mjs +81 -32
- package/dist/charts/kinds/grid-time.mjs +19 -5
- package/dist/charts/kinds/grid-words.mjs +57 -35
- package/dist/charts/kinds/grid.d.mts +7 -4
- package/dist/charts/kinds/grid.mjs +51 -9
- package/dist/charts/kinds/histogram-data.mjs +68 -26
- package/dist/charts/kinds/histogram-layout.mjs +4 -3
- package/dist/charts/kinds/histogram-words.mjs +2 -3
- package/dist/charts/kinds/histogram.d.mts +2 -2
- package/dist/charts/kinds/histogram.mjs +17 -1
- package/dist/charts/kinds/line-marks.mjs +19 -11
- package/dist/charts/kinds/line.d.mts +2 -2
- package/dist/charts/kinds/line.mjs +21 -3
- package/dist/charts/kinds/multiples-grid.mjs +57 -27
- package/dist/charts/kinds/multiples-head.mjs +52 -22
- package/dist/charts/kinds/multiples-layout.mjs +106 -52
- package/dist/charts/kinds/multiples-marks.mjs +6 -5
- package/dist/charts/kinds/multiples-words.mjs +53 -38
- package/dist/charts/kinds/multiples.d.mts +2 -2
- package/dist/charts/kinds/multiples.mjs +35 -7
- package/dist/charts/kinds/row-chart.d.mts +7 -0
- package/dist/charts/kinds/row-chart.mjs +47 -10
- package/dist/charts/kinds/row-marks.mjs +5 -5
- package/dist/charts/kinds/scatter-data.d.mts +5 -5
- package/dist/charts/kinds/scatter-data.mjs +6 -6
- package/dist/charts/kinds/scatter-marks.mjs +46 -19
- package/dist/charts/kinds/scatter-words.mjs +8 -8
- package/dist/charts/kinds/scatter.d.mts +5 -3
- package/dist/charts/kinds/scatter.mjs +18 -0
- package/dist/charts/kinds/stat-data.mjs +7 -7
- package/dist/charts/kinds/stat-marks.mjs +2 -2
- package/dist/charts/kinds/stat.d.mts +4 -4
- package/dist/charts/kinds/stat.mjs +19 -0
- package/dist/charts/kinds/time-chart.mjs +13 -4
- package/dist/charts/kinds/time-frame.mjs +50 -19
- package/dist/charts/kinds/time-plan.mjs +29 -2
- package/dist/charts/kinds/time-plot.mjs +1 -1
- package/dist/charts/kinds/time-stops.mjs +58 -29
- package/dist/charts/kinds/waterfall-data.d.mts +3 -3
- package/dist/charts/kinds/waterfall-data.mjs +2 -2
- package/dist/charts/kinds/waterfall.d.mts +5 -4
- package/dist/charts/kinds/waterfall.mjs +29 -2
- package/dist/charts/layout/frame.mjs +5 -3
- package/dist/charts/layout/stack.mjs +43 -22
- package/dist/charts/marks/axes.mjs +12 -6
- package/dist/charts/marks/budget.mjs +14 -0
- package/dist/charts/marks/end-labels.mjs +24 -10
- package/dist/charts/marks/legend.mjs +19 -8
- package/dist/charts/marks/lines.mjs +3 -3
- package/dist/charts/marks/more.mjs +79 -13
- package/dist/charts/marks/notes.mjs +12 -6
- package/dist/charts/marks/series-line.mjs +14 -10
- package/dist/charts/marks/thin.mjs +16 -33
- package/dist/charts/marks/x-axis.mjs +3 -2
- package/dist/charts/scale/calendar.mjs +41 -26
- package/dist/charts/scale/linear.mjs +58 -0
- package/dist/charts/scale/value.d.mts +21 -0
- package/dist/charts/scale/value.mjs +67 -9
- package/dist/charts/scene/lazy.mjs +27 -0
- package/dist/charts/scene/markup.mjs +2 -1
- package/dist/charts/scene/svg.mjs +20 -8
- package/dist/charts/scene/types.d.mts +34 -0
- package/dist/charts/text/measure.mjs +33 -3
- package/dist/charts/theme.d.mts +25 -25
- package/dist/charts/theme.mjs +47 -30
- package/dist/charts-react/Chart.d.mts +20 -0
- package/dist/charts-react/Chart.mjs +9 -67
- package/dist/charts-react/Reader.mjs +50 -96
- package/dist/charts-react/box.mjs +106 -0
- package/dist/charts-react/bucket-names.mjs +9 -24
- package/dist/charts-react/columns-picture.mjs +12 -0
- package/dist/charts-react/exact-sum.mjs +4 -7
- package/dist/charts-react/from-answer.mjs +9 -4
- package/dist/charts-react/index.d.mts +9 -2
- package/dist/charts-react/index.mjs +9 -2
- package/dist/charts-react/kinds/area.d.mts +4 -0
- package/dist/charts-react/kinds/area.mjs +38 -0
- package/dist/charts-react/kinds/bar.d.mts +4 -0
- package/dist/charts-react/kinds/bar.mjs +15 -0
- package/dist/charts-react/kinds/funnel.d.mts +4 -0
- package/dist/charts-react/kinds/funnel.mjs +13 -0
- package/dist/charts-react/kinds/heatmap.d.mts +4 -0
- package/dist/charts-react/kinds/heatmap.mjs +13 -0
- package/dist/charts-react/kinds/line.d.mts +4 -0
- package/dist/charts-react/kinds/line.mjs +20 -0
- package/dist/charts-react/kinds/multiples.d.mts +4 -0
- package/dist/charts-react/kinds/multiples.mjs +33 -0
- package/dist/charts-react/kinds/number.d.mts +5 -0
- package/dist/charts-react/kinds/number.mjs +86 -0
- package/dist/charts-react/plan-bars.mjs +15 -8
- package/dist/charts-react/plan-funnel.mjs +3 -1
- package/dist/charts-react/plan-grid.mjs +14 -5
- package/dist/charts-react/plan-of.mjs +17 -0
- package/dist/charts-react/plan-parts.mjs +16 -5
- package/dist/charts-react/plan-time.mjs +4 -53
- package/dist/charts-react/reader-page.d.mts +1 -1
- package/dist/charts-react/reader-page.mjs +19 -9
- package/dist/charts-react/renderers.d.mts +14 -0
- package/dist/charts-react/renderers.mjs +22 -0
- package/dist/charts-react/table.d.mts +1 -0
- package/dist/charts-react/table.mjs +108 -0
- package/dist/charts-react/tiles.mjs +21 -49
- package/dist/charts-react/useScene.mjs +45 -17
- package/dist/charts-react/words.mjs +19 -0
- package/dist/checks.mjs +97 -19
- package/dist/cli/add.mjs +4 -3
- package/dist/cli/doctor.mjs +2 -2
- package/dist/core/conformance/index.d.mts +5 -2
- package/dist/core/conformance/index.mjs +5 -2
- package/dist/core/conformance/memory/aggregate.mjs +11 -6
- package/dist/core/conformance/memory/rows.d.mts +7 -3
- package/dist/core/conformance/memory/rows.mjs +19 -13
- package/dist/core/conformance/memory/source.mjs +4 -4
- package/dist/core/document/control-fields.d.mts +20 -0
- package/dist/core/document/control-fields.mjs +117 -0
- package/dist/core/document/display-comparisons.d.mts +17 -0
- package/dist/core/document/display-comparisons.mjs +15 -4
- package/dist/core/document/display-entries.d.mts +14 -0
- package/dist/core/document/display-entries.mjs +25 -9
- package/dist/core/document/display-validation.d.mts +5 -1
- package/dist/core/document/display-validation.mjs +14 -7
- package/dist/core/document/display.d.mts +11 -8
- package/dist/core/document/display.mjs +26 -3
- package/dist/core/document/layout.d.mts +8 -9
- package/dist/core/document/layout.mjs +23 -6
- package/dist/core/document/stacked.d.mts +0 -7
- package/dist/core/document/types.mjs +8 -6
- package/dist/core/document/upgrade.d.mts +1 -0
- package/dist/core/document/upgrade.mjs +4 -2
- package/dist/core/engine/access.mjs +3 -3
- package/dist/core/engine/assert.mjs +4 -2
- package/dist/core/engine/bucket.mjs +2 -2
- package/dist/core/engine/checks.mjs +6 -7
- package/dist/core/engine/custom/ask.mjs +22 -2
- package/dist/core/engine/custom/cells.mjs +22 -22
- package/dist/core/engine/custom/level.mjs +12 -13
- package/dist/core/engine/custom/measures.mjs +12 -9
- package/dist/core/engine/custom/reader.mjs +3 -1
- package/dist/core/engine/custom/records.mjs +8 -7
- package/dist/core/engine/custom/unread.mjs +78 -0
- package/dist/core/engine/custom/where.mjs +15 -10
- package/dist/core/engine/index.d.mts +2 -13
- package/dist/core/engine/index.mjs +2 -12
- package/dist/core/engine/measure.mjs +1 -0
- package/dist/core/engine/members.mjs +7 -3
- package/dist/core/engine/nan.mjs +10 -1
- package/dist/core/engine/native.mjs +2 -20
- package/dist/core/engine/numbers.mjs +26 -14
- package/dist/core/engine/postgres.mjs +9 -5
- package/dist/core/engine/prepare.mjs +4 -4
- package/dist/core/engine/rank-sets.mjs +1 -1
- package/dist/core/engine/read.mjs +5 -4
- package/dist/core/engine/reader.d.mts +6 -0
- package/dist/core/engine/record-layout.mjs +3 -3
- package/dist/core/engine/run.mjs +77 -20
- package/dist/core/engine/segmented.d.mts +2 -1
- package/dist/core/engine/segmented.mjs +19 -12
- package/dist/core/engine/series.mjs +1 -1
- package/dist/core/engine/shape.mjs +8 -8
- package/dist/core/engine/sql-partition.mjs +2 -2
- package/dist/core/engine/sql-pass.mjs +3 -2
- package/dist/core/engine/sql-reader.mjs +13 -5
- package/dist/core/engine/sql-reads.mjs +2 -1
- package/dist/core/engine/sql-records.mjs +2 -2
- package/dist/core/engine/sql-split.mjs +1 -1
- package/dist/core/engine/sql-unread.mjs +70 -0
- package/dist/core/engine/time.mjs +2 -1
- package/dist/core/engine/types.d.mts +17 -0
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +24 -1
- package/dist/core/error/codes.mjs +23 -3
- package/dist/core/error/refusal.d.mts +8 -3
- package/dist/core/error/refusal.mjs +6 -1
- package/dist/core/exact/decimal.d.mts +1 -14
- package/dist/core/exact/decimal.mjs +9 -19
- package/dist/core/exact/stored.d.mts +9 -0
- package/dist/core/exact/stored.mjs +38 -0
- package/dist/core/exact/text.d.mts +16 -1
- package/dist/core/exact/text.mjs +50 -1
- package/dist/core/format/digits.mjs +55 -0
- package/dist/core/format/index.d.mts +16 -0
- package/dist/core/format/index.mjs +27 -0
- package/dist/core/format/number.d.mts +27 -0
- package/dist/core/format/number.mjs +158 -0
- package/dist/core/format/write.d.mts +6 -0
- package/dist/core/format/write.mjs +57 -0
- package/dist/core/index.d.mts +43 -33
- package/dist/core/index.mjs +31 -28
- package/dist/core/model/defaults.d.mts +18 -1
- package/dist/core/model/defaults.mjs +19 -1
- package/dist/core/model/define.d.mts +17 -8
- package/dist/core/model/define.mjs +2 -0
- package/dist/core/model/member.d.mts +5 -3
- package/dist/core/model/member.mjs +33 -6
- package/dist/core/model/storage.mjs +40 -12
- package/dist/core/model/types.d.mts +17 -1
- package/dist/core/model/types.mjs +5 -0
- package/dist/core/model/validate/expr.d.mts +1 -7
- package/dist/core/model/validate/fields.d.mts +2 -0
- package/dist/core/model/validate/fields.mjs +14 -7
- package/dist/core/model/validate/issues.mjs +5 -1
- package/dist/core/model/validate/known-members.mjs +6 -5
- package/dist/core/model/validate/shape.mjs +36 -3
- package/dist/core/model/validate/source.mjs +2 -2
- package/dist/core/oracle/data.d.mts +4 -2
- package/dist/core/oracle/evaluate.d.mts +19 -1
- package/dist/core/oracle/evaluate.mjs +56 -10
- package/dist/core/oracle/expr.mjs +1 -1
- package/dist/core/oracle/facts.mjs +12 -5
- package/dist/core/oracle/measure.mjs +1 -1
- package/dist/core/oracle/request.mjs +39 -4
- package/dist/core/oracle/segmented.d.mts +3 -1
- package/dist/core/oracle/segmented.mjs +19 -13
- package/dist/core/oracle/unread.mjs +32 -0
- package/dist/core/oracle/visibility.mjs +4 -3
- package/dist/core/policy/bind.d.mts +2 -11
- package/dist/core/policy/bind.mjs +1 -1
- package/dist/core/policy/match.mjs +1 -1
- package/dist/core/query/closure.d.mts +7 -2
- package/dist/core/query/closure.mjs +29 -12
- package/dist/core/query/compose-tile.d.mts +3 -2
- package/dist/core/query/compose-tile.mjs +32 -13
- package/dist/core/query/compose.d.mts +0 -5
- package/dist/core/query/drill/internal.d.mts +5 -5
- package/dist/core/query/drill/internal.mjs +11 -0
- package/dist/core/query/drill/links.d.mts +2 -3
- package/dist/core/query/drill/links.mjs +18 -4
- package/dist/core/query/drill/selection.d.mts +8 -2
- package/dist/core/query/drill/selection.mjs +14 -3
- package/dist/core/query/drill/synthetic.mjs +1 -1
- package/dist/core/query/drill/time.mjs +11 -10
- package/dist/core/query/filter.d.mts +1 -6
- package/dist/core/query/filter.mjs +1 -4
- package/dist/core/query/fold.mjs +23 -0
- package/dist/core/query/segments.mjs +42 -3
- package/dist/core/query/to-wire.d.mts +7 -0
- package/dist/core/query/to-wire.mjs +14 -2
- package/dist/core/query/types.d.mts +30 -13
- package/dist/core/result/columns.mjs +23 -13
- package/dist/core/result/number.mjs +3 -3
- package/dist/core/result/status.d.mts +13 -0
- package/dist/core/result/status.mjs +18 -0
- package/dist/core/result/time-axis.d.mts +14 -13
- package/dist/core/result/time-axis.mjs +20 -2
- package/dist/core/result/types.d.mts +33 -3
- package/dist/core/result/whole.d.mts +23 -0
- package/dist/core/result/whole.mjs +27 -0
- package/dist/core/schema/agent-query.d.mts +89 -0
- package/dist/core/schema/agent-query.mjs +115 -0
- package/dist/core/schema/aliases.mjs +1 -52
- package/dist/core/schema/answer-parts.mjs +17 -13
- package/dist/core/schema/answers.d.mts +787 -319
- package/dist/core/schema/commands.d.mts +33 -23
- package/dist/core/schema/commands.mjs +26 -18
- package/dist/core/schema/custom.mjs +46 -45
- package/dist/core/schema/document.d.mts +32 -27
- package/dist/core/schema/document.mjs +61 -81
- package/dist/core/schema/drill-answers.mjs +4 -1
- package/dist/core/schema/drill.d.mts +14 -9
- package/dist/core/schema/drill.mjs +23 -22
- package/dist/core/schema/index.d.mts +5 -3
- package/dist/core/schema/index.mjs +5 -3
- package/dist/core/schema/options.d.mts +92 -0
- package/dist/core/schema/options.mjs +104 -0
- package/dist/core/schema/picks.d.mts +2 -2
- package/dist/core/schema/picks.mjs +7 -6
- package/dist/core/schema/query.d.mts +9 -83
- package/dist/core/schema/query.mjs +49 -73
- package/dist/core/schema/strict.d.mts +3 -0
- package/dist/core/schema/strict.mjs +91 -0
- package/dist/core/schema/union-error.mjs +30 -7
- package/dist/core/schema/view.d.mts +4 -3
- package/dist/core/schema/view.mjs +16 -11
- package/dist/core/store/ddl.d.mts +0 -2
- package/dist/core/store/ddl.mjs +1 -5
- package/dist/core/time/bucket.d.mts +1 -18
- package/dist/core/time/bucket.mjs +12 -8
- package/dist/core/time/compare.mjs +3 -2
- package/dist/core/time/index.d.mts +7 -8
- package/dist/core/time/instant.d.mts +15 -9
- package/dist/core/time/instant.mjs +23 -9
- package/dist/core/time/range.d.mts +3 -15
- package/dist/core/time/range.mjs +17 -7
- package/dist/core/time/stored.d.mts +8 -5
- package/dist/core/time/stored.mjs +51 -15
- package/dist/core/time/temporal.d.mts +1 -5
- package/dist/core/time/temporal.mjs +9 -4
- package/dist/core/time/text-time.d.mts +31 -2
- package/dist/core/time/text-time.mjs +139 -22
- package/dist/core/time/zone.d.mts +6 -1
- package/dist/core/time/zone.mjs +13 -4
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/dashboard.d.mts +185 -0
- package/dist/core/types/dashboard.mjs +26 -0
- package/dist/core/types/drill-api.d.mts +14 -2
- package/dist/core/types/infer.d.mts +0 -4
- package/dist/core/types/options-check.d.mts +42 -0
- package/dist/core/types/options-check.mjs +90 -0
- package/dist/core/types/options.d.mts +14 -8
- package/dist/core/value/casefold.d.mts +1 -3
- package/dist/core/value/stored.d.mts +26 -0
- package/dist/core/value/stored.mjs +28 -0
- package/dist/cursor-seal.mjs +37 -9
- package/dist/dashboard-documents.d.mts +14 -6
- package/dist/dashboard-documents.mjs +32 -12
- package/dist/dashboards.mjs +10 -9
- package/dist/drill-access.mjs +6 -6
- package/dist/drill-change.mjs +18 -20
- package/dist/drill-comparison.mjs +2 -1
- package/dist/drill-crumbs.mjs +63 -28
- package/dist/drill-distinct.mjs +2 -1
- package/dist/drill-explain.mjs +1 -1
- package/dist/drill-items.mjs +1 -1
- package/dist/drill-open.mjs +39 -23
- package/dist/drill-seal.mjs +41 -13
- package/dist/drill-share.mjs +1 -1
- package/dist/drill-summary.mjs +2 -1
- package/dist/drill-targets.mjs +4 -4
- package/dist/drill-views.mjs +4 -3
- package/dist/drill.mjs +1 -1
- package/dist/editing.mjs +5 -3
- package/dist/endpoints/index.d.mts +29 -8
- package/dist/endpoints/index.mjs +4 -1
- package/dist/endpoints/meta.mjs +4 -3
- package/dist/endpoints/query.mjs +5 -2
- package/dist/endpoints/read.mjs +7 -6
- package/dist/endpoints/versions.mjs +2 -1
- package/dist/execute.d.mts +3 -0
- package/dist/execute.mjs +23 -12
- package/dist/grant.d.mts +9 -0
- package/dist/grant.mjs +43 -0
- package/dist/handler.mjs +8 -13
- package/dist/http.d.mts +6 -2
- package/dist/http.mjs +6 -2
- package/dist/index.d.mts +25 -4
- package/dist/index.mjs +91 -40
- package/dist/llms.txt +3 -3
- package/dist/mcp/api.mjs +2 -1
- package/dist/mcp/query.mjs +3 -8
- package/dist/mcp/resolve.mjs +9 -2
- package/dist/node/index.d.mts +36 -0
- package/dist/node/index.mjs +89 -0
- package/dist/node/request.d.mts +12 -0
- package/dist/node/request.mjs +119 -0
- package/dist/node/response.mjs +58 -0
- package/dist/principal.mjs +15 -7
- package/dist/react/Canvas.mjs +90 -69
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +15 -1
- package/dist/react/Dashboard.mjs +43 -42
- package/dist/react/DashboardList.mjs +9 -4
- package/dist/react/Editing.d.mts +9 -0
- package/dist/react/Editing.mjs +8 -3
- package/dist/react/Grid.mjs +1 -1
- package/dist/react/Header.mjs +25 -52
- package/dist/react/History.mjs +3 -2
- package/dist/react/LoadFailed.mjs +59 -0
- package/dist/react/Panel.d.mts +1 -1
- package/dist/react/Panel.mjs +1 -1
- package/dist/react/Parts.d.mts +34 -0
- package/dist/react/Parts.mjs +9 -6
- package/dist/react/ReviewPanel.mjs +1 -1
- package/dist/react/RowBody.d.mts +2 -0
- package/dist/react/RowBody.mjs +5 -1
- package/dist/react/Share.mjs +153 -0
- package/dist/react/TabStrip.mjs +37 -0
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +89 -92
- package/dist/react/TileState.mjs +117 -0
- package/dist/react/ago.mjs +45 -0
- package/dist/react/arrange.mjs +1 -1
- package/dist/react/board.mjs +2 -2
- package/dist/react/bucket-name.d.mts +8 -0
- package/dist/react/bucket-name.mjs +13 -0
- package/dist/react/builder/DisplayOptions.mjs +219 -0
- package/dist/react/builder/Preview.mjs +13 -13
- package/dist/react/builder/RangeEditor.mjs +4 -3
- package/dist/react/builder/WidgetBuilder.d.mts +1 -7
- package/dist/react/builder/WidgetBuilder.mjs +12 -3
- package/dist/react/builder/base.d.mts +13 -2
- package/dist/react/builder/base.mjs +70 -12
- package/dist/react/builder/display.d.mts +3 -0
- package/dist/react/builder/display.mjs +256 -0
- package/dist/react/builder/labels.mjs +19 -5
- package/dist/react/builder/options.mjs +11 -6
- package/dist/react/builder/state.mjs +25 -3
- package/dist/react/builder/useBuilder.d.mts +7 -1
- package/dist/react/builder/useBuilder.mjs +6 -9
- package/dist/react/builder/usePreview.mjs +3 -2
- package/dist/react/builder/words.d.mts +16 -1
- package/dist/react/builder/words.mjs +41 -1
- package/dist/react/change-text.mjs +149 -0
- package/dist/react/client.d.mts +9 -0
- package/dist/react/client.mjs +105 -14
- package/dist/react/columns.mjs +9 -1
- package/dist/react/context.d.mts +24 -3
- package/dist/react/context.mjs +23 -7
- package/dist/react/dates-shown.mjs +76 -0
- package/dist/react/draft.mjs +3 -2
- package/dist/react/drill/Bars.mjs +12 -16
- package/dist/react/drill/Comparison.mjs +1 -1
- package/dist/react/drill/DrillPanel.d.mts +1 -1
- package/dist/react/drill/DrillPanel.mjs +2 -1
- package/dist/react/drill/Header.mjs +65 -12
- package/dist/react/drill/Items.d.mts +1 -1
- package/dist/react/drill/Notes.mjs +10 -7
- package/dist/react/drill/PanelStates.mjs +8 -1
- package/dist/react/drill/Trend.mjs +10 -5
- package/dist/react/drill/board.d.mts +1 -1
- package/dist/react/drill/board.mjs +1 -0
- package/dist/react/drill/host.mjs +4 -1
- package/dist/react/drill/lazy.mjs +2 -27
- package/dist/react/drill/props.d.mts +19 -8
- package/dist/react/drill/props.mjs +62 -18
- package/dist/react/drill/state.d.mts +15 -5
- package/dist/react/drill/state.mjs +12 -3
- package/dist/react/drill/words.d.mts +46 -3
- package/dist/react/drill/words.mjs +30 -5
- package/dist/react/english.mjs +33 -8
- package/dist/react/export/ExportButton.mjs +4 -1
- package/dist/react/export/csv.d.mts +7 -2
- package/dist/react/export/csv.mjs +24 -7
- package/dist/react/failure-words.mjs +60 -0
- package/dist/react/filters/bar.d.mts +1 -1
- package/dist/react/filters/bar.mjs +4 -1
- package/dist/react/filters/calendar.mjs +23 -8
- package/dist/react/filters/chip.mjs +7 -3
- package/dist/react/filters/context.d.mts +13 -1
- package/dist/react/filters/context.mjs +1 -1
- package/dist/react/filters/dates-said.mjs +57 -0
- package/dist/react/filters/days.d.mts +3 -4
- package/dist/react/filters/days.mjs +10 -17
- package/dist/react/filters/hooks.d.mts +11 -0
- package/dist/react/filters/hooks.mjs +10 -6
- package/dist/react/filters/menu-search.mjs +17 -9
- package/dist/react/filters/menu.mjs +10 -8
- package/dist/react/filters/phone.mjs +41 -16
- package/dist/react/filters/place.mjs +40 -0
- package/dist/react/filters/popover.mjs +18 -13
- package/dist/react/filters/rules.d.mts +4 -3
- package/dist/react/filters/rules.mjs +3 -3
- package/dist/react/filters/sheet.mjs +7 -3
- package/dist/react/filters/state.mjs +6 -1
- package/dist/react/filters/values.mjs +24 -7
- package/dist/react/filters/words.d.mts +13 -0
- package/dist/react/filters/words.mjs +5 -0
- package/dist/react/format-time.d.mts +17 -6
- package/dist/react/format-time.mjs +152 -33
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +35 -122
- package/dist/react/headline.d.mts +12 -0
- package/dist/react/headline.mjs +107 -0
- package/dist/react/index.d.mts +20 -17
- package/dist/react/index.mjs +13 -10
- package/dist/react/lazy.mjs +38 -0
- package/dist/react/messages.d.mts +78 -2
- package/dist/react/now.mjs +38 -0
- package/dist/react/place.mjs +4 -2
- package/dist/react/read.d.mts +1 -0
- package/dist/react/read.mjs +140 -9
- package/dist/react/renderers/exact.mjs +31 -59
- package/dist/react/renderers/index.d.mts +27 -6
- package/dist/react/renderers/index.mjs +154 -92
- package/dist/react/renderers/list-parts.mjs +24 -0
- package/dist/react/renderers/list.d.mts +1 -0
- package/dist/react/renderers/list.mjs +99 -43
- package/dist/react/renderers/more-rows.mjs +75 -0
- package/dist/react/renderers/number-before.mjs +320 -0
- package/dist/react/renderers/number-period.mjs +54 -0
- package/dist/react/renderers/number-whole.mjs +29 -0
- package/dist/react/renderers/props.d.mts +24 -1
- package/dist/react/renderers/props.mjs +8 -0
- package/dist/react/renderers/table-cells.mjs +137 -31
- package/dist/react/renderers/table-fit.mjs +55 -10
- package/dist/react/renderers/table-measure.mjs +29 -9
- package/dist/react/renderers/table-row.mjs +14 -9
- package/dist/react/renderers/table-scale.mjs +2 -3
- package/dist/react/renderers/table-sort.mjs +3 -2
- package/dist/react/renderers/table-whole.mjs +37 -0
- package/dist/react/renderers/table.mjs +73 -53
- package/dist/react/review.d.mts +7 -0
- package/dist/react/review.mjs +35 -8
- package/dist/react/roving.d.mts +6 -0
- package/dist/react/roving.mjs +123 -0
- package/dist/react/says-dates.d.mts +7 -0
- package/dist/react/says-dates.mjs +51 -0
- package/dist/react/series.mjs +5 -6
- package/dist/react/stable.mjs +1 -1
- package/dist/react/tabs/EditTabs.mjs +125 -0
- package/dist/react/tabs/NameField.mjs +72 -0
- package/dist/react/tabs/TabMenu.mjs +175 -0
- package/dist/react/tabs/actions.mjs +37 -0
- package/dist/react/tabs/commands.mjs +76 -0
- package/dist/react/tabs/focus.mjs +22 -0
- package/dist/react/tabs/keys.mjs +28 -0
- package/dist/react/theme-unlayered.css +1 -1
- package/dist/react/theme.css +1 -1
- package/dist/react/tile-store.d.mts +4 -0
- package/dist/react/tile-store.mjs +93 -13
- package/dist/react/touch.d.mts +16 -0
- package/dist/react/touch.mjs +39 -0
- package/dist/react/useBoard.d.mts +6 -0
- package/dist/react/useBoard.mjs +1 -0
- package/dist/react/useDashboard.d.mts +2 -0
- package/dist/react/useDashboard.mjs +5 -2
- package/dist/react/useTiles.d.mts +3 -0
- package/dist/react/useTiles.mjs +73 -17
- package/dist/react/view-grid.mjs +2 -2
- package/dist/react/view.mjs +1 -1
- package/dist/recharts/axes.mjs +1 -1
- package/dist/recharts/axis.mjs +23 -73
- package/dist/recharts/bar.d.mts +2 -1
- package/dist/recharts/bar.mjs +140 -64
- package/dist/recharts/fit.mjs +33 -0
- package/dist/recharts/line.mjs +23 -17
- package/dist/recharts/marks.mjs +2 -1
- package/dist/recharts/parts.mjs +19 -14
- package/dist/recharts/table.mjs +8 -3
- package/dist/refusal.mjs +46 -0
- package/dist/registry/filter-bar.json +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +25 -9
- package/dist/tile-doc.mjs +1 -1
- package/package.json +21 -6
- package/dist/charts-react/plan.d.mts +0 -3
- package/dist/charts-react/plan.mjs +0 -37
- package/dist/charts-react/tiles.d.mts +0 -24
- package/dist/core/policy/match.d.mts +0 -16
- package/dist/core/schema/aliases.d.mts +0 -7
- package/dist/core/time/compare.d.mts +0 -30
- package/dist/react/EditBar.d.mts +0 -16
- package/dist/react/History.d.mts +0 -30
- package/dist/react/ReviewPanel.d.mts +0 -15
- package/dist/react/digits.mjs +0 -46
- package/dist/react/drill/trend-touch.mjs +0 -33
- package/dist/react/renderers/exact.d.mts +0 -6
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { didYouMean } from "../model/validate/fields.mjs";
|
|
2
|
+
import { RESERVED_KEY } from "../model/validate/issues.mjs";
|
|
3
|
+
import { unionError } from "./union-error.mjs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
// src/schema/strict.ts
|
|
6
|
+
/**
|
|
7
|
+
* The one way an object is checked: every schema of input (documents, commands, queries, bodies,
|
|
8
|
+
* views, drills) builds its objects with `strict`, so a key the shape does not have is refused at
|
|
9
|
+
* any depth, never dropped. A dropped key is how a misplaced `lock` once left a dashboard
|
|
10
|
+
* unlocked. `laws/strict.laws.test.ts` walks every schema and holds each object to it.
|
|
11
|
+
*/
|
|
12
|
+
const sentence = (keys) => keys.map((key) => `"${key}"`).join(", ");
|
|
13
|
+
/** The keys the object that refused a key has, read from the schema itself, so `.extend` keeps it right. */
|
|
14
|
+
function knownKeys(inst) {
|
|
15
|
+
return inst instanceof z.ZodObject ? Object.keys(inst.shape) : [];
|
|
16
|
+
}
|
|
17
|
+
/** One unknown key in words: what it is, and the key it most likely meant. */
|
|
18
|
+
function unknownKey(key, known) {
|
|
19
|
+
return `Unknown key "${key}".${didYouMean(key, known)}`;
|
|
20
|
+
}
|
|
21
|
+
/** The message for keys a shape does not have: each named, the nearest valid key offered, and the keys it takes. */
|
|
22
|
+
const unknownKeys = (issue) => {
|
|
23
|
+
if (issue.code !== "unrecognized_keys") return;
|
|
24
|
+
const known = knownKeys(issue.inst);
|
|
25
|
+
const named = issue.keys.map((key) => unknownKey(key, known)).join(" ");
|
|
26
|
+
return known.length === 0 ? named : `${named} The keys here are ${sentence(known)}.`;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Where a problem is, as every schema of input reports it: its path, and for one unknown key
|
|
30
|
+
* the key itself, so a key unknown at the root is not at `[]`. Several keys stay at their object.
|
|
31
|
+
*/
|
|
32
|
+
function pathOf(problem) {
|
|
33
|
+
const path = problem.path.map((key) => typeof key === "number" ? key : String(key));
|
|
34
|
+
if (problem.code !== "unrecognized_keys" || problem.keys.length !== 1) return path;
|
|
35
|
+
return [...path, ...problem.keys];
|
|
36
|
+
}
|
|
37
|
+
/** An object of exactly these keys: an unknown one is refused, by name, with the key it most likely meant. */
|
|
38
|
+
function strict(shape) {
|
|
39
|
+
return z.strictObject(shape, { error: unknownKeys });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* An object whose other keys belong to someone else and are kept as they are: a renderer's
|
|
43
|
+
* display options (checked against the renderer, `documentDisplayIssues`) and a plugin's `ext`
|
|
44
|
+
* data. The only objects not `strict`; the strictness law names each one.
|
|
45
|
+
*/
|
|
46
|
+
function open(shape) {
|
|
47
|
+
return z.looseObject(shape);
|
|
48
|
+
}
|
|
49
|
+
/** The keys of each option that tell it apart: its own, less those every object option has. */
|
|
50
|
+
function distinguishing(options) {
|
|
51
|
+
const keys = options.map((option) => knownKeys(option));
|
|
52
|
+
const objects = keys.filter((k) => k.length > 0);
|
|
53
|
+
const common = (key) => objects.every((k) => k.includes(key));
|
|
54
|
+
return keys.map((k) => k.filter((key) => objects.length < 2 || !common(key)));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* One of several shapes, as every schema of input writes a union: a value that fits none is
|
|
58
|
+
* refused with the problem of the shape it is nearest (an unknown key first, with the key it
|
|
59
|
+
* most likely meant), never zod's bare "Invalid input".
|
|
60
|
+
*/
|
|
61
|
+
function either(options) {
|
|
62
|
+
return z.union(options, { error: unionError(distinguishing(options)) });
|
|
63
|
+
}
|
|
64
|
+
const reserved = (text) => `"${text}" is reserved and cannot be a key; pick another name.`;
|
|
65
|
+
/** A name: 1 to 200 characters. */
|
|
66
|
+
const name = z.string().min(1).max(200);
|
|
67
|
+
/**
|
|
68
|
+
* A name used as a key of a map (widgets, queries, filters by source, picks, ext): a name, and
|
|
69
|
+
* never one JavaScript objects reserve, which a map would swallow into its prototype instead of
|
|
70
|
+
* keeping. Every `z.record` of input is keyed by it; the strictness law holds that.
|
|
71
|
+
*/
|
|
72
|
+
const key = name.refine((text) => !RESERVED_KEY.test(text), { error: (issue) => reserved(String(issue.input)) });
|
|
73
|
+
/**
|
|
74
|
+
* Refuses an own `__proto__` key before a record reads the map: zod's record skips that key
|
|
75
|
+
* without running `key` on it, so a map from `JSON.parse` would lose the entry with no word.
|
|
76
|
+
*/
|
|
77
|
+
function ownProto(input, ctx) {
|
|
78
|
+
if (typeof input === "object" && input !== null && Object.hasOwn(input, "__proto__")) ctx.addIssue({
|
|
79
|
+
code: "custom",
|
|
80
|
+
message: reserved("__proto__"),
|
|
81
|
+
path: ["__proto__"],
|
|
82
|
+
input
|
|
83
|
+
});
|
|
84
|
+
return input;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A map of input, keyed by `key`: every key a reserved name refuses is refused at its path,
|
|
88
|
+
* `__proto__` from JSON too. The strictness law holds every map of input to be one of these.
|
|
89
|
+
*/
|
|
90
|
+
const map = (value) => z.preprocess(ownProto, z.record(key, value, { error: (issue) => issue.code === "invalid_key" ? issue.issues[0]?.message : void 0 }));
|
|
91
|
+
export { either, key, map, name, open, pathOf, strict };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { meant, nearest } from "../model/validate/fields.mjs";
|
|
1
2
|
// src/schema/union-error.ts
|
|
2
3
|
const quoted = (keys) => keys.map((key) => `\`${key}\``);
|
|
3
4
|
function oneOf(keys) {
|
|
@@ -8,31 +9,53 @@ function oneOf(keys) {
|
|
|
8
9
|
function onlyMissing(issues, own) {
|
|
9
10
|
return issues.every((issue) => issue.code === "invalid_type" && issue.path.length === 1 && !own.includes(String(issue.path[0])));
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A branch's problem as one line, with its path. A key the branch does not take comes first: it
|
|
14
|
+
* is usually a misspelling, and its message names the key it most likely meant.
|
|
15
|
+
*/
|
|
16
|
+
function described(issues) {
|
|
17
|
+
const issue = issues?.find((it) => it.code === "unrecognized_keys") ?? issues?.[0];
|
|
12
18
|
if (issue === void 0) return void 0;
|
|
13
19
|
const where = issue.path.map(String).join(".");
|
|
14
20
|
return where === "" ? issue.message : `${where}: ${issue.message}`;
|
|
15
21
|
}
|
|
22
|
+
/** How deep a branch's problems lie: the longest path among them. */
|
|
23
|
+
const depth = (issues) => Math.max(0, ...issues.map((it) => it.path.length));
|
|
24
|
+
/** "Expected an object with …", and the key the input most likely meant when one is close. */
|
|
25
|
+
function expected(all, own) {
|
|
26
|
+
const near = own.map((key) => nearest(key, all)).find((key) => key !== void 0);
|
|
27
|
+
return `Expected an object with ${oneOf(all)}.${meant(near)}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* How well an input's keys fit a shape: two for each of its keys the input has, and one for each
|
|
31
|
+
* the input nearly has (`variablex` for `variable`), so a misspelling still points at its shape.
|
|
32
|
+
*/
|
|
33
|
+
function fit(keys, own) {
|
|
34
|
+
const exact = keys.filter((key) => own.includes(key)).length;
|
|
35
|
+
const missing = keys.filter((key) => !own.includes(key));
|
|
36
|
+
const near = own.filter((key) => !keys.includes(key) && nearest(key, missing) !== void 0);
|
|
37
|
+
return exact * 2 + near.length;
|
|
38
|
+
}
|
|
16
39
|
/**
|
|
17
40
|
* The error for a union of object shapes, each named by the keys that tell it apart. Instead of
|
|
18
41
|
* zod's bare "Invalid input", it picks the shape the input shares the most of those keys with and
|
|
19
|
-
* reports that shape's own
|
|
20
|
-
* from complete, it names the keys any of them needs.
|
|
42
|
+
* reports that shape's own problem, an unknown key first, with its path; when the input is
|
|
43
|
+
* several shapes away from complete, it names the keys any of them needs.
|
|
21
44
|
*/
|
|
22
45
|
function unionError(shapes) {
|
|
23
46
|
return (issue) => {
|
|
24
47
|
if (issue.code !== "invalid_union") return;
|
|
25
48
|
const { input } = issue;
|
|
26
|
-
const all = shapes.
|
|
49
|
+
const all = shapes.flatMap((keys) => keys.slice(0, 1));
|
|
27
50
|
if (typeof input !== "object" || input === null || Array.isArray(input)) return `Expected an object with ${oneOf(all)}.`;
|
|
28
51
|
const own = Object.keys(input);
|
|
29
|
-
const scores = shapes.map((keys) => keys
|
|
52
|
+
const scores = shapes.map((keys) => fit(keys, own));
|
|
30
53
|
const best = Math.max(...scores);
|
|
31
54
|
const picked = scores.flatMap((score, at) => score === best ? [at] : []);
|
|
32
55
|
const branches = picked.map((at) => issue.errors[at] ?? []);
|
|
33
|
-
if (best === 0) return
|
|
56
|
+
if (best === 0) return expected(all, own);
|
|
34
57
|
if (picked.length > 1 && branches.every((branch) => onlyMissing(branch, own))) return `Needs ${oneOf(branches.flatMap((branch) => branch.map((it) => String(it.path[0]))))}.`;
|
|
35
|
-
return described(branches[0]
|
|
58
|
+
return described(branches.toSorted((a, b) => depth(b) - depth(a))[0]);
|
|
36
59
|
};
|
|
37
60
|
}
|
|
38
61
|
export { unionError };
|
|
@@ -2,9 +2,10 @@ import { ViewState } from "../document/view.mjs";
|
|
|
2
2
|
/**
|
|
3
3
|
* A view read back from URL search parameters (`encodeView` wrote them): each pick checked as
|
|
4
4
|
* the tile endpoints check one, and a parameter that is not a view's left out and named in
|
|
5
|
-
* `dropped` (by its filter id), so the host can pass them to `<Dashboard linkDropped>`.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* `dropped` (by its filter id), so the host can pass them to `<Dashboard linkDropped>`.
|
|
6
|
+
* Parameters without the prefix are the host's and are ignored. The dashboard then keeps only
|
|
7
|
+
* the tab and filters it has (`viewFor`), and the server applies the viewer's own access as
|
|
8
|
+
* always: a link never widens what anyone sees.
|
|
8
9
|
*/
|
|
9
10
|
export declare function decodeView(params: Iterable<readonly [string, string]>, prefix?: string): {
|
|
10
11
|
view: ViewState;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VIEW_KEYS } from "../document/view.mjs";
|
|
2
2
|
import { drillStateSchema } from "./drill.mjs";
|
|
3
3
|
import { pick } from "./picks.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { key } from "./strict.mjs";
|
|
5
5
|
// src/schema/view.ts
|
|
6
6
|
/** A pick from its JSON, or null when it is not JSON or not a pick. */
|
|
7
7
|
function readPick(text) {
|
|
@@ -21,13 +21,16 @@ function readDrill(text) {
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* One parameter of a view: a tab, a pick, a drill, or something that is neither. A pick's id is
|
|
26
|
+
* a map key as every schema of input checks one (`key`): never a name JavaScript objects reserve.
|
|
27
|
+
*/
|
|
25
28
|
function readParam(rest, text) {
|
|
26
29
|
if (rest === VIEW_KEYS.tab) return { tab: text };
|
|
27
30
|
if (rest === VIEW_KEYS.drill) return readDrill(text);
|
|
28
31
|
const id = rest.startsWith(VIEW_KEYS.filter) ? rest.slice(VIEW_KEYS.filter.length) : "";
|
|
29
32
|
const read = readPick(text);
|
|
30
|
-
if (!
|
|
33
|
+
if (!key.safeParse(id).success || read === null) return null;
|
|
31
34
|
return { pick: {
|
|
32
35
|
id,
|
|
33
36
|
value: read.value
|
|
@@ -36,24 +39,26 @@ function readParam(rest, text) {
|
|
|
36
39
|
/**
|
|
37
40
|
* A view read back from URL search parameters (`encodeView` wrote them): each pick checked as
|
|
38
41
|
* the tile endpoints check one, and a parameter that is not a view's left out and named in
|
|
39
|
-
* `dropped` (by its filter id), so the host can pass them to `<Dashboard linkDropped>`.
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
+
* `dropped` (by its filter id), so the host can pass them to `<Dashboard linkDropped>`.
|
|
43
|
+
* Parameters without the prefix are the host's and are ignored. The dashboard then keeps only
|
|
44
|
+
* the tab and filters it has (`viewFor`), and the server applies the viewer's own access as
|
|
45
|
+
* always: a link never widens what anyone sees.
|
|
42
46
|
*/
|
|
43
47
|
function decodeView(params, prefix = "dd.") {
|
|
44
|
-
const
|
|
48
|
+
const picked = [];
|
|
45
49
|
const dropped = [];
|
|
46
50
|
let tab;
|
|
47
51
|
let drill;
|
|
48
|
-
for (const [
|
|
49
|
-
if (!
|
|
50
|
-
const rest =
|
|
52
|
+
for (const [param, text] of params) {
|
|
53
|
+
if (!param.startsWith(prefix)) continue;
|
|
54
|
+
const rest = param.slice(prefix.length);
|
|
51
55
|
const read = readParam(rest, text);
|
|
52
56
|
if (read === null) dropped.push(rest.startsWith(VIEW_KEYS.filter) ? rest.slice(VIEW_KEYS.filter.length) : rest);
|
|
53
57
|
else if ("tab" in read) tab = read.tab;
|
|
54
58
|
else if ("drill" in read) drill = read.drill;
|
|
55
|
-
else
|
|
59
|
+
else picked.push([read.pick.id, read.pick.value]);
|
|
56
60
|
}
|
|
61
|
+
const picks = Object.fromEntries(picked);
|
|
57
62
|
return {
|
|
58
63
|
view: {
|
|
59
64
|
...tab === void 0 ? {} : { tab },
|
|
@@ -6,8 +6,6 @@ export type StoreDialect = "postgres" | "sqlite";
|
|
|
6
6
|
* connection makes an unqualified table.
|
|
7
7
|
*/
|
|
8
8
|
export declare function createTable(dialect: StoreDialect, name: string, def: TableDef, schema?: string): string[];
|
|
9
|
-
/** Every statement of the library's schema, in order: what `createTables` runs and `generate` writes. */
|
|
10
|
-
export declare function schemaStatements(dialect: StoreDialect): string[];
|
|
11
9
|
/**
|
|
12
10
|
* Reads the `dd_` columns a database has, from its own catalog, as rows of
|
|
13
11
|
* `{ table, column, schema }`, each table where the store's queries find it (on Postgres, through
|
package/dist/core/store/ddl.mjs
CHANGED
|
@@ -46,10 +46,6 @@ function createTable(dialect, name, def, schema) {
|
|
|
46
46
|
...indexes
|
|
47
47
|
];
|
|
48
48
|
}
|
|
49
|
-
/** Every statement of the library's schema, in order: what `createTables` runs and `generate` writes. */
|
|
50
|
-
function schemaStatements(dialect) {
|
|
51
|
-
return Object.entries(TABLES).flatMap(([name, def]) => createTable(dialect, name, def));
|
|
52
|
-
}
|
|
53
49
|
/**
|
|
54
50
|
* Reads the `dd_` columns a database has, from its own catalog, as rows of
|
|
55
51
|
* `{ table, column, schema }`, each table where the store's queries find it (on Postgres, through
|
|
@@ -76,4 +72,4 @@ function schemaChecks(dialect, schema) {
|
|
|
76
72
|
}))
|
|
77
73
|
}));
|
|
78
74
|
}
|
|
79
|
-
export { CATALOG, createTable, schemaChecks
|
|
75
|
+
export { CATALOG, createTable, schemaChecks };
|
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import { Calendar, Grain } from "../query/types.mjs";
|
|
2
2
|
import { Micros } from "./instant.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* The first instant of the bucket an instant falls in, in the calendar's zone. A day bucket
|
|
5
|
-
* starts at the day's first instant, so it lasts 23 or 25 hours across a clock change.
|
|
6
|
-
*/
|
|
7
|
-
export declare function bucketStart(instant: Micros, grain: Grain, calendar: Calendar): Micros;
|
|
8
|
-
/**
|
|
9
|
-
* The first instant after a bucket start that begins another bucket. An hour is a real hour,
|
|
10
|
-
* so a repeated wall-clock hour is two buckets and a skipped one is none.
|
|
11
|
-
*/
|
|
12
|
-
export declare function nextBucketStart(start: Micros, grain: Grain, calendar: Calendar): Micros;
|
|
13
|
-
/** The start of the bucket `n` buckets away from the one starting at `start`. */
|
|
14
|
-
export declare function shiftBucket(start: Micros, grain: Grain, n: number, calendar: Calendar): Micros;
|
|
15
3
|
/**
|
|
16
4
|
* The name of the bucket an instant falls in. Day and longer: the local date it starts on,
|
|
17
5
|
* `2026-03-01`. Hour: the UTC instant it starts at, `2026-11-01T05:00:00.000000Z`, so the
|
|
18
6
|
* repeated hour is two names. Labels sort in time order.
|
|
19
7
|
*/
|
|
20
|
-
export declare function bucketLabel(instant: Micros, grain: Grain, calendar: Calendar): string;
|
|
21
|
-
/** Every bucket label a span touches, in order, including a partial first bucket. */
|
|
22
|
-
export declare function bucketLabels(span: {
|
|
23
|
-
from: Micros;
|
|
24
|
-
to: Micros;
|
|
25
|
-
}, grain: Grain, calendar: Calendar): string[];
|
|
8
|
+
export declare function bucketLabel(instant: Micros, grain: Grain, calendar: Calendar): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parseTextTime } from "./text-time.mjs";
|
|
1
|
+
import { formatTextTime, latest, parseDate } from "./instant.mjs";
|
|
2
|
+
import { MICROS_PER_HOUR, parseTextTime } from "./text-time.mjs";
|
|
3
3
|
import { Temporal, zonedAt } from "./temporal.mjs";
|
|
4
4
|
import { lastChange, nextChange, startOfDate } from "./zone.mjs";
|
|
5
5
|
// src/time/bucket.ts
|
|
@@ -29,7 +29,7 @@ function startDate(date, grain, calendar) {
|
|
|
29
29
|
}
|
|
30
30
|
/** An instant's local wall time floored to the hour, at the instant's own offset. */
|
|
31
31
|
function wallHour(instant, zone) {
|
|
32
|
-
return instant - ((instant + zonedAt(instant, zone).offsetNanoseconds / 1e3) % MICROS_PER_HOUR + MICROS_PER_HOUR) % MICROS_PER_HOUR;
|
|
32
|
+
return instant - ((instant + BigInt(zonedAt(instant, zone).offsetNanoseconds / 1e3)) % MICROS_PER_HOUR + MICROS_PER_HOUR) % MICROS_PER_HOUR;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* The start of an instant's hour bucket: its wall hour. When that hour reaches back past the
|
|
@@ -42,7 +42,7 @@ function hourStart(instant, zone) {
|
|
|
42
42
|
const floored = wallHour(instant, zone);
|
|
43
43
|
const change = lastChange(instant, zone);
|
|
44
44
|
if (change === void 0 || floored >= change) return floored;
|
|
45
|
-
return floored === hourStart(change -
|
|
45
|
+
return floored === hourStart(change - 1n, zone) ? floored : change;
|
|
46
46
|
}
|
|
47
47
|
/** The next hour bucket's start: the next wall hour, or a clock change before it that starts a bucket. */
|
|
48
48
|
function nextHour(start, zone) {
|
|
@@ -53,12 +53,16 @@ function nextHour(start, zone) {
|
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* The first instant of the bucket an instant falls in, in the calendar's zone. A day bucket
|
|
56
|
-
* starts at the day's first instant, so it lasts 23 or 25 hours across a clock
|
|
56
|
+
* starts at the day's first instant (`startOfDate`), so it lasts 23 or 25 hours across a clock
|
|
57
|
+
* change, and every instant is in exactly one.
|
|
57
58
|
*/
|
|
58
59
|
function bucketStart(instant, grain, calendar) {
|
|
59
60
|
const zone = calendar.timezone;
|
|
60
61
|
if (grain === "hour") return hourStart(instant, zone);
|
|
61
|
-
|
|
62
|
+
const date = zonedAt(instant, zone).toPlainDate();
|
|
63
|
+
const start = startOfDate(startDate(date, grain, calendar), zone);
|
|
64
|
+
if (start <= instant) return start;
|
|
65
|
+
return startOfDate(startDate(date.subtract({ days: 1 }), grain, calendar), zone);
|
|
62
66
|
}
|
|
63
67
|
/**
|
|
64
68
|
* The first instant after a bucket start that begins another bucket. An hour is a real hour,
|
|
@@ -72,7 +76,7 @@ function shiftBucket(start, grain, n, calendar) {
|
|
|
72
76
|
const zone = calendar.timezone;
|
|
73
77
|
if (grain === "hour") {
|
|
74
78
|
let at = hourStart(start, zone);
|
|
75
|
-
for (let i = 0; i < Math.abs(n); i++) at = n > 0 ? nextHour(at, zone) : hourStart(at -
|
|
79
|
+
for (let i = 0; i < Math.abs(n); i++) at = n > 0 ? nextHour(at, zone) : hourStart(at - 1n, zone);
|
|
76
80
|
return at;
|
|
77
81
|
}
|
|
78
82
|
const date = zonedAt(start, zone).toPlainDate().add(times(UNIT[grain], n));
|
|
@@ -98,7 +102,7 @@ function labelStart(label, grain, calendar) {
|
|
|
98
102
|
function bucketLabels(span, grain, calendar) {
|
|
99
103
|
const labels = [];
|
|
100
104
|
for (let at = bucketStart(span.from, grain, calendar); at < span.to;) {
|
|
101
|
-
labels.push(bucketLabel(
|
|
105
|
+
labels.push(bucketLabel(latest(at, span.from), grain, calendar));
|
|
102
106
|
at = nextBucketStart(at, grain, calendar);
|
|
103
107
|
}
|
|
104
108
|
return labels;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bucketStart, nextBucketStart } from "./bucket.mjs";
|
|
2
|
-
import { MICROS_PER_HOUR
|
|
2
|
+
import { MICROS_PER_HOUR } from "./text-time.mjs";
|
|
3
|
+
import { formatTextTime } from "./instant.mjs";
|
|
3
4
|
import { microsOf, zonedAt } from "./temporal.mjs";
|
|
4
5
|
// src/time/compare.ts
|
|
5
6
|
const MONTHS = {
|
|
@@ -12,7 +13,7 @@ const MONTHS = {
|
|
|
12
13
|
* Months clamp to the end of a shorter month (March 31 back one month is the end of February).
|
|
13
14
|
*/
|
|
14
15
|
function shiftInstant(instant, unit, n, calendar) {
|
|
15
|
-
if (unit === "hour") return instant + n * MICROS_PER_HOUR;
|
|
16
|
+
if (unit === "hour") return instant + BigInt(n) * MICROS_PER_HOUR;
|
|
16
17
|
const local = zonedAt(instant, calendar.timezone);
|
|
17
18
|
const months = MONTHS[unit];
|
|
18
19
|
if (months !== void 0) return microsOf(local.add({ months: months * n }));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { bucketLabel
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export { MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, type Micros, type Moment, type NaiveRule, type OffsetSegment, type Span, bucketLabel, bucketLabels, bucketStart, comparisonQuery, comparisonSpan, formatTextTime, inSpan, isZone, lastIncludedMillisecond, momentMicros, nextBucketStart, offsetSegments, parseDate, parseNaiveTime, parseTextTime, resolveNaive, resolveRange, shiftBucket, shiftInstant, startOfDate };
|
|
1
|
+
import { bucketLabel } from "./bucket.mjs";
|
|
2
|
+
import { Micros, formatTextTime } from "./instant.mjs";
|
|
3
|
+
import { Span, requestInstant } from "./range.mjs";
|
|
4
|
+
import { Moment } from "./temporal.mjs";
|
|
5
|
+
import { MICROS_PER_DAY, dateMillis, isDateOnly, lastIncludedMillisecond, parseTextTime, textMillis, wallClock } from "./text-time.mjs";
|
|
6
|
+
import { NaiveRule } from "./zone.mjs";
|
|
7
|
+
export { MICROS_PER_DAY, type Micros, type Moment, type NaiveRule, type Span, bucketLabel, dateMillis, formatTextTime, isDateOnly, lastIncludedMillisecond, parseTextTime, requestInstant, textMillis, wallClock };
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { Temporal } from "./temporal.mjs";
|
|
2
|
-
import { parseTextTime } from "./text-time.mjs";
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { MICROS_PER_DAY, parseTextTime } from "./text-time.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Microseconds since 1970-01-01T00:00:00Z, as a whole `bigint`: exact for every instant from
|
|
5
|
+
* year 1 to 9999 (and past), where a `number` loses a microsecond beyond about 2255. A float
|
|
6
|
+
* cannot be passed where an instant is expected; read one with `parseTextTime` or `momentMicros`.
|
|
7
|
+
*/
|
|
8
|
+
export type Micros = bigint;
|
|
9
|
+
/** A wall-clock time with no offset, as a naive timestamp column stores it, to the microsecond. */
|
|
9
10
|
export declare function parseNaiveTime(text: string): Temporal.PlainDateTime | undefined;
|
|
10
11
|
/** A `date` value: a calendar day. Undefined when it is not a real day. */
|
|
11
12
|
export declare function parseDate(text: string): Temporal.PlainDate | undefined;
|
|
12
|
-
/**
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* An instant as text time in UTC, with all six fraction digits: the inverse of parseTextTime.
|
|
15
|
+
* The end of the instants held (`INSTANTS.to`, in year 10000) is written as text time writes it
|
|
16
|
+
* in four digits, `INSTANTS.toText`, so a range that ends there reads back.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatTextTime(instant: Micros): string;
|
|
19
|
+
export { MICROS_PER_DAY };
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
+
import { answerInvalid } from "../error/refusal.mjs";
|
|
2
|
+
import { wholeNumber } from "../value/stored.mjs";
|
|
1
3
|
import { Temporal, instantAt } from "./temporal.mjs";
|
|
2
|
-
import { matchTime, parseTextTime } from "./text-time.mjs";
|
|
4
|
+
import { DATE_ONLY, INSTANTS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, isInstant, matchTime, parseTextTime } from "./text-time.mjs";
|
|
3
5
|
// src/time/instant.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
/** Whole microseconds as a database returns a `bigint` column; anything else is a driver fault. */
|
|
7
|
+
function wholeMicros(raw, column) {
|
|
8
|
+
const micros = wholeNumber(raw);
|
|
9
|
+
if (micros !== void 0) return micros;
|
|
10
|
+
throw answerInvalid(column, `the driver returned ${String(raw)} where whole microseconds were expected.`);
|
|
11
|
+
}
|
|
12
|
+
/** The later of two instants. */
|
|
13
|
+
const latest = (a, b) => a > b ? a : b;
|
|
14
|
+
/** The earlier of two instants. */
|
|
15
|
+
const earliest = (a, b) => a < b ? a : b;
|
|
16
|
+
/** A wall-clock time with no offset, as a naive timestamp column stores it, to the microsecond. */
|
|
8
17
|
function parseNaiveTime(text) {
|
|
9
18
|
if (matchTime(text, false) === void 0) return void 0;
|
|
10
19
|
try {
|
|
11
|
-
|
|
20
|
+
const cut = text.replace(/(\.\d{6})\d+/u, "$1");
|
|
21
|
+
return Temporal.PlainDateTime.from(cut, { overflow: "reject" });
|
|
12
22
|
} catch {
|
|
13
23
|
return;
|
|
14
24
|
}
|
|
15
25
|
}
|
|
16
|
-
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/u;
|
|
17
26
|
/** A `date` value: a calendar day. Undefined when it is not a real day. */
|
|
18
27
|
function parseDate(text) {
|
|
19
28
|
if (!DATE_ONLY.test(text)) return void 0;
|
|
@@ -23,8 +32,13 @@ function parseDate(text) {
|
|
|
23
32
|
return;
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* An instant as text time in UTC, with all six fraction digits: the inverse of parseTextTime.
|
|
37
|
+
* The end of the instants held (`INSTANTS.to`, in year 10000) is written as text time writes it
|
|
38
|
+
* in four digits, `INSTANTS.toText`, so a range that ends there reads back.
|
|
39
|
+
*/
|
|
27
40
|
function formatTextTime(instant) {
|
|
41
|
+
if (instant === INSTANTS.to) return INSTANTS.toText;
|
|
28
42
|
return instantAt(instant).toString({ fractionalSecondDigits: 6 });
|
|
29
43
|
}
|
|
30
|
-
export { MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, formatTextTime, parseDate, parseNaiveTime, parseTextTime };
|
|
44
|
+
export { INSTANTS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, earliest, formatTextTime, isInstant, latest, parseDate, parseNaiveTime, parseTextTime, wholeMicros };
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import { Calendar, DateRange } from "../query/types.mjs";
|
|
2
1
|
import { Micros } from "./instant.mjs";
|
|
2
|
+
import { Moment } from "./temporal.mjs";
|
|
3
3
|
/** A resolved range: `from` included, `to` excluded. */
|
|
4
4
|
export type Span = {
|
|
5
5
|
from: Micros;
|
|
6
6
|
to: Micros;
|
|
7
7
|
};
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
* - Explicit: `[from, to)`; a date end means that day's first instant in the calendar's zone.
|
|
12
|
-
* - Relative, `includeCurrent: false`: the last `n` complete units before the current one.
|
|
13
|
-
* - Relative, `includeCurrent: true`: `n` units, the last of them the current, partial one,
|
|
14
|
-
* ending at `now` floored to the `quantum`, but never before the current unit starts. A
|
|
15
|
-
* quantum lets equal requests within it share one cached answer.
|
|
16
|
-
*
|
|
17
|
-
* Units start where buckets of that grain start, in the calendar's zone, week start and
|
|
18
|
-
* fiscal year. Undefined when an explicit end is not valid.
|
|
19
|
-
*/
|
|
20
|
-
export declare function resolveRange(range: DateRange, now: Micros, calendar: Calendar, quantum?: Micros): Span | undefined;
|
|
21
|
-
export declare function inSpan(instant: Micros, span: Span): boolean;
|
|
8
|
+
/** The one owner of now floored to the quantum, which the engine and the answer cache both read. */
|
|
9
|
+
export declare function requestInstant(now: Moment, quantumSeconds?: number): Micros;
|
package/dist/core/time/range.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EngineError } from "../error/refusal.mjs";
|
|
2
2
|
import { bucketStart, shiftBucket } from "./bucket.mjs";
|
|
3
3
|
import { parseDate } from "./instant.mjs";
|
|
4
|
+
import { momentMicros } from "./temporal.mjs";
|
|
5
|
+
import { MICROS_PER_SECOND, parseRangeEnd } from "./text-time.mjs";
|
|
4
6
|
import { startOfDate } from "./zone.mjs";
|
|
5
7
|
// src/time/range.ts
|
|
6
8
|
/** An explicit range end: a text time with its offset, or a date meaning its first instant. */
|
|
7
9
|
function rangeEnd(text, calendar) {
|
|
8
10
|
const date = parseDate(text);
|
|
9
|
-
return date === void 0 ?
|
|
11
|
+
return date === void 0 ? parseRangeEnd(text) : startOfDate(date, calendar.timezone);
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* The instants a date range covers for one request.
|
|
@@ -14,13 +16,12 @@ function rangeEnd(text, calendar) {
|
|
|
14
16
|
* - Explicit: `[from, to)`; a date end means that day's first instant in the calendar's zone.
|
|
15
17
|
* - Relative, `includeCurrent: false`: the last `n` complete units before the current one.
|
|
16
18
|
* - Relative, `includeCurrent: true`: `n` units, the last of them the current, partial one,
|
|
17
|
-
* ending at `now
|
|
18
|
-
* quantum lets equal requests within it share one cached answer.
|
|
19
|
+
* ending at `now`, the request's instant (`requestInstant`), which the cache keys by too.
|
|
19
20
|
*
|
|
20
21
|
* Units start where buckets of that grain start, in the calendar's zone, week start and
|
|
21
22
|
* fiscal year. Undefined when an explicit end is not valid.
|
|
22
23
|
*/
|
|
23
|
-
function resolveRange(range, now, calendar
|
|
24
|
+
function resolveRange(range, now, calendar) {
|
|
24
25
|
if ("from" in range) {
|
|
25
26
|
const from = rangeEnd(range.from, calendar);
|
|
26
27
|
const to = rangeEnd(range.to, calendar);
|
|
@@ -33,10 +34,19 @@ function resolveRange(range, now, calendar, quantum = 1) {
|
|
|
33
34
|
const back = range.includeCurrent ? range.last - 1 : range.last;
|
|
34
35
|
return {
|
|
35
36
|
from: shiftBucket(current, range.unit, -back, calendar),
|
|
36
|
-
to: range.includeCurrent ?
|
|
37
|
+
to: range.includeCurrent ? now : current
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
function inSpan(instant, span) {
|
|
40
41
|
return instant >= span.from && instant < span.to;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
const isQuantum = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
44
|
+
/** The one owner of now floored to the quantum, which the engine and the answer cache both read. */
|
|
45
|
+
function requestInstant(now, quantumSeconds) {
|
|
46
|
+
const at = momentMicros(now);
|
|
47
|
+
if (quantumSeconds === void 0) return at;
|
|
48
|
+
if (!isQuantum(quantumSeconds)) throw new EngineError("QUANTUM_INVALID", "`cache.quantum` is a whole number of seconds, 1 or more.");
|
|
49
|
+
const quantum = BigInt(quantumSeconds) * MICROS_PER_SECOND;
|
|
50
|
+
return at - (at % quantum + quantum) % quantum;
|
|
51
|
+
}
|
|
52
|
+
export { inSpan, requestInstant, resolveRange };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { TimeStorage } from "../model/types.mjs";
|
|
2
2
|
import { Calendar } from "../query/types.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { Reading, StoredValue } from "../value/stored.mjs";
|
|
4
4
|
import { Micros } from "./instant.mjs";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* A stored time value read by its declared storage. A date is its first instant in the
|
|
7
|
+
* request's zone, so it buckets as its own date in any zone. Text time is RFC 3339 with `T` or
|
|
8
|
+
* a space (as Postgres prints it, `2026-11-20 10:00:00+00`); a `Date` is its instant; an epoch
|
|
9
|
+
* column takes a number, a `bigint` or digit text. Anything else is unread, with its reason.
|
|
9
10
|
*/
|
|
10
|
-
export declare function
|
|
11
|
+
export declare function readTime(storage: TimeStorage, raw: StoredValue | undefined, calendar: Pick<Calendar, "timezone">): Reading<Micros>;
|
|
12
|
+
/** The instant a stored time value places its row at: null when stored null or unread. */
|
|
13
|
+
export declare const timeValue: (storage: TimeStorage, raw: StoredValue | undefined, calendar: Pick<Calendar, "timezone">) => Micros | null;
|