@malloy-publisher/sdk 0.12.1 → 0.12.3

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 (208) hide show
  1. package/README.md +79 -6
  2. package/dist/{RenderedResult-DrNhQ2_9.cjs.js → RenderedResult-C2arX5Zz.cjs.js} +1 -1
  3. package/dist/{RenderedResult-AyM-RQaA.es.js → RenderedResult-DqPvGZgL.es.js} +2 -2
  4. package/dist/ServerProvider-CqL6xzta.cjs.js +1 -0
  5. package/dist/{ServerProvider-a9Ki0QXO.es.js → ServerProvider-DRbZ6tLP.es.js} +1213 -1187
  6. package/dist/builder/index.cjs.js +1 -1
  7. package/dist/builder/index.es.js +3 -3
  8. package/dist/client/api.d.ts +43 -13
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +28 -27
  11. package/dist/components/Model/ExplorerPage.d.ts +9 -0
  12. package/dist/components/Model/Model.d.ts +27 -11
  13. package/dist/components/ModelViewer/AccessChips.d.ts +34 -0
  14. package/dist/components/ModelViewer/EmptyRow.d.ts +23 -0
  15. package/dist/components/ModelViewer/Facts.d.ts +15 -0
  16. package/dist/components/ModelViewer/FieldGroup.d.ts +31 -0
  17. package/dist/components/ModelViewer/FieldRow.d.ts +69 -0
  18. package/dist/components/ModelViewer/GivenFacts.d.ts +21 -0
  19. package/dist/components/ModelViewer/HeaderBar.d.ts +75 -0
  20. package/dist/components/ModelViewer/InlineDoc.d.ts +13 -0
  21. package/dist/components/ModelViewer/ModelGivensSection.d.ts +32 -0
  22. package/dist/components/ModelViewer/ModelSection.d.ts +21 -0
  23. package/dist/components/ModelViewer/ModelViewer.d.ts +91 -0
  24. package/dist/components/ModelViewer/QueriesGroup.d.ts +15 -0
  25. package/dist/components/ModelViewer/RowGlyph.d.ts +27 -0
  26. package/dist/components/ModelViewer/RunResult.d.ts +46 -0
  27. package/dist/components/ModelViewer/SampleValues.d.ts +20 -0
  28. package/dist/components/ModelViewer/SchemaJoin.d.ts +51 -0
  29. package/dist/components/ModelViewer/SchemaView.d.ts +52 -0
  30. package/dist/components/ModelViewer/SegmentIcons.d.ts +70 -0
  31. package/dist/components/ModelViewer/SourcesDropdown.d.ts +53 -0
  32. package/dist/components/ModelViewer/SourcesNav.d.ts +25 -0
  33. package/dist/components/ModelViewer/StatusPill.d.ts +56 -0
  34. package/dist/components/ModelViewer/ValueChip.d.ts +17 -0
  35. package/dist/components/ModelViewer/ViewRow.d.ts +36 -0
  36. package/dist/components/ModelViewer/clickableBox.d.ts +29 -0
  37. package/dist/components/ModelViewer/codeDisplay.d.ts +44 -0
  38. package/dist/components/ModelViewer/docAnnotations.d.ts +90 -0
  39. package/dist/components/ModelViewer/explorerModel.d.ts +12 -0
  40. package/dist/components/ModelViewer/extensions.d.ts +94 -0
  41. package/dist/components/ModelViewer/fieldCode.d.ts +74 -0
  42. package/dist/components/ModelViewer/fieldEntities.d.ts +45 -0
  43. package/dist/components/ModelViewer/fieldExpansion.d.ts +41 -0
  44. package/dist/components/ModelViewer/givenUsage.d.ts +71 -0
  45. package/dist/components/ModelViewer/headerCard.d.ts +31 -0
  46. package/dist/components/ModelViewer/httpStatus.d.ts +4 -0
  47. package/dist/components/ModelViewer/icons.d.ts +31 -0
  48. package/dist/components/ModelViewer/index.d.ts +9 -0
  49. package/dist/components/ModelViewer/joinAccess.d.ts +52 -0
  50. package/dist/components/ModelViewer/malloyRunText.d.ts +22 -0
  51. package/dist/components/ModelViewer/malloyText.d.ts +21 -0
  52. package/dist/components/ModelViewer/modelGivens.d.ts +61 -0
  53. package/dist/components/ModelViewer/modelGivensContext.d.ts +9 -0
  54. package/dist/components/ModelViewer/modelHeaderPresentation.d.ts +28 -0
  55. package/dist/components/ModelViewer/modelTextDeclarations.d.ts +32 -0
  56. package/dist/components/ModelViewer/modelTextParse.d.ts +27 -0
  57. package/dist/components/ModelViewer/namedQueryCode.d.ts +12 -0
  58. package/dist/components/ModelViewer/offSurface.d.ts +54 -0
  59. package/dist/components/ModelViewer/rowLayers.d.ts +30 -0
  60. package/dist/components/ModelViewer/runGate.d.ts +49 -0
  61. package/dist/components/ModelViewer/schemaModel.d.ts +109 -0
  62. package/dist/components/ModelViewer/sectionOpenCommand.d.ts +45 -0
  63. package/dist/components/ModelViewer/sourceAccess.d.ts +67 -0
  64. package/dist/components/ModelViewer/sourceLineage.d.ts +14 -0
  65. package/dist/components/ModelViewer/sourcePicker.d.ts +66 -0
  66. package/dist/components/ModelViewer/surface.d.ts +47 -0
  67. package/dist/components/ModelViewer/text.d.ts +6 -0
  68. package/dist/components/ModelViewer/theme.d.ts +63 -0
  69. package/dist/components/ModelViewer/tokens.d.ts +52 -0
  70. package/dist/components/ModelViewer/ui.d.ts +48 -0
  71. package/dist/components/ModelViewer/useDimensionSamples.d.ts +76 -0
  72. package/dist/components/ModelViewer/useModelSources.d.ts +92 -0
  73. package/dist/components/ModelViewer/useRunQuery.d.ts +115 -0
  74. package/dist/components/ReportBuilder/loadMalloy.d.ts +4 -0
  75. package/dist/components/ServerProvider.d.ts +15 -1
  76. package/dist/components/filter/utils.d.ts +1 -1
  77. package/dist/components/given/GivenInput.d.ts +7 -1
  78. package/dist/components/given/GivensPanel.d.ts +3 -1
  79. package/dist/components/given/filterSummary.d.ts +6 -0
  80. package/dist/components/given/useGivenUrlParams.d.ts +11 -0
  81. package/dist/components/index.d.ts +2 -1
  82. package/dist/components/modelPage.d.ts +36 -0
  83. package/dist/hooks/useDimensionalFilterRangeData.d.ts +9 -0
  84. package/dist/hooks/useSuggestOptions.d.ts +26 -2
  85. package/dist/index.cjs.js +47 -19
  86. package/dist/index.es.js +14281 -9879
  87. package/dist/useCompiledDocument--Z7vKZL5.cjs.js +143 -0
  88. package/dist/{useCompiledDocument-Utj2u8CG.es.js → useCompiledDocument-BnT2QpG0.es.js} +6975 -6893
  89. package/dist/utils/filterCondition.d.ts +14 -0
  90. package/dist/utils/malloyLiteral.d.ts +20 -1
  91. package/package.json +2 -2
  92. package/src/components/Model/ExplorerPage.tsx +269 -0
  93. package/src/components/Model/Model.tsx +66 -250
  94. package/src/components/Model/ModelExplorer.spec.tsx +64 -1
  95. package/src/components/ModelViewer/AccessChips.tsx +149 -0
  96. package/src/components/ModelViewer/EmptyRow.tsx +71 -0
  97. package/src/components/ModelViewer/Facts.tsx +46 -0
  98. package/src/components/ModelViewer/FieldGroup.tsx +137 -0
  99. package/src/components/ModelViewer/FieldRow.tsx +566 -0
  100. package/src/components/ModelViewer/GivenFacts.tsx +89 -0
  101. package/src/components/ModelViewer/HeaderBar.tsx +362 -0
  102. package/src/components/ModelViewer/InlineDoc.tsx +50 -0
  103. package/src/components/ModelViewer/ModelGivensSection.tsx +142 -0
  104. package/src/components/ModelViewer/ModelSection.tsx +98 -0
  105. package/src/components/ModelViewer/ModelViewer.spec.tsx +937 -0
  106. package/src/components/ModelViewer/ModelViewer.tsx +777 -0
  107. package/src/components/ModelViewer/QueriesGroup.tsx +107 -0
  108. package/src/components/ModelViewer/RowGlyph.tsx +138 -0
  109. package/src/components/ModelViewer/RunResult.tsx +298 -0
  110. package/src/components/ModelViewer/SampleValues.tsx +97 -0
  111. package/src/components/ModelViewer/SchemaJoin.tsx +258 -0
  112. package/src/components/ModelViewer/SchemaView.tsx +222 -0
  113. package/src/components/ModelViewer/SegmentIcons.tsx +129 -0
  114. package/src/components/ModelViewer/SourcesDropdown.tsx +265 -0
  115. package/src/components/ModelViewer/SourcesNav.tsx +75 -0
  116. package/src/components/ModelViewer/StatusPill.tsx +145 -0
  117. package/src/components/ModelViewer/ValueChip.tsx +39 -0
  118. package/src/components/ModelViewer/ViewRow.tsx +274 -0
  119. package/src/components/ModelViewer/clickableBox.ts +59 -0
  120. package/src/components/ModelViewer/codeDisplay.spec.ts +176 -0
  121. package/src/components/ModelViewer/codeDisplay.ts +118 -0
  122. package/src/components/ModelViewer/docAnnotations.spec.ts +181 -0
  123. package/src/components/ModelViewer/docAnnotations.ts +244 -0
  124. package/src/components/ModelViewer/docAnnotations.typeDetail.spec.ts +114 -0
  125. package/src/components/ModelViewer/explorerModel.spec.ts +43 -0
  126. package/src/components/ModelViewer/explorerModel.ts +31 -0
  127. package/src/components/ModelViewer/extensions.tsx +112 -0
  128. package/src/components/ModelViewer/fieldCode.spec.ts +168 -0
  129. package/src/components/ModelViewer/fieldCode.ts +118 -0
  130. package/src/components/ModelViewer/fieldEntities.ts +63 -0
  131. package/src/components/ModelViewer/fieldExpansion.spec.ts +116 -0
  132. package/src/components/ModelViewer/fieldExpansion.ts +95 -0
  133. package/src/components/ModelViewer/givenUsage.spec.ts +304 -0
  134. package/src/components/ModelViewer/givenUsage.ts +325 -0
  135. package/src/components/ModelViewer/headerCard.tsx +102 -0
  136. package/src/components/ModelViewer/httpStatus.ts +15 -0
  137. package/src/components/ModelViewer/icons.tsx +67 -0
  138. package/src/components/ModelViewer/index.ts +26 -0
  139. package/src/components/ModelViewer/joinAccess.spec.ts +95 -0
  140. package/src/components/ModelViewer/joinAccess.ts +54 -0
  141. package/src/components/ModelViewer/malloyRunText.spec.ts +48 -0
  142. package/src/components/ModelViewer/malloyRunText.ts +51 -0
  143. package/src/components/ModelViewer/malloyText.spec.ts +47 -0
  144. package/src/components/ModelViewer/malloyText.ts +77 -0
  145. package/src/components/ModelViewer/modelGivens.ts +228 -0
  146. package/src/components/ModelViewer/modelGivensContext.ts +13 -0
  147. package/src/components/ModelViewer/modelHeaderPresentation.spec.ts +31 -0
  148. package/src/components/ModelViewer/modelHeaderPresentation.ts +41 -0
  149. package/src/components/ModelViewer/modelTextDeclarations.spec.ts +336 -0
  150. package/src/components/ModelViewer/modelTextDeclarations.ts +228 -0
  151. package/src/components/ModelViewer/modelTextParse.ts +112 -0
  152. package/src/components/ModelViewer/namedQueryCode.spec.ts +58 -0
  153. package/src/components/ModelViewer/namedQueryCode.ts +26 -0
  154. package/src/components/ModelViewer/offSurface.tsx +124 -0
  155. package/src/components/ModelViewer/rowLayers.tsx +104 -0
  156. package/src/components/ModelViewer/runGate.spec.ts +219 -0
  157. package/src/components/ModelViewer/runGate.ts +145 -0
  158. package/src/components/ModelViewer/schemaModel.defaultSource.spec.ts +126 -0
  159. package/src/components/ModelViewer/schemaModel.queries.spec.ts +37 -0
  160. package/src/components/ModelViewer/schemaModel.ts +300 -0
  161. package/src/components/ModelViewer/sectionOpenCommand.tsx +125 -0
  162. package/src/components/ModelViewer/sourceAccess.spec.ts +130 -0
  163. package/src/components/ModelViewer/sourceAccess.ts +194 -0
  164. package/src/components/ModelViewer/sourceLineage.spec.ts +73 -0
  165. package/src/components/ModelViewer/sourceLineage.ts +38 -0
  166. package/src/components/ModelViewer/sourcePicker.spec.ts +294 -0
  167. package/src/components/ModelViewer/sourcePicker.ts +162 -0
  168. package/src/components/ModelViewer/surface.ts +51 -0
  169. package/src/components/ModelViewer/text.tsx +33 -0
  170. package/src/components/ModelViewer/theme.spec.ts +38 -0
  171. package/src/components/ModelViewer/theme.ts +58 -0
  172. package/src/components/ModelViewer/tokens.ts +87 -0
  173. package/src/components/ModelViewer/ui.tsx +201 -0
  174. package/src/components/ModelViewer/useDimensionSamples.spec.tsx +139 -0
  175. package/src/components/ModelViewer/useDimensionSamples.ts +220 -0
  176. package/src/components/ModelViewer/useModelSources.spec.ts +110 -0
  177. package/src/components/ModelViewer/useModelSources.ts +238 -0
  178. package/src/components/ModelViewer/useRunQuery.spec.ts +50 -0
  179. package/src/components/ModelViewer/useRunQuery.ts +223 -0
  180. package/src/components/ReportBuilder/emptyStart.spec.ts +8 -0
  181. package/src/components/ReportBuilder/loadMalloy.ts +8 -1
  182. package/src/components/ServerProvider.tsx +27 -3
  183. package/src/components/filter/utils.ts +4 -60
  184. package/src/components/given/FilterButton.tsx +4 -1
  185. package/src/components/given/GivenInput.tsx +8 -0
  186. package/src/components/given/GivensPanel.tsx +6 -1
  187. package/src/components/given/filterSummary.spec.ts +31 -1
  188. package/src/components/given/filterSummary.ts +41 -19
  189. package/src/components/given/useGivenUrlParams.spec.tsx +32 -0
  190. package/src/components/given/useGivenUrlParams.ts +49 -14
  191. package/src/components/index.ts +6 -1
  192. package/src/components/legacy/malloynb/Notebook.spec.tsx +38 -4
  193. package/src/components/legacy/malloynb/NotebookCell.tsx +8 -2
  194. package/src/components/modelPage.spec.ts +79 -0
  195. package/src/components/modelPage.ts +48 -0
  196. package/src/hooks/useDimensionFilters.ts +3 -58
  197. package/src/hooks/useDimensionFiltersQuery.ts +3 -58
  198. package/src/hooks/useDimensionalFilterRangeData.spec.ts +57 -0
  199. package/src/hooks/useDimensionalFilterRangeData.ts +8 -63
  200. package/src/hooks/useSuggestOptions.dom.spec.ts +54 -1
  201. package/src/hooks/useSuggestOptions.spec.ts +71 -0
  202. package/src/hooks/useSuggestOptions.ts +102 -12
  203. package/src/utils/filterCondition.spec.ts +87 -0
  204. package/src/utils/filterCondition.ts +66 -0
  205. package/src/utils/malloyLiteral.spec.ts +53 -1
  206. package/src/utils/malloyLiteral.ts +47 -12
  207. package/dist/ServerProvider-BvD7PYZ7.cjs.js +0 -1
  208. package/dist/useCompiledDocument-CRhFBKv_.cjs.js +0 -142
