@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.
Files changed (129) hide show
  1. package/README.md +14 -9
  2. package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorageProvider-CyOJ0hqf.es.js} +7114 -6939
  3. package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
  4. package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-BnPzJ9Jf.es.js} +64 -57
  5. package/dist/{RenderedResult-CPi6uQWq.cjs.js → RenderedResult-Dp22kZsQ.cjs.js} +2 -2
  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 +41 -41
  9. package/dist/builder/index.es.js +2752 -2831
  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 +10 -5
  17. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
  18. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +8 -2
  19. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +8 -10
  20. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  21. package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
  22. package/dist/components/ItemRow.d.ts +38 -0
  23. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  24. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  25. package/dist/components/Materializations/Materializations.d.ts +7 -3
  26. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  27. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  28. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  29. package/dist/components/Materializations/index.d.ts +0 -1
  30. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  31. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  32. package/dist/components/Package/index.d.ts +0 -1
  33. package/dist/components/PackageSection.d.ts +23 -0
  34. package/dist/components/buttons.d.ts +53 -0
  35. package/dist/components/index.d.ts +5 -0
  36. package/dist/components/styles.d.ts +49 -40
  37. package/dist/hooks/useCrudMutation.d.ts +42 -0
  38. package/dist/index.cjs.js +22 -26
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.es.js +17425 -20672
  41. package/dist/telemetry/consoleEvents.d.ts +60 -0
  42. package/dist/utils/sha256.d.ts +2 -0
  43. package/package.json +1 -1
  44. package/src/components/AppDialog.tsx +115 -0
  45. package/src/components/BackLink.tsx +83 -0
  46. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  47. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  48. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  49. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  50. package/src/components/Dashboard/telemetry.ts +10 -3
  51. package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
  52. package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
  53. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
  54. package/src/components/DashboardBuilder/DashboardBuilder.tsx +184 -171
  55. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  56. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
  57. package/src/components/DashboardBuilder/DashboardEditor.tsx +135 -61
  58. package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
  59. package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
  60. package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
  61. package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
  62. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  63. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  64. package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
  65. package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
  66. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
  67. package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
  68. package/src/components/Environment/About.tsx +14 -28
  69. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  70. package/src/components/Environment/Connections.tsx +125 -205
  71. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  72. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  73. package/src/components/Environment/Environment.tsx +34 -36
  74. package/src/components/Environment/Packages.tsx +63 -128
  75. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  76. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  77. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  78. package/src/components/Home/Home.tsx +101 -214
  79. package/src/components/ItemRow.tsx +165 -0
  80. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  81. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  82. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  83. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  84. package/src/components/Materializations/Materializations.tsx +137 -140
  85. package/src/components/Materializations/ScopeButton.tsx +85 -0
  86. package/src/components/Materializations/SectionLabel.tsx +7 -4
  87. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  88. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  89. package/src/components/Materializations/cron.spec.ts +113 -0
  90. package/src/components/Materializations/index.ts +0 -1
  91. package/src/components/Materializations/utils.spec.ts +182 -0
  92. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  93. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  94. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  95. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  96. package/src/components/Package/Package.tsx +179 -238
  97. package/src/components/Package/index.ts +0 -1
  98. package/src/components/PackageSection.tsx +85 -0
  99. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  100. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  101. package/src/components/ResultsDialog.tsx +8 -32
  102. package/src/components/buttons.tsx +114 -0
  103. package/src/components/designSystem.spec.tsx +316 -0
  104. package/src/components/given/paramCodec.spec.ts +1 -1
  105. package/src/components/index.ts +10 -0
  106. package/src/components/styles.ts +49 -85
  107. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  108. package/src/hooks/useCrudMutation.tsx +85 -0
  109. package/src/index.ts +9 -0
  110. package/src/telemetry/consoleEvents.spec.ts +130 -0
  111. package/src/telemetry/consoleEvents.ts +124 -0
  112. package/src/theme/defaults.ts +34 -23
  113. package/src/theme/resolveTheme.spec.ts +9 -4
  114. package/src/theme/resolveTheme.ts +12 -8
  115. package/src/utils/sha256.ts +13 -0
  116. package/test/README.md +1 -1
  117. package/test/serverProvider.tsx +5 -2
  118. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
  119. package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
  120. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  121. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  122. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  123. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  124. package/dist/components/Package/Models.d.ts +0 -6
  125. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  126. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  127. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  128. package/src/components/Materializations/TriggerChip.tsx +0 -44
  129. package/src/components/Package/Models.tsx +0 -71
