@malloy-publisher/sdk 0.17.0 → 0.17.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 +32 -50
- package/dist/{RenderedResult-BcEDcw0V.es.js → RenderedResult-CYJ2Y9Fm.es.js} +24 -24
- package/dist/{RenderedResult-uT2oc6ke.cjs.js → RenderedResult-hRvgFMAF.cjs.js} +1 -1
- package/dist/ServerProvider-DeVejmVr.cjs.js +1 -0
- package/dist/{ServerProvider-vmEUjlEu.es.js → ServerProvider-DzzfVDg_.es.js} +1314 -1712
- package/dist/builder/index.cjs.js +12 -12
- package/dist/builder/index.es.js +4 -9
- package/dist/client/api.d.ts +63 -506
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +132 -144
- package/dist/components/Dashboard/DashboardGrid.d.ts +1 -1
- package/dist/components/Model/ExplorerPage.d.ts +1 -3
- package/dist/components/Model/Model.d.ts +1 -4
- package/dist/components/Model/ModelExplorer.d.ts +1 -2
- package/dist/components/Package/reportQueries.d.ts +2 -4
- package/dist/components/Report/Report.d.ts +20 -9
- package/dist/components/{legacy → Report}/malloynb/CellRunnerView.d.ts +13 -16
- package/dist/components/Report/malloynb/MalloynbReport.d.ts +11 -0
- package/dist/components/{legacy → Report}/malloynb/cellKind.d.ts +1 -1
- package/dist/components/ServerProvider.d.ts +1 -3
- package/dist/components/drill/drillClauses.d.ts +8 -9
- package/dist/components/drill/rowsTarget.d.ts +7 -9
- package/dist/components/legacy/index.d.ts +3 -7
- package/dist/components/modelPage.d.ts +2 -5
- package/dist/hooks/useModelGivens.d.ts +2 -2
- package/dist/hooks/useQueryResult.d.ts +7 -0
- package/dist/index.cjs.js +33 -33
- package/dist/index.es.js +8799 -8903
- package/dist/{useCompiledDocument-h5-Kc1Zh.cjs.js → useCompiledDocument-BCr-xB_i.cjs.js} +4 -4
- package/dist/{useCompiledDocument-rOwDSK_s.es.js → useCompiledDocument-E0tU5KzP.es.js} +266 -277
- package/package.json +1 -1
- package/src/components/Dashboard/DashboardGrid.tsx +1 -1
- package/src/components/Dashboard/DashboardTile.spec.tsx +1 -1
- package/src/components/Model/ExplorerPage.tsx +1 -3
- package/src/components/Model/Model.tsx +1 -4
- package/src/components/Model/ModelExplorer.tsx +1 -2
- package/src/components/Package/Package.tsx +1 -5
- package/src/components/Package/reportQueries.ts +3 -15
- package/src/components/Report/Report.malloynb.spec.tsx +230 -0
- package/src/components/Report/Report.spec.tsx +429 -38
- package/src/components/Report/Report.telemetry.spec.tsx +51 -10
- package/src/components/Report/Report.tsx +63 -44
- package/src/components/{legacy → Report}/malloynb/CellRunnerView.spec.tsx +11 -44
- package/src/components/{legacy → Report}/malloynb/CellRunnerView.tsx +63 -107
- package/src/components/Report/malloynb/MalloynbReport.tsx +110 -0
- package/src/components/{legacy → Report}/malloynb/cellKind.ts +5 -4
- package/src/components/ReportBuilder/EditorSurface.tsx +3 -3
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +2 -2
- package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +0 -4
- package/src/components/ReportBuilder/ReportEditor.queryVersion.spec.tsx +0 -1
- package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -3
- package/src/components/ReportBuilder/ReportEditor.tsx +1 -1
- package/src/components/ReportBuilder/loadMalloy.ts +1 -4
- package/src/components/ReportBuilder/useSaveChannel.ts +1 -6
- package/src/components/ServerProvider.tsx +0 -4
- package/src/components/drill/drillClauses.ts +8 -9
- package/src/components/drill/rowsTarget.ts +7 -9
- package/src/components/index.ts +2 -3
- package/src/components/legacy/index.ts +3 -7
- package/src/components/modelPage.ts +2 -5
- package/src/hooks/useGivensState.ts +8 -8
- package/src/hooks/useModelGivens.ts +2 -2
- package/src/hooks/useQueryResult.ts +30 -18
- package/test/README.md +4 -4
- package/dist/ServerProvider-DDRwHiPz.cjs.js +0 -1
- package/dist/components/legacy/Dashboard.d.ts +0 -68
- package/dist/components/legacy/malloynb/MalloynbCells.d.ts +0 -13
- package/dist/components/legacy/malloynb/Notebook.d.ts +0 -15
- package/dist/components/legacy/queryKeys.d.ts +0 -8
- package/src/components/legacy/Dashboard.spec.tsx +0 -242
- package/src/components/legacy/Dashboard.tsx +0 -181
- package/src/components/legacy/malloynb/MalloynbCells.tsx +0 -88
- package/src/components/legacy/malloynb/Notebook.layout.spec.tsx +0 -103
- package/src/components/legacy/malloynb/Notebook.served.spec.tsx +0 -84
- package/src/components/legacy/malloynb/Notebook.spec.tsx +0 -223
- package/src/components/legacy/malloynb/Notebook.tsx +0 -46
- package/src/components/legacy/queryKeys.ts +0 -26
- /package/dist/components/{legacy → Report}/malloynb/NotebookCell.d.ts +0 -0
- /package/dist/components/{legacy → Report}/malloynb/runPlan.d.ts +0 -0
- /package/dist/components/{legacy → Report}/malloynb/types.d.ts +0 -0
- /package/src/components/{legacy → Report}/malloynb/NotebookCell.tsx +0 -0
- /package/src/components/{legacy → Report}/malloynb/cellKind.spec.ts +0 -0
- /package/src/components/{legacy → Report}/malloynb/runPlan.spec.ts +0 -0
- /package/src/components/{legacy → Report}/malloynb/runPlan.ts +0 -0
- /package/src/components/{legacy → Report}/malloynb/types.ts +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated `.malloynb` only, and deleted with the format. A `.malloynb`
|
|
6
|
+
* drawn by `Report` from the `notebook` that `GET …/reports/{path}` serves,
|
|
7
|
+
* each code cell's served `runQuery` sent as it is to the governed query
|
|
8
|
+
* endpoint, `POST …/models/{path}/query`, with the notebook's own path as the
|
|
9
|
+
* model.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { isCancelledError } from "@tanstack/react-query";
|
|
13
|
+
import { useCallback } from "react";
|
|
14
|
+
import type { ReportCells } from "../../../client";
|
|
15
|
+
import {
|
|
16
|
+
queryResultKey,
|
|
17
|
+
requestQueryResult,
|
|
18
|
+
type QueryRequestSpec,
|
|
19
|
+
} from "../../../hooks/useQueryResult";
|
|
20
|
+
import { encodeResourceUri } from "../../../utils/formatting";
|
|
21
|
+
import {
|
|
22
|
+
CHART_RESULT_QUERY_OPTIONS,
|
|
23
|
+
globalQueryClient,
|
|
24
|
+
} from "../../../utils/queryClient";
|
|
25
|
+
import { givensToRequest } from "../../given/paramCodec";
|
|
26
|
+
import { useServer } from "../../ServerProvider";
|
|
27
|
+
import {
|
|
28
|
+
CellRunnerView,
|
|
29
|
+
type CellReportProps,
|
|
30
|
+
type CellRunner,
|
|
31
|
+
} from "./CellRunnerView";
|
|
32
|
+
|
|
33
|
+
export interface MalloynbReportProps
|
|
34
|
+
extends Omit<CellReportProps, "resourceUri"> {
|
|
35
|
+
environmentName: string;
|
|
36
|
+
packageName: string;
|
|
37
|
+
versionId?: string;
|
|
38
|
+
/** The notebook's package path, the model every cell runs against. */
|
|
39
|
+
path: string;
|
|
40
|
+
notebook: ReportCells;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function MalloynbReport({
|
|
44
|
+
environmentName,
|
|
45
|
+
packageName,
|
|
46
|
+
versionId,
|
|
47
|
+
path,
|
|
48
|
+
notebook,
|
|
49
|
+
...props
|
|
50
|
+
}: MalloynbReportProps) {
|
|
51
|
+
const { apiClients, server } = useServer();
|
|
52
|
+
const runCell = useCallback<CellRunner>(
|
|
53
|
+
async ({ cell, givens, declaredTypes, signal }) => {
|
|
54
|
+
const query = cell.runQuery;
|
|
55
|
+
// A cell that only imports or declares has nothing to run.
|
|
56
|
+
if (query === undefined) return {};
|
|
57
|
+
signal.throwIfAborted();
|
|
58
|
+
const request = givensToRequest(givens, declaredTypes);
|
|
59
|
+
const spec: QueryRequestSpec = {
|
|
60
|
+
environmentName,
|
|
61
|
+
packageName,
|
|
62
|
+
versionId,
|
|
63
|
+
modelPath: path,
|
|
64
|
+
query,
|
|
65
|
+
givens: Object.keys(request).length > 0 ? request : undefined,
|
|
66
|
+
};
|
|
67
|
+
// A tile's key, server last as `useQueryWithApiError` adds it, so a
|
|
68
|
+
// remount within the cache window reads the answer it already has.
|
|
69
|
+
const queryKey = [...queryResultKey(spec), server];
|
|
70
|
+
const fetch = () =>
|
|
71
|
+
globalQueryClient.fetchQuery({
|
|
72
|
+
queryKey,
|
|
73
|
+
queryFn: ({ signal: querySignal }) =>
|
|
74
|
+
requestQueryResult(apiClients, spec, querySignal),
|
|
75
|
+
...CHART_RESULT_QUERY_OPTIONS,
|
|
76
|
+
});
|
|
77
|
+
// Cancelling the entry reverts it, so an abandoned run caches nothing.
|
|
78
|
+
const cancel = () =>
|
|
79
|
+
void globalQueryClient.cancelQueries({ queryKey, exact: true });
|
|
80
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
81
|
+
try {
|
|
82
|
+
let response;
|
|
83
|
+
try {
|
|
84
|
+
response = await fetch();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
// Another run of the same cell was cancelled under this one.
|
|
87
|
+
if (!isCancelledError(error) || signal.aborted) throw error;
|
|
88
|
+
response = await fetch();
|
|
89
|
+
}
|
|
90
|
+
return { result: response.data.result };
|
|
91
|
+
} finally {
|
|
92
|
+
signal.removeEventListener("abort", cancel);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[apiClients, server, environmentName, packageName, path, versionId],
|
|
96
|
+
);
|
|
97
|
+
return (
|
|
98
|
+
<CellRunnerView
|
|
99
|
+
{...props}
|
|
100
|
+
resourceUri={encodeResourceUri({
|
|
101
|
+
environmentName,
|
|
102
|
+
packageName,
|
|
103
|
+
modelPath: path,
|
|
104
|
+
versionId,
|
|
105
|
+
})}
|
|
106
|
+
notebook={notebook}
|
|
107
|
+
runCell={runCell}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated `.malloynb` only; deleted with the format.
|
|
6
6
|
*
|
|
7
|
-
* How a `.malloynb` cell is read: every code cell
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* How a `.malloynb` cell is read: every code cell is handed to the runner,
|
|
8
|
+
* which sends the cell's served `runQuery`, and a cell's code is shown without
|
|
9
|
+
* its `##` lines (the notebook's own annotations), which are not part of the
|
|
10
|
+
* query. A `.malloy` report never reaches here: it is tiles.
|
|
10
11
|
*/
|
|
11
12
|
import type { NotebookCell } from "../../../client";
|
|
12
13
|
|
|
13
|
-
/** Whether the viewer
|
|
14
|
+
/** Whether the viewer hands a cell to its runner: every code cell. */
|
|
14
15
|
export function cellRuns(cell: Pick<NotebookCell, "type">): boolean {
|
|
15
16
|
return cell.type === "code";
|
|
16
17
|
}
|
|
@@ -72,9 +72,9 @@ import type { BuilderControlsHandler } from "./builderControls";
|
|
|
72
72
|
* The builder under a real control row, with the controls driving the tiles,
|
|
73
73
|
* both following the LIVE document rather than the saved file.
|
|
74
74
|
*
|
|
75
|
-
* Owns the given values for the same reason the reader's `
|
|
76
|
-
* bar and the tiles have to read one set of values, so whatever
|
|
77
|
-
* to sit above both. The manifest supplies what the file cannot say about the
|
|
75
|
+
* Owns the given values for the same reason the reader's `DashboardView`
|
|
76
|
+
* does: the bar and the tiles have to read one set of values, so whatever
|
|
77
|
+
* holds them has to sit above both. The manifest supplies what the file cannot say about the
|
|
78
78
|
* model's own givens, and the set of givens the server can be sent; a control
|
|
79
79
|
* declared here and not yet in the package is written into each tile's query as
|
|
80
80
|
* a literal, so it works the moment it is added.
|
|
@@ -111,8 +111,8 @@ describe("ReportBuilder", () => {
|
|
|
111
111
|
expect(screen.getByText("Storefront")).toBeDefined();
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
// The point of taking the rule from `
|
|
115
|
-
// what you arrange is what a reader sees.
|
|
114
|
+
// The point of taking the rule from `DashboardView` rather than restating
|
|
115
|
+
// it: what you arrange is what a reader sees.
|
|
116
116
|
it("lays tiles out on the dashboard's own grid rule", async () => {
|
|
117
117
|
await mount();
|
|
118
118
|
expect(itemStyleOf("by_cat")).toContain("grid-column: span 6");
|
|
@@ -68,7 +68,6 @@ const getReport = mock(
|
|
|
68
68
|
},
|
|
69
69
|
}),
|
|
70
70
|
);
|
|
71
|
-
const getDashboard = mock(() => pending());
|
|
72
71
|
const listModels = mock(async () => ({ data: [] }));
|
|
73
72
|
const executeQueryModel = mock(() => pending());
|
|
74
73
|
const updateModelSource = mock(
|
|
@@ -98,7 +97,6 @@ mockServerProvider(
|
|
|
98
97
|
getReport,
|
|
99
98
|
listReports: mock(async () => ({ data: [] })),
|
|
100
99
|
},
|
|
101
|
-
dashboards: { getDashboard },
|
|
102
100
|
},
|
|
103
101
|
serverContext,
|
|
104
102
|
);
|
|
@@ -137,7 +135,6 @@ beforeEach(async () => {
|
|
|
137
135
|
serverContext.mutable = true;
|
|
138
136
|
getModel.mockClear();
|
|
139
137
|
getReport.mockClear();
|
|
140
|
-
getDashboard.mockClear();
|
|
141
138
|
updateModelSource.mockClear();
|
|
142
139
|
});
|
|
143
140
|
|
|
@@ -154,7 +151,6 @@ describe("ReportEditor as a notebook", () => {
|
|
|
154
151
|
expect(getModel.mock.calls[0][4]).toBe(true);
|
|
155
152
|
await waitFor(() => expect(getReport).toHaveBeenCalled());
|
|
156
153
|
expect(getReport.mock.calls[0][2]).toBe("notebooks/tour.malloy");
|
|
157
|
-
expect(getDashboard).not.toHaveBeenCalled();
|
|
158
154
|
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
159
155
|
type: "report.opened",
|
|
160
156
|
surface: "edit",
|
|
@@ -304,9 +304,9 @@ describe("versionId", () => {
|
|
|
304
304
|
// Proof, not a proxy for one: the live query's key now ends in a
|
|
305
305
|
// version slot rather than at `modelPath`, and the invalidate call
|
|
306
306
|
// that follows a save has to end in the same slot to still match it.
|
|
307
|
-
// A version spliced into the middle of either key (as
|
|
308
|
-
//
|
|
309
|
-
// until something else happened to touch it.
|
|
307
|
+
// A version spliced into the middle of either key (as the removed
|
|
308
|
+
// `Dashboard` did for its own, unrelated, key) would leave this read
|
|
309
|
+
// stale until something else happened to touch it.
|
|
310
310
|
await waitFor(() =>
|
|
311
311
|
expect(
|
|
312
312
|
getModel.mock.calls.filter(
|
|
@@ -459,7 +459,7 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
459
459
|
const note = ordinary || caption === saveLabel ? "" : caption;
|
|
460
460
|
|
|
461
461
|
// After every hook, so the hook order does not depend on the URI. Same
|
|
462
|
-
// reasoning as `
|
|
462
|
+
// reasoning as `Report`'s own check.
|
|
463
463
|
if (!uriNamesBoth && "resourceUri" in props)
|
|
464
464
|
return (
|
|
465
465
|
<Alert severity="error" sx={{ m: 2 }}>
|
|
@@ -39,8 +39,5 @@ export async function loadMalloyTag(): Promise<MalloyTag> {
|
|
|
39
39
|
* the Explorer's callers import this (`EXPLORER_CALLERS`).
|
|
40
40
|
*/
|
|
41
41
|
export async function loadQueryBuilder(): Promise<QueryBuilder> {
|
|
42
|
-
return unwrapQueryBuilder(
|
|
43
|
-
// eslint-disable-next-line no-restricted-syntax -- the query builder's one loader, for the Explorer; every other rule still holds in this file
|
|
44
|
-
await import("@malloydata/malloy-query-builder"),
|
|
45
|
-
);
|
|
42
|
+
return unwrapQueryBuilder(await import("@malloydata/malloy-query-builder"));
|
|
46
43
|
}
|
|
@@ -14,13 +14,11 @@ import React, {
|
|
|
14
14
|
} from "react";
|
|
15
15
|
import {
|
|
16
16
|
ConnectionsApi,
|
|
17
|
-
DashboardsApi,
|
|
18
17
|
DataAppsApi,
|
|
19
18
|
DatabasesApi,
|
|
20
19
|
EnvironmentsApi,
|
|
21
20
|
MaterializationsApi,
|
|
22
21
|
ModelsApi,
|
|
23
|
-
NotebooksApi,
|
|
24
22
|
PackagesApi,
|
|
25
23
|
AgentsApi,
|
|
26
24
|
PublisherApi,
|
|
@@ -189,9 +187,7 @@ const getApiClients = (
|
|
|
189
187
|
environments: new EnvironmentsApi(config, basePath, axiosInstance),
|
|
190
188
|
packages: new PackagesApi(config, basePath, axiosInstance),
|
|
191
189
|
agents: new AgentsApi(config, basePath, axiosInstance),
|
|
192
|
-
dashboards: new DashboardsApi(config, basePath, axiosInstance),
|
|
193
190
|
dataApps: new DataAppsApi(config, basePath, axiosInstance),
|
|
194
|
-
notebooks: new NotebooksApi(config, basePath, axiosInstance),
|
|
195
191
|
reports: new ReportsApi(config, basePath, axiosInstance),
|
|
196
192
|
connections: new ConnectionsApi(config, basePath, axiosInstance),
|
|
197
193
|
databases: new DatabasesApi(config, basePath, axiosInstance),
|
|
@@ -11,16 +11,15 @@ import { escapeMalloyString } from "../../utils/malloyString";
|
|
|
11
11
|
*
|
|
12
12
|
* The rows query reads each dimension's value from here and writes it itself
|
|
13
13
|
* (`literalText`), rather than taking the renderer's own `DrillData.query`,
|
|
14
|
-
* which Malloy
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* filter does accept for every truncation is the truncated value itself
|
|
18
|
-
* full precision, so that is what is written: a date as its day, a
|
|
19
|
-
* to the second, or to its fraction when it has one.
|
|
14
|
+
* which Malloy cannot run as written for a truncated time: measured on 0.0.435,
|
|
15
|
+
* it reads every hour as `00`, and it writes quarter, week and minute literals
|
|
16
|
+
* (`@2026-Q1`) a filter refuses; 0.0.438 still writes a quarter that way.
|
|
17
|
+
* What a filter does accept for every truncation is the truncated value itself
|
|
18
|
+
* at full precision, so that is what is written: a date as its day, a
|
|
19
|
+
* timestamp to the second, or to its fraction when it has one.
|
|
20
20
|
*
|
|
21
|
-
* Remove
|
|
22
|
-
*
|
|
23
|
-
* truncated literals.
|
|
21
|
+
* Remove this workaround, and take `DrillData.query` as written, once a Malloy
|
|
22
|
+
* release fixes the renderer's hour digits and truncated literals.
|
|
24
23
|
*/
|
|
25
24
|
export type DrillClause = Malloy.DrillOperation;
|
|
26
25
|
|
|
@@ -18,15 +18,13 @@ import type { DrillField, DrillTagReader } from "./resolveDrill";
|
|
|
18
18
|
* whatever the tile was written as: `source -> view`, a refined view, a
|
|
19
19
|
* named query, an inline query, a nest.
|
|
20
20
|
*
|
|
21
|
-
* `where:` and not `drill:`,
|
|
22
|
-
*
|
|
23
|
-
* plain source field with none (`region`, not `by_month.region`), so its
|
|
24
|
-
* could not be named that way.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* reaches Publisher, the join is no longer a reason; the refined query's
|
|
29
|
-
* missing view path still is.
|
|
21
|
+
* `where:` and not `drill:`, because `drill:` needs the view's own path for
|
|
22
|
+
* every dimension, and a refined view, or a query with no view at all, reports
|
|
23
|
+
* a plain source field with none (`region`, not `by_month.region`), so its
|
|
24
|
+
* rows could not be named that way. Measured on Malloy 0.0.438, for a refined
|
|
25
|
+
* view written inline and as a named query. A `drill:` on a joined field no
|
|
26
|
+
* longer fails to bring the join in (malloydata/malloy#3158, fixed in
|
|
27
|
+
* 0.0.437), so that is not a reason.
|
|
30
28
|
*
|
|
31
29
|
* A field reads as having rows only when every piece is there: a source with
|
|
32
30
|
* no arguments, every level on the way down marked `drillable` (one stage),
|
package/src/components/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
// Exported because
|
|
5
|
-
//
|
|
6
|
-
// its own.
|
|
4
|
+
// Exported because Report and DashboardTile both present request failures
|
|
5
|
+
// through it; a host composing those needs the same presentation for its own.
|
|
7
6
|
export { ApiErrorDisplay, type ApiErrorDisplayProps } from "./ApiErrorDisplay";
|
|
8
7
|
// The Console's button roles; see `buttons.tsx`. Exported so a host — the
|
|
9
8
|
// Publisher app included — builds its own screens out of the same four.
|
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Deprecated surface kept for hosts that still use it: the by-name
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* code imports nothing from here; removing a feature is deleting its module
|
|
9
|
-
* and its line below.
|
|
5
|
+
* Deprecated surface kept for hosts that still use it: the by-name lookups
|
|
6
|
+
* behind old links, and the kind-typed vocabulary. Report code imports nothing
|
|
7
|
+
* from here; removing a feature is deleting its module and its line below.
|
|
10
8
|
*/
|
|
11
|
-
export { Dashboard, type DashboardProps } from "./Dashboard";
|
|
12
|
-
export { default as Notebook } from "./malloynb/Notebook";
|
|
13
9
|
export { type DocumentKind } from "./kindAdapter";
|
|
14
10
|
export {
|
|
15
11
|
documentRoute,
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The model page a server asks for, its `PUBLISHER_MODEL_PAGE
|
|
6
|
-
*
|
|
7
|
-
* (`escapeString` in `@malloydata/malloy-interfaces` is a TODO), so a drilled
|
|
8
|
-
* value holding a double quote rewrites its query; `viewer` shows a page that
|
|
9
|
-
* builds none.
|
|
5
|
+
* The model page a server asks for, its `PUBLISHER_MODEL_PAGE`: `explorer`
|
|
6
|
+
* builds queries, `viewer` shows a page that builds none.
|
|
10
7
|
*/
|
|
11
8
|
export type ModelPage = "explorer" | "viewer";
|
|
12
9
|
|
|
@@ -365,9 +365,8 @@ export function useGivensState({
|
|
|
365
365
|
// a link copied before anything was touched follows the file's starting
|
|
366
366
|
// values as they are later edited, rather than pinning the ones it was opened
|
|
367
367
|
// at. That falls out of the seeding below for a host that mounts this with
|
|
368
|
-
// its manifest loaded, as
|
|
369
|
-
// and loads after
|
|
370
|
-
// an uncached load.)
|
|
368
|
+
// its manifest loaded, as `Report` does for either format. A host that
|
|
369
|
+
// mounts first and loads after reports them on an uncached load.
|
|
371
370
|
//
|
|
372
371
|
// The reference starts at the first render's values rather than empty. The
|
|
373
372
|
// control row is empty until the manifest arrives and says which givens
|
|
@@ -394,11 +393,12 @@ export function useGivensState({
|
|
|
394
393
|
lastReportedAt.current = Date.now();
|
|
395
394
|
}
|
|
396
395
|
// Recorded only when the report is actually DELIVERED. A surface withholds
|
|
397
|
-
// the callback while it is still loading — `
|
|
398
|
-
// the document has arrived, so that a report made in the
|
|
399
|
-
// does not yet know which givens exist cannot tell the host
|
|
400
|
-
// parameters belonging to the notebook then arriving — and a value
|
|
401
|
-
// in that window is remembered as reported without the host ever
|
|
396
|
+
// the callback while it is still loading — `useDocumentControls` passes
|
|
397
|
+
// undefined until the document has arrived, so that a report made in the
|
|
398
|
+
// window where it does not yet know which givens exist cannot tell the host
|
|
399
|
+
// to clear parameters belonging to the notebook then arriving — and a value
|
|
400
|
+
// recorded in that window is remembered as reported without the host ever
|
|
401
|
+
// hearing it.
|
|
402
402
|
//
|
|
403
403
|
// That is not merely a missed report, because the echo test above reads this
|
|
404
404
|
// same record: the host's URL still holds the old value, the record says the
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import { Given,
|
|
5
|
+
import { Given, ReportCells } from "../client";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Extracts the deduplicated list of model-level `given:` declarations from
|
|
@@ -12,7 +12,7 @@ import { Given, RawNotebook } from "../client";
|
|
|
12
12
|
*
|
|
13
13
|
* Returns an empty array when no givens are declared on any source.
|
|
14
14
|
*/
|
|
15
|
-
export function useModelGivens(notebook:
|
|
15
|
+
export function useModelGivens(notebook: ReportCells | undefined): Given[] {
|
|
16
16
|
return useMemo(() => {
|
|
17
17
|
if (!notebook?.sources?.length) return [];
|
|
18
18
|
const byName = new Map<string, Given>();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import type { QueryKey } from "@tanstack/react-query";
|
|
5
|
-
import { useServer } from "../components/ServerProvider";
|
|
5
|
+
import { type ApiClients, useServer } from "../components/ServerProvider";
|
|
6
6
|
import { CHART_RESULT_QUERY_OPTIONS } from "../utils/queryClient";
|
|
7
7
|
import { keepPreviousData } from "@tanstack/react-query";
|
|
8
8
|
import { useQueryWithApiError } from "./useQueryWithApiError";
|
|
@@ -70,6 +70,34 @@ export function modelResultsKey(
|
|
|
70
70
|
];
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* The request for `spec`, cancelled by `signal`: what {@link useQueryResult}
|
|
75
|
+
* sends for a tile and a `.malloynb` sends for a cell, so a result cached
|
|
76
|
+
* under {@link queryResultKey} is the same answer whichever of them asked.
|
|
77
|
+
*/
|
|
78
|
+
export function requestQueryResult(
|
|
79
|
+
apiClients: ApiClients,
|
|
80
|
+
spec: QueryRequestSpec,
|
|
81
|
+
signal?: AbortSignal,
|
|
82
|
+
) {
|
|
83
|
+
return apiClients.models.executeQueryModel(
|
|
84
|
+
spec.environmentName,
|
|
85
|
+
spec.packageName,
|
|
86
|
+
spec.modelPath,
|
|
87
|
+
{
|
|
88
|
+
queryName: spec.queryName,
|
|
89
|
+
query: spec.query,
|
|
90
|
+
sourceName: spec.sourceName,
|
|
91
|
+
givens: spec.givens,
|
|
92
|
+
versionId: spec.versionId,
|
|
93
|
+
},
|
|
94
|
+
undefined,
|
|
95
|
+
// versionId: carried in the body.
|
|
96
|
+
undefined,
|
|
97
|
+
{ signal },
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
73
101
|
export function useQueryResult(
|
|
74
102
|
spec: QueryRequestSpec,
|
|
75
103
|
{ enabled = true }: { enabled?: boolean } = {},
|
|
@@ -82,23 +110,7 @@ export function useQueryResult(
|
|
|
82
110
|
// changed under it, or one that unmounted. react-query reverts a
|
|
83
111
|
// cancelled query to its previous state rather than to an error, so an
|
|
84
112
|
// abort never reaches `ResultPanel`'s failed state.
|
|
85
|
-
queryFn: ({ signal }) =>
|
|
86
|
-
apiClients.models.executeQueryModel(
|
|
87
|
-
spec.environmentName,
|
|
88
|
-
spec.packageName,
|
|
89
|
-
spec.modelPath,
|
|
90
|
-
{
|
|
91
|
-
queryName: spec.queryName,
|
|
92
|
-
query: spec.query,
|
|
93
|
-
sourceName: spec.sourceName,
|
|
94
|
-
givens: spec.givens,
|
|
95
|
-
versionId: spec.versionId,
|
|
96
|
-
},
|
|
97
|
-
undefined,
|
|
98
|
-
// versionId: carried in the body.
|
|
99
|
-
undefined,
|
|
100
|
-
{ signal },
|
|
101
|
-
),
|
|
113
|
+
queryFn: ({ signal }) => requestQueryResult(apiClients, spec, signal),
|
|
102
114
|
enabled,
|
|
103
115
|
// A change of givens is a new key, and without this the surface drops to
|
|
104
116
|
// "Running…" and back: every tile on a page blanked and redrew on each
|
package/test/README.md
CHANGED
|
@@ -132,13 +132,13 @@ is the one way to do it:
|
|
|
132
132
|
import { cacheKeys, clearCache, mockServerProvider, pending, serverWrapper }
|
|
133
133
|
from "../../../test/serverProvider";
|
|
134
134
|
|
|
135
|
-
const
|
|
136
|
-
mockServerProvider({
|
|
135
|
+
const getReport = mock(() => pending());
|
|
136
|
+
mockServerProvider({ reports: { getReport } });
|
|
137
137
|
|
|
138
138
|
// AFTER the line above, never a static import: it would hoist past the stub.
|
|
139
|
-
const {
|
|
139
|
+
const { Report } = await import("./Report");
|
|
140
140
|
|
|
141
|
-
render(<
|
|
141
|
+
render(<Report resourceUri={URI} path="ops.malloy" />, { wrapper: serverWrapper });
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
Three things that file exists to get right.
|