derive-dashboards 0.5.1 → 0.7.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/README.md +4 -2
- package/dist/body.mjs +2 -2
- package/dist/charts/data/buckets.d.mts +11 -0
- package/dist/charts/data/buckets.mjs +66 -0
- package/dist/charts/data/clean.mjs +55 -0
- package/dist/charts/data/format.d.mts +19 -0
- package/dist/charts/data/format.mjs +174 -0
- package/dist/charts/data/input-error.d.mts +5 -0
- package/dist/charts/data/input-error.mjs +11 -0
- package/dist/charts/data/range.mjs +14 -0
- package/dist/charts/data/rows.d.mts +13 -0
- package/dist/charts/data/rows.mjs +31 -0
- package/dist/charts/data/shares.mjs +55 -0
- package/dist/charts/data/types.d.mts +106 -0
- package/dist/charts/data/words.d.mts +44 -0
- package/dist/charts/data/words.mjs +31 -0
- package/dist/charts/describe.mjs +110 -0
- package/dist/charts/index.d.mts +34 -0
- package/dist/charts/index.mjs +24 -0
- package/dist/charts/kinds/area-marks.mjs +120 -0
- package/dist/charts/kinds/area.d.mts +23 -0
- package/dist/charts/kinds/area.mjs +71 -0
- package/dist/charts/kinds/bars-data.d.mts +11 -0
- package/dist/charts/kinds/bars-data.mjs +30 -0
- package/dist/charts/kinds/bars-layout.mjs +30 -0
- package/dist/charts/kinds/bars-marks.mjs +93 -0
- package/dist/charts/kinds/bars-words.mjs +56 -0
- package/dist/charts/kinds/bars.d.mts +17 -0
- package/dist/charts/kinds/bars.mjs +68 -0
- package/dist/charts/kinds/columns-data.mjs +116 -0
- package/dist/charts/kinds/columns-layout.mjs +29 -0
- package/dist/charts/kinds/columns-marks.mjs +200 -0
- package/dist/charts/kinds/columns-words.mjs +26 -0
- package/dist/charts/kinds/columns.d.mts +13 -0
- package/dist/charts/kinds/columns.mjs +80 -0
- package/dist/charts/kinds/dumbbell-data.d.mts +22 -0
- package/dist/charts/kinds/dumbbell-data.mjs +59 -0
- package/dist/charts/kinds/dumbbell-layout.mjs +113 -0
- package/dist/charts/kinds/dumbbell-marks.mjs +119 -0
- package/dist/charts/kinds/dumbbell-words.d.mts +7 -0
- package/dist/charts/kinds/dumbbell-words.mjs +94 -0
- package/dist/charts/kinds/dumbbell.d.mts +14 -0
- package/dist/charts/kinds/dumbbell.mjs +67 -0
- package/dist/charts/kinds/funnel-data.d.mts +11 -0
- package/dist/charts/kinds/funnel-data.mjs +70 -0
- package/dist/charts/kinds/funnel-layout.mjs +32 -0
- package/dist/charts/kinds/funnel-marks.mjs +204 -0
- package/dist/charts/kinds/funnel-words.mjs +77 -0
- package/dist/charts/kinds/funnel.d.mts +11 -0
- package/dist/charts/kinds/funnel.mjs +75 -0
- package/dist/charts/kinds/grid-data.d.mts +18 -0
- package/dist/charts/kinds/grid-data.mjs +35 -0
- package/dist/charts/kinds/grid-layout.mjs +77 -0
- package/dist/charts/kinds/grid-marks.mjs +140 -0
- package/dist/charts/kinds/grid-time.mjs +41 -0
- package/dist/charts/kinds/grid-words.mjs +86 -0
- package/dist/charts/kinds/grid.d.mts +22 -0
- package/dist/charts/kinds/grid.mjs +55 -0
- package/dist/charts/kinds/histogram-data.mjs +142 -0
- package/dist/charts/kinds/histogram-layout.mjs +144 -0
- package/dist/charts/kinds/histogram-marks.mjs +110 -0
- package/dist/charts/kinds/histogram-words.mjs +104 -0
- package/dist/charts/kinds/histogram.d.mts +15 -0
- package/dist/charts/kinds/histogram.mjs +47 -0
- package/dist/charts/kinds/line-marks.mjs +36 -0
- package/dist/charts/kinds/line.d.mts +17 -0
- package/dist/charts/kinds/line.mjs +52 -0
- package/dist/charts/kinds/multiples-grid.mjs +107 -0
- package/dist/charts/kinds/multiples-head.mjs +44 -0
- package/dist/charts/kinds/multiples-layout.mjs +159 -0
- package/dist/charts/kinds/multiples-marks.mjs +95 -0
- package/dist/charts/kinds/multiples-words.mjs +110 -0
- package/dist/charts/kinds/multiples.d.mts +26 -0
- package/dist/charts/kinds/multiples.mjs +42 -0
- package/dist/charts/kinds/row-chart.mjs +112 -0
- package/dist/charts/kinds/row-marks.mjs +121 -0
- package/dist/charts/kinds/scatter-data.d.mts +18 -0
- package/dist/charts/kinds/scatter-data.mjs +123 -0
- package/dist/charts/kinds/scatter-layout.mjs +189 -0
- package/dist/charts/kinds/scatter-marks.mjs +149 -0
- package/dist/charts/kinds/scatter-words.mjs +80 -0
- package/dist/charts/kinds/scatter.d.mts +21 -0
- package/dist/charts/kinds/scatter.mjs +72 -0
- package/dist/charts/kinds/stat-data.mjs +91 -0
- package/dist/charts/kinds/stat-layout.mjs +108 -0
- package/dist/charts/kinds/stat-marks.mjs +85 -0
- package/dist/charts/kinds/stat-words.mjs +57 -0
- package/dist/charts/kinds/stat.d.mts +28 -0
- package/dist/charts/kinds/stat.mjs +35 -0
- package/dist/charts/kinds/time-chart.mjs +74 -0
- package/dist/charts/kinds/time-frame.mjs +113 -0
- package/dist/charts/kinds/time-notes.mjs +36 -0
- package/dist/charts/kinds/time-plan.d.mts +8 -0
- package/dist/charts/kinds/time-plan.mjs +57 -0
- package/dist/charts/kinds/time-plot.mjs +56 -0
- package/dist/charts/kinds/time-stops.mjs +56 -0
- package/dist/charts/kinds/value-plot.mjs +33 -0
- package/dist/charts/kinds/waterfall-data.d.mts +7 -0
- package/dist/charts/kinds/waterfall-data.mjs +71 -0
- package/dist/charts/kinds/waterfall-layout.mjs +38 -0
- package/dist/charts/kinds/waterfall-marks.mjs +82 -0
- package/dist/charts/kinds/waterfall-words.mjs +118 -0
- package/dist/charts/kinds/waterfall.d.mts +17 -0
- package/dist/charts/kinds/waterfall.mjs +66 -0
- package/dist/charts/layout/boxes.mjs +28 -0
- package/dist/charts/layout/dodge.mjs +75 -0
- package/dist/charts/layout/extent.mjs +25 -0
- package/dist/charts/layout/frame.mjs +97 -0
- package/dist/charts/layout/place-labels.mjs +101 -0
- package/dist/charts/layout/stack.mjs +31 -0
- package/dist/charts/marks/axes.mjs +137 -0
- package/dist/charts/marks/dot.mjs +31 -0
- package/dist/charts/marks/end-labels.mjs +124 -0
- package/dist/charts/marks/legend.mjs +141 -0
- package/dist/charts/marks/lines.d.mts +2 -0
- package/dist/charts/marks/lines.mjs +38 -0
- package/dist/charts/marks/lit.d.mts +3 -0
- package/dist/charts/marks/lit.mjs +63 -0
- package/dist/charts/marks/more.mjs +18 -0
- package/dist/charts/marks/notes.mjs +253 -0
- package/dist/charts/marks/series-line.mjs +110 -0
- package/dist/charts/marks/thin.mjs +138 -0
- package/dist/charts/marks/x-axis.mjs +32 -0
- package/dist/charts/scale/calendar.mjs +174 -0
- package/dist/charts/scale/time-ticks.mjs +154 -0
- package/dist/charts/scale/time.mjs +33 -0
- package/dist/charts/scale/value.mjs +161 -0
- package/dist/charts/scene/defs.mjs +33 -0
- package/dist/charts/scene/markup.mjs +35 -0
- package/dist/charts/scene/nearest.d.mts +11 -0
- package/dist/charts/scene/nearest.mjs +49 -0
- package/dist/charts/scene/paint.d.mts +12 -0
- package/dist/charts/scene/paint.mjs +13 -0
- package/dist/charts/scene/svg.d.mts +18 -0
- package/dist/charts/scene/svg.mjs +185 -0
- package/dist/charts/scene/types.d.mts +177 -0
- package/dist/charts/text/measure.d.mts +9 -0
- package/dist/charts/text/measure.mjs +123 -0
- package/dist/charts/theme.d.mts +47 -0
- package/dist/charts/theme.mjs +239 -0
- package/dist/charts-react/Chart.d.mts +91 -0
- package/dist/charts-react/Chart.mjs +166 -0
- package/dist/charts-react/Overlay.mjs +171 -0
- package/dist/charts-react/Picture.mjs +22 -0
- package/dist/charts-react/Reader.mjs +147 -0
- package/dist/charts-react/bucket-names.mjs +29 -0
- package/dist/charts-react/chart-unlayered.css +1 -0
- package/dist/charts-react/chart-unlayered.css.d.ts +1 -0
- package/dist/charts-react/chart.css +1 -0
- package/dist/charts-react/chart.css.d.ts +1 -0
- package/dist/charts-react/events.mjs +72 -0
- package/dist/charts-react/exact-sum.mjs +24 -0
- package/dist/charts-react/from-answer.mjs +185 -0
- package/dist/charts-react/index.d.mts +3 -0
- package/dist/charts-react/index.mjs +4 -0
- package/dist/charts-react/keys.mjs +117 -0
- package/dist/charts-react/opens.mjs +28 -0
- package/dist/charts-react/plan-bars.mjs +95 -0
- package/dist/charts-react/plan-funnel.mjs +120 -0
- package/dist/charts-react/plan-grid.mjs +121 -0
- package/dist/charts-react/plan-parts.d.mts +2 -0
- package/dist/charts-react/plan-parts.mjs +30 -0
- package/dist/charts-react/plan-time.mjs +84 -0
- package/dist/charts-react/plan.d.mts +3 -0
- package/dist/charts-react/plan.mjs +37 -0
- package/dist/charts-react/point-keys.mjs +22 -0
- package/dist/charts-react/pointer.mjs +99 -0
- package/dist/charts-react/reader-page.d.mts +8 -0
- package/dist/charts-react/reader-page.mjs +116 -0
- package/dist/charts-react/tiles.d.mts +24 -0
- package/dist/charts-react/tiles.mjs +142 -0
- package/dist/charts-react/tip-place.mjs +107 -0
- package/dist/charts-react/tip-room.mjs +31 -0
- package/dist/charts-react/useClientLayoutEffect.mjs +8 -0
- package/dist/charts-react/useScene.mjs +76 -0
- package/dist/charts-react/useSize.mjs +44 -0
- package/dist/charts-react/useStop.mjs +68 -0
- package/dist/core/conformance/memory/aggregate.mjs +2 -1
- package/dist/core/conformance/memory/rows.mjs +1 -1
- package/dist/core/conformance/memory/source.mjs +3 -2
- package/dist/core/document/display-comparisons.mjs +49 -0
- package/dist/core/document/display-entries.mjs +2 -1
- package/dist/core/document/display-validation.d.mts +12 -0
- package/dist/core/document/display-validation.mjs +56 -0
- package/dist/core/document/display.d.mts +27 -12
- package/dist/core/document/display.mjs +40 -49
- package/dist/core/document/view-layout.mjs +16 -0
- package/dist/core/engine/access.mjs +4 -2
- package/dist/core/engine/context.mjs +5 -7
- package/dist/core/engine/custom/cells.mjs +1 -1
- package/dist/core/engine/custom/records.mjs +2 -1
- package/dist/core/engine/dialect.d.mts +2 -0
- package/dist/core/engine/index.mjs +1 -1
- package/dist/core/engine/levels.mjs +33 -1
- package/dist/core/engine/plan.d.mts +2 -0
- package/dist/core/engine/postgres.mjs +1 -0
- package/dist/core/engine/rank.mjs +1 -1
- package/dist/core/engine/reader.d.mts +4 -0
- package/dist/core/engine/sql-partition.mjs +45 -0
- package/dist/core/engine/sql-reads.mjs +4 -1
- package/dist/core/engine/statement.mjs +4 -4
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +1 -1
- package/dist/core/error/codes.mjs +1 -1
- package/dist/core/exact/decimal.d.mts +1 -4
- package/dist/core/exact/decimal.mjs +1 -14
- package/dist/core/exact/text.d.mts +5 -0
- package/dist/core/exact/text.mjs +19 -0
- package/dist/core/index.d.mts +9 -6
- package/dist/core/index.mjs +11 -8
- package/dist/core/model/types.d.mts +2 -0
- package/dist/core/model/validate/fields.mjs +1 -1
- package/dist/core/model/validate/known-members.mjs +2 -0
- package/dist/core/model/validate/shape.mjs +5 -1
- package/dist/core/oracle/visibility.mjs +2 -2
- package/dist/core/policy/bind.mjs +29 -1
- package/dist/core/query/drill/compose.d.mts +2 -0
- package/dist/core/query/drill/compose.mjs +1 -1
- package/dist/core/query/drill/synthetic.mjs +2 -1
- package/dist/core/query/drill/types.d.mts +7 -0
- package/dist/core/query/drill/types.mjs +3 -1
- package/dist/core/result/number.mjs +2 -1
- package/dist/core/result/time-axis.mjs +2 -1
- package/dist/core/schema/answers.d.mts +1176 -362
- package/dist/core/schema/commands.mjs +2 -1
- package/dist/core/schema/document.mjs +27 -2
- package/dist/core/schema/drill-answers.mjs +19 -1
- package/dist/core/schema/drill.d.mts +21 -6
- package/dist/core/schema/drill.mjs +7 -1
- package/dist/core/schema/index.d.mts +2 -1
- package/dist/core/schema/index.mjs +2 -1
- package/dist/core/schema/null-ops.d.mts +6 -0
- package/dist/core/schema/null-ops.mjs +18 -0
- package/dist/core/schema/query.mjs +30 -4
- package/dist/core/schema/tools.mjs +13 -0
- package/dist/core/schema/union-error.mjs +38 -0
- package/dist/core/time/bucket.mjs +2 -1
- package/dist/core/time/index.d.mts +3 -2
- package/dist/core/time/instant.d.mts +1 -2
- package/dist/core/time/instant.mjs +2 -30
- package/dist/core/time/range.mjs +2 -1
- package/dist/core/time/stored.mjs +2 -1
- package/dist/core/time/text-time.d.mts +10 -0
- package/dist/core/time/text-time.mjs +80 -0
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +22 -2
- package/dist/dashboard-documents.d.mts +8 -0
- package/dist/dashboard-documents.mjs +52 -0
- package/dist/drill-access.mjs +40 -3
- package/dist/drill-comparison.mjs +71 -0
- package/dist/drill-crumbs.mjs +21 -2
- package/dist/drill-group-seal.mjs +13 -0
- package/dist/drill-open.mjs +7 -1
- package/dist/drill-seal.mjs +4 -6
- package/dist/drill-views.mjs +5 -13
- package/dist/drill.mjs +28 -58
- package/dist/editing.mjs +1 -1
- package/dist/endpoints/drill.mjs +2 -3
- package/dist/endpoints/index.d.mts +20 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +6 -27
- package/dist/llms.txt +1 -1
- package/dist/react/Cell.mjs +2 -2
- package/dist/react/DashboardList.mjs +3 -3
- package/dist/react/Editing.mjs +3 -3
- package/dist/react/Header.mjs +2 -2
- package/dist/react/History.mjs +3 -3
- package/dist/react/Parts.mjs +2 -2
- package/dist/react/RowBody.d.mts +2 -4
- package/dist/react/RowBody.mjs +14 -39
- package/dist/react/Tile.mjs +4 -5
- package/dist/react/builder/FilterEditor.mjs +2 -2
- package/dist/react/builder/Picker.mjs +3 -3
- package/dist/react/builder/RangeEditor.mjs +3 -3
- package/dist/react/builder/Time.mjs +3 -3
- package/dist/react/builder/Values.mjs +2 -2
- package/dist/react/builder/WidgetBuilder.mjs +2 -2
- package/dist/react/digits.mjs +1 -1
- package/dist/react/drill/Bars.mjs +34 -38
- package/dist/react/drill/Comparison.mjs +204 -0
- package/dist/react/drill/Controls.mjs +8 -12
- package/dist/react/drill/DrillDrawer.mjs +42 -0
- package/dist/react/drill/DrillPanel.mjs +61 -41
- package/dist/react/drill/Header.mjs +65 -35
- package/dist/react/drill/ItemLink.mjs +40 -0
- package/dist/react/drill/Items.d.mts +2 -1
- package/dist/react/drill/Items.mjs +126 -99
- package/dist/react/drill/ItemsBody.mjs +38 -0
- package/dist/react/drill/ItemsFoot.mjs +24 -19
- package/dist/react/drill/Notes.mjs +23 -13
- package/dist/react/drill/PanelBody.mjs +7 -25
- package/dist/react/drill/RecordRow.mjs +47 -0
- package/dist/react/drill/Trend.mjs +186 -0
- package/dist/react/drill/board.mjs +21 -11
- package/dist/react/drill/drawer-context.mjs +5 -0
- package/dist/react/drill/item-parts.mjs +53 -35
- package/dist/react/drill/item-type.d.mts +2 -2
- package/dist/react/drill/lazy.d.mts +1 -4
- package/dist/react/drill/lazy.mjs +29 -11
- package/dist/react/drill/panel-focus.mjs +18 -7
- package/dist/react/drill/props.d.mts +7 -1
- package/dist/react/drill/props.mjs +39 -8
- package/dist/react/drill/record-page.mjs +61 -0
- package/dist/react/drill/state.mjs +17 -2
- package/dist/react/drill/trend-touch.mjs +33 -0
- package/dist/react/drill/useDrill.d.mts +3 -3
- package/dist/react/drill/useDrill.mjs +35 -15
- package/dist/react/drill/words.d.mts +14 -0
- package/dist/react/drill/words.mjs +20 -8
- package/dist/react/english.d.mts +4 -1
- package/dist/react/english.mjs +17 -2
- package/dist/react/filters/chip.mjs +2 -2
- package/dist/react/filters/menu-search.mjs +5 -5
- package/dist/react/filters/menu.mjs +2 -2
- package/dist/react/filters/number.mjs +2 -2
- package/dist/react/filters/operator.mjs +2 -2
- package/dist/react/filters/phone.mjs +2 -2
- package/dist/react/filters/values.mjs +4 -4
- package/dist/react/format-time.d.mts +2 -1
- package/dist/react/format-time.mjs +42 -34
- package/dist/react/format.mjs +15 -3
- package/dist/react/index.d.mts +4 -3
- package/dist/react/index.mjs +4 -3
- package/dist/react/messages.d.mts +23 -2
- package/dist/react/renderers/entries.d.mts +11 -0
- package/dist/react/renderers/list.mjs +8 -10
- package/dist/react/renderers/table-cells.mjs +38 -9
- package/dist/react/renderers/table-measure.mjs +2 -0
- package/dist/react/renderers/table-row.mjs +64 -7
- package/dist/react/renderers/table-sort.mjs +2 -8
- package/dist/react/renderers/table.mjs +16 -15
- package/dist/react/series.mjs +8 -3
- package/dist/react/theme-unlayered.css +1 -3144
- package/dist/react/theme.css +1 -3146
- package/dist/recharts/parts.mjs +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +10 -5
- package/dist/store/apply.mjs +2 -2
- package/dist/store/editor.mjs +2 -2
- package/dist/store/writer.mjs +2 -2
- package/package.json +27 -2
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
|
|
6
6
|
* against the files and prints the new value when they change.
|
|
7
7
|
*/
|
|
8
|
-
export declare const ENGINE_VERSION = "
|
|
8
|
+
export declare const ENGINE_VERSION = "f390ec5ebe464f91";
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
|
|
7
7
|
* against the files and prints the new value when they change.
|
|
8
8
|
*/
|
|
9
|
-
const ENGINE_VERSION = "
|
|
9
|
+
const ENGINE_VERSION = "f390ec5ebe464f91";
|
|
10
10
|
export { ENGINE_VERSION };
|
|
@@ -135,7 +135,7 @@ export declare const DRILL_REASONS: {
|
|
|
135
135
|
/** A dashboard edit the document reducer refuses. */
|
|
136
136
|
export declare const DOCUMENT_REFUSALS: {
|
|
137
137
|
readonly CONTROL_EXISTS: "A control with that id already exists.";
|
|
138
|
-
readonly DOCUMENT_INVALID: "A
|
|
138
|
+
readonly DOCUMENT_INVALID: "A dashboard document does not match its schema, or a code-defined dashboard has a display option its widget or query cannot use.";
|
|
139
139
|
readonly DOCUMENT_TOO_NEW: "A dashboard document was written by a newer version of the library than this one.";
|
|
140
140
|
readonly CONTROL_UNKNOWN: "The edit names a control that does not exist.";
|
|
141
141
|
readonly DISPLAY_INVALID: "An edit sets a widget's display option to the wrong type for its kind (a line's colors that is not a map of colours). Named in the issues of EDIT_REFUSED; the reducer itself applies any display, so a draft's stored commands replay.";
|
|
@@ -113,7 +113,7 @@ const DRILL_REASONS = {
|
|
|
113
113
|
/** A dashboard edit the document reducer refuses. */
|
|
114
114
|
const DOCUMENT_REFUSALS = {
|
|
115
115
|
CONTROL_EXISTS: "A control with that id already exists.",
|
|
116
|
-
DOCUMENT_INVALID: "A
|
|
116
|
+
DOCUMENT_INVALID: "A dashboard document does not match its schema, or a code-defined dashboard has a display option its widget or query cannot use.",
|
|
117
117
|
DOCUMENT_TOO_NEW: "A dashboard document was written by a newer version of the library than this one.",
|
|
118
118
|
CONTROL_UNKNOWN: "The edit names a control that does not exist.",
|
|
119
119
|
DISPLAY_INVALID: "An edit sets a widget's display option to the wrong type for its kind (a line's colors that is not a map of colours). Named in the issues of EDIT_REFUSED; the reducer itself applies any display, so a draft's stored commands replay.",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatExact, parseExact } from "./text.mjs";
|
|
1
2
|
/**
|
|
2
3
|
* Exact numbers are whole numbers of minor units (cents at scale 2). They are `bigint` from
|
|
3
4
|
* the aggregate to the cell, where they become text. They never pass through a `number`.
|
|
@@ -5,10 +6,6 @@
|
|
|
5
6
|
export type Exact = bigint;
|
|
6
7
|
/** The size no aggregate can reach (see lean/Kernel/Exact.lean) and no cell may pass. */
|
|
7
8
|
export declare const EXACT_LIMIT: Exact;
|
|
8
|
-
/** Minor units as decimal text: 1234 at scale 2 is "12.34"; -5 at scale 2 is "-0.05". */
|
|
9
|
-
export declare function formatExact(value: Exact, scale: number): string;
|
|
10
|
-
/** Decimal text as minor units. Undefined when it is not a number with at most `scale` places. */
|
|
11
|
-
export declare function parseExact(text: string, scale: number): Exact | undefined;
|
|
12
9
|
/**
|
|
13
10
|
* `numerator / denominator` to `places` decimal places, as a whole number of 10^-places,
|
|
14
11
|
* rounded half to even in one step. Null when the denominator is zero.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatExact, parseExact } from "./text.mjs";
|
|
1
2
|
import { Big } from "big.js";
|
|
2
3
|
// src/exact/decimal.ts
|
|
3
4
|
/** The size no aggregate can reach (see lean/Kernel/Exact.lean) and no cell may pass. */
|
|
@@ -11,20 +12,6 @@ function decimalAt(places) {
|
|
|
11
12
|
D.RM = HALF_EVEN;
|
|
12
13
|
return D;
|
|
13
14
|
}
|
|
14
|
-
/** Minor units as decimal text: 1234 at scale 2 is "12.34"; -5 at scale 2 is "-0.05". */
|
|
15
|
-
function formatExact(value, scale) {
|
|
16
|
-
const D = decimalAt(scale);
|
|
17
|
-
return D(value).div(D(10).pow(scale)).toFixed(scale);
|
|
18
|
-
}
|
|
19
|
-
/** The one form of decimal text, as Postgres prints `numeric`: no exponent, no bare point. */
|
|
20
|
-
const DECIMAL_TEXT = /^-?\d+(?:\.\d+)?$/u;
|
|
21
|
-
/** Decimal text as minor units. Undefined when it is not a number with at most `scale` places. */
|
|
22
|
-
function parseExact(text, scale) {
|
|
23
|
-
if (!DECIMAL_TEXT.test(text)) return void 0;
|
|
24
|
-
const D = decimalAt(scale);
|
|
25
|
-
const units = D(text).times(D(10).pow(scale));
|
|
26
|
-
return units.eq(units.round(0, 0)) ? BigInt(units.toFixed(0)) : void 0;
|
|
27
|
-
}
|
|
28
15
|
/**
|
|
29
16
|
* `numerator / denominator` to `places` decimal places, as a whole number of 10^-places,
|
|
30
17
|
* rounded half to even in one step. Null when the denominator is zero.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Exact } from "./decimal.mjs";
|
|
2
|
+
/** Minor units as decimal text: 1234 at scale 2 is "12.34"; -5 at scale 2 is "-0.05". */
|
|
3
|
+
export declare function formatExact(value: Exact, scale: number): string;
|
|
4
|
+
/** Decimal text as minor units. Undefined when it is not a number with at most `scale` places. */
|
|
5
|
+
export declare function parseExact(text: string, scale: number): Exact | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/exact/text.ts
|
|
2
|
+
/** Minor units as decimal text: 1234 at scale 2 is "12.34"; -5 at scale 2 is "-0.05". */
|
|
3
|
+
function formatExact(value, scale) {
|
|
4
|
+
const digits = (value < 0n ? -value : value).toString().padStart(scale + 1, "0");
|
|
5
|
+
const whole = digits.slice(0, digits.length - scale);
|
|
6
|
+
const fraction = scale === 0 ? "" : `.${digits.slice(digits.length - scale)}`;
|
|
7
|
+
return `${value < 0n ? "-" : ""}${whole}${fraction}`;
|
|
8
|
+
}
|
|
9
|
+
/** The one form of decimal text, as Postgres prints `numeric`: no exponent, no bare point. */
|
|
10
|
+
const DECIMAL_TEXT = /^-?\d+(?:\.\d+)?$/u;
|
|
11
|
+
/** Decimal text as minor units. Undefined when it is not a number with at most `scale` places. */
|
|
12
|
+
function parseExact(text, scale) {
|
|
13
|
+
if (!DECIMAL_TEXT.test(text)) return void 0;
|
|
14
|
+
const [whole = "0", fraction = ""] = text.replace("-", "").split(".");
|
|
15
|
+
if (/[1-9]/u.test(fraction.slice(scale))) return void 0;
|
|
16
|
+
const units = BigInt(`${whole}${fraction.slice(0, scale).padEnd(scale, "0")}`);
|
|
17
|
+
return text.startsWith("-") ? -units : units;
|
|
18
|
+
}
|
|
19
|
+
export { formatExact, parseExact };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -7,12 +7,13 @@ import { DimensionId, JoinedDimensionId, MeasureId, MemberId, ModelError, OwnDim
|
|
|
7
7
|
import { DimensionHints, Noun, NumberFormat, RecordsHint, Tone } from "./model/hints.mjs";
|
|
8
8
|
import { MemberRef, ResolvedDimension, parseMemberId, recordDimensions, resolveDimension, resolveMeasure } from "./model/member.mjs";
|
|
9
9
|
import { Moment, isZone, momentMicros } from "./time/temporal.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { lastIncludedMillisecond, parseTextTime } from "./time/text-time.mjs";
|
|
11
|
+
import { MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, Micros, formatTextTime, parseDate, parseNaiveTime } from "./time/instant.mjs";
|
|
11
12
|
import { bucketLabel, bucketLabels, bucketStart, nextBucketStart, shiftBucket } from "./time/bucket.mjs";
|
|
12
13
|
import { DatePart, DimensionDef, EXPR_FUNCTIONS, Expr, ExprCondition, ExprFunction, JoinDef, MeasureDef, MemberMeta, Model, Numeric, PolicyBinding, PolicyFilter, PolicyRule, Relationship, RowPolicy, SourceDef, TenantBinding, TimeStorage, Unit, ViewerMatch } from "./model/types.mjs";
|
|
13
14
|
import { LinearTerm, linearTerms } from "./model/validate/expr.mjs";
|
|
14
15
|
import { validateModel } from "./model/validate/index.mjs";
|
|
15
|
-
import { Cuts, Drill, DrillCan, DrillField, DrillOrigin, DrillSemantics, DrillState, DrillStep, DrillView, MAX_DRILL_STEPS, PinnedExecution, Selection } from "./query/drill/types.mjs";
|
|
16
|
+
import { Cuts, Drill, DrillCan, DrillField, DrillOrigin, DrillSemantics, DrillState, DrillStep, DrillView, MAX_DRILL_ROWS, MAX_DRILL_STEPS, PinnedExecution, Selection } from "./query/drill/types.mjs";
|
|
16
17
|
import { ColumnRole, Mark, Receipt, RecordColumn, Result, ResultCell, ResultColumn, ResultRows, TimeAxis, TimeBucket } from "./result/types.mjs";
|
|
17
18
|
import { Span, inSpan, resolveRange } from "./time/range.mjs";
|
|
18
19
|
import { NaiveRule, OffsetSegment, offsetSegments, resolveNaive, startOfDate } from "./time/zone.mjs";
|
|
@@ -20,7 +21,8 @@ import { viaJoins } from "./model/validate/via.mjs";
|
|
|
20
21
|
import { BoundRule, bindFilter, bindPolicy, namedPolicy, viewerValues } from "./policy/bind.mjs";
|
|
21
22
|
import { Command, CommandBody, CommandId, Display, Doc, LayoutItem, Scope, Tab, TabId, Widget, WidgetId, emptyDoc } from "./document/types.mjs";
|
|
22
23
|
import { Change, Placement, WidgetPart, changedWidget, diffDocs, markShifted, placementOf, widgetDiff } from "./document/diff.mjs";
|
|
23
|
-
import { DISPLAY_HELP, DISPLAY_OPTIONS, DisplayKind, DisplayOf, SharedDisplay, displayIssues, displayOf,
|
|
24
|
+
import { ComparisonFields, DISPLAY_HELP, DISPLAY_OPTIONS, DisplayKind, DisplayOf, SharedDisplay, displayIssues, displayOf, sharedDisplay } from "./document/display.mjs";
|
|
25
|
+
import { documentDisplayIssues, editedDisplayIssues } from "./document/display-validation.mjs";
|
|
24
26
|
import { GRID_COLUMNS, Gap, closeGaps, closeGapsCommands, freeSpot, layoutGaps, placeItem, repairLayout } from "./document/layout.mjs";
|
|
25
27
|
import { Outcome } from "./document/outcome.mjs";
|
|
26
28
|
import { lockChanged, reduce, reduceAll } from "./document/reduce.mjs";
|
|
@@ -28,7 +30,8 @@ import { Recorded, Replayed, commandWidget, replay } from "./document/replay.mjs
|
|
|
28
30
|
import { readingOrder, stepCommands, stepMoves } from "./document/stacked.mjs";
|
|
29
31
|
import { EncodeOptions, VIEW_PREFIX, ViewState, encodeView, viewFor, withView } from "./document/view.mjs";
|
|
30
32
|
import { smallestFor, viewLayout } from "./document/view-layout.mjs";
|
|
31
|
-
import {
|
|
33
|
+
import { formatExact, parseExact } from "./exact/text.mjs";
|
|
34
|
+
import { EXACT_LIMIT, Exact, divideExact, storedExact } from "./exact/decimal.mjs";
|
|
32
35
|
import { ExactSum, Operands, rowValue, sumLinear } from "./exact/sum.mjs";
|
|
33
36
|
import { bindQueryViewer, bindViewer } from "./policy/bind-query.mjs";
|
|
34
37
|
import { ruleMatches, selectRule } from "./policy/match.mjs";
|
|
@@ -44,7 +47,7 @@ import { CalcAlias, Calendar, Cell, Control, ControlId, DateRange, DimensionAlia
|
|
|
44
47
|
import "./time/index.mjs";
|
|
45
48
|
import { ItemLinks, ItemLinksFor, LINK_PART, itemLink, linkTemplateIssues } from "./query/drill/links.mjs";
|
|
46
49
|
import { ApiError, CONTRACT_VERSION, CoreContract, DashboardListResponse, DashboardResponse, DraftResponse, MetaJoin, MetaMember, MetaResponse, PublishResponse, QueryAnswer, QueryLine, RecordsResponse, TileAnswer, TileLine, TileRequest, TileResult, TilesRequest, ValidateResponse, ValuesResponse } from "./types/api.mjs";
|
|
47
|
-
import { AnswerDrill, ClosedRow, DrillAbilities, DrillAnswer, DrillBody, DrillCrumb, DrillExplanationView, DrillGroupedView, DrillItem, DrillItemsView, DrillOperand, DrillSummary, ItemColumn, SealedAnswer } from "./types/drill-api.mjs";
|
|
50
|
+
import { AnswerDrill, ClosedRow, DrillAbilities, DrillAnswer, DrillBody, DrillComparisonView, DrillCrumb, DrillExplanationView, DrillGroupedView, DrillItem, DrillItemsView, DrillOperand, DrillSummary, ItemColumn, SealedAnswer } from "./types/drill-api.mjs";
|
|
48
51
|
import { CoreApi, CreateDash, Dash, EndpointsByPath, HeadersLike, PluginEndpoints, PluginErrorCodes, ServerCall, ServerCallInput, ServerCalls, UniqueIds } from "./types/infer.mjs";
|
|
49
52
|
import { CodeDashboard, DashOptions, SecondaryStorage } from "./types/options.mjs";
|
|
50
53
|
import { addsUp } from "./result/additive.mjs";
|
|
@@ -62,4 +65,4 @@ import { Author, DashAdapter, DashboardHead, DashboardReader, DashboardStore, Da
|
|
|
62
65
|
import { CanFn, Channel, Principal, Resource, TenantKeysOf, Verb, Viewer, ViewerFor, principalTenant } from "./types/viewer.mjs";
|
|
63
66
|
import { canonical } from "./value/canonical.mjs";
|
|
64
67
|
import { fold, foldingPairs } from "./value/casefold.mjs";
|
|
65
|
-
export { type AccessParts, type Alias, type AnswerDrill, type ApiError, type AssertionContext, type Author, type Awaitable, BASE_ERROR_CODES, type BoundFilter, type BoundPolicy, type BoundPolicyFilter, type BoundRule, CATALOG, CONTRACT_VERSION, type CalcAlias, type Calendar, type CanFn, type Catalog, type CatalogIssueCode, type Cell, type Change, type Channel, type ClosedRow, type Closure, type CodeDashboard, type Column, type ColumnRole, type ColumnType, type Command, type CommandBody, type CommandId, type ComposeCtx, type ComposeDelta, type ComposedQuery, type ComposedTile, type CompositionPolicy, type ConnectionId, type Control, type ControlId, type CoreApi, type CoreContract, type CreateDash, type CustomSource, type Cuts, DEFAULT_COMPOSITION_POLICY, DISPLAY_HELP, DISPLAY_OPTIONS, DRILL_REASONS, type Dash, type DashAdapter, type DashEndpoint, type DashHook, type DashOptions, type DashPlugin, type DashboardHead, type DashboardListResponse, type DashboardReader, type DashboardResponse, type DashboardStore, type DashboardSummary, type DatePart, type DateRange, type DbSchema, type DimensionAlias, type DimensionCut, type DimensionDef, type DimensionHints, type DimensionId, type DimensionName, type Display, type DisplayKind, type DisplayOf, type Doc, type DocumentRefusalCode, type DocumentSlice, type Draft, type DraftResponse, type DraftTarget, type Drill, type DrillAbilities, type DrillAnswer, type DrillBody, type DrillCan, type DrillCrumb, type DrillExplanationView, type DrillField, type DrillGroupedView, type DrillItem, type DrillItemsView, type DrillOperand, type DrillOrigin, type DrillReason, type DrillSemantics, type DrillState, type DrillStep, type DrillSummary, type DrillView, EXACT_LIMIT, EXPR_FUNCTIONS, type EncodeOptions, type EndpointAccess, type EndpointContext, type EndpointsByPath, type EntryId, type Exact, type ExactSum, type Explanation, type ExplicitRange, type Expr, type ExprCondition, type ExprFunction, type Field, type FieldType, type Format, type Formula, type FormulaNode, type FormulaRef, GRID_COLUMNS, type Gap, type Grain, type GroupedRead, type HeadersLike, type HookContext, type HostCell, type HostRows, type IanaZone, type IntrospectingConnection, type IsoInstant, type Issue, type IssueCode, type ItemColumn, type ItemLinks, type ItemLinksFor, type JoinDef, type JoinName, type JoinedDimensionId, LINK_PART, type LayoutItem, type Leaf, type LinearTerm, type LockEntry, MAX_DRILL_STEPS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, type Mark, type MeasureAlias, type MeasureDef, type MeasureId, type MeasureName, type MemberId, type MemberMeta, type MemberRef, type MetaJoin, type MetaMember, type MetaResponse, type Micros, type Model, ModelError, type ModelIssueCode, type Moment, NEGATION_OF, NEGATIVE_OPS, NULL_OPS, type NaiveRule, type NegativeOp, type NodeId, type Noun, type NullOp, type NumberFormat, type Numeric, type OffsetSegment, type Op, type Operands, type Outcome, type OverlapPart, type OwnDimensionId, POSITIVE_OPS, type PageRequest, type Param, type Picks, type PinnedExecution, type Placement, type PluginEndpoints, type PluginErrorCodes, type PolicyBinding, type PolicyFilter, type PolicyName, type PolicyRule, type PositiveOp, type Preview, type Primitive, type Principal, type PublishResponse, type Published, type QueryAnswer, type QueryConnection, type QueryCtx, type QueryLine, QueryReferenceError, type QueryRefusalCode, type RawError, type RawLevels, type RawResult, type ReadContext, type ReadField, type ReadFilter, type ReadMeasure, type ReadSession, type Receipt, type RecordColumn, type RecordPage, type Recorded, type RecordsHint, type RecordsRead, type RecordsResponse, type RefOf, type Refusal, type Relationship, type RelativeRange, type Replayed, type RequiredEntry, type ResolvedDimension, type ResolvedRange, type Resource, type Result, type ResultCell, type ResultColumn, type ResultRows, type ResultWarningCode, type Row, type RowPolicy, type RunOptions, type RuntimeErrorCode, type SchemaDriver, type Scope, type ScopeCoverage, type SealedAnswer, type SecondaryStorage, type Selection, type SemanticProvider, type ServerCall, type ServerCallInput, type ServerCalls, type SharedDisplay, type SourceDef, type SourceName, type SourceNameOf, type Span, type Sql, type StoreDialect, type StoredFilter, type StoredFormulaNode, type StoredLockEntry, type StoredQuery, type StoredVersion, TABLES, type Tab, type TabId, type TableCheck, type TableDef, type TableName, type Tenant, type TenantBinding, type TenantKey, type TenantKeysOf, type TileAnswer, type TileInput, type TileLine, type TileRef, type TileRequest, type TileResult, type TilesRequest, type TimeAxis, type TimeBucket, type TimeStorage, type Token, type Tone, type TypedFilter, type TypedQuery, type UniqueIds, type Unit, type UnpublishedDraft, VIEW_PREFIX, type ValidateResponse, type ValueLeaf, type ValuesResponse, type VariableLeaf, type Verb, type VersionEntry, type ViewState, type Viewer, type ViewerFor, type ViewerLeaf, type ViewerMatch, type ViewerRef, type WeekStart, type Where, type Widget, type WidgetId, type WidgetPart, type WireFilter, type WireQuery, addsUp, bindFilter, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketLabels, bucketStart, canonical, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonQuery, comparisonSpan, composeTile, createDashEndpoint, createTable, defineErrorCodes, defineModel, describeQueries, diffDocs, displayIssues, displayOf, divideExact, documentDisplayIssues, documentLock, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entryAliases, fold, foldingPairs, formatExact, formatTextTime, formulaRefs, freeSpot, inSpan, isBound, isDateRange, isLeaf, isMark, isValuePick, isZone, itemLink, layoutGaps, linearTerms, linkTemplateIssues, lockChanged, markShifted, markedRows, memberLabel, momentMicros, namedPolicy, nextBucketStart, offsetSegments, parseDate, parseExact, parseMemberId, parseNaiveTime, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, repairLayout, replay, resolveDimension, resolveMeasure, resolveNaive, resolveRange, resultColumns, roleOf, rowValue, ruleMatches, schemaChecks, schemaStatements, selectRule, shareOf, sharedDisplay, shiftBucket, shiftInstant, smallestFor, startOfDate, stepCommands, stepMoves, storedExact, stripIds, sumLinear, tileInputs, timeAxis, toWire, validateModel, viaJoins, viewFor, viewLayout, viewerValues, widgetDiff, withTime, withView };
|
|
68
|
+
export { type AccessParts, type Alias, type AnswerDrill, type ApiError, type AssertionContext, type Author, type Awaitable, BASE_ERROR_CODES, type BoundFilter, type BoundPolicy, type BoundPolicyFilter, type BoundRule, CATALOG, CONTRACT_VERSION, type CalcAlias, type Calendar, type CanFn, type Catalog, type CatalogIssueCode, type Cell, type Change, type Channel, type ClosedRow, type Closure, type CodeDashboard, type Column, type ColumnRole, type ColumnType, type Command, type CommandBody, type CommandId, type ComparisonFields, type ComposeCtx, type ComposeDelta, type ComposedQuery, type ComposedTile, type CompositionPolicy, type ConnectionId, type Control, type ControlId, type CoreApi, type CoreContract, type CreateDash, type CustomSource, type Cuts, DEFAULT_COMPOSITION_POLICY, DISPLAY_HELP, DISPLAY_OPTIONS, DRILL_REASONS, type Dash, type DashAdapter, type DashEndpoint, type DashHook, type DashOptions, type DashPlugin, type DashboardHead, type DashboardListResponse, type DashboardReader, type DashboardResponse, type DashboardStore, type DashboardSummary, type DatePart, type DateRange, type DbSchema, type DimensionAlias, type DimensionCut, type DimensionDef, type DimensionHints, type DimensionId, type DimensionName, type Display, type DisplayKind, type DisplayOf, type Doc, type DocumentRefusalCode, type DocumentSlice, type Draft, type DraftResponse, type DraftTarget, type Drill, type DrillAbilities, type DrillAnswer, type DrillBody, type DrillCan, type DrillComparisonView, type DrillCrumb, type DrillExplanationView, type DrillField, type DrillGroupedView, type DrillItem, type DrillItemsView, type DrillOperand, type DrillOrigin, type DrillReason, type DrillSemantics, type DrillState, type DrillStep, type DrillSummary, type DrillView, EXACT_LIMIT, EXPR_FUNCTIONS, type EncodeOptions, type EndpointAccess, type EndpointContext, type EndpointsByPath, type EntryId, type Exact, type ExactSum, type Explanation, type ExplicitRange, type Expr, type ExprCondition, type ExprFunction, type Field, type FieldType, type Format, type Formula, type FormulaNode, type FormulaRef, GRID_COLUMNS, type Gap, type Grain, type GroupedRead, type HeadersLike, type HookContext, type HostCell, type HostRows, type IanaZone, type IntrospectingConnection, type IsoInstant, type Issue, type IssueCode, type ItemColumn, type ItemLinks, type ItemLinksFor, type JoinDef, type JoinName, type JoinedDimensionId, LINK_PART, type LayoutItem, type Leaf, type LinearTerm, type LockEntry, MAX_DRILL_ROWS, MAX_DRILL_STEPS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, type Mark, type MeasureAlias, type MeasureDef, type MeasureId, type MeasureName, type MemberId, type MemberMeta, type MemberRef, type MetaJoin, type MetaMember, type MetaResponse, type Micros, type Model, ModelError, type ModelIssueCode, type Moment, NEGATION_OF, NEGATIVE_OPS, NULL_OPS, type NaiveRule, type NegativeOp, type NodeId, type Noun, type NullOp, type NumberFormat, type Numeric, type OffsetSegment, type Op, type Operands, type Outcome, type OverlapPart, type OwnDimensionId, POSITIVE_OPS, type PageRequest, type Param, type Picks, type PinnedExecution, type Placement, type PluginEndpoints, type PluginErrorCodes, type PolicyBinding, type PolicyFilter, type PolicyName, type PolicyRule, type PositiveOp, type Preview, type Primitive, type Principal, type PublishResponse, type Published, type QueryAnswer, type QueryConnection, type QueryCtx, type QueryLine, QueryReferenceError, type QueryRefusalCode, type RawError, type RawLevels, type RawResult, type ReadContext, type ReadField, type ReadFilter, type ReadMeasure, type ReadSession, type Receipt, type RecordColumn, type RecordPage, type Recorded, type RecordsHint, type RecordsRead, type RecordsResponse, type RefOf, type Refusal, type Relationship, type RelativeRange, type Replayed, type RequiredEntry, type ResolvedDimension, type ResolvedRange, type Resource, type Result, type ResultCell, type ResultColumn, type ResultRows, type ResultWarningCode, type Row, type RowPolicy, type RunOptions, type RuntimeErrorCode, type SchemaDriver, type Scope, type ScopeCoverage, type SealedAnswer, type SecondaryStorage, type Selection, type SemanticProvider, type ServerCall, type ServerCallInput, type ServerCalls, type SharedDisplay, type SourceDef, type SourceName, type SourceNameOf, type Span, type Sql, type StoreDialect, type StoredFilter, type StoredFormulaNode, type StoredLockEntry, type StoredQuery, type StoredVersion, TABLES, type Tab, type TabId, type TableCheck, type TableDef, type TableName, type Tenant, type TenantBinding, type TenantKey, type TenantKeysOf, type TileAnswer, type TileInput, type TileLine, type TileRef, type TileRequest, type TileResult, type TilesRequest, type TimeAxis, type TimeBucket, type TimeStorage, type Token, type Tone, type TypedFilter, type TypedQuery, type UniqueIds, type Unit, type UnpublishedDraft, VIEW_PREFIX, type ValidateResponse, type ValueLeaf, type ValuesResponse, type VariableLeaf, type Verb, type VersionEntry, type ViewState, type Viewer, type ViewerFor, type ViewerLeaf, type ViewerMatch, type ViewerRef, type WeekStart, type Where, type Widget, type WidgetId, type WidgetPart, type WireFilter, type WireQuery, addsUp, bindFilter, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketLabels, bucketStart, canonical, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonQuery, comparisonSpan, composeTile, createDashEndpoint, createTable, defineErrorCodes, defineModel, describeQueries, diffDocs, displayIssues, displayOf, divideExact, documentDisplayIssues, documentLock, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entryAliases, fold, foldingPairs, formatExact, formatTextTime, formulaRefs, freeSpot, inSpan, isBound, isDateRange, isLeaf, isMark, isValuePick, isZone, itemLink, lastIncludedMillisecond, layoutGaps, linearTerms, linkTemplateIssues, lockChanged, markShifted, markedRows, memberLabel, momentMicros, namedPolicy, nextBucketStart, offsetSegments, parseDate, parseExact, parseMemberId, parseNaiveTime, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, repairLayout, replay, resolveDimension, resolveMeasure, resolveNaive, resolveRange, resultColumns, roleOf, rowValue, ruleMatches, schemaChecks, schemaStatements, selectRule, shareOf, sharedDisplay, shiftBucket, shiftInstant, smallestFor, startOfDate, stepCommands, stepMoves, storedExact, stripIds, sumLinear, tileInputs, timeAxis, toWire, validateModel, viaJoins, viewFor, viewLayout, viewerValues, widgetDiff, withTime, withView };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { BASE_ERROR_CODES, DRILL_REASONS, defineErrorCodes } from "./error/codes.mjs";
|
|
2
2
|
import { changedWidget, diffDocs, markShifted, placementOf, widgetDiff } from "./document/diff.mjs";
|
|
3
|
+
import { DISPLAY_HELP, DISPLAY_OPTIONS, displayIssues, displayOf, sharedDisplay } from "./document/display.mjs";
|
|
3
4
|
import { checkCatalog } from "./model/catalog/check.mjs";
|
|
4
5
|
import { describeQueries } from "./model/catalog/queries.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { policyBinding } from "./model/defaults.mjs";
|
|
7
|
+
import { documentDisplayIssues, editedDisplayIssues } from "./document/display-validation.mjs";
|
|
6
8
|
import { GRID_COLUMNS, closeGaps, closeGapsCommands, freeSpot, layoutGaps, placeItem, repairLayout } from "./document/layout.mjs";
|
|
7
9
|
import { lockChanged, reduce, reduceAll } from "./document/reduce.mjs";
|
|
8
10
|
import { commandWidget, replay } from "./document/replay.mjs";
|
|
9
11
|
import { readingOrder, stepCommands, stepMoves } from "./document/stacked.mjs";
|
|
10
12
|
import { emptyDoc } from "./document/types.mjs";
|
|
11
|
-
import {
|
|
13
|
+
import { ModelError, defineModel } from "./model/define.mjs";
|
|
12
14
|
import { VIEW_PREFIX, encodeView, viewFor, withView } from "./document/view.mjs";
|
|
13
15
|
import { smallestFor, viewLayout } from "./document/view-layout.mjs";
|
|
14
|
-
import { ModelError, defineModel } from "./model/define.mjs";
|
|
15
|
-
import { EXACT_LIMIT, divideExact, formatExact, parseExact, storedExact } from "./exact/decimal.mjs";
|
|
16
|
-
import { rowValue, sumLinear } from "./exact/sum.mjs";
|
|
17
16
|
import { parseMemberId, recordDimensions, resolveDimension, resolveMeasure } from "./model/member.mjs";
|
|
17
|
+
import { formatExact, parseExact } from "./exact/text.mjs";
|
|
18
|
+
import { EXACT_LIMIT, divideExact, storedExact } from "./exact/decimal.mjs";
|
|
19
|
+
import { rowValue, sumLinear } from "./exact/sum.mjs";
|
|
18
20
|
import { EXPR_FUNCTIONS } from "./model/types.mjs";
|
|
19
21
|
import { linearTerms } from "./model/validate/expr.mjs";
|
|
20
22
|
import { validateModel } from "./model/validate/index.mjs";
|
|
@@ -32,12 +34,13 @@ import { changeOf, formulaRefs, shareOf } from "./query/formulas.mjs";
|
|
|
32
34
|
import { isDateRange, isValuePick, pickProblem } from "./query/picks.mjs";
|
|
33
35
|
import { QueryReferenceError, entryAliases, toWire } from "./query/to-wire.mjs";
|
|
34
36
|
import { LINK_PART, itemLink, linkTemplateIssues } from "./query/drill/links.mjs";
|
|
35
|
-
import { MAX_DRILL_STEPS } from "./query/drill/types.mjs";
|
|
37
|
+
import { MAX_DRILL_ROWS, MAX_DRILL_STEPS } from "./query/drill/types.mjs";
|
|
36
38
|
import { CONTRACT_VERSION } from "./types/api.mjs";
|
|
37
39
|
import { addsUp } from "./result/additive.mjs";
|
|
38
40
|
import { memberLabel, recordColumns, resultColumns, roleOf } from "./result/columns.mjs";
|
|
39
41
|
import { isMark, markedRows } from "./result/marks.mjs";
|
|
40
|
-
import {
|
|
42
|
+
import { lastIncludedMillisecond, parseTextTime } from "./time/text-time.mjs";
|
|
43
|
+
import { MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, formatTextTime, parseDate, parseNaiveTime } from "./time/instant.mjs";
|
|
41
44
|
import { offsetSegments, resolveNaive, startOfDate } from "./time/zone.mjs";
|
|
42
45
|
import { bucketLabel, bucketLabels, bucketStart, nextBucketStart, shiftBucket } from "./time/bucket.mjs";
|
|
43
46
|
import { timeAxis, withTime } from "./result/time-axis.mjs";
|
|
@@ -49,4 +52,4 @@ import { createDashEndpoint } from "./types/plugin.mjs";
|
|
|
49
52
|
import { principalTenant } from "./types/viewer.mjs";
|
|
50
53
|
import { canonical } from "./value/canonical.mjs";
|
|
51
54
|
import { fold, foldingPairs } from "./value/casefold.mjs";
|
|
52
|
-
export { BASE_ERROR_CODES, CATALOG, CONTRACT_VERSION, DEFAULT_COMPOSITION_POLICY, DISPLAY_HELP, DISPLAY_OPTIONS, DRILL_REASONS, EXACT_LIMIT, EXPR_FUNCTIONS, GRID_COLUMNS, LINK_PART, MAX_DRILL_STEPS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, ModelError, NEGATION_OF, NEGATIVE_OPS, NULL_OPS, POSITIVE_OPS, QueryReferenceError, TABLES, VIEW_PREFIX, addsUp, bindFilter, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketLabels, bucketStart, canonical, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonQuery, comparisonSpan, composeTile, createDashEndpoint, createTable, defineErrorCodes, defineModel, describeQueries, diffDocs, displayIssues, displayOf, divideExact, documentDisplayIssues, documentLock, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entryAliases, fold, foldingPairs, formatExact, formatTextTime, formulaRefs, freeSpot, inSpan, isBound, isDateRange, isLeaf, isMark, isValuePick, isZone, itemLink, layoutGaps, linearTerms, linkTemplateIssues, lockChanged, markShifted, markedRows, memberLabel, momentMicros, namedPolicy, nextBucketStart, offsetSegments, parseDate, parseExact, parseMemberId, parseNaiveTime, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, repairLayout, replay, resolveDimension, resolveMeasure, resolveNaive, resolveRange, resultColumns, roleOf, rowValue, ruleMatches, schemaChecks, schemaStatements, selectRule, shareOf, sharedDisplay, shiftBucket, shiftInstant, smallestFor, startOfDate, stepCommands, stepMoves, storedExact, stripIds, sumLinear, tileInputs, timeAxis, toWire, validateModel, viaJoins, viewFor, viewLayout, viewerValues, widgetDiff, withTime, withView };
|
|
55
|
+
export { BASE_ERROR_CODES, CATALOG, CONTRACT_VERSION, DEFAULT_COMPOSITION_POLICY, DISPLAY_HELP, DISPLAY_OPTIONS, DRILL_REASONS, EXACT_LIMIT, EXPR_FUNCTIONS, GRID_COLUMNS, LINK_PART, MAX_DRILL_ROWS, MAX_DRILL_STEPS, MICROS_PER_DAY, MICROS_PER_HOUR, MICROS_PER_SECOND, ModelError, NEGATION_OF, NEGATIVE_OPS, NULL_OPS, POSITIVE_OPS, QueryReferenceError, TABLES, VIEW_PREFIX, addsUp, bindFilter, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketLabels, bucketStart, canonical, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonQuery, comparisonSpan, composeTile, createDashEndpoint, createTable, defineErrorCodes, defineModel, describeQueries, diffDocs, displayIssues, displayOf, divideExact, documentDisplayIssues, documentLock, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entryAliases, fold, foldingPairs, formatExact, formatTextTime, formulaRefs, freeSpot, inSpan, isBound, isDateRange, isLeaf, isMark, isValuePick, isZone, itemLink, lastIncludedMillisecond, layoutGaps, linearTerms, linkTemplateIssues, lockChanged, markShifted, markedRows, memberLabel, momentMicros, namedPolicy, nextBucketStart, offsetSegments, parseDate, parseExact, parseMemberId, parseNaiveTime, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, repairLayout, replay, resolveDimension, resolveMeasure, resolveNaive, resolveRange, resultColumns, roleOf, rowValue, ruleMatches, schemaChecks, schemaStatements, selectRule, shareOf, sharedDisplay, shiftBucket, shiftInstant, smallestFor, startOfDate, stepCommands, stepMoves, storedExact, stripIds, sumLinear, tileInputs, timeAxis, toWire, validateModel, viaJoins, viewFor, viewLayout, viewerValues, widgetDiff, withTime, withView };
|
|
@@ -181,9 +181,11 @@ export type MeasureDef = MemberMeta & {
|
|
|
181
181
|
} & OverColumn) | ({
|
|
182
182
|
kind: "avg";
|
|
183
183
|
numeric: Numeric;
|
|
184
|
+
unit?: Unit;
|
|
184
185
|
} & OverColumn) | ({
|
|
185
186
|
kind: "percentile";
|
|
186
187
|
p: 50 | 75 | 90 | 95 | 99;
|
|
188
|
+
unit?: Unit;
|
|
187
189
|
} & OverColumn) | {
|
|
188
190
|
kind: "ratio";
|
|
189
191
|
numerator: MeasureName;
|
|
@@ -127,4 +127,4 @@ function lacking(what, keys) {
|
|
|
127
127
|
return [issue("MODEL_SHAPE", path, `${what} holds one of ${keys.join(", ")}.${meant(near)}`)];
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
export { byKey, byKind, fields, lacking, listOf, mapOf, orFalse, orWord, orWords, wordOrList };
|
|
130
|
+
export { byKey, byKind, fields, lacking, listOf, mapOf, nearest, orFalse, orWord, orWords, wordOrList };
|
|
@@ -48,6 +48,7 @@ const MEASURE = byKind("a measure", {
|
|
|
48
48
|
"kind",
|
|
49
49
|
"merge",
|
|
50
50
|
"numeric",
|
|
51
|
+
"unit",
|
|
51
52
|
...OVER,
|
|
52
53
|
...META
|
|
53
54
|
]), over),
|
|
@@ -55,6 +56,7 @@ const MEASURE = byKind("a measure", {
|
|
|
55
56
|
"kind",
|
|
56
57
|
"merge",
|
|
57
58
|
"p",
|
|
59
|
+
"unit",
|
|
58
60
|
...OVER,
|
|
59
61
|
...META
|
|
60
62
|
]), over),
|
|
@@ -46,6 +46,9 @@ const oneOf = (list) => list.map((v) => JSON.stringify(v)).join(", ");
|
|
|
46
46
|
function needs(m, fields, path) {
|
|
47
47
|
return fields.flatMap((f) => m[f] === void 0 ? [shape([...path, f], `A ${String(m["kind"])} needs "${f}".`)] : []);
|
|
48
48
|
}
|
|
49
|
+
function unitShape(unit, path) {
|
|
50
|
+
return unit === void 0 || typeof unit === "string" ? [] : [shape([...path, "unit"], "A measure unit is a string, such as \"USD\".")];
|
|
51
|
+
}
|
|
49
52
|
function measureShape(m, path) {
|
|
50
53
|
if (!isObject(m)) return [shape(path, "A measure is an object.")];
|
|
51
54
|
if (!known(MEASURE_KINDS, m["kind"])) return [shape([...path, "kind"], `"${String(m["kind"])}" is not a measure kind: ${oneOf(MEASURE_KINDS)}.`)];
|
|
@@ -57,7 +60,8 @@ function measureShape(m, path) {
|
|
|
57
60
|
return [
|
|
58
61
|
...merge,
|
|
59
62
|
...needs(m, fields, path),
|
|
60
|
-
...p
|
|
63
|
+
...p,
|
|
64
|
+
...unitShape(m["unit"], path)
|
|
61
65
|
];
|
|
62
66
|
}
|
|
63
67
|
function storageShape(storage, path) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { policyBinding, tenantBinding, tenantKeys } from "../model/defaults.mjs";
|
|
2
|
-
import { bindPolicy, namedPolicy } from "../policy/bind.mjs";
|
|
2
|
+
import { bindPolicy, grantsNothingYet, namedPolicy } from "../policy/bind.mjs";
|
|
3
3
|
import { principalTenant } from "../types/viewer.mjs";
|
|
4
4
|
import { joined, sourceOf } from "./data.mjs";
|
|
5
5
|
import { evaluateLeaf } from "./filter.mjs";
|
|
@@ -46,6 +46,6 @@ function readable(input, source) {
|
|
|
46
46
|
const policy = policyBinding(sourceOf(input.model, source));
|
|
47
47
|
if (typeof policy === "object" && "via" in policy) return (typeof policy.via === "string" ? [policy.via] : policy.via).every((name) => readable(input, sourceOf(input.model, source).joins?.[name]?.to ?? source));
|
|
48
48
|
const rules = typeof policy === "string" ? namedPolicy(input.model, policy) : policy;
|
|
49
|
-
return bindPolicy(rules, input.principal) !== "none";
|
|
49
|
+
return bindPolicy(rules, input.principal) !== "none" || grantsNothingYet(rules, input.principal);
|
|
50
50
|
}
|
|
51
51
|
export { allowed, inTenant, readable };
|
|
@@ -61,4 +61,32 @@ function namedPolicy(model, name) {
|
|
|
61
61
|
if (name === "all") return ALL_FOR_USERS;
|
|
62
62
|
return model.policies?.[name] ?? { rules: [] };
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
/** The viewer references a policy filter reads. */
|
|
65
|
+
function refsOf(filter) {
|
|
66
|
+
if ("all" in filter) return filter.all.flatMap(refsOf);
|
|
67
|
+
if ("any" in filter) return filter.any.flatMap(refsOf);
|
|
68
|
+
if ("not" in filter) return refsOf(filter.not);
|
|
69
|
+
return "viewer" in filter ? [filter.viewer] : [];
|
|
70
|
+
}
|
|
71
|
+
/** Whether the viewer holds a reference at all; an empty list is held (it means "none yet"). */
|
|
72
|
+
function holds(viewer, ref) {
|
|
73
|
+
if (ref === "id") return viewer.id !== "";
|
|
74
|
+
if (ref === "roles") return viewer.roles !== void 0;
|
|
75
|
+
return viewer.attributes?.[ref.slice(11)] !== void 0;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Whether a rule applies to the principal but reads only lists the viewer holds empty: a person
|
|
79
|
+
* with no websites yet. They read no rows, exactly as with "none", but they do have access, so
|
|
80
|
+
* their tiles are empty answers, not refusals. A rule that says "none", a value the viewer does
|
|
81
|
+
* not have at all, or no rule that applies, is no access.
|
|
82
|
+
*/
|
|
83
|
+
function grantsNothingYet(policy, principal) {
|
|
84
|
+
const selected = selectRule(policy, principal);
|
|
85
|
+
if (selected === void 0) return false;
|
|
86
|
+
const allow = selected.rule.allow;
|
|
87
|
+
if (allow === "all" || allow === "none") return false;
|
|
88
|
+
const viewer = principal.channel === "user" ? principal.viewer : void 0;
|
|
89
|
+
if (viewer === void 0 || bindFilter(allow, viewer) !== void 0) return false;
|
|
90
|
+
return refsOf(allow).every((ref) => holds(viewer, ref));
|
|
91
|
+
}
|
|
92
|
+
export { bindFilter, bindPolicy, grantsNothingYet, namedPolicy, viewerValues };
|
|
@@ -10,6 +10,8 @@ export type DrillInput = {
|
|
|
10
10
|
drill: Drill;
|
|
11
11
|
readable: Readable;
|
|
12
12
|
clock: DrillClock;
|
|
13
|
+
/** A group comparison reads every line together. */
|
|
14
|
+
comparison?: true;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* The rows behind a drill, as a query with no grouping: the tile's own query (its filters,
|
|
@@ -71,7 +71,7 @@ function composeDrill(input) {
|
|
|
71
71
|
const [only, ...more] = parts;
|
|
72
72
|
const around = aroundCalcs(query);
|
|
73
73
|
const calc = (query.calc ?? []).filter((c) => !around.has(c.id));
|
|
74
|
-
checkLine(query, drill);
|
|
74
|
+
if (!input.comparison || drill.measure !== void 0) checkLine(query, drill);
|
|
75
75
|
const time = drilledTime(input.model, query, drill.steps, input.clock);
|
|
76
76
|
return {
|
|
77
77
|
kind: query.kind,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { storedExact } from "../../exact/decimal.mjs";
|
|
2
|
+
import { formatExact } from "../../exact/text.mjs";
|
|
2
3
|
import { parseMemberId } from "../../model/member.mjs";
|
|
3
4
|
import { memberLabel } from "../../result/columns.mjs";
|
|
4
5
|
import { operandColumn } from "./operand.mjs";
|
|
@@ -101,6 +101,10 @@ export type DrillView = {
|
|
|
101
101
|
by: "breakdown";
|
|
102
102
|
member?: string;
|
|
103
103
|
search?: string;
|
|
104
|
+
} | {
|
|
105
|
+
by: "comparison";
|
|
106
|
+
member: string;
|
|
107
|
+
thenBy?: string;
|
|
104
108
|
} | {
|
|
105
109
|
by: "trend";
|
|
106
110
|
grain?: Grain;
|
|
@@ -109,6 +113,7 @@ export type DrillView = {
|
|
|
109
113
|
{
|
|
110
114
|
by: "items";
|
|
111
115
|
numerator?: true;
|
|
116
|
+
fields?: true;
|
|
112
117
|
} | {
|
|
113
118
|
by: "explanation";
|
|
114
119
|
};
|
|
@@ -138,6 +143,8 @@ export type Cuts = {
|
|
|
138
143
|
};
|
|
139
144
|
/** A path is at most this many selections; a deeper one is refused. */
|
|
140
145
|
export declare const MAX_DRILL_STEPS = 8;
|
|
146
|
+
/** Maximum number of rows a sealed answer can open, counted from the start of the answer. */
|
|
147
|
+
export declare const MAX_DRILL_ROWS = 1000;
|
|
141
148
|
/** A field a drill can be broken down by, as a viewer reads it. */
|
|
142
149
|
export type DrillField = {
|
|
143
150
|
id: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// src/query/drill/types.ts
|
|
2
2
|
/** A path is at most this many selections; a deeper one is refused. */
|
|
3
3
|
const MAX_DRILL_STEPS = 8;
|
|
4
|
-
|
|
4
|
+
/** Maximum number of rows a sealed answer can open, counted from the start of the answer. */
|
|
5
|
+
const MAX_DRILL_ROWS = 1e3;
|
|
6
|
+
export { MAX_DRILL_ROWS, MAX_DRILL_STEPS };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatExact, parseExact } from "../exact/text.mjs";
|
|
2
|
+
import { EXACT_LIMIT, divideExact } from "../exact/decimal.mjs";
|
|
2
3
|
// src/result/number.ts
|
|
3
4
|
const exactNum = (minor, scale) => ({
|
|
4
5
|
exact: true,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { parseTextTime } from "../time/text-time.mjs";
|
|
1
2
|
import { labelStart, nextBucketStart } from "../time/bucket.mjs";
|
|
2
|
-
import { formatTextTime
|
|
3
|
+
import { formatTextTime } from "../time/instant.mjs";
|
|
3
4
|
// src/result/time-axis.ts
|
|
4
5
|
/** A resolved range as instants; none when it is absent or does not read. */
|
|
5
6
|
function spanOf(range) {
|