@malloy-publisher/sdk 0.0.382-dev → 0.2.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 +115 -95
- package/TREE_SHAKING.md +16 -11
- package/bunfig.toml +7 -0
- package/dist/ServerProvider-CTopDUWW.cjs.js +1 -0
- package/dist/ServerProvider-DUFPY6Rv.es.js +4072 -0
- package/dist/client/api.d.ts +3718 -1507
- 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 +85 -59
- package/dist/components/Connections/EditConnectionDialog.d.ts +2 -1
- package/dist/components/Connections/common.d.ts +8 -2
- package/dist/components/Dashboard/Dashboard.d.ts +49 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +48 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/DataAppViewer/DataAppViewer.d.ts +23 -0
- package/dist/components/DataAppViewer/index.d.ts +1 -0
- package/dist/components/Environment/Environment.d.ts +6 -0
- package/dist/components/Environment/index.d.ts +2 -0
- package/dist/components/Home/AddEnvironmentDialog.d.ts +1 -0
- package/dist/components/Home/DeleteEnvironmentDialog.d.ts +5 -0
- package/dist/components/Home/EditEnvironmentDialog.d.ts +7 -0
- package/dist/components/Home/Home.d.ts +2 -2
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +14 -0
- package/dist/components/Materializations/CreateMaterializationDialog.d.ts +10 -0
- package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +7 -0
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +7 -0
- package/dist/components/Materializations/ManifestView.d.ts +13 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +9 -0
- package/dist/components/Materializations/MaterializationRunsList.d.ts +15 -0
- package/dist/components/Materializations/Materializations.d.ts +7 -0
- package/dist/components/Materializations/ScheduleCard.d.ts +20 -0
- package/dist/components/Materializations/SectionLabel.d.ts +10 -0
- package/dist/components/Materializations/SetScheduleDialog.d.ts +11 -0
- package/dist/components/Materializations/TriggerChip.d.ts +10 -0
- package/dist/components/Materializations/cron.d.ts +23 -0
- package/dist/components/Materializations/index.d.ts +2 -0
- package/dist/components/Materializations/utils.d.ts +46 -0
- package/dist/components/Notebook/Notebook.d.ts +47 -4
- package/dist/components/Notebook/NotebookCell.d.ts +37 -1
- package/dist/components/Notebook/runPlan.d.ts +29 -0
- package/dist/components/Notebook/types.d.ts +10 -0
- package/dist/components/Package/ContentTypeIcon.d.ts +31 -0
- package/dist/components/Package/Package.d.ts +1 -4
- package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +5 -1
- package/dist/components/RenderedResult/renderLogs.d.ts +6 -0
- package/dist/components/ResultsDialog.d.ts +6 -1
- package/dist/components/ServerProvider.d.ts +28 -4
- package/dist/components/click_helper.d.ts +10 -1
- package/dist/components/drill/index.d.ts +3 -0
- package/dist/components/drill/markDrillableCells.d.ts +55 -0
- package/dist/components/drill/resolveDrill.d.ts +139 -0
- package/dist/components/drill/useDrill.d.ts +63 -0
- package/dist/components/given/GivenInput.d.ts +52 -0
- package/dist/components/given/GivensPanel.d.ts +47 -0
- package/dist/components/given/filterValue.d.ts +97 -0
- package/dist/components/given/index.d.ts +2 -0
- package/dist/components/given/paramCodec.d.ts +60 -0
- package/dist/components/given/utils.d.ts +17 -0
- package/dist/components/highlighter.d.ts +6 -1
- package/dist/components/index.d.ts +7 -2
- package/dist/components/styles.d.ts +47 -0
- package/dist/constants/docLinks.d.ts +12 -0
- package/dist/{core-YNpOLuB1.cjs.js → core-hLahnv0W.cjs.js} +1 -1
- package/dist/{core-CjeTkq8O.es.js → core-lb28vQkR.es.js} +1 -1
- package/dist/github-dark-BKL9xNgN.cjs.js +1 -0
- package/dist/github-dark-DenFmJkN.es.js +4 -0
- package/dist/hooks/givenValue.d.ts +10 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useDimensionFiltersFromSpec.d.ts +3 -3
- package/dist/hooks/useDimensionFiltersQuery.d.ts +3 -3
- package/dist/hooks/useDimensionalFilterRangeData.d.ts +4 -4
- package/dist/hooks/useGivensState.d.ts +64 -0
- package/dist/hooks/useModelGivens.d.ts +10 -0
- package/dist/hooks/useSuggestOptions.d.ts +78 -0
- package/dist/index-DvEanVgc.cjs.js +339 -0
- package/dist/{index-DRDu9kIV.es.js → index-txw04ZbN.es.js} +40531 -27964
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.es.js +79 -48
- package/dist/malloy-explorer.css +12 -1
- package/dist/sdk.css +1 -1
- package/dist/theme/ThemeContext.d.ts +45 -0
- package/dist/theme/buildMalloyExplicitTheme.d.ts +34 -0
- package/dist/theme/buildTableCssVars.d.ts +25 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +16 -0
- package/dist/theme/defaults.d.ts +7 -0
- package/dist/theme/index.d.ts +8 -0
- package/dist/theme/keys.d.ts +20 -0
- package/dist/theme/readChartAnnotations.d.ts +23 -0
- package/dist/theme/resolveTheme.d.ts +22 -0
- package/dist/theme/types.d.ts +70 -0
- package/dist/utils/dataAppEmbed.d.ts +44 -0
- package/dist/utils/formatting.d.ts +1 -1
- package/dist/utils/malloyString.d.ts +7 -0
- package/dist/utils/parsing.d.ts +2 -2
- package/dist/utils/queryClient.d.ts +5 -0
- package/package.json +19 -8
- package/src/client-entry.ts +3 -0
- package/src/components/AnalyzePackageButton.tsx +9 -3
- package/src/components/ApiErrorDisplay.tsx +3 -0
- package/src/components/Connections/AddConnectionDialog.tsx +30 -2
- package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
- package/src/components/Connections/EditConnectionDialog.tsx +33 -4
- package/src/components/Connections/common.ts +64 -1
- package/src/components/DOMElement/DOMElement.tsx +3 -0
- package/src/components/DOMElement/index.ts +3 -0
- package/src/components/Dashboard/Dashboard.tsx +398 -0
- package/src/components/Dashboard/DashboardTile.tsx +153 -0
- package/src/components/Dashboard/index.ts +5 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
- package/src/components/DataAppViewer/index.ts +4 -0
- package/src/components/{Project → Environment}/About.tsx +11 -4
- package/src/components/Environment/AddPackageDialog.tsx +202 -0
- package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
- package/src/components/Environment/Connections.tsx +391 -0
- package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
- package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
- package/src/components/Environment/Environment.tsx +89 -0
- package/src/components/Environment/Packages.tsx +206 -0
- package/src/components/Environment/index.ts +5 -0
- package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
- package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
- package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
- package/src/components/Home/Home.tsx +386 -408
- package/src/components/Home/index.ts +3 -0
- package/src/components/Loading.tsx +3 -0
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
- package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
- package/src/components/Materializations/ManifestView.tsx +87 -0
- package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
- package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
- package/src/components/Materializations/Materializations.tsx +355 -0
- package/src/components/Materializations/ScheduleCard.tsx +231 -0
- package/src/components/Materializations/SectionLabel.tsx +30 -0
- package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
- package/src/components/Materializations/TriggerChip.tsx +44 -0
- package/src/components/Materializations/cron.ts +124 -0
- package/src/components/Materializations/index.ts +5 -0
- package/src/components/Materializations/utils.ts +145 -0
- package/src/components/Model/Model.tsx +44 -2
- package/src/components/Model/ModelCell.tsx +14 -5
- package/src/components/Model/ModelExplorer.tsx +3 -0
- package/src/components/Model/ModelExplorerDialog.tsx +4 -1
- package/src/components/Model/SourcesExplorer.tsx +9 -6
- package/src/components/Model/index.ts +3 -0
- package/src/components/Model/useModelData.ts +6 -3
- package/src/components/Notebook/Notebook.tsx +475 -339
- package/src/components/Notebook/NotebookCell.tsx +264 -25
- package/src/components/Notebook/index.ts +3 -0
- package/src/components/Notebook/runPlan.spec.ts +155 -0
- package/src/components/Notebook/runPlan.ts +67 -0
- package/src/components/Notebook/types.ts +14 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
- package/src/components/Package/ContentTypeIcon.tsx +177 -0
- package/src/components/Package/FileTreeView.tsx +3 -0
- package/src/components/Package/Models.tsx +7 -4
- package/src/components/Package/Package.tsx +666 -59
- package/src/components/Package/index.ts +3 -0
- package/src/components/QueryResult/QueryResult.tsx +17 -8
- package/src/components/QueryResult/index.ts +3 -0
- package/src/components/RenderedResult/RenderedResult.tsx +685 -67
- package/src/components/RenderedResult/ResultContainer.tsx +71 -2
- package/src/components/RenderedResult/index.ts +3 -0
- package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
- package/src/components/RenderedResult/renderLogs.ts +43 -0
- package/src/components/ResultsDialog.tsx +13 -1
- package/src/components/ServerProvider.tsx +175 -51
- package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
- package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
- package/src/components/Workbook/ModelPicker.tsx +7 -4
- package/src/components/Workbook/MutableCell.tsx +10 -5
- package/src/components/Workbook/Workbook.tsx +8 -5
- package/src/components/Workbook/WorkbookList.tsx +3 -0
- package/src/components/Workbook/WorkbookManager.ts +3 -0
- package/src/components/Workbook/WorkbookStorage.ts +3 -0
- package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
- package/src/components/Workbook/index.ts +3 -0
- package/src/components/click_helper.ts +17 -1
- package/src/components/drill/index.ts +28 -0
- package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
- package/src/components/drill/markDrillableCells.spec.ts +109 -0
- package/src/components/drill/markDrillableCells.ts +314 -0
- package/src/components/drill/resolveDrill.spec.ts +449 -0
- package/src/components/drill/resolveDrill.ts +375 -0
- package/src/components/drill/useDrill.tsx +203 -0
- package/src/components/filter/DimensionFilter.tsx +3 -0
- package/src/components/filter/index.ts +3 -0
- package/src/components/filter/utils.ts +16 -5
- package/src/components/given/GivenInput.spec.tsx +689 -0
- package/src/components/given/GivenInput.tsx +801 -0
- package/src/components/given/GivensPanel.spec.tsx +175 -0
- package/src/components/given/GivensPanel.tsx +195 -0
- package/src/components/given/filterValue.spec.ts +364 -0
- package/src/components/given/filterValue.ts +207 -0
- package/src/components/given/index.ts +9 -0
- package/src/components/given/paramCodec.spec.ts +857 -0
- package/src/components/given/paramCodec.ts +483 -0
- package/src/components/given/utils.spec.ts +60 -0
- package/src/components/given/utils.ts +79 -0
- package/src/components/highlighter.ts +22 -5
- package/src/components/index.ts +10 -2
- package/src/components/styles.ts +82 -33
- package/src/constants/docLinks.spec.ts +54 -0
- package/src/constants/docLinks.ts +46 -0
- package/src/hooks/givenValue.ts +13 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useDimensionFilters.ts +4 -7
- package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
- package/src/hooks/useDimensionFiltersQuery.ts +10 -13
- package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
- package/src/hooks/useGivensState.spec.ts +449 -0
- package/src/hooks/useGivensState.ts +340 -0
- package/src/hooks/useModelGivens.ts +29 -0
- package/src/hooks/useQueryWithApiError.ts +3 -0
- package/src/hooks/useRawQueryData.ts +6 -3
- package/src/hooks/useSuggestOptions.spec.ts +112 -0
- package/src/hooks/useSuggestOptions.ts +263 -0
- package/src/index.ts +10 -1
- package/src/react-app-env.d.ts +3 -0
- package/src/theme/ThemeContext.tsx +86 -0
- package/src/theme/buildMalloyExplicitTheme.ts +61 -0
- package/src/theme/buildTableCssVars.spec.ts +67 -0
- package/src/theme/buildTableCssVars.ts +67 -0
- package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
- package/src/theme/buildVegaThemeOverride.ts +47 -0
- package/src/theme/defaults.ts +78 -0
- package/src/theme/index.ts +11 -0
- package/src/theme/keys.ts +32 -0
- package/src/theme/readChartAnnotations.spec.ts +58 -0
- package/src/theme/readChartAnnotations.ts +69 -0
- package/src/theme/resolveTheme.spec.ts +160 -0
- package/src/theme/resolveTheme.ts +121 -0
- package/src/theme/types.ts +79 -0
- package/src/utils/dataAppEmbed.spec.ts +63 -0
- package/src/utils/dataAppEmbed.ts +84 -0
- package/src/utils/formatting.spec.ts +25 -21
- package/src/utils/formatting.ts +11 -7
- package/src/utils/malloyString.spec.ts +24 -0
- package/src/utils/malloyString.ts +12 -0
- package/src/utils/parsing.spec.ts +26 -19
- package/src/utils/parsing.ts +11 -6
- package/src/utils/queryClient.ts +17 -0
- package/test/README.md +141 -0
- package/test/setup.ts +29 -0
- package/tsconfig.json +12 -1
- package/tsconfig.spec.json +22 -0
- package/vite.config.ts +3 -0
- package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
- package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
- package/dist/components/Home/AddProjectDialog.d.ts +0 -1
- package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
- package/dist/components/Home/EditProjectDialog.d.ts +0 -7
- package/dist/components/Package/Config.d.ts +0 -5
- package/dist/components/Package/Databases.d.ts +0 -5
- package/dist/components/Package/Notebooks.d.ts +0 -6
- package/dist/components/Project/Project.d.ts +0 -6
- package/dist/components/Project/index.d.ts +0 -2
- package/dist/index-BOLBP6_i.cjs.js +0 -233
- package/src/components/Package/Config.tsx +0 -97
- package/src/components/Package/Connections.tsx +0 -373
- package/src/components/Package/Databases.tsx +0 -228
- package/src/components/Package/Notebooks.tsx +0 -77
- package/src/components/Project/AddPackageDialog.tsx +0 -159
- package/src/components/Project/Packages.tsx +0 -191
- package/src/components/Project/Project.tsx +0 -52
- package/src/components/Project/index.ts +0 -2
- /package/dist/components/{Project → Environment}/About.d.ts +0 -0
- /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
- /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
- /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
|
5
|
+
import {
|
|
6
|
+
Box,
|
|
7
|
+
Container,
|
|
8
|
+
Link,
|
|
9
|
+
Snackbar,
|
|
10
|
+
Stack,
|
|
11
|
+
Typography,
|
|
12
|
+
} from "@mui/material";
|
|
13
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
14
|
+
import React, { useState } from "react";
|
|
15
|
+
import {
|
|
16
|
+
Materialization,
|
|
17
|
+
MaterializationActionActionEnum,
|
|
18
|
+
PackageScopeEnum,
|
|
19
|
+
} from "../../client";
|
|
20
|
+
import {
|
|
21
|
+
useMutationWithApiError,
|
|
22
|
+
useQueryWithApiError,
|
|
23
|
+
} from "../../hooks/useQueryWithApiError";
|
|
24
|
+
import { parseResourceUri } from "../../utils/formatting";
|
|
25
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
26
|
+
import { Loading } from "../Loading";
|
|
27
|
+
import { useServer } from "../ServerProvider";
|
|
28
|
+
import CreateMaterializationDialog from "./CreateMaterializationDialog";
|
|
29
|
+
import MaterializationDetailDialog from "./MaterializationDetailDialog";
|
|
30
|
+
import MaterializationRunsList from "./MaterializationRunsList";
|
|
31
|
+
import ScheduleCard from "./ScheduleCard";
|
|
32
|
+
import { isActiveStatus } from "./utils";
|
|
33
|
+
|
|
34
|
+
const MATERIALIZATION_POLL_MS = 3000;
|
|
35
|
+
|
|
36
|
+
interface MaterializationsProps {
|
|
37
|
+
resourceUri: string;
|
|
38
|
+
onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default function Materializations({
|
|
42
|
+
resourceUri,
|
|
43
|
+
onClickPackageFile,
|
|
44
|
+
}: MaterializationsProps) {
|
|
45
|
+
const { apiClients, mutable } = useServer();
|
|
46
|
+
const queryClient = useQueryClient();
|
|
47
|
+
const { environmentName, packageName } = parseResourceUri(resourceUri);
|
|
48
|
+
const [notificationMessage, setNotificationMessage] = useState("");
|
|
49
|
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
50
|
+
|
|
51
|
+
const onClick =
|
|
52
|
+
onClickPackageFile ??
|
|
53
|
+
((to: string) => {
|
|
54
|
+
window.location.href = to;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (!packageName) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
"Materializations requires a package in the resource URI",
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const listQuery = useQueryWithApiError({
|
|
64
|
+
queryKey: ["materializations", environmentName, packageName],
|
|
65
|
+
queryFn: () =>
|
|
66
|
+
apiClients.materializations.listMaterializations(
|
|
67
|
+
environmentName,
|
|
68
|
+
packageName,
|
|
69
|
+
),
|
|
70
|
+
refetchInterval: (query) => {
|
|
71
|
+
const payload = query.state.data as
|
|
72
|
+
| { data?: Materialization[] }
|
|
73
|
+
| undefined;
|
|
74
|
+
const rows = payload?.data ?? [];
|
|
75
|
+
return rows.some((row) => isActiveStatus(row.status))
|
|
76
|
+
? MATERIALIZATION_POLL_MS
|
|
77
|
+
: false;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// The build plan is a property of the compiled package (Package.buildPlan),
|
|
82
|
+
// not of a historical run, so fetch it from the package for the detail view.
|
|
83
|
+
const packageQuery = useQueryWithApiError({
|
|
84
|
+
queryKey: ["package", environmentName, packageName],
|
|
85
|
+
queryFn: () =>
|
|
86
|
+
apiClients.packages.getPackage(environmentName, packageName),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const invalidateList = () =>
|
|
90
|
+
queryClient.invalidateQueries({
|
|
91
|
+
queryKey: ["materializations", environmentName, packageName],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Auto-run: the publisher compiles, builds every persist source, and loads
|
|
95
|
+
// the resulting manifest in a single pass.
|
|
96
|
+
const createMaterialization = useMutationWithApiError({
|
|
97
|
+
mutationFn: (opts: { forceRefresh: boolean }) =>
|
|
98
|
+
apiClients.materializations.createMaterialization(
|
|
99
|
+
environmentName,
|
|
100
|
+
packageName,
|
|
101
|
+
{
|
|
102
|
+
forceRefresh: opts.forceRefresh,
|
|
103
|
+
},
|
|
104
|
+
),
|
|
105
|
+
onSuccess() {
|
|
106
|
+
setNotificationMessage("Materialization requested");
|
|
107
|
+
invalidateList();
|
|
108
|
+
},
|
|
109
|
+
onError(error) {
|
|
110
|
+
setNotificationMessage(error.message);
|
|
111
|
+
invalidateList();
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const stopMaterialization = useMutationWithApiError({
|
|
116
|
+
mutationFn: (materialization: Materialization) =>
|
|
117
|
+
apiClients.materializations.materializationAction(
|
|
118
|
+
environmentName,
|
|
119
|
+
packageName,
|
|
120
|
+
materialization.id as string,
|
|
121
|
+
MaterializationActionActionEnum.Stop,
|
|
122
|
+
),
|
|
123
|
+
onSuccess() {
|
|
124
|
+
setNotificationMessage("Materialization stopped");
|
|
125
|
+
invalidateList();
|
|
126
|
+
},
|
|
127
|
+
onError(error) {
|
|
128
|
+
setNotificationMessage(error.message);
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const deleteMaterialization = useMutationWithApiError({
|
|
133
|
+
mutationFn: ({
|
|
134
|
+
materialization,
|
|
135
|
+
dropTables,
|
|
136
|
+
}: {
|
|
137
|
+
materialization: Materialization;
|
|
138
|
+
dropTables: boolean;
|
|
139
|
+
}) =>
|
|
140
|
+
apiClients.materializations.deleteMaterialization(
|
|
141
|
+
environmentName,
|
|
142
|
+
packageName,
|
|
143
|
+
materialization.id as string,
|
|
144
|
+
dropTables,
|
|
145
|
+
),
|
|
146
|
+
onSuccess() {
|
|
147
|
+
setNotificationMessage("Materialization deleted");
|
|
148
|
+
invalidateList();
|
|
149
|
+
},
|
|
150
|
+
onError(error) {
|
|
151
|
+
setNotificationMessage(error.message);
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const currentPackage = packageQuery.data?.data;
|
|
156
|
+
|
|
157
|
+
// Edit the package's materialization.schedule (persisted to publisher.json).
|
|
158
|
+
// A schedule is legal only on a version-scoped package, so enabling one also
|
|
159
|
+
// sets scope: version; clearing (null) leaves scope untouched — scope is an
|
|
160
|
+
// explicit control (updateScope below), so clearing a schedule no longer
|
|
161
|
+
// strands scope: version with no way back. The running scheduler re-arms from
|
|
162
|
+
// the new cron on its next tick — no reload needed.
|
|
163
|
+
const updateSchedule = useMutationWithApiError({
|
|
164
|
+
mutationFn: (schedule: string | null) =>
|
|
165
|
+
apiClients.packages.updatePackage(environmentName, packageName, {
|
|
166
|
+
name: packageName,
|
|
167
|
+
// updatePackage overwrites description from the body — carry the
|
|
168
|
+
// current value through so a schedule edit doesn't drop it.
|
|
169
|
+
description: currentPackage?.description,
|
|
170
|
+
...(schedule ? { scope: PackageScopeEnum.Version } : {}),
|
|
171
|
+
materialization: { schedule },
|
|
172
|
+
}),
|
|
173
|
+
onSuccess(_data, schedule) {
|
|
174
|
+
setNotificationMessage(
|
|
175
|
+
schedule ? "Schedule updated" : "Schedule cleared",
|
|
176
|
+
);
|
|
177
|
+
queryClient.invalidateQueries({
|
|
178
|
+
queryKey: ["package", environmentName, packageName],
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
onError(error) {
|
|
182
|
+
setNotificationMessage(error.message);
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Set the persist scope explicitly (package | version). Independent of the
|
|
187
|
+
// schedule so the version flip a schedule requires can be undone after the
|
|
188
|
+
// schedule is cleared. The server rejects scope: package while a schedule is
|
|
189
|
+
// still set (publish-gate Rule 2), so the UI only offers this when no
|
|
190
|
+
// schedule is active.
|
|
191
|
+
const updateScope = useMutationWithApiError({
|
|
192
|
+
mutationFn: (scope: PackageScopeEnum) =>
|
|
193
|
+
apiClients.packages.updatePackage(environmentName, packageName, {
|
|
194
|
+
name: packageName,
|
|
195
|
+
description: currentPackage?.description,
|
|
196
|
+
scope,
|
|
197
|
+
}),
|
|
198
|
+
onSuccess() {
|
|
199
|
+
setNotificationMessage("Scope updated");
|
|
200
|
+
queryClient.invalidateQueries({
|
|
201
|
+
queryKey: ["package", environmentName, packageName],
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
onError(error) {
|
|
205
|
+
setNotificationMessage(error.message);
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const materializations = (listQuery.data?.data ?? []) as Materialization[];
|
|
210
|
+
const selected =
|
|
211
|
+
materializations.find((row) => row.id === selectedId) ?? null;
|
|
212
|
+
const hasActive = materializations.some((row) => isActiveStatus(row.status));
|
|
213
|
+
const isMutating =
|
|
214
|
+
createMaterialization.isPending ||
|
|
215
|
+
stopMaterialization.isPending ||
|
|
216
|
+
deleteMaterialization.isPending;
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<Container
|
|
220
|
+
maxWidth={false}
|
|
221
|
+
sx={{ maxWidth: 1024, mx: "auto", px: 3, py: 6 }}
|
|
222
|
+
>
|
|
223
|
+
<Box sx={{ mb: 4 }}>
|
|
224
|
+
<Link
|
|
225
|
+
onClick={(event: React.MouseEvent) =>
|
|
226
|
+
onClick(`/${environmentName}/${packageName}`, event)
|
|
227
|
+
}
|
|
228
|
+
underline="none"
|
|
229
|
+
sx={{
|
|
230
|
+
display: "inline-flex",
|
|
231
|
+
alignItems: "center",
|
|
232
|
+
gap: 0.5,
|
|
233
|
+
cursor: "pointer",
|
|
234
|
+
color: "text.secondary",
|
|
235
|
+
fontSize: "0.875rem",
|
|
236
|
+
mb: 2,
|
|
237
|
+
"&:hover": { color: "primary.main" },
|
|
238
|
+
}}
|
|
239
|
+
>
|
|
240
|
+
<ArrowBackIcon sx={{ fontSize: 18 }} />
|
|
241
|
+
Back to {packageName}
|
|
242
|
+
</Link>
|
|
243
|
+
<Stack
|
|
244
|
+
direction="row"
|
|
245
|
+
alignItems="flex-start"
|
|
246
|
+
justifyContent="space-between"
|
|
247
|
+
>
|
|
248
|
+
<Box>
|
|
249
|
+
<Typography
|
|
250
|
+
variant="h4"
|
|
251
|
+
component="h1"
|
|
252
|
+
sx={{
|
|
253
|
+
fontWeight: 600,
|
|
254
|
+
letterSpacing: "-0.025em",
|
|
255
|
+
mb: 0.5,
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
258
|
+
Materializations
|
|
259
|
+
</Typography>
|
|
260
|
+
<Typography variant="body2" color="text.secondary">
|
|
261
|
+
Materialize the persist sources in {packageName} into
|
|
262
|
+
tables and serve queries from them
|
|
263
|
+
</Typography>
|
|
264
|
+
</Box>
|
|
265
|
+
{mutable && (
|
|
266
|
+
<CreateMaterializationDialog
|
|
267
|
+
onSubmit={(opts) =>
|
|
268
|
+
createMaterialization.mutateAsync(opts)
|
|
269
|
+
}
|
|
270
|
+
isSubmitting={createMaterialization.isPending}
|
|
271
|
+
disabled={hasActive}
|
|
272
|
+
disabledReason="A materialization is already pending or running for this package."
|
|
273
|
+
/>
|
|
274
|
+
)}
|
|
275
|
+
</Stack>
|
|
276
|
+
</Box>
|
|
277
|
+
|
|
278
|
+
{packageQuery.isSuccess && (
|
|
279
|
+
<ScheduleCard
|
|
280
|
+
schedule={currentPackage?.materialization?.schedule ?? null}
|
|
281
|
+
scope={
|
|
282
|
+
currentPackage?.scope === PackageScopeEnum.Version
|
|
283
|
+
? "version"
|
|
284
|
+
: "package"
|
|
285
|
+
}
|
|
286
|
+
manifestLocation={currentPackage?.manifestLocation ?? null}
|
|
287
|
+
hasFreshness={Boolean(
|
|
288
|
+
currentPackage?.materialization?.freshness,
|
|
289
|
+
)}
|
|
290
|
+
mutable={mutable}
|
|
291
|
+
isSubmitting={updateSchedule.isPending}
|
|
292
|
+
isScopeMutating={updateScope.isPending}
|
|
293
|
+
onSubmit={(schedule) => updateSchedule.mutateAsync(schedule)}
|
|
294
|
+
onScopeChange={(scope) =>
|
|
295
|
+
updateScope.mutateAsync(
|
|
296
|
+
scope === "version"
|
|
297
|
+
? PackageScopeEnum.Version
|
|
298
|
+
: PackageScopeEnum.Package,
|
|
299
|
+
)
|
|
300
|
+
}
|
|
301
|
+
/>
|
|
302
|
+
)}
|
|
303
|
+
|
|
304
|
+
<Box sx={{ mb: 6 }}>
|
|
305
|
+
<Typography
|
|
306
|
+
variant="h6"
|
|
307
|
+
sx={{ fontWeight: 600, letterSpacing: "-0.025em", mb: 1 }}
|
|
308
|
+
>
|
|
309
|
+
Runs
|
|
310
|
+
</Typography>
|
|
311
|
+
{listQuery.isError && (
|
|
312
|
+
<ApiErrorDisplay
|
|
313
|
+
error={listQuery.error}
|
|
314
|
+
context={`${environmentName} > ${packageName} > Materializations`}
|
|
315
|
+
/>
|
|
316
|
+
)}
|
|
317
|
+
{!listQuery.isSuccess && !listQuery.isError && (
|
|
318
|
+
<Loading text="Loading materializations..." />
|
|
319
|
+
)}
|
|
320
|
+
{listQuery.isSuccess && (
|
|
321
|
+
<MaterializationRunsList
|
|
322
|
+
materializations={materializations}
|
|
323
|
+
mutable={mutable}
|
|
324
|
+
isMutating={isMutating}
|
|
325
|
+
onStop={(materialization) =>
|
|
326
|
+
stopMaterialization.mutate(materialization)
|
|
327
|
+
}
|
|
328
|
+
onDelete={(materialization, dropTables) =>
|
|
329
|
+
deleteMaterialization.mutate({
|
|
330
|
+
materialization,
|
|
331
|
+
dropTables,
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
onViewDetails={(materialization) =>
|
|
335
|
+
setSelectedId(materialization.id ?? null)
|
|
336
|
+
}
|
|
337
|
+
/>
|
|
338
|
+
)}
|
|
339
|
+
</Box>
|
|
340
|
+
|
|
341
|
+
<MaterializationDetailDialog
|
|
342
|
+
materialization={selected}
|
|
343
|
+
buildPlan={packageQuery.data?.data?.buildPlan ?? null}
|
|
344
|
+
onClose={() => setSelectedId(null)}
|
|
345
|
+
/>
|
|
346
|
+
|
|
347
|
+
<Snackbar
|
|
348
|
+
open={notificationMessage !== ""}
|
|
349
|
+
autoHideDuration={6000}
|
|
350
|
+
onClose={() => setNotificationMessage("")}
|
|
351
|
+
message={notificationMessage}
|
|
352
|
+
/>
|
|
353
|
+
</Container>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import ScheduleIcon from "@mui/icons-material/Schedule";
|
|
5
|
+
import {
|
|
6
|
+
Box,
|
|
7
|
+
Card,
|
|
8
|
+
CardContent,
|
|
9
|
+
Chip,
|
|
10
|
+
Stack,
|
|
11
|
+
ToggleButton,
|
|
12
|
+
ToggleButtonGroup,
|
|
13
|
+
Tooltip,
|
|
14
|
+
Typography,
|
|
15
|
+
} from "@mui/material";
|
|
16
|
+
import { MONO_FONT_FAMILY } from "../styles";
|
|
17
|
+
import { describeCron, formatNextRun } from "./cron";
|
|
18
|
+
import SetScheduleDialog from "./SetScheduleDialog";
|
|
19
|
+
|
|
20
|
+
type Scope = "package" | "version";
|
|
21
|
+
|
|
22
|
+
type ScheduleCardProps = {
|
|
23
|
+
/** The package's cron, or null when no schedule is declared. */
|
|
24
|
+
schedule: string | null;
|
|
25
|
+
/** The package's persist scope. */
|
|
26
|
+
scope: Scope;
|
|
27
|
+
/** When set, the package is control-plane-driven (orchestrated). */
|
|
28
|
+
manifestLocation: string | null;
|
|
29
|
+
/** True when the package declares a freshness policy (schedule N/A). */
|
|
30
|
+
hasFreshness: boolean;
|
|
31
|
+
mutable: boolean;
|
|
32
|
+
isSubmitting: boolean;
|
|
33
|
+
/** True while a scope change is in flight. */
|
|
34
|
+
isScopeMutating?: boolean;
|
|
35
|
+
onSubmit: (schedule: string | null) => Promise<unknown>;
|
|
36
|
+
/** Persist a new scope (package | version). */
|
|
37
|
+
onScopeChange?: (scope: Scope) => Promise<unknown>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default function ScheduleCard({
|
|
41
|
+
schedule,
|
|
42
|
+
scope,
|
|
43
|
+
manifestLocation,
|
|
44
|
+
hasFreshness,
|
|
45
|
+
mutable,
|
|
46
|
+
isSubmitting,
|
|
47
|
+
isScopeMutating,
|
|
48
|
+
onSubmit,
|
|
49
|
+
onScopeChange,
|
|
50
|
+
}: ScheduleCardProps) {
|
|
51
|
+
const orchestrated = Boolean(manifestLocation);
|
|
52
|
+
const info = schedule ? describeCron(schedule) : null;
|
|
53
|
+
// A schedule requires version scope, so scope is locked while one is set —
|
|
54
|
+
// the server would reject scope: package (publish-gate Rule 2). Clearing the
|
|
55
|
+
// schedule unlocks it, giving an explicit way back to package scope.
|
|
56
|
+
const scopeLocked = Boolean(schedule);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Card variant="outlined" sx={{ borderRadius: 2, mb: 6 }}>
|
|
60
|
+
<CardContent>
|
|
61
|
+
<Stack
|
|
62
|
+
direction="row"
|
|
63
|
+
justifyContent="space-between"
|
|
64
|
+
alignItems="flex-start"
|
|
65
|
+
spacing={2}
|
|
66
|
+
>
|
|
67
|
+
<Box sx={{ minWidth: 0 }}>
|
|
68
|
+
<Stack
|
|
69
|
+
direction="row"
|
|
70
|
+
alignItems="center"
|
|
71
|
+
spacing={1}
|
|
72
|
+
sx={{ mb: 1 }}
|
|
73
|
+
>
|
|
74
|
+
<ScheduleIcon fontSize="small" color="action" />
|
|
75
|
+
<Typography
|
|
76
|
+
variant="h6"
|
|
77
|
+
sx={{ fontWeight: 600, letterSpacing: "-0.025em" }}
|
|
78
|
+
>
|
|
79
|
+
Schedule
|
|
80
|
+
</Typography>
|
|
81
|
+
</Stack>
|
|
82
|
+
|
|
83
|
+
{orchestrated ? (
|
|
84
|
+
<Box>
|
|
85
|
+
<Chip
|
|
86
|
+
size="small"
|
|
87
|
+
color="default"
|
|
88
|
+
variant="outlined"
|
|
89
|
+
label="Control-plane managed"
|
|
90
|
+
sx={{ mb: 1 }}
|
|
91
|
+
/>
|
|
92
|
+
<Typography variant="body2" color="text.secondary">
|
|
93
|
+
Refresh is driven by the control plane; the built-in
|
|
94
|
+
scheduler does not fire this package.
|
|
95
|
+
</Typography>
|
|
96
|
+
</Box>
|
|
97
|
+
) : info ? (
|
|
98
|
+
<Box>
|
|
99
|
+
<Stack
|
|
100
|
+
direction="row"
|
|
101
|
+
alignItems="center"
|
|
102
|
+
spacing={1}
|
|
103
|
+
sx={{ mb: 0.5, flexWrap: "wrap" }}
|
|
104
|
+
>
|
|
105
|
+
<Chip
|
|
106
|
+
size="small"
|
|
107
|
+
color="success"
|
|
108
|
+
variant="outlined"
|
|
109
|
+
icon={<ScheduleIcon fontSize="small" />}
|
|
110
|
+
label="Active"
|
|
111
|
+
/>
|
|
112
|
+
<Box
|
|
113
|
+
component="code"
|
|
114
|
+
sx={{
|
|
115
|
+
fontFamily: MONO_FONT_FAMILY,
|
|
116
|
+
fontSize: "0.8125rem",
|
|
117
|
+
px: 0.75,
|
|
118
|
+
py: 0.25,
|
|
119
|
+
borderRadius: 1,
|
|
120
|
+
bgcolor: "action.hover",
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{schedule}
|
|
124
|
+
</Box>
|
|
125
|
+
</Stack>
|
|
126
|
+
<Typography variant="body2">
|
|
127
|
+
{info.valid
|
|
128
|
+
? info.description
|
|
129
|
+
: "Unrecognized cron expression."}
|
|
130
|
+
</Typography>
|
|
131
|
+
{info.valid && (
|
|
132
|
+
<Typography variant="body2" color="text.secondary">
|
|
133
|
+
Next run: {formatNextRun(info.nextRun)}
|
|
134
|
+
</Typography>
|
|
135
|
+
)}
|
|
136
|
+
</Box>
|
|
137
|
+
) : hasFreshness ? (
|
|
138
|
+
<Typography variant="body2" color="text.secondary">
|
|
139
|
+
This package uses a freshness policy; a cron schedule is
|
|
140
|
+
not applicable.
|
|
141
|
+
</Typography>
|
|
142
|
+
) : (
|
|
143
|
+
<Typography variant="body2" color="text.secondary">
|
|
144
|
+
On-demand only — no schedule set.
|
|
145
|
+
</Typography>
|
|
146
|
+
)}
|
|
147
|
+
|
|
148
|
+
{!orchestrated && (
|
|
149
|
+
<Box sx={{ mt: 2 }}>
|
|
150
|
+
<Typography
|
|
151
|
+
variant="caption"
|
|
152
|
+
color="text.secondary"
|
|
153
|
+
sx={{ display: "block", mb: 0.5 }}
|
|
154
|
+
>
|
|
155
|
+
Scope
|
|
156
|
+
</Typography>
|
|
157
|
+
<Tooltip
|
|
158
|
+
title={
|
|
159
|
+
scopeLocked
|
|
160
|
+
? "A schedule requires version scope. Clear the schedule to change it."
|
|
161
|
+
: ""
|
|
162
|
+
}
|
|
163
|
+
>
|
|
164
|
+
<span>
|
|
165
|
+
<ToggleButtonGroup
|
|
166
|
+
size="small"
|
|
167
|
+
exclusive
|
|
168
|
+
value={scope}
|
|
169
|
+
disabled={
|
|
170
|
+
!mutable ||
|
|
171
|
+
!onScopeChange ||
|
|
172
|
+
scopeLocked ||
|
|
173
|
+
Boolean(isScopeMutating)
|
|
174
|
+
}
|
|
175
|
+
onChange={(_e, next: Scope | null) => {
|
|
176
|
+
if (next && next !== scope) {
|
|
177
|
+
onScopeChange?.(next);
|
|
178
|
+
}
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
<ToggleButton value="package">
|
|
182
|
+
package
|
|
183
|
+
</ToggleButton>
|
|
184
|
+
<ToggleButton value="version">
|
|
185
|
+
version
|
|
186
|
+
</ToggleButton>
|
|
187
|
+
</ToggleButtonGroup>
|
|
188
|
+
</span>
|
|
189
|
+
</Tooltip>
|
|
190
|
+
<Typography
|
|
191
|
+
variant="caption"
|
|
192
|
+
color="text.secondary"
|
|
193
|
+
sx={{ display: "block", mt: 0.5 }}
|
|
194
|
+
>
|
|
195
|
+
{scope === "version"
|
|
196
|
+
? "Materialized artifacts are per version (required for a schedule)."
|
|
197
|
+
: "Materialized artifacts are shared across versions."}
|
|
198
|
+
</Typography>
|
|
199
|
+
</Box>
|
|
200
|
+
)}
|
|
201
|
+
|
|
202
|
+
<Typography
|
|
203
|
+
variant="caption"
|
|
204
|
+
color="text.secondary"
|
|
205
|
+
sx={{ display: "block", mt: 1.5 }}
|
|
206
|
+
>
|
|
207
|
+
Declared in <code>publisher.json</code>.
|
|
208
|
+
{!orchestrated && (
|
|
209
|
+
<>
|
|
210
|
+
{" "}
|
|
211
|
+
In a hosted deployment, a change takes effect on your
|
|
212
|
+
next publish.
|
|
213
|
+
</>
|
|
214
|
+
)}
|
|
215
|
+
</Typography>
|
|
216
|
+
</Box>
|
|
217
|
+
|
|
218
|
+
{mutable && !orchestrated && (
|
|
219
|
+
<SetScheduleDialog
|
|
220
|
+
currentSchedule={schedule}
|
|
221
|
+
isSubmitting={isSubmitting}
|
|
222
|
+
disabled={hasFreshness}
|
|
223
|
+
disabledReason="This package declares a freshness policy; a schedule and freshness are mutually exclusive."
|
|
224
|
+
onSubmit={onSubmit}
|
|
225
|
+
/>
|
|
226
|
+
)}
|
|
227
|
+
</Stack>
|
|
228
|
+
</CardContent>
|
|
229
|
+
</Card>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { Typography } from "@mui/material";
|
|
5
|
+
import { ReactNode } from "react";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Small uppercase section heading for consistent hierarchy across the
|
|
9
|
+
* materialization views (detail dialog, manifest view). One source of truth for
|
|
10
|
+
* the style so the headings can't drift. Renders as an <h6> so it is a real
|
|
11
|
+
* heading (role="heading") — the caption styling is purely visual.
|
|
12
|
+
*/
|
|
13
|
+
export default function SectionLabel({ children }: { children: ReactNode }) {
|
|
14
|
+
return (
|
|
15
|
+
<Typography
|
|
16
|
+
variant="caption"
|
|
17
|
+
component="h6"
|
|
18
|
+
sx={{
|
|
19
|
+
display: "block",
|
|
20
|
+
textTransform: "uppercase",
|
|
21
|
+
letterSpacing: "0.06em",
|
|
22
|
+
fontWeight: 600,
|
|
23
|
+
color: "text.secondary",
|
|
24
|
+
mb: 1,
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</Typography>
|
|
29
|
+
);
|
|
30
|
+
}
|