@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
@@ -16,9 +16,29 @@
16
16
  * ask for one kind. Everything else a backend may know about a document, who
17
17
  * changed it and when, who may see it, stays with the backend.
18
18
  *
19
+ * A host hands the SDK ONE storage and keeps handing it the same one. What a
20
+ * storage says about its workspaces decides how the editor routes a save, and
21
+ * the editor asks once, when it opens; a host that re-creates its storage mid
22
+ * session leaves the editor routing by the old answer until the new list
23
+ * resolves.
24
+ *
19
25
  * Every method rejects rather than returning a sentinel when the document is
20
- * not there, so a caller can tell "missing" from "empty".
26
+ * not there, so a caller can tell "missing" from "empty". Absence rejects with
27
+ * a {@link DocumentNotFoundError} specifically, so a caller can tell either of
28
+ * those from a backend that could not be reached: a failed read answered with
29
+ * "there is no document" reads as "the package is the only copy", and saving
30
+ * on that belief overwrites the copy that was actually there.
31
+ */
32
+ /**
33
+ * Absence, and only absence: the document is not at that locator. Every other
34
+ * rejection means the backend could not answer, which is not the same thing and
35
+ * must not be treated as one.
21
36
  */
37
+ export declare class DocumentNotFoundError extends Error {
38
+ constructor(message: string);
39
+ }
40
+ /** Whether a rejection means absence rather than a backend that could not answer. */
41
+ export declare const isDocumentNotFound: (error: unknown) => boolean;
22
42
  /**
23
43
  * The kinds of document the SDK authors. A `dashboard` is a
24
44
  * `dashboards/<slug>.malloy` file; a `notebook` is a `.malloynb`.
@@ -29,7 +49,33 @@ export interface Workspace {
29
49
  name: string;
30
50
  /** False for a workspace this reader may list and open but not save into. */
31
51
  writeable: boolean;
52
+ /**
53
+ * What this place is, in the backend's own words, for the editor to show a
54
+ * reader rather than guessing on their behalf.
55
+ */
32
56
  description: string;
57
+ /**
58
+ * This workspace holds the package's system of record: what it keeps for a
59
+ * document IS that document, and the package file is a copy of it or a
60
+ * deploy behind it.
61
+ *
62
+ * Left out, the workspace is a place a reader's work is kept beside the
63
+ * package — the Console's browser copy, a scratch space — and the package
64
+ * file is the record.
65
+ *
66
+ * The contract, which the editor relies on and does not police:
67
+ *
68
+ * - At most one workspace of a storage declares itself authoritative. The
69
+ * editor takes the first it is given and does not arbitrate between two.
70
+ * - It is orthogonal to {@link Workspace.writeable} and to the server's
71
+ * `mutable`. A workspace can be the record and still be read-only to this
72
+ * reader, and a server that refuses writes to its own package says
73
+ * nothing about where the record lives.
74
+ * - A host whose authority differs per package mounts one storage per
75
+ * context rather than flipping this between renders; the editor reads it
76
+ * once, when it opens.
77
+ */
78
+ authoritative?: boolean;
33
79
  }
34
80
  /** One document's address: which workspace, which kind, and its path there. */
