@malloy-publisher/sdk 0.10.6 → 0.11.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/dist/{RenderedResult-BlYdT4lz.cjs.js → RenderedResult-C2r3Zkwl.cjs.js} +1 -1
- package/dist/{RenderedResult-B_sW7neX.es.js → RenderedResult-r3dg2xOJ.es.js} +2 -2
- package/dist/ServerProvider-CFHqDHFO.cjs.js +1 -0
- package/dist/{ServerProvider-BN399NH6.es.js → ServerProvider-DdGjhDhY.es.js} +2077 -1604
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +673 -165
- 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 +101 -92
- package/dist/components/Materializations/Materializations.d.ts +8 -1
- package/dist/components/Package/Package.d.ts +15 -1
- package/dist/components/Package/VersionSwitch.d.ts +51 -0
- package/dist/components/Package/index.d.ts +2 -0
- package/dist/components/Package/usePackageVersions.d.ts +48 -0
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/hooks/useDimensionFiltersQuery.d.ts +2 -0
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +8290 -7677
- package/dist/{useCompiledDocument-xJRD5DRP.es.js → useCompiledDocument-Bc0HuUtz.es.js} +3 -3
- package/dist/{useCompiledDocument-CyPOSStA.cjs.js → useCompiledDocument-QgySwHGA.cjs.js} +2 -2
- package/dist/utils/dataAppEmbed.d.ts +6 -1
- package/package.json +1 -1
- package/src/components/DataAppViewer/DataAppViewer.tsx +18 -5
- package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +2 -0
- package/src/components/Environment/Packages.tsx +12 -5
- package/src/components/Environment/Packages.versions.spec.tsx +62 -0
- package/src/components/Materializations/Materializations.tsx +26 -6
- package/src/components/Materializations/Materializations.versions.spec.tsx +101 -0
- package/src/components/Package/Package.agents.spec.tsx +2 -0
- package/src/components/Package/Package.artifacts.spec.tsx +35 -0
- package/src/components/Package/Package.create.spec.tsx +37 -1
- package/src/components/Package/Package.notebooks.spec.tsx +2 -0
- package/src/components/Package/Package.spec.tsx +23 -11
- package/src/components/Package/Package.tsx +111 -20
- package/src/components/Package/VersionSwitch.spec.tsx +668 -0
- package/src/components/Package/VersionSwitch.tsx +779 -0
- package/src/components/Package/index.ts +7 -0
- package/src/components/Package/usePackageVersions.spec.tsx +78 -0
- package/src/components/Package/usePackageVersions.ts +146 -0
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
- package/src/components/ReportBuilder/ReportEditor.authoritative.spec.tsx +5 -1
- package/src/components/ServerProvider.tsx +2 -0
- package/src/hooks/useDimensionFiltersFromSpec.ts +1 -0
- package/src/hooks/useDimensionFiltersQuery.ts +5 -1
- package/src/utils/dataAppEmbed.spec.ts +27 -0
- package/src/utils/dataAppEmbed.ts +11 -3
- package/src/utils/formatting.spec.ts +25 -0
- package/src/utils/formatting.ts +2 -1
- package/test/serverProvider.tsx +15 -0
- package/dist/ServerProvider-e2369oom.cjs.js +0 -1
|
@@ -55,6 +55,8 @@ import {
|
|
|
55
55
|
} from "./documentLocation";
|
|
56
56
|
import { invalidateReportQueries } from "./reportQueries";
|
|
57
57
|
import { useReportListing } from "./useDocumentLocation";
|
|
58
|
+
import { usePackageVersions } from "./usePackageVersions";
|
|
59
|
+
import { VersionSwitch } from "./VersionSwitch";
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
62
|
* The pinned README: a report at the package root whose basename is README,
|
|
@@ -93,6 +95,20 @@ interface PackageProps {
|
|
|
93
95
|
resourceUri: string;
|
|
94
96
|
/** What the New report dialog creates, or why it could not; see `ReportEvent`. */
|
|
95
97
|
onEvent?: ReportEventHandler;
|
|
98
|
+
/**
|
|
99
|
+
* Open another version of the package, picked from the title's version
|
|
100
|
+
* switch. Absent, the page navigates to the Console's own route for it,
|
|
101
|
+
* `/<env>/<pkg>/<version>`. Only a package with published versions shows
|
|
102
|
+
* the switch.
|
|
103
|
+
*/
|
|
104
|
+
onSelectVersion?: (versionId: string, event?: React.MouseEvent) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Show another version in place of the one on screen after it was
|
|
107
|
+
* archived or deleted: a version's id, or undefined for `latest`. Meant to
|
|
108
|
+
* replace the address rather than add to history. Absent, the version is
|
|
109
|
+
* opened with `onSelectVersion`.
|
|
110
|
+
*/
|
|
111
|
+
onReplaceVersion?: (versionId: string | undefined) => void;
|
|
96
112
|
}
|
|
97
113
|
|
|
98
114
|
export default function Package({
|
|
@@ -100,6 +116,8 @@ export default function Package({
|
|
|
100
116
|
onOpenDocument,
|
|
101
117
|
resourceUri,
|
|
102
118
|
onEvent,
|
|
119
|
+
onSelectVersion,
|
|
120
|
+
onReplaceVersion,
|
|
103
121
|
}: PackageProps) {
|
|
104
122
|
const { apiClients, server, mutable } = useServer();
|
|
105
123
|
const queryClient = useQueryClient();
|
|
@@ -110,6 +128,22 @@ export default function Package({
|
|
|
110
128
|
});
|
|
111
129
|
const { environmentName, packageName, versionId } =
|
|
112
130
|
parseResourceUri(resourceUri);
|
|
131
|
+
// A package with published versions is immutable: it shows which version
|
|
132
|
+
// is on screen, and offers nothing that writes into the package. Until
|
|
133
|
+
// its listing has said it has none, nothing that writes is offered either:
|
|
134
|
+
// while the listing loads, or when it failed.
|
|
135
|
+
const versionListing = usePackageVersions(environmentName, packageName);
|
|
136
|
+
const { versions } = versionListing;
|
|
137
|
+
const versioned = versions.length > 0;
|
|
138
|
+
const editable =
|
|
139
|
+
!versioned && !versionListing.isPending && !versionListing.isError;
|
|
140
|
+
const selectVersion =
|
|
141
|
+
onSelectVersion ??
|
|
142
|
+
((id: string, event?: React.MouseEvent) =>
|
|
143
|
+
onClick(
|
|
144
|
+
`/${encodeURIComponent(environmentName)}/${encodeURIComponent(packageName)}/${encodeURIComponent(id)}`,
|
|
145
|
+
event,
|
|
146
|
+
));
|
|
113
147
|
const openDocument =
|
|
114
148
|
onOpenDocument ??
|
|
115
149
|
((request: OpenDocumentRequest, event?: React.MouseEvent) => {
|
|
@@ -204,17 +238,16 @@ export default function Package({
|
|
|
204
238
|
// Goes through the configured API client so consumers using a non-default
|
|
205
239
|
// baseURL or Bearer auth (via <ServerProvider>) get the same plumbing as
|
|
206
240
|
// every other endpoint.
|
|
207
|
-
//
|
|
208
|
-
//
|
|
209
|
-
// versionId would fragment the cache and prevent DataAppViewer's identical
|
|
210
|
-
// query from deduping.
|
|
241
|
+
// A published version lists its own data apps, each `resource` naming that
|
|
242
|
+
// version, so the key carries it, the same key DataAppViewer reads.
|
|
211
243
|
const dataAppsQuery = useQueryWithApiError({
|
|
212
|
-
queryKey: ["data-apps", environmentName, packageName],
|
|
244
|
+
queryKey: ["data-apps", environmentName, packageName, versionId],
|
|
213
245
|
queryFn: async () => {
|
|
214
246
|
try {
|
|
215
247
|
return await apiClients.dataApps.listDataApps(
|
|
216
248
|
environmentName,
|
|
217
249
|
packageName,
|
|
250
|
+
versionId,
|
|
218
251
|
);
|
|
219
252
|
} catch (e) {
|
|
220
253
|
// A 404 or transport-level failure (older Publisher without the
|
|
@@ -262,7 +295,7 @@ export default function Package({
|
|
|
262
295
|
workspace.state === "ready"
|
|
263
296
|
? createRoute({
|
|
264
297
|
authoritative: workspace.chosen?.authoritative === true,
|
|
265
|
-
mutable,
|
|
298
|
+
mutable: mutable && editable,
|
|
266
299
|
canStore: workspace.chosen?.writeable === true,
|
|
267
300
|
...(versionId === undefined ? {} : { versionId }),
|
|
268
301
|
})
|
|
@@ -331,13 +364,56 @@ export default function Package({
|
|
|
331
364
|
// one parallel request's latency.
|
|
332
365
|
const isLoading = !reportListing.settled;
|
|
333
366
|
|
|
367
|
+
const versionSwitch = versioned ? (
|
|
368
|
+
<VersionSwitch
|
|
369
|
+
environmentName={environmentName}
|
|
370
|
+
packageName={packageName}
|
|
371
|
+
versions={versions}
|
|
372
|
+
{...(versionId !== undefined ? { selectedVersionId: versionId } : {})}
|
|
373
|
+
onSelectVersion={selectVersion}
|
|
374
|
+
{...(onReplaceVersion ? { onReplaceVersion } : {})}
|
|
375
|
+
// Deleting the only version deletes the package: back to its
|
|
376
|
+
// environment.
|
|
377
|
+
onPackageDeleted={() =>
|
|
378
|
+
onClick(`/${encodeURIComponent(environmentName)}`)
|
|
379
|
+
}
|
|
380
|
+
canManage={mutable}
|
|
381
|
+
/>
|
|
382
|
+
) : null;
|
|
383
|
+
|
|
384
|
+
const title = (
|
|
385
|
+
<Stack direction="row" alignItems="center" spacing={1.5} sx={{ mb: 0.5 }}>
|
|
386
|
+
<Typography
|
|
387
|
+
variant="h4"
|
|
388
|
+
component="h1"
|
|
389
|
+
sx={{ fontWeight: 600, letterSpacing: "-0.025em" }}
|
|
390
|
+
>
|
|
391
|
+
{packageName}
|
|
392
|
+
</Typography>
|
|
393
|
+
{versionSwitch}
|
|
394
|
+
</Stack>
|
|
395
|
+
);
|
|
396
|
+
|
|
334
397
|
if (pkgQuery.isError) {
|
|
335
|
-
|
|
398
|
+
const error = (
|
|
336
399
|
<ApiErrorDisplay
|
|
337
400
|
error={pkgQuery.error}
|
|
338
401
|
context={`${environmentName} > ${packageName}`}
|
|
339
402
|
/>
|
|
340
403
|
);
|
|
404
|
+
// A version that cannot be served (archived, unknown, or no `latest`
|
|
405
|
+
// yet) still offers the switch, the way to one that can.
|
|
406
|
+
return versionSwitch ? (
|
|
407
|
+
<Container
|
|
408
|
+
maxWidth={false}
|
|
409
|
+
sx={{ maxWidth: 1024, mx: "auto", px: 3, py: 6 }}
|
|
410
|
+
>
|
|
411
|
+
<Box sx={{ mb: 4 }}>{title}</Box>
|
|
412
|
+
{error}
|
|
413
|
+
</Container>
|
|
414
|
+
) : (
|
|
415
|
+
error
|
|
416
|
+
);
|
|
341
417
|
}
|
|
342
418
|
|
|
343
419
|
return (
|
|
@@ -346,17 +422,7 @@ export default function Package({
|
|
|
346
422
|
sx={{ maxWidth: 1024, mx: "auto", px: 3, py: 6 }}
|
|
347
423
|
>
|
|
348
424
|
<Box sx={{ mb: 4 }}>
|
|
349
|
-
|
|
350
|
-
variant="h4"
|
|
351
|
-
component="h1"
|
|
352
|
-
sx={{
|
|
353
|
-
fontWeight: 600,
|
|
354
|
-
letterSpacing: "-0.025em",
|
|
355
|
-
mb: 0.5,
|
|
356
|
-
}}
|
|
357
|
-
>
|
|
358
|
-
{packageName}
|
|
359
|
-
</Typography>
|
|
425
|
+
{title}
|
|
360
426
|
{description && (
|
|
361
427
|
<Typography variant="body2" color="text.secondary">
|
|
362
428
|
{description}
|
|
@@ -366,6 +432,26 @@ export default function Package({
|
|
|
366
432
|
|
|
367
433
|
<PackageProblems warnings={pkgQuery.data?.data?.warnings} />
|
|
368
434
|
|
|
435
|
+
{versionListing.isError && (
|
|
436
|
+
<Box sx={{ mb: 4 }}>
|
|
437
|
+
<Alert
|
|
438
|
+
severity="warning"
|
|
439
|
+
action={
|
|
440
|
+
<Button
|
|
441
|
+
color="inherit"
|
|
442
|
+
size="small"
|
|
443
|
+
onClick={versionListing.refetch}
|
|
444
|
+
>
|
|
445
|
+
Retry
|
|
446
|
+
</Button>
|
|
447
|
+
}
|
|
448
|
+
>
|
|
449
|
+
Could not read this package's versions, so nothing that
|
|
450
|
+
changes it is offered until they load.
|
|
451
|
+
</Alert>
|
|
452
|
+
</Box>
|
|
453
|
+
)}
|
|
454
|
+
|
|
369
455
|
{isLoading && <Loading text="Loading package..." />}
|
|
370
456
|
|
|
371
457
|
{createTarget && (
|
|
@@ -499,7 +585,9 @@ export default function Package({
|
|
|
499
585
|
))}
|
|
500
586
|
</PackageSection>
|
|
501
587
|
)}
|
|
502
|
-
{
|
|
588
|
+
{/* A draft opens in the builder, which saves into the
|
|
589
|
+
package: not offered where nothing may be written. */}
|
|
590
|
+
{editable && drafts.length > 0 && (
|
|
503
591
|
<PackageSection title="Drafts" count={drafts.length}>
|
|
504
592
|
{drafts.map(({ locator, where }) => (
|
|
505
593
|
<PackageItemRow
|
|
@@ -656,7 +744,10 @@ export default function Package({
|
|
|
656
744
|
{databases.length === 0 && <EmptyRow label="No data files" />}
|
|
657
745
|
</PackageSection>
|
|
658
746
|
|
|
659
|
-
<Materializations
|
|
747
|
+
<Materializations
|
|
748
|
+
resourceUri={resourceUri}
|
|
749
|
+
versioned={!editable}
|
|
750
|
+
/>
|
|
660
751
|
|
|
661
752
|
{readmePath && (
|
|
662
753
|
<Box sx={{ mt: 6 }}>
|