@@ -1,26 +1,15 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import { Add } from "@mui/icons-material";
5
- import {
6
- Box,
7
- Button,
8
- Dialog,
9
- DialogActions,
10
- DialogContent,
11
- DialogTitle,
12
- Snackbar,
13
- Stack,
14
- TextField,
15
- Typography,
16
- } from "@mui/material";
17
- import { useQueryClient } from "@tanstack/react-query";
4
+ import { Box, Button, Stack, TextField } from "@mui/material";
18
5
  import React, { useState } from "react";
19
6
  import { Package } from "../../client";
20
- import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
7
+ import { useCrudMutation } from "../../hooks/useCrudMutation";
21
8
  import { parseResourceUri } from "../../utils/formatting";
22
9
  import { DOC_LINKS } from "../../constants/docLinks";
23
10
  import { useServer } from "../ServerProvider";
11
+ import { AppDialog } from "../AppDialog";
12
+ import { AddButton } from "../buttons";
24
13
 
25
14
  interface AddPackageDialogProps {
26
15
  resourceUri: string;
@@ -31,33 +20,22 @@ export default function AddPackageDialog({
31
20
  }: AddPackageDialogProps) {
32
21
  const [open, setOpen] = useState(false);
33
22
  const { apiClients } = useServer();
34
- const queryClient = useQueryClient();
35
- const [notificationMessage, setNotificationMessage] = useState("");
36
23
 
37
24
  const { environmentName } = parseResourceUri(resourceUri);
38
25
 
39
- const addPackage = useMutationWithApiError({
40
- async mutationFn(variables: Package) {
26
+ const addPackage = useCrudMutation({
27
+ mutationFn(variables: Package) {
41
28
  return apiClients.packages.createPackage(environmentName, {
42
29
  name: variables.name,
43
30
  description: variables.description,
44
31
  location: variables.location,
45
32
  });
46
33
  },
47
- onSuccess() {
48
- setOpen(false);
49
- setNotificationMessage("Package created successfully");
50
- queryClient.invalidateQueries({
51
- queryKey: ["packages", environmentName],
52
- });
53
- },
54
- onError(error) {
55
- setNotificationMessage(
56
- error instanceof Error
57
- ? error.message
58
- : "An unknown error occurred",
59
- );
60
- },
34
+ success: "Package created",
35
+ invalidates: [["packages", environmentName]],
36
+ closeDialog: () => setOpen(false),
37
+ resource: "package",
38
+ action: "create",
61
39
  });
62
40
 
63
41
  const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
@@ -71,132 +49,85 @@ export default function AddPackageDialog({
71
49
 
72
50
  return (
73
51
  <>
74
- <Button
75
- onClick={() => setOpen(true)}
76
- variant="contained"
77
- color="primary"
78
- startIcon={<Add />}
79
- >
80
- Add Package
81
- </Button>
52
+ <AddButton label="Package" onClick={() => setOpen(true)} />
82
53
 
83
- <Dialog
54
+ <AppDialog
84
55
  open={open}
85
56
  onClose={() => setOpen(false)}
86
- maxWidth="sm"
87
- fullWidth
88
- PaperProps={{ sx: { borderRadius: 2 } }}
89
- >
90
- <DialogTitle
91
- sx={{
92
- fontSize: "1.25rem",
93
- fontWeight: 600,
94
- letterSpacing: "-0.025em",
95
- pt: 3,
96
- pb: 1,
97
- px: 3,
98
- }}
99
- >
100
- Create New Package
101
- </DialogTitle>
102
- <DialogContent sx={{ px: 3, pb: 0 }}>
103
- <Box sx={{ mb: 3 }}>
104
- <Typography
105
- variant="body2"
106
- color="text.secondary"
107
- sx={{ mb: 1.5 }}
57
+ title="New package"
58
+ description={
59
+ <>
60
+ A package is a directory of Malloy models and their data. Give
61
+ its location as a GitHub, S3 or GCS URL, or an absolute path
62
+ the server can read; see the{" "}
63
+ <Box
64
+ component="a"
65
+ href={DOC_LINKS.publishing}
66
+ target="_blank"
67
+ rel="noopener noreferrer"
68
+ sx={{ color: "text.primary" }}
69
+ >
70
+ package format
71
+ </Box>
72
+ .
73
+ </>
74
+ }
75
+ actions={
76
+ <>
77
+ <Button
78
+ disabled={addPackage.isPending}
79
+ onClick={() => setOpen(false)}
108
80
  >
109
- Create a new Malloy package to start exploring your data.
110
- </Typography>
111
- <Typography
112
- variant="body2"
113
- color="text.secondary"
114
- sx={{ mb: 1.5 }}
81
+ Cancel
82
+ </Button>
83
+ <Button
84
+ type="submit"
85
+ form="package-form"
86
+ variant="contained"
87
+ loading={addPackage.isPending}
115
88
  >
116
- The location can be a GitHub/S3/GCP URL containing a
117
- package (zipped or unzipped), or an absolute path to a
118
- directory the publisher server has access to.
119
- </Typography>
120
- <Typography variant="body2" color="text.secondary">
121
- Make sure to conform to the{" "}
122
- <Box
123
- component="a"
124
- href={DOC_LINKS.publishing}
125
- target="_blank"
126
- rel="noopener noreferrer"
127
- sx={{
128
- color: "text.primary",
129
- textDecoration: "underline",
130
- }}
131
- >
132
- Malloy Package Format
133
- </Box>
134
- .
135
- </Typography>
136
- </Box>
137
- <form onSubmit={handleSubmit} id="package-form">
138
- <Stack spacing={2.5}>
139
- <TextField
140
- autoFocus
141
- required
142
- id="name"
143
- name="name"
144
- label="Package Name"
145
- type="text"
146
- fullWidth
147
- variant="outlined"
148
- size="small"
149
- InputLabelProps={{ shrink: true }}
150
- />
151
- <TextField
152
- id="description"
153
- name="description"
154
- label="Description"
155
- multiline
156
- rows={3}
157
- fullWidth
158
- variant="outlined"
159
- size="small"
160
- InputLabelProps={{ shrink: true }}
161
- />
162
- <TextField
163
- id="location"
164
- name="location"
165
- label="Location"
166
- type="text"
167
- placeholder="e.g. s3://my-bucket/my-package.zip"
168
- fullWidth
169
- variant="outlined"
170
- size="small"
171
- InputLabelProps={{ shrink: true }}
172
- />
173
- </Stack>
174
- </form>
175
- </DialogContent>
176
- <DialogActions sx={{ px: 3, pt: 2, pb: 3, gap: 1 }}>
177
- <Button
178
- variant="outlined"
179
- disabled={addPackage.isPending}
180
- onClick={() => setOpen(false)}
181
- >
182
- Cancel
183
- </Button>
184
- <Button
185
- type="submit"
186
- form="package-form"
187
- variant="contained"
188
- loading={addPackage.isPending}
189
- >
190
- Save Changes
191
- </Button>
192
- </DialogActions>
193
- </Dialog>
194
- <Snackbar
195
- open={notificationMessage !== ""}
196
- autoHideDuration={6000}
197
- onClose={() => setNotificationMessage("")}
198
- message={notificationMessage}
199
- />
89
+ Create package
90
+ </Button>
91
+ </>
92
+ }
93
+ >
94
+ <form onSubmit={handleSubmit} id="package-form">
95
+ <Stack sx={{ gap: 2 }}>
96
+ <TextField
97
+ autoFocus
98
+ required
99
+ id="name"
100
+ name="name"
101
+ label="Name"
102
+ type="text"
103
+ fullWidth
104
+ size="small"
105
+ InputLabelProps={{ shrink: true }}
106
+ />
107
+ <TextField
108
+ id="description"
109
+ name="description"
110
+ label="Description"
111
+ multiline
112
+ rows={3}
113
+ fullWidth
114
+ size="small"
115
+ InputLabelProps={{ shrink: true }}
116
+ />
117
+ <TextField
118
+ id="location"
119
+ name="location"
120
+ label="Location"
121
+ type="text"
122
+ placeholder="e.g. s3://my-bucket/my-package.zip"
123
+ fullWidth
124
+ size="small"
125
+ InputLabelProps={{ shrink: true }}
126
+ />
127
+ </Stack>
128
+ </form>
129
+ </AppDialog>
130
+ {addPackage.notice}
200
131
  </>
201
132
  );
202
133
  }