@malloy-publisher/sdk 0.0.239 → 0.0.241
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/bunfig.toml +4 -0
- package/dist/ServerProvider-D40U1tBk.cjs.js +1 -0
- package/dist/{ServerProvider-kzoOMXNx.es.js → ServerProvider-FQ4I4dKu.es.js} +250 -241
- package/dist/client/api.d.ts +181 -109
- 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 +70 -68
- package/dist/components/{PageViewer/PageViewer.d.ts → DataAppViewer/DataAppViewer.d.ts} +6 -6
- package/dist/components/DataAppViewer/index.d.ts +1 -0
- package/dist/components/Package/ContentTypeIcon.d.ts +1 -1
- package/dist/components/ServerProvider.d.ts +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/{core-DtPGM_JB.cjs.js → core-2tUy-45C.cjs.js} +1 -1
- package/dist/{core-BGHaIj_q.es.js → core-KFsKleo0.es.js} +1 -1
- package/dist/hooks/useGivensForm.d.ts +8 -4
- package/dist/{index-B2gBd2gP.cjs.js → index-C0EfXZ-k.cjs.js} +31 -31
- package/dist/{index-CEteIhTc.es.js → index-D2sq6csh.es.js} +1825 -1829
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +34 -34
- package/dist/utils/{pageEmbed.d.ts → dataAppEmbed.d.ts} +7 -7
- package/package.json +7 -4
- package/src/components/{PageViewer/PageViewer.tsx → DataAppViewer/DataAppViewer.tsx} +41 -36
- package/src/components/DataAppViewer/index.ts +1 -0
- package/src/components/Package/ContentTypeIcon.tsx +2 -2
- package/src/components/Package/Package.tsx +28 -30
- package/src/components/ServerProvider.tsx +2 -2
- package/src/components/given/GivenInput.spec.tsx +206 -0
- package/src/components/given/GivenInput.tsx +6 -1
- package/src/components/index.ts +1 -1
- package/src/hooks/useGivensForm.spec.ts +99 -0
- package/src/hooks/useGivensForm.ts +14 -5
- package/src/index.ts +1 -1
- package/src/utils/{pageEmbed.spec.ts → dataAppEmbed.spec.ts} +1 -1
- package/src/utils/{pageEmbed.ts → dataAppEmbed.ts} +9 -9
- package/test/README.md +130 -0
- package/test/setup.ts +26 -0
- package/tsconfig.json +12 -1
- package/tsconfig.spec.json +22 -0
- package/dist/ServerProvider-nJNqhxy6.cjs.js +0 -1
- package/dist/components/PageViewer/index.d.ts +0 -1
- package/src/components/PageViewer/index.ts +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-C0EfXZ-k.cjs.js"),r=require("./ServerProvider-D40U1tBk.cjs.js");exports.AnalyzePackageButton=e.AnalyzePackageButton;exports.BrowserWorkbookStorage=e.BrowserWorkbookStorage;exports.ConnectionExplorer=e.ConnectionExplorer;exports.DOC_LINKS=e.DOC_LINKS;exports.DataAppViewer=e.DataAppViewer;exports.DimensionFilter=e.DimensionFilter;exports.EmbeddedQueryResult=e.EmbeddedQueryResult;exports.Environment=e.Environment;exports.EnvironmentMaterializations=e.EnvironmentMaterializations;exports.Home=e.Home;exports.Loading=e.Loading;exports.Materializations=e.Materializations;exports.Model=e.Model;exports.ModelExplorer=e.ModelExplorer;exports.ModelExplorerDialog=e.ModelExplorerDialog;exports.Models=e.Models;exports.Notebook=e.Notebook;exports.Package=e.Package;exports.Packages=e.Packages;exports.QueryResult=e.QueryResult;exports.RenderedResult=e.RenderedResult;exports.ResultContainer=e.ResultContainer;exports.SourceExplorerComponent=e.SourceExplorerComponent;exports.SourcesExplorer=e.SourcesExplorer;exports.Workbook=e.Workbook;exports.WorkbookList=e.WorkbookList;exports.WorkbookManager=e.WorkbookManager;exports.WorkbookStorageProvider=e.WorkbookStorageProvider;exports.buildMalloyExplicitTheme=e.buildMalloyExplicitTheme;exports.buildTableCssVars=e.buildTableCssVars;exports.buildVegaThemeOverride=e.buildVegaThemeOverride;exports.createEmbeddedQueryResult=e.createEmbeddedQueryResult;exports.encodeResourceUri=e.encodeResourceUri;exports.extractDimensionSpecs=e.extractDimensionSpecs;exports.extractSourceFromQuery=e.extractSourceFromQuery;exports.generateFilterClause=e.generateFilterClause;exports.getDimensionKey=e.getDimensionKey;exports.getJoinedSources=e.getJoinedSources;exports.injectWhereClause=e.injectWhereClause;exports.makeDimensionKey=e.makeDimensionKey;exports.packageFileUrl=e.packageFileUrl;exports.parseAllSourceInfos=e.parseAllSourceInfos;exports.parseDimensionFilterAnnotation=e.parseDimensionFilterAnnotation;exports.parseNotebookFilterAnnotation=e.parseNotebookFilterAnnotation;exports.parseResourceUri=e.parseResourceUri;exports.readChartAnnotations=e.readChartAnnotations;exports.useDimensionFilters=e.useDimensionFilters;exports.useDimensionFiltersFromSpec=e.useDimensionFiltersFromSpec;exports.useDimensionFiltersQuery=e.useDimensionFiltersQuery;exports.useDimensionalFilterRangeData=e.useDimensionalFilterRangeData;exports.useGivensForm=e.useGivensForm;exports.useModelData=e.useModelData;exports.useModelGivens=e.useModelGivens;exports.useRawQueryData=e.useRawQueryData;exports.useRouterClickHandler=e.useRouterClickHandler;exports.DEFAULT_THEME=r.DEFAULT_THEME;exports.ServerProvider=r.ServerProvider;exports.ThemeProvider=r.ThemeProvider;exports.resolveMode=r.resolveMode;exports.resolveTheme=r.resolveTheme;exports.usePublisherTheme=r.usePublisherTheme;exports.useServer=r.useServer;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export * from './hooks';
|
|
|
5
5
|
export { useRawQueryData } from './hooks/useRawQueryData';
|
|
6
6
|
export * from './theme';
|
|
7
7
|
export * from './utils/formatting';
|
|
8
|
-
export { packageFileUrl } from './utils/
|
|
8
|
+
export { packageFileUrl } from './utils/dataAppEmbed';
|
|
9
9
|
export * from './constants/docLinks';
|
package/dist/index.es.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { A as s, U as o, C as r, a9 as i, D as n,
|
|
2
|
-
import {
|
|
1
|
+
import { A as s, U as o, C as r, a9 as i, D as n, g as t, I as l, E as u, r as d, H as m, L as c, M as k, t as p, v as D, x as g, G as b, N as E, F, P as S, Q as v, R as M, K as R, y as x, S as y, W as C, O as T, V as h, T as A, a3 as P, a4 as Q, a5 as W, J as H, a8 as K, i as L, j as U, k as I, $ as N, l as V, m as f, a0 as w, p as z, n as B, o as G, q as J, a7 as O, a6 as _, X as j, Y as q, Z as X, _ as Y, a2 as Z, B as $, a1 as ee, u as ae, e as se } from "./index-D2sq6csh.es.js";
|
|
2
|
+
import { aI as re, S as ie, aK as ne, aJ as te, aH as le, at as ue, u as de } from "./ServerProvider-FQ4I4dKu.es.js";
|
|
3
3
|
export {
|
|
4
4
|
s as AnalyzePackageButton,
|
|
5
5
|
o as BrowserWorkbookStorage,
|
|
6
6
|
r as ConnectionExplorer,
|
|
7
7
|
re as DEFAULT_THEME,
|
|
8
8
|
i as DOC_LINKS,
|
|
9
|
-
n as
|
|
10
|
-
t as
|
|
11
|
-
l as
|
|
12
|
-
u as
|
|
13
|
-
d as
|
|
14
|
-
m as
|
|
15
|
-
c as
|
|
16
|
-
k as
|
|
17
|
-
p as
|
|
9
|
+
n as DataAppViewer,
|
|
10
|
+
t as DimensionFilter,
|
|
11
|
+
l as EmbeddedQueryResult,
|
|
12
|
+
u as Environment,
|
|
13
|
+
d as EnvironmentMaterializations,
|
|
14
|
+
m as Home,
|
|
15
|
+
c as Loading,
|
|
16
|
+
k as Materializations,
|
|
17
|
+
p as Model,
|
|
18
|
+
D as ModelExplorer,
|
|
18
19
|
g as ModelExplorerDialog,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
S as PageViewer,
|
|
20
|
+
b as Models,
|
|
21
|
+
E as Notebook,
|
|
22
|
+
F as Package,
|
|
23
|
+
S as Packages,
|
|
24
24
|
v as QueryResult,
|
|
25
25
|
M as RenderedResult,
|
|
26
26
|
R as ResultContainer,
|
|
@@ -29,30 +29,30 @@ export {
|
|
|
29
29
|
y as SourcesExplorer,
|
|
30
30
|
ne as ThemeProvider,
|
|
31
31
|
C as Workbook,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
T as WorkbookList,
|
|
33
|
+
h as WorkbookManager,
|
|
34
|
+
A as WorkbookStorageProvider,
|
|
35
|
+
P as buildMalloyExplicitTheme,
|
|
36
36
|
Q as buildTableCssVars,
|
|
37
37
|
W as buildVegaThemeOverride,
|
|
38
38
|
H as createEmbeddedQueryResult,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
K as encodeResourceUri,
|
|
40
|
+
L as extractDimensionSpecs,
|
|
41
|
+
U as extractSourceFromQuery,
|
|
42
42
|
I as generateFilterClause,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
N as getDimensionKey,
|
|
44
|
+
V as getJoinedSources,
|
|
45
|
+
f as injectWhereClause,
|
|
46
|
+
w as makeDimensionKey,
|
|
47
|
+
z as packageFileUrl,
|
|
48
|
+
B as parseAllSourceInfos,
|
|
49
|
+
G as parseDimensionFilterAnnotation,
|
|
50
|
+
J as parseNotebookFilterAnnotation,
|
|
51
|
+
O as parseResourceUri,
|
|
52
|
+
_ as readChartAnnotations,
|
|
53
53
|
te as resolveMode,
|
|
54
54
|
le as resolveTheme,
|
|
55
|
-
|
|
55
|
+
j as useDimensionFilters,
|
|
56
56
|
q as useDimensionFiltersFromSpec,
|
|
57
57
|
X as useDimensionFiltersQuery,
|
|
58
58
|
Y as useDimensionalFilterRangeData,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* postMessage `type` an embedded
|
|
3
|
-
* height changes, so the host can resize the iframe to avoid nested
|
|
4
|
-
* Payload shape is {@link PublisherResizeMessage}.
|
|
2
|
+
* postMessage `type` an embedded data app emits to its host frame as its
|
|
3
|
+
* content height changes, so the host can resize the iframe to avoid nested
|
|
4
|
+
* scrollbars. Payload shape is {@link PublisherResizeMessage}.
|
|
5
5
|
*/
|
|
6
6
|
export declare const PUBLISHER_RESIZE_MESSAGE_TYPE = "publisher:resize";
|
|
7
|
-
/** Resize message posted by an embedded
|
|
7
|
+
/** Resize message posted by an embedded data app's publisher.js runtime. */
|
|
8
8
|
export interface PublisherResizeMessage {
|
|
9
9
|
type: typeof PUBLISHER_RESIZE_MESSAGE_TYPE;
|
|
10
10
|
/** Content height in CSS pixels. */
|
|
@@ -18,15 +18,15 @@ export declare function isPublisherResizeMessage(data: unknown): data is Publish
|
|
|
18
18
|
*
|
|
19
19
|
* The static-file routes live off the server root, not under the API prefix,
|
|
20
20
|
* and the data origin can differ from the SPA origin in multi-host
|
|
21
|
-
* deployments — so a
|
|
22
|
-
* with
|
|
21
|
+
* deployments — so a data app's standalone URL is `serverBaseUrl(server)`
|
|
22
|
+
* joined with its root-relative `resource`.
|
|
23
23
|
*/
|
|
24
24
|
export declare function serverBaseUrl(server: string): string;
|
|
25
25
|
/**
|
|
26
26
|
* Absolute URL of a file inside a package, as Publisher serves it:
|
|
27
27
|
* `<data origin>/environments/<env>/packages/<pkg>/<path>`.
|
|
28
28
|
*
|
|
29
|
-
* The one home for this string. Both the
|
|
29
|
+
* The one home for this string. Both the data app viewer's iframe and the
|
|
30
30
|
* "this is not a model" page point at it, and hand-building it in each place is
|
|
31
31
|
* how the two drift.
|
|
32
32
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloy-publisher/sdk",
|
|
3
3
|
"description": "Malloy Publisher SDK",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.241",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"build": "bun generate-api-types && bunx vite build",
|
|
61
61
|
"postbuild": "cp ../../node_modules/@malloydata/malloy-explorer/dist/malloy-explorer.css ./dist/malloy-explorer.css && cp ../../node_modules/@uiw/react-md-editor/markdown-editor.css ./dist/markdown-editor.css && echo '/* SDK Styles */\n@import \"./malloy-explorer.css\";\n@import \"./markdown-editor.css\";' > ./dist/styles.css",
|
|
62
62
|
"test": "bun test",
|
|
63
|
-
"lint": "bunx eslint ./src --fix",
|
|
63
|
+
"lint": "bunx eslint ./src ./test --fix",
|
|
64
64
|
"format": "bunx prettier --write --parser typescript '**/*.{ts,tsx}'",
|
|
65
65
|
"analyze": "bunx vite-bundle-visualizer",
|
|
66
66
|
"generate-api-types": "bunx openapi-generator-cli generate -i ../../api-doc.yaml -g typescript-axios -o src/client/"
|
|
@@ -93,10 +93,15 @@
|
|
|
93
93
|
"dayjs": "^1.11.13"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
+
"@happy-dom/global-registrator": "^20.11.1",
|
|
96
97
|
"@malloydata/malloy-explorer": "0.0.338-dev260215172810",
|
|
97
98
|
"@malloydata/malloy-query-builder": "^0.0.427",
|
|
98
99
|
"@malloydata/malloy-tag": "^0.0.427",
|
|
99
100
|
"@openapitools/openapi-generator-cli": "^2.20.2",
|
|
101
|
+
"@shikijs/langs": "^1.16.3",
|
|
102
|
+
"@shikijs/themes": "^1.16.3",
|
|
103
|
+
"@testing-library/dom": "^10.4.1",
|
|
104
|
+
"@testing-library/react": "^16.3.2",
|
|
100
105
|
"@types/bun": "^1.2.21",
|
|
101
106
|
"@types/k6": "^1.0.2",
|
|
102
107
|
"@types/react": "^19.1.7",
|
|
@@ -112,8 +117,6 @@
|
|
|
112
117
|
"eslint-plugin-react-hooks": "5.0.0",
|
|
113
118
|
"eslint-plugin-storybook": "^0.11.4",
|
|
114
119
|
"shiki": "^1.16.3",
|
|
115
|
-
"@shikijs/langs": "^1.16.3",
|
|
116
|
-
"@shikijs/themes": "^1.16.3",
|
|
117
120
|
"vite": "^6.3.2",
|
|
118
121
|
"vite-plugin-dts": "^4.5.3",
|
|
119
122
|
"vite-plugin-svgr": "^4.3.0"
|
|
@@ -8,47 +8,47 @@ import { parseResourceUri } from "../../utils/formatting";
|
|
|
8
8
|
import {
|
|
9
9
|
isPublisherResizeMessage,
|
|
10
10
|
packageFileUrl,
|
|
11
|
-
} from "../../utils/
|
|
11
|
+
} from "../../utils/dataAppEmbed";
|
|
12
12
|
|
|
13
|
-
interface
|
|
13
|
+
interface DataAppViewerProps {
|
|
14
14
|
resourceUri: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function
|
|
17
|
+
function parseDataAppResource(resourceUri: string) {
|
|
18
18
|
try {
|
|
19
19
|
const { environmentName, packageName, modelPath } =
|
|
20
20
|
parseResourceUri(resourceUri);
|
|
21
21
|
if (!environmentName || !packageName || !modelPath) return null;
|
|
22
|
-
return { environmentName, packageName,
|
|
22
|
+
return { environmentName, packageName, dataAppPath: modelPath };
|
|
23
23
|
} catch {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Renders an in-package HTML
|
|
29
|
+
* Renders an in-package HTML data app (from the Publisher static-file route)
|
|
30
30
|
* inside an iframe, wrapped in light SPA chrome — title, breadcrumb-ish
|
|
31
31
|
* label, and an "open standalone" escape hatch.
|
|
32
32
|
*
|
|
33
33
|
* The iframe `src` points at the Publisher worker's standalone URL on the
|
|
34
34
|
* data origin (derived from `useServer().server`, which may differ from
|
|
35
|
-
* the SPA origin in multi-host deployments). The
|
|
35
|
+
* the SPA origin in multi-host deployments). The app's `publisher.js`
|
|
36
36
|
* runtime postMessages `{ type: "publisher:resize", height }` as content
|
|
37
37
|
* height changes; we listen and resize the iframe to match so embedded
|
|
38
38
|
* dashboards don't get a nested scrollbar.
|
|
39
39
|
*
|
|
40
40
|
* Full-screen apps (e.g. slide decks) can opt out of content-height sizing
|
|
41
41
|
* with `<meta name="publisher:fit" content="viewport">`, surfaced as
|
|
42
|
-
* `
|
|
43
|
-
* height (matching the standalone view) instead of collapsing to the
|
|
42
|
+
* `DataApp.fit === "viewport"`. The iframe then fills the available viewport
|
|
43
|
+
* height (matching the standalone view) instead of collapsing to the app's
|
|
44
44
|
* near-zero reported content height.
|
|
45
45
|
*/
|
|
46
|
-
export default function
|
|
46
|
+
export default function DataAppViewer({ resourceUri }: DataAppViewerProps) {
|
|
47
47
|
const { server, apiClients } = useServer();
|
|
48
|
-
const parsed =
|
|
48
|
+
const parsed = parseDataAppResource(resourceUri);
|
|
49
49
|
const environmentName = parsed?.environmentName ?? "";
|
|
50
50
|
const packageName = parsed?.packageName ?? "";
|
|
51
|
-
const
|
|
51
|
+
const dataAppPath = parsed?.dataAppPath ?? "";
|
|
52
52
|
|
|
53
53
|
const standaloneUrl = useMemo(
|
|
54
54
|
() =>
|
|
@@ -56,29 +56,33 @@ export default function PageViewer({ resourceUri }: PageViewerProps) {
|
|
|
56
56
|
server,
|
|
57
57
|
environmentName,
|
|
58
58
|
packageName,
|
|
59
|
-
path:
|
|
59
|
+
path: dataAppPath,
|
|
60
60
|
}),
|
|
61
|
-
[server, environmentName, packageName,
|
|
61
|
+
[server, environmentName, packageName, dataAppPath],
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
// Use the /
|
|
65
|
-
// here (older Publisher without /
|
|
66
|
-
// non-fatal — `title` falls back to `
|
|
67
|
-
// renders. The
|
|
64
|
+
// Use the /data-apps endpoint to grab the <title> for the header. Any error
|
|
65
|
+
// here (older Publisher without /data-apps, transient network blip, 5xx) is
|
|
66
|
+
// non-fatal — `title` falls back to `dataAppPath` and the iframe still
|
|
67
|
+
// renders. The app itself is loaded via the iframe `src`, not from this
|
|
68
68
|
// query, so blocking the viewer on a metadata lookup would be wrong.
|
|
69
|
-
const
|
|
70
|
-
queryKey: ["
|
|
71
|
-
queryFn: () =>
|
|
69
|
+
const dataAppsQuery = useQueryWithApiError({
|
|
70
|
+
queryKey: ["data-apps", environmentName, packageName],
|
|
71
|
+
queryFn: () =>
|
|
72
|
+
apiClients.dataApps.listDataApps(environmentName, packageName),
|
|
72
73
|
enabled: !!parsed,
|
|
73
74
|
});
|
|
74
|
-
const
|
|
75
|
-
|
|
75
|
+
const dataAppMeta = dataAppsQuery.data?.data?.find(
|
|
76
|
+
(a) => a.path === dataAppPath,
|
|
77
|
+
);
|
|
78
|
+
const title = dataAppMeta?.title ?? dataAppPath;
|
|
76
79
|
// Full-screen apps opt in via <meta name="publisher:fit" content="viewport">
|
|
77
|
-
// (surfaced as
|
|
78
|
-
// the available viewport height instead of being sized to the
|
|
79
|
-
// content height: a viewport-filling deck has ~no content
|
|
80
|
-
// so the default auto-size would clip it.
|
|
81
|
-
|
|
80
|
+
// (surfaced as DataApp.fit by the /data-apps listing). In fill mode the
|
|
81
|
+
// iframe fills the available viewport height instead of being sized to the
|
|
82
|
+
// app's reported content height: a viewport-filling deck has ~no content
|
|
83
|
+
// height to report, so the default auto-size would clip it. An ordinary
|
|
84
|
+
// content-driven app keeps auto-sizing.
|
|
85
|
+
const fillViewport = dataAppMeta?.fit === "viewport";
|
|
82
86
|
|
|
83
87
|
const iframeRef = useRef<HTMLIFrameElement | null>(null);
|
|
84
88
|
// Start small so the iframe doesn't pre-commit space before the first
|
|
@@ -89,7 +93,7 @@ export default function PageViewer({ resourceUri }: PageViewerProps) {
|
|
|
89
93
|
useEffect(() => {
|
|
90
94
|
// Fill mode pins the iframe to 100%, so content-height resize messages are
|
|
91
95
|
// irrelevant; skip subscribing (and the per-message re-renders) until the
|
|
92
|
-
//
|
|
96
|
+
// app is in content-height mode.
|
|
93
97
|
if (fillViewport) return;
|
|
94
98
|
function onMessage(e: MessageEvent) {
|
|
95
99
|
if (!isPublisherResizeMessage(e.data)) return;
|
|
@@ -106,10 +110,10 @@ export default function PageViewer({ resourceUri }: PageViewerProps) {
|
|
|
106
110
|
return (
|
|
107
111
|
<Box sx={{ p: 3, maxWidth: 1200, mx: "auto" }}>
|
|
108
112
|
<Typography variant="h6" sx={{ fontWeight: 600 }}>
|
|
109
|
-
Can't open
|
|
113
|
+
Can't open data app
|
|
110
114
|
</Typography>
|
|
111
115
|
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
|
|
112
|
-
This
|
|
116
|
+
This data app link is missing an environment, package, or path:
|
|
113
117
|
<Box
|
|
114
118
|
component="span"
|
|
115
119
|
sx={{ fontFamily: MONO_FONT_FAMILY, ml: 1 }}
|
|
@@ -125,10 +129,11 @@ export default function PageViewer({ resourceUri }: PageViewerProps) {
|
|
|
125
129
|
<Box
|
|
126
130
|
sx={{
|
|
127
131
|
p: 3,
|
|
128
|
-
// Fill mode fills the available height of
|
|
129
|
-
// it must render inside a height-constrained container. The
|
|
130
|
-
// app provides one (MainPage's 100dvh flex chain); an SDK
|
|
131
|
-
// embedding
|
|
132
|
+
// Fill mode fills the available height of DataAppViewer's ancestor,
|
|
133
|
+
// so it must render inside a height-constrained container. The
|
|
134
|
+
// Publisher app provides one (MainPage's 100dvh flex chain); an SDK
|
|
135
|
+
// consumer embedding DataAppViewer should give it a bounded-height
|
|
136
|
+
// parent.
|
|
132
137
|
...(fillViewport
|
|
133
138
|
? { height: "100%", display: "flex", flexDirection: "column" }
|
|
134
139
|
: { maxWidth: 1200, mx: "auto" }),
|
|
@@ -151,7 +156,7 @@ export default function PageViewer({ resourceUri }: PageViewerProps) {
|
|
|
151
156
|
color="text.secondary"
|
|
152
157
|
sx={{ fontFamily: MONO_FONT_FAMILY }}
|
|
153
158
|
>
|
|
154
|
-
{
|
|
159
|
+
{dataAppPath}
|
|
155
160
|
</Typography>
|
|
156
161
|
<Box sx={{ flex: 1 }} />
|
|
157
162
|
<Tooltip title="Open standalone in new tab">
|
|
@@ -175,7 +180,7 @@ export default function PageViewer({ resourceUri }: PageViewerProps) {
|
|
|
175
180
|
overflow: "hidden",
|
|
176
181
|
backgroundColor: "background.paper",
|
|
177
182
|
// Fill mode: grow to consume the remaining viewport height (the
|
|
178
|
-
// SPA gives
|
|
183
|
+
// SPA gives DataAppViewer a 100dvh flex ancestor) so the iframe
|
|
179
184
|
// below can be 100% tall. minHeight:0 lets this flex child
|
|
180
185
|
// actually shrink/grow instead of overflowing its parent.
|
|
181
186
|
...(fillViewport ? { flex: 1, minHeight: 0 } : {}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DataAppViewer } from "./DataAppViewer";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SvgIcon, { SvgIconProps } from "@mui/material/SvgIcon";
|
|
2
2
|
|
|
3
|
-
type ContentType = "report" | "model" | "data" | "materialization" | "
|
|
3
|
+
type ContentType = "report" | "model" | "data" | "materialization" | "dataApp";
|
|
4
4
|
|
|
5
5
|
interface ContentTypeIconProps extends Omit<SvgIconProps, "fontSize"> {
|
|
6
6
|
type: ContentType;
|
|
@@ -39,7 +39,7 @@ export default function ContentTypeIcon({
|
|
|
39
39
|
{type === "model" && <BoxTopPath />}
|
|
40
40
|
{type === "data" && <TablePath />}
|
|
41
41
|
{type === "materialization" && <StackPath />}
|
|
42
|
-
{type === "
|
|
42
|
+
{type === "dataApp" && <BrowserWindowPath />}
|
|
43
43
|
</SvgIcon>
|
|
44
44
|
);
|
|
45
45
|
}
|
|
@@ -27,7 +27,7 @@ import { Loading } from "../Loading";
|
|
|
27
27
|
import { Notebook } from "../Notebook";
|
|
28
28
|
import { useServer } from "../ServerProvider";
|
|
29
29
|
import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
|
|
30
|
-
import { serverBaseUrl } from "../../utils/
|
|
30
|
+
import { serverBaseUrl } from "../../utils/dataAppEmbed";
|
|
31
31
|
import { MALLOY_BRAND, MONO_FONT_FAMILY } from "../styles";
|
|
32
32
|
import ContentTypeIcon from "./ContentTypeIcon";
|
|
33
33
|
|
|
@@ -93,40 +93,40 @@ export default function Package({
|
|
|
93
93
|
),
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
// List of HTML
|
|
96
|
+
// List of in-package HTML data apps bundled inside the package.
|
|
97
97
|
// Goes through the configured API client so consumers using a non-default
|
|
98
98
|
// baseURL or Bearer auth (via <ServerProvider>) get the same plumbing as
|
|
99
99
|
// every other endpoint.
|
|
100
|
-
// No versionId in the key: /
|
|
101
|
-
// versioned (
|
|
102
|
-
// versionId would fragment the cache and prevent
|
|
100
|
+
// No versionId in the key: /data-apps serves static files, which aren't
|
|
101
|
+
// versioned (listDataApps takes only env + package), so keying on
|
|
102
|
+
// versionId would fragment the cache and prevent DataAppViewer's identical
|
|
103
103
|
// query from deduping.
|
|
104
|
-
const
|
|
105
|
-
queryKey: ["
|
|
104
|
+
const dataAppsQuery = useQueryWithApiError({
|
|
105
|
+
queryKey: ["data-apps", environmentName, packageName],
|
|
106
106
|
queryFn: async () => {
|
|
107
107
|
try {
|
|
108
|
-
return await apiClients.
|
|
108
|
+
return await apiClients.dataApps.listDataApps(
|
|
109
109
|
environmentName,
|
|
110
110
|
packageName,
|
|
111
111
|
);
|
|
112
112
|
} catch (e) {
|
|
113
113
|
// A 404 or transport-level failure (older Publisher without the
|
|
114
|
-
// /
|
|
115
|
-
// page without a
|
|
114
|
+
// /data-apps route, network blip) is non-fatal: render the package
|
|
115
|
+
// page without a Data Apps section. A genuinely missing package
|
|
116
116
|
// surfaces its own error via the package query above, so an empty
|
|
117
117
|
// list here can't hide it.
|
|
118
118
|
const status = (e as { response?: { status?: number } })?.response
|
|
119
119
|
?.status;
|
|
120
120
|
if (status === 404 || status === undefined) {
|
|
121
121
|
return { data: [] } as Awaited<
|
|
122
|
-
ReturnType<typeof apiClients.
|
|
122
|
+
ReturnType<typeof apiClients.dataApps.listDataApps>
|
|
123
123
|
>;
|
|
124
124
|
}
|
|
125
125
|
throw e;
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
});
|
|
129
|
-
const
|
|
129
|
+
const dataApps = dataAppsQuery.data?.data ?? [];
|
|
130
130
|
|
|
131
131
|
const notebooks = (notebooksQuery.data?.data ?? [])
|
|
132
132
|
.slice()
|
|
@@ -205,10 +205,7 @@ export default function Package({
|
|
|
205
205
|
|
|
206
206
|
{!isLoading && (
|
|
207
207
|
<>
|
|
208
|
-
<PackageSection
|
|
209
|
-
title="Governed Reports"
|
|
210
|
-
count={notebooks.length}
|
|
211
|
-
>
|
|
208
|
+
<PackageSection title="Notebooks" count={notebooks.length}>
|
|
212
209
|
{notebooks.map((notebook) => (
|
|
213
210
|
<PackageItemRow
|
|
214
211
|
key={notebook.path}
|
|
@@ -226,34 +223,35 @@ export default function Package({
|
|
|
226
223
|
{notebooks.length === 0 && <EmptyRow label="No notebooks" />}
|
|
227
224
|
</PackageSection>
|
|
228
225
|
|
|
229
|
-
{
|
|
230
|
-
<PackageSection title="
|
|
231
|
-
{
|
|
226
|
+
{dataApps.length > 0 && (
|
|
227
|
+
<PackageSection title="Data Apps" count={dataApps.length}>
|
|
228
|
+
{dataApps.map((dataApp) => {
|
|
232
229
|
const hasTitle =
|
|
233
|
-
!!
|
|
230
|
+
!!dataApp.title && dataApp.title !== dataApp.path;
|
|
234
231
|
// Standalone (raw) URL: the Publisher static-file route.
|
|
235
|
-
//
|
|
232
|
+
// dataApp.resource is the root-relative path; we join it
|
|
236
233
|
// with the data origin (the API base minus /api/v0),
|
|
237
234
|
// which may differ from the SPA origin when the SDK is
|
|
238
235
|
// embedded in a host app on another domain.
|
|
239
236
|
const standaloneUrl = `${serverBaseUrl(server)}${
|
|
240
|
-
|
|
237
|
+
dataApp.resource
|
|
241
238
|
}`;
|
|
242
239
|
return (
|
|
243
240
|
<PackageItemRow
|
|
244
|
-
key={
|
|
245
|
-
icon={<ContentTypeIcon type="
|
|
241
|
+
key={dataApp.path}
|
|
242
|
+
icon={<ContentTypeIcon type="dataApp" />}
|
|
246
243
|
tint={MALLOY_BRAND.teal}
|
|
247
|
-
label={hasTitle ?
|
|
248
|
-
rightLabel={hasTitle ?
|
|
244
|
+
label={hasTitle ? dataApp.title : dataApp.path}
|
|
245
|
+
rightLabel={hasTitle ? dataApp.path : undefined}
|
|
249
246
|
onClick={(event) => {
|
|
250
247
|
if (onClickPackageFile) {
|
|
251
248
|
// Host app routes within SPA to an embedded
|
|
252
|
-
// <
|
|
253
|
-
// The `
|
|
254
|
-
// off the existing model-path
|
|
249
|
+
// <DataAppViewer> that iframes the standalone
|
|
250
|
+
// URL. The `data-apps/` prefix lets the
|
|
251
|
+
// router branch off the existing model-path
|
|
252
|
+
// catch-all.
|
|
255
253
|
onClickPackageFile(
|
|
256
|
-
`/${environmentName}/${packageName}/
|
|
254
|
+
`/${environmentName}/${packageName}/data-apps/${dataApp.path}`,
|
|
257
255
|
event,
|
|
258
256
|
);
|
|
259
257
|
} else {
|
|
@@ -11,13 +11,13 @@ import React, {
|
|
|
11
11
|
} from "react";
|
|
12
12
|
import {
|
|
13
13
|
ConnectionsApi,
|
|
14
|
+
DataAppsApi,
|
|
14
15
|
DatabasesApi,
|
|
15
16
|
EnvironmentsApi,
|
|
16
17
|
MaterializationsApi,
|
|
17
18
|
ModelsApi,
|
|
18
19
|
NotebooksApi,
|
|
19
20
|
PackagesApi,
|
|
20
|
-
PagesApi,
|
|
21
21
|
PublisherApi,
|
|
22
22
|
WatchModeApi,
|
|
23
23
|
} from "../client";
|
|
@@ -138,7 +138,7 @@ const getApiClients = (
|
|
|
138
138
|
publisher: new PublisherApi(config, basePath, axiosInstance),
|
|
139
139
|
environments: new EnvironmentsApi(config, basePath, axiosInstance),
|
|
140
140
|
packages: new PackagesApi(config, basePath, axiosInstance),
|
|
141
|
-
|
|
141
|
+
dataApps: new DataAppsApi(config, basePath, axiosInstance),
|
|
142
142
|
notebooks: new NotebooksApi(config, basePath, axiosInstance),
|
|
143
143
|
connections: new ConnectionsApi(config, basePath, axiosInstance),
|
|
144
144
|
databases: new DatabasesApi(config, basePath, axiosInstance),
|