@malloy-publisher/sdk 0.12.0 → 0.12.2
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 +79 -6
- package/dist/{RenderedResult-SgDlxzs9.cjs.js → RenderedResult-Cgw4iqev.cjs.js} +1 -1
- package/dist/{RenderedResult-D8bCgThO.es.js → RenderedResult-DEjFM1DL.es.js} +2 -2
- package/dist/ServerProvider-BRQl_cBo.cjs.js +1 -0
- package/dist/{ServerProvider-DBw-thY0.es.js → ServerProvider-RnliA2Ao.es.js} +1084 -723
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +754 -41
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +120 -110
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +16 -1
- package/dist/components/Model/ExplorerPage.d.ts +9 -0
- package/dist/components/Model/Model.d.ts +27 -11
- package/dist/components/ModelViewer/AccessChips.d.ts +34 -0
- package/dist/components/ModelViewer/EmptyRow.d.ts +23 -0
- package/dist/components/ModelViewer/Facts.d.ts +15 -0
- package/dist/components/ModelViewer/FieldGroup.d.ts +31 -0
- package/dist/components/ModelViewer/FieldRow.d.ts +69 -0
- package/dist/components/ModelViewer/GivenFacts.d.ts +21 -0
- package/dist/components/ModelViewer/HeaderBar.d.ts +75 -0
- package/dist/components/ModelViewer/InlineDoc.d.ts +13 -0
- package/dist/components/ModelViewer/ModelGivensSection.d.ts +32 -0
- package/dist/components/ModelViewer/ModelSection.d.ts +21 -0
- package/dist/components/ModelViewer/ModelViewer.d.ts +91 -0
- package/dist/components/ModelViewer/QueriesGroup.d.ts +15 -0
- package/dist/components/ModelViewer/RowGlyph.d.ts +27 -0
- package/dist/components/ModelViewer/RunResult.d.ts +46 -0
- package/dist/components/ModelViewer/SampleValues.d.ts +20 -0
- package/dist/components/ModelViewer/SchemaJoin.d.ts +51 -0
- package/dist/components/ModelViewer/SchemaView.d.ts +52 -0
- package/dist/components/ModelViewer/SegmentIcons.d.ts +70 -0
- package/dist/components/ModelViewer/SourcesDropdown.d.ts +53 -0
- package/dist/components/ModelViewer/SourcesNav.d.ts +25 -0
- package/dist/components/ModelViewer/StatusPill.d.ts +56 -0
- package/dist/components/ModelViewer/ValueChip.d.ts +17 -0
- package/dist/components/ModelViewer/ViewRow.d.ts +36 -0
- package/dist/components/ModelViewer/clickableBox.d.ts +29 -0
- package/dist/components/ModelViewer/codeDisplay.d.ts +44 -0
- package/dist/components/ModelViewer/docAnnotations.d.ts +90 -0
- package/dist/components/ModelViewer/explorerModel.d.ts +12 -0
- package/dist/components/ModelViewer/extensions.d.ts +94 -0
- package/dist/components/ModelViewer/fieldCode.d.ts +74 -0
- package/dist/components/ModelViewer/fieldEntities.d.ts +45 -0
- package/dist/components/ModelViewer/fieldExpansion.d.ts +41 -0
- package/dist/components/ModelViewer/givenUsage.d.ts +71 -0
- package/dist/components/ModelViewer/headerCard.d.ts +31 -0
- package/dist/components/ModelViewer/httpStatus.d.ts +4 -0
- package/dist/components/ModelViewer/icons.d.ts +31 -0
- package/dist/components/ModelViewer/index.d.ts +9 -0
- package/dist/components/ModelViewer/joinAccess.d.ts +52 -0
- package/dist/components/ModelViewer/malloyRunText.d.ts +22 -0
- package/dist/components/ModelViewer/malloyText.d.ts +21 -0
- package/dist/components/ModelViewer/modelGivens.d.ts +61 -0
- package/dist/components/ModelViewer/modelGivensContext.d.ts +9 -0
- package/dist/components/ModelViewer/modelHeaderPresentation.d.ts +28 -0
- package/dist/components/ModelViewer/modelTextDeclarations.d.ts +32 -0
- package/dist/components/ModelViewer/modelTextParse.d.ts +27 -0
- package/dist/components/ModelViewer/namedQueryCode.d.ts +12 -0
- package/dist/components/ModelViewer/offSurface.d.ts +54 -0
- package/dist/components/ModelViewer/rowLayers.d.ts +30 -0
- package/dist/components/ModelViewer/runGate.d.ts +49 -0
- package/dist/components/ModelViewer/schemaModel.d.ts +109 -0
- package/dist/components/ModelViewer/sectionOpenCommand.d.ts +45 -0
- package/dist/components/ModelViewer/sourceAccess.d.ts +67 -0
- package/dist/components/ModelViewer/sourceLineage.d.ts +14 -0
- package/dist/components/ModelViewer/sourcePicker.d.ts +66 -0
- package/dist/components/ModelViewer/surface.d.ts +47 -0
- package/dist/components/ModelViewer/text.d.ts +6 -0
- package/dist/components/ModelViewer/theme.d.ts +63 -0
- package/dist/components/ModelViewer/tokens.d.ts +52 -0
- package/dist/components/ModelViewer/ui.d.ts +48 -0
- package/dist/components/ModelViewer/useDimensionSamples.d.ts +76 -0
- package/dist/components/ModelViewer/useModelSources.d.ts +92 -0
- package/dist/components/ModelViewer/useRunQuery.d.ts +115 -0
- package/dist/components/ReportBuilder/loadMalloy.d.ts +4 -0
- package/dist/components/ServerProvider.d.ts +17 -2
- package/dist/components/filter/utils.d.ts +1 -1
- package/dist/components/given/GivenInput.d.ts +7 -1
- package/dist/components/given/GivensPanel.d.ts +3 -1
- package/dist/components/given/filterSummary.d.ts +6 -0
- package/dist/components/given/useGivenUrlParams.d.ts +11 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/components/modelPage.d.ts +36 -0
- package/dist/hooks/useDimensionalFilterRangeData.d.ts +9 -0
- package/dist/hooks/useSuggestOptions.d.ts +26 -2
- package/dist/index.cjs.js +47 -19
- package/dist/index.es.js +14137 -9697
- package/dist/useCompiledDocument-D88_2cGS.cjs.js +143 -0
- package/dist/{useCompiledDocument-CXMPtJkJ.es.js → useCompiledDocument-Dmm6xkom.es.js} +6975 -6893
- package/dist/utils/filterCondition.d.ts +14 -0
- package/dist/utils/malloyLiteral.d.ts +20 -1
- package/package.json +2 -2
- package/src/components/Materializations/MaterializationDetailDialog.tsx +33 -7
- package/src/components/Materializations/Materializations.tsx +47 -4
- package/src/components/Materializations/Materializations.versions.spec.tsx +140 -1
- package/src/components/Model/ExplorerPage.tsx +269 -0
- package/src/components/Model/Model.tsx +66 -250
- package/src/components/Model/ModelExplorer.spec.tsx +64 -1
- package/src/components/ModelViewer/AccessChips.tsx +149 -0
- package/src/components/ModelViewer/EmptyRow.tsx +71 -0
- package/src/components/ModelViewer/Facts.tsx +46 -0
- package/src/components/ModelViewer/FieldGroup.tsx +137 -0
- package/src/components/ModelViewer/FieldRow.tsx +566 -0
- package/src/components/ModelViewer/GivenFacts.tsx +89 -0
- package/src/components/ModelViewer/HeaderBar.tsx +362 -0
- package/src/components/ModelViewer/InlineDoc.tsx +50 -0
- package/src/components/ModelViewer/ModelGivensSection.tsx +142 -0
- package/src/components/ModelViewer/ModelSection.tsx +98 -0
- package/src/components/ModelViewer/ModelViewer.spec.tsx +937 -0
- package/src/components/ModelViewer/ModelViewer.tsx +777 -0
- package/src/components/ModelViewer/QueriesGroup.tsx +107 -0
- package/src/components/ModelViewer/RowGlyph.tsx +138 -0
- package/src/components/ModelViewer/RunResult.tsx +298 -0
- package/src/components/ModelViewer/SampleValues.tsx +97 -0
- package/src/components/ModelViewer/SchemaJoin.tsx +258 -0
- package/src/components/ModelViewer/SchemaView.tsx +222 -0
- package/src/components/ModelViewer/SegmentIcons.tsx +129 -0
- package/src/components/ModelViewer/SourcesDropdown.tsx +265 -0
- package/src/components/ModelViewer/SourcesNav.tsx +75 -0
- package/src/components/ModelViewer/StatusPill.tsx +145 -0
- package/src/components/ModelViewer/ValueChip.tsx +39 -0
- package/src/components/ModelViewer/ViewRow.tsx +274 -0
- package/src/components/ModelViewer/clickableBox.ts +59 -0
- package/src/components/ModelViewer/codeDisplay.spec.ts +176 -0
- package/src/components/ModelViewer/codeDisplay.ts +118 -0
- package/src/components/ModelViewer/docAnnotations.spec.ts +181 -0
- package/src/components/ModelViewer/docAnnotations.ts +244 -0
- package/src/components/ModelViewer/docAnnotations.typeDetail.spec.ts +114 -0
- package/src/components/ModelViewer/explorerModel.spec.ts +43 -0
- package/src/components/ModelViewer/explorerModel.ts +31 -0
- package/src/components/ModelViewer/extensions.tsx +112 -0
- package/src/components/ModelViewer/fieldCode.spec.ts +168 -0
- package/src/components/ModelViewer/fieldCode.ts +118 -0
- package/src/components/ModelViewer/fieldEntities.ts +63 -0
- package/src/components/ModelViewer/fieldExpansion.spec.ts +116 -0
- package/src/components/ModelViewer/fieldExpansion.ts +95 -0
- package/src/components/ModelViewer/givenUsage.spec.ts +304 -0
- package/src/components/ModelViewer/givenUsage.ts +325 -0
- package/src/components/ModelViewer/headerCard.tsx +102 -0
- package/src/components/ModelViewer/httpStatus.ts +15 -0
- package/src/components/ModelViewer/icons.tsx +67 -0
- package/src/components/ModelViewer/index.ts +26 -0
- package/src/components/ModelViewer/joinAccess.spec.ts +95 -0
- package/src/components/ModelViewer/joinAccess.ts +54 -0
- package/src/components/ModelViewer/malloyRunText.spec.ts +48 -0
- package/src/components/ModelViewer/malloyRunText.ts +51 -0
- package/src/components/ModelViewer/malloyText.spec.ts +47 -0
- package/src/components/ModelViewer/malloyText.ts +77 -0
- package/src/components/ModelViewer/modelGivens.ts +228 -0
- package/src/components/ModelViewer/modelGivensContext.ts +13 -0
- package/src/components/ModelViewer/modelHeaderPresentation.spec.ts +31 -0
- package/src/components/ModelViewer/modelHeaderPresentation.ts +41 -0
- package/src/components/ModelViewer/modelTextDeclarations.spec.ts +336 -0
- package/src/components/ModelViewer/modelTextDeclarations.ts +228 -0
- package/src/components/ModelViewer/modelTextParse.ts +112 -0
- package/src/components/ModelViewer/namedQueryCode.spec.ts +58 -0
- package/src/components/ModelViewer/namedQueryCode.ts +26 -0
- package/src/components/ModelViewer/offSurface.tsx +124 -0
- package/src/components/ModelViewer/rowLayers.tsx +104 -0
- package/src/components/ModelViewer/runGate.spec.ts +219 -0
- package/src/components/ModelViewer/runGate.ts +145 -0
- package/src/components/ModelViewer/schemaModel.defaultSource.spec.ts +126 -0
- package/src/components/ModelViewer/schemaModel.queries.spec.ts +37 -0
- package/src/components/ModelViewer/schemaModel.ts +300 -0
- package/src/components/ModelViewer/sectionOpenCommand.tsx +125 -0
- package/src/components/ModelViewer/sourceAccess.spec.ts +130 -0
- package/src/components/ModelViewer/sourceAccess.ts +194 -0
- package/src/components/ModelViewer/sourceLineage.spec.ts +73 -0
- package/src/components/ModelViewer/sourceLineage.ts +38 -0
- package/src/components/ModelViewer/sourcePicker.spec.ts +294 -0
- package/src/components/ModelViewer/sourcePicker.ts +162 -0
- package/src/components/ModelViewer/surface.ts +51 -0
- package/src/components/ModelViewer/text.tsx +33 -0
- package/src/components/ModelViewer/theme.spec.ts +38 -0
- package/src/components/ModelViewer/theme.ts +58 -0
- package/src/components/ModelViewer/tokens.ts +87 -0
- package/src/components/ModelViewer/ui.tsx +201 -0
- package/src/components/ModelViewer/useDimensionSamples.spec.tsx +139 -0
- package/src/components/ModelViewer/useDimensionSamples.ts +220 -0
- package/src/components/ModelViewer/useModelSources.spec.ts +110 -0
- package/src/components/ModelViewer/useModelSources.ts +238 -0
- package/src/components/ModelViewer/useRunQuery.spec.ts +50 -0
- package/src/components/ModelViewer/useRunQuery.ts +223 -0
- package/src/components/Package/Package.agents.spec.tsx +5 -4
- package/src/components/Package/Package.tsx +8 -1
- package/src/components/ReportBuilder/emptyStart.spec.ts +8 -0
- package/src/components/ReportBuilder/loadMalloy.ts +8 -1
- package/src/components/ServerProvider.tsx +29 -3
- package/src/components/filter/utils.ts +4 -60
- package/src/components/given/FilterButton.tsx +4 -1
- package/src/components/given/GivenInput.tsx +8 -0
- package/src/components/given/GivensPanel.tsx +6 -1
- package/src/components/given/filterSummary.spec.ts +31 -1
- package/src/components/given/filterSummary.ts +41 -19
- package/src/components/given/useGivenUrlParams.spec.tsx +32 -0
- package/src/components/given/useGivenUrlParams.ts +49 -14
- package/src/components/index.ts +6 -1
- package/src/components/legacy/malloynb/Notebook.spec.tsx +38 -4
- package/src/components/legacy/malloynb/NotebookCell.tsx +8 -2
- package/src/components/modelPage.spec.ts +79 -0
- package/src/components/modelPage.ts +48 -0
- package/src/hooks/useDimensionFilters.ts +3 -58
- package/src/hooks/useDimensionFiltersQuery.ts +3 -58
- package/src/hooks/useDimensionalFilterRangeData.spec.ts +57 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +8 -63
- package/src/hooks/useSuggestOptions.dom.spec.ts +54 -1
- package/src/hooks/useSuggestOptions.spec.ts +71 -0
- package/src/hooks/useSuggestOptions.ts +102 -12
- package/src/utils/filterCondition.spec.ts +87 -0
- package/src/utils/filterCondition.ts +66 -0
- package/src/utils/malloyLiteral.spec.ts +53 -1
- package/src/utils/malloyLiteral.ts +47 -12
- package/dist/ServerProvider-BHfg1Ed6.cjs.js +0 -1
- package/dist/useCompiledDocument-D7X_K6YU.cjs.js +0 -142
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
2
|
+
import { ReactNode, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* The one status/tag pill: fully rounded, tinted, borderless (the design
|
|
5
|
+
* system has no outlines). Two voices, chosen by what the text IS:
|
|
6
|
+
*
|
|
7
|
+
* - `state` — a human state word ("Indexed", "In scope", "Materialized",
|
|
8
|
+
* "Published"): sans, sentence case supplied by the caller.
|
|
9
|
+
* - `token` — a machine token that exists verbatim in code or config
|
|
10
|
+
* (`join_one`, `line_chart`): mono, rendered exactly as written.
|
|
11
|
+
*
|
|
12
|
+
* Every status the app shows is drawn by this component — a list row's
|
|
13
|
+
* annotation and a page header's state alike — so a "Ready" reads the same
|
|
14
|
+
* wherever it sits, at ONE size: a header's state is the same pill as a row's,
|
|
15
|
+
* centered in the header's 28px row, so two states side by side never differ
|
|
16
|
+
* in scale. A host's own states (`renderSourceStatus`, `renderFieldStatus`)
|
|
17
|
+
* read best drawn with it too.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* A pill reports a state, and there are four a reader acts on differently. The
|
|
21
|
+
* first two are the labels: `neutral` names a thing, `positive` says it is good.
|
|
22
|
+
*
|
|
23
|
+
* `warning` and `negative` are for a state that is degraded — data that is out
|
|
24
|
+
* of date, or something that failed outright — which the reader needs to see
|
|
25
|
+
* WITHOUT opening the row. Reach for them only where the state is genuinely degraded — a join
|
|
26
|
+
* relationship (`join_one`) is not a warning, so it takes no warm tone.
|
|
27
|
+
*/
|
|
28
|
+
/** `info`: work under way, with its spinner (`busy`). */
|
|
29
|
+
export type StatusPillTone = "positive" | "neutral" | "warning" | "negative" | "quiet" | "info";
|
|
30
|
+
/**
|
|
31
|
+
* Where the pill sits: a row's annotation (`inline`) or a page or panel header's state
|
|
32
|
+
* (`header`). The same pill either way; the size names the place, not a scale.
|
|
33
|
+
*/
|
|
34
|
+
export type StatusPillSize = "inline" | "header";
|
|
35
|
+
interface StatusPillProps {
|
|
36
|
+
tone?: StatusPillTone;
|
|
37
|
+
voice?: "state" | "token";
|
|
38
|
+
size?: StatusPillSize;
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
sx?: SxProps<Theme>;
|
|
41
|
+
/**
|
|
42
|
+
* Accessibility passthrough to the rendered span. Declared rather than left
|
|
43
|
+
* to `...rest` because only one of the two was actually being type-checked:
|
|
44
|
+
* TypeScript skips JSX attributes containing a hyphen, so `aria-label` was
|
|
45
|
+
* always accepted while `role` was rejected — and an `aria-label` without a
|
|
46
|
+
* role is exactly the combination screen readers ignore.
|
|
47
|
+
*/
|
|
48
|
+
role?: string;
|
|
49
|
+
"aria-label"?: string;
|
|
50
|
+
/** A tab stop, for a pill whose tooltip must reach a keyboard (guide §7). */
|
|
51
|
+
tabIndex?: number;
|
|
52
|
+
/** Work in flight: a spinner before the label. */
|
|
53
|
+
busy?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export declare const StatusPill: ForwardRefExoticComponent<StatusPillProps & RefAttributes<HTMLSpanElement>>;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A single data VALUE — a sample from a dimension's index — as a **grey,
|
|
4
|
+
* outlined, gently-rounded rectangle**, deliberately unlike every other chip on
|
|
5
|
+
* these surfaces (the borderless, fully-rounded, semantically- or
|
|
6
|
+
* neutrally-toned pills the Base/Declarations/Platform layers use). A sample
|
|
7
|
+
* value is neither a layer status nor an annotation; it is raw data pulled from
|
|
8
|
+
* the warehouse, so it gets its own bordered-box vocabulary rather than reading
|
|
9
|
+
* as one more layer pill.
|
|
10
|
+
*
|
|
11
|
+
* <p>Mono, because a value is a literal that exists verbatim in the data (like
|
|
12
|
+
* the identifiers elsewhere here). On theme tokens (`action.hover` / `divider` /
|
|
13
|
+
* `text.primary`), no raw hex.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ValueChip({ children }: {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FieldCodeLookup } from './fieldCode';
|
|
2
|
+
import { ExplorerField } from './schemaModel';
|
|
3
|
+
import { RunContext } from './useRunQuery';
|
|
4
|
+
import { GivenInfo } from './modelGivens';
|
|
5
|
+
/**
|
|
6
|
+
* A source's view, or a model's named query, as a row of the page — the same
|
|
7
|
+
* line a measure or dimension has (RowLine), opened and closed the same way. Open,
|
|
8
|
+
* it shows its result card under the line, a notebook cell's shape: the Result |
|
|
9
|
+
* Code switch (and a host's actions) and the result, drawn by RunResult.
|
|
10
|
+
*
|
|
11
|
+
* <p>It runs when first opened, on its Result, and never on render: browsing a
|
|
12
|
+
* source costs nothing. The card mounts on first open and stays mounted while
|
|
13
|
+
* closed, so reopening shows the result already drawn; the result itself is the
|
|
14
|
+
* viewer's cache entry (runQueryOptions, kept for the page), so a remount
|
|
15
|
+
* (switching source and back) reopens it without a second request.
|
|
16
|
+
*
|
|
17
|
+
* <p>A row with nowhere to run (no `run`) opens on its Code, Result disabled.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ViewRow({ field, modelPath, sourceName, fieldCode, run, runQuery, runGivens, runGivensUnknown, }: {
|
|
20
|
+
field: ExplorerField;
|
|
21
|
+
modelPath: string;
|
|
22
|
+
/** The source the view belongs to; for a named query, the source it runs
|
|
23
|
+
* against when known (for its required filters), else "". */
|
|
24
|
+
sourceName: string;
|
|
25
|
+
/** The view's Malloy, when the source's definitions are available. */
|
|
26
|
+
fieldCode?: FieldCodeLookup;
|
|
27
|
+
/** Where to run it; absent where it can't be run. */
|
|
28
|
+
run?: RunContext;
|
|
29
|
+
/** A named query's `run:` text; a view's is built from its source and name.
|
|
30
|
+
* Its code is then the whole `query:` declaration, shown as written. */
|
|
31
|
+
runQuery?: string;
|
|
32
|
+
/** The givens a run reads, where its source can't say (see RunResult). */
|
|
33
|
+
runGivens?: ReadonlyArray<GivenInfo>;
|
|
34
|
+
/** Those of `runGivens` the page can't tie to the run either way. */
|
|
35
|
+
runGivensUnknown?: ReadonlySet<string>;
|
|
36
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { KeyboardEvent, MouseEvent, SyntheticEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `role`, `tabIndex`, accessible name, and Enter/Space activation for a
|
|
4
|
+
* clickable `Box`. Pair with {@link focusRingSx} so the focus stop is visible.
|
|
5
|
+
*
|
|
6
|
+
* `onActivate` receives the originating event so a control that anchors a popup
|
|
7
|
+
* can read `currentTarget`; handlers that don't need it can ignore it.
|
|
8
|
+
*
|
|
9
|
+
* Pass `undefined` for `label` ONLY when the element's own text content names it
|
|
10
|
+
* — a `role="button"` falls back to its contents, so an explicit label there
|
|
11
|
+
* would just be a second, drift-prone copy of the text on screen. A control
|
|
12
|
+
* whose content is an icon, or arbitrary nodes that may not include text, needs
|
|
13
|
+
* the explicit label.
|
|
14
|
+
*/
|
|
15
|
+
export declare function clickableBoxProps(label: string | undefined, onActivate?: (e: SyntheticEvent<HTMLElement>) => void): {
|
|
16
|
+
readonly onClick: (e: MouseEvent<HTMLElement>) => void;
|
|
17
|
+
readonly onKeyDown: (e: KeyboardEvent<HTMLElement>) => void;
|
|
18
|
+
readonly "aria-label"?: string;
|
|
19
|
+
readonly role: "button";
|
|
20
|
+
readonly tabIndex: 0;
|
|
21
|
+
};
|
|
22
|
+
/** Focus ring for a clickable `Box` — MUI draws none, so it needs one explicitly. */
|
|
23
|
+
export declare const focusRingSx: {
|
|
24
|
+
readonly "&:focus-visible": {
|
|
25
|
+
readonly outline: "2px solid";
|
|
26
|
+
readonly outlineColor: "primary.main";
|
|
27
|
+
readonly outlineOffset: "-2px";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drop the doc annotations from the head of a stored definition slice.
|
|
3
|
+
*
|
|
4
|
+
* The same text is the row's hover (see DocTooltip), so leaving it in the
|
|
5
|
+
* code block would print the description twice and bury the one thing the
|
|
6
|
+
* expansion exists to show — the expression — under prose. It would also keep
|
|
7
|
+
* the wrapper-strip below from matching, since the slice would not start with
|
|
8
|
+
* `name is`.
|
|
9
|
+
*
|
|
10
|
+
* Doc annotations only: `#(index)`, renderer tags and any other `#` annotation
|
|
11
|
+
* stay, because they are part of how the field behaves rather than a description
|
|
12
|
+
* of it. Both Malloy doc forms are recognized — `#(doc) …` and consecutive `#"`
|
|
13
|
+
* lines.
|
|
14
|
+
*
|
|
15
|
+
* The whole leading annotation run is scanned, not just its first lines: both
|
|
16
|
+
* orders are legal Malloy, so stopping at a `#(index)` would leave the docstring
|
|
17
|
+
* below it in the code block AND in the hover — the double-print this exists to
|
|
18
|
+
* prevent.
|
|
19
|
+
*/
|
|
20
|
+
export declare function stripDocAnnotations(code: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Trim the redundant declaration wrapper off a field's stored Malloy
|
|
23
|
+
* definition for display — but only when the body is a BLOCK.
|
|
24
|
+
*
|
|
25
|
+
* `by_state is { … }` shows its dedented body: the braces and their level of
|
|
26
|
+
* indentation are pure wrapper, and `group_by:` / `aggregate:` describe
|
|
27
|
+
* themselves. An EXPRESSION keeps its wrapper, because stripping it throws
|
|
28
|
+
* away the relationship that makes it a definition — `category_grain is
|
|
29
|
+
* category` rendered as a lone `category` reads as a stray field reference,
|
|
30
|
+
* not as "this field is defined as that one".
|
|
31
|
+
*
|
|
32
|
+
* Anything that doesn't match the expected wrapper (multi-statement slices,
|
|
33
|
+
* renames, exotic forms) is shown verbatim rather than mangled.
|
|
34
|
+
*/
|
|
35
|
+
export declare function stripDefinitionWrapper(name: string, code: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* A view's whole declaration for display — `view: by_year is { … }`, keyword
|
|
38
|
+
* included, with its tags (`# line_chart`) above it and only the doc text dropped
|
|
39
|
+
* (the row prints that already). A view is read as the thing a model declares, so
|
|
40
|
+
* its Definition shows the declaration rather than just the block's body. The stored
|
|
41
|
+
* slice may start at the name (`by_year is { … }`); the keyword is put back then.
|
|
42
|
+
* Anything that isn't that shape is shown verbatim.
|
|
43
|
+
*/
|
|
44
|
+
export declare function viewDeclaration(name: string, code: string): string;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type * as Malloy from "@malloydata/malloy-interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Extract human-readable documentation from a list of Malloy annotations.
|
|
4
|
+
*
|
|
5
|
+
* Supports both forms a model author can use:
|
|
6
|
+
* - `#" markdown doc comment` lines (Malloy doc comments)
|
|
7
|
+
* - `#(doc) "text"` tag-style annotations
|
|
8
|
+
*
|
|
9
|
+
* Multiple matching lines are joined with newlines. Returns undefined when
|
|
10
|
+
* there is no documentation, so callers can `doc ?? fallback`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getDocString(annotations: Malloy.Annotation[] | undefined): string | undefined;
|
|
13
|
+
/** Each doc annotation's text, in order — what `getDocString` joins. */
|
|
14
|
+
export declare function getDocParts(annotations: Malloy.Annotation[] | undefined): string[];
|
|
15
|
+
/**
|
|
16
|
+
* A model file's own doc: its `##"` and `##(doc)` lines (a model's annotations
|
|
17
|
+
* take the double hash), read as `getDocString` reads a source's. Other `##`
|
|
18
|
+
* lines (`##! experimental…`, model tags) are not prose and are left out.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getModelDocString(annotations: Malloy.Annotation[] | undefined): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* A source's own doc, without what it inherited. A source that `extend`s another
|
|
23
|
+
* carries the base's doc annotations ahead of its own (the compiled source has no
|
|
24
|
+
* mark saying which are which), so a header printing all of them repeats the base
|
|
25
|
+
* source's description above the one written for this source. `base` is the source
|
|
26
|
+
* this one extends, read from the model's text (sourceLineage's `baseSourceName`);
|
|
27
|
+
* its whole doc, as a leading run of this one's, is what was inherited. Without a
|
|
28
|
+
* known base nothing is dropped: two unrelated sources can share boilerplate. A
|
|
29
|
+
* source with no doc of its own keeps the inherited one — it still describes it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function ownSourceDoc(source: {
|
|
32
|
+
docParts?: string[];
|
|
33
|
+
}, base: {
|
|
34
|
+
docParts?: string[];
|
|
35
|
+
} | undefined): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The non-doc annotation lines — renderer/behavior tags like `# bar_chart`,
|
|
38
|
+
* `# size=lg`, or `#(index)` — normalized for chip display: the `#` prefix
|
|
39
|
+
* (and any `#(malloy)`-style parens wrapper) stripped, whitespace trimmed.
|
|
40
|
+
* Doc lines (`#"`, `#(doc)`) are excluded (they're `getDocString`'s). Returns
|
|
41
|
+
* [] when there are none.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getTagLines(annotations: Malloy.Annotation[] | undefined): string[];
|
|
44
|
+
/**
|
|
45
|
+
* What a view's tag lines (getTagLines) make it, as names for its row: the chart
|
|
46
|
+
* type and any other bare tag (`line_chart`, `dashboard`, `percent`), each once.
|
|
47
|
+
* A tag's parameters (`{ y=checklist_count }`) and valued settings (`size=lg`)
|
|
48
|
+
* are left to the view's code, where they are read in full (except `viz=bar`, the
|
|
49
|
+
* chart type's other spelling, which names `bar`): on the row they
|
|
50
|
+
* crowded its name off the line. A removed tag (`-bar_chart`) names nothing.
|
|
51
|
+
*
|
|
52
|
+
* Parsed by Malloy's own tag parser; a line it can't parse names its first word,
|
|
53
|
+
* cut at any `{` or `=`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function tagNames(tagLines: string[]): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Whether a source's annotations carry a Malloy Persistence `persist` tag
|
|
58
|
+
* (`#@ persist …`) — the marker that this source is served from a
|
|
59
|
+
* materialized table rather than computed live.
|
|
60
|
+
*/
|
|
61
|
+
export declare function hasPersistTag(annotations: Malloy.Annotation[] | undefined): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether a measure's annotations carry a Malloy Persistence `preaggregate` tag
|
|
64
|
+
* (`#@ preaggregate grain="…"`) — the marker that this measure is rolled up
|
|
65
|
+
* into a table grouped at that grain.
|
|
66
|
+
*
|
|
67
|
+
* <p>The measure-level counterpart to {@link hasPersistTag}. Like it, this
|
|
68
|
+
* reports what the model DECLARES, which is true whether or not a rollup has
|
|
69
|
+
* been built — the built artifact is a binding, and the two are shown
|
|
70
|
+
* differently on purpose (see {@link import("./DeclarationPill").DeclarationPill}).
|
|
71
|
+
*/
|
|
72
|
+
export declare function hasPreaggregateTag(annotations: Malloy.Annotation[] | undefined): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* A field's type as a reader needs it, with the detail the kind alone drops:
|
|
75
|
+
* a time field's timeframe ("date · month"), a number's subtype
|
|
76
|
+
* ("number · integer"), an array's element type ("array<string>"), a record's
|
|
77
|
+
* field count, a native column's SQL type.
|
|
78
|
+
*/
|
|
79
|
+
export declare function atomicTypeDetail(type: Malloy.AtomicType | undefined): string | undefined;
|
|
80
|
+
/** A record's fields, one per line ("name string"), for its type chip's tooltip;
|
|
81
|
+
* undefined for any other type. */
|
|
82
|
+
export declare function recordFieldsTip(type: Malloy.AtomicType | undefined): string | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* A field's author-facing tags (`# label="Revenue"`, `# currency`, `# percent`,
|
|
85
|
+
* `# number="0.0%"`) as `getTagLines` reads them, less the persistence
|
|
86
|
+
* tags (`#@ preaggregate …`), which the row states as its own pill.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getFieldTagLines(annotations: Malloy.Annotation[] | undefined): string[];
|
|
89
|
+
/** Strip the "_type" suffix off an AtomicType kind ("string_type" → "string"). */
|
|
90
|
+
export declare function atomicTypeLabel(type: Malloy.AtomicType | undefined): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as Malloy from "@malloydata/malloy-interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Each source's required filters, by source name, for the sources that declare
|
|
4
|
+
* any. Only the annotations: a required filter is declared there, and the field
|
|
5
|
+
* walk the full metadata does is for filter controls this surface doesn't render.
|
|
6
|
+
*/
|
|
7
|
+
export declare function requiredFiltersBySource(sourceInfos: Malloy.SourceInfo[]): Map<string, string[]>;
|
|
8
|
+
/** The names of the model's sources: what lineage, inherited givens and a
|
|
9
|
+
* same-model join target are resolved against. */
|
|
10
|
+
export declare function sourceNameSet(sources: readonly {
|
|
11
|
+
name: string;
|
|
12
|
+
}[]): ReadonlySet<string>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ReactNode, Context } from 'react';
|
|
2
|
+
import { GivenRequest } from './modelGivens';
|
|
3
|
+
import { ShownRun } from './RunResult';
|
|
4
|
+
import { ExplorerField } from './schemaModel';
|
|
5
|
+
import { SampleValuesFetcher } from './useDimensionSamples';
|
|
6
|
+
/** An open view's or named query's run, for a host's actions beside it. */
|
|
7
|
+
export interface RunActionContext {
|
|
8
|
+
kind: "view" | "query";
|
|
9
|
+
modelPath: string;
|
|
10
|
+
/** The source a view belongs to; "" for a named query. */
|
|
11
|
+
sourceName: string;
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* The Malloy the row runs: the view or query by name, with no row limit of
|
|
15
|
+
* its own, so its rows are what the server's cap allows.
|
|
16
|
+
*/
|
|
17
|
+
query: string;
|
|
18
|
+
/** The given values the run sends (`QueryRequest.givens`), unset ones left out. */
|
|
19
|
+
givens?: GivenRequest;
|
|
20
|
+
/**
|
|
21
|
+
* The viewer's cache key for this run, so a host's refresh can invalidate
|
|
22
|
+
* it and a host's own run of the same query can share the entry.
|
|
23
|
+
*/
|
|
24
|
+
queryKey: readonly unknown[];
|
|
25
|
+
/** The result the card shows, once it has one. */
|
|
26
|
+
shown?: ShownRun;
|
|
27
|
+
}
|
|
28
|
+
/** A field row, for a host's additions to it. */
|
|
29
|
+
export interface FieldContext {
|
|
30
|
+
modelPath: string;
|
|
31
|
+
sourceName: string;
|
|
32
|
+
field: ExplorerField;
|
|
33
|
+
/** A joined source's field, shown inside a join on another source's page. */
|
|
34
|
+
joined: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The source on screen, or a source in the picker, for a host's additions to it. */
|
|
37
|
+
export interface SourceContext {
|
|
38
|
+
modelPath: string;
|
|
39
|
+
sourceName: string;
|
|
40
|
+
}
|
|
41
|
+
/** What a host adds to a source's line in the picker. */
|
|
42
|
+
export interface PickerSourceExtras {
|
|
43
|
+
/** A description where the source has no `#(doc)`, marked Generated. */
|
|
44
|
+
summary?: string;
|
|
45
|
+
/** Hold the description's line: the host is still reading its summaries. */
|
|
46
|
+
summaryPending?: boolean;
|
|
47
|
+
/** Chips after the source's name. */
|
|
48
|
+
status?: ReactNode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What a host adds to the viewer without the viewer knowing what it is: the
|
|
52
|
+
* Publisher's own reads draw every row, and a host with more to say about a
|
|
53
|
+
* field (what it has built from it, an index of its values) or more to do with
|
|
54
|
+
* a result (download it) says and does it through these.
|
|
55
|
+
*
|
|
56
|
+
* **Experimental.** These slots are new, and no host has been built on them
|
|
57
|
+
* yet; they may change in a minor release until one has.
|
|
58
|
+
*/
|
|
59
|
+
export interface ModelViewerExtensions {
|
|
60
|
+
/** Actions beside an open view's or named query's Result | Code switch. */
|
|
61
|
+
renderRunActions?: (run: RunActionContext) => ReactNode;
|
|
62
|
+
/** A dimension's sample values, instead of the viewer's own query. */
|
|
63
|
+
fetchSamples?: SampleValuesFetcher;
|
|
64
|
+
/**
|
|
65
|
+
* The build of the values `fetchSamples` serves (an index's version, say):
|
|
66
|
+
* a new one is a new cache entry, so a row reopened after a rebuild never
|
|
67
|
+
* shows the values from before it.
|
|
68
|
+
*/
|
|
69
|
+
samplesGeneration?: string;
|
|
70
|
+
/** Chips a host adds to a field's line, after its own. */
|
|
71
|
+
renderFieldStatus?: (field: FieldContext) => ReactNode;
|
|
72
|
+
/** The row's one action, beside its chips (a Rebuild, say). */
|
|
73
|
+
renderFieldAction?: (field: FieldContext) => ReactNode;
|
|
74
|
+
/**
|
|
75
|
+
* What an open field row shows. `builtIn` is the viewer's own card (the
|
|
76
|
+
* field's code, a dimension's values, the givens it reads), undefined where
|
|
77
|
+
* the row has none. Return it to keep it, beside a card of your own or not;
|
|
78
|
+
* return something else to show that in its place; return null for nothing,
|
|
79
|
+
* and the row then doesn't open.
|
|
80
|
+
*/
|
|
81
|
+
renderFieldDetail?: (field: FieldContext, builtIn: ReactNode | undefined) => ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* Whether a view's or field's row is listed, for a host's narrowed view of
|
|
84
|
+
* a source (the fields it has built from, say). Each section's count is of
|
|
85
|
+
* the rows it lists. Absent, every row is.
|
|
86
|
+
*/
|
|
87
|
+
showField?: (field: FieldContext) => boolean;
|
|
88
|
+
/** A card under the source's header, for what only the host knows of it (where its data comes from, its build). */
|
|
89
|
+
renderSourceDetail?: (source: SourceContext) => ReactNode;
|
|
90
|
+
/** A host's summary and chips on a source's line in the picker. */
|
|
91
|
+
describePickerSource?: (source: SourceContext) => PickerSourceExtras | undefined;
|
|
92
|
+
}
|
|
93
|
+
export declare const ModelViewerExtensionsContext: Context<ModelViewerExtensions>;
|
|
94
|
+
export declare function useModelViewerExtensions(): ModelViewerExtensions;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { EntitiesByField } from './fieldEntities';
|
|
2
|
+
import { TextDeclaration } from './modelTextDeclarations';
|
|
3
|
+
/**
|
|
4
|
+
* Per-field Malloy-definition lookup, supplied by the owner (SchemaView) when
|
|
5
|
+
* code snippets are available for this row's source. `code` stays undefined
|
|
6
|
+
* while loading or when the field has no definition of its own (an inherited
|
|
7
|
+
* column).
|
|
8
|
+
*/
|
|
9
|
+
export interface FieldCodeLookup {
|
|
10
|
+
code?: string;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
/** The definitions read failed: kept distinct from "this field has no
|
|
13
|
+
* definition" (an error carries no evidence of absence), and the one
|
|
14
|
+
* absence the row still opens to report. */
|
|
15
|
+
error?: boolean;
|
|
16
|
+
/** The field is an inherited table column (entity `fieldType` "column"):
|
|
17
|
+
* its stored code is the SOURCE's declaring line, which reads as nonsense
|
|
18
|
+
* for the field, so it's suppressed. Such a row doesn't open; without a
|
|
19
|
+
* description it says "inherited" beside its type instead. */
|
|
20
|
+
inherited?: boolean;
|
|
21
|
+
/** For an inherited column, where it comes from: the table expression a
|
|
22
|
+
* table column is read from (`fromTable`), or the passthrough line of the
|
|
23
|
+
* query source it is an output of. Shown as its Code in place of a
|
|
24
|
+
* definition of its own. */
|
|
25
|
+
inheritedFrom?: {
|
|
26
|
+
code: string;
|
|
27
|
+
fromTable: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** For an inherited column: a host's description of that warehouse column,
|
|
30
|
+
* so a passthrough dimension the modeler never documented still says what
|
|
31
|
+
* it holds. Never set for a defined field. */
|
|
32
|
+
columnDoc?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Builds the per-field code lookup for ONE source's fields.
|
|
36
|
+
*
|
|
37
|
+
* Shared by the active source and by each joined source rendered inline: a
|
|
38
|
+
* joined source is the same source seen from another page, so its fields must
|
|
39
|
+
* offer the same definition/"inherited" affordance. Keeping one factory is what
|
|
40
|
+
* makes that identical rather than merely similar.
|
|
41
|
+
*
|
|
42
|
+
* `entities` must be the fields of the source that DECLARES these fields —
|
|
43
|
+
* for a join, the target source's map, not the host's. Field names are only
|
|
44
|
+
* unique within a source, so passing the wrong map silently renders another
|
|
45
|
+
* source's definition on a same-named field.
|
|
46
|
+
*/
|
|
47
|
+
export declare function makeGetFieldCode(params: {
|
|
48
|
+
entities: EntitiesByField | undefined;
|
|
49
|
+
loading: boolean;
|
|
50
|
+
error: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Generated descriptions of the base TABLE's columns (column name → text),
|
|
53
|
+
* for the table this source reads. Only ever applied to inherited columns —
|
|
54
|
+
* a field with a Malloy definition is the modeler's expression, and its name
|
|
55
|
+
* colliding with a warehouse column's says nothing about what it computes.
|
|
56
|
+
*
|
|
57
|
+
* Must be the table behind THESE entities. A joined source reads its own
|
|
58
|
+
* table, so the host's map would describe the wrong columns — SchemaJoin
|
|
59
|
+
* passes none.
|
|
60
|
+
*/
|
|
61
|
+
columnDescriptions?: ReadonlyMap<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* The same source's declarations read from the model file's text
|
|
64
|
+
* (`fieldDeclarations`), for a field the entities don't carry: without a
|
|
65
|
+
* host's entities, every field's code comes from here. Used only once the entities read has settled with no entity for the
|
|
66
|
+
* field, and only for a declaration of the field's own kind.
|
|
67
|
+
*/
|
|
68
|
+
declarations?: ReadonlyMap<string, TextDeclaration>;
|
|
69
|
+
/** The model file is still being parsed for `declarations`. */
|
|
70
|
+
declarationsLoading?: boolean;
|
|
71
|
+
}): (field: {
|
|
72
|
+
name: string;
|
|
73
|
+
kind?: string;
|
|
74
|
+
}) => FieldCodeLookup;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a host knows about a model's fields beyond what the compiled model says.
|
|
3
|
+
*
|
|
4
|
+
* The viewer's own reads give it every field's name, type and annotations, and
|
|
5
|
+
* the model file's text gives it the code of whatever the file declares. A host
|
|
6
|
+
* with a fuller record of the model (an index of every field the model compiles,
|
|
7
|
+
* say) can pass that record as entities, and the viewer then shows what only it
|
|
8
|
+
* knows: an inherited table column's origin, the table a source reads, a join's
|
|
9
|
+
* target source and its declaration.
|
|
10
|
+
*/
|
|
11
|
+
export interface FieldEntity {
|
|
12
|
+
/** The field's name within its declaring source. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** The source that declares the field. An entity without one is dropped:
|
|
15
|
+
* field names are unique only within a source. */
|
|
16
|
+
source?: string | null;
|
|
17
|
+
/** `dimension`, `measure`, `view`, `join`, or `column` for a table column the
|
|
18
|
+
* source passes through unchanged. */
|
|
19
|
+
fieldType?: string | null;
|
|
20
|
+
/** The Malloy that defines the field, verbatim. */
|
|
21
|
+
code?: string | null;
|
|
22
|
+
/** The table the declaring source reads, when it reads one. */
|
|
23
|
+
table?: FieldEntityTable | null;
|
|
24
|
+
/** For a join, the source it joins: the alias can differ from its name. */
|
|
25
|
+
joinTarget?: {
|
|
26
|
+
modelPath: string;
|
|
27
|
+
sourceName: string;
|
|
28
|
+
} | null;
|
|
29
|
+
}
|
|
30
|
+
export interface FieldEntityTable {
|
|
31
|
+
connectionName: string;
|
|
32
|
+
catalogName?: string | null;
|
|
33
|
+
schemaName?: string | null;
|
|
34
|
+
tableName: string;
|
|
35
|
+
}
|
|
36
|
+
/** One source's fields, keyed by field name. */
|
|
37
|
+
export type EntitiesByField = ReadonlyMap<string, FieldEntity>;
|
|
38
|
+
/**
|
|
39
|
+
* Every source declared by one model file, keyed by SOURCE name, never a flat
|
|
40
|
+
* field map: `aircraft` and `aircraft_models` can both declare `id`, and a flat
|
|
41
|
+
* map would show one source's definition on the other's field.
|
|
42
|
+
*/
|
|
43
|
+
export type EntitiesBySource = ReadonlyMap<string, EntitiesByField>;
|
|
44
|
+
/** A model's entities grouped by declaring source; one with no source is dropped rather than guessed. */
|
|
45
|
+
export declare function groupEntitiesBySource(entities: ReadonlyArray<FieldEntity>): EntitiesBySource;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FieldCodeLookup } from './fieldCode';
|
|
2
|
+
import { ExplorerField } from './schemaModel';
|
|
3
|
+
/** A dimension whose VALUES are in the search index (`#(index)`), so the row can
|
|
4
|
+
* show sample values — content in its own right, with or without a definition. */
|
|
5
|
+
export declare function isIndexedDimension(field: ExplorerField): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Whether the expansion has a definition section to draw. True while the fetch
|
|
8
|
+
* is in flight (the answer isn't known yet, and a row that opens late is
|
|
9
|
+
* better than one that vanishes under the pointer) and true on failure, which
|
|
10
|
+
* is a fact about the pane worth surfacing rather than reading as "no
|
|
11
|
+
* definition". False for an inherited table column — its story is told on the
|
|
12
|
+
* row's hover instead.
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasDefinitionToShow(fieldCode: FieldCodeLookup | undefined): boolean;
|
|
15
|
+
export declare function isFieldExpandable(field: ExplorerField, fieldCode: FieldCodeLookup | undefined): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Expandable fields first, each block keeping the model's declaration order.
|
|
18
|
+
*
|
|
19
|
+
* A group of a table-backed source's dimensions is mostly passthrough columns,
|
|
20
|
+
* and the handful the modeler actually wrote were scattered among them — the
|
|
21
|
+
* interesting rows found by hunting for the ones that open. Hoisting them puts the
|
|
22
|
+
* source's own work at the top of the group and leaves the inherited columns as
|
|
23
|
+
* the tail they are.
|
|
24
|
+
*
|
|
25
|
+
* **The row and the order answer "loading" differently, on purpose.**
|
|
26
|
+
* `isFieldExpandable` is optimistic while the definitions read is in flight —
|
|
27
|
+
* a row that becomes openable late beats one that stops being so under the pointer. Order
|
|
28
|
+
* cannot be optimistic the same way: taking `loading` as expandable puts EVERY
|
|
29
|
+
* field in the hoisted block, so `rest` is empty, the identity short-circuit
|
|
30
|
+
* below returns the list unsorted, and the group then re-sorts under the reader
|
|
31
|
+
* when the read lands. So ordering asks a stricter question — is this field
|
|
32
|
+
* expandable *on what is known now*.
|
|
33
|
+
*
|
|
34
|
+
* **This narrows the reorder; it does not remove it.** A row is knowable at
|
|
35
|
+
* first paint only through `isIndexedDimension`, which reads `field.indexed`
|
|
36
|
+
* off the compiled schema. A plain written measure still hoists when its
|
|
37
|
+
* definition's read lands (the model text's parse, or a host's entities),
|
|
38
|
+
* because written-vs-inherited is only known from that read. Removing the rest
|
|
39
|
+
* needs the compiled schema to say what a field is.
|
|
40
|
+
*/
|
|
41
|
+
export declare function expandableFirst(items: ExplorerField[], getFieldCode: (field: ExplorerField) => FieldCodeLookup | undefined): ExplorerField[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { GivenInfo } from './modelGivens';
|
|
2
|
+
/**
|
|
3
|
+
* Which givens a piece of Malloy reads, found in its text.
|
|
4
|
+
*
|
|
5
|
+
* The compiled model lists a model's givens but not where each is used, so
|
|
6
|
+
* this reads the definitions the page already has: a
|
|
7
|
+
* field's or view's code, and the model file's text. A given is referenced as
|
|
8
|
+
* `$NAME` and its name is a declared identifier, so a whole-name match against
|
|
9
|
+
* the declared list is reliable; comments and strings are masked first
|
|
10
|
+
* (`maskCommentsAndStrings`) so a mention there is not a use. Host-filled givens never reach here (the viewer leaves out its
|
|
11
|
+
* `hostGivenNames`), so `$GROUPS` in a gate is not a reader's given.
|
|
12
|
+
*/
|
|
13
|
+
export declare function givensReadBy(code: string | undefined, givens: ReadonlyArray<GivenInfo>): GivenInfo[];
|
|
14
|
+
/**
|
|
15
|
+
* The names of the givens a model file declares itself (`NAME :: type`), as
|
|
16
|
+
* opposed to ones it holds because it imports them: the compiled model lists
|
|
17
|
+
* both, and doesn't say which file declared each.
|
|
18
|
+
*/
|
|
19
|
+
export declare function givensDeclaredIn(sourceText: string | undefined, givens: ReadonlyArray<GivenInfo>): Set<string>;
|
|
20
|
+
/**
|
|
21
|
+
* The givens a named query reads when the model doesn't say which source it
|
|
22
|
+
* runs against: those its declaration names, plus those of every source of
|
|
23
|
+
* the model it names (`givensBySource`, what a run on that source gates on).
|
|
24
|
+
* Undefined without its declaration's text, where every given is the only
|
|
25
|
+
* safe answer.
|
|
26
|
+
*/
|
|
27
|
+
export declare function givensOfNamedQuery(code: string | undefined, givens: ReadonlyArray<GivenInfo>, givensBySource: ReadonlyMap<string, ReadonlyArray<GivenInfo>> | undefined): GivenInfo[] | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* {@link givensOfNamedQuery}, and which of its givens the page can't tie to
|
|
30
|
+
* the query either way (`unknown`): those of a source it names that the scan
|
|
31
|
+
* couldn't follow (`unknownBySource`), and, when the query runs over something
|
|
32
|
+
* that isn't one of the model's sources (an imported source the model doesn't
|
|
33
|
+
* export, another query, a `compose(…)`), every given its own text doesn't
|
|
34
|
+
* read, all of which it then returns. Without its text, every given, none
|
|
35
|
+
* known.
|
|
36
|
+
*/
|
|
37
|
+
export declare function scanGivensOfNamedQuery(code: string | undefined, givens: ReadonlyArray<GivenInfo>, givensBySource: ReadonlyMap<string, ReadonlyArray<GivenInfo>> | undefined, unknownBySource?: ReadonlyMap<string, ReadonlySet<string>>): {
|
|
38
|
+
givens: GivenInfo[];
|
|
39
|
+
unknown: ReadonlySet<string>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The givens that matter on one source's page: those its own declaration reads
|
|
43
|
+
* (and the sources it extends, derives from or joins, which its queries run
|
|
44
|
+
* through — exported or not), plus the model-wide ones no source reads — a
|
|
45
|
+
* given used only by a top-level query, or by nothing yet, belongs to every
|
|
46
|
+
* page. Falls back to every given when the model's text is absent, when the
|
|
47
|
+
* source's declaration is not one this can find, and when the source builds on
|
|
48
|
+
* something the text doesn't declare (an imported source, a query, a
|
|
49
|
+
* `compose(…)`), whose reads it can't see: a page never hides a control it
|
|
50
|
+
* might need, and a run never goes out without a value it reads.
|
|
51
|
+
*/
|
|
52
|
+
export declare function givensForSource(sourceText: string | undefined, sourceName: string, givens: GivenInfo[]): GivenInfo[];
|
|
53
|
+
/**
|
|
54
|
+
* {@link givensForSource}, and which of the givens it returns the scan can't
|
|
55
|
+
* tie to the source either way (`unknown`), so the page can say a value set for
|
|
56
|
+
* one may not apply. Where it fell back to every given, that is each one the
|
|
57
|
+
* source's own text in this file doesn't read: a source built on an import that
|
|
58
|
+
* reads a given itself is known to read it. Empty where the scan could tell.
|
|
59
|
+
*/
|
|
60
|
+
export declare function scanGivensForSource(sourceText: string | undefined, sourceName: string, givens: GivenInfo[]): {
|
|
61
|
+
givens: GivenInfo[];
|
|
62
|
+
unknown: ReadonlySet<string>;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The givens a source's page shows only because a source it builds on reads
|
|
66
|
+
* them, where that source isn't one the page can open (the model doesn't
|
|
67
|
+
* export it): given name → the unexported sources that read it. A reader sees
|
|
68
|
+
* the control with no field on the page that uses it, so the section names
|
|
69
|
+
* where the given comes from.
|
|
70
|
+
*/
|
|
71
|
+
export declare function givensInheritedBy(sourceText: string | undefined, sourceName: string, givens: GivenInfo[], knownSources: ReadonlySet<string>): Map<string, string[]>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ReactNode, Context } from 'react';
|
|
2
|
+
import { RowLayer } from './rowLayers';
|
|
3
|
+
/**
|
|
4
|
+
* The source header's facts card, as the chips on its status row see it: which
|
|
5
|
+
* layer it is open on (none: shut), and how a chip opens or shuts it. Provided
|
|
6
|
+
* by HeaderBar; absent anywhere else, where a chip is only a tooltip.
|
|
7
|
+
*/
|
|
8
|
+
export interface HeaderCard {
|
|
9
|
+
openLayer: RowLayer | undefined;
|
|
10
|
+
/** The layers the card has facts for; a chip for any other stays a tooltip. */
|
|
11
|
+
layers: ReadonlyArray<RowLayer>;
|
|
12
|
+
toggle: (layer: RowLayer) => void;
|
|
13
|
+
cardId: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const HeaderCardContext: Context<HeaderCard>;
|
|
16
|
+
/**
|
|
17
|
+
* A status-row chip that is also the way into the facts behind it: the chip is a
|
|
18
|
+
* button, `aria-expanded` saying whether its card is open; the pointer and a
|
|
19
|
+
* shade on hover say it opens, and it stays shaded while open. A chip whose
|
|
20
|
+
* layer the card has no facts for (or outside the header) is the plain focusable
|
|
21
|
+
* chip it always was: a tab stop whose name is its meaning. So is a chip with no layer at all
|
|
22
|
+
* (a file's Public / Private), which has no facts to open, only its why.
|
|
23
|
+
*/
|
|
24
|
+
export declare function HeaderChip({ layer, title, children, testId, }: {
|
|
25
|
+
/** The card layer it opens; none for a chip that only says what it means. */
|
|
26
|
+
layer?: RowLayer;
|
|
27
|
+
/** The tooltip and accessible name: what the chip means. */
|
|
28
|
+
title: string;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
testId?: string;
|
|
31
|
+
}): import("react/jsx-runtime").JSX.Element;
|