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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EngineError } from "../error/refusal.mjs";
|
|
2
2
|
import { hourStart } from "../time/bucket.mjs";
|
|
3
|
-
import { MICROS_PER_DAY, MICROS_PER_HOUR } from "../time/
|
|
3
|
+
import { MICROS_PER_DAY, MICROS_PER_HOUR } from "../time/text-time.mjs";
|
|
4
4
|
import { lastChange, offsetSegments } from "../time/zone.mjs";
|
|
5
5
|
import { instantSql } from "./members.mjs";
|
|
6
6
|
import { ident, join, keyword, sql } from "./sql.mjs";
|
|
7
7
|
// src/engine/bucket.ts
|
|
8
8
|
function bySegment(instant, segments, span, value) {
|
|
9
|
-
const none =
|
|
9
|
+
const none = -(2n ** 62n);
|
|
10
10
|
const first = lastChange(span.from, span.zone) ?? none;
|
|
11
11
|
const of = (change) => keyword(String(change === none ? none : value(change)));
|
|
12
12
|
const arms = segments.map((s, i) => sql`WHEN ${instant} < ${keyword(String(s.to))} THEN ${of(i === 0 ? first : s.from)}`);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { EngineError } from "../error/refusal.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { resolveRange } from "../time/range.mjs";
|
|
4
|
-
import { isZone
|
|
2
|
+
import { missingTenantKey, untiedSource } from "../model/defaults.mjs";
|
|
3
|
+
import { requestInstant, resolveRange } from "../time/range.mjs";
|
|
4
|
+
import { isZone } from "../time/temporal.mjs";
|
|
5
5
|
import { principalTenant } from "../types/viewer.mjs";
|
|
6
6
|
// src/engine/checks.ts
|
|
7
7
|
/** A request is refused before any SQL when its tenant or calendar is not valid. */
|
|
8
8
|
function check(input) {
|
|
9
9
|
const untied = untiedSource(input.model);
|
|
10
10
|
if (untied !== void 0) throw new EngineError("PLAN_ASSERTION", `"${untied}" is not tied to the model's tenant keys, so no query reads the model. Check it with defineModel.`);
|
|
11
|
-
const
|
|
12
|
-
const missing = tenantKeys(input.model).find((key) => (values[key] ?? "") === "");
|
|
11
|
+
const missing = missingTenantKey(input.model, principalTenant(input.principal));
|
|
13
12
|
if (missing !== void 0) throw new EngineError("TENANT_MISSING", `The request has no value for the tenant key "${missing}": viewer() must return it in the viewer's tenant.`);
|
|
14
13
|
const { timezone, weekStart, fiscalYearStartMonth: month } = input.calendar;
|
|
15
14
|
if (!isZone(timezone)) throw new EngineError("ZONE_UNKNOWN", `"${timezone}" is not a known time zone.`);
|
|
@@ -21,8 +20,8 @@ function check(input) {
|
|
|
21
20
|
}
|
|
22
21
|
function spanOf(input, query) {
|
|
23
22
|
if (query.time === void 0) return void 0;
|
|
24
|
-
const
|
|
25
|
-
const span = resolveRange(query.time.range,
|
|
23
|
+
const now = requestInstant(input.now, input.quantumSeconds);
|
|
24
|
+
const span = resolveRange(query.time.range, now, input.calendar);
|
|
26
25
|
if (span === void 0) throw new EngineError("RANGE_INVALID", "The date range is not valid.");
|
|
27
26
|
return span;
|
|
28
27
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EngineError } from "../../error/refusal.mjs";
|
|
2
|
+
import { tenantEntry } from "../../model/defaults.mjs";
|
|
1
3
|
import { principalTenant } from "../../types/viewer.mjs";
|
|
2
4
|
import { assertPlan } from "../assert.mjs";
|
|
3
5
|
// src/engine/custom/ask.ts
|
|
@@ -8,6 +10,24 @@ function checked(ask) {
|
|
|
8
10
|
/** The viewer's tenant by the model's tenant keys, as every request carries it; `{}` with none. */
|
|
9
11
|
function tenantOf(ask) {
|
|
10
12
|
const values = principalTenant(ask.input.principal);
|
|
11
|
-
return Object.fromEntries((ask.input.model.tenant?.keys ?? []).map((k) => [k, values
|
|
13
|
+
return Object.fromEntries((ask.input.model.tenant?.keys ?? []).map((k) => [k, tenantEntry(values, k) ?? ""]));
|
|
12
14
|
}
|
|
13
|
-
|
|
15
|
+
/** What a host answered, shown in a refusal: a forgotten `return` is `undefined`. */
|
|
16
|
+
function shown(answered) {
|
|
17
|
+
if (Array.isArray(answered)) return "a list with a row that is not a list";
|
|
18
|
+
if (typeof answered === "object" && answered !== null) return "an object";
|
|
19
|
+
return typeof answered === "string" ? JSON.stringify(answered) : String(answered);
|
|
20
|
+
}
|
|
21
|
+
/** A list whose every row is a list: the rows' cells are checked as they decode. */
|
|
22
|
+
const isRows = (answered) => Array.isArray(answered) && answered.every((row) => Array.isArray(row));
|
|
23
|
+
/** A host's answer to a `what` read of `source`, refused when it is not a list of rows. */
|
|
24
|
+
function listed(answered, source, what) {
|
|
25
|
+
if (isRows(answered)) return answered;
|
|
26
|
+
throw new EngineError("ANSWER_INVALID", `The custom source answered a ${what} of "${source}" with ${shown(answered)}, not a list of rows.`);
|
|
27
|
+
}
|
|
28
|
+
/** One grouped read, after the plan check, its answer a list of rows. */
|
|
29
|
+
async function answer(ask, request) {
|
|
30
|
+
checked(ask);
|
|
31
|
+
return listed(await ask.source.answer(request, ask.context), request.source.name, "grouped read");
|
|
32
|
+
}
|
|
33
|
+
export { answer, checked, listed, tenantOf };
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
+
import { EngineError } from "../../error/refusal.mjs";
|
|
1
2
|
import { parseExact } from "../../exact/text.mjs";
|
|
2
3
|
import { cellOf, exactNum } from "../../result/number.mjs";
|
|
4
|
+
import { wholeNumber } from "../../value/stored.mjs";
|
|
3
5
|
import { nanRefusal } from "../nan.mjs";
|
|
4
6
|
// src/engine/custom/cells.ts
|
|
5
7
|
/** A host's answer that does not keep the contract: a bug in the host, not a refusal. */
|
|
6
8
|
function wrong(what, cell) {
|
|
7
|
-
const shown = typeof cell === "bigint" ? cell
|
|
8
|
-
throw new
|
|
9
|
+
const shown = typeof cell === "bigint" || typeof cell === "number" ? String(cell) : JSON.stringify(cell ?? null);
|
|
10
|
+
throw new EngineError("ANSWER_INVALID", `The custom source answered ${shown} where ${what} was expected.`);
|
|
9
11
|
}
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
* source the host answered wrongly is what its author needs to find the bug.
|
|
13
|
-
*/
|
|
14
|
-
function decodedFrom(source, what, decode) {
|
|
12
|
+
/** Runs a decode, naming where a malformed answer was met (`where: ...`) in what it throws. */
|
|
13
|
+
function naming(where, decode) {
|
|
15
14
|
try {
|
|
16
15
|
return decode();
|
|
17
16
|
} catch (error) {
|
|
18
|
-
if (!(error instanceof
|
|
19
|
-
throw new
|
|
17
|
+
if (!(error instanceof EngineError) || error.code !== "ANSWER_INVALID") throw error;
|
|
18
|
+
throw new EngineError("ANSWER_INVALID", `${where}: ${error.message}`);
|
|
20
19
|
}
|
|
21
20
|
}
|
|
21
|
+
/** Decodes one column of a host's answer, naming the column (a member id) a malformed cell came in. */
|
|
22
|
+
const inColumn = (column, decode) => naming(`Column "${column}"`, decode);
|
|
23
|
+
/**
|
|
24
|
+
* Decodes a host's answer, naming the source a malformed cell came from: which read of which
|
|
25
|
+
* source the host answered wrongly is what its author needs to find the bug.
|
|
26
|
+
*/
|
|
27
|
+
const decodedFrom = (source, what, decode) => naming(`In its answer to a ${what} of "${source}"`, decode);
|
|
22
28
|
const inner = (cell) => typeof cell === "object" && cell !== null ? cell.v : cell;
|
|
23
29
|
/** A count: a whole number as a number, digit text, a bigint or an `int` cell. */
|
|
24
|
-
|
|
25
|
-
const v = inner(cell);
|
|
26
|
-
if (typeof v === "bigint") return v;
|
|
27
|
-
if (typeof v === "number" && Number.isSafeInteger(v)) return BigInt(v);
|
|
28
|
-
if (typeof v === "string" && /^-?\d+$/u.test(v)) return BigInt(v);
|
|
29
|
-
return wrong("a whole number", cell);
|
|
30
|
-
}
|
|
30
|
+
const intOf = (cell) => wholeNumber(inner(cell)) ?? wrong("a whole number", cell);
|
|
31
31
|
/** An exact number as minor units at `scale`, or null; the text NaN is a stored NaN. */
|
|
32
32
|
function exactOf(cell, scale) {
|
|
33
33
|
const v = inner(cell);
|
|
34
34
|
if (v === null || v === void 0) return null;
|
|
35
35
|
if (v === "NaN") throw nanRefusal();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return (typeof
|
|
36
|
+
const whole = wholeNumber(v);
|
|
37
|
+
if (whole !== void 0) return whole * 10n ** BigInt(scale);
|
|
38
|
+
return (typeof v === "string" ? parseExact(v, scale) : void 0) ?? wrong(`a decimal with at most ${scale} places`, cell);
|
|
39
39
|
}
|
|
40
40
|
/** A float, or null; a value that is not finite is no value. */
|
|
41
41
|
function floatOf(cell) {
|
|
@@ -57,7 +57,7 @@ function rest(of, whole, kept, i) {
|
|
|
57
57
|
/** A count of rows: the rows left out are counted by difference. */
|
|
58
58
|
const countLess = (whole, kept) => ({
|
|
59
59
|
t: "int",
|
|
60
|
-
v: rest(
|
|
60
|
+
v: rest(intOf, whole, kept, 0).toString()
|
|
61
61
|
});
|
|
62
62
|
/**
|
|
63
63
|
* An exact sum read beside its count of values: the values left out sum to the
|
|
@@ -65,7 +65,7 @@ const countLess = (whole, kept) => ({
|
|
|
65
65
|
* over rows whose values are all null.
|
|
66
66
|
*/
|
|
67
67
|
const sumLess = (scale) => (whole, kept) => {
|
|
68
|
-
if (rest(
|
|
68
|
+
if (rest(intOf, whole, kept, 1) === 0n) return null;
|
|
69
69
|
return cellOf(exactNum(rest((c) => exactOf(c, scale) ?? 0n, whole, kept, 0), scale), false);
|
|
70
70
|
};
|
|
71
71
|
/** A value a level kept from the host's answer (`Decoded.raw`): a cell, as it answered it. */
|
|
@@ -77,4 +77,4 @@ function isHostCell(value) {
|
|
|
77
77
|
}
|
|
78
78
|
/** The host cells a level kept, from `start` for `width`; a value that is not one is none. */
|
|
79
79
|
const keptCells = (raw, start, width) => raw.slice(start, start + width).map((v) => isHostCell(v) ? v : null);
|
|
80
|
-
export { countLess, decodedFrom, exactOf, floatOf, intOf, keptCells, plainOf, sumLess };
|
|
80
|
+
export { countLess, decodedFrom, exactOf, floatOf, inColumn, intOf, keptCells, plainOf, sumLess };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { EngineError } from "../../error/refusal.mjs";
|
|
1
2
|
import { fold } from "../../value/casefold.mjs";
|
|
2
3
|
import { refuseNaN } from "../nan.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { decodedFrom, intOf, keptCells, plainOf } from "./cells.mjs";
|
|
4
|
+
import { answer } from "./ask.mjs";
|
|
5
|
+
import { decodedFrom, inColumn, intOf, keptCells, plainOf } from "./cells.mjs";
|
|
5
6
|
import { emptyCell } from "./measures.mjs";
|
|
6
7
|
// src/engine/custom/level.ts
|
|
7
8
|
/** Where each measure's aggregates start among the request's measures. */
|
|
@@ -9,16 +10,16 @@ const startsOf = (measures) => measures.map((_m, i) => measures.slice(0, i).redu
|
|
|
9
10
|
/** A row of the host's answer as a decoded level row: a "ci" key is its label's fold. */
|
|
10
11
|
function decodeRow(q, shape, row) {
|
|
11
12
|
const at = shape.bucket ? 1 : 0;
|
|
12
|
-
const shown = Array.from({ length: shape.keys }, (_v, i) => plainOf(row[at + i]));
|
|
13
|
+
const shown = Array.from({ length: shape.keys }, (_v, i) => inColumn(q.dims[i]?.member ?? "", () => plainOf(row[at + i])));
|
|
13
14
|
const key = shown.map((v, i) => typeof v === "string" && q.ci[i] === true ? fold(v) : v);
|
|
14
15
|
const starts = startsOf(q.measures).map((s) => s + at + shape.keys);
|
|
15
16
|
const cells = q.measures.map((m, i) => {
|
|
16
17
|
const start = starts[i] ?? 0;
|
|
17
|
-
return m.decode(row.slice(start, start + m.aggregates.length));
|
|
18
|
+
return inColumn(m.member, () => m.decode(row.slice(start, start + m.aggregates.length)));
|
|
18
19
|
});
|
|
19
20
|
const raw = row.slice(at + shape.keys);
|
|
20
21
|
return {
|
|
21
|
-
bucket: shape.bucket ? plainOf(row[0]) : null,
|
|
22
|
+
bucket: shape.bucket ? inColumn("bucket", () => plainOf(row[0])) : null,
|
|
22
23
|
key,
|
|
23
24
|
shown,
|
|
24
25
|
cells,
|
|
@@ -69,7 +70,7 @@ function requestOf(q, level, shape) {
|
|
|
69
70
|
}
|
|
70
71
|
/** The one row of an ungrouped read: the aggregate over no rows when none matched, unless `nonEmpty`. */
|
|
71
72
|
function onlyRow(q, level, request, rows) {
|
|
72
|
-
if (rows.length > 1) throw new
|
|
73
|
+
if (rows.length > 1) throw new EngineError("ANSWER_INVALID", "The custom source answered two rows for no group.");
|
|
73
74
|
const [only] = rows;
|
|
74
75
|
if (level.nonEmpty === true && (only === void 0 || intOf(only.at(-1)) === 0n)) return [];
|
|
75
76
|
return [decodeRow(q, {
|
|
@@ -98,13 +99,12 @@ async function levelOf(ask, q, level, nan) {
|
|
|
98
99
|
kind: "count",
|
|
99
100
|
where: nanWhere(nan)
|
|
100
101
|
}];
|
|
101
|
-
|
|
102
|
-
const answered = await ask.source.answer({
|
|
102
|
+
const answered = await answer(ask, {
|
|
103
103
|
...request,
|
|
104
104
|
measures: [...request.measures, ...counts]
|
|
105
|
-
}
|
|
105
|
+
});
|
|
106
106
|
const width = (shape.bucket ? 1 : 0) + shape.keys + request.measures.length + counts.length;
|
|
107
|
-
if (answered.some((row) => row.length !== width)) throw new
|
|
107
|
+
if (answered.some((row) => row.length !== width)) throw new EngineError("ANSWER_INVALID", `The custom source answered a read of "${request.source.name}" with a row that does not have ${width} cells: [bucket?, ...dimensions, ...measures].`);
|
|
108
108
|
const rows = answered.map((row) => row.slice(0, width - counts.length));
|
|
109
109
|
const counted = nan === void 0 ? {} : { nan: answered.reduce((n, row) => n + intOf(row.at(-1)), 0n) };
|
|
110
110
|
if (!shape.bucket && shape.keys === 0) return {
|
|
@@ -122,15 +122,14 @@ async function levelOf(ask, q, level, nan) {
|
|
|
122
122
|
*/
|
|
123
123
|
async function checkNaN(ask, q, columns) {
|
|
124
124
|
const { bucket: _bucket, ...base } = q.base;
|
|
125
|
-
|
|
126
|
-
const [row] = await ask.source.answer({
|
|
125
|
+
const [row] = await answer(ask, {
|
|
127
126
|
...base,
|
|
128
127
|
dimensions: [],
|
|
129
128
|
measures: [{
|
|
130
129
|
kind: "count",
|
|
131
130
|
where: nanWhere(columns)
|
|
132
131
|
}]
|
|
133
|
-
}
|
|
132
|
+
});
|
|
134
133
|
refuseNaN(row === void 0 ? 0 : intOf(row[0]));
|
|
135
134
|
}
|
|
136
135
|
export { checkNaN, lessKept, levelOf };
|
|
@@ -23,7 +23,7 @@ function whereOf(ctx, def) {
|
|
|
23
23
|
}
|
|
24
24
|
const count = ([c]) => ({
|
|
25
25
|
t: "int",
|
|
26
|
-
v: intOf(c
|
|
26
|
+
v: intOf(c).toString()
|
|
27
27
|
});
|
|
28
28
|
const float = ([c]) => floatOf(c);
|
|
29
29
|
const exact = (scale) => ([c]) => {
|
|
@@ -32,7 +32,7 @@ const exact = (scale) => ([c]) => {
|
|
|
32
32
|
};
|
|
33
33
|
/** An average: the sum of the values over their count, exactly when the values are exact. */
|
|
34
34
|
const average = (numeric) => ([s, c]) => {
|
|
35
|
-
const n = intOf(c
|
|
35
|
+
const n = intOf(c);
|
|
36
36
|
if (numeric === "float") {
|
|
37
37
|
const sum = floatOf(s);
|
|
38
38
|
return sum === null || n === 0n ? null : sum / Number(n);
|
|
@@ -88,7 +88,7 @@ function ofPlan(ctx, def) {
|
|
|
88
88
|
numeric,
|
|
89
89
|
...where
|
|
90
90
|
}];
|
|
91
|
-
const counted = ([s, c]) => intOf(c
|
|
91
|
+
const counted = ([s, c]) => intOf(c) === 0n ? null : decode([s ?? null]);
|
|
92
92
|
return {
|
|
93
93
|
aggregates,
|
|
94
94
|
decode: counted,
|
|
@@ -134,12 +134,15 @@ function ratio(ctx, def) {
|
|
|
134
134
|
* `counted`: exact sums count their values too, so Other can be the total less the kept groups.
|
|
135
135
|
*/
|
|
136
136
|
function planMeasures(at, query, counted = false) {
|
|
137
|
-
return queryMeasures(at, query).map((m) =>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
return queryMeasures(at, query).map((m) => ({
|
|
138
|
+
...planOf({
|
|
139
|
+
at,
|
|
140
|
+
source: query.source,
|
|
141
|
+
line: m.line,
|
|
142
|
+
counted
|
|
143
|
+
}, m.def),
|
|
144
|
+
member: m.member
|
|
145
|
+
}));
|
|
143
146
|
}
|
|
144
147
|
/** The cell an aggregate has over no rows: a count is zero, anything else no value. */
|
|
145
148
|
const emptyCell = (m) => m.kind === "count" ? 0 : null;
|
|
@@ -4,6 +4,7 @@ import { checkNaN, lessKept, levelOf } from "./level.mjs";
|
|
|
4
4
|
import { queryOf } from "./query.mjs";
|
|
5
5
|
import { customRecords } from "./records.mjs";
|
|
6
6
|
import { binding } from "./seen.mjs";
|
|
7
|
+
import { customUnread } from "./unread.mjs";
|
|
7
8
|
// src/engine/custom/reader.ts
|
|
8
9
|
/** Whether a level reads every row the query reads: no group left out, none cut. */
|
|
9
10
|
const everyRow = (l) => l.restrict === void 0 && l.take === void 0;
|
|
@@ -58,7 +59,8 @@ function customReader(source, context) {
|
|
|
58
59
|
return {
|
|
59
60
|
reads: (query, span) => customReads(ask, query, span),
|
|
60
61
|
sources: () => [...ask.at.touched].toSorted(),
|
|
61
|
-
records: (records) => customRecords(ask, records)
|
|
62
|
+
records: (records) => customRecords(ask, records),
|
|
63
|
+
unread: (query) => customUnread(ask, query)
|
|
62
64
|
};
|
|
63
65
|
},
|
|
64
66
|
concurrent: true
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EngineError } from "../../error/refusal.mjs";
|
|
1
|
+
import { EngineError, answerInvalid } from "../../error/refusal.mjs";
|
|
2
2
|
import { parseTextTime } from "../../time/text-time.mjs";
|
|
3
3
|
import { formatTextTime } from "../../time/instant.mjs";
|
|
4
|
-
import { checked, tenantOf } from "./ask.mjs";
|
|
5
|
-
import { decodedFrom, plainOf } from "./cells.mjs";
|
|
4
|
+
import { checked, listed, tenantOf } from "./ask.mjs";
|
|
5
|
+
import { decodedFrom, inColumn, plainOf } from "./cells.mjs";
|
|
6
6
|
import { fieldOf, sourceOf } from "./fields.mjs";
|
|
7
7
|
import { seen } from "./seen.mjs";
|
|
8
8
|
import { factWhere } from "./where.mjs";
|
|
@@ -12,7 +12,7 @@ function cellOf(field, cell) {
|
|
|
12
12
|
const value = plainOf(cell);
|
|
13
13
|
if (field.value.kind !== "time" || value === null) return value;
|
|
14
14
|
const instant = typeof value === "string" ? parseTextTime(value) : void 0;
|
|
15
|
-
if (instant === void 0) throw
|
|
15
|
+
if (instant === void 0) throw answerInvalid(field.member, `the custom source answered ${JSON.stringify(value)} where a time was expected.`);
|
|
16
16
|
return formatTextTime(instant);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -41,11 +41,12 @@ async function customRecords(ask, records) {
|
|
|
41
41
|
...page.after === void 0 ? {} : { after: page.after }
|
|
42
42
|
};
|
|
43
43
|
checked(ask);
|
|
44
|
-
const
|
|
44
|
+
const answered = await read(request, ask.context);
|
|
45
|
+
const rows = listed(answered, request.source.name, "records read");
|
|
45
46
|
const width = columns.length + request.order.length + request.key.length;
|
|
46
|
-
if (rows.some((row) => row.length !== width)) throw new
|
|
47
|
+
if (rows.some((row) => row.length !== width)) throw new EngineError("ANSWER_INVALID", `The custom source answered a records read of "${request.source.name}" with a row that does not have ${width} cells: one per column asked for, then one per order field and key column.`);
|
|
47
48
|
return decodedFrom(request.source.name, "records read", () => ({
|
|
48
|
-
rows: rows.map((row) => columns.map((c, i) => cellOf(c, row[i]))),
|
|
49
|
+
rows: rows.map((row) => columns.map((c, i) => inColumn(c.member, () => cellOf(c, row[i])))),
|
|
49
50
|
at: rows.map((row) => row.slice(columns.length).map((cell) => plainOf(cell)))
|
|
50
51
|
}));
|
|
51
52
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { readColumns } from "../../model/storage.mjs";
|
|
2
|
+
import { INSTANTS } from "../../time/text-time.mjs";
|
|
3
|
+
import { spanOf } from "../checks.mjs";
|
|
4
|
+
import { answer, tenantOf } from "./ask.mjs";
|
|
5
|
+
import { intOf } from "./cells.mjs";
|
|
6
|
+
import { sourceOf } from "./fields.mjs";
|
|
7
|
+
import { factWhere, rangeWhere } from "./where.mjs";
|
|
8
|
+
// src/engine/custom/unread.ts
|
|
9
|
+
const set = (column) => ({
|
|
10
|
+
column,
|
|
11
|
+
op: "set",
|
|
12
|
+
values: []
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* The counts that find a column's unread values, in the contract every host answers already:
|
|
16
|
+
* a time set but in no instant at all (`INSTANTS`); an exact value set, less those that read.
|
|
17
|
+
*/
|
|
18
|
+
function countsOf(c, ranged) {
|
|
19
|
+
if (c.kind === "time") {
|
|
20
|
+
const ever = { range: {
|
|
21
|
+
time: {
|
|
22
|
+
column: c.column,
|
|
23
|
+
storage: c.storage
|
|
24
|
+
},
|
|
25
|
+
from: INSTANTS.fromText,
|
|
26
|
+
to: INSTANTS.toText
|
|
27
|
+
} };
|
|
28
|
+
return [{
|
|
29
|
+
kind: "count",
|
|
30
|
+
where: { all: [set(c.column), { not: ever }] }
|
|
31
|
+
}];
|
|
32
|
+
}
|
|
33
|
+
const where = { all: [ranged, set(c.column)] };
|
|
34
|
+
const of = { terms: [{
|
|
35
|
+
column: c.column,
|
|
36
|
+
coefficient: 1
|
|
37
|
+
}] };
|
|
38
|
+
return [{
|
|
39
|
+
kind: "count",
|
|
40
|
+
where
|
|
41
|
+
}, {
|
|
42
|
+
kind: "count",
|
|
43
|
+
of,
|
|
44
|
+
numeric: c.numeric,
|
|
45
|
+
where
|
|
46
|
+
}];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The values a query's answer leaves out because they do not read as their column's storage:
|
|
50
|
+
* one grouped read of the rows the query reads without its range, a time counted over all of
|
|
51
|
+
* them (an unread time is in no range) and an exact value over those in the range.
|
|
52
|
+
*/
|
|
53
|
+
async function customUnread(ask, query) {
|
|
54
|
+
const columns = readColumns(ask.input.model, query);
|
|
55
|
+
if (columns.length === 0) return [];
|
|
56
|
+
const ranged = rangeWhere(ask.at, query, spanOf(ask.input, query));
|
|
57
|
+
const counts = columns.map((c) => countsOf(c, ranged));
|
|
58
|
+
const [row] = await answer(ask, {
|
|
59
|
+
source: sourceOf(ask.at.model, query.source),
|
|
60
|
+
tenant: tenantOf(ask),
|
|
61
|
+
calendar: ask.input.calendar,
|
|
62
|
+
where: factWhere(ask.at, query),
|
|
63
|
+
dimensions: [],
|
|
64
|
+
measures: counts.flat()
|
|
65
|
+
});
|
|
66
|
+
if (row === void 0) return [];
|
|
67
|
+
let at = 0;
|
|
68
|
+
return columns.flatMap((c, i) => {
|
|
69
|
+
const [first = 0n, second = 0n] = (counts[i] ?? []).map(() => intOf(row[at++]));
|
|
70
|
+
const count = Number(c.kind === "time" ? first : first - second);
|
|
71
|
+
return count === 0 ? [] : [{
|
|
72
|
+
source: query.source,
|
|
73
|
+
column: c.column,
|
|
74
|
+
count
|
|
75
|
+
}];
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export { customUnread };
|
|
@@ -4,6 +4,19 @@ import { queryTime } from "../time.mjs";
|
|
|
4
4
|
import { joinOf } from "./fields.mjs";
|
|
5
5
|
import { boundFilter, seen } from "./seen.mjs";
|
|
6
6
|
// src/engine/custom/where.ts
|
|
7
|
+
/** The query's range on its time column; true (`{ all: [] }`) with no range. */
|
|
8
|
+
function rangeWhere(at, query, span) {
|
|
9
|
+
const time = queryTime(at, query);
|
|
10
|
+
if (time === void 0 || span === void 0) return { all: [] };
|
|
11
|
+
return { range: {
|
|
12
|
+
time: {
|
|
13
|
+
column: time.column,
|
|
14
|
+
storage: time.storage
|
|
15
|
+
},
|
|
16
|
+
from: formatTextTime(span.from),
|
|
17
|
+
to: formatTextTime(span.to)
|
|
18
|
+
} };
|
|
19
|
+
}
|
|
7
20
|
/** The fact rows a query reads: seen, the query's filters, every guard, and the range. */
|
|
8
21
|
function factWhere(at, query, span) {
|
|
9
22
|
const fact = query.source;
|
|
@@ -15,15 +28,7 @@ function factWhere(at, query, span) {
|
|
|
15
28
|
} };
|
|
16
29
|
});
|
|
17
30
|
const filters = bound(query.filters);
|
|
18
|
-
const
|
|
19
|
-
const range = time === void 0 || span === void 0 ? [] : [{ range: {
|
|
20
|
-
time: {
|
|
21
|
-
column: time.column,
|
|
22
|
-
storage: time.storage
|
|
23
|
-
},
|
|
24
|
-
from: formatTextTime(span.from),
|
|
25
|
-
to: formatTextTime(span.to)
|
|
26
|
-
} }];
|
|
31
|
+
const range = span !== void 0 && queryTime(at, query) !== void 0 ? [rangeWhere(at, query, span)] : [];
|
|
27
32
|
return { all: [
|
|
28
33
|
seen(at, fact),
|
|
29
34
|
...filters === void 0 ? [] : [boundFilter(at, fact, filters)],
|
|
@@ -31,4 +36,4 @@ function factWhere(at, query, span) {
|
|
|
31
36
|
...range
|
|
32
37
|
] };
|
|
33
38
|
}
|
|
34
|
-
export { factWhere };
|
|
39
|
+
export { factWhere, rangeWhere };
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { EngineError, EngineErrorCode } from "../error/refusal.mjs";
|
|
1
|
+
import { EngineError, EngineErrorCode, answerInvalid } from "../error/refusal.mjs";
|
|
2
2
|
import { Answer, EngineInput, Ran } from "./types.mjs";
|
|
3
|
-
import "../query/drill/internal.mjs";
|
|
4
|
-
import { Readable, offeredMembers, trendDimension } from "../query/drill/fields.mjs";
|
|
5
|
-
import { DrillClock, trendQuery } from "../query/drill/time.mjs";
|
|
6
|
-
import { DrillInput, composeDrill } from "../query/drill/compose.mjs";
|
|
7
|
-
import { LineSemantics, drillMeasure, lineSemantics } from "../query/drill/line.mjs";
|
|
8
|
-
import { ItemsOrder, itemsShape } from "../query/drill/items.mjs";
|
|
9
|
-
import { Scope, formulaParts, lineScopes, measuresOnly, scopeSteps, scopedLines } from "../query/drill/scopes.mjs";
|
|
10
|
-
import { Drawn, Picked, rowSelection } from "../query/drill/selection.mjs";
|
|
11
|
-
import { keptPath, pathFields, stepMembers } from "../query/drill/steps.mjs";
|
|
12
|
-
import { KEY_FIELD, ROW_COUNT, drillModel, drillOwner, flagCell, storedCell } from "../query/drill/synthetic.mjs";
|
|
13
|
-
import { breakdownQuery, countQuery, distinctQuery, lineFilter, parentQuery, population, summaryQuery } from "../query/drill/views.mjs";
|
|
14
3
|
import { limitedDimensions, rankQuery, segmentCuts } from "../query/segments.mjs";
|
|
15
4
|
import { PlanContext, assertPlan } from "./assert.mjs";
|
|
16
5
|
import { customReader } from "./custom/reader.mjs";
|
|
@@ -25,4 +14,4 @@ import "./run.mjs";
|
|
|
25
14
|
import { readQuery, runQuery } from "./segmented.mjs";
|
|
26
15
|
import { sqlReader } from "./sql-reader.mjs";
|
|
27
16
|
import { ENGINE_VERSION } from "./version.mjs";
|
|
28
|
-
export { type AccessPlan, type AccessTerm, type Answer, type CustomSource, type Dialect,
|
|
17
|
+
export { type AccessPlan, type AccessTerm, type Answer, type CustomSource, type Dialect, ENGINE_VERSION, EngineError, type EngineErrorCode, type EngineInput, FOLD_FUNCTION, type GroupedRead, type Guard, type HostCell, type HostRows, type PlanContext, type Ran, type ReadBucket, type ReadContext, type ReadExpr, type ReadField, type ReadFilter, type ReadJoin, type ReadMeasure, type ReadOperand, type ReadOrder, type ReadTime, type ReadValue, type Reader, type RecordPage, type RecordShape, type RecordsRead, type SourceRef, type SqlType, answerInvalid, assertPlan, customReader, foldFunctionSql, limitedDimensions, postgres, rankQuery, readQuery, readRecords, runQuery, segmentCuts, sqlReader };
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EngineError } from "../error/refusal.mjs";
|
|
1
|
+
import { EngineError, answerInvalid } from "../error/refusal.mjs";
|
|
3
2
|
import { limitedDimensions, rankQuery, segmentCuts } from "../query/segments.mjs";
|
|
4
|
-
import { formulaParts, lineScopes, measuresOnly, scopeSteps, scopedLines } from "../query/drill/scopes.mjs";
|
|
5
|
-
import { keptPath, pathFields, stepMembers } from "../query/drill/steps.mjs";
|
|
6
|
-
import { trendQuery } from "../query/drill/time.mjs";
|
|
7
|
-
import { composeDrill } from "../query/drill/compose.mjs";
|
|
8
|
-
import { itemsShape } from "../query/drill/items.mjs";
|
|
9
|
-
import { KEY_FIELD, ROW_COUNT, drillModel, drillOwner, flagCell, storedCell } from "../query/drill/synthetic.mjs";
|
|
10
|
-
import { drillMeasure, lineSemantics } from "../query/drill/line.mjs";
|
|
11
|
-
import { rowSelection } from "../query/drill/selection.mjs";
|
|
12
|
-
import { breakdownQuery, countQuery, distinctQuery, lineFilter, parentQuery, population, summaryQuery } from "../query/drill/views.mjs";
|
|
13
3
|
import { assertPlan } from "./assert.mjs";
|
|
14
4
|
import { customReader } from "./custom/reader.mjs";
|
|
15
5
|
import { FOLD_FUNCTION, foldFunctionSql, postgres } from "./postgres.mjs";
|
|
@@ -17,4 +7,4 @@ import { readRecords } from "./records.mjs";
|
|
|
17
7
|
import { readQuery, runQuery } from "./segmented.mjs";
|
|
18
8
|
import { sqlReader } from "./sql-reader.mjs";
|
|
19
9
|
import { ENGINE_VERSION } from "./version.mjs";
|
|
20
|
-
export { ENGINE_VERSION, EngineError, FOLD_FUNCTION,
|
|
10
|
+
export { ENGINE_VERSION, EngineError, FOLD_FUNCTION, answerInvalid, assertPlan, customReader, foldFunctionSql, limitedDimensions, postgres, rankQuery, readQuery, readRecords, runQuery, segmentCuts, sqlReader };
|
|
@@ -73,6 +73,7 @@ function queryMeasures(b, query) {
|
|
|
73
73
|
const def = resolveMeasure(b.model, query.source, m.measure);
|
|
74
74
|
if (def === void 0) throw new EngineError("MEASURE_UNKNOWN", `"${m.measure}" is not a measure.`);
|
|
75
75
|
return {
|
|
76
|
+
member: m.measure,
|
|
76
77
|
def,
|
|
77
78
|
line: m.filter
|
|
78
79
|
};
|
|
@@ -33,8 +33,9 @@ function instantSql(b, alias, dim) {
|
|
|
33
33
|
const d = b.dialect;
|
|
34
34
|
if (storage === "timestamptz") return d.timestamptzMicros(column);
|
|
35
35
|
if (storage === "date") return d.dateMicros(column, b.calendar.timezone);
|
|
36
|
-
|
|
37
|
-
if (storage === "
|
|
36
|
+
const digits = d.cast(d.cast(column, "text"), "numeric");
|
|
37
|
+
if (storage === "epoch_ms") return sql`round(${digits} * 1000)`;
|
|
38
|
+
if (storage === "epoch_s") return sql`round(${digits} * 1000000)`;
|
|
38
39
|
if (typeof storage === "object" && "timestamp" in storage) return d.naiveMicros(d.cast(column, "text"), storage.timestamp);
|
|
39
40
|
return d.textMicros(column);
|
|
40
41
|
}
|
|
@@ -46,7 +47,10 @@ function timeDimension(model, source, name) {
|
|
|
46
47
|
const FUNCTIONS = {
|
|
47
48
|
coalesce: (_b, args) => sql`coalesce(${join(args)})`,
|
|
48
49
|
abs: (b, [x = sql`NULL`]) => sql`abs(${b.dialect.cast(x, "float")})`,
|
|
49
|
-
round: (b, [x = sql`NULL`]) =>
|
|
50
|
+
round: (b, [x = sql`NULL`]) => {
|
|
51
|
+
const n = b.dialect.cast(x, "float");
|
|
52
|
+
return sql`CASE WHEN ${n} - floor(${n}) >= 0.5 THEN ceil(${n}) ELSE floor(${n}) END`;
|
|
53
|
+
},
|
|
50
54
|
length: (b, [x = sql`NULL`]) => sql`char_length(${b.dialect.cast(x, "text")})`,
|
|
51
55
|
lower_fold: (b, [x = sql`NULL`]) => b.dialect.fold(b.dialect.cast(x, "text"))
|
|
52
56
|
};
|
package/dist/core/engine/nan.mjs
CHANGED
|
@@ -2,8 +2,17 @@ import { EngineError } from "../error/refusal.mjs";
|
|
|
2
2
|
// src/engine/nan.ts
|
|
3
3
|
/** The one refusal for a stored NaN in a decimal column: it is not an exact number. */
|
|
4
4
|
const nanRefusal = () => new EngineError("NUMERIC_STORAGE", "A decimal column this query reads holds NaN, which is not an exact number.");
|
|
5
|
+
/**
|
|
6
|
+
* Reads the level of the worst stored exact value (`storedPart`): refuses a NaN (2), and notes
|
|
7
|
+
* a value that is no operand (1), which `sqlUnread` then counts.
|
|
8
|
+
*/
|
|
9
|
+
function checkStored(level, seen) {
|
|
10
|
+
const worst = Number(level ?? 0);
|
|
11
|
+
if (worst >= 2) throw nanRefusal();
|
|
12
|
+
if (worst >= 1) seen.unread = true;
|
|
13
|
+
}
|
|
5
14
|
/** Refuses when a count of NaN values is above zero, however a reader counted them. */
|
|
6
15
|
function refuseNaN(count) {
|
|
7
16
|
if (Number(count ?? 0) > 0) throw nanRefusal();
|
|
8
17
|
}
|
|
9
|
-
export { nanRefusal, refuseNaN };
|
|
18
|
+
export { checkStored, nanRefusal, refuseNaN };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRealDay } from "../time/text-time.mjs";
|
|
1
2
|
// src/engine/native.ts
|
|
2
3
|
const DATE = /^(\d{4})-(\d{2})-(\d{2})/u;
|
|
3
4
|
const CLOCK = / (\d{2}):(\d{2}):(\d{2})(?:\.\d{1,6})?/u;
|
|
@@ -6,25 +7,6 @@ const SHAPES = {
|
|
|
6
7
|
timestamp: new RegExp(`${DATE.source}${CLOCK.source}$`, "u"),
|
|
7
8
|
timestamptz: new RegExp(`${DATE.source}${CLOCK.source}${/([+-])(\d{2})(?::(\d{2}))?(?::(\d{2}))?$/u.source}`, "u")
|
|
8
9
|
};
|
|
9
|
-
const leap = (y) => y % 4 === 0 && y % 100 !== 0 || y % 400 === 0;
|
|
10
|
-
const DAYS = [
|
|
11
|
-
31,
|
|
12
|
-
28,
|
|
13
|
-
31,
|
|
14
|
-
30,
|
|
15
|
-
31,
|
|
16
|
-
30,
|
|
17
|
-
31,
|
|
18
|
-
31,
|
|
19
|
-
30,
|
|
20
|
-
31,
|
|
21
|
-
30,
|
|
22
|
-
31
|
|
23
|
-
];
|
|
24
|
-
function dateValid(y, m, d) {
|
|
25
|
-
const days = m === 2 && leap(y) ? 29 : DAYS[m - 1] ?? 0;
|
|
26
|
-
return y >= 1 && m >= 1 && m <= 12 && d >= 1 && d <= days;
|
|
27
|
-
}
|
|
28
10
|
const within = (parts, max) => parts.every((p, i) => p === void 0 || Number(p) <= (max[i] ?? 0));
|
|
29
11
|
/**
|
|
30
12
|
* Whether `text` has the shape the column's type writes its values in (ISO dates, a space
|
|
@@ -36,7 +18,7 @@ function readsAs(type, text) {
|
|
|
36
18
|
const match = SHAPES[type].exec(text);
|
|
37
19
|
if (match === null) return false;
|
|
38
20
|
const [, y, mo, d, h, mi, s, , oh, om, os] = match;
|
|
39
|
-
if (!
|
|
21
|
+
if (Number(y) < 1 || !isRealDay(Number(y), Number(mo), Number(d))) return false;
|
|
40
22
|
if (type === "date") return true;
|
|
41
23
|
return within([
|
|
42
24
|
h,
|