@malloy-publisher/sdk 0.10.2 → 0.10.4

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.
Files changed (47) hide show
  1. package/dist/{RenderedResult-BCJC0ZVj.es.js → RenderedResult-B_sW7neX.es.js} +328 -265
  2. package/dist/RenderedResult-BlYdT4lz.cjs.js +179 -0
  3. package/dist/builder/index.cjs.js +1 -1
  4. package/dist/builder/index.es.js +2 -2
  5. package/dist/client/api.d.ts +5 -5
  6. package/dist/components/Dashboard/DashboardView.d.ts +10 -3
  7. package/dist/components/Dashboard/DownloadRowsCsv.d.ts +10 -0
  8. package/dist/components/Dashboard/RowsDialog.d.ts +63 -21
  9. package/dist/components/Dashboard/index.d.ts +2 -0
  10. package/dist/components/Dashboard/rowsCsv.d.ts +26 -0
  11. package/dist/components/RenderedResult/ResultContainer.d.ts +2 -3
  12. package/dist/components/RenderedResult/resultSizing.d.ts +2 -0
  13. package/dist/components/Report/Report.d.ts +8 -1
  14. package/dist/components/drill/drillClauses.d.ts +34 -0
  15. package/dist/components/drill/drillClickRelay.d.ts +36 -0
  16. package/dist/components/drill/resolveDrill.d.ts +29 -0
  17. package/dist/components/drill/rowsTarget.d.ts +114 -0
  18. package/dist/components/drill/useDrill.d.ts +24 -12
  19. package/dist/index.cjs.js +13 -11
  20. package/dist/index.es.js +7331 -6886
  21. package/dist/{useCompiledDocument-C995sQ3j.cjs.js → useCompiledDocument-CyPOSStA.cjs.js} +31 -31
  22. package/dist/{useCompiledDocument-Citpvpnx.es.js → useCompiledDocument-xJRD5DRP.es.js} +1587 -1574
  23. package/dist/utils/malloyString.d.ts +2 -1
  24. package/package.json +1 -1
  25. package/src/components/Dashboard/DashboardView.tsx +54 -28
  26. package/src/components/Dashboard/DownloadRowsCsv.tsx +152 -0
  27. package/src/components/Dashboard/RowsDialog.actions.spec.tsx +250 -0
  28. package/src/components/Dashboard/RowsDialog.drill.compile.spec.ts +672 -0
  29. package/src/components/Dashboard/RowsDialog.spec.ts +38 -11
  30. package/src/components/Dashboard/RowsDialog.tsx +194 -40
  31. package/src/components/Dashboard/index.ts +2 -0
  32. package/src/components/Dashboard/rowsCsv.spec.ts +105 -0
  33. package/src/components/Dashboard/rowsCsv.ts +107 -0
  34. package/src/components/RenderedResult/RenderedResult.tsx +44 -7
  35. package/src/components/RenderedResult/ResultContainer.tsx +2 -2
  36. package/src/components/RenderedResult/resultSizing.ts +3 -0
  37. package/src/components/Report/Report.tsx +9 -0
  38. package/src/components/drill/drillClauses.ts +201 -0
  39. package/src/components/drill/drillClickRelay.spec.ts +122 -0
  40. package/src/components/drill/drillClickRelay.ts +106 -0
  41. package/src/components/drill/resolveDrill.ts +29 -0
  42. package/src/components/drill/rowsTarget.ts +245 -0
  43. package/src/components/drill/useDrill.spec.tsx +311 -15
  44. package/src/components/drill/useDrill.tsx +206 -67
  45. package/src/components/legacy/malloynb/NotebookCell.tsx +0 -7
  46. package/src/utils/malloyString.ts +21 -2
  47. package/dist/RenderedResult-B5f4qOjp.cjs.js +0 -171
@@ -4,6 +4,7 @@ import { HostGivenValue } from '../../hooks/givenValue';
4
4
  import { DrillNavigation } from '../drill';
5
5
  import { GivensLayout } from '../given';
6
6
  import { NavigationClick } from '../click_helper';
7
+ import { RowsActions } from './RowsDialog';
7
8
  import { TileChrome } from './TileCard';
8
9
  /** Re-exported for hosts that import it from here; defined with the page parts. */
9
10
  export { STICKY_CONTROLS_Z, STICKY_TOP_VAR } from '../Report/ReportPage';
