@malloy-publisher/sdk 0.14.0 → 0.15.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.
Files changed (28) hide show
  1. package/dist/{RenderedResult-C9PiHrGC.cjs.js → RenderedResult-B2VzqpJV.cjs.js} +1 -1
  2. package/dist/{RenderedResult-D0kAzSrP.es.js → RenderedResult-Ct3z543g.es.js} +9 -9
  3. package/dist/{ServerProvider-BHM9y5l0.es.js → ServerProvider-Be9eusDF.es.js} +1066 -989
  4. package/dist/ServerProvider-DDr5VOVF.cjs.js +1 -0
  5. package/dist/builder/index.cjs.js +1 -1
  6. package/dist/builder/index.es.js +335 -335
  7. package/dist/client/api.d.ts +245 -73
  8. package/dist/client/index.cjs.js +1 -1
  9. package/dist/client/index.es.js +110 -104
  10. package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +1 -1
  11. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -1
  12. package/dist/components/Materializations/utils.d.ts +7 -4
  13. package/dist/components/Package/PackageProblems.d.ts +6 -0
  14. package/dist/index.cjs.js +38 -38
  15. package/dist/index.es.js +6176 -6665
  16. package/dist/{useCompiledDocument-Co-INO6B.cjs.js → useCompiledDocument-CQG6VO-x.cjs.js} +20 -20
  17. package/dist/{useCompiledDocument-CF5s0cXj.es.js → useCompiledDocument-CuSAYHX_.es.js} +56 -60
  18. package/package.json +1 -1
  19. package/src/components/Materializations/DeleteMaterializationDialog.tsx +5 -16
  20. package/src/components/Materializations/MaterializationRunsList.tsx +3 -5
  21. package/src/components/Materializations/Materializations.tsx +3 -13
  22. package/src/components/Materializations/Materializations.versions.spec.tsx +6 -3
  23. package/src/components/Materializations/TriggerLabel.tsx +2 -2
  24. package/src/components/Materializations/utils.spec.ts +6 -1
  25. package/src/components/Materializations/utils.ts +11 -5
  26. package/src/components/Package/PackageProblems.spec.tsx +25 -1
  27. package/src/components/Package/PackageProblems.tsx +30 -12
  28. package/dist/ServerProvider-D97_rUv5.cjs.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import { jsx as S, jsxs as re, Fragment as Bt } from "react/jsx-runtime";
2
2
  import { Box as be, Dialog as Ed, DialogTitle as Od, IconButton as Qn, DialogContent as Ad, Typography as Ge, Stack as wt, DialogActions as Fd, Button as st, Tooltip as wn, TextField as Vn, InputAdornment as Wl, Alert as Ld, Autocomplete as Nd, CircularProgress as Hl, FormControl as Ki, Slider as Bd, FormHelperText as Xi, FormControlLabel as Vd, Checkbox as zd, Paper as ni, MenuItem as An, ButtonBase as Ul, Popover as _d, LinearProgress as Wd } from "@mui/material";
3
- import { bv as Ke, bA as Zn, bB as Hd, bw as Jn, bu as Yl, bQ as Ud } from "./ServerProvider-BHM9y5l0.es.js";
3
+ import { bB as Ke, bG as Zn, bH as Hd, bC as Jn, bA as Yl, bW as Ud } from "./ServerProvider-Be9eusDF.es.js";
4
4
  import * as x from "react";
5
5
  import xt, { useState as Oe, useEffect as He, useRef as Ye, useId as jl, useMemo as Ve, useCallback as et, createContext as Fo, useContext as er, isValidElement as co, cloneElement as uo, Children as Yd, Suspense as jd, lazy as Gd } from "react";
6
6
  import { useQueries as Gl, QueryClientContext as qd, useQuery as Kd, useMutation as Xd, keepPreviousData as Qd } from "@tanstack/react-query";
