@malloy-publisher/sdk 0.0.248 → 0.0.249
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 +32 -17
- package/dist/ServerProvider-CcfeBpt3.cjs.js +1 -0
- package/dist/{ServerProvider-BxEh3nFI.es.js → ServerProvider-EqBlMMqx.es.js} +1056 -905
- package/dist/client/api.d.ts +297 -6
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +74 -70
- package/dist/components/Dashboard/Dashboard.d.ts +49 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +48 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Notebook/Notebook.d.ts +46 -8
- package/dist/components/Notebook/NotebookCell.d.ts +37 -3
- package/dist/components/Notebook/runPlan.d.ts +29 -0
- package/dist/components/Notebook/types.d.ts +10 -0
- package/dist/components/Package/ContentTypeIcon.d.ts +17 -1
- package/dist/components/Package/Package.d.ts +1 -4
- package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +3 -1
- package/dist/components/ResultsDialog.d.ts +4 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/click_helper.d.ts +10 -1
- package/dist/components/drill/index.d.ts +3 -0
- package/dist/components/drill/markDrillableCells.d.ts +55 -0
- package/dist/components/drill/resolveDrill.d.ts +159 -0
- package/dist/components/drill/useDrill.d.ts +63 -0
- package/dist/components/given/GivenInput.d.ts +27 -3
- package/dist/components/given/GivensPanel.d.ts +36 -7
- package/dist/components/given/filterValue.d.ts +117 -0
- package/dist/components/given/index.d.ts +1 -1
- package/dist/components/given/paramCodec.d.ts +60 -0
- package/dist/components/index.d.ts +4 -1
- package/dist/components/styles.d.ts +23 -0
- package/dist/constants/docLinks.d.ts +6 -0
- package/dist/{core-BuvlzSIX.es.js → core-DFBwNhvb.es.js} +1 -1
- package/dist/{core-C86Rb7tJ.cjs.js → core-DZk7z7ko.cjs.js} +1 -1
- package/dist/hooks/givenValue.d.ts +10 -0
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/useGivensState.d.ts +64 -0
- package/dist/hooks/useSuggestOptions.d.ts +78 -0
- package/dist/{index-BdtAZ5k6.es.js → index-CLcRrkxd.es.js} +41221 -39894
- package/dist/index-CWQXhe0D.cjs.js +338 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +77 -62
- package/dist/theme/types.d.ts +9 -0
- package/package.json +3 -1
- package/src/components/Connections/AddConnectionDialog.tsx +10 -1
- package/src/components/Dashboard/Dashboard.tsx +395 -0
- package/src/components/Dashboard/DashboardTile.tsx +150 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Home/Home.tsx +114 -23
- package/src/components/Notebook/Notebook.tsx +444 -390
- package/src/components/Notebook/NotebookCell.tsx +117 -3
- package/src/components/Notebook/runPlan.spec.ts +152 -0
- package/src/components/Notebook/runPlan.ts +64 -0
- package/src/components/Notebook/types.ts +11 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +88 -0
- package/src/components/Package/ContentTypeIcon.tsx +77 -6
- package/src/components/Package/Package.tsx +148 -38
- package/src/components/RenderedResult/RenderedResult.tsx +309 -19
- package/src/components/RenderedResult/ResultContainer.tsx +28 -1
- package/src/components/ResultsDialog.tsx +5 -0
- package/src/components/ServerProvider.tsx +2 -0
- package/src/components/click_helper.ts +14 -1
- package/src/components/drill/index.ts +25 -0
- package/src/components/drill/markDrillableCells.dom.spec.ts +310 -0
- package/src/components/drill/markDrillableCells.spec.ts +106 -0
- package/src/components/drill/markDrillableCells.ts +311 -0
- package/src/components/drill/resolveDrill.spec.ts +446 -0
- package/src/components/drill/resolveDrill.ts +372 -0
- package/src/components/drill/useDrill.tsx +200 -0
- package/src/components/given/GivenInput.spec.tsx +495 -15
- package/src/components/given/GivenInput.tsx +562 -30
- package/src/components/given/GivensPanel.spec.tsx +172 -0
- package/src/components/given/GivensPanel.tsx +139 -32
- package/src/components/given/filterValue.spec.ts +361 -0
- package/src/components/given/filterValue.ts +204 -0
- package/src/components/given/index.ts +5 -1
- package/src/components/given/paramCodec.spec.ts +854 -0
- package/src/components/given/paramCodec.ts +480 -0
- package/src/components/index.ts +4 -1
- package/src/components/styles.ts +27 -3
- package/src/constants/docLinks.spec.ts +51 -0
- package/src/constants/docLinks.ts +26 -0
- package/src/hooks/givenValue.ts +10 -0
- package/src/hooks/index.ts +6 -4
- package/src/hooks/useGivensState.spec.ts +446 -0
- package/src/hooks/useGivensState.ts +337 -0
- package/src/hooks/useSuggestOptions.spec.ts +109 -0
- package/src/hooks/useSuggestOptions.ts +260 -0
- package/src/theme/buildTableCssVars.ts +4 -0
- package/src/theme/resolveTheme.spec.ts +13 -0
- package/src/theme/resolveTheme.ts +3 -0
- package/src/theme/types.ts +9 -0
- package/test/README.md +16 -10
- package/dist/ServerProvider-Dg5S1qBU.cjs.js +0 -1
- package/dist/hooks/useGivensForm.d.ts +0 -35
- package/dist/index-MES4MGpQ.cjs.js +0 -309
- package/src/hooks/useGivensForm.spec.ts +0 -99
- package/src/hooks/useGivensForm.ts +0 -107
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GivenValue } from '../../hooks/givenValue';
|
|
2
|
+
import { DrillBinding } from '../drill';
|
|
3
|
+
export interface DashboardTileProps {
|
|
4
|
+
environmentName: string;
|
|
5
|
+
packageName: string;
|
|
6
|
+
modelPath: string;
|
|
7
|
+
/** A named query (the single-query form). */
|
|
8
|
+
queryName?: string;
|
|
9
|
+
/** A run expression (a composite tile). */
|
|
10
|
+
tile?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The whole applied control row, NOT this tile's share of it. The narrowing
|
|
13
|
+
* happens here, in `givensToRequest` below, using {@link givenNames}: the
|
|
14
|
+
* caller does not know which givens a tile references and this component
|
|
15
|
+
* does.
|
|
16
|
+
*/
|
|
17
|
+
givens: Map<string, GivenValue>;
|
|
18
|
+
/** Declared type per given name, which decides how a value is encoded. */
|
|
19
|
+
declaredTypes: ReadonlyMap<string, string | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Given names this tile references, or undefined when discovery could not
|
|
22
|
+
* resolve the tile. Undefined means "send the whole control row", which the
|
|
23
|
+
* server accepts: a surfaced given a query does not reference is ignored.
|
|
24
|
+
*/
|
|
25
|
+
givenNames?: string[];
|
|
26
|
+
height: number;
|
|
27
|
+
maxResultSize?: number;
|
|
28
|
+
/** Cell clicks and their affordance, for the dashboard's `# drill`. */
|
|
29
|
+
drill?: DrillBinding;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A composite tile's heading, read off its run expression: the last step's name
|
|
33
|
+
* as a sentence, so `scoped_sales -> sales_by_month` is titled "Sales by month".
|
|
34
|
+
*
|
|
35
|
+
* A tile in the single-query form gets its heading from a `# label` on the nest,
|
|
36
|
+
* and a composite tile has no nest to label: the entry is a string in
|
|
37
|
+
* `tiles=[…]`. Deriving it keeps the two forms reading alike instead of one
|
|
38
|
+
* showing titles and the other showing code.
|
|
39
|
+
*/
|
|
40
|
+
export declare function tileTitle(tile: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* One result panel: run it, render it, and keep its failure to itself.
|
|
43
|
+
*
|
|
44
|
+
* A tile owning its own query is what lets a composite dashboard survive a bad
|
|
45
|
+
* tile: the broken one shows its error in place and the rest of the grid still
|
|
46
|
+
* renders, rather than one failure blanking the page.
|
|
47
|
+
*/
|
|
48
|
+
export declare function DashboardTile({ environmentName, packageName, modelPath, queryName, tile, givens, declaredTypes, givenNames, height, maxResultSize, drill, }: DashboardTileProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { NavigationClick } from '../click_helper';
|
|
2
|
+
import { DrillNavigation } from '../drill';
|
|
3
3
|
interface NotebookProps {
|
|
4
4
|
resourceUri: string;
|
|
5
5
|
maxResultSize?: number;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Parameter values from the host, typically its URL query parameters: the
|
|
8
|
+
* same contract `Dashboard` takes, so a link into a filtered notebook works
|
|
9
|
+
* the way a link into a filtered dashboard does.
|
|
10
|
+
*/
|
|
11
|
+
givens?: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Applied parameter values, for a host that wants them in its URL. Fires
|
|
14
|
+
* with what the cells actually ran with, which is what makes the URL a link
|
|
15
|
+
* that reproduces the view.
|
|
16
|
+
*
|
|
17
|
+
* That is every committed change. Under `## autorun=false` a change is
|
|
18
|
+
* committed on Apply, so reports are batched; otherwise every change is
|
|
19
|
+
* committed and typing in a text control reports per keystroke. It does NOT
|
|
20
|
+
* run per keystroke: a changed value waits
|
|
21
|
+
* `GIVEN_SETTLE_MS` before anything is dispatched, so a burst of typing
|
|
22
|
+
* produces one run. A run that does start supersedes and aborts the one
|
|
23
|
+
* before it. The REPORTS are still per keystroke, so a host doing something
|
|
24
|
+
* expensive per call should debounce.
|
|
25
|
+
*
|
|
26
|
+
* `managed` names every given this notebook declares, set or not. A host
|
|
27
|
+
* writing to a shared query string needs it: `givens` alone says which
|
|
28
|
+
* parameters to write but not which to *remove*, and a host that guesses by
|
|
29
|
+
* removing everything it did not just receive deletes the unrelated
|
|
30
|
+
* parameters it has no business touching.
|
|
31
|
+
*/
|
|
32
|
+
onGivensChange?: (givens: Record<string, string>, managed: readonly string[]) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Optional SPA navigation handler for links inside the notebook. When
|
|
9
35
|
* omitted, in-notebook links fall back to plain absolute anchors, so no
|
|
10
|
-
* react-router context is required to render a notebook.
|
|
11
|
-
|
|
36
|
+
* react-router context is required to render a notebook.
|
|
37
|
+
*
|
|
38
|
+
* It does NOT carry drill. A `# drill { to=self }` filters this notebook
|
|
39
|
+
* through `given:` state and needs no handler at all, and a drill naming a
|
|
40
|
+
* dashboard goes through {@link onDrillNavigate}, which takes a destination
|
|
41
|
+
* rather than a URL.
|
|
42
|
+
*/
|
|
43
|
+
onNavigate?: (to: string, event?: NavigationClick) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Opens a `# drill { to=<dashboard> }` from a cell, seeded with the clicked
|
|
46
|
+
* value. Omitted on a host with no dashboard route, which leaves those
|
|
47
|
+
* destinations inert AND unmarked rather than painting a dead link.
|
|
48
|
+
*/
|
|
49
|
+
onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
12
50
|
}
|
|
13
|
-
export default function Notebook({ resourceUri, maxResultSize,
|
|
51
|
+
export default function Notebook({ resourceUri, maxResultSize, givens, onGivensChange, onNavigate, onDrillNavigate, }: NotebookProps): import("react/jsx-runtime").JSX.Element;
|
|
14
52
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NavigationClick } from '../click_helper';
|
|
2
|
+
import { DrillNavigation } from '../drill';
|
|
2
3
|
import { EnhancedNotebookCell } from './types';
|
|
3
4
|
interface NotebookCellProps {
|
|
4
5
|
cell: EnhancedNotebookCell;
|
|
@@ -10,7 +11,40 @@ interface NotebookCellProps {
|
|
|
10
11
|
index: number;
|
|
11
12
|
maxResultSize?: number;
|
|
12
13
|
isExecuting?: boolean;
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* A re-run is coming but has not started, i.e. the given-settle window.
|
|
16
|
+
* Separate from `isExecuting` because the spinner below is gated on
|
|
17
|
+
* `!cell.result`, so on a re-run (where a result IS present) it renders
|
|
18
|
+
* nothing at all, which is exactly the case the settle window needs to
|
|
19
|
+
* signal: the values on screen are already stale.
|
|
20
|
+
*/
|
|
21
|
+
pendingRerun?: boolean;
|
|
22
|
+
onNavigate?: (to: string, event?: NavigationClick) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Applies a `# drill { to=self }` in place, by setting the named parameter
|
|
25
|
+
* on the notebook that owns this cell. Omitted when the notebook declares no
|
|
26
|
+
* givens, which makes a self-drill inert rather than an error.
|
|
27
|
+
*
|
|
28
|
+
* Takes the clicked value unencoded: only the notebook knows the declared
|
|
29
|
+
* type of the given being set, and the encoding depends on it.
|
|
30
|
+
*/
|
|
31
|
+
onDrillSelf?: (given: string, rawValue: unknown) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the owning notebook declares a given, so a `to=self` drill onto it
|
|
34
|
+
* can be honoured. Without it every self-drill reads as clickable and the
|
|
35
|
+
* refusal only shows up in the console.
|
|
36
|
+
*/
|
|
37
|
+
canDrillSelf?: (given: string) => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Opens a `# drill { to=<dashboard> }` destination, seeded with the clicked
|
|
40
|
+
* value. Distinct from {@link onNavigate}, which routes a markdown link and
|
|
41
|
+
* takes a URL: this one takes a destination and the givens to seed, and only
|
|
42
|
+
* the host knows how to turn those into a route.
|
|
43
|
+
*
|
|
44
|
+
* Omitted on a host with no dashboard route, which makes a cross-dashboard
|
|
45
|
+
* drill inert rather than dead-ended, and removes the affordance with it.
|
|
46
|
+
*/
|
|
47
|
+
onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
14
48
|
}
|
|
15
|
-
export declare function NotebookCell({ cell, hideCodeCellIcon, hideEmbeddingIcon, resourceUri, index, maxResultSize, isExecuting, onNavigate, }: NotebookCellProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare function NotebookCell({ cell, hideCodeCellIcon, hideEmbeddingIcon, resourceUri, index, maxResultSize, isExecuting, pendingRerun, onNavigate, onDrillSelf, canDrillSelf, onDrillNavigate, }: NotebookCellProps): import("react/jsx-runtime").JSX.Element;
|
|
16
50
|
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the notebook's run effect should do about the state it just observed.
|
|
3
|
+
*
|
|
4
|
+
* Pulled out as a pure function because the inline version produced two defects
|
|
5
|
+
* that no test could reach: it first lost the bound on concurrent runs
|
|
6
|
+
* entirely, then, once a settle delay put the bound back, it let an abandoned
|
|
7
|
+
* run fire. Both were reasoning errors about
|
|
8
|
+
* three interacting pieces of state, which is exactly what a table of cases
|
|
9
|
+
* pins and a component test does not.
|
|
10
|
+
*/
|
|
11
|
+
export interface RunPlanInput {
|
|
12
|
+
/** Whether the notebook is loaded and runnable at all. */
|
|
13
|
+
ready: boolean;
|
|
14
|
+
/** Key of the run that has already been dispatched, or null before the first. */
|
|
15
|
+
lastRunKey: string | null;
|
|
16
|
+
/** Key of a run currently waiting out the settle delay, if any. */
|
|
17
|
+
pendingKey: string | undefined;
|
|
18
|
+
/** Key for the state the notebook is in now. */
|
|
19
|
+
runKey: string;
|
|
20
|
+
/** The `resourceUri|generation` prefix of {@link runKey}, without the parameters. */
|
|
21
|
+
documentKey: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RunPlan {
|
|
24
|
+
/** Clear the pending timer, because what it would run is no longer current. */
|
|
25
|
+
cancelPending: boolean;
|
|
26
|
+
/** `now` skips the settle delay; `settle` waits it out; `none` does nothing. */
|
|
27
|
+
dispatch: "now" | "settle" | "none";
|
|
28
|
+
}
|
|
29
|
+
export declare function planRun({ ready, lastRunKey, pendingKey, runKey, documentKey, }: RunPlanInput): RunPlan;
|
|
@@ -18,4 +18,14 @@ export interface EnhancedNotebookCell extends ClientNotebookCell {
|
|
|
18
18
|
* that become available in this cell (e.g., from imports or source definitions)
|
|
19
19
|
*/
|
|
20
20
|
newSources?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Why this cell has no result, when the server refused to run it.
|
|
23
|
+
*
|
|
24
|
+
* A cell that throws used to be logged to the console and nothing else, so
|
|
25
|
+
* the reader got an empty space with no indication anything had happened.
|
|
26
|
+
* That was survivable while the only way to reach it was a server fault; it
|
|
27
|
+
* stopped being survivable once a model with a required `#(filter)` began
|
|
28
|
+
* failing every cell by design.
|
|
29
|
+
*/
|
|
30
|
+
error?: string;
|
|
21
31
|
}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { SvgIconProps } from '@mui/material/SvgIcon';
|
|
2
|
-
type ContentType = "report" | "model" | "data" | "materialization" | "dataApp";
|
|
2
|
+
export type ContentType = "report" | "model" | "data" | "materialization" | "dataApp" | "dashboard";
|
|
3
|
+
/**
|
|
4
|
+
* The backplate color behind each icon. One per content type and no repeats: on
|
|
5
|
+
* a page that lists all six, a shared color reads as a shared kind, and the
|
|
6
|
+
* glyphs are small enough that color does most of the telling apart.
|
|
7
|
+
*
|
|
8
|
+
* The logo's three go to the three artifacts a reader opens to look at data,
|
|
9
|
+
* dashboards and notebooks and the models under them, and the accents to the
|
|
10
|
+
* rest, so the brand leads on the things the page is mostly for. Not a
|
|
11
|
+
* seniority ranking: dashboards are the newest thing a package can hold, and
|
|
12
|
+
* Package Data is among the oldest and takes an accent.
|
|
13
|
+
*
|
|
14
|
+
* Exhaustive by type rather than by a default, so adding a `ContentType` is a
|
|
15
|
+
* compile error here instead of a row that silently paints itself the same as
|
|
16
|
+
* its neighbour.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CONTENT_TINT: Record<ContentType, string>;
|
|
3
19
|
interface ContentTypeIconProps extends Omit<SvgIconProps, "fontSize"> {
|
|
4
20
|
type: ContentType;
|
|
5
21
|
/** Pixel size of the rendered icon. */
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { RetrievalFunction } from '../filter/DimensionFilter';
|
|
3
2
|
interface PackageProps {
|
|
4
3
|
onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
|
|
5
4
|
resourceUri: string;
|
|
6
|
-
/** Optional retrieval function for semantic search filters */
|
|
7
|
-
retrievalFn?: RetrievalFunction;
|
|
8
5
|
}
|
|
9
|
-
export default function Package({ onClickPackageFile, resourceUri,
|
|
6
|
+
export default function Package({ onClickPackageFile, resourceUri, }: PackageProps): import("react/jsx-runtime").JSX.Element;
|
|
10
7
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { DrillBinding } from '../drill/useDrill';
|
|
2
3
|
type MalloyRenderElement = HTMLElement & Record<string, unknown>;
|
|
3
4
|
declare global {
|
|
4
5
|
namespace JSX {
|
|
@@ -12,7 +13,12 @@ interface RenderedResultProps {
|
|
|
12
13
|
height?: number;
|
|
13
14
|
isFillElement?: (boolean: any) => void;
|
|
14
15
|
onSizeChange?: (height: number) => void;
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Makes `# drill` cells clickable, and makes them look it. From `useDrill`
|
|
18
|
+
* on the host surface, which decides where a click may go; omitted where
|
|
19
|
+
* nothing can act on one, and then the result renders inert.
|
|
20
|
+
*/
|
|
21
|
+
drill?: DrillBinding;
|
|
16
22
|
}
|
|
17
23
|
export default function RenderedResult(props: RenderedResultProps): import("react/jsx-runtime").JSX.Element;
|
|
18
24
|
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { LogMessage } from '../../client';
|
|
2
|
+
import { DrillBinding } from '../drill/useDrill';
|
|
2
3
|
interface ResultContainerProps {
|
|
3
4
|
result: string | undefined;
|
|
4
5
|
maxHeight: number;
|
|
5
6
|
maxResultSize?: number;
|
|
6
7
|
renderLogs?: LogMessage[];
|
|
8
|
+
drill?: DrillBinding;
|
|
7
9
|
}
|
|
8
|
-
export default function ResultContainer({ result, maxHeight, maxResultSize, renderLogs, }: ResultContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function ResultContainer({ result, maxHeight, maxResultSize, renderLogs, drill, }: ResultContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { LogMessage } from '../client';
|
|
2
|
+
import { DrillBinding } from './drill';
|
|
2
3
|
interface ResultsDialogProps {
|
|
3
4
|
open: boolean;
|
|
4
5
|
onClose: () => void;
|
|
5
6
|
result: string;
|
|
6
7
|
title?: string;
|
|
7
8
|
renderLogs?: LogMessage[];
|
|
9
|
+
/** `# drill` wiring, so a result stays clickable when it is expanded. */
|
|
10
|
+
drill?: DrillBinding;
|
|
8
11
|
}
|
|
9
|
-
export default function ResultsDialog({ open, onClose, result, title, renderLogs, }: ResultsDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default function ResultsDialog({ open, onClose, result, title, renderLogs, drill, }: ResultsDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
10
13
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
|
2
|
-
import { ConnectionsApi, DataAppsApi, DatabasesApi, EnvironmentsApi, MaterializationsApi, ModelsApi, NotebooksApi, PackagesApi, PublisherApi, WatchModeApi } from '../client';
|
|
2
|
+
import { ConnectionsApi, DashboardsApi, DataAppsApi, DatabasesApi, EnvironmentsApi, MaterializationsApi, ModelsApi, NotebooksApi, PackagesApi, PublisherApi, WatchModeApi } from '../client';
|
|
3
3
|
import { Theme } from '../theme/types';
|
|
4
4
|
export interface ServerContextValue {
|
|
5
5
|
server: string;
|
|
@@ -47,6 +47,7 @@ declare const getApiClients: (baseURL?: string, accessToken?: () => Promise<stri
|
|
|
47
47
|
publisher: PublisherApi;
|
|
48
48
|
environments: EnvironmentsApi;
|
|
49
49
|
packages: PackagesApi;
|
|
50
|
+
dashboards: DashboardsApi;
|
|
50
51
|
dataApps: DataAppsApi;
|
|
51
52
|
notebooks: NotebooksApi;
|
|
52
53
|
connections: ConnectionsApi;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The modifier state a navigation decision reads, and nothing more.
|
|
4
|
+
*
|
|
5
|
+
* Both React's synthetic mouse event and the DOM's satisfy it, which is the
|
|
6
|
+
* point. A click can reach navigation from a React handler, or from outside
|
|
7
|
+
* React entirely (a `# drill` click arrives from the Malloy renderer as a plain
|
|
8
|
+
* DOM event), and neither should have to be converted to the other first.
|
|
9
|
+
*/
|
|
10
|
+
export type NavigationClick = Pick<MouseEvent, "metaKey" | "ctrlKey" | "shiftKey" | "button">;
|
|
2
11
|
/**
|
|
3
12
|
* Custom hook that returns a function for handling clicks with proper modifier key support.
|
|
4
13
|
* The returned function handles CMD/Ctrl clicks to open in new tabs, regular clicks for navigation.
|
|
5
14
|
*
|
|
6
15
|
* @returns A function that takes a relative URL and either navigates or opens in new tab
|
|
7
16
|
*/
|
|
8
|
-
export declare function useRouterClickHandler(): (to: string, event?:
|
|
17
|
+
export declare function useRouterClickHandler(): (to: string, event?: NavigationClick) => void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DRILL_CELL_CLASS, drillableFieldNames, markDrillableCells, type DrillMetadataSource, } from './markDrillableCells';
|
|
2
|
+
export { DRILL_SELF, drillDestinations, drillValueToFilter, encodeDrillValue, humanizeSlug, resolveDrill, type DrillClickPayload, type DrillField, type DrillIntent, type DrillNavigation, type DrillTagReader, } from './resolveDrill';
|
|
3
|
+
export { useDrill, type DrillBinding, type UseDrillOptions, type UseDrillResult, } from './useDrill';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DrillField } from './resolveDrill';
|
|
2
|
+
/**
|
|
3
|
+
* Marks a leaf value cell whose column declares an honorable `# drill`.
|
|
4
|
+
* Malloyyo's counterpart is `dash-drill`; the name is local to each app's
|
|
5
|
+
* stylesheet, and only the tag grammar is a compatibility surface.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DRILL_CELL_CLASS = "publisher-drill";
|
|
8
|
+
/** As much of the renderer's viz handle as the affordance reads. */
|
|
9
|
+
export interface DrillMetadataSource {
|
|
10
|
+
getMetadata: () => {
|
|
11
|
+
getAllFields: () => DrillField[];
|
|
12
|
+
} | null | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The column names to mark: every field whose `# drill` this surface can honor.
|
|
16
|
+
*
|
|
17
|
+
* Both the field's own name and its `# label` go in, because the header cell
|
|
18
|
+
* this is matched against renders `getLabel()`: the label when the author set
|
|
19
|
+
* one, the name otherwise, and the caller cannot tell which from the DOM.
|
|
20
|
+
*
|
|
21
|
+
* `canDrill` is the host's capability filter (see `useDrill`), so a destination
|
|
22
|
+
* the surface cannot reach never becomes a link: a dead link is worse than none.
|
|
23
|
+
*/
|
|
24
|
+
export declare function drillableFieldNames(viz: DrillMetadataSource, canDrill: (field: DrillField) => boolean): Set<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Add {@link DRILL_CELL_CLASS} to the cells `names` makes clickable.
|
|
27
|
+
*
|
|
28
|
+
* Per table rather than per container: a nested table has its own grid and its
|
|
29
|
+
* own column numbering, so matching across them would mark whichever column of
|
|
30
|
+
* the child happened to share a number with the parent's.
|
|
31
|
+
*
|
|
32
|
+
* Idempotent, and safe to call repeatedly: a `# dashboard` result builds its
|
|
33
|
+
* cards over several frames, so the caller re-runs this as the DOM settles.
|
|
34
|
+
*/
|
|
35
|
+
export declare function markDrillableCells(container: HTMLElement, names: Set<string>): void;
|
|
36
|
+
/**
|
|
37
|
+
* The drillable cells sharing `cell`'s column, in row order, or an empty array
|
|
38
|
+
* when `cell` is not a marked cell.
|
|
39
|
+
*
|
|
40
|
+
* Lives here rather than in the keyboard handler that calls it because the
|
|
41
|
+
* column identity is this module's rule: a cell's column is its inline
|
|
42
|
+
* `grid-column` start, scoped to its own `.malloy-table` so a nested table's
|
|
43
|
+
* numbering never matches the parent's. Two sites deciding that separately is
|
|
44
|
+
* how they come to disagree, so the handler asks this one.
|
|
45
|
+
*/
|
|
46
|
+
export declare function drillColumnSiblings(cell: HTMLElement): HTMLElement[];
|
|
47
|
+
/**
|
|
48
|
+
* Move a drillable column's single tab stop `to` rows from `from`, or to the
|
|
49
|
+
* first or last cell, and return the cell that should now take focus.
|
|
50
|
+
*
|
|
51
|
+
* Lives beside {@link drillColumnSiblings} because it enforces the same
|
|
52
|
+
* invariant the marking does: exactly one cell per column carries
|
|
53
|
+
* `tabindex="0"`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function moveDrillStop(from: HTMLElement, to: number | "first" | "last"): HTMLElement | undefined;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolving a renderer click into a `# drill` intent.
|
|
3
|
+
*
|
|
4
|
+
* `# drill { to=[…] given=… }` is written on a source *dimension*, and Malloy
|
|
5
|
+
* carries a dimension's annotations through to the query result's output field.
|
|
6
|
+
* So everything a click needs is already on the clicked field, and drill needs
|
|
7
|
+
* no endpoint of its own: the same resolution works for a dashboard tile and a
|
|
8
|
+
* notebook cell, which is the "one drill implementation" the design asks for.
|
|
9
|
+
*
|
|
10
|
+
* That propagation is the premise the whole design rests on, and NOTHING IN THIS
|
|
11
|
+
* PR pins it: the specs here drive a hand-built tag stub, deliberately, because
|
|
12
|
+
* what they test is the grammar. It is pinned against the real compiler by
|
|
13
|
+
* `packages/server/src/service/drill_probe.spec.ts`, which arrives with the
|
|
14
|
+
* dashboard slice of this split rather than here. If a Malloy upgrade stopped
|
|
15
|
+
* propagating dimension annotations, drill would go quiet everywhere at once and
|
|
16
|
+
* this slice's tests would all still pass.
|
|
17
|
+
*
|
|
18
|
+
* This module answers only *what* was asked for, which dashboards, seeding
|
|
19
|
+
* which given to which value. Navigating is the host's job.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The parsed-tag surface this module reads, structurally typed.
|
|
23
|
+
*
|
|
24
|
+
* The renderer hands over an already-parsed `Tag` from `@malloydata/malloy-tag`,
|
|
25
|
+
* so naming the shape rather than importing the class keeps that package a
|
|
26
|
+
* render-time detail: SDK consumers can bundle without it, the same allowance
|
|
27
|
+
* `RenderedResult` makes for its theme annotations.
|
|
28
|
+
*/
|
|
29
|
+
export interface DrillTagReader {
|
|
30
|
+
tag(...at: string[]): DrillTagReader | undefined;
|
|
31
|
+
text(...at: string[]): string | undefined;
|
|
32
|
+
textArray(...at: string[]): string[] | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** The clicked field, as much of it as drill reads. */
|
|
35
|
+
export interface DrillField {
|
|
36
|
+
name: string;
|
|
37
|
+
tag?: DrillTagReader;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the field was grouped rather than aggregated. Only dimensions
|
|
40
|
+
* drill: a measure's cell has no dimension value to seed a filter with even
|
|
41
|
+
* when the tag reaches it, so filtering by one would filter by something
|
|
42
|
+
* other than what was clicked. Optional because the renderer's click payload
|
|
43
|
+
* and its field metadata are the two callers and only one is guaranteed to
|
|
44
|
+
* carry the method; absent, the field is taken at its word.
|
|
45
|
+
*/
|
|
46
|
+
wasDimension?: () => boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A click from `@malloydata/render`'s `onClick`, narrowed to what drill needs.
|
|
50
|
+
* Mirrors its `MalloyClickEventPayload` without importing it, since the renderer
|
|
51
|
+
* is a lazily-imported dependency here.
|
|
52
|
+
*/
|
|
53
|
+
export interface DrillClickPayload {
|
|
54
|
+
field?: DrillField;
|
|
55
|
+
value?: unknown;
|
|
56
|
+
isHeader?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The originating click, which the host needs for two things a resolved
|
|
59
|
+
* intent cannot express, where to anchor a menu of destinations, and whether
|
|
60
|
+
* a modifier was held (cmd/ctrl to open in a new tab).
|
|
61
|
+
*/
|
|
62
|
+
event?: MouseEvent;
|
|
63
|
+
}
|
|
64
|
+
/** The literal `to=self`: filter the current view instead of leaving it. */
|
|
65
|
+
export declare const DRILL_SELF = "self";
|
|
66
|
+
/**
|
|
67
|
+
* The `to=` destinations a field's `# drill` declares, empty when it declares
|
|
68
|
+
* none or the field cannot drill.
|
|
69
|
+
*
|
|
70
|
+
* Read separately from {@link resolveDrill} because two callers need it: the
|
|
71
|
+
* click, which also needs the clicked value, and the *affordance*, which runs
|
|
72
|
+
* over the result's field metadata before any click to decide which columns read
|
|
73
|
+
* as clickable. Sharing this is what keeps the two honest: a cell that looks
|
|
74
|
+
* clickable is one whose click resolves, because both answers come from here.
|
|
75
|
+
*/
|
|
76
|
+
export declare function drillDestinations(field: DrillField | undefined): string[];
|
|
77
|
+
/**
|
|
78
|
+
* A destination slug as a menu label: `category_detail` → `Category detail`.
|
|
79
|
+
*
|
|
80
|
+
* Ported from Malloyyo so the same drill reads the same way in both, rather than
|
|
81
|
+
* naming the file on one and a sentence on the other.
|
|
82
|
+
*/
|
|
83
|
+
export declare function humanizeSlug(slug: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* The given a `# drill` on this field would set: `given=` when the tag names
|
|
86
|
+
* one, otherwise the dimension name exactly as the model spells it.
|
|
87
|
+
*
|
|
88
|
+
* Shared with the affordance for the same reason `drillDestinations` is: a cell
|
|
89
|
+
* reads as clickable exactly when clicking it would do something, and deciding
|
|
90
|
+
* "would it" needs the given's name before any click happens.
|
|
91
|
+
*/
|
|
92
|
+
export declare function drillGivenName(field: DrillField): string;
|
|
93
|
+
/** Where a `# drill` click wants to go, for the host to route however it routes. */
|
|
94
|
+
export interface DrillNavigation {
|
|
95
|
+
/** The destination dashboard's slug. */
|
|
96
|
+
dashboard: string;
|
|
97
|
+
/**
|
|
98
|
+
* Control values to open it with: the clicked value seeded into the drill's
|
|
99
|
+
* given. Only the seeded given: the source view's other filters are not
|
|
100
|
+
* carried over, since the destination need not bind them.
|
|
101
|
+
*/
|
|
102
|
+
givens: Record<string, string>;
|
|
103
|
+
}
|
|
104
|
+
/** What a click asked for, once the tag on the clicked field is read. */
|
|
105
|
+
export interface DrillIntent {
|
|
106
|
+
/** Destinations in declared order: dashboard slugs and/or {@link DRILL_SELF}. */
|
|
107
|
+
to: string[];
|
|
108
|
+
/** The given to seed: the dimension name as spelled, unless `given=` says otherwise. */
|
|
109
|
+
given: string;
|
|
110
|
+
/**
|
|
111
|
+
* The clicked value as Malloy filter syntax, ready to send to a `filter<…>`
|
|
112
|
+
* given. This is the right encoding for a cross-dashboard drill, whose
|
|
113
|
+
* destination declares its own givens and is conventionally `filter<…>`.
|
|
114
|
+
*/
|
|
115
|
+
value: string;
|
|
116
|
+
/**
|
|
117
|
+
* The same value before any encoding.
|
|
118
|
+
*
|
|
119
|
+
* Carried because the filter encoding above is only correct for a
|
|
120
|
+
* `filter<…>` target, and a click cannot know what it is aiming at: the
|
|
121
|
+
* destination may be another dashboard entirely. A host that *does* know,
|
|
122
|
+
* `to=self`, where the target given is one of its own: re-encodes from this
|
|
123
|
+
* with {@link encodeDrillValue}. Without it, drilling into a plain `string`
|
|
124
|
+
* given seeded it with backslash-escaped filter syntax and matched nothing.
|
|
125
|
+
*/
|
|
126
|
+
rawValue: unknown;
|
|
127
|
+
/** The clicked value as it read on screen, for labelling the destination menu. */
|
|
128
|
+
label: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The clicked cell's value as filter syntax, or undefined when it cannot be
|
|
132
|
+
* expressed as one.
|
|
133
|
+
*
|
|
134
|
+
* Encoded from the value's own type rather than the given's, which a click does
|
|
135
|
+
* not know (a notebook cell has no control row to consult). Refusing the cases
|
|
136
|
+
* it cannot encode is deliberate: a drill that filtered by something other than
|
|
137
|
+
* the cell the user clicked would be worse than one that does nothing.
|
|
138
|
+
*/
|
|
139
|
+
export declare function drillValueToFilter(value: unknown): string | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Read the `# drill` intent off a renderer click, or undefined when the click
|
|
142
|
+
* was not on a drillable value.
|
|
143
|
+
*
|
|
144
|
+
* Silent on anything untagged, which is most clicks: this runs on every click
|
|
145
|
+
* the renderer reports, so "not a drill" is the ordinary answer, not a fault.
|
|
146
|
+
*/
|
|
147
|
+
export declare function resolveDrill(payload: DrillClickPayload | undefined): DrillIntent | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* A clicked value encoded for a given whose declared type is known.
|
|
150
|
+
*
|
|
151
|
+
* `filter<…>` takes filter syntax, so the value is escaped into a one-value
|
|
152
|
+
* filter list. Every other type takes the value itself: a plain `string` given
|
|
153
|
+
* seeded with `Ben\ &\ Jerry` would match nothing, because the escaping is
|
|
154
|
+
* meaningful only to the filter parser.
|
|
155
|
+
*
|
|
156
|
+
* Undefined when the value has no spelling for that type, which the caller
|
|
157
|
+
* should treat the way it treats an unresolvable drill: do nothing.
|
|
158
|
+
*/
|
|
159
|
+
export declare function encodeDrillValue(rawValue: unknown, targetType: string | undefined): string | number | boolean | Date | undefined;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DrillField, DrillClickPayload, DrillNavigation } from './resolveDrill';
|
|
3
|
+
export interface UseDrillOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Open another dashboard, seeded with the clicked value. Omitted on a surface
|
|
6
|
+
* that cannot navigate, which makes those destinations inert rather than
|
|
7
|
+
* dead-ended.
|
|
8
|
+
*/
|
|
9
|
+
onNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Apply the clicked value to this surface's own control row (`to=self`).
|
|
12
|
+
* Omitted on a surface that has none, such as a notebook cell.
|
|
13
|
+
*/
|
|
14
|
+
onSelf?: (given: string, rawValue: unknown) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a `to=self` drill onto this given can actually be honoured: for a
|
|
17
|
+
* notebook, whether it declares that given at all.
|
|
18
|
+
*
|
|
19
|
+
* Without it the affordance says yes to every self-drill and the click is
|
|
20
|
+
* refused afterwards with a console warning, which is the dead link this
|
|
21
|
+
* module exists to avoid. Absent means "any self-drill is fine", the right
|
|
22
|
+
* default for a surface that binds whatever it is handed.
|
|
23
|
+
*/
|
|
24
|
+
canSelf?: (given: string) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* What `to=self` is called in the menu. A notebook filtering itself is not
|
|
27
|
+
* "this dashboard", and the drill tag: written on a shared model dimension,
|
|
28
|
+
* cannot know which document the reader is in, so the surface names itself.
|
|
29
|
+
*/
|
|
30
|
+
selfLabel?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* What a surface hands to its result renderer to become drillable: the click
|
|
34
|
+
* handler, and the predicate that decides which cells say so.
|
|
35
|
+
*
|
|
36
|
+
* One object because the two must agree. Passing only the handler is what
|
|
37
|
+
* produced the original asymmetry: clicks worked, but nothing looked clickable.
|
|
38
|
+
*/
|
|
39
|
+
export interface DrillBinding {
|
|
40
|
+
/**
|
|
41
|
+
* Every cell click. Most carry no `# drill` and mean nothing, so this
|
|
42
|
+
* tolerates being called constantly.
|
|
43
|
+
*/
|
|
44
|
+
onClick: (payload: DrillClickPayload) => void;
|
|
45
|
+
/** Whether this field's cells should read as clickable. */
|
|
46
|
+
canDrill: (field: DrillField) => boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface UseDrillResult {
|
|
49
|
+
/** Hand to `ResultContainer`'s (or `RenderedResult`'s) `drill` prop. */
|
|
50
|
+
drill: DrillBinding;
|
|
51
|
+
/** Render anywhere in the subtree: the menu a multi-destination drill opens. */
|
|
52
|
+
drillMenu: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Click-to-drill for any surface that renders a Malloy result.
|
|
56
|
+
*
|
|
57
|
+
* Shared between the dashboard viewer and notebook cells on purpose: `# drill`
|
|
58
|
+
* is declared on a model *dimension*, so it fires wherever that dimension is
|
|
59
|
+
* grouped, and a notebook can therefore drill into a dashboard with no notebook-
|
|
60
|
+
* specific code. What differs between surfaces is only what they can do about it,
|
|
61
|
+
* which is what the two callbacks express.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useDrill({ onNavigate, onSelf, selfLabel, canSelf, }: UseDrillOptions): UseDrillResult;
|