@@ -0,0 +1,109 @@
1
+ import { AccentName } from './tokens';
2
+ import { ModelNamedQuery } from './useModelSources';
3
+ import type * as Malloy from "@malloydata/malloy-interfaces";
4
+ /**
5
+ * Render-ready view model for the model viewer, flattened from the compiled
6
+ * `Malloy.SourceInfo` metadata.
7
+ *
8
+ * SourceInfo doesn't expose everything the design mock shows — table name,
9
+ * grain, primary key, measure expressions, join `on` conditions, and view
10
+ * group-by/aggregate breakdowns aren't in the compiled metadata, so the
11
+ * explorer renders only name / type / docstring / join relationship. If the
12
+ * model API grows those fields, extend these types rather than re-deriving
13
+ * in components.
14
+ */
15
+ export interface ExplorerField {
16
+ name: string;
17
+ kind: "dimension" | "measure" | "calculate" | "view";
18
+ /** Type with its detail, e.g. "string", "number · integer", "date · month",
19
+ * "array<string>": dimensions, measures and calculations only. */
20
+ dataType?: string;
21
+ /** A record type's fields, one per line, for the type chip's tooltip. */
22
+ typeTip?: string;
23
+ doc?: string;
24
+ /** True when the dimension carries `#(index)` / `#(index_values)` —
25
+ * its values can be fetched from the dimensional index. */
26
+ indexed?: boolean;
27
+ /** True when the measure carries `#@ preaggregate` — it is DECLARED to roll
28
+ * up into a table at some grain. Says nothing about whether one has been
29
+ * built; that is the measure's binding. */
30
+ preaggregate?: boolean;
31
+ /** Author-facing tags from the non-doc annotation lines: a view's renderer
32
+ * tags (`bar_chart`, `size=lg`), a field's display tags (`label="Revenue"`,
33
+ * `currency`, `percent`). */
34
+ tags?: string[];
35
+ }
36
+ /**
37
+ * A model-level named query (`query: name is …`). Model-scoped, not a field of
38
+ * any source — so it is listed beside the sources in the rail, not inside one.
39
+ * The compiled metadata carries its name and annotations only (no definition:
40
+ * `modelInfo.entries` never includes queries, and a host's entities have no
41
+ * query kind), so a query is something to RUN rather than something to read.
42
+ */
43
+ export interface ExplorerQuery {
44
+ name: string;
45
+ /** The source the query runs against, when the publisher reports it — the
46
+ * source whose required filters gate a run. */
47
+ sourceName?: string;
48
+ doc?: string;
49
+ /** Renderer/behavior tags (`bar_chart`, …), from the non-doc annotation lines. */
50
+ tags?: string[];
51
+ }
52
+ export interface ExplorerJoin {
53
+ name: string;
54
+ relationship: Malloy.Relationship;
55
+ doc?: string;
56
+ dimensions: ExplorerField[];
57
+ measures: ExplorerField[];
58
+ }
59
+ export interface ExplorerSource {
60
+ name: string;
61
+ doc?: string;
62
+ /** Each doc annotation, in order, inherited ones first (see `ownSourceDoc`). */
63
+ docParts?: string[];
64
+ accent: AccentName;
65
+ /** The source carries a `#@ persist` tag — served from a materialized
66
+ * table rather than computed live. */
67
+ persist?: boolean;
68
+ dimensions: ExplorerField[];
69
+ measures: ExplorerField[];
70
+ /** `calculate:` fields. */
71
+ calculations: ExplorerField[];
72
+ views: ExplorerField[];
73
+ joins: ExplorerJoin[];
74
+ }
75
+ /** Flatten one compiled source into the explorer view model. */
76
+ export declare function toExplorerSource(source: Malloy.SourceInfo, index: number): ExplorerSource;
77
+ /**
78
+ * Flatten the model's named queries. The publisher's `CompiledModel.queries`
79
+ * carries annotations as raw lines (not `Malloy.Annotation` objects), so they
80
+ * are wrapped to reuse the one doc/tag parser the fields use.
81
+ */
82
+ export declare function toExplorerQueries(queries: ReadonlyArray<ModelNamedQuery> | undefined): ExplorerQuery[];
83
+ /**
84
+ * The fields a source declares: its dimensions, measures, calculations and views.
85
+ *
86
+ * A join's own fields are NOT counted: the pane header's count has to add
87
+ * up to the group counts printed directly beneath it — Dimensions · N, Measures
88
+ * · N, Views · N — and counting fields reachable THROUGH a join made the header
89
+ * read higher than anything visible, with the difference buried inside a
90
+ * collapsed Joins group. A join is counted as a join, not as its fields.
91
+ */
92
+ export declare function fieldCount(source: ExplorerSource): number;
93
+ /**
94
+ * Which source a model opens on when the address names none.
95
+ *
96
+ * Declaration order is not a ranking. `flights.malloy` declares `carriers`
97
+ * first and `flights` last; `imdb.malloy` declares `people` first and `movies`
98
+ * last — so `sources[0]` opened both files on a lookup table while the source
99
+ * the file is about sat at the bottom of the rail.
100
+ *
101
+ * The signal is **views**: a source someone has written views over is one
102
+ * someone means to be read, and the analytically-central source is where the
103
+ * views accumulate. Ties break toward the file's namesake (`flights.malloy` →
104
+ * `flights`), then toward declaration order, so the pick is total and stable.
105
+ *
106
+ * Namesake alone would not do it: `imdb.malloy` has no `imdb` source, and its
107
+ * subject is `movies`. Views get both files right.
108
+ */
109
+ export declare function pickDefaultSource(sources: ExplorerSource[], modelPath?: string): ExplorerSource | null;
@@ -0,0 +1,45 @@
1
+ import { Context } from 'react';
2
+ /**
3
+ * A section's last "Expand" / "Collapse": every row in the section opens or
4
+ * shuts when `n` changes, then each is the reader's own again. Undefined until
5
+ * the reader asks, so a row starts shut.
6
+ */
7
+ export interface SectionOpenCommand {
8
+ open: boolean;
9
+ n: number;
10
+ }
11
+ export declare const SectionOpenCommandContext: Context<SectionOpenCommand>;
12
+ /**
13
+ * A row's open state, following its section's Expand / Collapse each time it is
14
+ * asked and the reader's own toggle in between.
15
+ */
16
+ export declare function useSectionOpen(): [
17
+ boolean,
18
+ (update: (open: boolean) => boolean) => void
19
+ ];
20
+ /**
21
+ * The Expand / Collapse control for a section: the chevron saying which way it goes, and
22
+ * an accessible name saying what it opens, its visible words first and then the rows they
23
+ * act on ("Expand all measures"), or why it can't. It changes what the section shows rather
24
+ * than acting on the page, so it is a quiet text link alone on the line under the section's
25
+ * title, in the caption voice, so it reads as part of the section's header.
26
+ */
27
+ export declare function SectionExpandButton({ allOpen, onToggle, noun, disabledReason, }: {
28
+ allOpen: boolean;
29
+ onToggle: () => void;
30
+ noun: readonly [string, string];
31
+ disabledReason?: string;
32
+ }): import("react/jsx-runtime").JSX.Element;
33
+ /**
34
+ * A section's Expand / Collapse and the command it sends its rows. Always in
35
+ * place on a page section, so the header never moves; disabled, with why, where
36
+ * no row has anything to open.
37
+ */
38
+ export declare function useSectionExpand({ noun, disabledReason, }: {
39
+ noun: readonly [string, string];
40
+ /** Set when no row in the section can open. */
41
+ disabledReason?: string;
42
+ }): {
43
+ command: SectionOpenCommand;
44
+ action: import("react/jsx-runtime").JSX.Element;
45
+ };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * What a source's access declarations say, read from the compiled model's
3
+ * `sources[]` (the publisher's `Source.authorize` and `Source.accessFilter`).
4
+ *
5
+ * Both lists are the RULE, never a verdict about the reader: the publisher is
6
+ * the only authority on whether a caller passes, and its docs forbid
7
+ * re-deriving that from these strings. So everything here answers "is this
8
+ * source restricted / row filtered, and what does the rule say", and nothing
9
+ * answers "can you query it".
10
+ */
11
+ export interface SourceAccess {
12
+ /** Effective `#(authorize)` expressions (own and inherited), AND-ed. */
13
+ authorize: string[];
14
+ /** Effective `#(access_filter)` expressions, AND-ed. */
15
+ accessFilter: string[];
16
+ }
17
+ /**
18
+ * Source name → its access declarations, for every source the compiled model
19
+ * lists. Shape-checked: through the router an older publisher sends neither
20
+ * field (or `null`), which reads as no declaration.
21
+ */
22
+ export declare function extractSourceAccess(body: unknown): Map<string, SourceAccess>;
23
+ /** The declarations of one source, or none. */
24
+ export declare function accessOf(bySource: ReadonlyMap<string, SourceAccess> | undefined, sourceName: string | undefined): SourceAccess;
25
+ /**
26
+ * Whether an `#(authorize)` rule locks the source. Read element-wise, as the
27
+ * publisher documents: the list is unlocked only when every element is the
28
+ * `"true"` sentinel (gates from different declaring sources AND together, so
29
+ * `["true", "'finance' in $GROUPS"]` is locked).
30
+ */
31
+ export declare function isRestricted(access: SourceAccess | undefined): boolean;
32
+ /** Whether an `#(access_filter)` scopes the source's rows per reader. */
33
+ export declare function isRowFiltered(access: SourceAccess | undefined): boolean;
34
+ /**
35
+ * Who the `#(authorize)` rule admits, in plain words: "members of finance".
36
+ * Several rules all apply, so they are joined with "and"; a rule this cannot
37
+ * say becomes "readers its access rule admits" rather than a guess.
38
+ */
39
+ export declare function restrictedToWords(access: SourceAccess): string;
40
+ /** What a Restricted chip's tooltip and accessible name say. */
41
+ export declare const RESTRICTED_MEANING = "Only some readers can query this source";
42
+ /** What a Row filtered chip's tooltip and accessible name say. */
43
+ export declare const ROW_FILTERED_MEANING = "Each reader sees only the rows they're allowed to see";
44
+ /**
45
+ * What a refused (403) run says: that the reader can't access the source, a
46
+ * restricted source's rule in words, and the way out — never a status code, and
47
+ * no Retry, since a second attempt meets the same rule. A 403 on a source with no
48
+ * rule this page knows (a package-level refusal, a rule the compiled model did
49
+ * not report) still says so in the same words.
50
+ */
51
+ export declare function refusalMessage(sourceName: string | undefined, access: SourceAccess): string;
52
+ /**
53
+ * The caption under an empty result on a row-filtered source: an access filter
54
+ * that admits none of a reader's rows answers 200 with zero rows, which reads as
55
+ * "there is no data" unless the page says why. Only for zero rows: an ungrouped
56
+ * aggregate over nothing returns one row (`count()` = 0), which the caption
57
+ * cannot tell from a real zero, so it says nothing there.
58
+ */
59
+ export declare function filteredEmptyCaption(access: SourceAccess, result: string | undefined): string | undefined;
60
+ /** Whether the source declares either rule, so there is something to show. */
61
+ export declare function hasAccessRules(access: SourceAccess | undefined): boolean;
62
+ /**
63
+ * What an editor is told on an open join to a gated source: a gate applies only
64
+ * on the source a query enters through, so through this join the joined
65
+ * source's rows are read under this source's rules, not its own.
66
+ */
67
+ export declare function joinGateWarning(sourceName: string, access: SourceAccess): string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The immediate upstream SOURCE a derived source is built from, parsed from the
3
+ * model's own Malloy text — e.g. `raw_orders` for
4
+ * `source: order_rollup is raw_orders -> { … }`.
5
+ *
6
+ * Only a source-to-source derivation resolves. A table-backed source
7
+ * (`is conn.table('…')`, `is conn.sql('…')`) returns undefined — it has
8
+ * physical table provenance the header shows instead — and the parsed base
9
+ * must be one of the model's own sources, so a connection name or SQL slice is
10
+ * never mistaken for lineage. This is a best-effort read of source text: when
11
+ * the text is absent, or the declaration takes a form this doesn't recognise,
12
+ * it yields undefined and the header simply shows no `from`.
13
+ */
14
+ export declare function baseSourceName(sourceText: string | undefined, sourceName: string | undefined, knownSources: ReadonlySet<string>): string | undefined;
@@ -0,0 +1,66 @@
1
+ import { ExplorerSource } from './schemaModel';
2
+ /**
3
+ * The row's meta line: "16 views · 37 fields · 4 joins". The field count is the one the
4
+ * source's own header prints once it is picked (`fieldCount`), so the picker and the page it
5
+ * opens never disagree; joins are left out when there are none.
6
+ */
7
+ export declare function sourceMetaLine(source: ExplorerSource): string;
8
+ /** The picker's sources in the order it lists them, and the one its token marks. */
9
+ export interface PickerOrder {
10
+ sources: ExplorerSource[];
11
+ /** True on the package's root `index.malloy`, on the surface: its sources are the curated
12
+ * set, and the pill counts them as public. */
13
+ curated: boolean;
14
+ /** The curated sources are listed as the file's `export { … }` orders them, so the picker's
15
+ * header may say so. False when the file's text, and so its order, is unknown. */
16
+ exportOrdered: boolean;
17
+ /** The source the model opens on, when it really has the most views — the "Most views"
18
+ * token. Never set when the claim would be false. */
19
+ mostViews?: string;
20
+ }
21
+ /**
22
+ * The order the picker lists a model's sources in.
23
+ *
24
+ * - On the package's root `index.malloy`, when it is on the surface (`publicSurface`), the file
25
+ * IS the author's choice of what to publish, so its sources keep the order it exports them
26
+ * in, when its text says (`inExportOrder`); else the compiled model's, and `exportOrdered`
27
+ * is false so nothing claims an order.
28
+ * - On any other model, declaration order is not a ranking (`pickDefaultSource`), so the
29
+ * source the model opens on comes first and the rest follow by view count, most first;
30
+ * equal counts keep declaration order. A lookup table with no views sinks to the end.
31
+ *
32
+ * `mostViews` names the default only when no other source has more views than it and it has
33
+ * any: `pickDefaultSource` sets aside a source that extends another, so the default can be
34
+ * the base with fewer views than its extension, and the token must not claim otherwise.
35
+ */
36
+ export declare function orderPickerSources(sources: readonly ExplorerSource[], defaultSource: ExplorerSource | null,
37
+ /** Set on the root `index.malloy` on the surface: the names its `export { … }` lists, in
38
+ * order (`exportOrder`), empty when its text is unknown. */
39
+ publicSurface?: {
40
+ exportOrder: readonly string[];
41
+ }): PickerOrder;
42
+ /**
43
+ * The names a model file's `export { … }` statements list, in the order written. The compiled
44
+ * model lists its exports in declaration order (an imported source where the import brings it
45
+ * in), which is not the order an `index.malloy`'s author chose, so the text is read for it.
46
+ * Each item is a bare identifier (Malloy's `exportItem`), backquoted or not; the keyword is
47
+ * matched without case, as Malloy's are, and comments are skipped. Empty when the text is
48
+ * unknown or has no export statement.
49
+ */
50
+ export declare function exportOrder(sourceText: string | undefined): string[];
51
+ /**
52
+ * `items` in the order `order` names them; anything it does not name keeps its place after
53
+ * them, in the order given. Unchanged when `order` is empty.
54
+ */
55
+ export declare function inExportOrder<T>(items: readonly T[], nameOf: (item: T) => string, order: readonly string[]): T[];
56
+ /** A row's description: the author's words, else a host's generated one, marked. */
57
+ export interface PickerDescription {
58
+ text: string;
59
+ /** From the host, not the model's author: the row marks it Generated. */
60
+ generated: boolean;
61
+ }
62
+ /**
63
+ * The row's description: the source's own `#(doc)` when it has one — the author's words win —
64
+ * else a host's summary (`describePickerSource`), marked as generated. Nothing when neither.
65
+ */
66
+ export declare function pickerDescription(doc: string | undefined, summary: string | undefined): PickerDescription | undefined;
@@ -0,0 +1,47 @@
1
+ /** The model viewer's page column and pane geometry. */
2
+ /** The page's reading column. */
3
+ export declare const CONTENT_COLUMN_SX: {
4
+ readonly width: "100%";
5
+ readonly maxWidth: "1200px";
6
+ readonly mx: "auto";
7
+ };
8
+ /** The gap between a page's header and its first line (theme spacing units). */
9
+ export declare const FILE_VIEW_TOP_GAP = 3;
10
+ /** A card's inner inset (theme spacing units). */
11
+ export declare const PANE_INSET = 1.5;
12
+ /**
13
+ * A read-only card: bordered, rounded, on the paper colour. Text's I-beam
14
+ * cursor advertises an edit these cards don't offer, so the default cursor is
15
+ * set once; anything interactive declares `pointer`.
16
+ */
17
+ export declare const PANE_CARD_SX: {
18
+ readonly display: "flex";
19
+ readonly flexDirection: "column";
20
+ readonly minWidth: 0;
21
+ readonly minHeight: 0;
22
+ readonly border: "1px solid";
23
+ readonly borderColor: "divider";
24
+ readonly borderRadius: 2;
25
+ readonly bgcolor: "background.paper";
26
+ readonly overflow: "hidden";
27
+ readonly cursor: "default";
28
+ };
29
+ /** The same pane with no card around it: the page's own surface. */
30
+ export declare const FLAT_PANE_SX: {
31
+ readonly border: "none";
32
+ readonly borderRadius: 0;
33
+ readonly bgcolor: "transparent";
34
+ readonly overflow: "visible";
35
+ readonly display: "flex";
36
+ readonly flexDirection: "column";
37
+ readonly minWidth: 0;
38
+ readonly minHeight: 0;
39
+ readonly borderColor: "divider";
40
+ readonly cursor: "default";
41
+ };
42
+ /** A pane's body, under its header. */
43
+ export declare const PANE_BODY_SX: {
44
+ readonly flex: 1;
45
+ readonly minHeight: 0;
46
+ readonly py: 1;
47
+ };
@@ -0,0 +1,6 @@
1
+ import { TypographyProps } from '@mui/material';
2
+ import { ForwardRefExoticComponent, RefAttributes } from 'react';
3
+ /** Secondary body text: a row's explanation, an empty state's line. */
4
+ export declare const BodyText: ForwardRefExoticComponent<Omit<TypographyProps, "ref"> & RefAttributes<HTMLSpanElement>>;
5
+ /** Caption text: a note under a result, a meta line. */
6
+ export declare const CaptionText: ForwardRefExoticComponent<Omit<TypographyProps, "ref"> & RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The model viewer's type steps and colour roles, in one place so the rows,
3
+ * pills and cards are set from the same few values. Built on the SDK palette.
4
+ *
5
+ * Every neutral is one of MUI's own palette keys (`text.*`, `action.*`), which
6
+ * every theme defines in both modes, never a hex or a key only some hosts add:
7
+ * a fixed light grey was a near-white pill under light text in a dark theme.
8
+ * So each role is for an `sx` colour prop, where MUI resolves it.
9
+ */
10
+ /** The custom property the viewer's root sets from the host's `ui.font.mono`. */
11
+ export declare const MONO_FONT_VAR = "--model-viewer-mono";
12
+ /** The viewer's code face: the host theme's mono face, set on the viewer's root. */
13
+ export declare const MONO_FONT_FAMILY = "var(--model-viewer-mono, \"JetBrains Mono\", \"ui-monospace\", \"SFMono-Regular\", \"Menlo\", monospace)";
14
+ export declare const SANS_FONT_FAMILY = "inherit";
15
+ export declare const fontSizes: {
16
+ /** 11px: the floor, for a pill's text. */
17
+ readonly micro: "0.6875rem";
18
+ /** 12px: secondary row detail. */
19
+ readonly caption: "0.75rem";
20
+ /** 13px: dense rows. */
21
+ readonly small: "0.8125rem";
22
+ /** 14px: body. */
23
+ readonly body: "0.875rem";
24
+ /** 16px: prose meant to be read at length. */
25
+ readonly bodyLarge: "1rem";
26
+ };
27
+ export declare const fontWeights: {
28
+ readonly regular: 400;
29
+ readonly medium: 500;
30
+ readonly strong: 500;
31
+ };
32
+ export declare const roles: {
33
+ readonly text: {
34
+ readonly primary: "text.primary";
35
+ readonly secondary: "text.secondary";
36
+ readonly tertiary: "text.disabled";
37
+ };
38
+ /** A row's hover and a quiet pill's fill, then one step up: a selected row, a pill on a hovered row. */
39
+ readonly background: {
40
+ readonly muted: "action.hover";
41
+ readonly strong: "action.selected";
42
+ };
43
+ readonly accent: {
44
+ readonly sage: {
45
+ tint: string;
46
+ onTint: string;
47
+ };
48
+ };
49
+ readonly warning: {
50
+ tint: string;
51
+ onTint: string;
52
+ };
53
+ readonly error: {
54
+ tint: string;
55
+ onTint: string;
56
+ };
57
+ readonly info: {
58
+ tint: string;
59
+ onTint: string;
60
+ };
61
+ };
62
+ /** Tertiary text: lighter than MUI's `text.secondary`, for a row's least words. */
63
+ export declare const TEXT_TERTIARY: "text.disabled";
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Design tokens for the model viewer: its accents and its type scale, drawn
3
+ * from the SDK's palette so the viewer reads as part of the same Console.
4
+ */
5
+ export declare const ink = "text.primary";
6
+ export type AccentName = "steel" | "sage" | "brown" | "olive" | "amber";
7
+ /** An accent hue: `main` for a fill or glyph, `tint` behind it, `onTint` on top of `tint`. */
8
+ export interface Accent {
9
+ main: string;
10
+ tint: string;
11
+ onTint: string;
12
+ }
13
+ export declare const ACCENT: Record<AccentName, Accent>;
14
+ /**
15
+ * Accent per field kind: steel = dimensions, sage = measures, amber =
16
+ * calculations, olive = views. Joins render brown (see SchemaJoin).
17
+ */
18
+ export declare function kindAccent(kind: "dimension" | "measure" | "calculate" | "view"): Accent;
19
+ export declare function sourceAccentName(index: number): AccentName;
20
+ /** The type scale the rows are set in. */
21
+ export declare const FONT_SIZE: {
22
+ readonly body: 14;
23
+ readonly small: 13;
24
+ readonly caption: 12;
25
+ };
26
+ /**
27
+ * The identifier style for a CONTAINER row (a join): a thing you open to find
28
+ * more things. Mono, because it exists verbatim in a .malloy file. One step
29
+ * above the leaf rows it holds ({@link ENTITY_NAME_SX}).
30
+ */
31
+ export declare const CONTAINER_NAME_SX: {
32
+ readonly fontFamily: "var(--model-viewer-mono, \"JetBrains Mono\", \"ui-monospace\", \"SFMono-Regular\", \"Menlo\", monospace)";
33
+ readonly fontSize: 14;
34
+ readonly fontWeight: 500;
35
+ readonly color: "text.primary";
36
+ };
37
+ /** The identifier style for a LEAF row (a field): the thing you came to read. */
38
+ export declare const ENTITY_NAME_SX: {
39
+ readonly fontFamily: "var(--model-viewer-mono, \"JetBrains Mono\", \"ui-monospace\", \"SFMono-Regular\", \"Menlo\", monospace)";
40
+ readonly fontSize: 13;
41
+ readonly fontWeight: 500;
42
+ readonly color: "text.primary";
43
+ };
44
+ /**
45
+ * The secondary voice beside a row's name: a type annotation (`string`,
46
+ * `number`) or a dimmed count. Sans on purpose: it describes the row, it isn't
47
+ * a token you would type.
48
+ */
49
+ export declare const ROW_META_SX: {
50
+ readonly fontSize: 12;
51
+ readonly color: "text.secondary";
52
+ };
@@ -0,0 +1,48 @@
1
+ import { ButtonProps } from '@mui/material';
2
+ import { ReactNode, ForwardRefExoticComponent, RefAttributes } from 'react';
3
+ /**
4
+ * Malloy, highlighted, in a read-only block: a field's definition, a view's
5
+ * code, the query a failed run sent. Plain text until the highlighter answers,
6
+ * so the code is readable on the first frame.
7
+ */
8
+ export declare function QueryCode({ code, testId, framed, }: {
9
+ code: string;
10
+ testId?: string;
11
+ /** False: the code as one section of a card someone else frames (an open field row's). */
12
+ framed?: boolean;
13
+ }): import("react/jsx-runtime").JSX.Element;
14
+ /** A read that failed, in place of what it would have shown, with a Retry where one can help. */
15
+ export declare function LoadErrorAlert({ message, onRetry, severity, }: {
16
+ message: ReactNode;
17
+ onRetry?: () => void;
18
+ severity?: "error" | "warning";
19
+ }): import("react/jsx-runtime").JSX.Element;
20
+ /** The server's own reason for a failed request (its Error body's `message`), if it gave one. */
21
+ export declare function serverMessage(error: unknown): string | undefined;
22
+ /** The server's own reason for a failed request, else what was being done. */
23
+ export declare function describeApiError(context: string, error: unknown): string;
24
+ /**
25
+ * Can re-sending this query succeed? Not for a 400 (the query does not compile)
26
+ * or a 422 (a value it refuses), which hold until the query or the value
27
+ * changes, nor for a refusal (401/403/404).
28
+ */
29
+ export declare function isRetryableQueryFailure(error: unknown): boolean;
30
+ /**
31
+ * A failed query, wherever a result would have been. The query is shown
32
+ * verbatim above the error, so a compile error's `line:column` points into text
33
+ * the reader can see, and Retry is offered only when a second attempt can
34
+ * succeed.
35
+ */
36
+ export declare function QueryFailure({ query, error, onRetry, testId, forbiddenMessage, }: {
37
+ /** The query as it was sent; omitted when there is none to show. */
38
+ query?: string;
39
+ error: unknown;
40
+ onRetry?: () => void;
41
+ testId?: string;
42
+ /** What a refusal (403) says, where the caller knows the rule that refused it. */
43
+ forbiddenMessage?: string;
44
+ }): import("react/jsx-runtime").JSX.Element;
45
+ /** The one filled action on a card: Run. */
46
+ export declare const PrimaryButton: ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & RefAttributes<HTMLButtonElement>>;
47
+ /** A rounded, quiet button that opens a menu: the sources picker. */
48
+ export declare const PillButton: ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,76 @@
1
+ import { ExplorerField } from './schemaModel';
2
+ import { RunContext } from './useRunQuery';
3
+ export declare const SAMPLE_LIMIT = 12;
4
+ /** What a host's sample fetcher is asked for. */
5
+ export interface SampleValuesRequest {
6
+ modelPath: string;
7
+ sourceName: string;
8
+ fieldName: string;
9
+ /** At most this many values are shown. */
10
+ limit: number;
11
+ signal?: AbortSignal;
12
+ }
13
+ /** What a host's sample fetcher can say beyond the values themselves. */
14
+ export interface SampleValuesPage {
15
+ /** The most common values, most common first. */
16
+ values: string[];
17
+ /** How many distinct values the dimension has, for the card's caption. */
18
+ total?: number | null;
19
+ /** Why there are none to show ("the index is still building"), said in their place. */
20
+ unavailable?: string;
21
+ }
22
+ /**
23
+ * A host's way to read a dimension's sample values (an index it maintains, say)
24
+ * instead of the viewer's own query: the values alone, or a
25
+ * {@link SampleValuesPage}. Rejecting with a 4xx that says the field has nothing
26
+ * to sample reads as "no values" (see {@link isExpectedNoSamples}).
27
+ */
28
+ export type SampleValuesFetcher = (request: SampleValuesRequest) => Promise<string[] | SampleValuesPage>;
29
+ interface UseDimensionSamplesArgs {
30
+ run: RunContext;
31
+ /** Model path the source belongs to (e.g. "flights.malloy"). */
32
+ modelPath: string;
33
+ /** Source the selected field belongs to. */
34
+ sourceName: string;
35
+ /** The field to sample, or null while the card is collapsed (hook idles). */
36
+ field: ExplorerField | null;
37
+ /** The host's fetcher; the viewer runs {@link sampleValuesQuery} without one. */
38
+ fetchSamples?: SampleValuesFetcher;
39
+ /** A host's build of the values it serves: a new one is a new cache entry,
40
+ * so a reopened row never shows the old values. */
41
+ generation?: string;
42
+ }
43
+ /**
44
+ * Whether a rejected sample read is an answer that the dimension simply has
45
+ * nothing to sample, so the card says "no values" rather than "couldn't be
46
+ * loaded": a client error, except the ones that say nothing about the field (a
47
+ * lapsed session 401, a timeout 408, a rate limit 429). Every 5xx, and every
48
+ * rejection with no status (the network), is a read that failed.
49
+ */
50
+ export declare function isExpectedNoSamples(error: unknown): boolean;
51
+ /** The first column of each row of a result, as text. */
52
+ export declare function firstColumnValues(resultJson: string | undefined): string[];
53
+ /**
54
+ * Lazily fetch sample values for a dimension. Only for dimensions the model tags
55
+ * `#(index)` / `#(index_values)`: the tag is the modeler saying its values are
56
+ * worth listing, and without it opening a row costs nothing. Everything else
57
+ * resolves to "no samples", as does a host's refusal that answers the question.
58
+ * Any other error is reported as `failed`, never as an empty list: the card
59
+ * must not say there are no values when it could not ask.
60
+ *
61
+ * Without a host fetcher this is one capped `group_by` query through the
62
+ * Publisher, run as a view's is (`runQueryOptions`: the same request, cache
63
+ * and `onQueryRun`), with the given values of the givens its source reads, and
64
+ * gated the same way. Shared by every mount: opening, shutting and reopening a
65
+ * row reads it once.
66
+ */
67
+ export declare function useDimensionSamples({ run, modelPath, sourceName, field, fetchSamples, generation, }: UseDimensionSamplesArgs): {
68
+ samples: string[];
69
+ /** How many distinct values there are, when a host says. */
70
+ total?: number | null;
71
+ /** Why there are none: a host's reason, or the given a run needs first. */
72
+ unavailable?: string;
73
+ loading: boolean;
74
+ failed: boolean;
75
+ };
76
+ export {};