@malloy-publisher/sdk 0.2.7 → 0.3.1
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 +180 -204
- package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +134 -0
- package/dist/DocumentStorageProvider-tGvodI8f.es.js +24268 -0
- package/dist/RenderedResult-CPi6uQWq.cjs.js +115 -0
- package/dist/RenderedResult-mDE-4u8S.es.js +542 -0
- package/dist/{ServerProvider-xXW1HJOJ.cjs.js → ServerProvider-CH71GsoL.cjs.js} +1 -1
- package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-X2Ma0HRs.es.js} +324 -359
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9561 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +13 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/ApiErrorDisplay.d.ts +1 -2
- package/dist/components/Dashboard/Dashboard.d.ts +23 -16
- package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
- package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
- package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
- package/dist/components/Dashboard/TileCard.d.ts +44 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +40 -0
- package/dist/components/Dashboard/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +112 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +32 -0
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
- package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
- package/dist/components/DashboardBuilder/controls.d.ts +157 -0
- package/dist/components/DashboardBuilder/diff.d.ts +35 -0
- package/dist/components/DashboardBuilder/document.d.ts +218 -0
- package/dist/components/DashboardBuilder/layout.d.ts +71 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
- package/dist/components/DashboardBuilder/preview.d.ts +60 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +44 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
- package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +14 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +58 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +25 -0
- package/dist/components/DocumentStorage/index.d.ts +3 -0
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/Model/index.d.ts +0 -1
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +2 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
- package/dist/components/drill/index.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/drill/useDrillSelf.d.ts +46 -0
- package/dist/components/given/filterValue.d.ts +63 -0
- package/dist/components/given/index.d.ts +1 -0
- package/dist/components/given/useGivenUrlParams.d.ts +39 -0
- package/dist/components/index.d.ts +3 -3
- package/dist/components/styles.d.ts +3 -7
- package/dist/core-8NVBCLZh.cjs.js +148 -0
- package/dist/{core-BY7vB5gN.es.js → core-B8oMW4sm.es.js} +3540 -2335
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/hooks/useSuggestOptions.d.ts +28 -12
- package/dist/index.cjs.js +34 -1
- package/dist/index.es.js +21487 -79
- package/dist/sdk.css +1 -1
- package/dist/styles.css +0 -1
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/package.json +25 -14
- package/src/builder-entry.ts +55 -0
- package/src/components/ApiErrorDisplay.tsx +1 -1
- package/src/components/Connections/EditConnectionDialog.tsx +96 -86
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +184 -229
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +67 -101
- package/src/components/Dashboard/ExploreDialog.tsx +84 -0
- package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
- package/src/components/Dashboard/RowsDialog.tsx +234 -0
- package/src/components/Dashboard/TileCard.tsx +120 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +207 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +160 -0
- package/src/components/Dashboard/telemetry.ts +44 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +249 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +270 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +858 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +653 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +211 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +493 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +129 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +281 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +581 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +125 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
- package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
- package/src/components/DashboardBuilder/catalog.ts +225 -0
- package/src/components/DashboardBuilder/controls.spec.ts +243 -0
- package/src/components/DashboardBuilder/controls.ts +398 -0
- package/src/components/DashboardBuilder/diff.spec.ts +44 -0
- package/src/components/DashboardBuilder/diff.ts +93 -0
- package/src/components/DashboardBuilder/document.ts +209 -0
- package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
- package/src/components/DashboardBuilder/layout.ts +143 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
- package/src/components/DashboardBuilder/malloyText.ts +151 -0
- package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
- package/src/components/DashboardBuilder/preview.spec.ts +149 -0
- package/src/components/DashboardBuilder/preview.ts +172 -0
- package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
- package/src/components/DashboardBuilder/readDocument.ts +467 -0
- package/src/components/DashboardBuilder/sortable.tsx +151 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +1108 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1098 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +255 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +193 -0
- package/src/components/DashboardBuilder/useDraft.ts +43 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
- package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
- package/src/components/DashboardBuilder/useTileResize.ts +110 -0
- package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +81 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +105 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +73 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +58 -0
- package/src/components/DocumentStorage/index.ts +16 -0
- package/src/components/Environment/About.tsx +4 -36
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +34 -72
- package/src/components/Model/index.ts +0 -1
- package/src/components/Notebook/Notebook.tsx +27 -156
- package/src/components/Notebook/NotebookCell.tsx +37 -191
- package/src/components/Prose.spec.tsx +85 -0
- package/src/components/Prose.tsx +179 -0
- package/src/components/QueryResult/QueryResult.tsx +15 -43
- package/src/components/RenderedResult/RenderedResult.tsx +86 -76
- package/src/components/RenderedResult/ResultContainer.tsx +25 -36
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +16 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +249 -0
- package/src/components/RenderedResult/resultSizing.ts +308 -0
- package/src/components/ResultsDialog.tsx +2 -1
- package/src/components/drill/index.ts +6 -0
- package/src/components/drill/resolveDrill.ts +22 -1
- package/src/components/drill/useDrill.spec.tsx +94 -0
- package/src/components/drill/useDrill.tsx +52 -12
- package/src/components/drill/useDrillSelf.spec.tsx +64 -0
- package/src/components/drill/useDrillSelf.ts +110 -0
- package/src/components/given/GivenInput.spec.tsx +196 -2
- package/src/components/given/GivenInput.tsx +300 -25
- package/src/components/given/GivensPanel.tsx +1 -1
- package/src/components/given/filterValue.spec.ts +112 -0
- package/src/components/given/filterValue.ts +188 -0
- package/src/components/given/index.ts +4 -0
- package/src/components/given/useGivenUrlParams.spec.tsx +74 -0
- package/src/components/given/useGivenUrlParams.ts +87 -0
- package/src/components/index.ts +11 -3
- package/src/components/styles.ts +0 -37
- package/src/hooks/index.ts +13 -1
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useGivensState.spec.ts +158 -0
- package/src/hooks/useGivensState.ts +114 -23
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
- package/src/hooks/useSuggestOptions.ts +94 -51
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/vite.config.ts +5 -1
- package/dist/components/AnalyzePackageButton.d.ts +0 -6
- package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +0 -9
- package/dist/components/Workbook/EditableMalloyCell.d.ts +0 -11
- package/dist/components/Workbook/ModelPicker.d.ts +0 -11
- package/dist/components/Workbook/MutableCell.d.ts +0 -17
- package/dist/components/Workbook/Workbook.d.ts +0 -7
- package/dist/components/Workbook/WorkbookList.d.ts +0 -7
- package/dist/components/Workbook/WorkbookManager.d.ts +0 -84
- package/dist/components/Workbook/WorkbookStorage.d.ts +0 -17
- package/dist/components/Workbook/WorkbookStorageProvider.d.ts +0 -12
- package/dist/components/Workbook/index.d.ts +0 -7
- package/dist/core-CWKmWEg2.cjs.js +0 -148
- package/dist/index-B0WyZAUA.es.js +0 -66412
- package/dist/index-kxVD1RjY.cjs.js +0 -356
- package/dist/markdown-editor.css +0 -341
- package/src/components/AnalyzePackageButton.tsx +0 -319
- package/src/components/Workbook/BrowserWorkbookStorage.ts +0 -64
- package/src/components/Workbook/EditableMalloyCell.tsx +0 -49
- package/src/components/Workbook/ModelPicker.tsx +0 -134
- package/src/components/Workbook/MutableCell.tsx +0 -458
- package/src/components/Workbook/Workbook.tsx +0 -501
- package/src/components/Workbook/WorkbookList.tsx +0 -110
- package/src/components/Workbook/WorkbookManager.ts +0 -214
- package/src/components/Workbook/WorkbookStorage.ts +0 -35
- package/src/components/Workbook/WorkbookStorageProvider.tsx +0 -40
- package/src/components/Workbook/index.ts +0 -10
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { useDimensionFilters, type DimensionFilterState, type FilterSelection, type MatchType, type UseDimensionFiltersParams, type UseDimensionFiltersResult, } from './useDimensionFilters';
|
|
2
2
|
export { useDimensionFiltersFromSpec, type DimensionFiltersConfig, type UseDimensionFiltersFromSpecOptions, } from './useDimensionFiltersFromSpec';
|
|
3
3
|
export { useDimensionFiltersQuery, type DimensionFiltersQueryResult, type UseDimensionFiltersQueryParams, } from './useDimensionFiltersQuery';
|
|
4
|
-
export { useDimensionalFilterRangeData, getDimensionKey,
|
|
4
|
+
export { useDimensionalFilterRangeData, getDimensionKey, type DimensionalFilterRangeDataResult, type DimensionSpec, type DimensionValue, type DimensionValues, type FilterType, type UseDimensionalFilterRangeDataParams, } from './useDimensionalFilterRangeData';
|
|
5
5
|
export { useModelGivens } from './useModelGivens';
|
|
6
6
|
export { type GivenValue } from './givenValue';
|
|
7
7
|
export { useGivensState, type UseGivensStateOptions, type UseGivensStateResult, } from './useGivensState';
|
|
8
8
|
export { useSuggestOptions } from './useSuggestOptions';
|
|
9
|
+
export { queryResultKey, useQueryResult, type QueryRequestSpec, type QueryResultState, } from './useQueryResult';
|
|
10
|
+
export { useDocumentControls, type DocumentControls, type UseDocumentControlsOptions, } from './useDocumentControls';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Given } from '../client';
|
|
2
|
+
import { GivensPanelProps } from '../components/given/GivensPanel';
|
|
3
|
+
import { UseGivensStateResult } from './useGivensState';
|
|
4
|
+
/**
|
|
5
|
+
* Everything a document's control row needs, from what the document declares.
|
|
6
|
+
*
|
|
7
|
+
* A dashboard, a notebook and the builder's harness each wired this by hand:
|
|
8
|
+
* the declared types read off the givens, the report to the host guarded on the
|
|
9
|
+
* document having loaded, `useGivensState`, `useSuggestOptions` for the pickers'
|
|
10
|
+
* options, `useDrillSelf` for `to=self`, and the same nine props into
|
|
11
|
+
* `GivensPanel`. Sixty lines each, with the same reasoning in the comments of
|
|
12
|
+
* each. This is that wiring once, so a control gains a behaviour on every
|
|
13
|
+
* surface at the same time.
|
|
14
|
+
*/
|
|
15
|
+
export interface UseDocumentControlsOptions {
|
|
16
|
+
/** The document's declared givens. Empty until it has loaded. */
|
|
17
|
+
specs: Given[];
|
|
18
|
+
/**
|
|
19
|
+
* Whether the document has loaded. Reports to the host are WITHHELD until
|
|
20
|
+
* it has: before then the declared set is empty, so a report would say "no
|
|
21
|
+
* values, and I manage nothing", which a host reasonably reads as "clear
|
|
22
|
+
* what you wrote" — and during an in-app move from one document to the next
|
|
23
|
+
* that window sits between the two, so the parameters it would clear belong
|
|
24
|
+
* to the document now arriving. A document that genuinely declares no givens
|
|
25
|
+
* still reports, because by then the empty set is the answer rather than
|
|
26
|
+
* the absence of one.
|
|
27
|
+
*/
|
|
28
|
+
loaded: boolean;
|
|
29
|
+
/** Where the controls start, from the file. A URL beats them. */
|
|
30
|
+
startingValues?: Record<string, string>;
|
|
31
|
+
/** Control values from the host, typically its URL query parameters. */
|
|
32
|
+
params?: Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Applied values, for a host that wants them in its URL, with every name
|
|
35
|
+
* this document manages — `givens` alone says which parameters to write but
|
|
36
|
+
* not which to remove.
|
|
37
|
+
*/
|
|
38
|
+
onGivensChange?: (givens: Record<string, string>, managed: readonly string[]) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Which document the edits belong to. Without it the edits are keyed by
|
|
41
|
+
* their starting VALUES alone, so two documents whose starting values
|
|
42
|
+
* coincide (the common case: both empty) look like one, and the one you came
|
|
43
|
+
* from keeps filtering the one you moved to. The version belongs in it too,
|
|
44
|
+
* so a swap between versions drops the edits made to the other.
|
|
45
|
+
*/
|
|
46
|
+
documentKey: string;
|
|
47
|
+
/** False batches changes behind Apply. */
|
|
48
|
+
autorun: boolean;
|
|
49
|
+
/** Where `suggest` queries run: the document's own model. */
|
|
50
|
+
environmentName: string;
|
|
51
|
+
packageName: string;
|
|
52
|
+
modelPath: string | undefined;
|
|
53
|
+
versionId?: string;
|
|
54
|
+
/** How the document names itself in a refused-drill warning. */
|
|
55
|
+
documentName: string;
|
|
56
|
+
}
|
|
57
|
+
export interface DocumentControls extends UseGivensStateResult {
|
|
58
|
+
/** Declared type per given name: what this document can set and how a value is encoded. */
|
|
59
|
+
declaredTypes: ReadonlyMap<string, string | undefined>;
|
|
60
|
+
options: Map<string, string[]>;
|
|
61
|
+
optionsLoading: boolean;
|
|
62
|
+
optionsFailed: ReadonlySet<string>;
|
|
63
|
+
/** For `useDrill`: whether a `to=self` on this given can be honoured. */
|
|
64
|
+
canSelf: (given: string) => boolean;
|
|
65
|
+
/** For `useDrill`: set the given to the clicked value, encoded for its type. */
|
|
66
|
+
onSelf: (given: string, rawValue: unknown) => void;
|
|
67
|
+
/** Everything `GivensPanel` takes except its layout: spread it in. */
|
|
68
|
+
panel: Omit<GivensPanelProps, "layout" | "title">;
|
|
69
|
+
}
|
|
70
|
+
export declare function useDocumentControls({ specs, loaded, startingValues, params, onGivensChange, documentKey, autorun, environmentName, packageName, modelPath, versionId, documentName, }: UseDocumentControlsOptions): DocumentControls;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { QueryKey, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
|
+
import { QueryResult } from '../client';
|
|
4
|
+
import { ApiError } from '../components/ApiErrorDisplay';
|
|
5
|
+
/**
|
|
6
|
+
* One query against one model, as every result surface asks for it.
|
|
7
|
+
*
|
|
8
|
+
* A dashboard tile, a model page's named query and an embedded `QueryResult`
|
|
9
|
+
* each ran a query through `executeQueryModel` with their own copy of the
|
|
10
|
+
* request, their own cache key and their own loading and error states — three
|
|
11
|
+
* spellings of one thing, and one of them (the model cell) had no error state
|
|
12
|
+
* at all. This is the request and the key; `ResultPanel` is the states.
|
|
13
|
+
*/
|
|
14
|
+
export interface QueryRequestSpec {
|
|
15
|
+
environmentName: string;
|
|
16
|
+
packageName: string;
|
|
17
|
+
modelPath: string;
|
|
18
|
+
/** The package version the caller's URI named, when it named one. */
|
|
19
|
+
versionId?: string;
|
|
20
|
+
/** A named query on the model. */
|
|
21
|
+
queryName?: string;
|
|
22
|
+
/** A run expression: `run: source -> view`. */
|
|
23
|
+
query?: string;
|
|
24
|
+
sourceName?: string;
|
|
25
|
+
/** The applied control values this query reads, already encoded. */
|
|
26
|
+
givens?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The cache key: every value the request is built from, in a fixed order, so
|
|
30
|
+
* the key cannot drift out of step with the request. A version that reached
|
|
31
|
+
* the request alone would leave two versions of one query on a single cache
|
|
32
|
+
* entry, each able to serve the other's result. `useQueryWithApiError` appends
|
|
33
|
+
* the server, so one key never spans two of them.
|
|
34
|
+
*/
|
|
35
|
+
export declare function queryResultKey(spec: QueryRequestSpec): QueryKey;
|
|
36
|
+
export declare function useQueryResult(spec: QueryRequestSpec, { enabled }?: {
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
}): UseQueryResult<AxiosResponse<QueryResult, any, {}>, ApiError>;
|
|
39
|
+
/** What a result surface holds while a query runs: hand it to `ResultPanel`. */
|
|
40
|
+
export type QueryResultState = ReturnType<typeof useQueryResult>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Given } from '../client';
|
|
2
|
+
import { GivenValue } from './givenValue';
|
|
2
3
|
/**
|
|
3
4
|
* How many options a generated `suggest { source=… dimension=… }` asks for.
|
|
4
5
|
*
|
|
@@ -37,19 +38,34 @@ export declare function buildSuggestQuery(source: string, dimension: string): st
|
|
|
37
38
|
* flat row form is what the widget needs, and asking for the full Malloy result
|
|
38
39
|
* would mean parsing rendering metadata to get at a list of strings.
|
|
39
40
|
*
|
|
40
|
-
*
|
|
41
|
-
* `
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* `suggest` server-side should settle it, and this hook's signature will need
|
|
50
|
-
* the values passed in.
|
|
41
|
+
* The request carries the givens the suggest query NEEDS and no others. An
|
|
42
|
+
* `#(authorize)` gate is evaluated against the request's givens, so a suggest
|
|
43
|
+
* over a gated source was denied outright and its dropdown read "Options
|
|
44
|
+
* unavailable". Sending every applied value would have fixed that but made the
|
|
45
|
+
* option list depend on the page's other filters, which this hook's caching
|
|
46
|
+
* deliberately avoids. So the server says, per suggest, which givens its source
|
|
47
|
+
* is gated or scoped by (`suggest.givenNames`), and {@link suggestRequestGivens}
|
|
48
|
+
* sends the current values of exactly those; the cache is keyed on them too.
|
|
49
|
+
* A server too old to name them sends none, and the request is as before.
|
|
51
50
|
*/
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The current values a suggest query has to carry: the applied values of the
|
|
53
|
+
* givens the server named on it, encoded for the request. Undefined when the
|
|
54
|
+
* suggest names none, or when the caller has no applied values to offer.
|
|
55
|
+
*/
|
|
56
|
+
export declare function suggestRequestGivens(spec: Given, applied: AppliedGivens | undefined): Record<string, unknown> | undefined;
|
|
57
|
+
/** The applied control row and the declared types that encode it. */
|
|
58
|
+
export interface AppliedGivens {
|
|
59
|
+
values: ReadonlyMap<string, GivenValue>;
|
|
60
|
+
declaredTypes: ReadonlyMap<string, string | undefined>;
|
|
61
|
+
}
|
|
62
|
+
export declare function useSuggestOptions(environmentName: string, packageName: string, modelPath: string | undefined, specs: Given[], versionId?: string,
|
|
63
|
+
/**
|
|
64
|
+
* The page's applied values, so a suggest can carry the givens its source
|
|
65
|
+
* is gated or scoped by. Optional for the same reason as `versionId`; a
|
|
66
|
+
* caller that omits it gets the pre-gating behaviour.
|
|
67
|
+
*/
|
|
68
|
+
applied?: AppliedGivens): {
|
|
53
69
|
options: Map<string, string[]>;
|
|
54
70
|
isLoading: boolean;
|
|
55
71
|
/**
|