@@ -23485,7 +23485,7 @@ function mk(e) {
23485
23485
  `)
23486
23486
  };
23487
23487
  }
23488
- const gk = Gd(() => import("./RenderedResult-D0kAzSrP.es.js").then((e) => e.c));
23488
+ const gk = Gd(() => import("./RenderedResult-Ct3z543g.es.js").then((e) => e.c));
23489
23489
  function yk({
23490
23490
  result: e,
23491
23491
  maxHeight: t,
@@ -25179,7 +25179,7 @@ export {
25179
25179
  Bc as by,
25180
25180
  KD as bz,
25181
25181
  dk as c,
25182
- Cs as c$,
25182
+ dd as c$,
25183
25183
  BD as c0,
25184
25184
  qe as c1,
25185
25185
  Or as c2,
@@ -25190,33 +25190,33 @@ export {
25190
25190
  Yk as c7,
25191
25191
  Ft as c8,
25192
25192
  Ht as c9,
25193
- pk as cA,
25194
- ud as cB,
25195
- HD as cC,
25196
- OP as cD,
25197
- Lg as cE,
25198
- LD as cF,
25199
- xd as cG,
25200
- yk as cH,
25201
- AD as cI,
25202
- FD as cJ,
25203
- Dg as cK,
25204
- bD as cL,
25205
- fk as cM,
25206
- wm as cN,
25207
- yD as cO,
25208
- oT as cP,
25209
- ID as cQ,
25210
- eg as cR,
25211
- uM as cS,
25212
- Ls as cT,
25213
- qD as cU,
25214
- kk as cV,
25215
- lM as cW,
25216
- Dk as cX,
25217
- Zk as cY,
25218
- Wm as cZ,
25219
- gD as c_,
25193
+ Lg as cA,
25194
+ LD as cB,
25195
+ xd as cC,
25196
+ yk as cD,
25197
+ AD as cE,
25198
+ FD as cF,
25199
+ Dg as cG,
25200
+ bD as cH,
25201
+ fk as cI,
25202
+ wm as cJ,
25203
+ yD as cK,
25204
+ oT as cL,
25205
+ ID as cM,
25206
+ eg as cN,
25207
+ uM as cO,
25208
+ Ls as cP,
25209
+ qD as cQ,
25210
+ kk as cR,
25211
+ lM as cS,
25212
+ Dk as cT,
25213
+ Zk as cU,
25214
+ Wm as cV,
25215
+ gD as cW,
25216
+ Cs as cX,
25217
+ EP as cY,
25218
+ Tk as cZ,
25219
+ yT as c_,
25220
25220
  wa as ca,
25221
25221
  yw as cb,
25222
25222
  S0 as cc,
@@ -25239,37 +25239,33 @@ export {
25239
25239
  WM as ct,
25240
25240
  rn as cu,
25241
25241
  ei as cv,
25242
- kt as cw,
25243
- Hh as cx,
25244
- ot as cy,
25245
- nr as cz,
25242
+ pk as cw,
25243
+ ud as cx,
25244
+ HD as cy,
25245
+ OP as cz,
25246
25246
  QD as d,
25247
- EP as d0,
25248
- Tk as d1,
25249
- yT as d2,
25250
- dd as d3,
25251
- Em as d4,
25252
- Mk as d5,
25253
- Tg as d6,
25254
- _k as d7,
25255
- Wk as d8,
25256
- bc as d9,
25257
- Ak as da,
25258
- wk as db,
25259
- $m as dc,
25260
- TD as dd,
25261
- bg as de,
25262
- Om as df,
25263
- Rk as dg,
25264
- wd as dh,
25265
- Un as di,
25266
- yM as dj,
25267
- Pk as dk,
25268
- Pa as dl,
25269
- XD as dm,
25270
- bT as dn,
25271
- vg as dp,
25272
- cm as dq,
25247
+ Em as d0,
25248
+ Mk as d1,
25249
+ Tg as d2,
25250
+ _k as d3,
25251
+ Wk as d4,
25252
+ bc as d5,
25253
+ Ak as d6,
25254
+ wk as d7,
25255
+ $m as d8,
25256
+ TD as d9,
25257
+ bg as da,
25258
+ Om as db,
25259
+ Rk as dc,
25260
+ wd as dd,
25261
+ Un as de,
25262
+ yM as df,
25263
+ Pk as dg,
25264
+ Pa as dh,
25265
+ XD as di,
25266
+ bT as dj,
25267
+ vg as dk,
25268
+ cm as dl,
25273
25269
  fD as e,
25274
25270
  Tm as f,
25275
25271
  hD as g,
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.14.0",
4
+ "version": "0.15.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -3,8 +3,6 @@
3
3
 
4
4
  import { Delete } from "@mui/icons-material";
5
5
  import Button from "@mui/material/Button";
6
- import Checkbox from "@mui/material/Checkbox";
7
- import FormControlLabel from "@mui/material/FormControlLabel";
8
6
  import ListItemIcon from "@mui/material/ListItemIcon";
9
7
  import ListItemText from "@mui/material/ListItemText";
10
8
  import MenuItem from "@mui/material/MenuItem";
@@ -22,15 +20,13 @@ export default function DeleteMaterializationDialog({
22
20
  materialization: Materialization;
23
21
  onCloseDialog: () => void;
24
22
  isMutating: boolean;
25
- onDelete: (dropTables: boolean) => void;
23
+ onDelete: () => void;
26
24
  }) {
27
25
  const [open, setOpen] = useState(false);
28
- const [dropTables, setDropTables] = useState(false);
29
26
 
30
27
  const handleClickOpen = () => setOpen(true);
31
28
  const handleClose = () => {
32
29
  setOpen(false);
33
- setDropTables(false);
34
30
  onCloseDialog();
35
31
  };
36
32
 
@@ -61,7 +57,7 @@ export default function DeleteMaterializationDialog({
61
57
  variant="contained"
62
58
  color="error"
63
59
  autoFocus
64
- onClick={() => onDelete(dropTables)}
60
+ onClick={() => onDelete()}
65
61
  loading={isMutating}
66
62
  >
67
63
  Delete run
@@ -70,17 +66,10 @@ export default function DeleteMaterializationDialog({
70
66
  }
71
67
  >
72
68
  <Typography variant="body2">
73
- Delete this run&apos;s record? This cannot be undone.
69
+ Delete this run&apos;s record? This cannot be undone. The tables
70
+ it built stay in place: drop any you no longer need through their
71
+ connection.
74
72
  </Typography>
75
- <FormControlLabel
76
- control={
77
- <Checkbox
78
- checked={dropTables}
79
- onChange={(event) => setDropTables(event.target.checked)}
80
- />
81
- }
82
- label="Also drop the materialized tables this run produced"
83
- />
84
73
  </AppDialog>
85
74
  </React.Fragment>
86
75
  );
@@ -39,7 +39,7 @@ type MaterializationRunsListProps = {
39
39
  mutable: boolean;
40
40
  isMutating: boolean;
41
41
  onStop: (materialization: Materialization) => void;
42
- onDelete: (materialization: Materialization, dropTables: boolean) => void;
42
+ onDelete: (materialization: Materialization) => void;
43
43
  onViewDetails: (materialization: Materialization) => void;
44
44
  };
45
45
 
@@ -115,7 +115,7 @@ function MaterializationRow({
115
115
  mutable: boolean;
116
116
  isMutating: boolean;
117
117
  onStop: (materialization: Materialization) => void;
118
- onDelete: (materialization: Materialization, dropTables: boolean) => void;
118
+ onDelete: (materialization: Materialization) => void;
119
119
  onViewDetails: (materialization: Materialization) => void;
120
120
  }) {
121
121
  const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
@@ -230,9 +230,7 @@ function MaterializationRow({
230
230
  materialization={materialization}
231
231
  isMutating={isMutating}
232
232
  onCloseDialog={handleMenuClose}
233
- onDelete={(dropTables) =>
234
- onDelete(materialization, dropTables)
235
- }
233
+ onDelete={() => onDelete(materialization)}
236
234
  />
237
235
  )}
238
236
  </Menu>
@@ -183,18 +183,11 @@ export default function Materializations({
183
183
  mutationFn: reporting(
184
184
  "materialization",
185
185
  "delete",
186
- ({
187
- materialization,
188
- dropTables,
189
- }: {
190
- materialization: Materialization;
191
- dropTables: boolean;
192
- }) =>
186
+ (materialization: Materialization) =>
193
187
  apiClients.materializations.deleteMaterialization(
194
188
  environmentName,
195
189
  packageName,
196
190
  materialization.id as string,
197
- dropTables,
198
191
  versionId,
199
192
  ),
200
193
  ),
@@ -385,11 +378,8 @@ export default function Materializations({
385
378
  onStop={(materialization) =>
386
379
  stopMaterialization.mutate(materialization)
387
380
  }
388
- onDelete={(materialization, dropTables) =>
389
- deleteMaterialization.mutate({
390
- materialization,
391
- dropTables,
392
- })
381
+ onDelete={(materialization) =>
382
+ deleteMaterialization.mutate(materialization)
393
383
  }
394
384
  onViewDetails={(materialization) =>
395
385
  setSelectedId(materialization.id ?? null)
@@ -40,7 +40,6 @@ const deleteMaterialization = mock(
40
40
  _environmentName: string,
41
41
  _packageName: string,
42
42
  _materializationId: string,
43
- _dropTables?: boolean,
44
43
  _versionId?: string,
45
44
  ) => Promise.resolve({ data: undefined }),
46
45
  );
@@ -138,6 +137,12 @@ async function deleteTheRun(resourceUri: string) {
138
137
  await waitFor(() => expect(deleteMaterialization).toHaveBeenCalled());
139
138
  }
140
139
 
140
+ it("deletes a run with no table option: the dialog offers none", async () => {
141
+ await deleteTheRun("publisher://environments/env/packages/pkg");
142
+
143
+ expect(screen.queryByRole("checkbox")).toBeNull();
144
+ });
145
+
141
146
  it("lists and deletes a pinned version's run by that version", async () => {
142
147
  await deleteTheRun("publisher://environments/env/packages/pkg?versionId=v2");
143
148
 
@@ -146,7 +151,6 @@ it("lists and deletes a pinned version's run by that version", async () => {
146
151
  "env",
147
152
  "pkg",
148
153
  "run-1",
149
- false,
150
154
  "v2",
151
155
  ]);
152
156
  });
@@ -158,7 +162,6 @@ it("deletes with no version when none is pinned, as before", async () => {
158
162
  "env",
159
163
  "pkg",
160
164
  "run-1",
161
- false,
162
165
  undefined,
163
166
  ]);
164
167
  });
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import { Tooltip, Typography } from "@mui/material";
5
- import { MaterializationMetadata, triggerLabel } from "./utils";
5
+ import { isScheduledRun, MaterializationMetadata, triggerLabel } from "./utils";
6
6
 
7
7
  /**
8
8
  * How a run was initiated — Scheduled (the standalone scheduler fired the
@@ -19,7 +19,7 @@ export default function TriggerLabel({
19
19
  }: {
20
20
  meta: MaterializationMetadata;
21
21
  }) {
22
- const scheduled = meta.trigger === "SCHEDULER";
22
+ const scheduled = isScheduledRun(meta);
23
23
  return (
24
24
  <Tooltip
25
25
  title={
@@ -146,9 +146,14 @@ describe("parseMetadata and triggerLabel", () => {
146
146
  });
147
147
 
148
148
  it("calls a run manual unless the scheduler says otherwise", () => {
149
+ expect(triggerLabel({ trigger: "scheduler" })).toBe("Scheduled");
150
+ expect(triggerLabel({ trigger: "on_demand" })).toBe("Manual");
151
+ expect(triggerLabel({})).toBe("Manual");
152
+ });
153
+
154
+ it("reads an older server's upper-case trigger the same", () => {
149
155
  expect(triggerLabel({ trigger: "SCHEDULER" })).toBe("Scheduled");
150
156
  expect(triggerLabel({ trigger: "ON_DEMAND" })).toBe("Manual");
151
- expect(triggerLabel({})).toBe("Manual");
152
157
  });
153
158
  });
154
159
 
@@ -100,12 +100,13 @@ export interface MaterializationMetadata {
100
100
  sourceNames?: string[];
101
101
  mode?: "auto" | "orchestrated";
102
102
  /**
103
- * What initiated the run. `SCHEDULER` = the standalone scheduler fired the
104
- * package's `materialization.schedule` cron; `ON_DEMAND` (default) = an
103
+ * What initiated the run. `scheduler` = the standalone scheduler fired the
104
+ * package's `materialization.schedule` cron; `on_demand` (default) = an
105
105
  * explicit API/UI create. Recorded on the run so a scheduled rebuild is
106
- * distinguishable from a manual one.
106
+ * distinguishable from a manual one. Servers before 0.15 wrote
107
+ * `SCHEDULER` and `ON_DEMAND`; read with {@link isScheduledRun}.
107
108
  */
108
- trigger?: "ON_DEMAND" | "SCHEDULER";
109
+ trigger?: "on_demand" | "scheduler" | "ON_DEMAND" | "SCHEDULER";
109
110
  sourcesBuilt?: number;
110
111
  sourcesReused?: number;
111
112
  /**
@@ -180,11 +181,16 @@ export function parseMetadata(
180
181
  return (materialization.metadata ?? {}) as MaterializationMetadata;
181
182
  }
182
183
 
184
+ /** Whether the scheduler fired the run, in either spelling a server wrote. */
185
+ export function isScheduledRun(meta: MaterializationMetadata): boolean {
186
+ return meta.trigger === "scheduler" || meta.trigger === "SCHEDULER";
187
+ }
188
+
183
189
  /** Human label for how a run was initiated. */
184
190
  export function triggerLabel(
185
191
  meta: MaterializationMetadata,
186
192
  ): "Scheduled" | "Manual" {
187
- return meta.trigger === "SCHEDULER" ? "Scheduled" : "Manual";
193
+ return isScheduledRun(meta) ? "Scheduled" : "Manual";
188
194
  }
189
195
 
190
196
  /** Human-readable elapsed time between two ISO timestamps (to now if open). */
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { describe, expect, it } from "bun:test";
5
5
  import { fireEvent, render, screen } from "@testing-library/react";
6
- import { PackageProblems } from "./PackageProblems";
6
+ import { PackageProblems, withoutRetainedAliases } from "./PackageProblems";
7
7
 
8
8
  const KIND_REMOVED = {
9
9
  model: "notebooks/overview.malloy",
@@ -39,3 +39,27 @@ describe("PackageProblems", () => {
39
39
  expect(screen.getByText(/is deprecated/)).toBeDefined();
40
40
  });
41
41
  });
42
+
43
+ describe("withoutRetainedAliases", () => {
44
+ const notBuilt = {
45
+ model: "m.malloy",
46
+ subject: "orders",
47
+ code: "rollup-not-built",
48
+ severity: "warn" as const,
49
+ message: "not built",
50
+ };
51
+
52
+ it("shows a renamed code's one-release repeat once", () => {
53
+ expect(
54
+ withoutRetainedAliases([
55
+ notBuilt,
56
+ { ...notBuilt, code: "preaggregate-not-built" },
57
+ ]),
58
+ ).toEqual([notBuilt]);
59
+ });
60
+
61
+ it("keeps an older server's former code when it is the only copy", () => {
62
+ const old = { ...notBuilt, code: "preaggregate-not-built" };
63
+ expect(withoutRetainedAliases([old])).toEqual([old]);
64
+ });
65
+ });
@@ -13,6 +13,35 @@ import { useState } from "react";
13
13
  import type { PackageWarningsInner } from "../../client";
14
14
  import { MONO_FONT_FAMILY } from "../styles";
15
15
 
16
+ /**
17
+ * A renamed warning code's former name, which a server repeats beside the new
18
+ * one, same message, for one release: by former code, the code it repeats.
19
+ * `persist-source-refused` is 0.14.0's; the others are 0.15.0's.
20
+ */
21
+ const RETAINED_ALIAS_OF: Readonly<Record<string, string>> = {
22
+ "persist-source-refused": "persist-not-built",
23
+ "preaggregate-not-built": "rollup-not-built",
24
+ "preaggregate-join-one-key-repeated": "rollup-join-one-key-repeated",
25
+ "stored-native-schema-missing": "database-native-type-missing",
26
+ };
27
+
28
+ /**
29
+ * `warnings` with each retained-alias repeat dropped when the warning it
30
+ * repeats is beside it, so each problem shows once. An older server's
31
+ * former code, with no new code beside it, is the only copy and still shows.
32
+ */
33
+ export function withoutRetainedAliases(
34
+ warnings: readonly PackageWarningsInner[],
35
+ ): PackageWarningsInner[] {
36
+ const key = (code: string | undefined, w: PackageWarningsInner) =>
37
+ `${code}\u0000${w.subject ?? ""}\u0000${w.message ?? ""}`;
38
+ const present = new Set(warnings.map((w) => key(w.code, w)));
39
+ return warnings.filter((w) => {
40
+ const now = w.code !== undefined ? RETAINED_ALIAS_OF[w.code] : undefined;
41
+ return now === undefined || !present.has(key(now, w));
42
+ });
43
+ }
44
+
16
45
  /**
17
46
  * What the server found wrong with a package when it loaded it, on the
18
47
  * package page.
@@ -29,18 +58,7 @@ export function PackageProblems({
29
58
  warnings: PackageWarningsInner[] | undefined;
30
59
  }) {
31
60
  const [showNotes, setShowNotes] = useState(false);
32
- // `persist-source-refused` is a one-release alias that repeats a
33
- // `persist-not-built` warning, same message, for API clients; show each
34
- // problem once. An older server's `persist-source-refused`, with no
35
- // `persist-not-built` beside it, is the only copy and still shows.
36
- const notBuilt = new Set(
37
- (warnings ?? [])
38
- .filter((w) => w.code === "persist-not-built")
39
- .map((w) => w.message),
40
- );
41
- const shown = (warnings ?? []).filter(
42
- (w) => w.code !== "persist-source-refused" || !notBuilt.has(w.message),
43
- );
61
+ const shown = withoutRetainedAliases(warnings ?? []);
44
62
  const errors = shown.filter((w) => w.severity === "error");
45
63
  const notes = shown.filter((w) => w.severity !== "error");
46
64
  if (errors.length === 0 && notes.length === 0) return null;