@malloy-publisher/sdk 0.12.1 → 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-DrNhQ2_9.cjs.js → RenderedResult-Cgw4iqev.cjs.js} +1 -1
- package/dist/{RenderedResult-AyM-RQaA.es.js → RenderedResult-DEjFM1DL.es.js} +2 -2
- package/dist/ServerProvider-BRQl_cBo.cjs.js +1 -0
- package/dist/{ServerProvider-a9Ki0QXO.es.js → ServerProvider-RnliA2Ao.es.js} +577 -555
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +10 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +28 -27
- 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 +15 -1
- 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 +14281 -9879
- package/dist/useCompiledDocument-D88_2cGS.cjs.js +143 -0
- package/dist/{useCompiledDocument-Utj2u8CG.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/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/ReportBuilder/emptyStart.spec.ts +8 -0
- package/src/components/ReportBuilder/loadMalloy.ts +8 -1
- package/src/components/ServerProvider.tsx +27 -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-BvD7PYZ7.cjs.js +0 -1
- package/dist/useCompiledDocument-CRhFBKv_.cjs.js +0 -142
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
2
|
+
import { ReactNode, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Malloy, highlighted, in a read-only block: a field's definition, a view's
|
|
5
|
+
* code, the query a failed run sent. Plain text until the highlighter answers,
|
|
6
|
+
* so the code is readable on the first frame.
|
|
7
|
+
*/
|
|
8
|
+
export declare function QueryCode({ code, testId, framed, }: {
|
|
9
|
+
code: string;
|
|
10
|
+
testId?: string;
|
|
11
|
+
/** False: the code as one section of a card someone else frames (an open field row's). */
|
|
12
|
+
framed?: boolean;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
/** A read that failed, in place of what it would have shown, with a Retry where one can help. */
|
|
15
|
+
export declare function LoadErrorAlert({ message, onRetry, severity, }: {
|
|
16
|
+
message: ReactNode;
|
|
17
|
+
onRetry?: () => void;
|
|
18
|
+
severity?: "error" | "warning";
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/** The server's own reason for a failed request (its Error body's `message`), if it gave one. */
|
|
21
|
+
export declare function serverMessage(error: unknown): string | undefined;
|
|
22
|
+
/** The server's own reason for a failed request, else what was being done. */
|
|
23
|
+
export declare function describeApiError(context: string, error: unknown): string;
|
|
24
|
+
/**
|
|
25
|
+
* Can re-sending this query succeed? Not for a 400 (the query does not compile)
|
|
26
|
+
* or a 422 (a value it refuses), which hold until the query or the value
|
|
27
|
+
* changes, nor for a refusal (401/403/404).
|
|
28
|
+
*/
|
|
29
|
+
export declare function isRetryableQueryFailure(error: unknown): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* A failed query, wherever a result would have been. The query is shown
|
|
32
|
+
* verbatim above the error, so a compile error's `line:column` points into text
|
|
33
|
+
* the reader can see, and Retry is offered only when a second attempt can
|
|
34
|
+
* succeed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function QueryFailure({ query, error, onRetry, testId, forbiddenMessage, }: {
|
|
37
|
+
/** The query as it was sent; omitted when there is none to show. */
|
|
38
|
+
query?: string;
|
|
39
|
+
error: unknown;
|
|
40
|
+
onRetry?: () => void;
|
|
41
|
+
testId?: string;
|
|
42
|
+
/** What a refusal (403) says, where the caller knows the rule that refused it. */
|
|
43
|
+
forbiddenMessage?: string;
|
|
44
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
/** The one filled action on a card: Run. */
|
|
46
|
+
export declare const PrimaryButton: ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & RefAttributes<HTMLButtonElement>>;
|
|
47
|
+
/** A rounded, quiet button that opens a menu: the sources picker. */
|
|
48
|
+
export declare const PillButton: ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ExplorerField } from './schemaModel';
|
|
2
|
+
import { RunContext } from './useRunQuery';
|
|
3
|
+
export declare const SAMPLE_LIMIT = 12;
|
|
4
|
+
/** What a host's sample fetcher is asked for. */
|
|
5
|
+
export interface SampleValuesRequest {
|
|
6
|
+
modelPath: string;
|
|
7
|
+
sourceName: string;
|
|
8
|
+
fieldName: string;
|
|
9
|
+
/** At most this many values are shown. */
|
|
10
|
+
limit: number;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
/** What a host's sample fetcher can say beyond the values themselves. */
|
|
14
|
+
export interface SampleValuesPage {
|
|
15
|
+
/** The most common values, most common first. */
|
|
16
|
+
values: string[];
|
|
17
|
+
/** How many distinct values the dimension has, for the card's caption. */
|
|
18
|
+
total?: number | null;
|
|
19
|
+
/** Why there are none to show ("the index is still building"), said in their place. */
|
|
20
|
+
unavailable?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A host's way to read a dimension's sample values (an index it maintains, say)
|
|
24
|
+
* instead of the viewer's own query: the values alone, or a
|
|
25
|
+
* {@link SampleValuesPage}. Rejecting with a 4xx that says the field has nothing
|
|
26
|
+
* to sample reads as "no values" (see {@link isExpectedNoSamples}).
|
|
27
|
+
*/
|
|
28
|
+
export type SampleValuesFetcher = (request: SampleValuesRequest) => Promise<string[] | SampleValuesPage>;
|
|
29
|
+
interface UseDimensionSamplesArgs {
|
|
30
|
+
run: RunContext;
|
|
31
|
+
/** Model path the source belongs to (e.g. "flights.malloy"). */
|
|
32
|
+
modelPath: string;
|
|
33
|
+
/** Source the selected field belongs to. */
|
|
34
|
+
sourceName: string;
|
|
35
|
+
/** The field to sample, or null while the card is collapsed (hook idles). */
|
|
36
|
+
field: ExplorerField | null;
|
|
37
|
+
/** The host's fetcher; the viewer runs {@link sampleValuesQuery} without one. */
|
|
38
|
+
fetchSamples?: SampleValuesFetcher;
|
|
39
|
+
/** A host's build of the values it serves: a new one is a new cache entry,
|
|
40
|
+
* so a reopened row never shows the old values. */
|
|
41
|
+
generation?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether a rejected sample read is an answer that the dimension simply has
|
|
45
|
+
* nothing to sample, so the card says "no values" rather than "couldn't be
|
|
46
|
+
* loaded": a client error, except the ones that say nothing about the field (a
|
|
47
|
+
* lapsed session 401, a timeout 408, a rate limit 429). Every 5xx, and every
|
|
48
|
+
* rejection with no status (the network), is a read that failed.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isExpectedNoSamples(error: unknown): boolean;
|
|
51
|
+
/** The first column of each row of a result, as text. */
|
|
52
|
+
export declare function firstColumnValues(resultJson: string | undefined): string[];
|
|
53
|
+
/**
|
|
54
|
+
* Lazily fetch sample values for a dimension. Only for dimensions the model tags
|
|
55
|
+
* `#(index)` / `#(index_values)`: the tag is the modeler saying its values are
|
|
56
|
+
* worth listing, and without it opening a row costs nothing. Everything else
|
|
57
|
+
* resolves to "no samples", as does a host's refusal that answers the question.
|
|
58
|
+
* Any other error is reported as `failed`, never as an empty list: the card
|
|
59
|
+
* must not say there are no values when it could not ask.
|
|
60
|
+
*
|
|
61
|
+
* Without a host fetcher this is one capped `group_by` query through the
|
|
62
|
+
* Publisher, run as a view's is (`runQueryOptions`: the same request, cache
|
|
63
|
+
* and `onQueryRun`), with the given values of the givens its source reads, and
|
|
64
|
+
* gated the same way. Shared by every mount: opening, shutting and reopening a
|
|
65
|
+
* row reads it once.
|
|
66
|
+
*/
|
|
67
|
+
export declare function useDimensionSamples({ run, modelPath, sourceName, field, fetchSamples, generation, }: UseDimensionSamplesArgs): {
|
|
68
|
+
samples: string[];
|
|
69
|
+
/** How many distinct values there are, when a host says. */
|
|
70
|
+
total?: number | null;
|
|
71
|
+
/** Why there are none: a host's reason, or the given a run needs first. */
|
|
72
|
+
unavailable?: string;
|
|
73
|
+
loading: boolean;
|
|
74
|
+
failed: boolean;
|
|
75
|
+
};
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { GivenInfo } from './modelGivens';
|
|
2
|
+
import { SourceAccess } from './sourceAccess';
|
|
3
|
+
import { useServer } from '../ServerProvider';
|
|
4
|
+
import { RefetchOptions, QueryObserverResult } from '@tanstack/query-core';
|
|
5
|
+
import type * as Malloy from "@malloydata/malloy-interfaces";
|
|
6
|
+
/** A model's named queries, as the publisher lists them on `CompiledModel.queries`. */
|
|
7
|
+
export interface ModelNamedQuery {
|
|
8
|
+
name?: string;
|
|
9
|
+
sourceName?: string;
|
|
10
|
+
annotations?: string[];
|
|
11
|
+
}
|
|
12
|
+
/** What the viewer keeps of a compiled model. */
|
|
13
|
+
export interface CompiledModelData {
|
|
14
|
+
sourceInfos: Malloy.SourceInfo[];
|
|
15
|
+
queries: ModelNamedQuery[];
|
|
16
|
+
/** The model file's Malloy text. Newer publishers return it on the compiled
|
|
17
|
+
* model (`sourceText`); older ones don't, and the SDK's type predates it,
|
|
18
|
+
* so it is read structurally and stays undefined when absent — the code
|
|
19
|
+
* view says so rather than showing an empty file. A SHAPE check, not a
|
|
20
|
+
* cast: through the router a declared-but-unsent field arrives as `null`,
|
|
21
|
+
* which must read as absent too. */
|
|
22
|
+
sourceText?: string;
|
|
23
|
+
/** The model's declared givens (shape-checked by extractCompiledModelGivens),
|
|
24
|
+
* so a run can say which defaults it used, or that it can't run without a
|
|
25
|
+
* value. */
|
|
26
|
+
givens: GivenInfo[];
|
|
27
|
+
/** Source name → its `#(authorize)` / `#(access_filter)` declarations (the
|
|
28
|
+
* compiled model's `sources[]`), for every source that declares either. */
|
|
29
|
+
access: ReadonlyMap<string, SourceAccess>;
|
|
30
|
+
/** The model file's own description (`##(doc)` / `##"`), from `modelInfo`. */
|
|
31
|
+
modelDoc?: string;
|
|
32
|
+
/** The model imports other files: an import-only model's page says why it
|
|
33
|
+
* is empty rather than reading as broken. */
|
|
34
|
+
hasImports: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The model's own doc: from the compiled model's `modelInfo` (a JSON string of
|
|
38
|
+
* Malloy's `ModelInfo`) where it carries the model's annotations, else from the
|
|
39
|
+
* model file's text. The publisher's `modelInfo` leaves `annotations` out today,
|
|
40
|
+
* and a `##` line is a model annotation wherever it sits at the top level, so
|
|
41
|
+
* the text answers the same question. Undefined when neither has one.
|
|
42
|
+
*/
|
|
43
|
+
export declare function modelDocOf(modelInfo: unknown, sourceText: string | undefined): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The one shaping of a compiled-model response, for both hooks below: they
|
|
46
|
+
* share a cache key, so they must store one shape, and a function is a
|
|
47
|
+
* guarantee where a comment was not.
|
|
48
|
+
*/
|
|
49
|
+
export declare function fetchCompiledModel(apiClients: ReturnType<typeof useServer>["apiClients"], projectName: string, packageName: string, modelPath: string, versionId?: string, includeHiddenFilesAndSources?: boolean): Promise<CompiledModelData>;
|
|
50
|
+
/**
|
|
51
|
+
* The viewer's cache key for a compiled model, for a host that reads the same
|
|
52
|
+
* model (and shares the one compile), or refreshes it after a republish.
|
|
53
|
+
* A hidden file's read is its own entry: the curated read's 404 must never be
|
|
54
|
+
* served in its place, nor its text to a reader who can't edit the package.
|
|
55
|
+
*/
|
|
56
|
+
export declare function modelQueryKey(projectName: string, packageName: string, modelPath: string, versionId?: string, includeHiddenFilesAndSources?: boolean): readonly unknown[];
|
|
57
|
+
/**
|
|
58
|
+
* A compiled model's query: its one cache key and fetch, for every reader of a
|
|
59
|
+
* compiled model. Compiling is server work, so
|
|
60
|
+
* a pinned version — which can't change — is kept for the page's life; `latest`
|
|
61
|
+
* goes stale like any other read.
|
|
62
|
+
*/
|
|
63
|
+
export declare function compiledModelQuery(apiClients: ReturnType<typeof useServer>["apiClients"], projectName: string, packageName: string, modelPath: string, versionId?: string, includeHiddenFilesAndSources?: boolean): {
|
|
64
|
+
staleTime?: number;
|
|
65
|
+
queryKey: readonly unknown[];
|
|
66
|
+
queryFn: () => Promise<CompiledModelData>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Fetch the compiled sources for a published model and parse them into
|
|
70
|
+
* `Malloy.SourceInfo` objects (`sourceInfos` is an array of JSON strings). The same
|
|
71
|
+
* response lists the model's named queries, so they ride along rather than
|
|
72
|
+
* costing a second fetch of the compiled model.
|
|
73
|
+
*/
|
|
74
|
+
export declare function useModelSources(projectName: string, packageName: string, modelPath: string, versionId?: string,
|
|
75
|
+
/** False holds the read, e.g. until the page has resolved `latest` to the
|
|
76
|
+
* version it will read everything at. */
|
|
77
|
+
enabled?: boolean,
|
|
78
|
+
/** Read a file the package's `index.malloy` hides, for a reader who can
|
|
79
|
+
* edit the package; anyone else is refused. */
|
|
80
|
+
includeHiddenFilesAndSources?: boolean): {
|
|
81
|
+
sources: Malloy.SourceInfo[];
|
|
82
|
+
queries: ModelNamedQuery[];
|
|
83
|
+
sourceText: string;
|
|
84
|
+
givens: GivenInfo[];
|
|
85
|
+
access: ReadonlyMap<string, SourceAccess>;
|
|
86
|
+
modelDoc: string;
|
|
87
|
+
hasImports: boolean;
|
|
88
|
+
isLoading: boolean;
|
|
89
|
+
isError: boolean;
|
|
90
|
+
error: Error | null;
|
|
91
|
+
refetch: (options?: RefetchOptions) => Promise< QueryObserverResult<CompiledModelData, Error>>;
|
|
92
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ApiClients } from '../ServerProvider';
|
|
2
|
+
import { GivenInfo, GivenRequest } from './modelGivens';
|
|
3
|
+
import { SourceAccess } from './sourceAccess';
|
|
4
|
+
import { RefetchOptions, QueryObserverResult } from '@tanstack/query-core';
|
|
5
|
+
import { AxiosResponse } from 'axios';
|
|
6
|
+
import { QueryResult } from '../../client';
|
|
7
|
+
/** How one run ended, for a host that counts them. */
|
|
8
|
+
export interface QueryRunEvent {
|
|
9
|
+
outcome: "success" | "error";
|
|
10
|
+
durationMs: number;
|
|
11
|
+
}
|
|
12
|
+
/** What a run needs to address the served model: the same coordinates the
|
|
13
|
+
* explorer already reads the model's metadata with. */
|
|
14
|
+
export interface RunContext {
|
|
15
|
+
projectName: string;
|
|
16
|
+
packageName: string;
|
|
17
|
+
versionId?: string;
|
|
18
|
+
/** The model's declared givens — the declarations runGate reads to name a
|
|
19
|
+
* default a run fell back to, or to refuse where a blank one has none. The
|
|
20
|
+
* values a run sends are `givenValues` below. */
|
|
21
|
+
givens?: ReadonlyArray<GivenInfo>;
|
|
22
|
+
/** Source name → the givens a run on that source can use (givensForSource):
|
|
23
|
+
* what its declaration reads, plus the model-wide ones no source reads. The
|
|
24
|
+
* page's Givens section shows the same set, so a gate never asks for a given
|
|
25
|
+
* that section can't set. */
|
|
26
|
+
givensBySource?: ReadonlyMap<string, GivenInfo[]>;
|
|
27
|
+
/** Source name → the givens in `givensBySource` the scan can't tie to it
|
|
28
|
+
* either way (scanGivensForSource), for a source built on what its file
|
|
29
|
+
* doesn't declare: a run's card says it ran with them only where the source
|
|
30
|
+
* reads them. */
|
|
31
|
+
unknownGivensBySource?: ReadonlyMap<string, ReadonlySet<string>>;
|
|
32
|
+
/** Source name → labels of its `#(filter … required)` filters; a run can't
|
|
33
|
+
* supply them, so it refuses rather than 400. */
|
|
34
|
+
requiredFiltersBySource?: ReadonlyMap<string, string[]>;
|
|
35
|
+
/** Given values the reader set in the page's Givens section, in the request
|
|
36
|
+
* form a dashboard sends (`givensRequest`: typed, unset ones left out), sent
|
|
37
|
+
* with every run and part of its cache key (givensKeyFor). */
|
|
38
|
+
givenValues?: GivenRequest;
|
|
39
|
+
/** Run a file the package's index.malloy hides, for someone who can edit the
|
|
40
|
+
* package (offSurface.tsx). Anyone else is refused. */
|
|
41
|
+
includeHiddenFilesAndSources?: boolean;
|
|
42
|
+
/** Source name → its access declarations, so a refused run can say which
|
|
43
|
+
* rule refused it rather than a bare "no access". */
|
|
44
|
+
accessBySource?: ReadonlyMap<string, SourceAccess>;
|
|
45
|
+
/** Labels every run carries (`QueryRequest.queryMetadata`), for a host that
|
|
46
|
+
* tags its traffic by the surface it came from. */
|
|
47
|
+
queryMetadata?: Readonly<Record<string, string>>;
|
|
48
|
+
/** Called once per run that settles; a run the reader left is not reported. */
|
|
49
|
+
onQueryRun?: (event: QueryRunEvent) => void;
|
|
50
|
+
/** A result larger than this (bytes) is held behind a warning before it renders. */
|
|
51
|
+
maxResultSize?: number;
|
|
52
|
+
}
|
|
53
|
+
/** The givens a run on `sourceName` reads — the model's own for a named query. */
|
|
54
|
+
export declare function givensOfRun(run: Pick<RunContext, "givens" | "givensBySource">, sourceName: string | undefined): ReadonlyArray<GivenInfo> | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The run as one view, query or sample read sends it: with the given values of
|
|
57
|
+
* the givens it reads alone (`givens`, from {@link givensOfRun}, the set its
|
|
58
|
+
* gate and its source's Givens section use). A value set for a given it doesn't
|
|
59
|
+
* read neither reaches its request nor changes its cache key, so changing one
|
|
60
|
+
* leaves its result current rather than paying for the same query again.
|
|
61
|
+
*/
|
|
62
|
+
export declare function runReading(run: RunContext, givens: ReadonlyArray<GivenInfo> | undefined): RunContext;
|
|
63
|
+
/**
|
|
64
|
+
* Run one Malloy query against a published model and hand back the publisher's
|
|
65
|
+
* `Result` JSON for `RenderedResult`: `executeQueryModel` with the query text,
|
|
66
|
+
* keyed by everything that decides its answer.
|
|
67
|
+
*
|
|
68
|
+
* Idle until `enabled`: browsing a source must cost nothing; a run happens on a
|
|
69
|
+
* click. And a result, once fetched, is final for this query text and version:
|
|
70
|
+
* it never goes stale and never refetches on focus or remount. Re-running is
|
|
71
|
+
* the card's own explicit control (`refetch`), because a warehouse query is
|
|
72
|
+
* billed.
|
|
73
|
+
*/
|
|
74
|
+
export declare function useRunQuery({ run, modelPath, query, enabled, }: {
|
|
75
|
+
run: RunContext;
|
|
76
|
+
modelPath: string;
|
|
77
|
+
query: string;
|
|
78
|
+
enabled: boolean;
|
|
79
|
+
}): {
|
|
80
|
+
result: string;
|
|
81
|
+
isSuccess: boolean;
|
|
82
|
+
isLoading: boolean;
|
|
83
|
+
isFetching: boolean;
|
|
84
|
+
isError: boolean;
|
|
85
|
+
error: Error;
|
|
86
|
+
refetch: (options?: RefetchOptions) => Promise< QueryObserverResult<AxiosResponse<QueryResult, any, {}, any>, Error>>;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The viewer's cache key for one run (a view's, a named query's), for a host
|
|
90
|
+
* that refreshes it or runs the same query itself (a download, say).
|
|
91
|
+
*/
|
|
92
|
+
export declare function runQueryKey(server: string, run: Pick<RunContext, "projectName" | "packageName" | "versionId" | "givenValues" | "includeHiddenFilesAndSources">, modelPath: string, query: string): readonly unknown[];
|
|
93
|
+
/**
|
|
94
|
+
* A viewer run's cache key, request and caching, apart from the hook, so a host
|
|
95
|
+
* that runs the same query (a download, say) reuses a result the reader already
|
|
96
|
+
* ran, and one it runs is cached for the reader to open without paying again.
|
|
97
|
+
*
|
|
98
|
+
* A run is kept until the page goes (`staleTime: Infinity`): its inputs are all in
|
|
99
|
+
* the key. A failed run is reported in place with its own Retry, so it never
|
|
100
|
+
* retries silently — that would re-bill a query the reader can see failed.
|
|
101
|
+
*/
|
|
102
|
+
export declare function runQueryOptions({ server, apiClients, run, modelPath, query, }: {
|
|
103
|
+
server: string;
|
|
104
|
+
apiClients: ApiClients;
|
|
105
|
+
run: RunContext;
|
|
106
|
+
modelPath: string;
|
|
107
|
+
query: string;
|
|
108
|
+
}): {
|
|
109
|
+
readonly queryKey: readonly unknown[];
|
|
110
|
+
readonly queryFn: ({ signal }: {
|
|
111
|
+
signal?: AbortSignal;
|
|
112
|
+
}) => Promise< AxiosResponse<QueryResult, any, {}, any>>;
|
|
113
|
+
readonly staleTime: number;
|
|
114
|
+
readonly retry: false;
|
|
115
|
+
};
|
|
@@ -11,5 +11,9 @@ export declare const unwrapQueryBuilder: (ns: QueryBuilder) => QueryBuilder;
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function loadMalloy(): Promise<Malloy>;
|
|
13
13
|
export declare function loadMalloyTag(): Promise<MalloyTag>;
|
|
14
|
+
/**
|
|
15
|
+
* The Explorer's query builder, for `SourcesExplorer` alone: ESLint lets only
|
|
16
|
+
* the Explorer's callers import this (`EXPLORER_CALLERS`).
|
|
17
|
+
*/
|
|
14
18
|
export declare function loadQueryBuilder(): Promise<QueryBuilder>;
|
|
15
19
|
export {};
|
|
@@ -2,12 +2,18 @@ import { default as React, ReactNode } from 'react';
|
|
|
2
2
|
import { ConnectionsApi, DashboardsApi, DataAppsApi, DatabasesApi, EnvironmentsApi, MaterializationsApi, ModelsApi, NotebooksApi, PackagesApi, AgentsApi, PublisherApi, ReportsApi, VersionsApi, WatchModeApi } from '../client';
|
|
3
3
|
import { ReportUiOverrides } from '../theme/ui';
|
|
4
4
|
import { Theme } from '../theme/types';
|
|
5
|
+
import { ModelPage } from './modelPage';
|
|
6
|
+
export type { ModelPage };
|
|
5
7
|
export interface ServerContextValue {
|
|
6
8
|
server: string;
|
|
7
9
|
getAccessToken?: () => Promise<string>;
|
|
8
10
|
apiClients: ApiClients;
|
|
9
11
|
/** `undefined` while `/status` loads (or failed) and the host passed no `mutable`. */
|
|
10
12
|
mutable: boolean | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* `/status` has neither answered nor failed yet, including while a retry is
|
|
15
|
+
* paused (offline, or a hidden tab).
|
|
16
|
+
*/
|
|
11
17
|
isLoadingStatus: boolean;
|
|
12
18
|
/**
|
|
13
19
|
* Instance-wide default theme, pulled from the `/api/v0/status` response.
|
|
@@ -15,6 +21,15 @@ export interface ServerContextValue {
|
|
|
15
21
|
* theme in `publisher.config.json`.
|
|
16
22
|
*/
|
|
17
23
|
instanceTheme?: Theme;
|
|
24
|
+
/**
|
|
25
|
+
* Which page `Model` shows, the server's `PUBLISHER_MODEL_PAGE` from
|
|
26
|
+
* `/status`: `explorer`, the Malloy Explorer, unless the server says
|
|
27
|
+
* `viewer`, and `viewer` when `/status` could not be read (see
|
|
28
|
+
* `modelPageOf`). `explorer` while `/status` loads and from a server
|
|
29
|
+
* that predates the setting, so wait on `isLoadingStatus` before showing
|
|
30
|
+
* anything the Explorer would replace.
|
|
31
|
+
*/
|
|
32
|
+
modelPage: ModelPage;
|
|
18
33
|
}
|
|
19
34
|
export interface ServerProviderProps {
|
|
20
35
|
children: ReactNode;
|
|
@@ -76,4 +91,3 @@ export type ApiClients = ReturnType<typeof getApiClients>;
|
|
|
76
91
|
*/
|
|
77
92
|
export declare const ServerProvider: React.FC<ServerProviderProps>;
|
|
78
93
|
export declare const useServer: () => ServerContextValue;
|
|
79
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DimensionSpec, FilterType } from '../../hooks/useDimensionalFilterRangeData';
|
|
2
2
|
import { FilterSelection } from '../../hooks/useDimensionFilters';
|
|
3
|
-
import * as Malloy from "@malloydata/malloy-interfaces";
|
|
3
|
+
import type * as Malloy from "@malloydata/malloy-interfaces";
|
|
4
4
|
/**
|
|
5
5
|
* A single filter specification with source and dimension
|
|
6
6
|
* Parsed from "source.dimension" string format
|
|
@@ -40,6 +40,12 @@ export interface GivenInputProps {
|
|
|
40
40
|
* that was cut off. Absent, typing filters `options` in the browser.
|
|
41
41
|
*/
|
|
42
42
|
optionSearch?: OptionSearch;
|
|
43
|
+
/**
|
|
44
|
+
* The control is opening, for a caller that fetches `options` only when
|
|
45
|
+
* one is wanted (see `useSuggestOptions`' `only`). Called by a picker's
|
|
46
|
+
* list and by a filter button's popover; harmless to call again.
|
|
47
|
+
*/
|
|
48
|
+
onOpen?: () => void;
|
|
43
49
|
}
|
|
44
50
|
/**
|
|
45
51
|
* Renders an input widget appropriate for the declared given type.
|
|
@@ -61,7 +67,7 @@ export interface GivenInputProps {
|
|
|
61
67
|
* `Default: …` helper line on every widget — including the boolean checkbox,
|
|
62
68
|
* which gets a wrapping FormControl for the slot.
|
|
63
69
|
*/
|
|
64
|
-
export declare function GivenInput({ given, value, onChange, options, optionsLoading, optionsFailed, optionsTruncated, optionSearch, }: GivenInputProps): import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
export declare function GivenInput({ given, value, onChange, options, optionsLoading, optionsFailed, optionsTruncated, optionSearch, onOpen, }: GivenInputProps): import("react/jsx-runtime").JSX.Element;
|
|
65
71
|
/**
|
|
66
72
|
* What the dropdown says about its options, if anything. Only a cut-off list
|
|
67
73
|
* has something to say: a whole list needs no footnote.
|
|
@@ -45,6 +45,8 @@ export interface GivensPanelProps {
|
|
|
45
45
|
};
|
|
46
46
|
/** Overrides the `panel` layout's "Filters" heading. */
|
|
47
47
|
title?: string;
|
|
48
|
+
/** A control is opening: for options fetched only once one is wanted. */
|
|
49
|
+
onControlOpen?: (name: string) => void;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* Renders the control row: one input per declared `given:`.
|
|
@@ -56,4 +58,4 @@ export interface GivensPanelProps {
|
|
|
56
58
|
* puts the document's starting values back rather than emptying the row, so the
|
|
57
59
|
* button and the state agree on what "Reset" means.
|
|
58
60
|
*/
|
|
59
|
-
export declare function GivensPanel({ givens, values, onChange, onReset, canReset, layout, options, optionsLoading, optionsFailed, optionsTruncated, optionSearch, apply, title, }: GivensPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
export declare function GivensPanel({ givens, values, onChange, onReset, canReset, layout, options, optionsLoading, optionsFailed, optionsTruncated, optionSearch, apply, title, onControlOpen, }: GivensPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,3 +7,9 @@ import { GivenValue } from '../../hooks/givenValue';
|
|
|
7
7
|
* is rather than a hint under the control. The full value is the popover's.
|
|
8
8
|
*/
|
|
9
9
|
export declare function summarizeGivenValue(given: Given, value: GivenValue | undefined): string;
|
|
10
|
+
/**
|
|
11
|
+
* A given's value in the same words, but whole: every picked value and no
|
|
12
|
+
* cut-off text. For a record of what produced a result, where nothing else
|
|
13
|
+
* holds the full value.
|
|
14
|
+
*/
|
|
15
|
+
export declare function describeGivenValue(given: Given, value: GivenValue | undefined): string;
|
|
@@ -6,6 +6,12 @@ export interface UseGivenUrlParamsResult {
|
|
|
6
6
|
* query string, in place, leaving every parameter that is not a given alone.
|
|
7
7
|
*/
|
|
8
8
|
onGivensChange: (next: Record<string, string>, managed: readonly string[]) => void;
|
|
9
|
+
/**
|
|
10
|
+
* One parameter of the host's own (the source on screen, say), written the
|
|
11
|
+
* same way: merged into the query string, in place, keeping the fragment;
|
|
12
|
+
* `undefined` removes it.
|
|
13
|
+
*/
|
|
14
|
+
setParam: (name: string, value: string | undefined) => void;
|
|
9
15
|
}
|
|
10
16
|
/**
|
|
11
17
|
* Keep a document's control values in the page's query string, so a filtered
|
|
@@ -35,5 +41,10 @@ export interface UseGivenUrlParamsResult {
|
|
|
35
41
|
* every value tried. And a navigation that names only `search` resolves to an
|
|
36
42
|
* empty fragment, which dropped whatever anchor the reader arrived on;
|
|
37
43
|
* `setSearchParams` has that problem, which is why this navigates itself.
|
|
44
|
+
* A host's own parameter goes through the same write (`setParam`).
|
|
45
|
+
* - **Writes in one tick build on each other.** Each starts from the query
|
|
46
|
+
* string the last one wrote while the router has yet to commit it, not from
|
|
47
|
+
* the location this render saw, so a given's report beside a source pick
|
|
48
|
+
* keeps both.
|
|
38
49
|
*/
|
|
39
50
|
export declare function useGivenUrlParams(): UseGivenUrlParamsResult;
|
|
@@ -19,6 +19,7 @@ export * from './Home';
|
|
|
19
19
|
export * from './Loading';
|
|
20
20
|
export * from './Materializations';
|
|
21
21
|
export * from './Model';
|
|
22
|
+
export * from './ModelViewer';
|
|
22
23
|
export * from './Package';
|
|
23
24
|
export { Prose, type ProseLinkContext, type ProseProps, type ProseVariant, } from './Prose';
|
|
24
25
|
export * from './QueryResult';
|
|
@@ -26,5 +27,5 @@ export * from './RenderedResult';
|
|
|
26
27
|
export * from './Report';
|
|
27
28
|
export * from './legacy';
|
|
28
29
|
export { ServerProvider, useServer } from './ServerProvider';
|
|
29
|
-
export type { ServerContextValue, ServerProviderProps } from './ServerProvider';
|
|
30
|
+
export type { ModelPage, ServerContextValue, ServerProviderProps, } from './ServerProvider';
|
|
30
31
|
export * from './DocumentStorage';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model page a server asks for, its `PUBLISHER_MODEL_PAGE`. The Explorer
|
|
3
|
+
* writes the queries it builds back to Malloy text with string values unescaped
|
|
4
|
+
* (`escapeString` in `@malloydata/malloy-interfaces` is a TODO), so a drilled
|
|
5
|
+
* value holding a double quote rewrites its query; `viewer` shows a page that
|
|
6
|
+
* builds none.
|
|
7
|
+
*/
|
|
8
|
+
export type ModelPage = "explorer" | "viewer";
|
|
9
|
+
/**
|
|
10
|
+
* The page to show, from what `/status` answered: `viewer` when it says so, and
|
|
11
|
+
* when it could not be read at all, since a deployment that chose `viewer` has
|
|
12
|
+
* chosen not to show the Explorer and the viewer writes no value into Malloy on
|
|
13
|
+
* any server. `explorer` otherwise, a server that predates the setting
|
|
14
|
+
* included. While `/status` is still loading this says `explorer`; a caller
|
|
15
|
+
* that would draw the Explorer waits on loading first.
|
|
16
|
+
*/
|
|
17
|
+
export declare function modelPageOf(status: {
|
|
18
|
+
modelPage?: unknown;
|
|
19
|
+
} | undefined, failed: boolean): ModelPage;
|
|
20
|
+
/**
|
|
21
|
+
* The model page, and whether to wait for it, from the `/status` query as
|
|
22
|
+
* react-query reports it. It waits while the query is pending, with no answer
|
|
23
|
+
* and no error yet, which includes a retry paused offline or in a hidden tab:
|
|
24
|
+
* there react-query's `isLoading` is false although nothing has answered, and
|
|
25
|
+
* a `viewer` server would draw the Explorer.
|
|
26
|
+
*/
|
|
27
|
+
export declare function modelPageState(query: {
|
|
28
|
+
data: {
|
|
29
|
+
modelPage?: unknown;
|
|
30
|
+
} | undefined;
|
|
31
|
+
isPending: boolean;
|
|
32
|
+
isError: boolean;
|
|
33
|
+
}): {
|
|
34
|
+
modelPage: ModelPage;
|
|
35
|
+
isLoadingStatus: boolean;
|
|
36
|
+
};
|
|
@@ -92,6 +92,15 @@ export interface DimensionalFilterRangeDataResult {
|
|
|
92
92
|
/** Refetch function to manually trigger the query */
|
|
93
93
|
refetch: () => void;
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Builds a Malloy index query to fetch dimension values for a single source
|
|
97
|
+
* Uses Malloy's built-in index operator for dimensional search
|
|
98
|
+
* Reference: https://docs.malloydata.dev/documentation/patterns/dim_index
|
|
99
|
+
*
|
|
100
|
+
* Exported for its spec: the active filters are written by `filterCondition`,
|
|
101
|
+
* the same as the result rows' query, so both agree on what a filter matches.
|
|
102
|
+
*/
|
|
103
|
+
export declare function buildDimensionalIndexQuery(source: string, dimensionSpecs: DimensionSpec[], indexLimit: number, activeFilters?: FilterSelection[]): string;
|
|
95
104
|
/**
|
|
96
105
|
* Custom hook to fetch dimensional filter values from a Malloy model
|
|
97
106
|
*
|
|
@@ -50,7 +50,19 @@ export interface OptionSearch {
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function buildSuggestQuery(source: string, dimension: string,
|
|
52
52
|
/** Text the values must contain, ignoring case: a search of a truncated list. */
|
|
53
|
-
search?: string): string;
|
|
53
|
+
search?: string, options?: SuggestQueryOptions): string;
|
|
54
|
+
/** How {@link buildSuggestQuery} writes its names. */
|
|
55
|
+
export interface SuggestQueryOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Backtick-quote every name (the source, each segment of the dimension's
|
|
58
|
+
* path, the output column), so a reserved word (`year`, `source`) or a name
|
|
59
|
+
* with a space is still read as a name. Off, the names are written as the
|
|
60
|
+
* `suggest` gave them, as before; a keyword then fails the query. On for a
|
|
61
|
+
* server whose `PUBLISHER_MODEL_PAGE` is `viewer`, and always in the model
|
|
62
|
+
* viewer.
|
|
63
|
+
*/
|
|
64
|
+
quoteNames?: boolean;
|
|
65
|
+
}
|
|
54
66
|
/**
|
|
55
67
|
* Text as a Malloy string literal, whatever it holds: a backslash and a
|
|
56
68
|
* single quote escaped, in that order, so neither can end the literal early.
|
|
@@ -110,7 +122,19 @@ applied?: AppliedGivens,
|
|
|
110
122
|
* Text-source mode: the document's definitions, sent ahead of the suggest as
|
|
111
123
|
* the viewer's own text. Absent, a suggest runs by name or by view as before.
|
|
112
124
|
*/
|
|
113
|
-
preamble?: string
|
|
125
|
+
preamble?: string,
|
|
126
|
+
/**
|
|
127
|
+
* Only these givens' options are fetched, for a page that loads a picker's
|
|
128
|
+
* list when it is opened rather than on render (the model viewer, where
|
|
129
|
+
* nothing runs until the reader asks). Absent, every picker's list is.
|
|
130
|
+
*/
|
|
131
|
+
only?: ReadonlySet<string>,
|
|
132
|
+
/**
|
|
133
|
+
* Quote every name in a generated suggest query (see
|
|
134
|
+
* {@link SuggestQueryOptions}). Absent, the server's model page decides:
|
|
135
|
+
* quoted on a `viewer` server, written as given otherwise.
|
|
136
|
+
*/
|
|
137
|
+
quoteNames?: boolean): {
|
|
114
138
|
options: Map<string, string[]>;
|
|
115
139
|
isLoading: boolean;
|
|
116
140
|
/**
|