35
81
  export interface DocumentLocator {
@@ -47,12 +93,30 @@ export interface DocumentStorage {
47
93
  listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
48
94
  /** Every document in a workspace, or only those of one kind. */
49
95
  listDocuments(workspace: Workspace, type?: DocumentType): Promise<DocumentLocator[]>;
50
- /** The document's content. Rejects when there is no document there. */
96
+ /**
97
+ * The document's content. Rejects with a {@link DocumentNotFoundError} when
98
+ * there is no document there, and with anything else when the backend could
99
+ * not be asked.
100
+ */
51
101
  getDocument(locator: DocumentLocator): Promise<string>;
52
- /** Write the content, creating the document or replacing it. */
102
+ /**
103
+ * Write the content, creating the document or replacing it.
104
+ *
105
+ * There is no expected-version slot, so this is last writer wins and a
106
+ * caller cannot tell that it overwrote someone. A backend that has to stop
107
+ * two authors clobbering each other enforces that itself, in the backend.
108
+ */
53
109
  saveDocument(locator: DocumentLocator, content: string): Promise<void>;
54
- /** Remove the document. Rejects when there is no document there. */
110
+ /**
111
+ * Remove the document. Rejects with a {@link DocumentNotFoundError} when
112
+ * there is no document there, and with anything else when the backend could
113
+ * not be asked — a caller must not read the second as the first and report
114
+ * the document gone.
115
+ */
55
116
  deleteDocument(locator: DocumentLocator): Promise<void>;
56
- /** Rename or relocate a document, keeping its content. Rejects when `from` is missing. */
117
+ /**
118
+ * Rename or relocate a document, keeping its content. Rejects with a
119
+ * {@link DocumentNotFoundError} when `from` is missing.
120
+ */
57
121
  moveDocument(from: DocumentLocator, to: DocumentLocator): Promise<void>;
58
122
  }
@@ -1,3 +1,4 @@
1
1
  export type { DocumentLocator, DocumentStorage, DocumentType, Workspace, } from './DocumentStorage';
2
+ export { DocumentNotFoundError, isDocumentNotFound } from './DocumentStorage';
2
3
  export { DocumentStorageProvider, useDocumentStorage, useOptionalDocumentStorage, type DocumentStorageProviderProps, } from './DocumentStorageProvider';
3
4
  export { BrowserDocumentStorage } from './BrowserDocumentStorage';
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+ /**
3
+ * One thing in a list, anywhere in the Console: a colored icon plate, the
4
+ * thing's name, what it is, and whatever acts on it at the right edge. One per
5
+ * row.
6
+ *
7
+ * The rule is that a list is a list: everything a reader scans down is drawn
8
+ * this way, so the same reading task looks the same on every page. A grid of
9
+ * cards says "these are tiles to arrange", which is not what any of these
10
+ * lists are; a row also lets the description be a description rather than two
11
+ * clamped lines.
12
+ *
13
+ * The color is passed rather than derived here: the package page keys it off
14
+ * content type (see `CONTENT_TINT`), and the environment-scoped lists off what
15
+ * kind of thing the list holds (see `SURFACE_TINT`). Both are exhaustive maps,
16
+ * so the color stays a property of the kind and not of the call site.
17
+ */
18
+ export declare function ItemRow({ icon, tint, label, mono, description, rightLabel, trailingAction, onClick, ariaLabel, }: {
19
+ /** The glyph, drawn white on the tinted plate. */
20
+ icon: React.ReactNode;
21
+ tint: string;
22
+ label: string;
23
+ /** Monospace label, for a name that is a file path. */
24
+ mono?: boolean;
25
+ /** What this one is, in the author's words. One line, then ellipsis. */
26
+ description?: string;
27
+ /** A fact about the row, right-aligned before any action: "1.0 K rows". */
28
+ rightLabel?: string;
29
+ /**
30
+ * Rendered at the end of the row: a menu, an open-in-new-tab button. Clicks
31
+ * on it should `event.stopPropagation()` so the row's own click does not
32
+ * also fire.
33
+ */
34
+ trailingAction?: React.ReactNode;
35
+ onClick?: (event: React.MouseEvent) => void;
36
+ /** Overrides the accessible name, which is otherwise the label. */
37
+ ariaLabel?: string;
38
+ }): import("react/jsx-runtime").JSX.Element;
@@ -2,8 +2,7 @@ import { BuildPlan, Materialization } from '../../client';
2
2
  type MaterializationDetailDialogProps = {
3
3
  materialization: Materialization | null;
4
4
  buildPlan: BuildPlan | null;
5
- showBuildPlan?: boolean;
6
5
  onClose: () => void;
7
6
  };
8
- export default function MaterializationDetailDialog({ materialization, buildPlan, showBuildPlan, onClose, }: MaterializationDetailDialogProps): import("react/jsx-runtime").JSX.Element;
7
+ export default function MaterializationDetailDialog({ materialization, buildPlan, onClose, }: MaterializationDetailDialogProps): import("react/jsx-runtime").JSX.Element;
9
8
  export {};
@@ -3,13 +3,9 @@ type MaterializationRunsListProps = {
3
3
  materializations: Materialization[];
4
4
  mutable: boolean;
5
5
  isMutating: boolean;
6
- /** Show a Package column — for the environment-scoped view spanning packages. */
7
- showPackage?: boolean;
8
- /** Navigate to a package (used by the Package column links). */
9
- onClickPackage?: (packageName: string) => void;
10
6
  onStop: (materialization: Materialization) => void;
11
7
  onDelete: (materialization: Materialization, dropTables: boolean) => void;
12
8
  onViewDetails: (materialization: Materialization) => void;
13
9
  };
14
- export default function MaterializationRunsList({ materializations, mutable, isMutating, showPackage, onClickPackage, onStop, onDelete, onViewDetails, }: MaterializationRunsListProps): import("react/jsx-runtime").JSX.Element;
10
+ export default function MaterializationRunsList({ materializations, mutable, isMutating, onStop, onDelete, onViewDetails, }: MaterializationRunsListProps): import("react/jsx-runtime").JSX.Element;
15
11
  export {};
@@ -1,7 +1,11 @@
1
- import { default as React } from 'react';
2
1
  interface MaterializationsProps {
3
2
  resourceUri: string;
4
- onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
5
3
  }
6
- export default function Materializations({ resourceUri, onClickPackageFile, }: MaterializationsProps): import("react/jsx-runtime").JSX.Element;
4
+ /**
5
+ * The package's materializations, as a section of its page: what has been
6
+ * built, and the three controls that change it — scope, schedule, and a new
7
+ * build. The runs are the package's own history, so they sit beside its
8
+ * dashboards and models rather than one click away on a page of their own.
9
+ */
10
+ export default function Materializations({ resourceUri, }: MaterializationsProps): import("react/jsx-runtime").JSX.Element;
7
11
  export {};
@@ -0,0 +1,18 @@
1
+ export type Scope = "package" | "version";
2
+ /**
3
+ * The package's persist scope, as one button.
4
+ *
5
+ * It is a menu rather than a pair of toggles because the two values are a
6
+ * choice, not a filter, and because the choice is usually made once and then
7
+ * left alone — the section's heading row is not the place for a permanent
8
+ * two-button control. What each value means is in the menu, where it is read at
9
+ * the moment of choosing rather than sitting on the page forever.
10
+ */
11
+ export default function ScopeButton({ scope, disabled, disabledReason, isSubmitting, onChange, }: {
12
+ scope: Scope;
13
+ disabled?: boolean;
14
+ /** Why the control is disabled, shown on hover. */
15
+ disabledReason?: string;
16
+ isSubmitting?: boolean;
17
+ onChange: (scope: Scope) => Promise<unknown>;
18
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,12 @@
1
1
  import { ReactNode } from 'react';
2
2
  /**
3
- * Small uppercase section heading for consistent hierarchy across the
4
- * materialization views (detail dialog, manifest view). One source of truth for
5
- * the style so the headings can't drift. Renders as an <h6> so it is a real
6
- * heading (role="heading") — the caption styling is purely visual.
3
+ * A sub-heading INSIDE a materialization view — the detail dialog and the
4
+ * manifest view — where `PackageSection` does not apply: those are sections of
5
+ * a dialog, not of a page. Small and uppercase to sit a level under the
6
+ * dialog's own title.
7
+ *
8
+ * Renders as an `<h6>`, so it is a real heading to anything navigating by
9
+ * them; the caption styling is purely visual.
7
10
  */
8
11
  export default function SectionLabel({ children }: {
9
12
  children: ReactNode;
@@ -0,0 +1,14 @@
1
+ import { MaterializationMetadata } from './utils';
2
+ /**
3
+ * How a run was initiated — Scheduled (the standalone scheduler fired the
4
+ * package's cron) or Manual (an API or UI create) — with the tooltip that says
5
+ * which. One source of truth for the label, so the runs list and the detail
6
+ * dialog cannot drift.
7
+ *
8
+ * A word, like every other cell in the row. A two-value distinction needs no
9
+ * pictogram, and a bordered pill here made a value look like something to
10
+ * click.
11
+ */
12
+ export default function TriggerLabel({ meta, }: {
13
+ meta: MaterializationMetadata;
14
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1 @@
1
1
  export { default as Materializations } from './Materializations';
2
- export { default as EnvironmentMaterializations } from './EnvironmentMaterializations';
@@ -5,11 +5,9 @@ export type ContentType = "report" | "model" | "data" | "materialization" | "dat
5
5
  * a page that lists all six, a shared color reads as a shared kind, and the
6
6
  * glyphs are small enough that color does most of the telling apart.
7
7
  *
8
- * The logo's three go to the three artifacts a reader opens to look at data,
9
- * dashboards and notebooks and the models under them, and the accents to the
10
- * rest, so the brand leads on the things the page is mostly for. Not a
11
- * seniority ranking: dashboards are the newest thing a package can hold, and
12
- * Package Data is among the oldest and takes an accent.
8
+ * Six hues from `PALETTE`, spaced far enough apart to survive being 18px of
9
+ * white on a 32px plate, and disjoint from the three `SURFACE_TINT` uses so a
10
+ * colour means one kind of thing everywhere in the Console.
13
11
  *
14
12
  * Exhaustive by type rather than by a default, so adding a `ContentType` is a
15
13
  * compile error here instead of a row that silently paints itself the same as
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A new dashboard, written into the package and opened in the builder: pick
3
+ * the model, a source it declares, the view for the first tile, and a title.
4
+ * The file is the one the builder would write (see `newDashboardSource`), so
5
+ * everything after this is the builder's.
6
+ */
7
+ export declare function NewDashboardDialog({ open, environmentName, packageName, models, existing, onClose, onCreated, }: {
8
+ open: boolean;
9
+ environmentName: string;
10
+ packageName: string;
11
+ /** The package's model files, relative to its root, to pick a source from. */
12
+ models: string[];
13
+ /** Slugs already in the package, which a new one may not repeat. */
14
+ existing: string[];
15
+ onClose: () => void;
16
+ /** The new dashboard's slug, once its file is in the package. */
17
+ onCreated: (slug: string) => void;
18
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1 @@
1
1
  export { default as Package } from './Package';
2
- export { default as Models } from './Models';
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ /**
3
+ * One titled section of a page: a heading, how many things are in it, what they
4
+ * are, and the control that adds one.
5
+ *
6
+ * Every section on every page is this component, so moving between a package
7
+ * and the environment above it does not restate the same heading at a different
8
+ * size, indent or gap.
9
+ *
10
+ * The section is a landmark named by its own heading, which is what makes
11
+ * "Dashboards" addressable — to a screen reader moving by region, and to a test
12
+ * that wants the dashboards list rather than every row on the page that happens
13
+ * to share a word with it.
14
+ */
15
+ export declare function PackageSection({ title, count, description, action, children, }: {
16
+ title: string;
17
+ count?: number;
18
+ /** What the section holds, in a line, under the heading. */
19
+ description?: string;
20
+ /** A control on the heading's row, hard right. */
21
+ action?: React.ReactNode;
22
+ children: React.ReactNode;
23
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ import * as React from "react";
2
+ /**
3
+ * The Console's buttons, by the job they do. Four roles, and every button on
4
+ * every page is one of them:
5
+ *
6
+ * 1. **Primary** — the one thing a surface is for: adding a package, a
7
+ * dashboard, a materialization; the confirm in a dialog. A filled dark pill
8
+ * at the default size. {@link AddButton} is the section-heading form of it.
9
+ * 2. **Secondary** — a control beside the primary one, changing something that
10
+ * already exists: Scope, Schedule, Filter. An outlined pill, the same size
11
+ * as the primary, so a heading row reads as one set of controls rather than
12
+ * a big button and some small ones. {@link SecondaryButton}.
13
+ * 3. **Quiet** — a dense bar of equals, where an outline per item would draw a
14
+ * grid: the dashboard builder's toolbar, a dialog's Cancel. A small text
15
+ * button, written inline.
16
+ * 4. **Icon** — a row's overflow menu or a compact toggle. A small icon
17
+ * button, written inline.
18
+ *
19
+ * The roles are exhaustive on purpose. A button that is none of them is a new
20
+ * family of control on a page that already has four, so add it here — with the
21
+ * job it does — rather than inline at its one call site.
22
+ */
23
+ /**
24
+ * The control that adds one thing to a section: a filled pill with a plus,
25
+ * right of the section's heading.
26
+ *
27
+ * The LABEL names the thing alone — "Package", "Connection", "Dashboard" —
28
+ * because the plus already says add; the verb went back into the accessible
29
+ * name, where a control called "Package" would otherwise say nothing about
30
+ * what it does.
31
+ */
32
+ export declare function AddButton({ label, onClick, disabled, }: {
33
+ /** The thing being added, as it should read on the button: "Package". */
34
+ label: string;
35
+ onClick: () => void;
36
+ disabled?: boolean;
37
+ }): import("react/jsx-runtime").JSX.Element;
38
+ /**
39
+ * A secondary control: outlined, and the same size as the primary it sits
40
+ * beside. Takes its own icon and, when it is disabled, the reason — a control
41
+ * that greys out without saying why is a control a reader has to guess at.
42
+ */
43
+ export declare function SecondaryButton({ label, icon, onClick, disabled, disabledReason, ariaLabel, ariaHasPopup, }: {
44
+ label: string;
45
+ icon?: React.ReactNode;
46
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
47
+ disabled?: boolean;
48
+ /** Shown on hover when disabled. */
49
+ disabledReason?: string;
50
+ /** Overrides the accessible name, which is otherwise the label. */
51
+ ariaLabel?: string;
52
+ ariaHasPopup?: "menu" | "dialog";
53
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,9 @@
1
1
  export { ApiErrorDisplay, type ApiErrorDisplayProps } from './ApiErrorDisplay';
2
+ export { AddButton, SecondaryButton } from './buttons';
3
+ export { AppDialog } from './AppDialog';
4
+ export { BackLink } from './BackLink';
5
+ export { DashboardBar } from './Dashboard/DashboardBar';
6
+ export { PALETTE, SURFACE_TINT } from './styles';
2
7
  export { useRouterClickHandler, type NavigationClick } from './click_helper';
3
8
  export * from './Dashboard';
4
9
  export * from './DataAppViewer';
@@ -4,49 +4,64 @@ import { CommonProps } from '@mui/material/OverridableComponent';
4
4
  import { DetailedHTMLProps, HTMLAttributes } from 'react';
5
5
  import { MUIStyledCommonProps } from '@mui/system';
6
6
  /**
7
- * Malloy brand colors — exact hex values from
8
- * `publisher/packages/app/public/logo.svg`. Use these instead of hardcoding
9
- * the hex values inline so the brand can be retuned in one place.
7
+ * The Console's palette: one set of hues, used everywhere a colour carries
8
+ * meaning.
9
+ *
10
+ * These are the register data tools encode categories in — saturated, mid-dark,
11
+ * evenly spaced around the wheel — rather than colours lifted from a logo. A
12
+ * logo is drawn to be recognised at one size in one place; a palette has to
13
+ * distinguish a dozen kinds of thing in a list, behind a glyph, and along a
14
+ * chart's series, and the two jobs pull in different directions. The previous
15
+ * palette was the logo's three plus two families invented to extend it, which
16
+ * is how one screen ended up with three unrelated colour systems on it.
17
+ *
18
+ * **Every value clears 3:1 against white**, WCAG's minimum for a graphical
19
+ * object, because these are painted as small solid backplates behind white
20
+ * glyphs where the glyph has to stay readable. That is a hard constraint on
21
+ * anything added here, asserted in `ContentTypeIcon.spec.ts` rather than left
22
+ * to review: a too-light plate looks perfectly fine in a screenshot and simply
23
+ * stops being legible. Measured against white, lowest first: emerald 3.8:1,
24
+ * red 4.8:1, lime 5.0:1, amber 5.0:1, blue 5.2:1, orange 5.2:1, cyan 5.4:1,
25
+ * teal 5.5:1, violet 5.7:1, pink 6.0:1, indigo 6.3:1, slate 7.6:1.
10
26
  */
11
- export declare const MALLOY_BRAND: {
12
- readonly teal: "#14b3cb";
13
- readonly orange: "#e47404";
14
- readonly darkBlue: "#1474a4";
27
+ export declare const PALETTE: {
28
+ readonly blue: "#2563eb";
29
+ readonly indigo: "#4f46e5";
30
+ readonly violet: "#7c3aed";
31
+ readonly pink: "#be185d";
32
+ readonly red: "#dc2626";
33
+ readonly orange: "#c2410c";
34
+ readonly amber: "#b45309";
35
+ readonly lime: "#4d7c0f";
36
+ readonly emerald: "#059669";
37
+ readonly teal: "#0f766e";
38
+ readonly cyan: "#0e7490";
39
+ readonly slate: "#475569";
15
40
  };
16
41
  /**
17
- * Accents that extend the logo's three, for the places that need more colors
18
- * than the brand supplies. The package page gives every kind of content its
19
- * own, and three kinds became six.
20
- *
21
- * Their own family rather than borrowings from the chart series
22
- * (`theme/defaults.ts`), because the two have opposite constraints. A series
23
- * color fills a large area and can be light; these sit behind a white icon as a
24
- * small solid backplate, where the icon has to stay legible. Measured against
25
- * white: violet 5.5:1, magenta 4.6:1, moss 3.9:1, so all three clear 3:1, the
26
- * WCAG minimum for a graphical object. The nearest series hues do not: `#aacd85`
27
- * sage is 1.8:1, `#ec72b8` pink 2.7:1, `#b87ced` violet 2.9:1.
42
+ * The tints for what a SERVER holds, as against what a package holds. Three
43
+ * kinds — an environment, a package, a connection — listed on the home and
44
+ * environment pages.
28
45
  *
29
- * These three were picked against the bar, but they are not the only colors it
30
- * now binds. `CONTENT_TINT` in `Package/ContentTypeIcon.tsx` paints all three of
31
- * `MALLOY_BRAND` behind glyphs as well, and `ContentTypeIcon.spec.ts` holds two
32
- * of them to the same 3:1: orange at 3.09:1 and darkBlue at 5.17:1. Orange
33
- * clears it by 0.09, so retuning it lighter turns that suite red, in a file a
34
- * brand change would not otherwise open. For those two the bar is a component
35
- * constraint, not only a brand decision.
46
+ * Kept clear of the hues `CONTENT_TINT` uses, so a colour means one kind of
47
+ * thing across the whole Console rather than one kind per page. All three are
48
+ * real colours rather than near-neutrals: a grey plate reads as chrome instead
49
+ * of as one of the coloured kinds, which is the plate's whole job.
36
50
  *
37
- * Teal is the exception at 2.5:1, below the bar and inherited from the logo, so
38
- * the row it backs carries a white-on-teal glyph that does not meet the
39
- * standard. Pre-existing, not introduced here. The spec grandfathers it by
40
- * content type rather than by color, so a new type handed teal still fails.
51
+ * Also kept clear of the primary. Packages were indigo, which sat a few degrees
52
+ * from the blue of the "Package" button on the same row and read as a failed
53
+ * attempt at the same colour. Teal is the furthest hue from blue still open,
54
+ * and packages and connections — the pair that actually share a screen — now
55
+ * sit on opposite sides of the wheel. Environments never appear beside either.
41
56
  */
42
- export declare const MALLOY_ACCENT: {
43
- readonly violet: "#7c4dcc";
44
- readonly magenta: "#c2478f";
45
- readonly moss: "#5c8f3f";
57
+ export declare const SURFACE_TINT: {
58
+ readonly environment: "#059669";
59
+ readonly package: "#0f766e";
60
+ readonly connection: "#c2410c";
46
61
  };
47
62
  /**
48
63
  * Monospace font stack used by code-like surfaces inside the SDK
49
- * (file-path labels in PackageItemRow, code blocks, etc.). Matches the
64
+ * (file-path labels in `ItemRow`, code blocks, etc.). Matches the
50
65
  * `MONO_FONT_FAMILY` defined in the publisher app's theme.
51
66
  */
52
67
  export declare const MONO_FONT_FAMILY = "\"JetBrains Mono\", \"ui-monospace\", \"SFMono-Regular\", \"Menlo\", monospace";
@@ -57,10 +72,4 @@ export declare const CleanNotebookContainer: StyledComponent<MUIStyledCommonProp
57
72
  export declare const CleanNotebookSection: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
58
73
  export declare const CleanMetricCard: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
59
74
  export declare const StyledExplorerPage: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
60
- export declare const StyledExplorerBanner: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
61
75
  export declare const StyledExplorerContent: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
62
- export declare const StyledExplorerPanel: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
63
- export declare const PackageCard: StyledComponent< CardOwnProps & CommonProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "className" | "style" | "classes" | "children" | "sx" | "variant" | "square" | "elevation" | "raised"> & MUIStyledCommonProps<Theme>, {}, {}>;
64
- export declare const PackageCardContent: StyledComponent< CardContentOwnProps & CommonProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "className" | "style" | "classes" | "children" | "sx"> & MUIStyledCommonProps<Theme>, {}, {}>;
65
- export declare const PackageSectionTitle: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
66
- export declare const PackageContainer: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,42 @@
1
+ import { QueryKey, UseMutateFunction } from '@tanstack/react-query';
2
+ import { ConsoleResource } from '../telemetry/consoleEvents';
3
+ import { ApiError } from '../components/ApiErrorDisplay';
4
+ import * as React from "react";
5
+ /**
6
+ * A write from a dialog: run it, close the dialog, refetch what it changed,
7
+ * and say what happened.
8
+ *
9
+ * Every create/edit/delete dialog in the Console does those four things in the
10
+ * same order and reported failure in one of two different ways depending on
11
+ * which file you were in. The shape is here once so the two conventions cannot
12
+ * drift back apart: a thrown `Error` shows its own message, because the API
13
+ * layer already turns a failed response into one worth reading, and anything
14
+ * else falls back to a sentence rather than `[object Object]`.
15
+ *
16
+ * `notice` is the Snackbar, wired and ready to render. It is returned rather
17
+ * than portalled from in here so a caller keeps it as a sibling of its dialog,
18
+ * where it was.
19
+ */
20
+ export declare function useCrudMutation<TVariables = void>({ mutationFn, success, invalidates, closeDialog, resource, action, }: {
21
+ mutationFn: (variables: TVariables) => Promise<unknown>;
22
+ /** What the snackbar says when the write lands: "Package created". */
23
+ success: string;
24
+ /** The query keys the write invalidates. Name the narrowest that covers it. */
25
+ invalidates: QueryKey[];
26
+ /**
27
+ * Closes the dialog. Runs on SUCCESS only — a write that failed leaves
28
+ * something to correct and retry, so the form has to stay — and before the
29
+ * refetch, so the dialog goes at once rather than after the list reloads.
30
+ *
31
+ * Not called `onSettled`: that name means "success or error" everywhere
32
+ * else in React Query, and this is the opposite of that.
33
+ */
34
+ closeDialog: () => void;
35
+ /** What is being written, for the event; see `ConsoleEvent`. */
36
+ resource: ConsoleResource;
37
+ action: "create" | "update" | "delete";
38
+ }): {
39
+ mutate: UseMutateFunction<unknown, ApiError, TVariables, unknown>;
40
+ isPending: boolean;
41
+ notice: React.ReactNode;
42
+ };