@malloy-publisher/sdk 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -9
- package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorageProvider-CyOJ0hqf.es.js} +7114 -6939
- package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
- package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-BnPzJ9Jf.es.js} +64 -57
- package/dist/{RenderedResult-CPi6uQWq.cjs.js → RenderedResult-Dp22kZsQ.cjs.js} +2 -2
- package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +41 -41
- package/dist/builder/index.es.js +2752 -2831
- package/dist/client/api.d.ts +100 -42
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +30 -0
- package/dist/components/BackLink.d.ts +32 -0
- package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
- package/dist/components/Dashboard/telemetry.d.ts +10 -5
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +8 -2
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +8 -10
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
- package/dist/components/ItemRow.d.ts +38 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
- package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
- package/dist/components/Materializations/Materializations.d.ts +7 -3
- package/dist/components/Materializations/ScopeButton.d.ts +18 -0
- package/dist/components/Materializations/SectionLabel.d.ts +7 -4
- package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
- package/dist/components/Materializations/index.d.ts +0 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
- package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
- package/dist/components/Package/index.d.ts +0 -1
- package/dist/components/PackageSection.d.ts +23 -0
- package/dist/components/buttons.d.ts +53 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/styles.d.ts +49 -40
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/index.cjs.js +22 -26
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +17425 -20672
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/AppDialog.tsx +115 -0
- package/src/components/BackLink.tsx +83 -0
- package/src/components/Connections/AddConnectionDialog.tsx +50 -70
- package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
- package/src/components/Connections/EditConnectionDialog.tsx +54 -73
- package/src/components/Dashboard/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/telemetry.ts +10 -3
- package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +184 -171
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
- package/src/components/DashboardBuilder/DashboardEditor.tsx +135 -61
- package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
- package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
- package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
- package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
- package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
- package/src/components/Environment/About.tsx +14 -28
- package/src/components/Environment/AddPackageDialog.tsx +85 -154
- package/src/components/Environment/Connections.tsx +125 -205
- package/src/components/Environment/DeletePackageDialog.tsx +32 -77
- package/src/components/Environment/EditPackageDialog.tsx +46 -58
- package/src/components/Environment/Environment.tsx +34 -36
- package/src/components/Environment/Packages.tsx +63 -128
- package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
- package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
- package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
- package/src/components/Home/Home.tsx +101 -214
- package/src/components/ItemRow.tsx +165 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
- package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
- package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
- package/src/components/Materializations/Materializations.tsx +137 -140
- package/src/components/Materializations/ScopeButton.tsx +85 -0
- package/src/components/Materializations/SectionLabel.tsx +7 -4
- package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
- package/src/components/Materializations/TriggerLabel.tsx +36 -0
- package/src/components/Materializations/cron.spec.ts +113 -0
- package/src/components/Materializations/index.ts +0 -1
- package/src/components/Materializations/utils.spec.ts +182 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
- package/src/components/Package/ContentTypeIcon.tsx +10 -12
- package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
- package/src/components/Package/NewDashboardDialog.tsx +265 -0
- package/src/components/Package/Package.tsx +179 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- package/src/components/ResultsDialog.tsx +8 -32
- package/src/components/buttons.tsx +114 -0
- package/src/components/designSystem.spec.tsx +316 -0
- package/src/components/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +10 -0
- package/src/components/styles.ts +49 -85
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -0
- package/src/index.ts +9 -0
- package/src/telemetry/consoleEvents.spec.ts +130 -0
- package/src/telemetry/consoleEvents.ts +124 -0
- package/src/theme/defaults.ts +34 -23
- package/src/theme/resolveTheme.spec.ts +9 -4
- package/src/theme/resolveTheme.ts +12 -8
- package/src/utils/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
- package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
- package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
- package/dist/components/Materializations/TriggerChip.d.ts +0 -10
- package/dist/components/Package/Models.d.ts +0 -6
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
- package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
- package/src/components/Materializations/ScheduleCard.tsx +0 -231
- package/src/components/Materializations/TriggerChip.tsx +0 -44
- package/src/components/Package/Models.tsx +0 -71
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import { Box, Button, Snackbar, Stack, Typography } from "@mui/material";
|
|
5
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
6
|
-
import React, { useState } from "react";
|
|
7
|
-
import { Materialization, MaterializationActionActionEnum } from "../../client";
|
|
8
|
-
import {
|
|
9
|
-
useMutationWithApiError,
|
|
10
|
-
useQueryWithApiError,
|
|
11
|
-
} from "../../hooks/useQueryWithApiError";
|
|
12
|
-
import { parseResourceUri } from "../../utils/formatting";
|
|
13
|
-
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
14
|
-
import { Loading } from "../Loading";
|
|
15
|
-
import { useServer } from "../ServerProvider";
|
|
16
|
-
import CreateEnvMaterializationDialog from "./CreateEnvMaterializationDialog";
|
|
17
|
-
import MaterializationDetailDialog from "./MaterializationDetailDialog";
|
|
18
|
-
import MaterializationRunsList from "./MaterializationRunsList";
|
|
19
|
-
import { isActiveStatus } from "./utils";
|
|
20
|
-
|
|
21
|
-
const MATERIALIZATION_POLL_MS = 3000;
|
|
22
|
-
const PAGE_SIZE = 10;
|
|
23
|
-
|
|
24
|
-
interface EnvironmentMaterializationsProps {
|
|
25
|
-
resourceUri: string;
|
|
26
|
-
onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default function EnvironmentMaterializations({
|
|
30
|
-
resourceUri,
|
|
31
|
-
onClickPackageFile,
|
|
32
|
-
}: EnvironmentMaterializationsProps) {
|
|
33
|
-
const { apiClients, mutable } = useServer();
|
|
34
|
-
const queryClient = useQueryClient();
|
|
35
|
-
const { environmentName } = parseResourceUri(resourceUri);
|
|
36
|
-
const [notificationMessage, setNotificationMessage] = useState("");
|
|
37
|
-
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
38
|
-
// Show the most recent runs and page in more on demand — a busy environment
|
|
39
|
-
// (e.g. a frequent schedule) accumulates runs without bound, so never render
|
|
40
|
-
// the full history at once.
|
|
41
|
-
const [limit, setLimit] = useState(PAGE_SIZE);
|
|
42
|
-
|
|
43
|
-
const onClick =
|
|
44
|
-
onClickPackageFile ??
|
|
45
|
-
((to: string) => {
|
|
46
|
-
window.location.href = to;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const listQuery = useQueryWithApiError({
|
|
50
|
-
queryKey: ["env-materializations", environmentName, limit],
|
|
51
|
-
queryFn: () =>
|
|
52
|
-
apiClients.materializations.listEnvironmentMaterializations(
|
|
53
|
-
environmentName,
|
|
54
|
-
limit,
|
|
55
|
-
),
|
|
56
|
-
// "Show more" grows `limit` (part of the key), so keep the current rows on
|
|
57
|
-
// screen while the larger page loads instead of flashing back to the
|
|
58
|
-
// loading state.
|
|
59
|
-
placeholderData: (previousData) => previousData,
|
|
60
|
-
refetchInterval: (query) => {
|
|
61
|
-
const payload = query.state.data as
|
|
62
|
-
| { data?: Materialization[] }
|
|
63
|
-
| undefined;
|
|
64
|
-
const rows = payload?.data ?? [];
|
|
65
|
-
return rows.some((row) => isActiveStatus(row.status))
|
|
66
|
-
? MATERIALIZATION_POLL_MS
|
|
67
|
-
: false;
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const packagesQuery = useQueryWithApiError({
|
|
72
|
-
queryKey: ["packages", environmentName],
|
|
73
|
-
queryFn: () => apiClients.packages.listPackages(environmentName),
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const invalidateList = () =>
|
|
77
|
-
queryClient.invalidateQueries({
|
|
78
|
-
queryKey: ["env-materializations", environmentName],
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// Fire one create per selected package. Each package builds independently, so
|
|
82
|
-
// a failure on one (e.g. an already-active materialization) does not block the
|
|
83
|
-
// others — report an aggregate outcome.
|
|
84
|
-
const createMaterializations = useMutationWithApiError({
|
|
85
|
-
mutationFn: async (opts: {
|
|
86
|
-
packageNames: string[];
|
|
87
|
-
forceRefresh: boolean;
|
|
88
|
-
}) => {
|
|
89
|
-
const results = await Promise.allSettled(
|
|
90
|
-
opts.packageNames.map((pkg) =>
|
|
91
|
-
apiClients.materializations.createMaterialization(
|
|
92
|
-
environmentName,
|
|
93
|
-
pkg,
|
|
94
|
-
{ forceRefresh: opts.forceRefresh },
|
|
95
|
-
),
|
|
96
|
-
),
|
|
97
|
-
);
|
|
98
|
-
const failed = results.filter((r) => r.status === "rejected").length;
|
|
99
|
-
return { total: opts.packageNames.length, failed };
|
|
100
|
-
},
|
|
101
|
-
onSuccess(result) {
|
|
102
|
-
const started = result.total - result.failed;
|
|
103
|
-
setNotificationMessage(
|
|
104
|
-
result.failed === 0
|
|
105
|
-
? `Started ${started} materialization${started === 1 ? "" : "s"}`
|
|
106
|
-
: `Started ${started} of ${result.total} (${result.failed} could not start — a build may already be active)`,
|
|
107
|
-
);
|
|
108
|
-
invalidateList();
|
|
109
|
-
},
|
|
110
|
-
onError(error) {
|
|
111
|
-
setNotificationMessage(error.message);
|
|
112
|
-
invalidateList();
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const stopMaterialization = useMutationWithApiError({
|
|
117
|
-
mutationFn: (materialization: Materialization) =>
|
|
118
|
-
apiClients.materializations.materializationAction(
|
|
119
|
-
environmentName,
|
|
120
|
-
materialization.packageName as string,
|
|
121
|
-
materialization.id as string,
|
|
122
|
-
MaterializationActionActionEnum.Stop,
|
|
123
|
-
),
|
|
124
|
-
onSuccess() {
|
|
125
|
-
setNotificationMessage("Materialization stopped");
|
|
126
|
-
invalidateList();
|
|
127
|
-
},
|
|
128
|
-
onError(error) {
|
|
129
|
-
setNotificationMessage(error.message);
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const deleteMaterialization = useMutationWithApiError({
|
|
134
|
-
mutationFn: ({
|
|
135
|
-
materialization,
|
|
136
|
-
dropTables,
|
|
137
|
-
}: {
|
|
138
|
-
materialization: Materialization;
|
|
139
|
-
dropTables: boolean;
|
|
140
|
-
}) =>
|
|
141
|
-
apiClients.materializations.deleteMaterialization(
|
|
142
|
-
environmentName,
|
|
143
|
-
materialization.packageName as string,
|
|
144
|
-
materialization.id as string,
|
|
145
|
-
dropTables,
|
|
146
|
-
),
|
|
147
|
-
onSuccess() {
|
|
148
|
-
setNotificationMessage("Materialization deleted");
|
|
149
|
-
invalidateList();
|
|
150
|
-
},
|
|
151
|
-
onError(error) {
|
|
152
|
-
setNotificationMessage(error.message);
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
const materializations = (listQuery.data?.data ?? []) as Materialization[];
|
|
157
|
-
const packages = (packagesQuery.data?.data ?? []) as { name: string }[];
|
|
158
|
-
const selected =
|
|
159
|
-
materializations.find((row) => row.id === selectedId) ?? null;
|
|
160
|
-
const isMutating =
|
|
161
|
-
createMaterializations.isPending ||
|
|
162
|
-
stopMaterialization.isPending ||
|
|
163
|
-
deleteMaterialization.isPending;
|
|
164
|
-
// A full page implies there may be older runs beyond the current window.
|
|
165
|
-
const hasMore = materializations.length >= limit;
|
|
166
|
-
|
|
167
|
-
return (
|
|
168
|
-
<Box>
|
|
169
|
-
<Box
|
|
170
|
-
sx={{
|
|
171
|
-
display: "flex",
|
|
172
|
-
alignItems: "flex-start",
|
|
173
|
-
justifyContent: "space-between",
|
|
174
|
-
mb: 3,
|
|
175
|
-
}}
|
|
176
|
-
>
|
|
177
|
-
<Box>
|
|
178
|
-
<Typography
|
|
179
|
-
variant="h6"
|
|
180
|
-
sx={{ fontWeight: 600, letterSpacing: "-0.025em" }}
|
|
181
|
-
>
|
|
182
|
-
Materializations
|
|
183
|
-
</Typography>
|
|
184
|
-
<Typography variant="body2" color="text.secondary">
|
|
185
|
-
All materialization builds across the packages in this
|
|
186
|
-
environment
|
|
187
|
-
</Typography>
|
|
188
|
-
</Box>
|
|
189
|
-
{mutable && (
|
|
190
|
-
<CreateEnvMaterializationDialog
|
|
191
|
-
packages={packages}
|
|
192
|
-
onSubmit={(opts) => createMaterializations.mutateAsync(opts)}
|
|
193
|
-
isSubmitting={createMaterializations.isPending}
|
|
194
|
-
/>
|
|
195
|
-
)}
|
|
196
|
-
</Box>
|
|
197
|
-
|
|
198
|
-
{listQuery.isError && (
|
|
199
|
-
<ApiErrorDisplay
|
|
200
|
-
error={listQuery.error}
|
|
201
|
-
context={`${environmentName} > Materializations`}
|
|
202
|
-
/>
|
|
203
|
-
)}
|
|
204
|
-
{!listQuery.isSuccess && !listQuery.isError && (
|
|
205
|
-
<Loading text="Loading materializations..." />
|
|
206
|
-
)}
|
|
207
|
-
{listQuery.isSuccess && (
|
|
208
|
-
<MaterializationRunsList
|
|
209
|
-
materializations={materializations}
|
|
210
|
-
mutable={mutable}
|
|
211
|
-
isMutating={isMutating}
|
|
212
|
-
showPackage
|
|
213
|
-
onClickPackage={(packageName) =>
|
|
214
|
-
onClick(`/${environmentName}/${packageName}/materializations`)
|
|
215
|
-
}
|
|
216
|
-
onStop={(materialization) =>
|
|
217
|
-
stopMaterialization.mutate(materialization)
|
|
218
|
-
}
|
|
219
|
-
onDelete={(materialization, dropTables) =>
|
|
220
|
-
deleteMaterialization.mutate({ materialization, dropTables })
|
|
221
|
-
}
|
|
222
|
-
onViewDetails={(materialization) =>
|
|
223
|
-
setSelectedId(materialization.id ?? null)
|
|
224
|
-
}
|
|
225
|
-
/>
|
|
226
|
-
)}
|
|
227
|
-
{listQuery.isSuccess && materializations.length > 0 && (
|
|
228
|
-
<Stack
|
|
229
|
-
direction="row"
|
|
230
|
-
alignItems="center"
|
|
231
|
-
justifyContent="center"
|
|
232
|
-
spacing={2}
|
|
233
|
-
sx={{ mt: 2 }}
|
|
234
|
-
>
|
|
235
|
-
<Typography variant="caption" color="text.secondary">
|
|
236
|
-
{hasMore
|
|
237
|
-
? `Showing ${materializations.length} most recent`
|
|
238
|
-
: `${materializations.length} materialization${materializations.length === 1 ? "" : "s"}`}
|
|
239
|
-
</Typography>
|
|
240
|
-
{hasMore && (
|
|
241
|
-
<Button
|
|
242
|
-
size="small"
|
|
243
|
-
onClick={() => setLimit((l) => l + PAGE_SIZE)}
|
|
244
|
-
disabled={listQuery.isFetching}
|
|
245
|
-
>
|
|
246
|
-
Show more
|
|
247
|
-
</Button>
|
|
248
|
-
)}
|
|
249
|
-
</Stack>
|
|
250
|
-
)}
|
|
251
|
-
|
|
252
|
-
<MaterializationDetailDialog
|
|
253
|
-
materialization={selected}
|
|
254
|
-
buildPlan={null}
|
|
255
|
-
showBuildPlan={false}
|
|
256
|
-
onClose={() => setSelectedId(null)}
|
|
257
|
-
/>
|
|
258
|
-
|
|
259
|
-
<Snackbar
|
|
260
|
-
open={notificationMessage !== ""}
|
|
261
|
-
autoHideDuration={6000}
|
|
262
|
-
onClose={() => setNotificationMessage("")}
|
|
263
|
-
message={notificationMessage}
|
|
264
|
-
/>
|
|
265
|
-
</Box>
|
|
266
|
-
);
|
|
267
|
-
}
|
|
@@ -1,231 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import ScheduleIcon from "@mui/icons-material/Schedule";
|
|
5
|
-
import TouchAppIcon from "@mui/icons-material/TouchApp";
|
|
6
|
-
import { Chip, Tooltip } from "@mui/material";
|
|
7
|
-
import { MaterializationMetadata, triggerLabel } from "./utils";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Chip showing how a run was initiated — Scheduled (the standalone scheduler
|
|
11
|
-
* fired the package's cron) vs Manual (an API/UI create) — with a tooltip. One
|
|
12
|
-
* source of truth for the color/icon/label so the runs list and the detail
|
|
13
|
-
* dialog can never drift.
|
|
14
|
-
*/
|
|
15
|
-
export default function TriggerChip({
|
|
16
|
-
meta,
|
|
17
|
-
}: {
|
|
18
|
-
meta: MaterializationMetadata;
|
|
19
|
-
}) {
|
|
20
|
-
const scheduled = meta.trigger === "SCHEDULER";
|
|
21
|
-
return (
|
|
22
|
-
<Tooltip
|
|
23
|
-
title={
|
|
24
|
-
scheduled
|
|
25
|
-
? "Fired by the materialization schedule"
|
|
26
|
-
: "Triggered manually"
|
|
27
|
-
}
|
|
28
|
-
>
|
|
29
|
-
<Chip
|
|
30
|
-
size="small"
|
|
31
|
-
variant="outlined"
|
|
32
|
-
color={scheduled ? "info" : "default"}
|
|
33
|
-
icon={
|
|
34
|
-
scheduled ? (
|
|
35
|
-
<ScheduleIcon fontSize="small" />
|
|
36
|
-
) : (
|
|
37
|
-
<TouchAppIcon fontSize="small" />
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
label={triggerLabel(meta)}
|
|
41
|
-
/>
|
|
42
|
-
</Tooltip>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import { Box, Typography } from "@mui/material";
|
|
5
|
-
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
6
|
-
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
7
|
-
import { Loading } from "../Loading";
|
|
8
|
-
import {
|
|
9
|
-
PackageCard,
|
|
10
|
-
PackageCardContent,
|
|
11
|
-
PackageSectionTitle,
|
|
12
|
-
} from "../styles";
|
|
13
|
-
import { FileTreeView } from "./FileTreeView";
|
|
14
|
-
import { parseResourceUri } from "../../utils/formatting";
|
|
15
|
-
import { useServer } from "../ServerProvider";
|
|
16
|
-
|
|
17
|
-
const DEFAULT_EXPANDED_FOLDERS = ["notebooks/", "models/"];
|
|
18
|
-
|
|
19
|
-
interface ModelsProps {
|
|
20
|
-
onClickModelFile: (to: string, event?: React.MouseEvent) => void;
|
|
21
|
-
resourceUri: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default function Models({ onClickModelFile, resourceUri }: ModelsProps) {
|
|
25
|
-
const {
|
|
26
|
-
environmentName: environmentName,
|
|
27
|
-
packageName: packageName,
|
|
28
|
-
versionId: versionId,
|
|
29
|
-
} = parseResourceUri(resourceUri);
|
|
30
|
-
const { apiClients } = useServer();
|
|
31
|
-
|
|
32
|
-
const { data, isError, error, isSuccess } = useQueryWithApiError({
|
|
33
|
-
queryKey: ["models", environmentName, packageName, versionId],
|
|
34
|
-
queryFn: () =>
|
|
35
|
-
apiClients.models.listModels(environmentName, packageName, versionId),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<PackageCard>
|
|
40
|
-
<PackageCardContent>
|
|
41
|
-
<PackageSectionTitle>Semantic Models</PackageSectionTitle>
|
|
42
|
-
<Box
|
|
43
|
-
sx={{
|
|
44
|
-
maxHeight: "200px",
|
|
45
|
-
overflowY: "auto",
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
{!isSuccess && !isError && <Loading text="Fetching Models..." />}
|
|
49
|
-
{isError && (
|
|
50
|
-
<ApiErrorDisplay
|
|
51
|
-
error={error}
|
|
52
|
-
context={`${environmentName} > ${packageName} > Models`}
|
|
53
|
-
/>
|
|
54
|
-
)}
|
|
55
|
-
{isSuccess && data.data.length > 0 && (
|
|
56
|
-
<FileTreeView
|
|
57
|
-
items={data.data.sort((a, b) => {
|
|
58
|
-
return a.path.localeCompare(b.path);
|
|
59
|
-
})}
|
|
60
|
-
onClickTreeNode={onClickModelFile}
|
|
61
|
-
defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
|
|
62
|
-
/>
|
|
63
|
-
)}
|
|
64
|
-
{isSuccess && data.data.length === 0 && (
|
|
65
|
-
<Typography variant="body2">No models found</Typography>
|
|
66
|
-
)}
|
|
67
|
-
</Box>
|
|
68
|
-
</PackageCardContent>
|
|
69
|
-
</PackageCard>
|
|
70
|
-
);
|
|
71
|
-
}
|