@malloy-publisher/sdk 0.12.0 → 0.12.2

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 (214) hide show
  1. package/README.md +79 -6
  2. package/dist/{RenderedResult-SgDlxzs9.cjs.js → RenderedResult-Cgw4iqev.cjs.js} +1 -1
  3. package/dist/{RenderedResult-D8bCgThO.es.js → RenderedResult-DEjFM1DL.es.js} +2 -2
  4. package/dist/ServerProvider-BRQl_cBo.cjs.js +1 -0
  5. package/dist/{ServerProvider-DBw-thY0.es.js → ServerProvider-RnliA2Ao.es.js} +1084 -723
  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 +754 -41
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +120 -110
  11. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +16 -1
  12. package/dist/components/Model/ExplorerPage.d.ts +9 -0
  13. package/dist/components/Model/Model.d.ts +27 -11
  14. package/dist/components/ModelViewer/AccessChips.d.ts +34 -0
  15. package/dist/components/ModelViewer/EmptyRow.d.ts +23 -0
  16. package/dist/components/ModelViewer/Facts.d.ts +15 -0
  17. package/dist/components/ModelViewer/FieldGroup.d.ts +31 -0
  18. package/dist/components/ModelViewer/FieldRow.d.ts +69 -0
  19. package/dist/components/ModelViewer/GivenFacts.d.ts +21 -0
  20. package/dist/components/ModelViewer/HeaderBar.d.ts +75 -0
  21. package/dist/components/ModelViewer/InlineDoc.d.ts +13 -0
  22. package/dist/components/ModelViewer/ModelGivensSection.d.ts +32 -0
  23. package/dist/components/ModelViewer/ModelSection.d.ts +21 -0
  24. package/dist/components/ModelViewer/ModelViewer.d.ts +91 -0
  25. package/dist/components/ModelViewer/QueriesGroup.d.ts +15 -0
  26. package/dist/components/ModelViewer/RowGlyph.d.ts +27 -0
  27. package/dist/components/ModelViewer/RunResult.d.ts +46 -0
  28. package/dist/components/ModelViewer/SampleValues.d.ts +20 -0
  29. package/dist/components/ModelViewer/SchemaJoin.d.ts +51 -0
  30. package/dist/components/ModelViewer/SchemaView.d.ts +52 -0
  31. package/dist/components/ModelViewer/SegmentIcons.d.ts +70 -0
  32. package/dist/components/ModelViewer/SourcesDropdown.d.ts +53 -0
  33. package/dist/components/ModelViewer/SourcesNav.d.ts +25 -0
  34. package/dist/components/ModelViewer/StatusPill.d.ts +56 -0
  35. package/dist/components/ModelViewer/ValueChip.d.ts +17 -0
  36. package/dist/components/ModelViewer/ViewRow.d.ts +36 -0
  37. package/dist/components/ModelViewer/clickableBox.d.ts +29 -0
  38. package/dist/components/ModelViewer/codeDisplay.d.ts +44 -0
  39. package/dist/components/ModelViewer/docAnnotations.d.ts +90 -0
  40. package/dist/components/ModelViewer/explorerModel.d.ts +12 -0
  41. package/dist/components/ModelViewer/extensions.d.ts +94 -0
  42. package/dist/components/ModelViewer/fieldCode.d.ts +74 -0
  43. package/dist/components/ModelViewer/fieldEntities.d.ts +45 -0
  44. package/dist/components/ModelViewer/fieldExpansion.d.ts +41 -0
  45. package/dist/components/ModelViewer/givenUsage.d.ts +71 -0
  46. package/dist/components/ModelViewer/headerCard.d.ts +31 -0
  47. package/dist/components/ModelViewer/httpStatus.d.ts +4 -0
  48. package/dist/components/ModelViewer/icons.d.ts +31 -0
  49. package/dist/components/ModelViewer/index.d.ts +9 -0
  50. package/dist/components/ModelViewer/joinAccess.d.ts +52 -0
  51. package/dist/components/ModelViewer/malloyRunText.d.ts +22 -0
  52. package/dist/components/ModelViewer/malloyText.d.ts +21 -0
  53. package/dist/components/ModelViewer/modelGivens.d.ts +61 -0
  54. package/dist/components/ModelViewer/modelGivensContext.d.ts +9 -0
  55. package/dist/components/ModelViewer/modelHeaderPresentation.d.ts +28 -0
  56. package/dist/components/ModelViewer/modelTextDeclarations.d.ts +32 -0
  57. package/dist/components/ModelViewer/modelTextParse.d.ts +27 -0
  58. package/dist/components/ModelViewer/namedQueryCode.d.ts +12 -0
  59. package/dist/components/ModelViewer/offSurface.d.ts +54 -0
  60. package/dist/components/ModelViewer/rowLayers.d.ts +30 -0
  61. package/dist/components/ModelViewer/runGate.d.ts +49 -0
  62. package/dist/components/ModelViewer/schemaModel.d.ts +109 -0
  63. package/dist/components/ModelViewer/sectionOpenCommand.d.ts +45 -0
  64. package/dist/components/ModelViewer/sourceAccess.d.ts +67 -0
  65. package/dist/components/ModelViewer/sourceLineage.d.ts +14 -0
  66. package/dist/components/ModelViewer/sourcePicker.d.ts +66 -0
  67. package/dist/components/ModelViewer/surface.d.ts +47 -0
  68. package/dist/components/ModelViewer/text.d.ts +6 -0
  69. package/dist/components/ModelViewer/theme.d.ts +63 -0
  70. package/dist/components/ModelViewer/tokens.d.ts +52 -0
  71. package/dist/components/ModelViewer/ui.d.ts +48 -0
  72. package/dist/components/ModelViewer/useDimensionSamples.d.ts +76 -0
  73. package/dist/components/ModelViewer/useModelSources.d.ts +92 -0
  74. package/dist/components/ModelViewer/useRunQuery.d.ts +115 -0
  75. package/dist/components/ReportBuilder/loadMalloy.d.ts +4 -0
  76. package/dist/components/ServerProvider.d.ts +17 -2
  77. package/dist/components/filter/utils.d.ts +1 -1
  78. package/dist/components/given/GivenInput.d.ts +7 -1
  79. package/dist/components/given/GivensPanel.d.ts +3 -1
  80. package/dist/components/given/filterSummary.d.ts +6 -0
  81. package/dist/components/given/useGivenUrlParams.d.ts +11 -0
  82. package/dist/components/index.d.ts +2 -1
  83. package/dist/components/modelPage.d.ts +36 -0
  84. package/dist/hooks/useDimensionalFilterRangeData.d.ts +9 -0
  85. package/dist/hooks/useSuggestOptions.d.ts +26 -2
  86. package/dist/index.cjs.js +47 -19
  87. package/dist/index.es.js +14137 -9697
  88. package/dist/useCompiledDocument-D88_2cGS.cjs.js +143 -0
  89. package/dist/{useCompiledDocument-CXMPtJkJ.es.js → useCompiledDocument-Dmm6xkom.es.js} +6975 -6893
  90. package/dist/utils/filterCondition.d.ts +14 -0
  91. package/dist/utils/malloyLiteral.d.ts +20 -1
  92. package/package.json +2 -2
  93. package/src/components/Materializations/MaterializationDetailDialog.tsx +33 -7
  94. package/src/components/Materializations/Materializations.tsx +47 -4
  95. package/src/components/Materializations/Materializations.versions.spec.tsx +140 -1
  96. package/src/components/Model/ExplorerPage.tsx +269 -0
  97. package/src/components/Model/Model.tsx +66 -250
  98. package/src/components/Model/ModelExplorer.spec.tsx +64 -1
  99. package/src/components/ModelViewer/AccessChips.tsx +149 -0
  100. package/src/components/ModelViewer/EmptyRow.tsx +71 -0
  101. package/src/components/ModelViewer/Facts.tsx +46 -0
  102. package/src/components/ModelViewer/FieldGroup.tsx +137 -0
  103. package/src/components/ModelViewer/FieldRow.tsx +566 -0
  104. package/src/components/ModelViewer/GivenFacts.tsx +89 -0
  105. package/src/components/ModelViewer/HeaderBar.tsx +362 -0
  106. package/src/components/ModelViewer/InlineDoc.tsx +50 -0
  107. package/src/components/ModelViewer/ModelGivensSection.tsx +142 -0
  108. package/src/components/ModelViewer/ModelSection.tsx +98 -0
  109. package/src/components/ModelViewer/ModelViewer.spec.tsx +937 -0
  110. package/src/components/ModelViewer/ModelViewer.tsx +777 -0
  111. package/src/components/ModelViewer/QueriesGroup.tsx +107 -0
  112. package/src/components/ModelViewer/RowGlyph.tsx +138 -0
  113. package/src/components/ModelViewer/RunResult.tsx +298 -0
  114. package/src/components/ModelViewer/SampleValues.tsx +97 -0
  115. package/src/components/ModelViewer/SchemaJoin.tsx +258 -0
  116. package/src/components/ModelViewer/SchemaView.tsx +222 -0
  117. package/src/components/ModelViewer/SegmentIcons.tsx +129 -0
  118. package/src/components/ModelViewer/SourcesDropdown.tsx +265 -0
  119. package/src/components/ModelViewer/SourcesNav.tsx +75 -0
  120. package/src/components/ModelViewer/StatusPill.tsx +145 -0
  121. package/src/components/ModelViewer/ValueChip.tsx +39 -0
  122. package/src/components/ModelViewer/ViewRow.tsx +274 -0
  123. package/src/components/ModelViewer/clickableBox.ts +59 -0
  124. package/src/components/ModelViewer/codeDisplay.spec.ts +176 -0
  125. package/src/components/ModelViewer/codeDisplay.ts +118 -0
  126. package/src/components/ModelViewer/docAnnotations.spec.ts +181 -0
  127. package/src/components/ModelViewer/docAnnotations.ts +244 -0
  128. package/src/components/ModelViewer/docAnnotations.typeDetail.spec.ts +114 -0
  129. package/src/components/ModelViewer/explorerModel.spec.ts +43 -0
  130. package/src/components/ModelViewer/explorerModel.ts +31 -0
  131. package/src/components/ModelViewer/extensions.tsx +112 -0
  132. package/src/components/ModelViewer/fieldCode.spec.ts +168 -0
  133. package/src/components/ModelViewer/fieldCode.ts +118 -0
  134. package/src/components/ModelViewer/fieldEntities.ts +63 -0
  135. package/src/components/ModelViewer/fieldExpansion.spec.ts +116 -0
  136. package/src/components/ModelViewer/fieldExpansion.ts +95 -0
  137. package/src/components/ModelViewer/givenUsage.spec.ts +304 -0
  138. package/src/components/ModelViewer/givenUsage.ts +325 -0
  139. package/src/components/ModelViewer/headerCard.tsx +102 -0
  140. package/src/components/ModelViewer/httpStatus.ts +15 -0
  141. package/src/components/ModelViewer/icons.tsx +67 -0
  142. package/src/components/ModelViewer/index.ts +26 -0
  143. package/src/components/ModelViewer/joinAccess.spec.ts +95 -0
  144. package/src/components/ModelViewer/joinAccess.ts +54 -0
  145. package/src/components/ModelViewer/malloyRunText.spec.ts +48 -0
  146. package/src/components/ModelViewer/malloyRunText.ts +51 -0
  147. package/src/components/ModelViewer/malloyText.spec.ts +47 -0
  148. package/src/components/ModelViewer/malloyText.ts +77 -0
  149. package/src/components/ModelViewer/modelGivens.ts +228 -0
  150. package/src/components/ModelViewer/modelGivensContext.ts +13 -0
  151. package/src/components/ModelViewer/modelHeaderPresentation.spec.ts +31 -0
  152. package/src/components/ModelViewer/modelHeaderPresentation.ts +41 -0
  153. package/src/components/ModelViewer/modelTextDeclarations.spec.ts +336 -0
  154. package/src/components/ModelViewer/modelTextDeclarations.ts +228 -0
  155. package/src/components/ModelViewer/modelTextParse.ts +112 -0
  156. package/src/components/ModelViewer/namedQueryCode.spec.ts +58 -0
  157. package/src/components/ModelViewer/namedQueryCode.ts +26 -0
  158. package/src/components/ModelViewer/offSurface.tsx +124 -0
  159. package/src/components/ModelViewer/rowLayers.tsx +104 -0
  160. package/src/components/ModelViewer/runGate.spec.ts +219 -0
  161. package/src/components/ModelViewer/runGate.ts +145 -0
  162. package/src/components/ModelViewer/schemaModel.defaultSource.spec.ts +126 -0
  163. package/src/components/ModelViewer/schemaModel.queries.spec.ts +37 -0
  164. package/src/components/ModelViewer/schemaModel.ts +300 -0
  165. package/src/components/ModelViewer/sectionOpenCommand.tsx +125 -0
  166. package/src/components/ModelViewer/sourceAccess.spec.ts +130 -0
  167. package/src/components/ModelViewer/sourceAccess.ts +194 -0
  168. package/src/components/ModelViewer/sourceLineage.spec.ts +73 -0
  169. package/src/components/ModelViewer/sourceLineage.ts +38 -0
  170. package/src/components/ModelViewer/sourcePicker.spec.ts +294 -0
  171. package/src/components/ModelViewer/sourcePicker.ts +162 -0
  172. package/src/components/ModelViewer/surface.ts +51 -0
  173. package/src/components/ModelViewer/text.tsx +33 -0
  174. package/src/components/ModelViewer/theme.spec.ts +38 -0
  175. package/src/components/ModelViewer/theme.ts +58 -0
  176. package/src/components/ModelViewer/tokens.ts +87 -0
  177. package/src/components/ModelViewer/ui.tsx +201 -0
  178. package/src/components/ModelViewer/useDimensionSamples.spec.tsx +139 -0
  179. package/src/components/ModelViewer/useDimensionSamples.ts +220 -0
  180. package/src/components/ModelViewer/useModelSources.spec.ts +110 -0
  181. package/src/components/ModelViewer/useModelSources.ts +238 -0
  182. package/src/components/ModelViewer/useRunQuery.spec.ts +50 -0
  183. package/src/components/ModelViewer/useRunQuery.ts +223 -0
  184. package/src/components/Package/Package.agents.spec.tsx +5 -4
  185. package/src/components/Package/Package.tsx +8 -1
  186. package/src/components/ReportBuilder/emptyStart.spec.ts +8 -0
  187. package/src/components/ReportBuilder/loadMalloy.ts +8 -1
  188. package/src/components/ServerProvider.tsx +29 -3
  189. package/src/components/filter/utils.ts +4 -60
  190. package/src/components/given/FilterButton.tsx +4 -1
  191. package/src/components/given/GivenInput.tsx +8 -0
  192. package/src/components/given/GivensPanel.tsx +6 -1
  193. package/src/components/given/filterSummary.spec.ts +31 -1
  194. package/src/components/given/filterSummary.ts +41 -19
  195. package/src/components/given/useGivenUrlParams.spec.tsx +32 -0
  196. package/src/components/given/useGivenUrlParams.ts +49 -14
  197. package/src/components/index.ts +6 -1
  198. package/src/components/legacy/malloynb/Notebook.spec.tsx +38 -4
  199. package/src/components/legacy/malloynb/NotebookCell.tsx +8 -2
  200. package/src/components/modelPage.spec.ts +79 -0
  201. package/src/components/modelPage.ts +48 -0
  202. package/src/hooks/useDimensionFilters.ts +3 -58
  203. package/src/hooks/useDimensionFiltersQuery.ts +3 -58
  204. package/src/hooks/useDimensionalFilterRangeData.spec.ts +57 -0
  205. package/src/hooks/useDimensionalFilterRangeData.ts +8 -63
  206. package/src/hooks/useSuggestOptions.dom.spec.ts +54 -1
  207. package/src/hooks/useSuggestOptions.spec.ts +71 -0
  208. package/src/hooks/useSuggestOptions.ts +102 -12
  209. package/src/utils/filterCondition.spec.ts +87 -0
  210. package/src/utils/filterCondition.ts +66 -0
  211. package/src/utils/malloyLiteral.spec.ts +53 -1
  212. package/src/utils/malloyLiteral.ts +47 -12
  213. package/dist/ServerProvider-BHfg1Ed6.cjs.js +0 -1
  214. package/dist/useCompiledDocument-D7X_K6YU.cjs.js +0 -142
