@malloy-publisher/sdk 0.3.1 → 0.4.1

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 (136) hide show
  1. package/README.md +33 -9
  2. package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorage-BiFqO15i.es.js} +7126 -6943
  3. package/dist/DocumentStorage-CMyLifsz.cjs.js +134 -0
  4. package/dist/RenderedResult-CZzE8wv-.cjs.js +115 -0
  5. package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-CvrmYyr5.es.js} +64 -57
  6. package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
  7. package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +52 -52
  9. package/dist/builder/index.es.js +3961 -3960
  10. package/dist/client/api.d.ts +100 -42
  11. package/dist/client/index.cjs.js +1 -1
  12. package/dist/client/index.es.js +1 -1
  13. package/dist/components/AppDialog.d.ts +30 -0
  14. package/dist/components/BackLink.d.ts +32 -0
  15. package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
  16. package/dist/components/Dashboard/telemetry.d.ts +24 -7
  17. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
  18. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +20 -2
  19. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +21 -11
  20. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  21. package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
  22. package/dist/components/DocumentStorage/DocumentStorage.d.ts +69 -5
  23. package/dist/components/DocumentStorage/index.d.ts +1 -0
  24. package/dist/components/ItemRow.d.ts +38 -0
  25. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  26. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  27. package/dist/components/Materializations/Materializations.d.ts +7 -3
  28. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  29. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  30. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  31. package/dist/components/Materializations/index.d.ts +0 -1
  32. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  33. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  34. package/dist/components/Package/index.d.ts +0 -1
  35. package/dist/components/PackageSection.d.ts +23 -0
  36. package/dist/components/buttons.d.ts +53 -0
  37. package/dist/components/index.d.ts +5 -0
  38. package/dist/components/styles.d.ts +49 -40
  39. package/dist/hooks/useCrudMutation.d.ts +42 -0
  40. package/dist/index.cjs.js +22 -26
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.es.js +17431 -20676
  43. package/dist/telemetry/consoleEvents.d.ts +60 -0
  44. package/dist/utils/sha256.d.ts +2 -0
  45. package/package.json +1 -1
  46. package/src/components/AppDialog.tsx +115 -0
  47. package/src/components/BackLink.tsx +83 -0
  48. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  49. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  50. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  51. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  52. package/src/components/Dashboard/telemetry.ts +24 -5
  53. package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
  54. package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
  55. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
  56. package/src/components/DashboardBuilder/DashboardBuilder.tsx +202 -171
  57. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +706 -0
  58. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  59. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
  60. package/src/components/DashboardBuilder/DashboardEditor.tsx +442 -94
  61. package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
  62. package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
  63. package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
  64. package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
  65. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  66. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  67. package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
  68. package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
  69. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
  70. package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
  71. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +7 -6
  72. package/src/components/DocumentStorage/DocumentStorage.ts +78 -5
  73. package/src/components/DocumentStorage/index.ts +1 -0
  74. package/src/components/Environment/About.tsx +14 -28
  75. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  76. package/src/components/Environment/Connections.tsx +125 -205
  77. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  78. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  79. package/src/components/Environment/Environment.tsx +34 -36
  80. package/src/components/Environment/Packages.tsx +63 -128
  81. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  82. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  83. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  84. package/src/components/Home/Home.tsx +101 -214
  85. package/src/components/ItemRow.tsx +165 -0
  86. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  87. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  88. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  89. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  90. package/src/components/Materializations/Materializations.tsx +137 -140
  91. package/src/components/Materializations/ScopeButton.tsx +85 -0
  92. package/src/components/Materializations/SectionLabel.tsx +7 -4
  93. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  94. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  95. package/src/components/Materializations/cron.spec.ts +113 -0
  96. package/src/components/Materializations/index.ts +0 -1
  97. package/src/components/Materializations/utils.spec.ts +182 -0
  98. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  99. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  100. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  101. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  102. package/src/components/Package/Package.tsx +184 -238
  103. package/src/components/Package/index.ts +0 -1
  104. package/src/components/PackageSection.tsx +85 -0
  105. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  106. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  107. package/src/components/ResultsDialog.tsx +8 -32
  108. package/src/components/buttons.tsx +114 -0
  109. package/src/components/designSystem.spec.tsx +316 -0
  110. package/src/components/given/paramCodec.spec.ts +1 -1
  111. package/src/components/index.ts +10 -0
  112. package/src/components/styles.ts +49 -85
  113. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  114. package/src/hooks/useCrudMutation.tsx +85 -0
  115. package/src/index.ts +9 -0
  116. package/src/telemetry/consoleEvents.spec.ts +130 -0
  117. package/src/telemetry/consoleEvents.ts +124 -0
  118. package/src/theme/defaults.ts +34 -23
  119. package/src/theme/resolveTheme.spec.ts +9 -4
  120. package/src/theme/resolveTheme.ts +12 -8
  121. package/src/utils/sha256.ts +13 -0
  122. package/test/README.md +1 -1
  123. package/test/serverProvider.tsx +5 -2
  124. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
  125. package/dist/RenderedResult-CPi6uQWq.cjs.js +0 -115
  126. package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
  127. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  128. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  129. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  130. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  131. package/dist/components/Package/Models.d.ts +0 -6
  132. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  133. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  134. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  135. package/src/components/Materializations/TriggerChip.tsx +0 -44
  136. package/src/components/Package/Models.tsx +0 -71
