@malloy-publisher/sdk 0.0.382-dev → 0.2.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 (277) hide show
  1. package/README.md +115 -95
  2. package/TREE_SHAKING.md +16 -11
  3. package/bunfig.toml +7 -0
  4. package/dist/ServerProvider-CTopDUWW.cjs.js +1 -0
  5. package/dist/ServerProvider-DUFPY6Rv.es.js +4072 -0
  6. package/dist/client/api.d.ts +3718 -1507
  7. package/dist/client/configuration.d.ts +1 -1
  8. package/dist/client/index.cjs.js +1 -1
  9. package/dist/client/index.d.ts +1 -1
  10. package/dist/client/index.es.js +85 -59
  11. package/dist/components/Connections/EditConnectionDialog.d.ts +2 -1
  12. package/dist/components/Connections/common.d.ts +8 -2
  13. package/dist/components/Dashboard/Dashboard.d.ts +49 -0
  14. package/dist/components/Dashboard/DashboardTile.d.ts +48 -0
  15. package/dist/components/Dashboard/index.d.ts +2 -0
  16. package/dist/components/DataAppViewer/DataAppViewer.d.ts +23 -0
  17. package/dist/components/DataAppViewer/index.d.ts +1 -0
  18. package/dist/components/Environment/Environment.d.ts +6 -0
  19. package/dist/components/Environment/index.d.ts +2 -0
  20. package/dist/components/Home/AddEnvironmentDialog.d.ts +1 -0
  21. package/dist/components/Home/DeleteEnvironmentDialog.d.ts +5 -0
  22. package/dist/components/Home/EditEnvironmentDialog.d.ts +7 -0
  23. package/dist/components/Home/Home.d.ts +2 -2
  24. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +14 -0
  25. package/dist/components/Materializations/CreateMaterializationDialog.d.ts +10 -0
  26. package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +7 -0
  27. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +7 -0
  28. package/dist/components/Materializations/ManifestView.d.ts +13 -0
  29. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +9 -0
  30. package/dist/components/Materializations/MaterializationRunsList.d.ts +15 -0
  31. package/dist/components/Materializations/Materializations.d.ts +7 -0
  32. package/dist/components/Materializations/ScheduleCard.d.ts +20 -0
  33. package/dist/components/Materializations/SectionLabel.d.ts +10 -0
  34. package/dist/components/Materializations/SetScheduleDialog.d.ts +11 -0
  35. package/dist/components/Materializations/TriggerChip.d.ts +10 -0
  36. package/dist/components/Materializations/cron.d.ts +23 -0
  37. package/dist/components/Materializations/index.d.ts +2 -0
  38. package/dist/components/Materializations/utils.d.ts +46 -0
  39. package/dist/components/Notebook/Notebook.d.ts +47 -4
  40. package/dist/components/Notebook/NotebookCell.d.ts +37 -1
  41. package/dist/components/Notebook/runPlan.d.ts +29 -0
  42. package/dist/components/Notebook/types.d.ts +10 -0
  43. package/dist/components/Package/ContentTypeIcon.d.ts +31 -0
  44. package/dist/components/Package/Package.d.ts +1 -4
  45. package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
  46. package/dist/components/RenderedResult/ResultContainer.d.ts +5 -1
  47. package/dist/components/RenderedResult/renderLogs.d.ts +6 -0
  48. package/dist/components/ResultsDialog.d.ts +6 -1
  49. package/dist/components/ServerProvider.d.ts +28 -4
  50. package/dist/components/click_helper.d.ts +10 -1
  51. package/dist/components/drill/index.d.ts +3 -0
  52. package/dist/components/drill/markDrillableCells.d.ts +55 -0
  53. package/dist/components/drill/resolveDrill.d.ts +139 -0
  54. package/dist/components/drill/useDrill.d.ts +63 -0
  55. package/dist/components/given/GivenInput.d.ts +52 -0
  56. package/dist/components/given/GivensPanel.d.ts +47 -0
  57. package/dist/components/given/filterValue.d.ts +97 -0
  58. package/dist/components/given/index.d.ts +2 -0
  59. package/dist/components/given/paramCodec.d.ts +60 -0
  60. package/dist/components/given/utils.d.ts +17 -0
  61. package/dist/components/highlighter.d.ts +6 -1
  62. package/dist/components/index.d.ts +7 -2
  63. package/dist/components/styles.d.ts +47 -0
  64. package/dist/constants/docLinks.d.ts +12 -0
  65. package/dist/{core-YNpOLuB1.cjs.js → core-hLahnv0W.cjs.js} +1 -1
  66. package/dist/{core-CjeTkq8O.es.js → core-lb28vQkR.es.js} +1 -1
  67. package/dist/github-dark-BKL9xNgN.cjs.js +1 -0
  68. package/dist/github-dark-DenFmJkN.es.js +4 -0
  69. package/dist/hooks/givenValue.d.ts +10 -0
  70. package/dist/hooks/index.d.ts +4 -0
  71. package/dist/hooks/useDimensionFiltersFromSpec.d.ts +3 -3
  72. package/dist/hooks/useDimensionFiltersQuery.d.ts +3 -3
  73. package/dist/hooks/useDimensionalFilterRangeData.d.ts +4 -4
  74. package/dist/hooks/useGivensState.d.ts +64 -0
  75. package/dist/hooks/useModelGivens.d.ts +10 -0
  76. package/dist/hooks/useSuggestOptions.d.ts +78 -0
  77. package/dist/index-DvEanVgc.cjs.js +339 -0
  78. package/dist/{index-DRDu9kIV.es.js → index-txw04ZbN.es.js} +40531 -27964
  79. package/dist/index.cjs.js +1 -1
  80. package/dist/index.d.ts +4 -1
  81. package/dist/index.es.js +79 -48
  82. package/dist/malloy-explorer.css +12 -1
  83. package/dist/sdk.css +1 -1
  84. package/dist/theme/ThemeContext.d.ts +45 -0
  85. package/dist/theme/buildMalloyExplicitTheme.d.ts +34 -0
  86. package/dist/theme/buildTableCssVars.d.ts +25 -0
  87. package/dist/theme/buildVegaThemeOverride.d.ts +16 -0
  88. package/dist/theme/defaults.d.ts +7 -0
  89. package/dist/theme/index.d.ts +8 -0
  90. package/dist/theme/keys.d.ts +20 -0
  91. package/dist/theme/readChartAnnotations.d.ts +23 -0
  92. package/dist/theme/resolveTheme.d.ts +22 -0
  93. package/dist/theme/types.d.ts +70 -0
  94. package/dist/utils/dataAppEmbed.d.ts +44 -0
  95. package/dist/utils/formatting.d.ts +1 -1
  96. package/dist/utils/malloyString.d.ts +7 -0
  97. package/dist/utils/parsing.d.ts +2 -2
  98. package/dist/utils/queryClient.d.ts +5 -0
  99. package/package.json +19 -8
  100. package/src/client-entry.ts +3 -0
  101. package/src/components/AnalyzePackageButton.tsx +9 -3
  102. package/src/components/ApiErrorDisplay.tsx +3 -0
  103. package/src/components/Connections/AddConnectionDialog.tsx +30 -2
  104. package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
  105. package/src/components/Connections/EditConnectionDialog.tsx +33 -4
  106. package/src/components/Connections/common.ts +64 -1
  107. package/src/components/DOMElement/DOMElement.tsx +3 -0
  108. package/src/components/DOMElement/index.ts +3 -0
  109. package/src/components/Dashboard/Dashboard.tsx +398 -0
  110. package/src/components/Dashboard/DashboardTile.tsx +153 -0
  111. package/src/components/Dashboard/index.ts +5 -0
  112. package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
  113. package/src/components/DataAppViewer/index.ts +4 -0
  114. package/src/components/{Project → Environment}/About.tsx +11 -4
  115. package/src/components/Environment/AddPackageDialog.tsx +202 -0
  116. package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
  117. package/src/components/Environment/Connections.tsx +391 -0
  118. package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
  119. package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
  120. package/src/components/Environment/Environment.tsx +89 -0
  121. package/src/components/Environment/Packages.tsx +206 -0
  122. package/src/components/Environment/index.ts +5 -0
  123. package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
  124. package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
  125. package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
  126. package/src/components/Home/Home.tsx +386 -408
  127. package/src/components/Home/index.ts +3 -0
  128. package/src/components/Loading.tsx +3 -0
  129. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
  130. package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
  131. package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
  132. package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
  133. package/src/components/Materializations/ManifestView.tsx +87 -0
  134. package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
  135. package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
  136. package/src/components/Materializations/Materializations.tsx +355 -0
  137. package/src/components/Materializations/ScheduleCard.tsx +231 -0
  138. package/src/components/Materializations/SectionLabel.tsx +30 -0
  139. package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
  140. package/src/components/Materializations/TriggerChip.tsx +44 -0
  141. package/src/components/Materializations/cron.ts +124 -0
  142. package/src/components/Materializations/index.ts +5 -0
  143. package/src/components/Materializations/utils.ts +145 -0
  144. package/src/components/Model/Model.tsx +44 -2
  145. package/src/components/Model/ModelCell.tsx +14 -5
  146. package/src/components/Model/ModelExplorer.tsx +3 -0
  147. package/src/components/Model/ModelExplorerDialog.tsx +4 -1
  148. package/src/components/Model/SourcesExplorer.tsx +9 -6
  149. package/src/components/Model/index.ts +3 -0
  150. package/src/components/Model/useModelData.ts +6 -3
  151. package/src/components/Notebook/Notebook.tsx +475 -339
  152. package/src/components/Notebook/NotebookCell.tsx +264 -25
  153. package/src/components/Notebook/index.ts +3 -0
  154. package/src/components/Notebook/runPlan.spec.ts +155 -0
  155. package/src/components/Notebook/runPlan.ts +67 -0
  156. package/src/components/Notebook/types.ts +14 -0
  157. package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
  158. package/src/components/Package/ContentTypeIcon.tsx +177 -0
  159. package/src/components/Package/FileTreeView.tsx +3 -0
  160. package/src/components/Package/Models.tsx +7 -4
  161. package/src/components/Package/Package.tsx +666 -59
  162. package/src/components/Package/index.ts +3 -0
  163. package/src/components/QueryResult/QueryResult.tsx +17 -8
  164. package/src/components/QueryResult/index.ts +3 -0
  165. package/src/components/RenderedResult/RenderedResult.tsx +685 -67
  166. package/src/components/RenderedResult/ResultContainer.tsx +71 -2
  167. package/src/components/RenderedResult/index.ts +3 -0
  168. package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
  169. package/src/components/RenderedResult/renderLogs.ts +43 -0
  170. package/src/components/ResultsDialog.tsx +13 -1
  171. package/src/components/ServerProvider.tsx +175 -51
  172. package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
  173. package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
  174. package/src/components/Workbook/ModelPicker.tsx +7 -4
  175. package/src/components/Workbook/MutableCell.tsx +10 -5
  176. package/src/components/Workbook/Workbook.tsx +8 -5
  177. package/src/components/Workbook/WorkbookList.tsx +3 -0
  178. package/src/components/Workbook/WorkbookManager.ts +3 -0
  179. package/src/components/Workbook/WorkbookStorage.ts +3 -0
  180. package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
  181. package/src/components/Workbook/index.ts +3 -0
  182. package/src/components/click_helper.ts +17 -1
  183. package/src/components/drill/index.ts +28 -0
  184. package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
  185. package/src/components/drill/markDrillableCells.spec.ts +109 -0
  186. package/src/components/drill/markDrillableCells.ts +314 -0
  187. package/src/components/drill/resolveDrill.spec.ts +449 -0
  188. package/src/components/drill/resolveDrill.ts +375 -0
  189. package/src/components/drill/useDrill.tsx +203 -0
  190. package/src/components/filter/DimensionFilter.tsx +3 -0
  191. package/src/components/filter/index.ts +3 -0
  192. package/src/components/filter/utils.ts +16 -5
  193. package/src/components/given/GivenInput.spec.tsx +689 -0
  194. package/src/components/given/GivenInput.tsx +801 -0
  195. package/src/components/given/GivensPanel.spec.tsx +175 -0
  196. package/src/components/given/GivensPanel.tsx +195 -0
  197. package/src/components/given/filterValue.spec.ts +364 -0
  198. package/src/components/given/filterValue.ts +207 -0
  199. package/src/components/given/index.ts +9 -0
  200. package/src/components/given/paramCodec.spec.ts +857 -0
  201. package/src/components/given/paramCodec.ts +483 -0
  202. package/src/components/given/utils.spec.ts +60 -0
  203. package/src/components/given/utils.ts +79 -0
  204. package/src/components/highlighter.ts +22 -5
  205. package/src/components/index.ts +10 -2
  206. package/src/components/styles.ts +82 -33
  207. package/src/constants/docLinks.spec.ts +54 -0
  208. package/src/constants/docLinks.ts +46 -0
  209. package/src/hooks/givenValue.ts +13 -0
  210. package/src/hooks/index.ts +13 -0
  211. package/src/hooks/useDimensionFilters.ts +4 -7
  212. package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
  213. package/src/hooks/useDimensionFiltersQuery.ts +10 -13
  214. package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
  215. package/src/hooks/useGivensState.spec.ts +449 -0
  216. package/src/hooks/useGivensState.ts +340 -0
  217. package/src/hooks/useModelGivens.ts +29 -0
  218. package/src/hooks/useQueryWithApiError.ts +3 -0
  219. package/src/hooks/useRawQueryData.ts +6 -3
  220. package/src/hooks/useSuggestOptions.spec.ts +112 -0
  221. package/src/hooks/useSuggestOptions.ts +263 -0
  222. package/src/index.ts +10 -1
  223. package/src/react-app-env.d.ts +3 -0
  224. package/src/theme/ThemeContext.tsx +86 -0
  225. package/src/theme/buildMalloyExplicitTheme.ts +61 -0
  226. package/src/theme/buildTableCssVars.spec.ts +67 -0
  227. package/src/theme/buildTableCssVars.ts +67 -0
  228. package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
  229. package/src/theme/buildVegaThemeOverride.ts +47 -0
  230. package/src/theme/defaults.ts +78 -0
  231. package/src/theme/index.ts +11 -0
  232. package/src/theme/keys.ts +32 -0
  233. package/src/theme/readChartAnnotations.spec.ts +58 -0
  234. package/src/theme/readChartAnnotations.ts +69 -0
  235. package/src/theme/resolveTheme.spec.ts +160 -0
  236. package/src/theme/resolveTheme.ts +121 -0
  237. package/src/theme/types.ts +79 -0
  238. package/src/utils/dataAppEmbed.spec.ts +63 -0
  239. package/src/utils/dataAppEmbed.ts +84 -0
  240. package/src/utils/formatting.spec.ts +25 -21
  241. package/src/utils/formatting.ts +11 -7
  242. package/src/utils/malloyString.spec.ts +24 -0
  243. package/src/utils/malloyString.ts +12 -0
  244. package/src/utils/parsing.spec.ts +26 -19
  245. package/src/utils/parsing.ts +11 -6
  246. package/src/utils/queryClient.ts +17 -0
  247. package/test/README.md +141 -0
  248. package/test/setup.ts +29 -0
  249. package/tsconfig.json +12 -1
  250. package/tsconfig.spec.json +22 -0
  251. package/vite.config.ts +3 -0
  252. package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
  253. package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
  254. package/dist/components/Home/AddProjectDialog.d.ts +0 -1
  255. package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
  256. package/dist/components/Home/EditProjectDialog.d.ts +0 -7
  257. package/dist/components/Package/Config.d.ts +0 -5
  258. package/dist/components/Package/Databases.d.ts +0 -5
  259. package/dist/components/Package/Notebooks.d.ts +0 -6
  260. package/dist/components/Project/Project.d.ts +0 -6
  261. package/dist/components/Project/index.d.ts +0 -2
  262. package/dist/index-BOLBP6_i.cjs.js +0 -233
  263. package/src/components/Package/Config.tsx +0 -97
  264. package/src/components/Package/Connections.tsx +0 -373
  265. package/src/components/Package/Databases.tsx +0 -228
  266. package/src/components/Package/Notebooks.tsx +0 -77
  267. package/src/components/Project/AddPackageDialog.tsx +0 -159
  268. package/src/components/Project/Packages.tsx +0 -191
  269. package/src/components/Project/Project.tsx +0 -52
  270. package/src/components/Project/index.ts +0 -2
  271. /package/dist/components/{Project → Environment}/About.d.ts +0 -0
  272. /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
  273. /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
  274. /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
  275. /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
  276. /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
  277. /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