@@ -0,0 +1,4 @@
1
+ /** The HTTP status a rejected request carries (axios's `response.status`), if any. */
2
+ export declare function httpStatusOf(error: unknown): number | undefined;
3
+ /** A refused read: 403, or 404 for something this caller may not know exists. */
4
+ export declare function isNotFoundOrForbidden(error: unknown): boolean;
@@ -0,0 +1,31 @@
1
+ import { ComponentType } from 'react';
2
+ /**
3
+ * The viewer's glyphs, each a Material icon drawn at a pixel size: `size` is
4
+ * the one prop a row passes, so a glyph is the same call whichever icon it is.
5
+ */
6
+ export interface IconProps {
7
+ size: number;
8
+ "aria-hidden"?: boolean;
9
+ }
10
+ export type Icon = ComponentType<IconProps>;
11
+ export declare const IconText: Icon;
12
+ export declare const IconOpen: Icon;
13
+ export declare const IconResult: Icon;
14
+ export declare const IconCalculation: Icon;
15
+ export declare const IconDate: Icon;
16
+ export declare const IconJoin: Icon;
17
+ export declare const IconCode: Icon;
18
+ export declare const IconList: Icon;
19
+ export declare const IconRecord: Icon;
20
+ export declare const IconCollapse: Icon;
21
+ export declare const IconExpand: Icon;
22
+ export declare const IconFields: Icon;
23
+ export declare const IconDropdown: Icon;
24
+ export declare const IconLock: Icon;
25
+ export declare const IconNumber: Icon;
26
+ export declare const IconTimestamp: Icon;
27
+ export declare const IconValues: Icon;
28
+ export declare const IconBoolean: Icon;
29
+ export declare const IconGivens: Icon;
30
+ export declare const IconColumn: Icon;
31
+ export declare const IconWarning: Icon;
@@ -0,0 +1,9 @@
1
+ export { ModelViewer, type ModelViewerProps } from './ModelViewer';
2
+ export { type FieldContext, type ModelViewerExtensions, type PickerSourceExtras, type RunActionContext, type SourceContext, } from './extensions';
3
+ export { groupEntitiesBySource, type FieldEntity, type FieldEntityTable, } from './fieldEntities';
4
+ export { malloyIdentifier } from './malloyRunText';
5
+ export type { ShownRun } from './RunResult';
6
+ export type { ExplorerField as ModelViewerField } from './schemaModel';
7
+ export type { SampleValuesFetcher, SampleValuesPage, SampleValuesRequest, } from './useDimensionSamples';
8
+ export { modelQueryKey } from './useModelSources';
9
+ export { runQueryKey, type QueryRunEvent } from './useRunQuery';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Whether a join's target source is a place you can go, or only something you
3
+ * can read through this join.
4
+ *
5
+ * A package curates what it serves: `explores` in the manifest picks the model
6
+ * files, `export {}` picks the sources within them, and the publisher omits
7
+ * everything else from `listModels`/`sourceInfos`. Those omitted sources still
8
+ * compile, import and join — a served source can legitimately join one — but
9
+ * they are not addressable, and with the default `queryableSources: "declared"`
10
+ * they are not directly queryable either.
11
+ *
12
+ * The join metadata comes from a host's entities, which may record every join
13
+ * the model compiles, curated or not. So the target of a join is not evidence
14
+ * that the target has a page. The browsable set — what the publisher actually
15
+ * served us — is.
16
+ *
17
+ * Showing the joined source's fields inline is a separate question and stays
18
+ * allowed: those fields are reachable through the join path at query time
19
+ * anyway, so the curation boundary is about entry points, not field secrecy.
20
+ */
21
+ export type JoinAccess =
22
+ /** Served as its own source: the row gets its "open" arrow. */
23
+ {
24
+ kind: "link";
25
+ }
26
+ /** Not served as its own source: reachable only through this join. */
27
+ | {
28
+ kind: "join-only";
29
+ }
30
+ /** Not established yet — say nothing rather than guess. */
31
+ | {
32
+ kind: "unknown";
33
+ };
34
+ export declare function joinAccess(target: {
35
+ modelPath: string;
36
+ sourceName: string;
37
+ } | undefined,
38
+ /**
39
+ * modelPath → the source names that model served, for every model whose
40
+ * source list has settled successfully. A model still in flight or whose
41
+ * fetch failed is simply absent (`unknown`), so a timeout cannot look like
42
+ * curation.
43
+ */
44
+ browsableByModel: ReadonlyMap<string, ReadonlySet<string>>): JoinAccess;
45
+ /** A resolved join target as the row renders it: the access plus, for a
46
+ * linkable one, where the arrow goes — an `href` to navigate to, or `onOpen`
47
+ * when the target is a selection on the page already showing (a join to
48
+ * another source of the same model). */
49
+ export type JoinLink = JoinAccess & {
50
+ href?: string;
51
+ onOpen?: () => void;
52
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The Malloy text the viewer runs. Pure string building, kept apart from the
3
+ * hooks that send it so it can be tested without a DOM. Every name is quoted
4
+ * by {@link malloyIdentifier}, and no value is ever written into the text.
5
+ */
6
+ /**
7
+ * A Malloy identifier, always backtick-quoted. Quoting unconditionally is what
8
+ * makes this safe: a name that LOOKS plain can still be a reserved word (`year`,
9
+ * `source`, `count`), and the quotes are the only spelling the grammar accepts
10
+ * for one of those. Inside the quotes, backslashes are escaped before backticks
11
+ * so neither can end the quoted name early.
12
+ */
13
+ export declare function malloyIdentifier(name: string): string;
14
+ /** The Malloy that runs a source's view by name. */
15
+ export declare function viewRunQuery(sourceName: string, viewName: string): string;
16
+ /** The Malloy that runs a model-level named query. */
17
+ export declare function namedQueryRunQuery(queryName: string): string;
18
+ /**
19
+ * The Malloy that reads a dimension's most common values, most common first:
20
+ * what a field's Values card shows when its host has no index to ask.
21
+ */
22
+ export declare function sampleValuesQuery(sourceName: string, fieldName: string, limit: number): string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * What the viewer's scans of a model file's text share: the givens a source
3
+ * reads, the order an `export { … }` lists, the source a derived one builds on.
4
+ * They read the text with regular expressions rather than the parser (which
5
+ * loads lazily), so each first masks what is not code.
6
+ */
7
+ /**
8
+ * The text with every comment and the contents of every string literal blanked
9
+ * to spaces, line breaks kept, so a scan sees only code: a `$GIVEN`, a brace or
10
+ * a keyword inside a comment or a string is not one. Offsets and line numbers
11
+ * are unchanged.
12
+ *
13
+ * Comments are `//` and `--` to the line's end, and `/* … *\/`. Strings are
14
+ * `'…'` and `"…"` (a backslash escapes the next character; a string ends at the
15
+ * line's end, as Malloy's do), with any prefix (`f'…'`, `r'…'`) left as code,
16
+ * and `"""…"""` across lines. A quoted identifier (`` `order items` ``) is code
17
+ * and is kept.
18
+ */
19
+ export declare function maskCommentsAndStrings(text: string): string;
20
+ /** A string matched literally inside a `RegExp`. */
21
+ export declare function escapeRegExp(value: string): string;
@@ -0,0 +1,61 @@
1
+ import { Given } from '../../client';
2
+ import { GivenValue } from '../../hooks/givenValue';
3
+ import type * as Malloy from "@malloydata/malloy-interfaces";
4
+ /**
5
+ * A given the model declares, as `CompiledModel.givens` carries it, with the
6
+ * model file that declared it so a row can say where it comes from.
7
+ */
8
+ export type GivenInfo = Given & {
9
+ /** Always present once shape-checked (the wire type leaves both optional). */
10
+ name: string;
11
+ type: string;
12
+ /** Package-relative path of the model file that declared this given. */
13
+ modelFile: string;
14
+ };
15
+ /** One given's value as a query request carries it. */
16
+ export type GivenRequestValue = string | number | boolean;
17
+ /** The `givens` map a run sends: keys sorted, so the same values always
18
+ * serialize (and cache-key, `givensKeyFor`) the same way. */
19
+ export type GivenRequest = Readonly<Record<string, GivenRequestValue>>;
20
+ /**
21
+ * The givens of a compiled model, less the ones its host fills on every query
22
+ * (`hostGivenNames`): a model may declare those (a gate reads `$GROUPS` with no
23
+ * default, as a gate must), but they are never a reader's input, so a control
24
+ * for one would be ignored and a missing value is never missing.
25
+ *
26
+ * Shape-checked rather than trusted, so an older server's body that lacks a
27
+ * field reads as no givens rather than a throw.
28
+ */
29
+ export declare function extractCompiledModelGivens(modelFile: string, body: unknown, hostGivenNames?: ReadonlySet<string>): GivenInfo[];
30
+ /** Declared type per given name, which decides how a `Date` is sent. */
31
+ export declare function declaredTypesOf(givens: ReadonlyArray<GivenInfo>): Map<string, string>;
32
+ /**
33
+ * The control row as the `givens` a run sends: only givens the model declares (a
34
+ * value left over for a since-removed given must not reach the server as an
35
+ * undeclared parameter), unset ones dropped, keys sorted. A blank `string` given
36
+ * is unset too: a cleared text box means "use the default". `undefined` when
37
+ * nothing is set, so a run at the defaults sends no `givens` at all.
38
+ */
39
+ export declare function givensRequest(values: ReadonlyMap<string, GivenValue>, declaredTypes: ReadonlyMap<string, string | undefined>): GivenRequest | undefined;
40
+ /** The givens part of a Malloy query's cache key: '' when none are set. */
41
+ export declare function givensKeyFor(givens: Readonly<Record<string, string | number | boolean>> | undefined): string;
42
+ /**
43
+ * Filter metadata parsed from a source's `#(filter)` annotation:
44
+ * `#(filter) [name=NAME] dimension=DIMENSION type=TYPE [implicit] [required]`,
45
+ * where a value may be double-quoted to hold spaces.
46
+ */
47
+ export interface SourceFilter {
48
+ /** Display name / API parameter key; defaults to the dimension name. */
49
+ name: string;
50
+ /** Name of the dimension the filter targets. */
51
+ dimension: string;
52
+ type: "equal" | "in" | "like" | "greater_than" | "less_than";
53
+ /** If true, don't show in the UI. */
54
+ implicit?: boolean;
55
+ /** If true, the server requires a value. */
56
+ required?: boolean;
57
+ }
58
+ /** Parse the `#(filter) ...` annotations on a source. */
59
+ export declare function parseSourceFilterAnnotations(annotations: Malloy.Annotation[] | undefined): SourceFilter[];
60
+ /** True if the field carries an `#(index_values)` or `#(index)` annotation. */
61
+ export declare function isFieldIndexed(field: Malloy.FieldInfo): boolean;
@@ -0,0 +1,9 @@
1
+ import { GivenInfo } from './modelGivens';
2
+ import { Context } from 'react';
3
+ /**
4
+ * The model's givens a reader can set (router-filled ones already left out), for
5
+ * the rows that read one: each marks itself "Given" and says which, from its own
6
+ * code (givensReadBy). Provided once by the explorer rather than threaded
7
+ * through every section and group.
8
+ */
9
+ export declare const ModelGivensContext: Context<readonly GivenInfo[]>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copy for the model page's header, mirroring the connection page's
3
+ * (connectionStatusPresentation.ts): the status line under the title, and the
4
+ * (?) help text beside it.
5
+ *
6
+ * Separate from the components so it can be asserted directly, and so the
7
+ * explorer modules keep exporting only components — a non-component export
8
+ * breaks Vite Fast Refresh for the whole module.
9
+ */
10
+ /**
11
+ * What this model holds, in the shape of the connection page's "Indexed 24
12
+ * tables": the count of the thing the page is a browser for.
13
+ */
14
+ export declare function modelSourcesLine(sourceCount: number): string;
15
+ /**
16
+ * What a source is and what picking one does — the two things a first-time
17
+ * reader of the sources list cannot guess from a bare count. Kept free of any
18
+ * chat-scoping clause, because the sources dropdown
19
+ * this labels also appears on the standalone model page, where there is no chat
20
+ * to scope.
21
+ */
22
+ export declare const MODEL_SOURCES_HELP = "A source is a queryable entry point into the model \u2014 pick one to browse its dimensions, measures, views and joins.";
23
+ /**
24
+ * The source picker pill's face, beside the source's title on the model page: "5 sources", or on
25
+ * the package's root `index.malloy` — whose sources are the set the package publishes —
26
+ * "4 public sources".
27
+ */
28
+ export declare function sourceCountLabel(sourceCount: number, curated?: boolean): string;
@@ -0,0 +1,32 @@
1
+ import { ParsedModelText } from './modelTextParse';
2
+ /** The field kinds a source declares with `kind: name is …`. */
3
+ export type DeclaredKind = "view" | "measure" | "dimension";
4
+ /** One field's declaration as written in the model file. */
5
+ export interface TextDeclaration {
6
+ kind: DeclaredKind;
7
+ /**
8
+ * The annotation lines directly above it, then the declaration from its name
9
+ * (`name is …`) to its end — the shape of the entities artifact's `code`, so
10
+ * the row's code display (viewDeclaration, stripDefinitionWrapper) reads both alike.
11
+ */
12
+ code: string;
13
+ }
14
+ /**
15
+ * Every view, measure and dimension a source declares, read from the model
16
+ * file with Malloy's parser: field name → its declaration.
17
+ *
18
+ * A host's entities can carry a field's code, but the Publisher's own reads
19
+ * don't, so without them the rows would offer no code at all. The compiled
20
+ * model carries the file's text, and this reads the declarations from it, as
21
+ * `namedQueryCode` does for a named query.
22
+ *
23
+ * The parser gives each declaration's exact text but not its kind, so the kind
24
+ * is the `dimension:` / `measure:` / `view:` keyword that owns the entry.
25
+ * Fields the source inherits from the source it extends (`source: b is a
26
+ * extend { … }`, `a` in the same file) are read from `a`'s declaration, the
27
+ * source's own taking precedence. A name declared twice is left out rather than
28
+ * guessed, and so is anything that is not a `name is …` definition under one of
29
+ * those keywords (a `rename:`, a query source's `group_by: carrier`, a field
30
+ * from another file): the row then says it has no code.
31
+ */
32
+ export declare function fieldDeclarations(parsed: ParsedModelText | undefined, sourceName: string | undefined): ReadonlyMap<string, TextDeclaration>;
@@ -0,0 +1,27 @@
1
+ import { DocumentRange, DocumentSymbol } from '@malloydata/malloy';
2
+ type MalloyModule = typeof import("@malloydata/malloy");
3
+ /**
4
+ * A model file's text with the symbols Malloy's parser finds in it: each
5
+ * source, its fields, views and joins, and the file's named queries, each with
6
+ * the range of text that declares it. Parsing does not compile, so a file
7
+ * mid-edit still yields what the parser could read.
8
+ */
9
+ export interface ParsedModelText {
10
+ /** The file's lines, CRLF read as LF, which the symbols' ranges index. */
11
+ lines: string[];
12
+ symbols: DocumentSymbol[];
13
+ }
14
+ /** Undefined when the parser throws: the rows then say they have no code. */
15
+ export declare function parseModelText(malloy: MalloyModule, text: string): ParsedModelText | undefined;
16
+ /** The text a range covers. */
17
+ export declare function rangeText(lines: readonly string[], range: DocumentRange): string;
18
+ /**
19
+ * `text` parsed, once the parser has loaded. `pending` while it loads; when
20
+ * `wanted` is false nothing is loaded or parsed. A parser that fails to load
21
+ * leaves `parsed` undefined and `pending` false.
22
+ */
23
+ export declare function useParsedModelText(text: string | undefined, wanted?: boolean): {
24
+ parsed: ParsedModelText | undefined;
25
+ pending: boolean;
26
+ };
27
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ParsedModelText } from './modelTextParse';
2
+ /**
3
+ * A model-level named query's declaration (`query: name is …`), read from the
4
+ * model file with Malloy's parser. The compiled model lists a query's name and
5
+ * annotations only, never its definition (see ExplorerQuery), so the file is
6
+ * the one place its code exists; this is what a query row's Code shows.
7
+ *
8
+ * Undefined where the file isn't available, doesn't declare the name, or
9
+ * declares it twice: the row's Code then says it has nothing to show, never a
10
+ * guess.
11
+ */
12
+ export declare function namedQueryCode(parsed: ParsedModelText | undefined, name: string): string | undefined;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * A package whose root `index.malloy` decides what it publishes hides every other
3
+ * model file: the models list leaves it out and the model GET answers 404. People
4
+ * who can edit the package still need to read those files, so for them the app asks
5
+ * with `includeHiddenFilesAndSources`, which a host allows only for someone who can edit
6
+ * the package. The same flag rides on their runs of such a file, and Publisher then drops
7
+ * the surface limit for that run, so an editor can query a hidden source too. Anyone else
8
+ * never sends the flag, so for them a hidden file stays a 404.
9
+ */
10
+ /** The marker on a hidden file, in the package's models list and on its page. */
11
+ export declare const OFF_SURFACE_LABEL = "Private";
12
+ /** What the marker means: its tooltip, wherever it shows. */
13
+ export declare const OFF_SURFACE_DETAIL = "index.malloy doesn't export this file, so only people who can edit the package see it.";
14
+ /** Whether a models-list entry is a file the package hides. Absent (an older server) reads as not hidden. */
15
+ export declare function isHidden(model: {
16
+ isHidden?: boolean;
17
+ }): boolean;
18
+ /**
19
+ * The Private marker on a row of the package's models list: not a tab stop, since the row is
20
+ * one link and a control inside it would be a second. Its why is in the tooltip for a pointer,
21
+ * and in the row's accessible name for everyone else ({@link surfaceRowLabel}), as a row's
22
+ * access pills put theirs (AccessChips `accessRowLabel`).
23
+ */
24
+ export declare function OffSurfacePill(): import("react/jsx-runtime").JSX.Element;
25
+ /**
26
+ * The Private marker on a hidden file's own page (its source's status row, or above the code):
27
+ * a status-row chip like its siblings (HeaderChip), so it is a tab stop whose accessible name
28
+ * is its why, reachable by keyboard and read by a screen reader, not only shown on hover.
29
+ */
30
+ export declare function OffSurfaceChip(): import("react/jsx-runtime").JSX.Element;
31
+ /** The marker on the package's root `index.malloy`: the sources it exports are the package's public ones. */
32
+ export declare const PUBLIC_SURFACE_LABEL = "Public";
33
+ /** What the marker means on the root `index.malloy`'s row in the package's models list. */
34
+ export declare const PUBLIC_FILE_DETAIL = "What index.malloy exports is what the package publishes: everyone who can read the package can query its sources.";
35
+ /** What the marker means in a source's status row on the root `index.malloy`'s page. */
36
+ export declare const PUBLIC_SOURCE_DETAIL = "index.malloy exports this source, so everyone who can read the package can query it.";
37
+ /**
38
+ * The marker on the package's root `index.malloy`'s row in the models list: what it exports is
39
+ * what the package publishes, so it is the model a reader should open first. Green beside the
40
+ * amber Private on the files it leaves out ({@link OffSurfacePill}), so the two read as one
41
+ * public/private pair (the guide's §4 names this pair as the one Declaration that takes a
42
+ * tone), and drawn the same way: not a tab stop, its why in the tooltip and in the row's
43
+ * accessible name ({@link surfaceRowLabel}).
44
+ */
45
+ export declare function PublicSurfacePill(): import("react/jsx-runtime").JSX.Element;
46
+ /**
47
+ * The Public marker in a source's status row on the root `index.malloy`'s page: a status-row
48
+ * chip like its siblings (HeaderChip), a tab stop whose accessible name is its why.
49
+ */
50
+ export declare function PublicSurfaceChip(): import("react/jsx-runtime").JSX.Element;
51
+ /** Which side of the package's surface a models-list row's file is on, when it is marked. */
52
+ export type FileSurface = "public" | "private";
53
+ /** The words a models-list row's accessible name adds for its surface pill (", Private: …"). */
54
+ export declare function surfaceRowLabel(surface: FileSurface | undefined): string;
@@ -0,0 +1,30 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ /**
3
+ * The kinds of content an open model row can show. An open row shows ONE card;
4
+ * where it has more than one of these, the switch on its line picks which, in
5
+ * this order.
6
+ */
7
+ export type RowLayer = "result" | "fields" | "code" | "values" | "givens" | "access";
8
+ /**
9
+ * The layer an open row shows: the one the reader picked while it is available,
10
+ * else `initial` (when available), else the first available. `available` is in
11
+ * any order; it is read in {@link LAYER_ORDER}.
12
+ */
13
+ export declare function useRowLayer(available: ReadonlyArray<RowLayer>, initial?: RowLayer): {
14
+ layers: RowLayer[];
15
+ layer: RowLayer;
16
+ setLayer: Dispatch<SetStateAction<RowLayer>>;
17
+ };
18
+ /**
19
+ * The switch between an open row's layers, drawn as action icons on its line.
20
+ * Nothing when there is only one layer: a switch with one option has nothing to
21
+ * switch. A layer the row has but cannot show here keeps its place, disabled with
22
+ * its reason (SegmentIcons).
23
+ */
24
+ export declare function RowLayerSwitch({ layers, value, onChange, "aria-label": ariaLabel, disabledReasons, }: {
25
+ layers: ReadonlyArray<RowLayer>;
26
+ value: RowLayer | undefined;
27
+ onChange: (layer: RowLayer) => void;
28
+ "aria-label": string;
29
+ disabledReasons?: Partial<Record<RowLayer, string>>;
30
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ import { GivenInfo, GivenRequest } from './modelGivens';
2
+ /**
3
+ * Whether a run from the explorer can be honest about its inputs.
4
+ *
5
+ * A run sends the given values the reader set in the page's Givens section
6
+ * (the dashboard's own controls). A given the reader left unset falls back
7
+ * to its declared default, and the card names every default it ran at, the
8
+ * way a report's panel shows the values that produced its cells. An unset
9
+ * given with no default, or a `#(filter … required)` on the source (the
10
+ * explorer has no filter controls), cannot run at all, so the card says what
11
+ * is missing instead of showing a bare 400.
12
+ *
13
+ * Each given is named as its control on the page words it, `Ordered since:
14
+ * Jan 1, 2023`, never as a Malloy literal. A given the page can't tie to the
15
+ * source either way (`unknown`) is named apart: the card says it can't tell
16
+ * whether the source reads it, and what the run had for it where it does,
17
+ * rather than calling its default one the run ran at. Values are named whole
18
+ * (`describeGivenValue`), never cut to a button's width: the note is the record
19
+ * of what produced the result.
20
+ *
21
+ * A run held only for givens the page can't tie to the source can run anyway
22
+ * (`canRunAnyway`), at the reader's word: if the source does read one, the run
23
+ * fails, and the card has already said why.
24
+ */
25
+ export type RunGate = {
26
+ kind: "ok";
27
+ } | {
28
+ kind: "noted";
29
+ note: string;
30
+ } | {
31
+ kind: "blocked";
32
+ reason: string;
33
+ canRunAnyway: boolean;
34
+ };
35
+ /** `A`, `A or B`, `A, B or C`. */
36
+ export declare function wordList(words: readonly string[], conjunction: string): string;
37
+ export declare function runGate(givens: ReadonlyArray<GivenInfo> | undefined, requiredFilters: ReadonlyArray<string> | undefined,
38
+ /** Values the reader set, as a run sends them; an absent entry means "use the
39
+ * default". An empty string is a value, as on a dashboard (for a
40
+ * `filter<…>`, "All"). */
41
+ values?: GivenRequest | undefined,
42
+ /** Names of the givens the page can't tie to the source either way
43
+ * (scanGivensForSource). */
44
+ unknown?: ReadonlySet<string> | undefined,
45
+ /** The reader chose to run without the missing givens the page can't tie
46
+ * to the source; honored only when those are all that holds the run. */
47
+ runAnyway?: boolean,
48
+ /** What the run reads from: its source, or a named query with none. */
49
+ subject?: "source" | "query"): RunGate;
@@ -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
+ };