@malloy-publisher/sdk 0.3.0 → 0.4.0
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 +22 -9
- package/dist/DocumentStorageProvider-CyOJ0hqf.es.js +24443 -0
- package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
- package/dist/RenderedResult-BnPzJ9Jf.es.js +549 -0
- package/dist/RenderedResult-Dp22kZsQ.cjs.js +115 -0
- package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-BWOEKg0O.es.js} +1256 -1318
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9482 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +100 -42
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +30 -0
- package/dist/components/BackLink.d.ts +32 -0
- package/dist/components/Dashboard/Dashboard.d.ts +19 -14
- package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
- 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 +7 -3
- package/dist/components/Dashboard/telemetry.d.ts +48 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +118 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +30 -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/newDashboard.d.ts +17 -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 +53 -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/DocumentStorageProvider.d.ts +7 -0
- package/dist/components/DocumentStorage/index.d.ts +1 -1
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/ItemRow.d.ts +38 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
- package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
- package/dist/components/Materializations/Materializations.d.ts +7 -3
- package/dist/components/Materializations/ScopeButton.d.ts +18 -0
- package/dist/components/Materializations/SectionLabel.d.ts +7 -4
- package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
- package/dist/components/Materializations/index.d.ts +0 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
- package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
- package/dist/components/Package/index.d.ts +0 -1
- package/dist/components/PackageSection.d.ts +23 -0
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +1 -0
- package/dist/components/buttons.d.ts +53 -0
- package/dist/components/drill/index.d.ts +1 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/index.d.ts +6 -0
- package/dist/components/styles.d.ts +49 -44
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/index.cjs.js +22 -273
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +16888 -44451
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +24 -9
- package/src/builder-entry.ts +55 -0
- package/src/components/AppDialog.tsx +115 -0
- package/src/components/BackLink.tsx +83 -0
- package/src/components/Connections/AddConnectionDialog.tsx +50 -70
- package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
- package/src/components/Connections/EditConnectionDialog.tsx +54 -73
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +165 -175
- package/src/components/Dashboard/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +66 -123
- 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 +70 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
- package/src/components/Dashboard/telemetry.ts +51 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +247 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +852 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +666 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +188 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +567 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +122 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +269 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +562 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +126 -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/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -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 +1161 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1135 -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 +311 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +201 -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/DocumentStorageProvider.tsx +12 -0
- package/src/components/DocumentStorage/index.ts +1 -0
- package/src/components/Environment/About.tsx +16 -62
- package/src/components/Environment/AddPackageDialog.tsx +85 -154
- package/src/components/Environment/Connections.tsx +125 -205
- package/src/components/Environment/DeletePackageDialog.tsx +32 -77
- package/src/components/Environment/EditPackageDialog.tsx +46 -58
- package/src/components/Environment/Environment.tsx +34 -36
- package/src/components/Environment/Packages.tsx +63 -128
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
- package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
- package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
- package/src/components/Home/Home.tsx +101 -214
- package/src/components/ItemRow.tsx +165 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
- package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
- package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
- package/src/components/Materializations/Materializations.tsx +137 -140
- package/src/components/Materializations/ScopeButton.tsx +85 -0
- package/src/components/Materializations/SectionLabel.tsx +7 -4
- package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
- package/src/components/Materializations/TriggerLabel.tsx +36 -0
- package/src/components/Materializations/cron.spec.ts +113 -0
- package/src/components/Materializations/index.ts +0 -1
- package/src/components/Materializations/utils.spec.ts +182 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +33 -72
- package/src/components/Notebook/Notebook.tsx +25 -88
- package/src/components/Notebook/NotebookCell.tsx +35 -183
- package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
- package/src/components/Package/ContentTypeIcon.tsx +10 -12
- package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
- package/src/components/Package/NewDashboardDialog.tsx +265 -0
- package/src/components/Package/Package.tsx +179 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- 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.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- package/src/components/RenderedResult/ResultContainer.tsx +4 -12
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +1 -0
- package/src/components/ResultsDialog.tsx +8 -32
- package/src/components/buttons.tsx +114 -0
- package/src/components/designSystem.spec.tsx +316 -0
- package/src/components/drill/index.ts +1 -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/given/GivensPanel.tsx +1 -1
- package/src/components/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +16 -0
- package/src/components/styles.ts +49 -122
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -0
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/index.ts +9 -0
- package/src/telemetry/consoleEvents.spec.ts +130 -0
- package/src/telemetry/consoleEvents.ts +124 -0
- package/src/theme/defaults.ts +34 -23
- package/src/theme/resolveTheme.spec.ts +9 -4
- package/src/theme/resolveTheme.ts +12 -8
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/src/utils/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/vite.config.ts +5 -0
- package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
- package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
- package/dist/components/Materializations/TriggerChip.d.ts +0 -10
- package/dist/components/Package/Models.d.ts +0 -6
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
- package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
- package/src/components/Materializations/ScheduleCard.tsx +0 -231
- package/src/components/Materializations/TriggerChip.tsx +0 -44
- package/src/components/Package/Models.tsx +0 -71
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A new dashboard, written into the package and opened in the builder: pick
|
|
3
|
+
* the model, a source it declares, the view for the first tile, and a title.
|
|
4
|
+
* The file is the one the builder would write (see `newDashboardSource`), so
|
|
5
|
+
* everything after this is the builder's.
|
|
6
|
+
*/
|
|
7
|
+
export declare function NewDashboardDialog({ open, environmentName, packageName, models, existing, onClose, onCreated, }: {
|
|
8
|
+
open: boolean;
|
|
9
|
+
environmentName: string;
|
|
10
|
+
packageName: string;
|
|
11
|
+
/** The package's model files, relative to its root, to pick a source from. */
|
|
12
|
+
models: string[];
|
|
13
|
+
/** Slugs already in the package, which a new one may not repeat. */
|
|
14
|
+
existing: string[];
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
/** The new dashboard's slug, once its file is in the package. */
|
|
17
|
+
onCreated: (slug: string) => void;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* One titled section of a page: a heading, how many things are in it, what they
|
|
4
|
+
* are, and the control that adds one.
|
|
5
|
+
*
|
|
6
|
+
* Every section on every page is this component, so moving between a package
|
|
7
|
+
* and the environment above it does not restate the same heading at a different
|
|
8
|
+
* size, indent or gap.
|
|
9
|
+
*
|
|
10
|
+
* The section is a landmark named by its own heading, which is what makes
|
|
11
|
+
* "Dashboards" addressable — to a screen reader moving by region, and to a test
|
|
12
|
+
* that wants the dashboards list rather than every row on the page that happens
|
|
13
|
+
* to share a word with it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function PackageSection({ title, count, description, action, children, }: {
|
|
16
|
+
title: string;
|
|
17
|
+
count?: number;
|
|
18
|
+
/** What the section holds, in a line, under the heading. */
|
|
19
|
+
description?: string;
|
|
20
|
+
/** A control on the heading's row, hard right. */
|
|
21
|
+
action?: React.ReactNode;
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SxProps, Theme } from '@mui/material';
|
|
2
|
+
import { NavigationClick } from './click_helper';
|
|
3
|
+
/**
|
|
4
|
+
* Markdown authored inside a package — a dashboard's `##"` description, a
|
|
5
|
+
* notebook's markdown cell, a README — rendered one way.
|
|
6
|
+
*
|
|
7
|
+
* Three surfaces each rendered it with their own style sheet, and only one of
|
|
8
|
+
* them guarded the links. Package content comes from untrusted git and S3
|
|
9
|
+
* sources, so a crafted `javascript:` or `data:` href in a README or a
|
|
10
|
+
* description must never run; the notebook cell knew this and the other two did
|
|
11
|
+
* not. Every link here goes through {@link ProseLink}.
|
|
12
|
+
*
|
|
13
|
+
* Two variants, because the prose plays two roles:
|
|
14
|
+
*
|
|
15
|
+
* - `document`: the prose IS the content — a notebook's markdown cells, read
|
|
16
|
+
* top to bottom. Full-size headings, reading-length lines.
|
|
17
|
+
* - `caption`: the prose sits under a title it must not compete with — a
|
|
18
|
+
* dashboard's description, a package's README card. Body size; headings are
|
|
19
|
+
* section labels within the block, at body size and bold.
|
|
20
|
+
*/
|
|
21
|
+
export type ProseVariant = "document" | "caption";
|
|
22
|
+
/**
|
|
23
|
+
* How a relative link is resolved. Links in package content are authored
|
|
24
|
+
* relative to the SOURCE FILE (`spielberg.malloynb`), and a plain anchor
|
|
25
|
+
* resolves them against the page URL instead, which drops the package segment
|
|
26
|
+
* for a README shown at the package route. With this, a relative link resolves
|
|
27
|
+
* against the file's own directory and routes through the host.
|
|
28
|
+
*/
|
|
29
|
+
export interface ProseLinkContext {
|
|
30
|
+
environmentName: string;
|
|
31
|
+
packageName: string;
|
|
32
|
+
/** The file the prose came from, within the package; its directory is the base. */
|
|
33
|
+
sourcePath?: string;
|
|
34
|
+
/**
|
|
35
|
+
* SPA navigation for a resolved link. Omitted, the absolute href navigates on
|
|
36
|
+
* its own, so rendering prose needs no router context.
|
|
37
|
+
*/
|
|
38
|
+
onNavigate?: (to: string, event?: NavigationClick) => void;
|
|
39
|
+
}
|
|
40
|
+
export interface ProseProps {
|
|
41
|
+
children: string;
|
|
42
|
+
variant?: ProseVariant;
|
|
43
|
+
links?: ProseLinkContext;
|
|
44
|
+
sx?: SxProps<Theme>;
|
|
45
|
+
}
|
|
46
|
+
export declare function Prose({ children, variant, links, sx, }: ProseProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { QueryResultState } from '../../hooks/useQueryResult';
|
|
2
|
+
import { DrillBinding } from '../drill/useDrill';
|
|
3
|
+
export interface ResultPanelProps {
|
|
4
|
+
/** From `useQueryResult`. */
|
|
5
|
+
state: QueryResultState;
|
|
6
|
+
/** Names the request in an error: the tile expression, the query name, the model path. */
|
|
7
|
+
context: string;
|
|
8
|
+
loadingText?: string;
|
|
9
|
+
maxHeight?: number;
|
|
10
|
+
maxResultSize?: number;
|
|
11
|
+
drill?: DrillBinding;
|
|
12
|
+
/**
|
|
13
|
+
* Rewrites the result before it is rendered — a dashboard tile promotes a
|
|
14
|
+
* one-row measure result to KPI cards this way. Memoized on the result
|
|
15
|
+
* string, so a large result is not re-parsed on every render around it.
|
|
16
|
+
*/
|
|
17
|
+
transform?: (result: string) => string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The three states of a running query, once: waiting, failed, and the result
|
|
21
|
+
* itself through `ResultContainer`.
|
|
22
|
+
*
|
|
23
|
+
* Every surface that runs a query goes through the same three, and each used
|
|
24
|
+
* to draw them itself with its own words ("Running…", "Loading results...",
|
|
25
|
+
* "Fetching Query Results...") and, in one case, without the failed state at
|
|
26
|
+
* all. A tile owning its own panel is still what lets a composite dashboard
|
|
27
|
+
* survive a bad tile: the broken one shows its error in place and the rest of
|
|
28
|
+
* the grid still renders.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ResultPanel({ state, context, loadingText, maxHeight, maxResultSize, drill, transform, }: ResultPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as RenderedResult } from './RenderedResult';
|
|
2
2
|
export { default as ResultContainer } from './ResultContainer';
|
|
3
|
+
export { ResultPanel, type ResultPanelProps } from './ResultPanel';
|
|
3
4
|
export { contentNodeDepth, INITIAL_RENDER_HEIGHT, initialResultHeight, measureContentHeight, MODEL_CELL_MAX_HEIGHT, NOTEBOOK_CELL_MAX_HEIGHT, remeasuresAfterReady, resolveResultHeight, RESULTS_DIALOG_MAX_HEIGHT, resultSizing, TILE_MAX_HEIGHT, UNCAPPED_CONTAINER_HEIGHT, type ResultSizing, } from './resultSizing';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The Console's buttons, by the job they do. Four roles, and every button on
|
|
4
|
+
* every page is one of them:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Primary** — the one thing a surface is for: adding a package, a
|
|
7
|
+
* dashboard, a materialization; the confirm in a dialog. A filled dark pill
|
|
8
|
+
* at the default size. {@link AddButton} is the section-heading form of it.
|
|
9
|
+
* 2. **Secondary** — a control beside the primary one, changing something that
|
|
10
|
+
* already exists: Scope, Schedule, Filter. An outlined pill, the same size
|
|
11
|
+
* as the primary, so a heading row reads as one set of controls rather than
|
|
12
|
+
* a big button and some small ones. {@link SecondaryButton}.
|
|
13
|
+
* 3. **Quiet** — a dense bar of equals, where an outline per item would draw a
|
|
14
|
+
* grid: the dashboard builder's toolbar, a dialog's Cancel. A small text
|
|
15
|
+
* button, written inline.
|
|
16
|
+
* 4. **Icon** — a row's overflow menu or a compact toggle. A small icon
|
|
17
|
+
* button, written inline.
|
|
18
|
+
*
|
|
19
|
+
* The roles are exhaustive on purpose. A button that is none of them is a new
|
|
20
|
+
* family of control on a page that already has four, so add it here — with the
|
|
21
|
+
* job it does — rather than inline at its one call site.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The control that adds one thing to a section: a filled pill with a plus,
|
|
25
|
+
* right of the section's heading.
|
|
26
|
+
*
|
|
27
|
+
* The LABEL names the thing alone — "Package", "Connection", "Dashboard" —
|
|
28
|
+
* because the plus already says add; the verb went back into the accessible
|
|
29
|
+
* name, where a control called "Package" would otherwise say nothing about
|
|
30
|
+
* what it does.
|
|
31
|
+
*/
|
|
32
|
+
export declare function AddButton({ label, onClick, disabled, }: {
|
|
33
|
+
/** The thing being added, as it should read on the button: "Package". */
|
|
34
|
+
label: string;
|
|
35
|
+
onClick: () => void;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
/**
|
|
39
|
+
* A secondary control: outlined, and the same size as the primary it sits
|
|
40
|
+
* beside. Takes its own icon and, when it is disabled, the reason — a control
|
|
41
|
+
* that greys out without saying why is a control a reader has to guess at.
|
|
42
|
+
*/
|
|
43
|
+
export declare function SecondaryButton({ label, icon, onClick, disabled, disabledReason, ariaLabel, ariaHasPopup, }: {
|
|
44
|
+
label: string;
|
|
45
|
+
icon?: React.ReactNode;
|
|
46
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
/** Shown on hover when disabled. */
|
|
49
|
+
disabledReason?: string;
|
|
50
|
+
/** Overrides the accessible name, which is otherwise the label. */
|
|
51
|
+
ariaLabel?: string;
|
|
52
|
+
ariaHasPopup?: "menu" | "dialog";
|
|
53
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DRILL_CELL_CLASS, drillableFieldNames, markDrillableCells, type DrillMetadataSource, } from './markDrillableCells';
|
|
2
|
-
export { DRILL_SELF, drillDestinations, drillValueToFilter, encodeDrillValue, humanizeSlug, resolveDrill, type DrillClickPayload, type DrillField, type DrillIntent, type DrillNavigation, type DrillTagReader, } from './resolveDrill';
|
|
2
|
+
export { DRILL_SELF, drillDestinations, drillValueToFilter, encodeDrillValue, humanizeSlug, resolveDrill, type DrillClickPayload, type DrillField, type DrillIntent, type DrillNavigation, type DrillRowsRequest, type DrillTagReader, } from './resolveDrill';
|
|
3
3
|
export { useDrill, type DrillBinding, type UseDrillOptions, type UseDrillResult, } from './useDrill';
|
|
4
4
|
export { useDrillSelf, type UseDrillSelfOptions, type UseDrillSelfResult, } from './useDrillSelf';
|
|
@@ -40,6 +40,26 @@ export interface DrillClickPayload {
|
|
|
40
40
|
* a modifier was held (cmd/ctrl to open in a new tab).
|
|
41
41
|
*/
|
|
42
42
|
event?: MouseEvent;
|
|
43
|
+
/**
|
|
44
|
+
* Where the click came from, as the host names it — for a dashboard, the
|
|
45
|
+
* tile expression whose result was clicked. Set by the host when it wraps
|
|
46
|
+
* a binding per tile; the renderer never fills it. What "the rows behind
|
|
47
|
+
* this value" runs against is read from here.
|
|
48
|
+
*/
|
|
49
|
+
context?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A click asking for the rows behind a value, on a surface that offers them.
|
|
53
|
+
* No tag is involved: any grouped value has rows behind it.
|
|
54
|
+
*/
|
|
55
|
+
export interface DrillRowsRequest {
|
|
56
|
+
/** The clicked field's name, as the result spells it. */
|
|
57
|
+
field: string;
|
|
58
|
+
rawValue: unknown;
|
|
59
|
+
/** The value as it read on screen. */
|
|
60
|
+
label: string;
|
|
61
|
+
/** {@link DrillClickPayload.context}, when the host set one. */
|
|
62
|
+
context?: string;
|
|
43
63
|
}
|
|
44
64
|
/** The literal `to=self`: filter the current view instead of leaving it. */
|
|
45
65
|
export declare const DRILL_SELF = "self";
|
|
@@ -117,6 +137,8 @@ export interface DrillIntent {
|
|
|
117
137
|
* the cell the user clicked would be worse than one that does nothing.
|
|
118
138
|
*/
|
|
119
139
|
export declare function drillValueToFilter(value: unknown): string | undefined;
|
|
140
|
+
/** How the clicked value read on screen, for a menu label. */
|
|
141
|
+
export declare function drillValueLabel(value: unknown): string;
|
|
120
142
|
/**
|
|
121
143
|
* Read the `# drill` intent off a renderer click, or undefined when the click
|
|
122
144
|
* was not on a drillable value.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { DrillField, DrillClickPayload, DrillNavigation } from './resolveDrill';
|
|
2
|
+
import { DrillField, DrillClickPayload, DrillNavigation, DrillRowsRequest } from './resolveDrill';
|
|
3
3
|
export interface UseDrillOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Open another dashboard, seeded with the clicked value. Omitted on a surface
|
|
@@ -28,6 +28,15 @@ export interface UseDrillOptions {
|
|
|
28
28
|
* cannot know which document the reader is in, so the surface names itself.
|
|
29
29
|
*/
|
|
30
30
|
selfLabel?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Show the rows behind a grouped value. With it, EVERY dimension cell is
|
|
33
|
+
* clickable: one with no `# drill` this surface can honour opens the rows;
|
|
34
|
+
* one with a drill behaves exactly as it does without this option, since a
|
|
35
|
+
* drill is the author's own instruction for that value. Omitted on a
|
|
36
|
+
* surface with nowhere to show them, and cells then click only where a tag
|
|
37
|
+
* says so.
|
|
38
|
+
*/
|
|
39
|
+
onRows?: (request: DrillRowsRequest) => void;
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
33
42
|
* What a surface hands to its result renderer to become drillable: the click
|
|
@@ -60,4 +69,4 @@ export interface UseDrillResult {
|
|
|
60
69
|
* specific code. What differs between surfaces is only what they can do about it,
|
|
61
70
|
* which is what the two callbacks express.
|
|
62
71
|
*/
|
|
63
|
-
export declare function useDrill({ onNavigate, onSelf, selfLabel, canSelf, }: UseDrillOptions): UseDrillResult;
|
|
72
|
+
export declare function useDrill({ onNavigate, onSelf, selfLabel, canSelf, onRows, }: UseDrillOptions): UseDrillResult;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export { ApiErrorDisplay, type ApiErrorDisplayProps } from './ApiErrorDisplay';
|
|
2
|
+
export { AddButton, SecondaryButton } from './buttons';
|
|
3
|
+
export { AppDialog } from './AppDialog';
|
|
4
|
+
export { BackLink } from './BackLink';
|
|
5
|
+
export { DashboardBar } from './Dashboard/DashboardBar';
|
|
6
|
+
export { PALETTE, SURFACE_TINT } from './styles';
|
|
2
7
|
export { useRouterClickHandler, type NavigationClick } from './click_helper';
|
|
3
8
|
export * from './Dashboard';
|
|
4
9
|
export * from './DataAppViewer';
|
|
@@ -12,6 +17,7 @@ export * from './Materializations';
|
|
|
12
17
|
export * from './Model';
|
|
13
18
|
export * from './Notebook';
|
|
14
19
|
export * from './Package';
|
|
20
|
+
export { Prose, type ProseLinkContext, type ProseProps, type ProseVariant, } from './Prose';
|
|
15
21
|
export * from './QueryResult';
|
|
16
22
|
export * from './RenderedResult';
|
|
17
23
|
export { ServerProvider, useServer } from './ServerProvider';
|
|
@@ -4,49 +4,64 @@ import { CommonProps } from '@mui/material/OverridableComponent';
|
|
|
4
4
|
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
5
5
|
import { MUIStyledCommonProps } from '@mui/system';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* The Console's palette: one set of hues, used everywhere a colour carries
|
|
8
|
+
* meaning.
|
|
9
|
+
*
|
|
10
|
+
* These are the register data tools encode categories in — saturated, mid-dark,
|
|
11
|
+
* evenly spaced around the wheel — rather than colours lifted from a logo. A
|
|
12
|
+
* logo is drawn to be recognised at one size in one place; a palette has to
|
|
13
|
+
* distinguish a dozen kinds of thing in a list, behind a glyph, and along a
|
|
14
|
+
* chart's series, and the two jobs pull in different directions. The previous
|
|
15
|
+
* palette was the logo's three plus two families invented to extend it, which
|
|
16
|
+
* is how one screen ended up with three unrelated colour systems on it.
|
|
17
|
+
*
|
|
18
|
+
* **Every value clears 3:1 against white**, WCAG's minimum for a graphical
|
|
19
|
+
* object, because these are painted as small solid backplates behind white
|
|
20
|
+
* glyphs where the glyph has to stay readable. That is a hard constraint on
|
|
21
|
+
* anything added here, asserted in `ContentTypeIcon.spec.ts` rather than left
|
|
22
|
+
* to review: a too-light plate looks perfectly fine in a screenshot and simply
|
|
23
|
+
* stops being legible. Measured against white, lowest first: emerald 3.8:1,
|
|
24
|
+
* red 4.8:1, lime 5.0:1, amber 5.0:1, blue 5.2:1, orange 5.2:1, cyan 5.4:1,
|
|
25
|
+
* teal 5.5:1, violet 5.7:1, pink 6.0:1, indigo 6.3:1, slate 7.6:1.
|
|
10
26
|
*/
|
|
11
|
-
export declare const
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
27
|
+
export declare const PALETTE: {
|
|
28
|
+
readonly blue: "#2563eb";
|
|
29
|
+
readonly indigo: "#4f46e5";
|
|
30
|
+
readonly violet: "#7c3aed";
|
|
31
|
+
readonly pink: "#be185d";
|
|
32
|
+
readonly red: "#dc2626";
|
|
33
|
+
readonly orange: "#c2410c";
|
|
34
|
+
readonly amber: "#b45309";
|
|
35
|
+
readonly lime: "#4d7c0f";
|
|
36
|
+
readonly emerald: "#059669";
|
|
37
|
+
readonly teal: "#0f766e";
|
|
38
|
+
readonly cyan: "#0e7490";
|
|
39
|
+
readonly slate: "#475569";
|
|
15
40
|
};
|
|
16
41
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* Their own family rather than borrowings from the chart series
|
|
22
|
-
* (`theme/defaults.ts`), because the two have opposite constraints. A series
|
|
23
|
-
* color fills a large area and can be light; these sit behind a white icon as a
|
|
24
|
-
* small solid backplate, where the icon has to stay legible. Measured against
|
|
25
|
-
* white: violet 5.5:1, magenta 4.6:1, moss 3.9:1, so all three clear 3:1, the
|
|
26
|
-
* WCAG minimum for a graphical object. The nearest series hues do not: `#aacd85`
|
|
27
|
-
* sage is 1.8:1, `#ec72b8` pink 2.7:1, `#b87ced` violet 2.9:1.
|
|
42
|
+
* The tints for what a SERVER holds, as against what a package holds. Three
|
|
43
|
+
* kinds — an environment, a package, a connection — listed on the home and
|
|
44
|
+
* environment pages.
|
|
28
45
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* of
|
|
33
|
-
* clears it by 0.09, so retuning it lighter turns that suite red, in a file a
|
|
34
|
-
* brand change would not otherwise open. For those two the bar is a component
|
|
35
|
-
* constraint, not only a brand decision.
|
|
46
|
+
* Kept clear of the hues `CONTENT_TINT` uses, so a colour means one kind of
|
|
47
|
+
* thing across the whole Console rather than one kind per page. All three are
|
|
48
|
+
* real colours rather than near-neutrals: a grey plate reads as chrome instead
|
|
49
|
+
* of as one of the coloured kinds, which is the plate's whole job.
|
|
36
50
|
*
|
|
37
|
-
*
|
|
38
|
-
* the
|
|
39
|
-
*
|
|
40
|
-
*
|
|
51
|
+
* Also kept clear of the primary. Packages were indigo, which sat a few degrees
|
|
52
|
+
* from the blue of the "Package" button on the same row and read as a failed
|
|
53
|
+
* attempt at the same colour. Teal is the furthest hue from blue still open,
|
|
54
|
+
* and packages and connections — the pair that actually share a screen — now
|
|
55
|
+
* sit on opposite sides of the wheel. Environments never appear beside either.
|
|
41
56
|
*/
|
|
42
|
-
export declare const
|
|
43
|
-
readonly
|
|
44
|
-
readonly
|
|
45
|
-
readonly
|
|
57
|
+
export declare const SURFACE_TINT: {
|
|
58
|
+
readonly environment: "#059669";
|
|
59
|
+
readonly package: "#0f766e";
|
|
60
|
+
readonly connection: "#c2410c";
|
|
46
61
|
};
|
|
47
62
|
/**
|
|
48
63
|
* Monospace font stack used by code-like surfaces inside the SDK
|
|
49
|
-
* (file-path labels in
|
|
64
|
+
* (file-path labels in `ItemRow`, code blocks, etc.). Matches the
|
|
50
65
|
* `MONO_FONT_FAMILY` defined in the publisher app's theme.
|
|
51
66
|
*/
|
|
52
67
|
export declare const MONO_FONT_FAMILY = "\"JetBrains Mono\", \"ui-monospace\", \"SFMono-Regular\", \"Menlo\", monospace";
|
|
@@ -54,17 +69,7 @@ export declare const StyledCard: StyledComponent< CardOwnProps & CommonProps & O
|
|
|
54
69
|
export declare const StyledCardContent: StyledComponent< CardContentOwnProps & CommonProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "className" | "style" | "classes" | "children" | "sx"> & MUIStyledCommonProps<Theme>, {}, {}>;
|
|
55
70
|
export declare const StyledCardMedia: StyledComponent< CardMediaOwnProps & CommonProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "className" | "style" | "classes" | "children" | "sx" | "image" | "src"> & MUIStyledCommonProps<Theme>, {}, {}>;
|
|
56
71
|
export declare const CleanNotebookContainer: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
57
|
-
export declare const CleanNotebookHeader: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
58
72
|
export declare const CleanNotebookSection: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
59
|
-
export declare const CleanNotebookCell: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
60
73
|
export declare const CleanMetricCard: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
61
|
-
export declare const CleanCodeBlock: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
62
|
-
export declare const CleanActionBar: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
63
74
|
export declare const StyledExplorerPage: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
64
|
-
export declare const StyledExplorerBanner: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
65
75
|
export declare const StyledExplorerContent: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
66
|
-
export declare const StyledExplorerPanel: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
67
|
-
export declare const PackageCard: StyledComponent< CardOwnProps & CommonProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "className" | "style" | "classes" | "children" | "sx" | "variant" | "square" | "elevation" | "raised"> & MUIStyledCommonProps<Theme>, {}, {}>;
|
|
68
|
-
export declare const PackageCardContent: StyledComponent< CardContentOwnProps & CommonProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "className" | "style" | "classes" | "children" | "sx"> & MUIStyledCommonProps<Theme>, {}, {}>;
|
|
69
|
-
export declare const PackageSectionTitle: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
70
|
-
export declare const PackageContainer: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -6,3 +6,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,42 @@
|
|
|
1
|
+
import { QueryKey, UseMutateFunction } from '@tanstack/react-query';
|
|
2
|
+
import { ConsoleResource } from '../telemetry/consoleEvents';
|
|
3
|
+
import { ApiError } from '../components/ApiErrorDisplay';
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
/**
|
|
6
|
+
* A write from a dialog: run it, close the dialog, refetch what it changed,
|
|
7
|
+
* and say what happened.
|
|
8
|
+
*
|
|
9
|
+
* Every create/edit/delete dialog in the Console does those four things in the
|
|
10
|
+
* same order and reported failure in one of two different ways depending on
|
|
11
|
+
* which file you were in. The shape is here once so the two conventions cannot
|
|
12
|
+
* drift back apart: a thrown `Error` shows its own message, because the API
|
|
13
|
+
* layer already turns a failed response into one worth reading, and anything
|
|
14
|
+
* else falls back to a sentence rather than `[object Object]`.
|
|
15
|
+
*
|
|
16
|
+
* `notice` is the Snackbar, wired and ready to render. It is returned rather
|
|
17
|
+
* than portalled from in here so a caller keeps it as a sibling of its dialog,
|
|
18
|
+
* where it was.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useCrudMutation<TVariables = void>({ mutationFn, success, invalidates, closeDialog, resource, action, }: {
|
|
21
|
+
mutationFn: (variables: TVariables) => Promise<unknown>;
|
|
22
|
+
/** What the snackbar says when the write lands: "Package created". */
|
|
23
|
+
success: string;
|
|
24
|
+
/** The query keys the write invalidates. Name the narrowest that covers it. */
|
|
25
|
+
invalidates: QueryKey[];
|
|
26
|
+
/**
|
|
27
|
+
* Closes the dialog. Runs on SUCCESS only — a write that failed leaves
|
|
28
|
+
* something to correct and retry, so the form has to stay — and before the
|
|
29
|
+
* refetch, so the dialog goes at once rather than after the list reloads.
|
|
30
|
+
*
|
|
31
|
+
* Not called `onSettled`: that name means "success or error" everywhere
|
|
32
|
+
* else in React Query, and this is the opposite of that.
|
|
33
|
+
*/
|
|
34
|
+
closeDialog: () => void;
|
|
35
|
+
/** What is being written, for the event; see `ConsoleEvent`. */
|
|
36
|
+
resource: ConsoleResource;
|
|
37
|
+
action: "create" | "update" | "delete";
|
|
38
|
+
}): {
|
|
39
|
+
mutate: UseMutateFunction<unknown, ApiError, TVariables, unknown>;
|
|
40
|
+
isPending: boolean;
|
|
41
|
+
notice: React.ReactNode;
|
|
42
|
+
};
|
|
@@ -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>;
|