derive-dashboards 0.1.0 → 0.2.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 +8 -5
- package/dist/adapter/sql-adapter.mjs +4 -4
- package/dist/body.mjs +11 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cli/add.mjs +130 -0
- package/dist/cli/check.mjs +14 -1
- package/dist/cli/cli.mjs +14 -12
- package/dist/cli/config.mjs +12 -1
- package/dist/cli/doctor.mjs +147 -0
- package/dist/cli/import/dbt-schema.mjs +2 -2
- package/dist/cli/import/index.mjs +2 -2
- package/dist/cli/init.mjs +3 -2
- package/dist/cli/json.mjs +21 -0
- package/dist/cli/layers.mjs +33 -0
- package/dist/core/conformance/cases.d.mts +3 -0
- package/dist/core/conformance/cases.mjs +20 -4
- package/dist/core/conformance/check.mjs +6 -3
- package/dist/core/conformance/drill-cases.mjs +120 -0
- package/dist/core/document/layout.mjs +1 -1
- package/dist/core/document/view-layout.d.mts +14 -0
- package/dist/core/document/view-layout.mjs +157 -0
- package/dist/core/document/view.d.mts +26 -7
- package/dist/core/document/view.mjs +42 -11
- package/dist/core/engine/filter.mjs +2 -2
- package/dist/core/engine/index.d.mts +14 -2
- package/dist/core/engine/index.mjs +12 -1
- package/dist/core/engine/leaf.mjs +9 -4
- package/dist/core/engine/members.mjs +2 -2
- package/dist/core/engine/postgres.mjs +1 -1
- package/dist/core/engine/record-layout.d.mts +11 -0
- package/dist/core/engine/record-layout.mjs +7 -7
- package/dist/core/engine/records.d.mts +3 -2
- package/dist/core/engine/records.mjs +2 -1
- package/dist/core/engine/segmented.mjs +5 -2
- package/dist/core/engine/sql-records.mjs +2 -1
- package/dist/core/engine/statement.mjs +37 -3
- package/dist/core/engine/types.d.mts +3 -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 +33 -1
- package/dist/core/error/codes.mjs +30 -2
- package/dist/core/index.d.mts +13 -7
- package/dist/core/index.mjs +9 -5
- package/dist/core/model/catalog/check.mjs +1 -1
- package/dist/core/model/hints.d.mts +36 -0
- package/dist/core/model/member.d.mts +4 -2
- package/dist/core/model/member.mjs +19 -3
- package/dist/core/model/types.d.mts +21 -19
- package/dist/core/model/validate/drill.mjs +70 -0
- package/dist/core/model/validate/index.mjs +3 -0
- package/dist/core/model/validate/members.mjs +7 -4
- package/dist/core/model/validate/shape.mjs +150 -0
- package/dist/core/model/validate/source.mjs +5 -3
- package/dist/core/policy/bind-query.d.mts +12 -0
- package/dist/core/policy/bind-query.mjs +53 -0
- package/dist/core/query/alias.mjs +7 -1
- package/dist/core/query/drill/compose.d.mts +22 -0
- package/dist/core/query/drill/compose.mjs +85 -0
- package/dist/core/query/drill/fields.d.mts +21 -0
- package/dist/core/query/drill/fields.mjs +91 -0
- package/dist/core/query/drill/internal.d.mts +11 -0
- package/dist/core/query/drill/items.d.mts +29 -0
- package/dist/core/query/drill/items.mjs +98 -0
- package/dist/core/query/drill/line.d.mts +31 -0
- package/dist/core/query/drill/line.mjs +183 -0
- package/dist/core/query/drill/links.d.mts +33 -0
- package/dist/core/query/drill/links.mjs +31 -0
- package/dist/core/query/drill/operand.mjs +7 -0
- package/dist/core/query/drill/scopes.d.mts +22 -0
- package/dist/core/query/drill/scopes.mjs +58 -0
- package/dist/core/query/drill/selection.d.mts +37 -0
- package/dist/core/query/drill/selection.mjs +144 -0
- package/dist/core/query/drill/steps.d.mts +14 -0
- package/dist/core/query/drill/steps.mjs +35 -0
- package/dist/core/query/drill/synthetic-expr.mjs +85 -0
- package/dist/core/query/drill/synthetic.d.mts +22 -0
- package/dist/core/query/drill/synthetic.mjs +165 -0
- package/dist/core/query/drill/time.d.mts +11 -0
- package/dist/core/query/drill/time.mjs +71 -0
- package/dist/core/query/drill/types.d.mts +155 -0
- package/dist/core/query/drill/types.mjs +4 -0
- package/dist/core/query/drill/views.d.mts +62 -0
- package/dist/core/query/drill/views.mjs +257 -0
- package/dist/core/query/filter.d.mts +6 -0
- package/dist/core/query/picks.d.mts +8 -2
- package/dist/core/query/picks.mjs +11 -4
- package/dist/core/query/segments.d.mts +12 -2
- package/dist/core/query/segments.mjs +5 -2
- package/dist/core/result/columns.mjs +20 -4
- package/dist/core/result/types.d.mts +5 -1
- package/dist/core/schema/aliases.d.mts +7 -0
- package/dist/core/schema/aliases.mjs +77 -0
- package/dist/core/schema/answer-parts.mjs +117 -0
- package/dist/core/schema/answers.d.mts +2109 -128
- package/dist/core/schema/answers.mjs +11 -113
- package/dist/core/schema/commands.d.mts +2 -2
- package/dist/core/schema/document.d.mts +1 -1
- package/dist/core/schema/drill-answers.mjs +179 -0
- package/dist/core/schema/drill.d.mts +260 -0
- package/dist/core/schema/drill.mjs +107 -0
- package/dist/core/schema/index.d.mts +6 -3
- package/dist/core/schema/index.mjs +6 -3
- package/dist/core/schema/picks.d.mts +35 -0
- package/dist/core/schema/picks.mjs +23 -0
- package/dist/core/schema/query.d.mts +82 -1
- package/dist/core/schema/query.mjs +9 -5
- package/dist/core/schema/tools.mjs +1 -1
- package/dist/core/schema/view.d.mts +0 -35
- package/dist/core/schema/view.mjs +19 -24
- package/dist/core/store/schema.d.mts +5 -0
- package/dist/core/store/schema.mjs +10 -0
- package/dist/core/types/api.d.mts +21 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +210 -0
- package/dist/core/types/options.d.mts +21 -0
- package/dist/core/types/viewer.d.mts +5 -0
- package/dist/cursor-seal.d.mts +8 -0
- package/dist/cursor-seal.mjs +98 -0
- package/dist/dashboard-id.mjs +1 -1
- package/dist/dashboards.mjs +4 -0
- package/dist/drill-access.mjs +93 -0
- package/dist/drill-change.mjs +76 -0
- package/dist/drill-crumbs.mjs +113 -0
- package/dist/drill-distinct.mjs +130 -0
- package/dist/drill-explain.mjs +64 -0
- package/dist/drill-identity.mjs +35 -0
- package/dist/drill-item-id.mjs +35 -0
- package/dist/drill-items.mjs +132 -0
- package/dist/drill-open.mjs +169 -0
- package/dist/drill-seal.mjs +170 -0
- package/dist/drill-secret.mjs +14 -0
- package/dist/drill-share.mjs +53 -0
- package/dist/drill-summary.mjs +158 -0
- package/dist/drill-targets.mjs +53 -0
- package/dist/drill-totals.mjs +8 -0
- package/dist/drill-views.mjs +175 -0
- package/dist/drill.mjs +157 -0
- package/dist/editing.mjs +3 -3
- package/dist/endpoints/dashboards.mjs +28 -5
- package/dist/endpoints/drill.mjs +55 -0
- package/dist/endpoints/index.d.mts +245 -4
- package/dist/endpoints/index.mjs +5 -1
- package/dist/endpoints/meta.mjs +10 -1
- package/dist/endpoints/query.mjs +26 -4
- package/dist/execute.d.mts +19 -1
- package/dist/execute.mjs +34 -27
- package/dist/handler.mjs +5 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +29 -2
- package/dist/llms.txt +22 -0
- package/dist/mcp/drill.mjs +61 -0
- package/dist/mcp/format.mjs +69 -11
- package/dist/mcp/index.d.mts +15 -4
- package/dist/mcp/index.mjs +13 -7
- package/dist/mcp/query.d.mts +7 -2
- package/dist/mcp/query.mjs +40 -6
- package/dist/node-postgres.d.mts +8 -4
- package/dist/node-postgres.mjs +29 -6
- package/dist/owner.mjs +3 -3
- package/dist/postgres-connection.d.mts +8 -2
- package/dist/postgres-connection.mjs +2 -1
- package/dist/postgres-store.mjs +1 -0
- package/dist/react/Canvas.mjs +28 -5
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +10 -5
- package/dist/react/Dashboard.mjs +62 -22
- package/dist/react/DashboardList.mjs +52 -24
- package/dist/react/DashboardListRow.mjs +49 -0
- package/dist/react/Discard.mjs +12 -4
- package/dist/react/Editing.mjs +19 -5
- package/dist/react/FilterBar.d.mts +7 -9
- package/dist/react/Grid.mjs +19 -24
- package/dist/react/Header.mjs +10 -1
- package/dist/react/History.mjs +5 -0
- package/dist/react/Parts.mjs +6 -2
- package/dist/react/ReadFailed.mjs +23 -0
- package/dist/react/ReviewPanel.mjs +13 -2
- package/dist/react/RowBody.d.mts +19 -0
- package/dist/react/RowBody.mjs +55 -0
- package/dist/react/Spaces.mjs +15 -1
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +84 -32
- package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/react/arrange-steps.mjs +16 -13
- package/dist/react/arrange.mjs +10 -3
- package/dist/react/builder/Calcs.mjs +35 -11
- package/dist/react/builder/FilterEditor.mjs +196 -0
- package/dist/react/builder/Filters.mjs +172 -116
- package/dist/react/builder/Formula.mjs +82 -0
- package/dist/react/builder/Groups.mjs +1 -0
- package/dist/react/builder/Preview.mjs +1 -1
- package/dist/react/builder/RangeEditor.mjs +184 -0
- package/dist/react/builder/Sections.mjs +41 -6
- package/dist/react/builder/Time.mjs +138 -60
- package/dist/react/builder/Values.mjs +85 -0
- package/dist/react/builder/WidgetBuilder.mjs +50 -49
- package/dist/react/builder/base.d.mts +5 -0
- package/dist/react/builder/base.mjs +33 -8
- package/dist/react/builder/calc.mjs +15 -1
- package/dist/react/builder/escape.d.mts +1 -0
- package/dist/react/builder/escape.mjs +62 -0
- package/dist/react/builder/filter-tree.d.mts +9 -0
- package/dist/react/builder/filter-tree.mjs +186 -0
- package/dist/react/builder/formula-parse.d.mts +18 -0
- package/dist/react/builder/formula-parse.mjs +136 -0
- package/dist/react/builder/labels.d.mts +1 -1
- package/dist/react/builder/state.d.mts +2 -1
- package/dist/react/builder/state.mjs +23 -37
- package/dist/react/builder/useBuilder.d.mts +12 -1
- package/dist/react/builder/useBuilder.mjs +6 -3
- package/dist/react/builder/words.d.mts +59 -0
- package/dist/react/builder/words.mjs +73 -0
- package/dist/react/client.d.mts +2 -0
- package/dist/react/client.mjs +1 -0
- package/dist/react/context.d.mts +28 -1
- package/dist/react/context.mjs +25 -4
- package/dist/react/drill/Bars.mjs +179 -0
- package/dist/react/drill/Controls.mjs +173 -0
- package/dist/react/drill/DashboardTile.d.mts +18 -0
- package/dist/react/drill/DashboardTile.mjs +107 -0
- package/dist/react/drill/DrillPanel.d.mts +31 -0
- package/dist/react/drill/DrillPanel.mjs +104 -0
- package/dist/react/drill/DrillTabs.mjs +52 -0
- package/dist/react/drill/Header.mjs +131 -0
- package/dist/react/drill/Items.d.mts +22 -0
- package/dist/react/drill/Items.mjs +164 -0
- package/dist/react/drill/ItemsFoot.mjs +60 -0
- package/dist/react/drill/Notes.mjs +58 -0
- package/dist/react/drill/PanelBody.mjs +74 -0
- package/dist/react/drill/PanelStates.mjs +37 -0
- package/dist/react/drill/board.d.mts +18 -0
- package/dist/react/drill/board.mjs +91 -0
- package/dist/react/drill/counts.mjs +14 -0
- package/dist/react/drill/host.mjs +26 -0
- package/dist/react/drill/item-parts.d.mts +5 -0
- package/dist/react/drill/item-parts.mjs +76 -0
- package/dist/react/drill/item-type.d.mts +26 -0
- package/dist/react/drill/item-type.mjs +7 -0
- package/dist/react/drill/lazy.d.mts +6 -0
- package/dist/react/drill/lazy.mjs +17 -0
- package/dist/react/drill/pages.mjs +48 -0
- package/dist/react/drill/panel-focus.mjs +51 -0
- package/dist/react/drill/props.d.mts +25 -0
- package/dist/react/drill/props.mjs +72 -0
- package/dist/react/drill/state.d.mts +18 -0
- package/dist/react/drill/state.mjs +68 -0
- package/dist/react/drill/useDrill.d.mts +46 -0
- package/dist/react/drill/useDrill.mjs +194 -0
- package/dist/react/drill/words.d.mts +101 -0
- package/dist/react/drill/words.mjs +79 -0
- package/dist/react/english.mjs +29 -6
- package/dist/react/filters/bar.d.mts +12 -0
- package/dist/react/filters/bar.mjs +135 -0
- package/dist/react/filters/calendar.mjs +193 -0
- package/dist/react/filters/chip.mjs +174 -0
- package/dist/react/filters/context.d.mts +22 -0
- package/dist/react/filters/context.mjs +78 -0
- package/dist/react/filters/dates.mjs +89 -0
- package/dist/react/filters/days.d.mts +36 -0
- package/dist/react/filters/days.mjs +87 -0
- package/dist/react/filters/field-step.mjs +81 -0
- package/dist/react/filters/hooks.d.mts +34 -0
- package/dist/react/filters/hooks.mjs +94 -0
- package/dist/react/filters/listbox.mjs +131 -0
- package/dist/react/filters/logic.d.mts +59 -0
- package/dist/react/filters/logic.mjs +109 -0
- package/dist/react/filters/menu-search.mjs +211 -0
- package/dist/react/filters/menu.mjs +85 -0
- package/dist/react/filters/number.mjs +127 -0
- package/dist/react/filters/numbers.d.mts +47 -0
- package/dist/react/filters/numbers.mjs +151 -0
- package/dist/react/filters/operator.mjs +104 -0
- package/dist/react/filters/phone.mjs +104 -0
- package/dist/react/filters/popover.d.mts +19 -0
- package/dist/react/filters/popover.mjs +153 -0
- package/dist/react/filters/rules.d.mts +8 -0
- package/dist/react/filters/rules.mjs +55 -0
- package/dist/react/filters/sheet.mjs +196 -0
- package/dist/react/filters/state.mjs +132 -0
- package/dist/react/filters/suggest.d.mts +47 -0
- package/dist/react/filters/suggest.mjs +97 -0
- package/dist/react/filters/values.mjs +166 -0
- package/dist/react/filters/words.d.mts +81 -0
- package/dist/react/filters/words.mjs +73 -0
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +45 -16
- package/dist/react/index.d.mts +34 -5
- package/dist/react/index.mjs +15 -4
- package/dist/react/messages.d.mts +47 -2
- package/dist/react/place.mjs +7 -3
- package/dist/react/renderers/index.d.mts +10 -2
- package/dist/react/renderers/index.mjs +116 -14
- package/dist/react/renderers/list.d.mts +22 -0
- package/dist/react/renderers/list.mjs +118 -0
- package/dist/react/review-words.mjs +1 -1
- package/dist/react/review.mjs +2 -2
- package/dist/react/scope.mjs +2 -7
- package/dist/react/series.d.mts +54 -0
- package/dist/react/series.mjs +191 -0
- package/dist/react/theme.css +2734 -1296
- package/dist/react/theme.css.d.ts +1 -0
- package/dist/react/tile-store.mjs +15 -3
- package/dist/react/useBoard.d.mts +7 -0
- package/dist/react/useBoard.mjs +4 -1
- package/dist/react/useDashboard.d.mts +4 -0
- package/dist/react/useDashboard.mjs +8 -1
- package/dist/react/useTiles.mjs +50 -15
- package/dist/react/view-grid.mjs +16 -0
- package/dist/react/view.d.mts +9 -0
- package/dist/react/view.mjs +22 -10
- package/dist/reading.d.mts +2 -0
- package/dist/reading.mjs +9 -1
- package/dist/recharts/axes.mjs +28 -0
- package/dist/recharts/axis.mjs +84 -0
- package/dist/recharts/bar.d.mts +7 -0
- package/dist/recharts/bar.mjs +140 -0
- package/dist/recharts/charts.d.mts +4 -6
- package/dist/recharts/charts.mjs +2 -114
- package/dist/recharts/index.d.mts +5 -3
- package/dist/recharts/index.mjs +6 -3
- package/dist/recharts/line.d.mts +2 -0
- package/dist/recharts/line.mjs +111 -0
- package/dist/recharts/marks.mjs +112 -0
- package/dist/recharts/parts.mjs +88 -0
- package/dist/recharts/series.d.mts +2 -22
- package/dist/recharts/series.mjs +1 -64
- package/dist/recharts/table.mjs +71 -0
- package/dist/records-read.mjs +44 -0
- package/dist/registry/filter-bar.json +26 -0
- package/dist/skills/derive-dashboards/SKILL.md +69 -0
- package/dist/store/apply.mjs +5 -5
- package/dist/store/commands.mjs +4 -4
- package/dist/store/discard.mjs +7 -7
- package/dist/store/drafts.mjs +5 -5
- package/dist/store/editor.mjs +1 -1
- package/dist/store/publish.mjs +12 -12
- package/dist/store/reader.mjs +41 -22
- package/dist/store/review.mjs +16 -16
- package/dist/store/rows.mjs +20 -20
- package/dist/store/undo.mjs +3 -3
- package/dist/store/unpublished.mjs +4 -4
- package/dist/store/versions.mjs +14 -14
- package/dist/testing/adapter-suite.mjs +4 -4
- package/dist/tiles.mjs +37 -3
- package/package.json +12 -10
- package/dist/react/FilterBar.mjs +0 -119
- package/dist/react/Records.d.mts +0 -12
- package/dist/react/Records.mjs +0 -97
- package/src/adapter/sql-adapter.ts +0 -95
- package/src/adapter/statement.ts +0 -185
- package/src/authorize.ts +0 -73
- package/src/body.ts +0 -169
- package/src/bounded.ts +0 -43
- package/src/cache.ts +0 -192
- package/src/checks.ts +0 -170
- package/src/custom-source.ts +0 -59
- package/src/dashboard-id.ts +0 -36
- package/src/dashboards.ts +0 -132
- package/src/editing.ts +0 -148
- package/src/endpoints/access.ts +0 -41
- package/src/endpoints/dashboards.ts +0 -92
- package/src/endpoints/drafts.ts +0 -138
- package/src/endpoints/index.ts +0 -21
- package/src/endpoints/meta.ts +0 -137
- package/src/endpoints/query.ts +0 -86
- package/src/endpoints/read.ts +0 -92
- package/src/endpoints/review.ts +0 -89
- package/src/endpoints/values.ts +0 -62
- package/src/endpoints/versions.ts +0 -104
- package/src/execute.ts +0 -207
- package/src/handler.ts +0 -232
- package/src/http.ts +0 -66
- package/src/index.ts +0 -163
- package/src/introspect.ts +0 -205
- package/src/mcp/api.ts +0 -59
- package/src/mcp/format.ts +0 -67
- package/src/mcp/index.ts +0 -151
- package/src/mcp/query.ts +0 -153
- package/src/mcp/resolve.ts +0 -114
- package/src/node-postgres.ts +0 -81
- package/src/owner.ts +0 -36
- package/src/postgres-connection.ts +0 -143
- package/src/postgres-store.ts +0 -82
- package/src/principal.ts +0 -39
- package/src/reading.ts +0 -56
- package/src/request-rows.ts +0 -23
- package/src/request.ts +0 -22
- package/src/storage.ts +0 -63
- package/src/store/apply.ts +0 -129
- package/src/store/commands.ts +0 -75
- package/src/store/conflicts.ts +0 -98
- package/src/store/create-tables.ts +0 -104
- package/src/store/discard.ts +0 -42
- package/src/store/drafts.ts +0 -133
- package/src/store/editor.ts +0 -28
- package/src/store/log.ts +0 -28
- package/src/store/publish.ts +0 -199
- package/src/store/publisher.ts +0 -21
- package/src/store/reader.ts +0 -139
- package/src/store/review.ts +0 -239
- package/src/store/rows.ts +0 -250
- package/src/store/tenant.ts +0 -28
- package/src/store/undo.ts +0 -56
- package/src/store/unpublished.ts +0 -33
- package/src/store/versions.ts +0 -106
- package/src/store/writer.ts +0 -19
- package/src/testing/adapter-suite.ts +0 -239
- package/src/testing/index.ts +0 -2
- package/src/tile-doc.ts +0 -46
- package/src/tiles.ts +0 -120
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DRILL_MODEL, DRILL_QUERIES } from "./drill-cases.mjs";
|
|
1
2
|
import { QUERIES } from "./queries.mjs";
|
|
2
3
|
// src/conformance/cases.ts
|
|
3
4
|
const viewer = (id, org, roles) => ({
|
|
@@ -69,9 +70,9 @@ const CALENDARS = {
|
|
|
69
70
|
fiscalYearStartMonth: 4
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
|
-
/**
|
|
73
|
-
function
|
|
74
|
-
return Object.entries(
|
|
73
|
+
/** Each query, by every principal, under each lock that applies, in each calendar given. */
|
|
74
|
+
function casesOf(queries, calendars) {
|
|
75
|
+
return Object.entries(queries).flatMap(([queryName, query]) => Object.entries(PRINCIPALS).flatMap(([who, principal]) => Object.entries(locksFor(query.source)).flatMap(([lockName, locks]) => Object.entries(calendars).map(([zone, calendar]) => ({
|
|
75
76
|
name: `${queryName}, asked by ${who}${lockName}${zone}`,
|
|
76
77
|
query,
|
|
77
78
|
principal,
|
|
@@ -79,4 +80,19 @@ function kitCases() {
|
|
|
79
80
|
calendar
|
|
80
81
|
})))));
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
+
/** Every query, by every principal, under each lock that applies, in each calendar. */
|
|
84
|
+
function kitCases() {
|
|
85
|
+
return casesOf(QUERIES, CALENDARS);
|
|
86
|
+
}
|
|
87
|
+
/** Every read a drill sends, by every principal, under each lock that applies, in UTC. */
|
|
88
|
+
function drillKitCases() {
|
|
89
|
+
return casesOf(DRILL_QUERIES, { "": {
|
|
90
|
+
timezone: "UTC",
|
|
91
|
+
weekStart: 1,
|
|
92
|
+
fiscalYearStartMonth: 1
|
|
93
|
+
} }).map((c) => ({
|
|
94
|
+
...c,
|
|
95
|
+
model: DRILL_MODEL
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
export { drillKitCases, kitCases };
|
|
@@ -2,7 +2,7 @@ import { customReader } from "../engine/custom/reader.mjs";
|
|
|
2
2
|
import { readQuery } from "../engine/segmented.mjs";
|
|
3
3
|
import { evaluate } from "../oracle/segmented.mjs";
|
|
4
4
|
import { canonical } from "../value/canonical.mjs";
|
|
5
|
-
import { kitCases } from "./cases.mjs";
|
|
5
|
+
import { drillKitCases, kitCases } from "./cases.mjs";
|
|
6
6
|
import { DATASET } from "./dataset.mjs";
|
|
7
7
|
import { pagingCase, recordsCase } from "./records-cases.mjs";
|
|
8
8
|
// src/conformance/check.ts
|
|
@@ -24,7 +24,7 @@ async function settled(run) {
|
|
|
24
24
|
}
|
|
25
25
|
const same = (a, b) => canonical(a) === canonical(b);
|
|
26
26
|
const inputOf = (c, now) => ({
|
|
27
|
-
model: DATASET.model,
|
|
27
|
+
model: c.model ?? DATASET.model,
|
|
28
28
|
query: c.query,
|
|
29
29
|
principal: c.principal,
|
|
30
30
|
locks: c.locks,
|
|
@@ -66,11 +66,14 @@ async function checkConformance(host, options = {}) {
|
|
|
66
66
|
},
|
|
67
67
|
source: host.source
|
|
68
68
|
};
|
|
69
|
-
const
|
|
69
|
+
const drills = drillKitCases();
|
|
70
|
+
const cases = [...kitCases(), ...drills];
|
|
70
71
|
const records = host.source.records === void 0 ? [] : cases.filter((c) => c.query.source === "job" && c.name.startsWith("jobs by status"));
|
|
72
|
+
const pages = host.source.records === void 0 ? [] : drills;
|
|
71
73
|
const results = [];
|
|
72
74
|
for (const c of cases) results.push(await answerCase(c, run));
|
|
73
75
|
for (const c of records) results.push(await recordsCase(c, run), await pagingCase(c, run));
|
|
76
|
+
for (const c of pages) results.push(await pagingCase(c, run));
|
|
74
77
|
const mismatches = results.filter((m) => m !== void 0);
|
|
75
78
|
return {
|
|
76
79
|
cases: results.length,
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { drillModel } from "../query/drill/synthetic.mjs";
|
|
2
|
+
import { deriveModel } from "./dataset-model.mjs";
|
|
3
|
+
// src/conformance/drill-cases.ts
|
|
4
|
+
/** The kit's model with one ratio, so a drill of a ratio has a numerator flag to read. */
|
|
5
|
+
function withRatio(model) {
|
|
6
|
+
const job = model.sources.job;
|
|
7
|
+
if (job === void 0) throw new Error("The kit's model has a job source.");
|
|
8
|
+
const measures = {
|
|
9
|
+
...job.measures,
|
|
10
|
+
done: {
|
|
11
|
+
kind: "count",
|
|
12
|
+
where: {
|
|
13
|
+
member: "job.status",
|
|
14
|
+
op: "equals",
|
|
15
|
+
values: ["done"]
|
|
16
|
+
},
|
|
17
|
+
merge: "sum"
|
|
18
|
+
},
|
|
19
|
+
doneShare: {
|
|
20
|
+
kind: "ratio",
|
|
21
|
+
numerator: "done",
|
|
22
|
+
denominator: "count",
|
|
23
|
+
merge: "none"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
...model,
|
|
28
|
+
sources: {
|
|
29
|
+
...model.sources,
|
|
30
|
+
job: {
|
|
31
|
+
...job,
|
|
32
|
+
measures
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The model every drill case reads: the kit's, with a ratio, widened as a drill widens it. */
|
|
38
|
+
const DRILL_MODEL = drillModel(withRatio(deriveModel));
|
|
39
|
+
const q = (source, measures, more = {}) => ({
|
|
40
|
+
kind: "aggregate",
|
|
41
|
+
source,
|
|
42
|
+
measures: measures.map((measure, i) => ({
|
|
43
|
+
id: `m${i + 1}`,
|
|
44
|
+
measure
|
|
45
|
+
})),
|
|
46
|
+
...more
|
|
47
|
+
});
|
|
48
|
+
const by = (member) => ({ dimensions: [{
|
|
49
|
+
id: "d1",
|
|
50
|
+
member
|
|
51
|
+
}] });
|
|
52
|
+
const isTrue = (member) => ({
|
|
53
|
+
member,
|
|
54
|
+
op: "equals",
|
|
55
|
+
values: [true]
|
|
56
|
+
});
|
|
57
|
+
const isSet = (member) => ({
|
|
58
|
+
member,
|
|
59
|
+
op: "set",
|
|
60
|
+
values: []
|
|
61
|
+
});
|
|
62
|
+
const ranked = { order: [{
|
|
63
|
+
by: "m1",
|
|
64
|
+
dir: "desc"
|
|
65
|
+
}, {
|
|
66
|
+
by: "d1",
|
|
67
|
+
dir: "asc"
|
|
68
|
+
}] };
|
|
69
|
+
/** A step on one field: equal to a value, or not set for the empty value. */
|
|
70
|
+
const step = (member, value) => value === null ? {
|
|
71
|
+
member,
|
|
72
|
+
op: "notSet",
|
|
73
|
+
values: []
|
|
74
|
+
} : {
|
|
75
|
+
member,
|
|
76
|
+
op: "equals",
|
|
77
|
+
values: [value]
|
|
78
|
+
};
|
|
79
|
+
/** Other of a limit: the rows in none of the groups it kept. */
|
|
80
|
+
const other = (member, kept) => ({ not: { any: kept.map((v) => ({ all: [step(member, v)] })) } });
|
|
81
|
+
/** The drill reads by name. */
|
|
82
|
+
const DRILL_QUERIES = {
|
|
83
|
+
"drill: a measure's own where is the population": q("comment", ["comment.openThreads", "comment.dd_rows"], {
|
|
84
|
+
...by("comment.artifact.kind"),
|
|
85
|
+
filters: { all: [step("comment.state", "open"), isTrue("comment.dd_set_openThreads")] }
|
|
86
|
+
}),
|
|
87
|
+
"drill: Other of a limit, with a kept empty value, through a join": q("job", ["job.dd_rows", "job.spend"], {
|
|
88
|
+
...by("job.status"),
|
|
89
|
+
filters: other("job.agent.name", [null, "Builder"])
|
|
90
|
+
}),
|
|
91
|
+
"drill: Other of a limit, the empty value in it": q("job", ["job.count"], {
|
|
92
|
+
...by("job.agent.name"),
|
|
93
|
+
filters: other("job.kind", ["ask"])
|
|
94
|
+
}),
|
|
95
|
+
"drill: a ratio's items, flagged by its numerator": q("job", ["job.dd_rows"], { ...by("job.dd_flag_doneShare") }),
|
|
96
|
+
"drill: a distinct count's values, without the empty one, paged": q("view", ["view.dd_rows"], {
|
|
97
|
+
...by("view.dd_distinct_viewers"),
|
|
98
|
+
filters: isSet("view.dd_distinct_viewers"),
|
|
99
|
+
...ranked,
|
|
100
|
+
limit: 2
|
|
101
|
+
}),
|
|
102
|
+
"drill: a distinct count with its own where": q("comment", ["comment.dd_rows"], {
|
|
103
|
+
...by("comment.dd_distinct_openThreads"),
|
|
104
|
+
filters: { all: [step("comment.state", "open"), isSet("comment.dd_distinct_openThreads")] },
|
|
105
|
+
...ranked
|
|
106
|
+
}),
|
|
107
|
+
"drill: a sum's rows with a value, summed exactly, with its least": q("job", [
|
|
108
|
+
"job.spend",
|
|
109
|
+
"job.dd_rows",
|
|
110
|
+
"job.dd_min_spend"
|
|
111
|
+
], { filters: isTrue("job.dd_set_spend") }),
|
|
112
|
+
"drill: each item's value as stored": q("job", ["job.spend"], by("job.dd_value_spend")),
|
|
113
|
+
"drill: rows that tie on their order (versions at one instant)": q("version", ["version.dd_rows"], { filters: step("version.source", "mcp") }),
|
|
114
|
+
"drill: rows that tie on their order (views at one instant)": q("view", ["view.dd_rows"], { filters: {
|
|
115
|
+
member: "view.createdAt",
|
|
116
|
+
op: "set",
|
|
117
|
+
values: []
|
|
118
|
+
} })
|
|
119
|
+
};
|
|
120
|
+
export { DRILL_MODEL, DRILL_QUERIES };
|
|
@@ -225,4 +225,4 @@ function repairLayout(doc) {
|
|
|
225
225
|
}]
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
export { GRID_COLUMNS, closeGaps, closeGapsCommands, compact, freeSpot, layoutGaps, packInto, placeItem, repairLayout };
|
|
228
|
+
export { GRID_COLUMNS, closeGaps, closeGapsCommands, compact, freeSpot, layoutGaps, overlaps, packInto, placeItem, repairLayout };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LayoutItem } from "./types.mjs";
|
|
2
|
+
/** The smallest a tile of this kind can be; a kind the kit does not know gets the number's size. */
|
|
3
|
+
export declare const smallestFor: (kind: string | undefined) => {
|
|
4
|
+
w: number;
|
|
5
|
+
h: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The layout as a viewer sees it, whatever was saved: every tile at least the size its kind
|
|
9
|
+
* reads at, nothing overlapping, no empty rows, no gap in the middle of a row, each row using
|
|
10
|
+
* the grid's whole width (its spare columns shared between its tiles), and a tile beside a
|
|
11
|
+
* taller one as tall as it. The saved layout is never changed; an editor draws it as saved.
|
|
12
|
+
* The order of tiles is kept.
|
|
13
|
+
*/
|
|
14
|
+
export declare function viewLayout(layout: readonly LayoutItem[], kindOf: (widget: string) => string | undefined): LayoutItem[];
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { closeGaps, compact, layoutGaps, overlaps, packInto } from "./layout.mjs";
|
|
2
|
+
// src/document/view-layout.ts
|
|
3
|
+
/** The smallest each kind of tile reads at: a chart needs room for its axes, a table for rows. */
|
|
4
|
+
const SMALLEST = {
|
|
5
|
+
number: {
|
|
6
|
+
w: 2,
|
|
7
|
+
h: 2
|
|
8
|
+
},
|
|
9
|
+
line: {
|
|
10
|
+
w: 4,
|
|
11
|
+
h: 3
|
|
12
|
+
},
|
|
13
|
+
bar: {
|
|
14
|
+
w: 4,
|
|
15
|
+
h: 3
|
|
16
|
+
},
|
|
17
|
+
table: {
|
|
18
|
+
w: 4,
|
|
19
|
+
h: 3
|
|
20
|
+
},
|
|
21
|
+
list: {
|
|
22
|
+
w: 3,
|
|
23
|
+
h: 3
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** The smallest a tile of this kind can be; a kind the kit does not know gets the number's size. */
|
|
27
|
+
const smallestFor = (kind) => (kind === void 0 ? void 0 : SMALLEST[kind]) ?? {
|
|
28
|
+
w: 2,
|
|
29
|
+
h: 2
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The tiles of one row band: items that start on the same row, are the same height and nothing
|
|
33
|
+
* else shares their rows. Their free columns at the right are shared out between them.
|
|
34
|
+
*/
|
|
35
|
+
function rowBands(layout) {
|
|
36
|
+
const byRow = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const item of layout) {
|
|
38
|
+
const key = `${String(item.y)}:${String(item.h)}`;
|
|
39
|
+
byRow.set(key, [...byRow.get(key) ?? [], item]);
|
|
40
|
+
}
|
|
41
|
+
return [...byRow.values()].map((band) => band.toSorted((a, b) => a.x - b.x)).filter((band) => {
|
|
42
|
+
const [first] = band;
|
|
43
|
+
if (first === void 0) return false;
|
|
44
|
+
const ids = new Set(band.map((i) => i.widget));
|
|
45
|
+
const rows = {
|
|
46
|
+
...first,
|
|
47
|
+
x: 0,
|
|
48
|
+
w: 12
|
|
49
|
+
};
|
|
50
|
+
return !layout.some((other) => !ids.has(other.widget) && overlaps(other, rows));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** A band's free columns at the right, shared out between its tiles, the leftmost first. */
|
|
54
|
+
function widened(band) {
|
|
55
|
+
const spare = 12 - band.reduce((sum, item) => sum + item.w, 0);
|
|
56
|
+
if (spare <= 0) return [...band];
|
|
57
|
+
const each = Math.floor(spare / band.length);
|
|
58
|
+
const extra = spare % band.length;
|
|
59
|
+
let x = 0;
|
|
60
|
+
return band.map((item, i) => {
|
|
61
|
+
const w = item.w + each + (i < extra ? 1 : 0);
|
|
62
|
+
const at = {
|
|
63
|
+
...item,
|
|
64
|
+
x,
|
|
65
|
+
w
|
|
66
|
+
};
|
|
67
|
+
x += w;
|
|
68
|
+
return at;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** A tile with free columns at its right that nothing else uses grows into them. */
|
|
72
|
+
function grownRight(layout) {
|
|
73
|
+
let current = [...layout];
|
|
74
|
+
for (const item of layout.toSorted((a, b) => a.y - b.y || b.x - a.x)) {
|
|
75
|
+
const at = current.find((i) => i.widget === item.widget);
|
|
76
|
+
if (at === void 0) continue;
|
|
77
|
+
const others = current.filter((i) => i.widget !== item.widget);
|
|
78
|
+
let w = at.w;
|
|
79
|
+
while (at.x + w < 12 && !others.some((o) => overlaps(o, {
|
|
80
|
+
...at,
|
|
81
|
+
w: w + 1
|
|
82
|
+
}))) w += 1;
|
|
83
|
+
if (w !== at.w) current = current.map((i) => i.widget === at.widget ? {
|
|
84
|
+
...at,
|
|
85
|
+
w
|
|
86
|
+
} : i);
|
|
87
|
+
}
|
|
88
|
+
return current;
|
|
89
|
+
}
|
|
90
|
+
/** A tile beside a taller one that starts on its row grows down to match it, into free space. */
|
|
91
|
+
function grownDown(layout) {
|
|
92
|
+
let current = [...layout];
|
|
93
|
+
for (const item of layout) {
|
|
94
|
+
const at = current.find((i) => i.widget === item.widget);
|
|
95
|
+
if (at === void 0) continue;
|
|
96
|
+
const bottom = Math.max(...current.filter((i) => i.y === at.y).map((i) => i.y + i.h));
|
|
97
|
+
const others = current.filter((i) => i.widget !== item.widget);
|
|
98
|
+
let h = at.h;
|
|
99
|
+
while (at.y + h < bottom && !others.some((o) => overlaps(o, {
|
|
100
|
+
...at,
|
|
101
|
+
h: h + 1
|
|
102
|
+
}))) h += 1;
|
|
103
|
+
if (h !== at.h) current = current.map((i) => i.widget === at.widget ? {
|
|
104
|
+
...at,
|
|
105
|
+
h
|
|
106
|
+
} : i);
|
|
107
|
+
}
|
|
108
|
+
return current;
|
|
109
|
+
}
|
|
110
|
+
/** Each tile, top to bottom, rises into free space above it, so no hole sits over a tile. */
|
|
111
|
+
function risen(layout) {
|
|
112
|
+
let current = [...layout];
|
|
113
|
+
for (const item of layout.toSorted((a, b) => a.y - b.y || a.x - b.x)) {
|
|
114
|
+
const at = current.find((i) => i.widget === item.widget);
|
|
115
|
+
if (at === void 0) continue;
|
|
116
|
+
const others = current.filter((i) => i.widget !== item.widget);
|
|
117
|
+
let y = at.y;
|
|
118
|
+
while (y > 0 && !others.some((o) => overlaps(o, {
|
|
119
|
+
...at,
|
|
120
|
+
y: y - 1
|
|
121
|
+
}))) y -= 1;
|
|
122
|
+
if (y !== at.y) current = current.map((i) => i.widget === at.widget ? {
|
|
123
|
+
...at,
|
|
124
|
+
y
|
|
125
|
+
} : i);
|
|
126
|
+
}
|
|
127
|
+
return current;
|
|
128
|
+
}
|
|
129
|
+
/** Holes closed until none is left: closing one can open room beside a tile it passed. */
|
|
130
|
+
function gapless(layout) {
|
|
131
|
+
let current = risen(layout);
|
|
132
|
+
for (let n = 0; n < 48 && layoutGaps(current).length > 0; n += 1) current = risen(closeGaps(current).layout);
|
|
133
|
+
return compact(current);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The layout as a viewer sees it, whatever was saved: every tile at least the size its kind
|
|
137
|
+
* reads at, nothing overlapping, no empty rows, no gap in the middle of a row, each row using
|
|
138
|
+
* the grid's whole width (its spare columns shared between its tiles), and a tile beside a
|
|
139
|
+
* taller one as tall as it. The saved layout is never changed; an editor draws it as saved.
|
|
140
|
+
* The order of tiles is kept.
|
|
141
|
+
*/
|
|
142
|
+
function viewLayout(layout, kindOf) {
|
|
143
|
+
const sized = layout.map((item) => {
|
|
144
|
+
const least = smallestFor(kindOf(item.widget));
|
|
145
|
+
return {
|
|
146
|
+
...item,
|
|
147
|
+
w: Math.max(item.w, least.w),
|
|
148
|
+
h: Math.max(item.h, least.h)
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
const closed = gapless(packInto([], sized));
|
|
152
|
+
const bands = new Map(rowBands(closed).flatMap((band) => widened(band).map((item) => [item.widget, item])));
|
|
153
|
+
const filled = gapless(grownDown(grownRight(closed.map((item) => bands.get(item.widget) ?? item))));
|
|
154
|
+
const order = new Map(layout.map((item, i) => [item.widget, i]));
|
|
155
|
+
return filled.toSorted((a, b) => (order.get(a.widget) ?? 0) - (order.get(b.widget) ?? 0));
|
|
156
|
+
}
|
|
157
|
+
export { smallestFor, viewLayout };
|
|
@@ -1,29 +1,48 @@
|
|
|
1
|
+
import { DrillState } from "../query/drill/types.mjs";
|
|
1
2
|
import { Control, Picks } from "../query/types.mjs";
|
|
2
3
|
import { TabId } from "./types.mjs";
|
|
3
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* What a link carries: the tab open, the filters set, and the drill open. Never who is looking
|
|
6
|
+
* or what they may see: a drill's path is sealed by the server, and every check runs again for
|
|
7
|
+
* the person who opens it. `drill: undefined` says no drill is open; a view with no `drill` key
|
|
8
|
+
* leaves the drill to the dashboard.
|
|
9
|
+
*/
|
|
4
10
|
export type ViewState = {
|
|
5
11
|
tab?: TabId;
|
|
6
12
|
picks: Picks;
|
|
13
|
+
drill?: DrillState | undefined;
|
|
7
14
|
};
|
|
8
15
|
/** The prefix a view's parameters go under by default, beside the host's own. */
|
|
9
16
|
export declare const VIEW_PREFIX = "dd.";
|
|
17
|
+
/** How a view goes into a URL: under which prefix, and whether its drill goes with it. */
|
|
18
|
+
export type EncodeOptions = {
|
|
19
|
+
prefix?: string;
|
|
20
|
+
drill?: "inline" | "omit";
|
|
21
|
+
};
|
|
10
22
|
/**
|
|
11
23
|
* A view as URL search parameters under a prefix (default `dd.`), so a host puts them in its
|
|
12
|
-
* own URL beside its own parameters. Each pick is JSON, so any value round-trips
|
|
24
|
+
* own URL beside its own parameters. Each pick is JSON, so any value round-trips, and so is
|
|
25
|
+
* the drill (`drill: "omit"` leaves it out, for a link to the dashboard alone);
|
|
13
26
|
* `decodeView` (from `derive-dashboards/core/schema`) reads them back.
|
|
14
27
|
*/
|
|
15
|
-
export declare function encodeView(view: ViewState,
|
|
28
|
+
export declare function encodeView(view: ViewState, options?: string | EncodeOptions): [string, string][];
|
|
29
|
+
/**
|
|
30
|
+
* An address's query with the view in it: the host's own parameters kept as they are, the view's
|
|
31
|
+
* (under `prefix`, `dd.` by default) replaced. `withView(location.search, next).toString()`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function withView(search: string | URLSearchParams, view: ViewState, options?: string | EncodeOptions): URLSearchParams;
|
|
16
34
|
/**
|
|
17
|
-
* A view kept to what a dashboard can show: a tab it does not have,
|
|
18
|
-
*
|
|
19
|
-
* left out and named in `dropped
|
|
20
|
-
* rather than shown an error on every tile.
|
|
35
|
+
* A view kept to what a dashboard can show: a tab it does not have, a pick for a filter it does
|
|
36
|
+
* not have or that does not fit that filter (`pickProblem`, the rule the tiles apply), or a
|
|
37
|
+
* drill into a widget it no longer has, is left out and named in `dropped`, so the viewer is
|
|
38
|
+
* told rather than shown an error on every tile.
|
|
21
39
|
*/
|
|
22
40
|
export declare function viewFor(doc: {
|
|
23
41
|
tabs: readonly {
|
|
24
42
|
id: TabId;
|
|
25
43
|
}[];
|
|
26
44
|
controls: readonly Control[];
|
|
45
|
+
widgets?: Readonly<Record<string, unknown>>;
|
|
27
46
|
}, view: ViewState): {
|
|
28
47
|
view: ViewState;
|
|
29
48
|
dropped: string[];
|
|
@@ -5,15 +5,34 @@ const VIEW_PREFIX = "dd.";
|
|
|
5
5
|
/** The parameter names a view uses, under the prefix. */
|
|
6
6
|
const VIEW_KEYS = {
|
|
7
7
|
tab: "tab",
|
|
8
|
-
filter: "f."
|
|
8
|
+
filter: "f.",
|
|
9
|
+
drill: "drill"
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* A view as URL search parameters under a prefix (default `dd.`), so a host puts them in its
|
|
12
|
-
* own URL beside its own parameters. Each pick is JSON, so any value round-trips
|
|
13
|
+
* own URL beside its own parameters. Each pick is JSON, so any value round-trips, and so is
|
|
14
|
+
* the drill (`drill: "omit"` leaves it out, for a link to the dashboard alone);
|
|
13
15
|
* `decodeView` (from `derive-dashboards/core/schema`) reads them back.
|
|
14
16
|
*/
|
|
15
|
-
function encodeView(view,
|
|
16
|
-
|
|
17
|
+
function encodeView(view, options = {}) {
|
|
18
|
+
const { prefix = "dd.", drill = "inline" } = typeof options === "string" ? { prefix: options } : options;
|
|
19
|
+
const tab = view.tab === void 0 ? [] : [[`${prefix}${VIEW_KEYS.tab}`, view.tab]];
|
|
20
|
+
const pending = view.drill?.path.some((p) => p.includes("#")) === true;
|
|
21
|
+
const drilled = view.drill === void 0 || drill === "omit" || pending ? [] : [[`${prefix}${VIEW_KEYS.drill}`, JSON.stringify(view.drill)]];
|
|
22
|
+
return [
|
|
23
|
+
...tab,
|
|
24
|
+
...drilled,
|
|
25
|
+
...Object.entries(view.picks).map(([id, value]) => [`${prefix}${VIEW_KEYS.filter}${id}`, JSON.stringify(value)])
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* An address's query with the view in it: the host's own parameters kept as they are, the view's
|
|
30
|
+
* (under `prefix`, `dd.` by default) replaced. `withView(location.search, next).toString()`.
|
|
31
|
+
*/
|
|
32
|
+
function withView(search, view, options = {}) {
|
|
33
|
+
const prefix = (typeof options === "string" ? options : options.prefix) ?? "dd.";
|
|
34
|
+
const own = [...new URLSearchParams(search)].filter(([key]) => !key.startsWith(prefix));
|
|
35
|
+
return new URLSearchParams([...own, ...encodeView(view, options)]);
|
|
17
36
|
}
|
|
18
37
|
/** The picks that fit the dashboard's filters, and the names of those that do not. */
|
|
19
38
|
function keptPicks(controls, picks) {
|
|
@@ -29,22 +48,34 @@ function keptPicks(controls, picks) {
|
|
|
29
48
|
dropped
|
|
30
49
|
};
|
|
31
50
|
}
|
|
51
|
+
/** Whether a dashboard can still open a drill: one into a widget it has. */
|
|
52
|
+
function drillFits(doc, drill) {
|
|
53
|
+
if (drill.origin.kind !== "dashboard") return false;
|
|
54
|
+
return doc.widgets === void 0 || Object.hasOwn(doc.widgets, drill.origin.widgetId);
|
|
55
|
+
}
|
|
32
56
|
/**
|
|
33
|
-
* A view kept to what a dashboard can show: a tab it does not have,
|
|
34
|
-
*
|
|
35
|
-
* left out and named in `dropped
|
|
36
|
-
* rather than shown an error on every tile.
|
|
57
|
+
* A view kept to what a dashboard can show: a tab it does not have, a pick for a filter it does
|
|
58
|
+
* not have or that does not fit that filter (`pickProblem`, the rule the tiles apply), or a
|
|
59
|
+
* drill into a widget it no longer has, is left out and named in `dropped`, so the viewer is
|
|
60
|
+
* told rather than shown an error on every tile.
|
|
37
61
|
*/
|
|
38
62
|
function viewFor(doc, view) {
|
|
39
63
|
const tab = doc.tabs.find((t) => t.id === view.tab)?.id;
|
|
40
64
|
const picks = keptPicks(doc.controls, view.picks);
|
|
41
65
|
const lostTab = view.tab === void 0 || tab !== void 0 ? [] : [view.tab];
|
|
66
|
+
const keep = view.drill !== void 0 && drillFits(doc, view.drill);
|
|
67
|
+
const lostDrill = view.drill === void 0 || keep ? [] : [VIEW_KEYS.drill];
|
|
42
68
|
return {
|
|
43
69
|
view: {
|
|
44
70
|
...tab === void 0 ? {} : { tab },
|
|
45
|
-
picks: picks.kept
|
|
71
|
+
picks: picks.kept,
|
|
72
|
+
...keep && view.drill !== void 0 ? { drill: view.drill } : {}
|
|
46
73
|
},
|
|
47
|
-
dropped: [
|
|
74
|
+
dropped: [
|
|
75
|
+
...lostTab,
|
|
76
|
+
...picks.dropped,
|
|
77
|
+
...lostDrill
|
|
78
|
+
]
|
|
48
79
|
};
|
|
49
80
|
}
|
|
50
|
-
export { VIEW_KEYS, VIEW_PREFIX, encodeView, viewFor };
|
|
81
|
+
export { VIEW_KEYS, VIEW_PREFIX, encodeView, viewFor, withView };
|
|
@@ -28,7 +28,7 @@ function filterSql(b, scope, filter) {
|
|
|
28
28
|
if ("not" in filter) return sql`NOT ${filterSql(b, scope, filter.not)}`;
|
|
29
29
|
if ("some" in filter) return childSql(b, scope, filter.some, false);
|
|
30
30
|
if ("none" in filter) return childSql(b, scope, filter.none, true);
|
|
31
|
-
return leafSql(b, memberSql(b, scope, filter.member), filter
|
|
31
|
+
return leafSql(b, memberSql(b, scope, filter.member), filter);
|
|
32
32
|
}
|
|
33
33
|
/** A bound row policy speaks about physical columns. */
|
|
34
34
|
function policySql(b, alias, filter) {
|
|
@@ -40,7 +40,7 @@ function policySql(b, alias, filter) {
|
|
|
40
40
|
type: typeOfValues(filter.values),
|
|
41
41
|
collation: "binary"
|
|
42
42
|
};
|
|
43
|
-
return leafSql(b, operand, filter
|
|
43
|
+
return leafSql(b, operand, filter);
|
|
44
44
|
}
|
|
45
45
|
/** Through a via: the parent row exists and carries the via's terms. */
|
|
46
46
|
function viaSql(b, alias, via) {
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { EngineError, EngineErrorCode } 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
|
+
import { limitedDimensions, rankQuery, segmentCuts } from "../query/segments.mjs";
|
|
3
15
|
import { PlanContext, assertPlan } from "./assert.mjs";
|
|
4
16
|
import { customReader } from "./custom/reader.mjs";
|
|
5
17
|
import { CustomSource, GroupedRead, HostCell, HostRows, ReadBucket, ReadContext, ReadExpr, ReadField, ReadFilter, ReadJoin, ReadMeasure, ReadOperand, ReadOrder, ReadTime, ReadValue, RecordsRead } from "./custom/request.mjs";
|
|
6
|
-
import { RecordPage } from "./record-layout.mjs";
|
|
18
|
+
import { RecordPage, RecordShape } from "./record-layout.mjs";
|
|
7
19
|
import { Dialect, SqlType } from "./dialect.mjs";
|
|
8
20
|
import { AccessPlan, AccessTerm, Guard, SourceRef } from "./plan.mjs";
|
|
9
21
|
import { FOLD_FUNCTION, foldFunctionSql, postgres } from "./postgres.mjs";
|
|
@@ -13,4 +25,4 @@ import "./run.mjs";
|
|
|
13
25
|
import { readQuery, runQuery } from "./segmented.mjs";
|
|
14
26
|
import { sqlReader } from "./sql-reader.mjs";
|
|
15
27
|
import { ENGINE_VERSION } from "./version.mjs";
|
|
16
|
-
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 RecordsRead, type SourceRef, type SqlType, assertPlan, customReader, foldFunctionSql, postgres, readQuery, readRecords, runQuery, sqlReader };
|
|
28
|
+
export { type AccessPlan, type AccessTerm, type Answer, type CustomSource, type Dialect, type Drawn, type DrillClock, type DrillInput, ENGINE_VERSION, EngineError, type EngineErrorCode, type EngineInput, FOLD_FUNCTION, type GroupedRead, type Guard, type HostCell, type HostRows, type ItemsOrder, KEY_FIELD, type LineSemantics, type Picked, type PlanContext, ROW_COUNT, 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 Readable, type Reader, type RecordPage, type RecordShape, type RecordsRead, type Scope, type SourceRef, type SqlType, assertPlan, breakdownQuery, composeDrill, countQuery, customReader, distinctQuery, drillMeasure, drillModel, drillOwner, flagCell, foldFunctionSql, formulaParts, itemsShape, keptPath, limitedDimensions, lineFilter, lineScopes, lineSemantics, measuresOnly, offeredMembers, parentQuery, pathFields, population, postgres, rankQuery, readQuery, readRecords, rowSelection, runQuery, scopeSteps, scopedLines, segmentCuts, sqlReader, stepMembers, storedCell, summaryQuery, trendDimension, trendQuery };
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { EngineError } from "../error/refusal.mjs";
|
|
2
|
+
import { limitedDimensions, rankQuery, segmentCuts } from "../query/segments.mjs";
|
|
3
|
+
import { offeredMembers, trendDimension } from "../query/drill/fields.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";
|
|
2
13
|
import { assertPlan } from "./assert.mjs";
|
|
3
14
|
import { customReader } from "./custom/reader.mjs";
|
|
4
15
|
import { FOLD_FUNCTION, foldFunctionSql, postgres } from "./postgres.mjs";
|
|
@@ -6,4 +17,4 @@ import { readRecords } from "./records.mjs";
|
|
|
6
17
|
import { readQuery, runQuery } from "./segmented.mjs";
|
|
7
18
|
import { sqlReader } from "./sql-reader.mjs";
|
|
8
19
|
import { ENGINE_VERSION } from "./version.mjs";
|
|
9
|
-
export { ENGINE_VERSION, EngineError, FOLD_FUNCTION, assertPlan, customReader, foldFunctionSql, postgres, readQuery, readRecords, runQuery, sqlReader };
|
|
20
|
+
export { ENGINE_VERSION, EngineError, FOLD_FUNCTION, KEY_FIELD, ROW_COUNT, assertPlan, breakdownQuery, composeDrill, countQuery, customReader, distinctQuery, drillMeasure, drillModel, drillOwner, flagCell, foldFunctionSql, formulaParts, itemsShape, keptPath, limitedDimensions, lineFilter, lineScopes, lineSemantics, measuresOnly, offeredMembers, parentQuery, pathFields, population, postgres, rankQuery, readQuery, readRecords, rowSelection, runQuery, scopeSteps, scopedLines, segmentCuts, sqlReader, stepMembers, storedCell, summaryQuery, trendDimension, trendQuery };
|
|
@@ -74,7 +74,7 @@ function eq(c, x, y, value) {
|
|
|
74
74
|
if (c.operand.type !== "string") return beside(c, [...bound(c, value, "over"), ...bound(c, value, "under")], sql`${x} = ${y}`);
|
|
75
75
|
if (!c.side.plain) {
|
|
76
76
|
const part = sql`${c.b.dialect.binary(x)} = ${y}`;
|
|
77
|
-
if (value === void 0) return part;
|
|
77
|
+
if (value === void 0 || c.broad) return part;
|
|
78
78
|
return sql`(${part} AND ${c.b.dialect.fold(c.operand.sql)} = ${param(c.b, value, c.operand)})`;
|
|
79
79
|
}
|
|
80
80
|
const native = c.operand.native;
|
|
@@ -120,16 +120,21 @@ const isNegative = (op) => op in NEGATION_OF;
|
|
|
120
120
|
* or of another type is FALSE before any SQL), so it is never unknown; it stands bare, where
|
|
121
121
|
* an index on the column can answer it.
|
|
122
122
|
*/
|
|
123
|
-
function leafSql(b, operand,
|
|
123
|
+
function leafSql(b, operand, leaf) {
|
|
124
|
+
const { op, values } = leaf;
|
|
124
125
|
if (op === "set") return sql`(${operand.sql} IS NOT NULL)`;
|
|
125
126
|
if (op === "notSet") return sql`(${operand.sql} IS NULL)`;
|
|
126
|
-
if (isNegative(op)) return sql`NOT ${leafSql(b, operand,
|
|
127
|
+
if (isNegative(op)) return sql`NOT ${leafSql(b, operand, {
|
|
128
|
+
...leaf,
|
|
129
|
+
op: NEGATION_OF[op]
|
|
130
|
+
})}`;
|
|
127
131
|
const side = columnSide(b, operand, op, values);
|
|
128
132
|
const test = POSITIVE[op]({
|
|
129
133
|
b,
|
|
130
134
|
operand,
|
|
131
135
|
side,
|
|
132
|
-
values
|
|
136
|
+
values,
|
|
137
|
+
broad: leaf.broad === true
|
|
133
138
|
});
|
|
134
139
|
return sql`(${operand.sql} IS NOT NULL AND ${test})`;
|
|
135
140
|
}
|
|
@@ -57,7 +57,7 @@ function caseSql(ctx, expr) {
|
|
|
57
57
|
sql: left,
|
|
58
58
|
type: typeOfValues(branch.when.values),
|
|
59
59
|
collation: "binary"
|
|
60
|
-
}, branch.when
|
|
60
|
+
}, branch.when);
|
|
61
61
|
return sql`WHEN ${test} THEN ${exprSql(ctx, branch.then)}`;
|
|
62
62
|
});
|
|
63
63
|
const otherwise = expr.else === void 0 ? sql`NULL` : exprSql(ctx, expr.else);
|
|
@@ -67,7 +67,7 @@ function caseSql(ctx, expr) {
|
|
|
67
67
|
function exprSql(ctx, expr) {
|
|
68
68
|
const { b } = ctx;
|
|
69
69
|
if ("col" in expr) return ident(ctx.alias, expr.col);
|
|
70
|
-
if ("lit" in expr) return sql`${expr.lit}`;
|
|
70
|
+
if ("lit" in expr) return typeof expr.lit === "boolean" ? b.dialect.cast(sql`${expr.lit}`, "boolean") : sql`${expr.lit}`;
|
|
71
71
|
if ("op" in expr) {
|
|
72
72
|
const [x, y] = expr.args.map((arg) => b.dialect.cast(exprSql(ctx, arg), "float"));
|
|
73
73
|
return sql`(${x} ${keyword(expr.op)} ${y})`;
|
|
@@ -104,7 +104,7 @@ const postgres = {
|
|
|
104
104
|
const side = (i) => pairs.map((pair) => String.fromCodePoint(pair[i])).join("");
|
|
105
105
|
return sql`translate((${text}) COLLATE "C", ${side(0)}, ${side(1)})`;
|
|
106
106
|
},
|
|
107
|
-
binary: (text) => sql`(${text}) COLLATE "C"`,
|
|
107
|
+
binary: (text) => sql`(CAST(${text} AS text)) COLLATE "C"`,
|
|
108
108
|
recheck,
|
|
109
109
|
equals: (text, value) => sql`(${text} = ${value} AND ${recheck(sql`(${text}) COLLATE "C" = ${value}`)})`,
|
|
110
110
|
textIs: (column, value) => sql`(${column} = ${value} AND ${recheck(sql`(CAST(${column} AS text)) COLLATE "C" = ${value}`)})`,
|