@@ -3,20 +3,13 @@
3
3
 
4
4
  import React, { useState } from "react";
5
5
  import Button from "@mui/material/Button";
6
- import Dialog from "@mui/material/Dialog";
7
- import DialogTitle from "@mui/material/DialogTitle";
8
- import DialogContent from "@mui/material/DialogContent";
9
- import DialogActions from "@mui/material/DialogActions";
10
- import IconButton from "@mui/material/IconButton";
11
- import CloseIcon from "@mui/icons-material/Close";
12
6
  import Typography from "@mui/material/Typography";
13
- import { ListItemIcon, ListItemText, MenuItem, Snackbar } from "@mui/material";
7
+ import { ListItemIcon, ListItemText, MenuItem } from "@mui/material";
14
8
  import { Delete } from "@mui/icons-material";
15
9
  import { Environment } from "../../client";
16
- import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
10
+ import { useCrudMutation } from "../../hooks/useCrudMutation";
17
11
  import { useServer } from "../ServerProvider";
18
- import { useQueryClient } from "@tanstack/react-query";
19
- import { MALLOY_BRAND } from "../styles";
12
+ import { AppDialog } from "../AppDialog";
20
13
 
21
14
  export default function DeleteEnvironmentDialog({
22
15
  environment,
@@ -27,8 +20,6 @@ export default function DeleteEnvironmentDialog({
27
20
  }) {
28
21
  const [open, setOpen] = useState(false);
29
22
  const { apiClients } = useServer();
30
- const queryClient = useQueryClient();
31
- const [notificationMessage, setNotificationMessage] = useState("");
32
23
  const handleClickOpen = () => {
33
24
  setOpen(true);
34
25
  };
@@ -37,21 +28,14 @@ export default function DeleteEnvironmentDialog({
37
28
  onCloseDialog();
38
29
  };
39
30
 
40
- const deleteEnvironment = useMutationWithApiError({
31
+ const deleteEnvironment = useCrudMutation({
41
32
  mutationFn: () =>
42
33
  apiClients.environments.deleteEnvironment(environment.name),
43
- onSuccess() {
44
- handleClose();
45
- queryClient.invalidateQueries({ queryKey: ["environments"] });
46
- setNotificationMessage("Environment deleted successfully");
47
- },
48
- onError(error) {
49
- setNotificationMessage(
50
- error instanceof Error
51
- ? error.message
52
- : "An unknown error occurred",
53
- );
54
- },
34
+ success: "Environment deleted",
35
+ invalidates: [["environments"]],
36
+ closeDialog: handleClose,
37
+ resource: "environment",
38
+ action: "delete",
55
39
  });
56
40
 
57
41
  return (
@@ -62,60 +46,31 @@ export default function DeleteEnvironmentDialog({
62
46
  </ListItemIcon>
63
47
  <ListItemText>Delete</ListItemText>
64
48
  </MenuItem>
65
- <Dialog
66
- onClose={handleClose}
67
- aria-labelledby="customized-dialog-title"
49
+ <AppDialog
68
50
  open={open}
51
+ onClose={handleClose}
52
+ title="Delete environment"
53
+ actions={
54
+ <>
55
+ <Button onClick={handleClose}>Cancel</Button>
56
+ <Button
57
+ variant="contained"
58
+ color="error"
59
+ autoFocus
60
+ onClick={() => deleteEnvironment.mutate()}
61
+ loading={deleteEnvironment.isPending}
62
+ >
63
+ Delete environment
64
+ </Button>
65
+ </>
66
+ }
69
67
  >
70
- <DialogTitle sx={{ m: 0, p: 2 }} id="customized-dialog-title">
71
- Delete Environment
72
- </DialogTitle>
73
- <IconButton
74
- aria-label="close"
75
- onClick={handleClose}
76
- sx={(theme) => ({
77
- position: "absolute",
78
- right: 8,
79
- top: 8,
80
- color: theme.palette.grey[500],
81
- })}
82
- >
83
- <CloseIcon />
84
- </IconButton>
85
- <DialogContent dividers>
86
- <Typography gutterBottom>
87
- Are you sure you want to delete &quot;{environment.name}
88
- &quot;? This action cannot be undone.
89
- </Typography>
90
- </DialogContent>
91
- <DialogActions>
92
- <Button
93
- variant="outlined"
94
- onClick={handleClose}
95
- style={{
96
- borderColor: MALLOY_BRAND.teal,
97
- color: MALLOY_BRAND.teal,
98
- }}
99
- >
100
- Cancel
101
- </Button>
102
- <Button
103
- loading={deleteEnvironment.isPending}
104
- variant="contained"
105
- autoFocus
106
- onClick={() => deleteEnvironment.mutate()}
107
- color="error"
108
- >
109
- Delete
110
- </Button>
111
- </DialogActions>
112
- <Snackbar
113
- open={notificationMessage !== ""}
114
- autoHideDuration={6000}
115
- onClose={() => setNotificationMessage("")}
116
- message={notificationMessage}
117
- />
118
- </Dialog>
68
+ <Typography variant="body2">
69
+ Delete <strong>{environment.name}</strong>? Its packages stop
70
+ being served and this cannot be undone.
71
+ </Typography>
72
+ </AppDialog>
73
+ {deleteEnvironment.notice}
119
74
  </React.Fragment>
120
75
  );
121
76
  }
@@ -4,22 +4,18 @@
4
4
  import React from "react";
5
5
  import Button from "@mui/material/Button";
6
6
  import TextField from "@mui/material/TextField";
7
- import Dialog from "@mui/material/Dialog";
8
- import DialogActions from "@mui/material/DialogActions";
9
- import DialogContent from "@mui/material/DialogContent";
10
- import DialogContentText from "@mui/material/DialogContentText";
11
- import DialogTitle from "@mui/material/DialogTitle";
12
7
  import { useState } from "react";
13
8
  import { Edit } from "@mui/icons-material";
14
- import { MenuItem, ListItemIcon, ListItemText, Snackbar } from "@mui/material";
9
+ import { MenuItem, ListItemIcon, ListItemText } from "@mui/material";
15
10
  import { Environment } from "../../client";
16
11
  import {
17
12
  generateEnvironmentReadme,
18
13
  getEnvironmentDescription,
19
14
  } from "../../utils/parsing";
20
- import { useQueryClient } from "@tanstack/react-query";
21
- import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
15
+ import { useCrudMutation } from "../../hooks/useCrudMutation";
22
16
  import { useServer } from "../ServerProvider";
17
+ import Stack from "@mui/material/Stack";
18
+ import { AppDialog } from "../AppDialog";
23
19
 
24
20
  interface EditEnvironmentModalProps {
25
21
  environment: Environment;
@@ -32,8 +28,6 @@ export default function EditEnvironmentDialog({
32
28
  }: EditEnvironmentModalProps) {
33
29
  const [open, setOpen] = useState(false);
34
30
  const { apiClients } = useServer();
35
- const queryClient = useQueryClient();
36
- const [notificationMessage, setNotificationMessage] = useState("");
37
31
 
38
32
  const handleClickOpen = () => {
39
33
  setOpen(true);
@@ -44,8 +38,8 @@ export default function EditEnvironmentDialog({
44
38
  onCloseDialog();
45
39
  };
46
40
 
47
- const editEnvironment = useMutationWithApiError({
48
- async mutationFn(variables: { description: string }) {
41
+ const editEnvironment = useCrudMutation({
42
+ mutationFn(variables: { description: string }) {
49
43
  return apiClients.environments.updateEnvironment(environment.name, {
50
44
  name: environment.name,
51
45
  readme: generateEnvironmentReadme(
@@ -57,18 +51,11 @@ export default function EditEnvironmentDialog({
57
51
  ),
58
52
  });
59
53
  },
60
- onSuccess() {
61
- handleClose();
62
- queryClient.invalidateQueries({ queryKey: ["environments"] });
63
- setNotificationMessage("Environment updated successfully");
64
- },
65
- onError(error) {
66
- setNotificationMessage(
67
- error instanceof Error
68
- ? error.message
69
- : "An unknown error occurred",
70
- );
71
- },
54
+ success: "Environment updated",
55
+ invalidates: [["environments"]],
56
+ closeDialog: handleClose,
57
+ resource: "environment",
58
+ action: "update",
72
59
  });
73
60
 
74
61
  const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
@@ -87,62 +74,61 @@ export default function EditEnvironmentDialog({
87
74
  <ListItemText>Edit</ListItemText>
88
75
  </MenuItem>
89
76
 
90
- <Dialog open={open} onClose={handleClose}>
91
- <DialogTitle>Edit Environment</DialogTitle>
92
- <DialogContent>
93
- <DialogContentText>
94
- Edit this environment&apos;s description.
95
- </DialogContentText>
96
- <form onSubmit={handleSubmit} id="environment-form">
77
+ <AppDialog
78
+ open={open}
79
+ onClose={handleClose}
80
+ title="Edit environment"
81
+ description="What this environment is, for the people who open it."
82
+ actions={
83
+ <>
84
+ <Button
85
+ disabled={editEnvironment.isPending}
86
+ onClick={handleClose}
87
+ >
88
+ Cancel
89
+ </Button>
90
+ <Button
91
+ type="submit"
92
+ form="environment-form"
93
+ variant="contained"
94
+ loading={editEnvironment.isPending}
95
+ >
96
+ Save changes
97
+ </Button>
98
+ </>
99
+ }
100
+ >
101
+ <form onSubmit={handleSubmit} id="environment-form">
102
+ <Stack sx={{ gap: 2 }}>
97
103
  <TextField
98
104
  autoFocus
99
105
  required
100
- margin="dense"
101
106
  id="name"
102
107
  name="name"
103
- label="Environment Name"
108
+ label="Name"
104
109
  disabled
105
110
  type="text"
106
111
  fullWidth
107
- variant="standard"
112
+ size="small"
108
113
  defaultValue={environment.name}
114
+ InputLabelProps={{ shrink: true }}
109
115
  />
110
116
  <TextField
111
- margin="dense"
112
117
  id="description"
113
118
  name="description"
114
- label="Environment Description"
119
+ label="Description"
115
120
  type="text"
116
121
  fullWidth
117
- variant="standard"
122
+ size="small"
118
123
  defaultValue={getEnvironmentDescription(
119
124
  environment.readme,
120
125
  )}
126
+ InputLabelProps={{ shrink: true }}
121
127
  />
122
- </form>
123
- </DialogContent>
124
- <DialogActions>
125
- <Button
126
- disabled={editEnvironment.isPending}
127
- onClick={handleClose}
128
- >
129
- Cancel
130
- </Button>
131
- <Button
132
- type="submit"
133
- form="environment-form"
134
- loading={editEnvironment.isPending}
135
- >
136
- Save Changes
137
- </Button>
138
- </DialogActions>
139
- </Dialog>
140
- <Snackbar
141
- open={notificationMessage !== ""}
142
- autoHideDuration={6000}
143
- onClose={() => setNotificationMessage("")}
144
- message={notificationMessage}
145
- />
128
+ </Stack>
129
+ </form>
130
+ </AppDialog>
131
+ {editEnvironment.notice}
146
132
  </React.Fragment>
147
133
  );
148
134
  }