@@ -0,0 +1,23 @@
1
+ import { Tag } from '@malloydata/malloy-tag';
2
+ import { Theme } from './types';
3
+ /**
4
+ * Read a `theme.*` annotation block out of a parsed Malloy {@link Tag}
5
+ * and turn it into a partial {@link Theme} suitable for the cascade.
6
+ * Returns `undefined` if the tag has no `theme` namespace.
7
+ *
8
+ * Recognised annotation forms (all optional, all sit under `theme`):
9
+ *
10
+ * # theme.palette.series = ["#ff0080", "#ff6b00"]
11
+ * # theme.palette.background.light = "#fff"
12
+ * # theme.palette.background.dark = "#000"
13
+ * # theme.palette.tableHeader.light = "#666"
14
+ * # theme.palette.tableHeader.dark = "#aaa"
15
+ * # theme.font.family = "Roboto, sans-serif"
16
+ * # theme.font.size = 13
17
+ *
18
+ * Series and font are shared across modes; only the seven
19
+ * {@link PER_MODE_COLOR_KEYS} accept light/dark variants. Annotations
20
+ * with the wrong type are silently ignored. The goal is "worst-case a
21
+ * typo means no styling", not "a typo crashes the renderer."
22
+ */
23
+ export declare function readChartAnnotations(tag: Tag | undefined): Theme | undefined;
@@ -0,0 +1,22 @@
1
+ import { ResolvedTheme, Theme, ThemeMode } from './types';
2
+ /**
3
+ * Collapse the layered theme cascade into a {@link ResolvedTheme} that
4
+ * downstream code can consume without null-checks or mode branches.
5
+ * Layer order is low → high precedence; later layers overwrite earlier
6
+ * ones for the keys they set. Per-mode colour objects merge per-mode
7
+ * (a layer that sets only `palette.tile.dark` doesn't clobber the
8
+ * instance-level `palette.tile.light`).
9
+ *
10
+ * The derived fields on ResolvedTheme (border, pinnedBorder,
11
+ * valueColor, foreground, axisFaint) are computed once here from the
12
+ * active mode so the three builders that consume the theme stop
13
+ * recomputing them with duplicated hex literals.
14
+ */
15
+ export declare function resolveTheme(layers: Array<Theme | undefined>, mode: ThemeMode): ResolvedTheme;
16
+ /**
17
+ * Pick the active mode for a viewer given the operator's `defaultMode`,
18
+ * any persisted viewer choice, and a snapshot of the OS dark-mode
19
+ * preference. "auto" is resolved here; callers see only "light" or
20
+ * "dark".
21
+ */
22
+ export declare function resolveMode(defaultMode: Theme["defaultMode"] | undefined, userChoice: ThemeMode | "auto" | undefined, prefersDark: boolean): ThemeMode;
@@ -0,0 +1,70 @@
1
+ import { Theme } from '../client';
2
+ export type { Theme };
3
+ export type ThemeMode = "light" | "dark";
4
+ /**
5
+ * A Theme with every field downstream consumers need actually filled in.
6
+ * Produced by `resolveTheme(layers, mode)`, which flattens the cascade
7
+ * and the per-mode colour split into a single mode-agnostic shape — so
8
+ * `buildTableCssVars`, `buildVegaThemeOverride`, and
9
+ * `buildMalloyExplicitTheme` never have to branch on mode themselves.
10
+ *
11
+ * The seven `palette.*` colour keys are stored per-mode on the raw Theme
12
+ * (one of light/dark per field) and collapse to the active mode here.
13
+ * The five "derived" fields (border, pinnedBorder, valueColor,
14
+ * foreground, axisFaint) are computed once from the resolved mode so
15
+ * the same hex literal isn't repeated across three builders.
16
+ */
17
+ export interface ResolvedTheme {
18
+ mode: ThemeMode;
19
+ series: string[];
20
+ font: {
21
+ family: string;
22
+ size: number;
23
+ };
24
+ background: string;
25
+ tableHeader: string;
26
+ tableHeaderBackground: string;
27
+ tableBody: string;
28
+ tile: string;
29
+ tileTitle: string;
30
+ /**
31
+ * Saturated end of the gradient used by sequential color scales
32
+ * (choropleth maps, heatmaps). The renderer pairs it with a
33
+ * near-neutral low-end so the operator only picks the brand end.
34
+ */
35
+ mapColor: string;
36
+ border: string;
37
+ pinnedBorder: string;
38
+ valueColor: string;
39
+ foreground: string;
40
+ axisFaint: string;
41
+ /**
42
+ * Background for the renderer's HTML chrome (the area between
43
+ * dashboard tiles). Mode-keyed and intentionally NOT
44
+ * operator-customizable — when an operator picks a bold accent
45
+ * for `palette.background` (the chart canvas), the surrounding
46
+ * panel should stay neutral so the accent reads cleanly. In dark
47
+ * mode it paints slate so the panel doesn't sit as a stark white
48
+ * box on the dark page chrome.
49
+ */
50
+ dashboardRoot: string;
51
+ /**
52
+ * Colour a `# drill` cell takes on hover, when it reads as a link. A link
53
+ * blue rather than anything from `palette.series`, deliberately: the
54
+ * affordance has to stay legible as a link against whatever the operator
55
+ * picked for the data, and a drillable bar or cell should not look like it
56
+ * belongs to a series. Mode-keyed and not operator-customizable, like
57
+ * `dashboardRoot`.
58
+ */
59
+ drillLink: string;
60
+ /**
61
+ * Background for the renderer's table interior. Follows the
62
+ * operator's `palette.background` (the chart canvas colour) so
63
+ * tables and charts share a single "viz surface" colour. In dark
64
+ * mode this also keeps the (light-slate) header/body text from
65
+ * painting unreadable light-on-white against the renderer's
66
+ * hardcoded default. Distinct from `dashboardRoot`, which is the
67
+ * panel BETWEEN tiles and stays mode-keyed / neutral.
68
+ */
69
+ tableBackground: string;
70
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * postMessage `type` an embedded data app emits to its host frame as its
3
+ * content height changes, so the host can resize the iframe to avoid nested
4
+ * scrollbars. Payload shape is {@link PublisherResizeMessage}.
5
+ */
6
+ export declare const PUBLISHER_RESIZE_MESSAGE_TYPE = "publisher:resize";
7
+ /** Resize message posted by an embedded data app's publisher.js runtime. */
8
+ export interface PublisherResizeMessage {
9
+ type: typeof PUBLISHER_RESIZE_MESSAGE_TYPE;
10
+ /** Content height in CSS pixels. */
11
+ height: number;
12
+ }
13
+ /** Type guard for a {@link PublisherResizeMessage} arriving via postMessage. */
14
+ export declare function isPublisherResizeMessage(data: unknown): data is PublisherResizeMessage;
15
+ /**
16
+ * Derive the Publisher data origin (where static package files are served)
17
+ * from the configured API base URL by stripping the trailing `/api/v0`.
18
+ *
19
+ * The static-file routes live off the server root, not under the API prefix,
20
+ * and the data origin can differ from the SPA origin in multi-host
21
+ * deployments — so a data app's standalone URL is `serverBaseUrl(server)`
22
+ * joined with its root-relative `resource`.
23
+ */
24
+ export declare function serverBaseUrl(server: string): string;
25
+ /**
26
+ * Absolute URL of a file inside a package, as Publisher serves it:
27
+ * `<data origin>/environments/<env>/packages/<pkg>/<path>`.
28
+ *
29
+ * The one home for this string. Both the data app viewer's iframe and the
30
+ * "this is not a model" page point at it, and hand-building it in each place is
31
+ * how the two drift.
32
+ *
33
+ * `path` is relative to the package's `public/` directory and is inserted as
34
+ * given, since it may contain slashes. A leading `public/` is dropped, because
35
+ * the served path does not include it and a caller passing a path a reader typed
36
+ * would otherwise produce `public/public/<file>`, which 404s. The server's own
37
+ * redirect drops it for the same reason.
38
+ */
39
+ export declare function packageFileUrl({ server, environmentName, packageName, path, }: {
40
+ server: string;
41
+ environmentName: string;
42
+ packageName: string;
43
+ path: string;
44
+ }): string;
@@ -1,5 +1,5 @@
1
1
  export type ParsedResource = {
2
- projectName: string;
2
+ environmentName: string;
3
3
  packageName?: string | undefined;
4
4
  connectionName?: string | undefined;
5
5
  versionId?: string | undefined;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Escape a value for use inside a single-quoted Malloy string literal.
3
+ *
4
+ * Backslashes are escaped first, then quotes: doing it the other way round
5
+ * would re-escape the backslash that the quote escape introduced.
6
+ */
7
+ export declare function escapeMalloyString(value: string): string;
@@ -1,5 +1,5 @@
1
- export declare const getProjectDescription: (readme: string | undefined) => string;
2
- export declare const generateProjectReadme: (project: {
1
+ export declare const getEnvironmentDescription: (readme: string | undefined) => string;
2
+ export declare const generateEnvironmentReadme: (environment: {
3
3
  name: string;
4
4
  readme?: string;
5
5
  }, description?: string) => string;
@@ -1,2 +1,7 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
2
  export declare const globalQueryClient: QueryClient;
3
+ export declare const CHART_RESULT_QUERY_OPTIONS: {
4
+ readonly staleTime: number;
5
+ readonly refetchOnWindowFocus: false;
6
+ readonly refetchOnReconnect: false;
7
+ };
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.0.382-dev",
4
+ "version": "0.2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -60,7 +60,7 @@
60
60
  "build": "bun generate-api-types && bunx vite build",
61
61
  "postbuild": "cp ../../node_modules/@malloydata/malloy-explorer/dist/malloy-explorer.css ./dist/malloy-explorer.css && cp ../../node_modules/@uiw/react-md-editor/markdown-editor.css ./dist/markdown-editor.css && echo '/* SDK Styles */\n@import \"./malloy-explorer.css\";\n@import \"./markdown-editor.css\";' > ./dist/styles.css",
62
62
  "test": "bun test",
63
- "lint": "bunx eslint ./src --fix",
63
+ "lint": "bunx eslint ./src ./test --fix",
64
64
  "format": "bunx prettier --write --parser typescript '**/*.{ts,tsx}'",
65
65
  "analyze": "bunx vite-bundle-visualizer",
66
66
  "generate-api-types": "bunx openapi-generator-cli generate -i ../../api-doc.yaml -g typescript-axios -o src/client/"
@@ -70,10 +70,12 @@
70
70
  "react-dom": ">=19.1.0",
71
71
  "react-router-dom": ">=7.6.2",
72
72
  "@tanstack/react-query": ">=5.59.16",
73
- "@malloydata/malloy-explorer": ">=0.0.338-dev260215172810",
74
- "@malloydata/malloy-interfaces": ">=0.0.374",
75
- "@malloydata/malloy-query-builder": ">=0.0.374",
76
- "@malloydata/render": ">=0.0.374",
73
+ "@malloydata/malloy-explorer": "0.0.338-dev260215172810",
74
+ "@malloydata/malloy-filter": "^0.0.432",
75
+ "@malloydata/malloy-interfaces": "^0.0.432",
76
+ "@malloydata/malloy-query-builder": "^0.0.432",
77
+ "@malloydata/malloy-tag": "^0.0.432",
78
+ "@malloydata/render": "^0.0.432",
77
79
  "@mui/icons-material": ">=7.1.1",
78
80
  "@mui/x-date-pickers": ">=7.1.1",
79
81
  "@mui/material": ">=7.1.1",
@@ -86,11 +88,22 @@
86
88
  "@emotion/styled": "^11.14.0",
87
89
  "@react-spring/web": "^10.0.1",
88
90
  "@uiw/react-md-editor": "^4.0.6",
91
+ "cron-parser": "^5.6.2",
92
+ "cronstrue": "^2.50.0",
89
93
  "markdown-to-jsx": "^7.7.6",
90
94
  "dayjs": "^1.11.13"
91
95
  },
92
96
  "devDependencies": {
97
+ "@happy-dom/global-registrator": "^20.11.1",
98
+ "@malloydata/malloy-explorer": "0.0.338-dev260215172810",
99
+ "@malloydata/malloy-filter": "^0.0.432",
100
+ "@malloydata/malloy-query-builder": "^0.0.432",
101
+ "@malloydata/malloy-tag": "^0.0.432",
93
102
  "@openapitools/openapi-generator-cli": "^2.20.2",
103
+ "@shikijs/langs": "^1.16.3",
104
+ "@shikijs/themes": "^1.16.3",
105
+ "@testing-library/dom": "^10.4.1",
106
+ "@testing-library/react": "^16.3.2",
94
107
  "@types/bun": "^1.2.21",
95
108
  "@types/k6": "^1.0.2",
96
109
  "@types/react": "^19.1.7",
@@ -106,8 +119,6 @@
106
119
  "eslint-plugin-react-hooks": "5.0.0",
107
120
  "eslint-plugin-storybook": "^0.11.4",
108
121
  "shiki": "^1.16.3",
109
- "@shikijs/langs": "^1.16.3",
110
- "@shikijs/themes": "^1.16.3",
111
122
  "vite": "^6.3.2",
112
123
  "vite-plugin-dts": "^4.5.3",
113
124
  "vite-plugin-svgr": "^4.3.0"
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  // Lightweight client entry point for better code splitting
2
5
  // This module contains essential client functionality without heavy UI components
3
6
 
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { Add, Launch } from "@mui/icons-material";
2
5
  import {
3
6
  Box,
@@ -230,13 +233,16 @@ export function AnalyzePackageButton({
230
233
  </FormControl>
231
234
  ) : availableWorkspaces.length === 1 ? (
232
235
  <Box
233
- sx={{
236
+ sx={(theme) => ({
234
237
  p: 2,
235
238
  border: 1,
236
239
  borderColor: "divider",
237
240
  borderRadius: 1,
238
- backgroundColor: "grey.50",
239
- }}
241
+ backgroundColor:
242
+ theme.palette.mode === "dark"
243
+ ? "rgba(255, 255, 255, 0.04)"
244
+ : "grey.50",
245
+ })}
240
246
  >
241
247
  <Typography
242
248
  variant="body2"
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { Typography } from "@mui/material";
2
5
 
3
6
  export interface ApiError extends Error {
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import AddIcon from "@mui/icons-material/Add";
2
5
  import DeleteIcon from "@mui/icons-material/Delete";
3
6
  import Box from "@mui/material/Box";
@@ -27,6 +30,7 @@ import {
27
30
  gcsAttachedDatabaseFields,
28
31
  getAttachedDatabaseFields,
29
32
  s3AttachedDatabaseFields,
33
+ uiCreatableConnectionTypes,
30
34
  } from "./common";
31
35
 
32
36
  type AddConnectionDialogProps = {
@@ -304,6 +308,21 @@ export default function AddConnectionDialog({
304
308
  if (!connectionConfig.accessToken) {
305
309
  throw new Error("Access Token is required");
306
310
  }
311
+ } else if (type === "databricks") {
312
+ if (!connectionConfig.host) {
313
+ throw new Error("Host is required");
314
+ }
315
+ if (!connectionConfig.path) {
316
+ throw new Error("HTTP Path is required");
317
+ }
318
+ const hasOAuth =
319
+ connectionConfig.oauthClientId &&
320
+ connectionConfig.oauthClientSecret;
321
+ if (!connectionConfig.token && !hasOAuth) {
322
+ throw new Error(
323
+ "Either Access Token or OAuth Client ID + Secret is required",
324
+ );
325
+ }
307
326
  }
308
327
 
309
328
  connectionPayload = {
@@ -339,7 +358,16 @@ export default function AddConnectionDialog({
339
358
 
340
359
  return (
341
360
  <React.Fragment>
342
- <Button variant="outlined" onClick={handleClickOpen}>
361
+ {/* Contained with a start icon, matching AddEnvironmentDialog and
362
+ AddPackageDialog. This was the only add-trigger of the three still
363
+ outlined and icon-less, which read as the secondary action on a
364
+ screen where it is the primary one. */}
365
+ <Button
366
+ variant="contained"
367
+ color="primary"
368
+ startIcon={<AddIcon />}
369
+ onClick={handleClickOpen}
370
+ >
343
371
  Add Connection
344
372
  </Button>
345
373
  <Dialog open={open} onClose={handleClose}>
@@ -373,7 +401,7 @@ export default function AddConnectionDialog({
373
401
  setType(event.target.value as ConnectionTypeEnum)
374
402
  }
375
403
  >
376
- {Object.values(ConnectionTypeEnum).map((type) => (
404
+ {uiCreatableConnectionTypes.map((type) => (
377
405
  <MenuItem key={type} value={type}>
378
406
  {type}
379
407
  </MenuItem>
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { Delete } from "@mui/icons-material";
2
5
  import CloseIcon from "@mui/icons-material/Close";
3
6
  import { Snackbar } from "@mui/material";
@@ -7,6 +10,9 @@ import DialogActions from "@mui/material/DialogActions";
7
10
  import DialogContent from "@mui/material/DialogContent";
8
11
  import DialogTitle from "@mui/material/DialogTitle";
9
12
  import IconButton from "@mui/material/IconButton";
13
+ import ListItemIcon from "@mui/material/ListItemIcon";
14
+ import ListItemText from "@mui/material/ListItemText";
15
+ import MenuItem from "@mui/material/MenuItem";
10
16
  import Typography from "@mui/material/Typography";
11
17
  import React, { useState } from "react";
12
18
  import { Connection } from "../../client";
@@ -34,14 +40,19 @@ export default function DeleteConnectionDialog({
34
40
 
35
41
  return (
36
42
  <React.Fragment>
37
- <IconButton
43
+ <MenuItem
44
+ aria-label={`Delete connection ${connection?.name ?? ""}`.trim()}
38
45
  onClick={(event) => {
39
46
  event.stopPropagation();
40
47
  handleClickOpen();
41
48
  }}
49
+ sx={{ color: "error.main" }}
42
50
  >
43
- <Delete />
44
- </IconButton>
51
+ <ListItemIcon sx={{ color: "inherit" }}>
52
+ <Delete fontSize="small" />
53
+ </ListItemIcon>
54
+ <ListItemText>Delete</ListItemText>
55
+ </MenuItem>
45
56
 
46
57
  <Dialog
47
58
  onClose={handleClose}
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import AddIcon from "@mui/icons-material/Add";
2
5
  import DeleteIcon from "@mui/icons-material/Delete";
3
6
  import Box from "@mui/material/Box";
@@ -8,6 +11,8 @@ import DialogContent from "@mui/material/DialogContent";
8
11
  import DialogContentText from "@mui/material/DialogContentText";
9
12
  import DialogTitle from "@mui/material/DialogTitle";
10
13
  import IconButton from "@mui/material/IconButton";
14
+ import ListItemIcon from "@mui/material/ListItemIcon";
15
+ import ListItemText from "@mui/material/ListItemText";
11
16
  import TextField from "@mui/material/TextField";
12
17
  import Typography from "@mui/material/Typography";
13
18
  import React, { useState } from "react";
@@ -28,12 +33,14 @@ import {
28
33
  gcsAttachedDatabaseFields,
29
34
  getAttachedDatabaseFields,
30
35
  s3AttachedDatabaseFields,
36
+ uiCreatableConnectionTypes,
31
37
  } from "./common";
32
38
 
33
39
  type EditConnectionDialogProps = {
34
40
  connection: Connection;
35
41
  onSubmit: (connection: Connection) => Promise<unknown>;
36
42
  isSubmitting: boolean;
43
+ onCloseDialog?: () => void;
37
44
  };
38
45
 
39
46
  function initAttachedDatabases(connection: Connection) {
@@ -56,6 +63,7 @@ export default function EditConnectionDialog({
56
63
  connection,
57
64
  onSubmit,
58
65
  isSubmitting,
66
+ onCloseDialog,
59
67
  }: EditConnectionDialogProps) {
60
68
  const [open, setOpen] = useState(false);
61
69
  const [type, setType] = useState<Connection["type"]>(connection.type);
@@ -83,6 +91,7 @@ export default function EditConnectionDialog({
83
91
 
84
92
  const handleClose = () => {
85
93
  setOpen(false);
94
+ onCloseDialog?.();
86
95
  };
87
96
 
88
97
  const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
@@ -362,6 +371,21 @@ export default function EditConnectionDialog({
362
371
  if (!connectionConfig.accessToken) {
363
372
  throw new Error("Access Token is required");
364
373
  }
374
+ } else if (type === "databricks") {
375
+ if (!connectionConfig.host) {
376
+ throw new Error("Host is required");
377
+ }
378
+ if (!connectionConfig.path) {
379
+ throw new Error("HTTP Path is required");
380
+ }
381
+ const hasOAuth =
382
+ connectionConfig.oauthClientId &&
383
+ connectionConfig.oauthClientSecret;
384
+ if (!connectionConfig.token && !hasOAuth) {
385
+ throw new Error(
386
+ "Either Access Token or OAuth Client ID + Secret is required",
387
+ );
388
+ }
365
389
  }
366
390
 
367
391
  connectionPayload = {
@@ -431,15 +455,19 @@ export default function EditConnectionDialog({
431
455
 
432
456
  return (
433
457
  <React.Fragment>
434
- <IconButton
458
+ <MenuItem
459
+ aria-label={`Edit connection ${connection?.name ?? ""}`.trim()}
435
460
  onClick={(event) => {
436
461
  event.preventDefault();
437
462
  event.stopPropagation();
438
463
  handleClickOpen();
439
464
  }}
440
465
  >
441
- <Edit />
442
- </IconButton>
466
+ <ListItemIcon>
467
+ <Edit fontSize="small" />
468
+ </ListItemIcon>
469
+ <ListItemText>Edit</ListItemText>
470
+ </MenuItem>
443
471
  <Dialog open={open} onClose={handleClose}>
444
472
  <DialogTitle
445
473
  onClick={(event) => {
@@ -482,7 +510,7 @@ export default function EditConnectionDialog({
482
510
  setType(event.target.value as ConnectionTypeEnum)
483
511
  }
484
512
  >
485
- {Object.values(ConnectionTypeEnum).map((type) => (
513
+ {uiCreatableConnectionTypes.map((type) => (
486
514
  <MenuItem key={type} value={type}>
487
515
  {type}
488
516
  </MenuItem>
@@ -722,6 +750,7 @@ export default function EditConnectionDialog({
722
750
  Database {index + 1}
723
751
  </Typography>
724
752
  <IconButton
753
+ aria-label={`Remove attached database ${index + 1}`}
725
754
  onClick={() =>
726
755
  removeAttachedDatabase(index)
727
756
  }
@@ -1,8 +1,12 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { HTMLInputTypeAttribute } from "react";
5
+ import { ConnectionTypeEnum } from "../../client/api";
2
6
  import type {
3
7
  AzureConnection,
4
8
  BigqueryConnection,
5
- ConnectionTypeEnum,
9
+ DatabricksConnection,
6
10
  DucklakeConnection,
7
11
  GCSConnection,
8
12
  MotherDuckConnection,
@@ -19,6 +23,7 @@ type ConnectionField = {
19
23
  BigqueryConnection &
20
24
  SnowflakeConnection &
21
25
  TrinoConnection &
26
+ DatabricksConnection &
22
27
  MysqlConnection &
23
28
  MotherDuckConnection &
24
29
  S3Connection &
@@ -217,6 +222,50 @@ export const connectionFieldsByType: Record<
217
222
  required: false, // Can be used instead of password for HTTPS
218
223
  },
219
224
  ],
225
+ databricks: [
226
+ {
227
+ label: "Host",
228
+ name: "host",
229
+ type: "text",
230
+ required: true,
231
+ },
232
+ {
233
+ label: "HTTP Path",
234
+ name: "path",
235
+ type: "text",
236
+ required: true,
237
+ },
238
+ {
239
+ label: "Access Token",
240
+ name: "token",
241
+ type: "password",
242
+ required: false, // Either token or OAuth client credentials required
243
+ },
244
+ {
245
+ label: "OAuth Client ID",
246
+ name: "oauthClientId",
247
+ type: "text",
248
+ required: false, // Required with oauthClientSecret if no token
249
+ },
250
+ {
251
+ label: "OAuth Client Secret",
252
+ name: "oauthClientSecret",
253
+ type: "password",
254
+ required: false, // Required with oauthClientId if no token
255
+ },
256
+ {
257
+ label: "Default Catalog",
258
+ name: "defaultCatalog",
259
+ type: "text",
260
+ required: false,
261
+ },
262
+ {
263
+ label: "Default Schema",
264
+ name: "defaultSchema",
265
+ type: "text",
266
+ required: false,
267
+ },
268
+ ],
220
269
  mysql: [
221
270
  {
222
271
  label: "Host",
@@ -267,6 +316,9 @@ export const connectionFieldsByType: Record<
267
316
  ],
268
317
  // DuckLake uses custom form rendering (catalog + storage dropdowns)
269
318
  ducklake: [],
319
+ // Publisher connections are defined in publisher.config.json, not built from
320
+ // this form (see uiCreatableConnectionTypes).
321
+ publisher: [],
270
322
  };
271
323
 
272
324
  export const attributesFieldName: Record<ConnectionTypeEnum, string> = {
@@ -274,12 +326,23 @@ export const attributesFieldName: Record<ConnectionTypeEnum, string> = {
274
326
  bigquery: "bigqueryConnection",
275
327
  snowflake: "snowflakeConnection",
276
328
  trino: "trinoConnection",
329
+ databricks: "databricksConnection",
277
330
  mysql: "mysqlConnection",
278
331
  duckdb: "duckdbConnection",
279
332
  motherduck: "motherduckConnection",
280
333
  ducklake: "ducklakeConnection",
334
+ publisher: "publisherConnection",
281
335
  };
282
336
 
337
+ /**
338
+ * Connection types the Add/Edit dialogs offer as creatable. `publisher` proxy
339
+ * connections are configured in publisher.config.json rather than through the
340
+ * UI, so they are a valid ConnectionTypeEnum but not a form choice.
341
+ */
342
+ export const uiCreatableConnectionTypes = Object.values(
343
+ ConnectionTypeEnum,
344
+ ).filter((type) => type !== ConnectionTypeEnum.Publisher);
345
+
283
346
  // Mapping for attached database types to their connection field names
284
347
  export const attachedDatabaseConnectionFieldName: Record<string, string> = {
285
348
  postgres: "postgresConnection",
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { useEffect, useRef } from "react";
2
5
 
3
6
  interface DOMElement {
@@ -1 +1,4 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  export { default as DOMElement } from "./DOMElement";