@@ -39,8 +40,8 @@ export interface DashboardViewProps {
39
40
  controlsLayout?: GivensLayout;
40
41
  /**
41
42
  * Text-source mode: the document's definitions (see `documentPreamble`),
42
- * sent ahead of each tile's `run:` so every query runs as the viewer's own
43
- * text. Rows, which reopens a tile by name, is off in this mode.
43
+ * sent ahead of each tile's `run:`, and of a rows query, so every query
44
+ * runs as the viewer's own text.
44
45
  */
45
46
  preamble?: string;
46
47
  /** Text-source mode: the model the text runs on top of, in place of `manifest.path`. */
@@ -65,6 +66,12 @@ export interface DashboardViewProps {
65
66
  * end of the title's line, where the builder's toolbar sits.
66
67
  */
67
68
  actions?: ReactNode;
69
+ /**
70
+ * The host's actions for the rows behind a clicked value (a download),
71
+ * drawn in the rows dialog's title row. Omitted, the dialog offers its own
72
+ * Download CSV; return `null` for none.
73
+ */
74
+ rowsActions?: RowsActions;
68
75
  }
69
76
  /**
70
77
  * A loaded dashboard manifest, drawn: the control row and the tile grid.
@@ -72,4 +79,4 @@ export interface DashboardViewProps {
72
79
  * Split from the manifest fetch so a notebook written as a tile layout, whose
73
80
  * manifest arrives inside the notebook response, renders through the same code.
74
81
  */
75
- export declare function DashboardView({ manifest, environmentName, packageName, versionId, documentName, givens, onGivensChange, onNavigate, height, maxResultSize, controlsLayout, preamble, runModelPath, hiddenGivens, literalReads, onLinkNavigate, actions, }: DashboardViewProps): import("react/jsx-runtime").JSX.Element;
82
+ export declare function DashboardView({ manifest, environmentName, packageName, versionId, documentName, givens, onGivensChange, onNavigate, height, maxResultSize, controlsLayout, preamble, runModelPath, hiddenGivens, literalReads, onLinkNavigate, actions, rowsActions, }: DashboardViewProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { RowsActionsContext } from './RowsDialog';
2
+ /**
3
+ * The rows dialog's own download, for a host that passes no `rowsActions`:
4
+ * runs the rows query with no row limit through the same query endpoint the
5
+ * dialog uses, and saves the result as CSV. The server's own row cap still
6
+ * applies; when the file reached it, the file name and the tooltip say so.
7
+ * A failure is written beside the button, where a keyboard user reaches it,
8
+ * with the server's message. Closing the dialog cancels a download in flight.
9
+ */
10
+ export declare function DownloadRowsCsv({ query, preamble, environmentName, packageName, modelPath, versionId, givens, fileName, }: RowsActionsContext): import("react/jsx-runtime").JSX.Element;
@@ -1,31 +1,65 @@
1
+ import { ReactNode } from 'react';
2
+ import { DrillClauseLabel } from '../drill/drillClauses';
3
+ import { DrillRowsRequest } from '../drill/resolveDrill';
4
+ import { RowsTarget } from '../drill/rowsTarget';
1
5
  /**
2
6
  * The rows behind a value: "show the rows" on a cell, as one query.
3
7
  *
4
- * A grouped value is an aggregate over rows of the tile's source, and Malloy's
5
- * `drill:` names exactly those rows: `drill: <view>.<field> = <value>` applies
6
- * the view's own `where:` — the tile's control bindings included — and the
7
- * clicked value's, so what comes back is the rows the number was made of.
8
- * Measured: `where: name = …` alone failed on a view that spelled the column
9
- * `name is products.name`, because the output name is not a source field;
10
- * `drill:` resolves it through the view, which is where the name lives.
8
+ * A grouped value is an aggregate over rows of the tile's source, and those
9
+ * rows are the source filtered by everything the value was filtered by: the
10
+ * tile's own `where:` (its control bindings included), every enclosing nest's,
11
+ * and each dimension of the clicked row at its value. All of that is read
12
+ * from the result's metadata (`rowsTarget.ts`), so a refined tile, a named
13
+ * query and a nest open their rows the same way a `source -> view` tile does.
11
14
  */
12
15
  export declare const ROW_LIMIT = 200;
13
- export interface RowsRequest {
14
- /** The source the rows are of: the tile expression's first step. */
15
- source: string;
16
- /** The view the value was grouped in: the expression's last step. */
17
- view: string;
18
- field: string;
19
- rawValue: unknown;
20
- label: string;
16
+ /** A click's rows request once its result has named everything a query needs. */
17
+ export type RowsRequest = DrillRowsRequest & {
18
+ target: RowsTarget;
19
+ };
20
+ /** The dialog's request for a click, if its result named everything a query needs. */
21
+ export declare function rowsRequestFor(request: DrillRowsRequest): RowsRequest | undefined;
22
+ /**
23
+ * What a host's rows actions get: everything needed to fetch the rows behind
24
+ * the value in full, not just the first {@link ROW_LIMIT} the dialog shows.
25
+ */
26
+ export interface RowsActionsContext {
27
+ /**
28
+ * The rows query with no `limit:`, so the server's own row cap is the only
29
+ * bound. Without the preamble: in text-source mode send
30
+ * `withPreamble(preamble, query)`, as the dialog does.
31
+ */
32
+ query: string;
33
+ /** Text-source mode: the document's definitions, sent ahead of `query`. */
34
+ preamble?: string;
35
+ environmentName: string;
36
+ packageName: string;
37
+ modelPath: string;
38
+ versionId?: string;
39
+ /** The givens the dialog's own query sends. */
40
+ givens: Record<string, unknown>;
41
+ /** A file name without an extension: the source and each value of the row. */
42
+ fileName: string;
21
43
  }
22
- /** The query the dialog runs, or undefined when the value cannot be spelled. */
23
- export declare function rowsQuery(request: RowsRequest): string | undefined;
44
+ /**
45
+ * The host's actions for the rows behind a value (a download, an export),
46
+ * drawn in the rows dialog's title row. Return `null` to show none; omitted,
47
+ * the dialog offers its own Download CSV.
48
+ */
49
+ export type RowsActions = (context: RowsActionsContext) => ReactNode;
50
+ /**
51
+ * The query the dialog runs, or undefined when a value cannot be spelled.
52
+ * `limit` caps the rows; `null` leaves the query unlimited, so only the
53
+ * server's own cap applies.
54
+ */
55
+ export declare function rowsQuery(request: RowsRequest, limit?: number | null): string | undefined;
56
+ /** What the dialog says when a request has no query. */
57
+ export declare const ROWS_REFUSAL = "This value cannot be written as a filter, so its rows cannot be fetched.";
58
+ /** What the title names: every value of the row, or the clicked one alone. */
59
+ export declare function rowsTitleParts(request: RowsRequest): DrillClauseLabel[];
24
60
  /**
25
61
  * `overview -> revenue_trend` → its source and view; undefined for anything
26
- * else — an inline stage has no view to drill through, a refined one carries
27
- * filters `drill:` would not, and a longer pipeline has no one view its value
28
- * came from.
62
+ * else.
29
63
  */
30
64
  export declare function stepsOf(tileExpression: string | undefined): {
31
65
  source: string;
@@ -33,15 +67,23 @@ export declare function stepsOf(tileExpression: string | undefined): {
33
67
  } | undefined;
34
68
  /** The source alone, for opening the explorer on it. */
35
69
  export declare const sourceOf: (tileExpression: string | undefined) => string;
36
- export declare function RowsDialog({ request, environmentName, packageName, versionId, modelPath, givens, onClose, onDone, }: {
70
+ export declare function RowsDialog({ request, environmentName, packageName, versionId, modelPath, preamble, givens, onClose, onDone, actions, }: {
37
71
  request: RowsRequest | undefined;
38
72
  environmentName: string;
39
73
  packageName: string;
40
74
  versionId?: string;
41
75
  modelPath: string;
76
+ /**
77
+ * Text-source mode: the document's definitions, sent ahead of the rows
78
+ * query exactly as they are ahead of each tile's, so the rows run as the
79
+ * viewer's own text on the same model.
80
+ */
81
+ preamble?: string;
42
82
  /** The applied control row, which the source's own `where:` may read. */
43
83
  givens: Record<string, unknown>;
44
84
  onClose: () => void;
45
85
  /** The query's outcome and how long it took, once per request. */
46
86
  onDone?: (ok: boolean, durationMs: number) => void;
87
+ /** The host's actions for these rows; omitted, the dialog's own Download CSV. */
88
+ actions?: RowsActions;
47
89
  }): import("react/jsx-runtime").JSX.Element;
@@ -3,4 +3,6 @@ export { TileFilterTag, tileIgnoredFilterLabels } from './TileFilterTag';
3
3
  export { DashboardTile, type DashboardTileProps } from './DashboardTile';
4
4
  export { documentPreamble, RESTRICTED_NOTICE, withPreamble, } from './textSource';
5
5
  export { TILE_MIN_HEIGHT, TileCard, TileHeading } from './TileCard';
6
+ export type { RowsActions, RowsActionsContext } from './RowsDialog';
7
+ export { DownloadRowsCsv } from './DownloadRowsCsv';
6
8
  export type { TileHeadingSlots } from './TileCard';
@@ -0,0 +1,26 @@
1
+ import type * as Malloy from "@malloydata/malloy-interfaces";
2
+ /**
3
+ * The rows behind a value as a CSV file: what the rows dialog's default
4
+ * download writes. A `select: *` result is one flat table, so each schema
5
+ * field is a column and each record a line.
6
+ */
7
+ /** A text value a spreadsheet would run as a formula is written with a leading `'`. */
8
+ export declare function neutralizeFormula(value: string): string;
9
+ /** The records of a result, in order. */
10
+ export declare function resultRecords(result: Malloy.Result): Malloy.Cell[][];
11
+ /**
12
+ * The result as CSV text: a header of the field names, then one line per
13
+ * record. Starts with a byte-order mark and ends lines with CRLF, so a
14
+ * spreadsheet opens non-ASCII text and line breaks inside a value correctly.
15
+ */
16
+ export declare function resultToCsv(result: Malloy.Result): string;
17
+ /**
18
+ * A file name for the rows behind a value, without an extension: the source
19
+ * and each value the rows are filtered on, as the dialog's title names them.
20
+ */
21
+ export declare function rowsFileName(source: string, values: readonly string[]): string;
22
+ /**
23
+ * How many rows the server's own cap left in a result, when that cap (not
24
+ * the query) cut it short; undefined when the result is complete.
25
+ */
26
+ export declare function serverCappedAt(rowCount: number, queryRowLimit: number | undefined, queryRowLimitSource: string | undefined): number | undefined;
@@ -1,7 +1,7 @@
1
1
  import { LogMessage } from '../../client';
2
2
  import { DrillBinding } from '../drill/useDrill';
3
- /** The box a dashboard tile's result scrolls in when it is taller than its cap. */
4
- export declare const RESULT_SCROLLER_CLASS = "publisher-result-scroller";
3
+ import { RESULT_SCROLLER_CLASS } from './resultSizing';
4
+ export { RESULT_SCROLLER_CLASS };
5
5
  interface ResultContainerProps {
6
6
  result: string | undefined;
7
7
  /**
@@ -38,4 +38,3 @@ interface ResultContainerProps {
38
38
  compactToFit?: boolean;
39
39
  }
40
40
  export default function ResultContainer({ result, maxHeight, tableMaxHeight, firstPaintHeight, maxResultSize, renderLogs, drill, fill, compactToFit, }: ResultContainerProps): import("react/jsx-runtime").JSX.Element;
41
- export {};
@@ -230,3 +230,5 @@ export declare function resolveResultHeight({ sizing, contentHeight, maxHeight,
230
230
  * (`ResultContainer` sets it); the renderer overrides in `RenderedResult` read it.
231
231
  */
232
232
  export declare const TIGHT_ATTR = "data-publisher-tight";
233
+ /** The box a dashboard tile's result scrolls in when it is taller than its cap. */
234
+ export declare const RESULT_SCROLLER_CLASS = "publisher-result-scroller";
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { NavigationClick } from '../click_helper';
3
+ import { RowsActions } from '../Dashboard/RowsDialog';
3
4
  import { TileChrome } from '../Dashboard/TileCard';
4
5
  import { DrillNavigation } from '../drill';
5
6
  import { DrillOutcome, ReportEventHandler } from './telemetry';
@@ -64,6 +65,12 @@ export interface ReportProps {
64
65
  * the end of the title's line rather than on a row of their own above it.
65
66
  */
66
67
  actions?: ReactNode;
68
+ /**
69
+ * The host's actions for the rows behind a clicked value (a download),
70
+ * drawn in the rows dialog's title row. Omitted, the dialog offers its own
71
+ * Download CSV; return `null` for none.
72
+ */
73
+ rowsActions?: RowsActions;
67
74
  }
68
75
  /**
69
76
  * A report of either layout, from `GET …/reports/{path}`: a grid drawn as a
@@ -73,5 +80,5 @@ export interface ReportProps {
73
80
  * Host-agnostic, like `Dashboard`: it takes props rather than reading a
74
81
  * router, and hands navigation and URL state back to whoever mounted it.
75
82
  */
76
- export declare function Report({ resourceUri, path, givens, onGivensChange, onNavigate, onLinkNavigate, height, maxResultSize, onEvent, chrome, manifestStaleTime, actions, }: ReportProps): import("react/jsx-runtime").JSX.Element;
83
+ export declare function Report({ resourceUri, path, givens, onGivensChange, onNavigate, onLinkNavigate, height, maxResultSize, onEvent, chrome, manifestStaleTime, actions, rowsActions, }: ReportProps): import("react/jsx-runtime").JSX.Element;
77
84
  export default Report;
@@ -0,0 +1,34 @@
1
+ import type * as Malloy from "@malloydata/malloy-interfaces";
2
+ /**
3
+ * The clicked row of a table, as the renderer reports it (its `onDrill`
4
+ * `DrillData.stableDrillClauses`): each dimension's expression and value,
5
+ * enclosing rows included. The click itself carries the clicked field alone.
6
+ *
7
+ * The rows query reads each dimension's value from here and writes it itself
8
+ * (`literalText`), rather than taking the renderer's own `DrillData.query`,
9
+ * which Malloy 0.0.435 cannot run as written: it puts a string between double
10
+ * quotes without escaping it, it reads every hour as `00`, and it writes
11
+ * quarter, week and minute literals (`@2026-Q1`) a filter refuses. What a
12
+ * filter does accept for every truncation is the truncated value itself at
13
+ * full precision, so that is what is written: a date as its day, a timestamp
14
+ * to the second, or to its fraction when it has one.
15
+ *
16
+ * Remove these workarounds, and take `DrillData.query` as written, once a
17
+ * Malloy release fixes the renderer's string quoting, hour digits and
18
+ * truncated literals.
19
+ */
20
+ export type DrillClause = Malloy.DrillOperation;
21
+ /** One clause as the title reads it: `region` is `West`. */
22
+ export interface DrillClauseLabel {
23
+ field: string;
24
+ label: string;
25
+ /** The clause's field expression, to find the result field it names. */
26
+ expression?: Malloy.Expression;
27
+ }
28
+ /** The clauses as the dialog title names them, each value as the table showed it. */
29
+ export declare function drillClauseLabels(clauses: readonly DrillClause[], timezone?: string): DrillClauseLabel[];
30
+ /**
31
+ * A literal as a filter's right-hand side, a timestamp as its wall clock in
32
+ * `timezone`. Undefined for a null, which is written `is null` instead.
33
+ */
34
+ export declare function literalText(value: Malloy.LiteralValue, timezone?: string): string | undefined;
@@ -0,0 +1,36 @@
1
+ import { DrillClause } from './drillClauses';
2
+ import { DrillClickPayload } from './resolveDrill';
3
+ /** As much of the renderer's `DrillData` as the relay reads. */
4
+ export interface RendererDrill {
5
+ stableDrillClauses: DrillClause[] | undefined;
6
+ }
7
+ /**
8
+ * Joins the renderer's two reports of one table-cell click into one payload.
9
+ *
10
+ * `onClick` names the clicked field and value; only `onDrill` knows the row,
11
+ * and the renderer calls it only with `tableConfig.enableDrill` set. For a
12
+ * table cell both run inside the same event dispatch, `onClick` first (the
13
+ * cell's handler, then its row-cell wrapper's), so a click is held for one
14
+ * microtask and the row lands on it before `forward` sees it. A click with no
15
+ * row, such as a dashboard item, goes out as it came.
16
+ */
17
+ export declare function drillClickRelay(forward: (payload: DrillClickPayload) => void): {
18
+ onClick: (payload: DrillClickPayload) => void;
19
+ onDrill: (data: RendererDrill) => void;
20
+ };
21
+ /**
22
+ * Lets the renderer report a clicked row's dimensions even where a level's
23
+ * filter has no stable form.
24
+ *
25
+ * The renderer builds a row's clauses (`stableDrillClauses`) from each level's
26
+ * filters and then its dimensions, and gives up on the whole row when one
27
+ * filter has no stable form, which is any filter that reads a given
28
+ * (`where: region ~ $REGION`, what a report's filter control writes). The rows
29
+ * query takes every filter from the result's metadata as code instead
30
+ * (`rowsTarget.ts`), so the filters are not wanted from the clauses at all.
31
+ * Reporting none per level leaves the clauses as the row's dimensions alone,
32
+ * which never depend on a filter's form.
33
+ *
34
+ * Per result, on its own field objects; the renderer's classes are untouched.
35
+ */
36
+ export declare function reportRowsWithoutFilters(root: object | undefined): void;
@@ -1,3 +1,5 @@
1
+ import { DrillClause } from './drillClauses';
2
+ import { RowsDimension, RowsTarget } from './rowsTarget';
1
3
  /**
2
4
  * The parsed-tag surface this module reads, structurally typed.
3
5
  *
@@ -10,6 +12,8 @@ export interface DrillTagReader {
10
12
  tag(...at: string[]): DrillTagReader | undefined;
11
13
  text(...at: string[]): string | undefined;
12
14
  textArray(...at: string[]): string[] | undefined;
15
+ array?(...at: string[]): DrillTagReader[] | undefined;
16
+ has?(...at: string[]): boolean;
13
17
  }
14
18
  /** The clicked field, as much of it as drill reads. */
15
19
  export interface DrillField {
@@ -24,6 +28,8 @@ export interface DrillField {
24
28
  * carry the method; absent, the field is taken at its word.
25
29
  */
26
30
  wasDimension?: () => boolean;
31
+ /** The column header: the field's `# label`, else its name. */
32
+ getLabel?: () => string;
27
33
  }
28
34
  /**
29
35
  * A click from `@malloydata/render`'s `onClick`, narrowed to what drill needs.
@@ -47,6 +53,19 @@ export interface DrillClickPayload {
47
53
  * this value" runs against is read from here.
48
54
  */
49
55
  context?: string;
56
+ /**
57
+ * Every dimension of the clicked row, enclosing rows included, as the
58
+ * renderer's `onDrill` reports them. Set by `RenderedResult` for a table
59
+ * cell; absent for a click the renderer reports no row for.
60
+ */
61
+ drillClauses?: readonly DrillClause[];
62
+ /** The query timezone, which a truncated timestamp in a clause is read in. */
63
+ timezone?: string;
64
+ /**
65
+ * Set by a host that shows no rows for this click's tile (a restricted
66
+ * one). Tag drills still apply.
67
+ */
68
+ noRows?: boolean;
50
69
  }
51
70
  /**
52
71
  * A click asking for the rows behind a value, on a surface that offers them.
@@ -60,6 +79,16 @@ export interface DrillRowsRequest {
60
79
  label: string;
61
80
  /** {@link DrillClickPayload.context}, when the host set one. */
62
81
  context?: string;
82
+ /** {@link DrillClickPayload.drillClauses}: the whole row, not just `field`. */
83
+ drillClauses?: readonly DrillClause[];
84
+ /** {@link DrillClickPayload.timezone}. */
85
+ timezone?: string;
86
+ /** The source and filters the rows run with, from the result's metadata. */
87
+ target?: RowsTarget;
88
+ /** The row's dimensions as code with their values, from `drillClauses`. */
89
+ dimensions?: readonly RowsDimension[];
90
+ /** The clicked field's code, for a click that came with no row. */
91
+ code?: string;
63
92
  }
64
93
  /** The literal `to=self`: filter the current view instead of leaving it. */
65
94
  export declare const DRILL_SELF = "self";
@@ -0,0 +1,114 @@
1
+ import { DrillClause } from './drillClauses';
2
+ import { DrillField, DrillTagReader } from './resolveDrill';
3
+ import type * as Malloy from "@malloydata/malloy-interfaces";
4
+ /**
5
+ * What "the rows behind a value" runs, read from the result's own metadata
6
+ * rather than from the tile's text.
7
+ *
8
+ * Malloy annotates every result with what a drill needs: the source the query
9
+ * ran on (`source.name`), each nest level's filters as code (`drill_filters`:
10
+ * the view's own `where:` and any refinement's, givens included), and each
11
+ * dimension's expression as code (`drill_expression.code`: `region`,
12
+ * `d.month`, `customers.name`). So the rows behind a row are
13
+ * `run: <source> -> { where: <every filter>, <every dimension> = <value>; select: * }`,
14
+ * whatever the tile was written as: `source -> view`, a refined view, a
15
+ * named query, an inline query, a nest.
16
+ *
17
+ * `where:` and not `drill:`, measured on Malloy 0.0.435. `drill:` needs the
18
+ * view's own path for every dimension, and a refined or named query reports a
19
+ * plain source field with none (`region`, not `by_month.region`), so its rows
20
+ * could not be named that way. And a `drill:` on a joined field
21
+ * (`by_name.name`, grouped as `customers.name`) does not bring the join in,
22
+ * so its query failed with `Referenced table … not found`; the same filter as
23
+ * `where:` does (malloydata/malloy#3158). Once a Malloy release with that fix
24
+ * reaches Publisher, the join is no longer a reason; the refined query's
25
+ * missing view path still is.
26
+ *
27
+ * A field reads as having rows only when every piece is there: a source with
28
+ * no arguments, every level on the way down marked `drillable` (one stage),
29
+ * a code for every filter on the way down, and a code for every dimension of
30
+ * the row. Anything else is not clickable for rows, never a guess. Malloy's
31
+ * metadata is wrong in places that would name the wrong rows (a pipeline's
32
+ * root marked `drillable`, a joined dimension's code); Publisher's server
33
+ * corrects those before it sends a result (`drill_metadata.ts`), and stamps
34
+ * the root {@link DRILL_METADATA_CORRECTED}. A result without the stamp, from
35
+ * a server older than the correction, offers no rows.
36
+ */
37
+ /**
38
+ * The root tag Publisher's server writes on a result whose drill metadata it
39
+ * corrected. Spelled the same in the server's `drill_metadata.ts`.
40
+ */
41
+ export declare const DRILL_METADATA_CORRECTED = "drill_metadata_corrected";
42
+ /**
43
+ * A renderer result field, as much as the rows behind a value read: the
44
+ * drill field plus Malloy's result metadata, its place in the result, and its
45
+ * type. Its own type because the renderer declares `metadataTag` protected, so
46
+ * a renderer field does not satisfy a `DrillField` that names it; a click's
47
+ * field is read as this one ({@link asRowsField}).
48
+ */
49
+ export interface RowsField extends DrillField {
50
+ metadataTag?: DrillTagReader;
51
+ parent?: RowsField;
52
+ fields?: RowsField[];
53
+ drillStableExpression?: Malloy.Expression;
54
+ getEffectiveQueryTimezone?: () => string | undefined;
55
+ isArray?: () => boolean;
56
+ isRecord?: () => boolean;
57
+ isBasic?: () => boolean;
58
+ isString?: () => boolean;
59
+ isNumber?: () => boolean;
60
+ isBoolean?: () => boolean;
61
+ isTime?: () => boolean;
62
+ }
63
+ /** A clicked or listed renderer field, read for its rows. */
64
+ export declare const asRowsField: (field: DrillField) => RowsField;
65
+ /** One dimension of the clicked row: its expression as code, and its value. */
66
+ export interface RowsDimension {
67
+ code: string;
68
+ value: Malloy.LiteralValue;
69
+ }
70
+ /** Where the rows come from, and what narrows them. */
71
+ export interface RowsTarget {
72
+ source: string;
73
+ /** The tile's own filters, every nest level's, as code, outermost first. */
74
+ filters: string[];
75
+ /** The view or query the value was grouped in, for telemetry and the title. */
76
+ queryName?: string;
77
+ }
78
+ /** A dimension's expression as Malloy code, or undefined when the result has none. */
79
+ export declare function dimensionCode(field: RowsField): string | undefined;
80
+ /**
81
+ * The source and filters the rows behind `field`'s values run with, or
82
+ * undefined when the result does not carry them all.
83
+ */
84
+ export declare function rowsTargetOf(field: RowsField): RowsTarget | undefined;
85
+ /**
86
+ * The dimensions of every level on the way from `field` to the root: the
87
+ * ones a row's values are given for. A level is whatever holds the fields,
88
+ * which for a table row is its repeated record (the root included).
89
+ */
90
+ export declare function rowDimensionsOf(field: RowsField): RowsField[];
91
+ /**
92
+ * The one zone every time dimension of the row was truncated in: undefined
93
+ * when there are none or they use the default, `null` when they differ. A
94
+ * rows query has one `timezone:`, so a nest whose levels set different zones
95
+ * cannot be filtered by all of its values at once.
96
+ */
97
+ export declare function rowTimezone(field: RowsField): string | undefined | null;
98
+ /**
99
+ * Whether a click on `field` can open its rows: a dimension, with a target,
100
+ * and every dimension of its row having a code, an expression the renderer
101
+ * reports its value under, and a value a filter can spell, all in one zone.
102
+ * What the affordance asks, so a value reads as clickable exactly when the
103
+ * click can build its query: the renderer reports no row at all when any
104
+ * dimension lacks an expression, and leaves out one whose value it cannot
105
+ * write.
106
+ */
107
+ export declare function canShowRows(field: RowsField): boolean;
108
+ /**
109
+ * The clicked row's dimensions, each as code with its value, from the
110
+ * renderer's row (`drillClauses`). Undefined unless every dimension of the row
111
+ * is there with a code: never a subset, since dropping a dimension returns
112
+ * rows that are not the row's.
113
+ */
114
+ export declare function rowsDimensions(field: RowsField, clauses: readonly DrillClause[]): RowsDimension[] | undefined;
@@ -23,18 +23,16 @@ export interface UseDrillOptions {
23
23
  */
24
24
  canSelf?: (given: string) => boolean;
25
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.
26
+ * A `to=` destination's title, for its menu entry. Undefined, or no
27
+ * function, and the entry names the destination's file name instead.
29
28
  */
30
- selfLabel?: string;
29
+ destinationTitle?: (destination: string) => string | undefined;
31
30
  /**
32
- * Show the rows behind a grouped value. With it, EVERY dimension cell is
33
- * clickable: one with no `# drill` this surface can honour opens the rows;
34
- * one with a drill behaves exactly as it does without this option, since a
35
- * drill is the author's own instruction for that value. Omitted on a
36
- * surface with nowhere to show them, and cells then click only where a tag
37
- * says so.
31
+ * Show the rows behind a grouped value. With it, a dimension cell whose
32
+ * result names everything its rows query needs (`canShowRows`) offers
33
+ * "Show rows" in its menu, beside any `# drill` actions. Omitted on a
34
+ * surface with nowhere to show them, and cells then offer only what a tag
35
+ * says.
38
36
  */
39
37
  onRows?: (request: DrillRowsRequest) => void;
40
38
  }
@@ -57,16 +55,30 @@ export interface DrillBinding {
57
55
  export interface UseDrillResult {
58
56
  /** Hand to `ResultContainer`'s (or `RenderedResult`'s) `drill` prop. */
59
57
  drill: DrillBinding;
60
- /** Render anywhere in the subtree: the menu a multi-destination drill opens. */
58
+ /**
59
+ * The binding for one result on a surface with several, such as a
60
+ * dashboard's tiles: its clicks carry `context`. `rows: false` turns rows
61
+ * off for that result, leaving its tag drills.
62
+ */
63
+ bindingFor: (context: string | undefined, rows: boolean) => DrillBinding;
64
+ /** Render anywhere in the subtree: the menu every drillable click opens. */
61
65
  drillMenu: ReactNode;
62
66
  }
63
67
  /**
64
68
  * Click-to-drill for any surface that renders a Malloy result.
65
69
  *
70
+ * Every drillable click opens one small menu that says what it can do, even
71
+ * when there is only one thing, each item naming the field and value it acts
72
+ * on: `Filter to Region: West` for a `to=self` drill, `Open Regional review
73
+ * (Region: West)` for each `to=` report, then `Show rows (Region: West, Month:
74
+ * 2025-12)`. A field is named as its column header reads. A `# drill` tag
75
+ * adds actions; it never replaces the rows, and a click never acts on a tag
76
+ * the reader cannot see.
77
+ *
66
78
  * Shared between the dashboard viewer and notebook cells on purpose: `# drill`
67
79
  * is declared on a model *dimension*, so it fires wherever that dimension is
68
80
  * grouped, and a notebook can therefore drill into a dashboard with no notebook-
69
81
  * specific code. What differs between surfaces is only what they can do about it,
70
82
  * which is what the two callbacks express.
71
83
  */
72
- export declare function useDrill({ onNavigate, onSelf, selfLabel, canSelf, onRows, }: UseDrillOptions): UseDrillResult;
84
+ export declare function useDrill({ onNavigate, onSelf, destinationTitle, canSelf, onRows, }: UseDrillOptions): UseDrillResult;