@malloy-publisher/sdk 0.12.1 → 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 (208) hide show
  1. package/README.md +79 -6
  2. package/dist/{RenderedResult-DrNhQ2_9.cjs.js → RenderedResult-Cgw4iqev.cjs.js} +1 -1
  3. package/dist/{RenderedResult-AyM-RQaA.es.js → RenderedResult-DEjFM1DL.es.js} +2 -2
  4. package/dist/ServerProvider-BRQl_cBo.cjs.js +1 -0
  5. package/dist/{ServerProvider-a9Ki0QXO.es.js → ServerProvider-RnliA2Ao.es.js} +577 -555
  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 +10 -1
  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-D88_2cGS.cjs.js +143 -0
  88. package/dist/{useCompiledDocument-Utj2u8CG.es.js → useCompiledDocument-Dmm6xkom.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,94 @@
1
+ import { ReactNode, Context } from 'react';
2
+ import { GivenRequest } from './modelGivens';
3
+ import { ShownRun } from './RunResult';
4
+ import { ExplorerField } from './schemaModel';
5
+ import { SampleValuesFetcher } from './useDimensionSamples';
6
+ /** An open view's or named query's run, for a host's actions beside it. */
7
+ export interface RunActionContext {
8
+ kind: "view" | "query";
9
+ modelPath: string;
10
+ /** The source a view belongs to; "" for a named query. */
11
+ sourceName: string;
12
+ name: string;
13
+ /**
14
+ * The Malloy the row runs: the view or query by name, with no row limit of
15
+ * its own, so its rows are what the server's cap allows.
16
+ */
17
+ query: string;
18
+ /** The given values the run sends (`QueryRequest.givens`), unset ones left out. */
19
+ givens?: GivenRequest;
20
+ /**
21
+ * The viewer's cache key for this run, so a host's refresh can invalidate
22
+ * it and a host's own run of the same query can share the entry.
23
+ */
24
+ queryKey: readonly unknown[];
25
+ /** The result the card shows, once it has one. */
26
+ shown?: ShownRun;
27
+ }
28
+ /** A field row, for a host's additions to it. */
29
+ export interface FieldContext {
30
+ modelPath: string;
31
+ sourceName: string;
32
+ field: ExplorerField;
33
+ /** A joined source's field, shown inside a join on another source's page. */
34
+ joined: boolean;
35
+ }
36
+ /** The source on screen, or a source in the picker, for a host's additions to it. */
37
+ export interface SourceContext {
38
+ modelPath: string;
39
+ sourceName: string;
40
+ }
41
+ /** What a host adds to a source's line in the picker. */
42
+ export interface PickerSourceExtras {
43
+ /** A description where the source has no `#(doc)`, marked Generated. */
44
+ summary?: string;
45
+ /** Hold the description's line: the host is still reading its summaries. */
46
+ summaryPending?: boolean;
47
+ /** Chips after the source's name. */
48
+ status?: ReactNode;
49
+ }
50
+ /**
51
+ * What a host adds to the viewer without the viewer knowing what it is: the
52
+ * Publisher's own reads draw every row, and a host with more to say about a
53
+ * field (what it has built from it, an index of its values) or more to do with
54
+ * a result (download it) says and does it through these.
55
+ *
56
+ * **Experimental.** These slots are new, and no host has been built on them
57
+ * yet; they may change in a minor release until one has.
58
+ */
59
+ export interface ModelViewerExtensions {
60
+ /** Actions beside an open view's or named query's Result | Code switch. */
61
+ renderRunActions?: (run: RunActionContext) => ReactNode;
62
+ /** A dimension's sample values, instead of the viewer's own query. */
63
+ fetchSamples?: SampleValuesFetcher;
64
+ /**
65
+ * The build of the values `fetchSamples` serves (an index's version, say):
66
+ * a new one is a new cache entry, so a row reopened after a rebuild never
67
+ * shows the values from before it.
68
+ */
69
+ samplesGeneration?: string;
70
+ /** Chips a host adds to a field's line, after its own. */
71
+ renderFieldStatus?: (field: FieldContext) => ReactNode;
72
+ /** The row's one action, beside its chips (a Rebuild, say). */
73
+ renderFieldAction?: (field: FieldContext) => ReactNode;
74
+ /**
75
+ * What an open field row shows. `builtIn` is the viewer's own card (the
76
+ * field's code, a dimension's values, the givens it reads), undefined where
77
+ * the row has none. Return it to keep it, beside a card of your own or not;
78
+ * return something else to show that in its place; return null for nothing,
79
+ * and the row then doesn't open.
80
+ */
81
+ renderFieldDetail?: (field: FieldContext, builtIn: ReactNode | undefined) => ReactNode;
82
+ /**
83
+ * Whether a view's or field's row is listed, for a host's narrowed view of
84
+ * a source (the fields it has built from, say). Each section's count is of
85
+ * the rows it lists. Absent, every row is.
86
+ */
87
+ showField?: (field: FieldContext) => boolean;
88
+ /** A card under the source's header, for what only the host knows of it (where its data comes from, its build). */
89
+ renderSourceDetail?: (source: SourceContext) => ReactNode;
90
+ /** A host's summary and chips on a source's line in the picker. */
91
+ describePickerSource?: (source: SourceContext) => PickerSourceExtras | undefined;
92
+ }
93
+ export declare const ModelViewerExtensionsContext: Context<ModelViewerExtensions>;
94
+ export declare function useModelViewerExtensions(): ModelViewerExtensions;
@@ -0,0 +1,74 @@
1
+ import { EntitiesByField } from './fieldEntities';
2
+ import { TextDeclaration } from './modelTextDeclarations';
3
+ /**
4
+ * Per-field Malloy-definition lookup, supplied by the owner (SchemaView) when
5
+ * code snippets are available for this row's source. `code` stays undefined
6
+ * while loading or when the field has no definition of its own (an inherited
7
+ * column).
8
+ */
9
+ export interface FieldCodeLookup {
10
+ code?: string;
11
+ loading: boolean;
12
+ /** The definitions read failed: kept distinct from "this field has no
13
+ * definition" (an error carries no evidence of absence), and the one
14
+ * absence the row still opens to report. */
15
+ error?: boolean;
16
+ /** The field is an inherited table column (entity `fieldType` "column"):
17
+ * its stored code is the SOURCE's declaring line, which reads as nonsense
18
+ * for the field, so it's suppressed. Such a row doesn't open; without a
19
+ * description it says "inherited" beside its type instead. */
20
+ inherited?: boolean;
21
+ /** For an inherited column, where it comes from: the table expression a
22
+ * table column is read from (`fromTable`), or the passthrough line of the
23
+ * query source it is an output of. Shown as its Code in place of a
24
+ * definition of its own. */
25
+ inheritedFrom?: {
26
+ code: string;
27
+ fromTable: boolean;
28
+ };
29
+ /** For an inherited column: a host's description of that warehouse column,
30
+ * so a passthrough dimension the modeler never documented still says what
31
+ * it holds. Never set for a defined field. */
32
+ columnDoc?: string;
33
+ }
34
+ /**
35
+ * Builds the per-field code lookup for ONE source's fields.
36
+ *
37
+ * Shared by the active source and by each joined source rendered inline: a
38
+ * joined source is the same source seen from another page, so its fields must
39
+ * offer the same definition/"inherited" affordance. Keeping one factory is what
40
+ * makes that identical rather than merely similar.
41
+ *
42
+ * `entities` must be the fields of the source that DECLARES these fields —
43
+ * for a join, the target source's map, not the host's. Field names are only
44
+ * unique within a source, so passing the wrong map silently renders another
45
+ * source's definition on a same-named field.
46
+ */
47
+ export declare function makeGetFieldCode(params: {
48
+ entities: EntitiesByField | undefined;
49
+ loading: boolean;
50
+ error: boolean;
51
+ /**
52
+ * Generated descriptions of the base TABLE's columns (column name → text),
53
+ * for the table this source reads. Only ever applied to inherited columns —
54
+ * a field with a Malloy definition is the modeler's expression, and its name
55
+ * colliding with a warehouse column's says nothing about what it computes.
56
+ *
57
+ * Must be the table behind THESE entities. A joined source reads its own
58
+ * table, so the host's map would describe the wrong columns — SchemaJoin
59
+ * passes none.
60
+ */
61
+ columnDescriptions?: ReadonlyMap<string, string>;
62
+ /**
63
+ * The same source's declarations read from the model file's text
64
+ * (`fieldDeclarations`), for a field the entities don't carry: without a
65
+ * host's entities, every field's code comes from here. Used only once the entities read has settled with no entity for the
66
+ * field, and only for a declaration of the field's own kind.
67
+ */
68
+ declarations?: ReadonlyMap<string, TextDeclaration>;
69
+ /** The model file is still being parsed for `declarations`. */
70
+ declarationsLoading?: boolean;
71
+ }): (field: {
72
+ name: string;
73
+ kind?: string;
74
+ }) => FieldCodeLookup;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * What a host knows about a model's fields beyond what the compiled model says.
3
+ *
4
+ * The viewer's own reads give it every field's name, type and annotations, and
5
+ * the model file's text gives it the code of whatever the file declares. A host
6
+ * with a fuller record of the model (an index of every field the model compiles,
7
+ * say) can pass that record as entities, and the viewer then shows what only it
8
+ * knows: an inherited table column's origin, the table a source reads, a join's
9
+ * target source and its declaration.
10
+ */
11
+ export interface FieldEntity {
12
+ /** The field's name within its declaring source. */
13
+ name: string;
14
+ /** The source that declares the field. An entity without one is dropped:
15
+ * field names are unique only within a source. */
16
+ source?: string | null;
17
+ /** `dimension`, `measure`, `view`, `join`, or `column` for a table column the
18
+ * source passes through unchanged. */
19
+ fieldType?: string | null;
20
+ /** The Malloy that defines the field, verbatim. */
21
+ code?: string | null;
22
+ /** The table the declaring source reads, when it reads one. */
23
+ table?: FieldEntityTable | null;
24
+ /** For a join, the source it joins: the alias can differ from its name. */
25
+ joinTarget?: {
26
+ modelPath: string;
27
+ sourceName: string;
28
+ } | null;
29
+ }
30
+ export interface FieldEntityTable {
31
+ connectionName: string;
32
+ catalogName?: string | null;
33
+ schemaName?: string | null;
34
+ tableName: string;
35
+ }
36
+ /** One source's fields, keyed by field name. */
37
+ export type EntitiesByField = ReadonlyMap<string, FieldEntity>;
38
+ /**
39
+ * Every source declared by one model file, keyed by SOURCE name, never a flat
40
+ * field map: `aircraft` and `aircraft_models` can both declare `id`, and a flat
41
+ * map would show one source's definition on the other's field.
42
+ */
43
+ export type EntitiesBySource = ReadonlyMap<string, EntitiesByField>;
44
+ /** A model's entities grouped by declaring source; one with no source is dropped rather than guessed. */
45
+ export declare function groupEntitiesBySource(entities: ReadonlyArray<FieldEntity>): EntitiesBySource;
@@ -0,0 +1,41 @@
1
+ import { FieldCodeLookup } from './fieldCode';
2
+ import { ExplorerField } from './schemaModel';
3
+ /** A dimension whose VALUES are in the search index (`#(index)`), so the row can
4
+ * show sample values — content in its own right, with or without a definition. */
5
+ export declare function isIndexedDimension(field: ExplorerField): boolean;
6
+ /**
7
+ * Whether the expansion has a definition section to draw. True while the fetch
8
+ * is in flight (the answer isn't known yet, and a row that opens late is
9
+ * better than one that vanishes under the pointer) and true on failure, which
10
+ * is a fact about the pane worth surfacing rather than reading as "no
11
+ * definition". False for an inherited table column — its story is told on the
12
+ * row's hover instead.
13
+ */
14
+ export declare function hasDefinitionToShow(fieldCode: FieldCodeLookup | undefined): boolean;
15
+ export declare function isFieldExpandable(field: ExplorerField, fieldCode: FieldCodeLookup | undefined): boolean;
16
+ /**
17
+ * Expandable fields first, each block keeping the model's declaration order.
18
+ *
19
+ * A group of a table-backed source's dimensions is mostly passthrough columns,
20
+ * and the handful the modeler actually wrote were scattered among them — the
21
+ * interesting rows found by hunting for the ones that open. Hoisting them puts the
22
+ * source's own work at the top of the group and leaves the inherited columns as
23
+ * the tail they are.
24
+ *
25
+ * **The row and the order answer "loading" differently, on purpose.**
26
+ * `isFieldExpandable` is optimistic while the definitions read is in flight —
27
+ * a row that becomes openable late beats one that stops being so under the pointer. Order
28
+ * cannot be optimistic the same way: taking `loading` as expandable puts EVERY
29
+ * field in the hoisted block, so `rest` is empty, the identity short-circuit
30
+ * below returns the list unsorted, and the group then re-sorts under the reader
31
+ * when the read lands. So ordering asks a stricter question — is this field
32
+ * expandable *on what is known now*.
33
+ *
34
+ * **This narrows the reorder; it does not remove it.** A row is knowable at
35
+ * first paint only through `isIndexedDimension`, which reads `field.indexed`
36
+ * off the compiled schema. A plain written measure still hoists when its
37
+ * definition's read lands (the model text's parse, or a host's entities),
38
+ * because written-vs-inherited is only known from that read. Removing the rest
39
+ * needs the compiled schema to say what a field is.
40
+ */
41
+ export declare function expandableFirst(items: ExplorerField[], getFieldCode: (field: ExplorerField) => FieldCodeLookup | undefined): ExplorerField[];
@@ -0,0 +1,71 @@
1
+ import { GivenInfo } from './modelGivens';
2
+ /**
3
+ * Which givens a piece of Malloy reads, found in its text.
4
+ *
5
+ * The compiled model lists a model's givens but not where each is used, so
6
+ * this reads the definitions the page already has: a
7
+ * field's or view's code, and the model file's text. A given is referenced as
8
+ * `$NAME` and its name is a declared identifier, so a whole-name match against
9
+ * the declared list is reliable; comments and strings are masked first
10
+ * (`maskCommentsAndStrings`) so a mention there is not a use. Host-filled givens never reach here (the viewer leaves out its
11
+ * `hostGivenNames`), so `$GROUPS` in a gate is not a reader's given.
12
+ */
13
+ export declare function givensReadBy(code: string | undefined, givens: ReadonlyArray<GivenInfo>): GivenInfo[];
14
+ /**
15
+ * The names of the givens a model file declares itself (`NAME :: type`), as
16
+ * opposed to ones it holds because it imports them: the compiled model lists
17
+ * both, and doesn't say which file declared each.
18
+ */
19
+ export declare function givensDeclaredIn(sourceText: string | undefined, givens: ReadonlyArray<GivenInfo>): Set<string>;
20
+ /**
21
+ * The givens a named query reads when the model doesn't say which source it
22
+ * runs against: those its declaration names, plus those of every source of
23
+ * the model it names (`givensBySource`, what a run on that source gates on).
24
+ * Undefined without its declaration's text, where every given is the only
25
+ * safe answer.
26
+ */
27
+ export declare function givensOfNamedQuery(code: string | undefined, givens: ReadonlyArray<GivenInfo>, givensBySource: ReadonlyMap<string, ReadonlyArray<GivenInfo>> | undefined): GivenInfo[] | undefined;
28
+ /**
29
+ * {@link givensOfNamedQuery}, and which of its givens the page can't tie to
30
+ * the query either way (`unknown`): those of a source it names that the scan
31
+ * couldn't follow (`unknownBySource`), and, when the query runs over something
32
+ * that isn't one of the model's sources (an imported source the model doesn't
33
+ * export, another query, a `compose(…)`), every given its own text doesn't
34
+ * read, all of which it then returns. Without its text, every given, none
35
+ * known.
36
+ */
37
+ export declare function scanGivensOfNamedQuery(code: string | undefined, givens: ReadonlyArray<GivenInfo>, givensBySource: ReadonlyMap<string, ReadonlyArray<GivenInfo>> | undefined, unknownBySource?: ReadonlyMap<string, ReadonlySet<string>>): {
38
+ givens: GivenInfo[];
39
+ unknown: ReadonlySet<string>;
40
+ };
41
+ /**
42
+ * The givens that matter on one source's page: those its own declaration reads
43
+ * (and the sources it extends, derives from or joins, which its queries run
44
+ * through — exported or not), plus the model-wide ones no source reads — a
45
+ * given used only by a top-level query, or by nothing yet, belongs to every
46
+ * page. Falls back to every given when the model's text is absent, when the
47
+ * source's declaration is not one this can find, and when the source builds on
48
+ * something the text doesn't declare (an imported source, a query, a
49
+ * `compose(…)`), whose reads it can't see: a page never hides a control it
50
+ * might need, and a run never goes out without a value it reads.
51
+ */
52
+ export declare function givensForSource(sourceText: string | undefined, sourceName: string, givens: GivenInfo[]): GivenInfo[];
53
+ /**
54
+ * {@link givensForSource}, and which of the givens it returns the scan can't
55
+ * tie to the source either way (`unknown`), so the page can say a value set for
56
+ * one may not apply. Where it fell back to every given, that is each one the
57
+ * source's own text in this file doesn't read: a source built on an import that
58
+ * reads a given itself is known to read it. Empty where the scan could tell.
59
+ */
60
+ export declare function scanGivensForSource(sourceText: string | undefined, sourceName: string, givens: GivenInfo[]): {
61
+ givens: GivenInfo[];
62
+ unknown: ReadonlySet<string>;
63
+ };
64
+ /**
65
+ * The givens a source's page shows only because a source it builds on reads
66
+ * them, where that source isn't one the page can open (the model doesn't
67
+ * export it): given name → the unexported sources that read it. A reader sees
68
+ * the control with no field on the page that uses it, so the section names
69
+ * where the given comes from.
70
+ */
71
+ export declare function givensInheritedBy(sourceText: string | undefined, sourceName: string, givens: GivenInfo[], knownSources: ReadonlySet<string>): Map<string, string[]>;
@@ -0,0 +1,31 @@
1
+ import { ReactNode, Context } from 'react';
2
+ import { RowLayer } from './rowLayers';
3
+ /**
4
+ * The source header's facts card, as the chips on its status row see it: which
5
+ * layer it is open on (none: shut), and how a chip opens or shuts it. Provided
6
+ * by HeaderBar; absent anywhere else, where a chip is only a tooltip.
7
+ */
8
+ export interface HeaderCard {
9
+ openLayer: RowLayer | undefined;
10
+ /** The layers the card has facts for; a chip for any other stays a tooltip. */
11
+ layers: ReadonlyArray<RowLayer>;
12
+ toggle: (layer: RowLayer) => void;
13
+ cardId: string;
14
+ }
15
+ export declare const HeaderCardContext: Context<HeaderCard>;
16
+ /**
17
+ * A status-row chip that is also the way into the facts behind it: the chip is a
18
+ * button, `aria-expanded` saying whether its card is open; the pointer and a
19
+ * shade on hover say it opens, and it stays shaded while open. A chip whose
20
+ * layer the card has no facts for (or outside the header) is the plain focusable
21
+ * chip it always was: a tab stop whose name is its meaning. So is a chip with no layer at all
22
+ * (a file's Public / Private), which has no facts to open, only its why.
23
+ */
24
+ export declare function HeaderChip({ layer, title, children, testId, }: {
25
+ /** The card layer it opens; none for a chip that only says what it means. */
26
+ layer?: RowLayer;
27
+ /** The tooltip and accessible name: what the chip means. */
28
+ title: string;
29
+ children: ReactNode;
30
+ testId?: string;
31
+ }): import("react/jsx-runtime").JSX.Element;
@@ -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>;