@altertable/data-app 0.69.0 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/AGENTS.md +11 -1
  2. package/CONTRIBUTING.md +59 -26
  3. package/README.md +22 -26
  4. package/REFERENCE.md +1900 -0
  5. package/dist/chunks/index-5a27erdg.js +54 -0
  6. package/dist/chunks/index-5a27erdg.js.map +10 -0
  7. package/dist/chunks/{index-2sbp9h2b.js → index-9yxr7nmm.js} +330 -21
  8. package/dist/chunks/index-9yxr7nmm.js.map +17 -0
  9. package/dist/chunks/{index-r7b1ftwy.js → index-j5q5n3ra.js} +8 -6
  10. package/dist/chunks/index-j5q5n3ra.js.map +10 -0
  11. package/dist/chunks/{index-22d576sn.js → index-q75zm3a7.js} +3 -3
  12. package/dist/chunks/{index-22d576sn.js.map → index-q75zm3a7.js.map} +3 -3
  13. package/dist/chunks/{index-kwnqycjt.js → index-vhaec7m5.js} +8 -6
  14. package/dist/chunks/index-vhaec7m5.js.map +10 -0
  15. package/dist/chunks/index-zp78caex.js +1047 -0
  16. package/dist/chunks/index-zp78caex.js.map +19 -0
  17. package/dist/client/index.js +284 -16
  18. package/dist/client/index.js.map +7 -3
  19. package/dist/core/appearance.js +181 -11
  20. package/dist/core/appearance.js.map +4 -3
  21. package/dist/core/config.js +3 -3
  22. package/dist/core/contract.js +13 -15
  23. package/dist/core/contract.js.map +1 -1
  24. package/dist/core/format.js +1 -1
  25. package/dist/index.js +4 -4
  26. package/dist/index.js.map +1 -1
  27. package/dist/internal.js +418 -0
  28. package/dist/internal.js.map +15 -0
  29. package/dist/server/index.js +102 -0
  30. package/dist/server/index.js.map +10 -0
  31. package/dist/types/client/annotations.d.ts +1 -1
  32. package/dist/types/client/data-client.d.ts +21 -10
  33. package/dist/types/client/iframe.d.ts +6 -6
  34. package/dist/types/client/index.d.ts +3 -4
  35. package/dist/types/client/location.d.ts +2 -2
  36. package/dist/types/client/logger.d.ts +1 -1
  37. package/dist/types/client/navigation.d.ts +1 -1
  38. package/dist/types/client/transport.d.ts +1 -1
  39. package/dist/types/core/bridge.d.ts +1 -1
  40. package/dist/types/core/config.d.ts +20 -17
  41. package/dist/types/core/contract.d.ts +23 -13
  42. package/dist/types/core/dimension-source.d.ts +64 -0
  43. package/dist/types/core/dimension.d.ts +31 -23
  44. package/dist/types/core/facets.d.ts +13 -0
  45. package/dist/types/core/filters.d.ts +1 -1
  46. package/dist/types/core/format.d.ts +1 -2
  47. package/dist/types/core/keys.d.ts +2 -0
  48. package/dist/types/core/messages.d.ts +3 -3
  49. package/dist/types/core/operation-types.d.ts +7 -6
  50. package/dist/types/core/presentation.d.ts +1 -1
  51. package/dist/types/core/queries.d.ts +75 -7
  52. package/dist/types/core/reading.d.ts +1 -1
  53. package/dist/types/core/variables.d.ts +38 -12
  54. package/dist/types/index.d.ts +1 -1
  55. package/dist/types/internal.d.ts +22 -0
  56. package/dist/types/server/index.d.ts +1 -2
  57. package/docs/app-authoring.md +12 -4
  58. package/docs/client.md +5 -6
  59. package/docs/composition.md +84 -0
  60. package/docs/contract.md +41 -21
  61. package/docs/data-context.md +5 -3
  62. package/docs/embed.md +4 -4
  63. package/docs/formatting-and-appearance.md +1 -1
  64. package/docs/hosted-apps.md +4 -0
  65. package/docs/react-embed.md +7 -6
  66. package/docs/react.md +5 -5
  67. package/docs/server-bun.md +5 -5
  68. package/docs/server.md +1 -1
  69. package/docs/stories-and-export.md +3 -3
  70. package/docs/styling.md +6 -2
  71. package/docs/ui.md +18 -7
  72. package/docs/variables.md +83 -11
  73. package/docs/views.md +57 -3
  74. package/docs/widgets.md +97 -4
  75. package/docs/worker.md +4 -4
  76. package/examples/starter-data-app/index.tsx +11 -23
  77. package/examples/starter-local-data-app/AGENTS.md +1 -1
  78. package/examples/starter-local-data-app/README.md +12 -10
  79. package/examples/starter-local-data-app/app.ts +7 -1
  80. package/examples/starter-local-data-app/package.json +3 -1
  81. package/examples/starter-local-data-app/src/App.tsx +1 -1
  82. package/examples/starter-local-data-app/src/data-context.ts +1 -1
  83. package/examples/starter-local-data-app/src/main.tsx +1 -1
  84. package/examples/starter-local-data-app/src/server.ts +1 -1
  85. package/examples/starter-local-data-app/tsconfig.json +7 -1
  86. package/package.json +16 -92
  87. package/THIRD_PARTY_NOTICES +0 -18
  88. package/dist/chunks/index-2sbp9h2b.js.map +0 -13
  89. package/dist/chunks/index-ap60vggk.js +0 -80
  90. package/dist/chunks/index-ap60vggk.js.map +0 -10
  91. package/dist/chunks/index-cv36cyna.js +0 -180
  92. package/dist/chunks/index-cv36cyna.js.map +0 -10
  93. package/dist/chunks/index-k766wwwr.js +0 -643
  94. package/dist/chunks/index-k766wwwr.js.map +0 -13
  95. package/dist/chunks/index-kwnqycjt.js.map +0 -10
  96. package/dist/chunks/index-m0gbxtgp.js +0 -355
  97. package/dist/chunks/index-m0gbxtgp.js.map +0 -13
  98. package/dist/chunks/index-qhzdzca2.js +0 -15869
  99. package/dist/chunks/index-qhzdzca2.js.map +0 -118
  100. package/dist/chunks/index-r7b1ftwy.js.map +0 -10
  101. package/dist/chunks/index-sx488hvs.js +0 -221
  102. package/dist/chunks/index-sx488hvs.js.map +0 -12
  103. package/dist/chunks/index-wss3gd3h.js +0 -319
  104. package/dist/chunks/index-wss3gd3h.js.map +0 -13
  105. package/dist/chunks/index-zcqxfwdq.js +0 -197
  106. package/dist/chunks/index-zcqxfwdq.js.map +0 -13
  107. package/dist/embed/index.js +0 -138
  108. package/dist/embed/index.js.map +0 -12
  109. package/dist/local.js +0 -432
  110. package/dist/local.js.map +0 -14
  111. package/dist/preview.js +0 -1456
  112. package/dist/preview.js.map +0 -17
  113. package/dist/react/embed/index.js +0 -117
  114. package/dist/react/embed/index.js.map +0 -10
  115. package/dist/react/index.js +0 -2948
  116. package/dist/react/index.js.map +0 -26
  117. package/dist/react/ui/index.js +0 -3142
  118. package/dist/react/ui/index.js.map +0 -35
  119. package/dist/server.js +0 -301
  120. package/dist/server.js.map +0 -13
  121. package/dist/types/core/time-interval.d.ts +0 -96
  122. package/dist/types/embed/bootstrap.d.ts +0 -5
  123. package/dist/types/embed/bridge.d.ts +0 -12
  124. package/dist/types/embed/host.d.ts +0 -36
  125. package/dist/types/embed/index.d.ts +0 -14
  126. package/dist/types/embed/navigation.d.ts +0 -6
  127. package/dist/types/embed/runtime-html.d.ts +0 -2
  128. package/dist/types/embed/source.d.ts +0 -16
  129. package/dist/types/embed/sql.d.ts +0 -4
  130. package/dist/types/react/annotations/AnnotationBar.d.ts +0 -30
  131. package/dist/types/react/annotations/AnnotationControls.d.ts +0 -10
  132. package/dist/types/react/annotations/AnnotationEditor.d.ts +0 -16
  133. package/dist/types/react/annotations/AnnotationMarkers.d.ts +0 -19
  134. package/dist/types/react/annotations/AnnotationSelectionLayer.d.ts +0 -12
  135. package/dist/types/react/annotations/AnnotationTarget.d.ts +0 -9
  136. package/dist/types/react/annotations/AnnotationTooltip.d.ts +0 -9
  137. package/dist/types/react/annotations/AnnotationTrigger.d.ts +0 -10
  138. package/dist/types/react/annotations/annotation-editor-state.d.ts +0 -58
  139. package/dist/types/react/annotations/annotation-screenshot.d.ts +0 -4
  140. package/dist/types/react/annotations/annotation-targets.d.ts +0 -34
  141. package/dist/types/react/annotations/getAnnotationProps.d.ts +0 -17
  142. package/dist/types/react/annotations/styles.d.ts +0 -3
  143. package/dist/types/react/annotations/useAnnotationGeometry.d.ts +0 -22
  144. package/dist/types/react/annotations/useDataAppAnnotations.d.ts +0 -22
  145. package/dist/types/react/app-context.d.ts +0 -3
  146. package/dist/types/react/bindings.d.ts +0 -133
  147. package/dist/types/react/content.d.ts +0 -36
  148. package/dist/types/react/date-formatting.d.ts +0 -12
  149. package/dist/types/react/embed/bridge.d.ts +0 -21
  150. package/dist/types/react/embed/index.d.ts +0 -7
  151. package/dist/types/react/hooks.d.ts +0 -75
  152. package/dist/types/react/index.d.ts +0 -75
  153. package/dist/types/react/injectStyles.d.ts +0 -7
  154. package/dist/types/react/mount.d.ts +0 -13
  155. package/dist/types/react/search-suggestions.d.ts +0 -8
  156. package/dist/types/react/source-owner.d.ts +0 -2
  157. package/dist/types/react/style-contract.d.ts +0 -88
  158. package/dist/types/react/style-validation.d.ts +0 -2
  159. package/dist/types/react/styles.d.ts +0 -8
  160. package/dist/types/react/ui/AboutData.d.ts +0 -68
  161. package/dist/types/react/ui/AltertableLogo.d.ts +0 -3
  162. package/dist/types/react/ui/AppFooter.d.ts +0 -6
  163. package/dist/types/react/ui/AppHeader.d.ts +0 -10
  164. package/dist/types/react/ui/AppLayout.d.ts +0 -10
  165. package/dist/types/react/ui/AppScope.d.ts +0 -7
  166. package/dist/types/react/ui/AppToolbar.d.ts +0 -30
  167. package/dist/types/react/ui/AreaChart.d.ts +0 -7
  168. package/dist/types/react/ui/BarChart.d.ts +0 -6
  169. package/dist/types/react/ui/Breakdown.d.ts +0 -13
  170. package/dist/types/react/ui/Button.d.ts +0 -11
  171. package/dist/types/react/ui/ChartLegend.d.ts +0 -32
  172. package/dist/types/react/ui/Checkbox.d.ts +0 -21
  173. package/dist/types/react/ui/CheckboxGroup.d.ts +0 -7
  174. package/dist/types/react/ui/ChoicePicker.d.ts +0 -39
  175. package/dist/types/react/ui/Comparison.d.ts +0 -14
  176. package/dist/types/react/ui/ComposedChart.d.ts +0 -41
  177. package/dist/types/react/ui/ComposedChartLegend.d.ts +0 -8
  178. package/dist/types/react/ui/ContentSkeleton.d.ts +0 -7
  179. package/dist/types/react/ui/DataApp.d.ts +0 -21
  180. package/dist/types/react/ui/DataAppFrame.d.ts +0 -52
  181. package/dist/types/react/ui/DataBoundary.d.ts +0 -14
  182. package/dist/types/react/ui/DataSection.d.ts +0 -14
  183. package/dist/types/react/ui/DataSectionBoundary.d.ts +0 -30
  184. package/dist/types/react/ui/DataTable.d.ts +0 -29
  185. package/dist/types/react/ui/DataValue.d.ts +0 -9
  186. package/dist/types/react/ui/DataViewToast.d.ts +0 -11
  187. package/dist/types/react/ui/DataWidget.d.ts +0 -34
  188. package/dist/types/react/ui/DateDisplay.d.ts +0 -9
  189. package/dist/types/react/ui/DateRangePicker.d.ts +0 -30
  190. package/dist/types/react/ui/DateTimeTooltip.d.ts +0 -10
  191. package/dist/types/react/ui/DimensionPicker.d.ts +0 -13
  192. package/dist/types/react/ui/EmptyState.d.ts +0 -6
  193. package/dist/types/react/ui/ExportControl.d.ts +0 -4
  194. package/dist/types/react/ui/FilterActions.d.ts +0 -10
  195. package/dist/types/react/ui/FilterBar.d.ts +0 -3
  196. package/dist/types/react/ui/FunnelChart.d.ts +0 -20
  197. package/dist/types/react/ui/GettingStarted.d.ts +0 -6
  198. package/dist/types/react/ui/GlossaryDefinition.d.ts +0 -7
  199. package/dist/types/react/ui/GlossaryExplanation.d.ts +0 -16
  200. package/dist/types/react/ui/GradientScroll.d.ts +0 -23
  201. package/dist/types/react/ui/Grid.d.ts +0 -12
  202. package/dist/types/react/ui/GridItem.d.ts +0 -7
  203. package/dist/types/react/ui/HelpPopover.d.ts +0 -21
  204. package/dist/types/react/ui/IconButton.d.ts +0 -19
  205. package/dist/types/react/ui/InspectionContext.d.ts +0 -12
  206. package/dist/types/react/ui/InspectionProvider.d.ts +0 -29
  207. package/dist/types/react/ui/JourneyChart.d.ts +0 -10
  208. package/dist/types/react/ui/Kbd.d.ts +0 -7
  209. package/dist/types/react/ui/LineChart.d.ts +0 -7
  210. package/dist/types/react/ui/LiveControl.d.ts +0 -10
  211. package/dist/types/react/ui/Menu.d.ts +0 -12
  212. package/dist/types/react/ui/MetricWidget.d.ts +0 -49
  213. package/dist/types/react/ui/NumberField.d.ts +0 -27
  214. package/dist/types/react/ui/NumberFilterPicker.d.ts +0 -11
  215. package/dist/types/react/ui/PeriodSummary.d.ts +0 -17
  216. package/dist/types/react/ui/PickerField.d.ts +0 -15
  217. package/dist/types/react/ui/PieChart.d.ts +0 -11
  218. package/dist/types/react/ui/PopoverSurface.d.ts +0 -5
  219. package/dist/types/react/ui/PresentStory.d.ts +0 -30
  220. package/dist/types/react/ui/QueryList.d.ts +0 -14
  221. package/dist/types/react/ui/RadioGroup.d.ts +0 -18
  222. package/dist/types/react/ui/Ranking.d.ts +0 -13
  223. package/dist/types/react/ui/RefreshControl.d.ts +0 -9
  224. package/dist/types/react/ui/RequestHint.d.ts +0 -20
  225. package/dist/types/react/ui/RetentionChart.d.ts +0 -27
  226. package/dist/types/react/ui/ScatterChart.d.ts +0 -17
  227. package/dist/types/react/ui/SearchField.d.ts +0 -23
  228. package/dist/types/react/ui/SearchInput.d.ts +0 -10
  229. package/dist/types/react/ui/SearchMatch.d.ts +0 -6
  230. package/dist/types/react/ui/SearchTypeahead.d.ts +0 -15
  231. package/dist/types/react/ui/SectionHeading.d.ts +0 -8
  232. package/dist/types/react/ui/Select.d.ts +0 -18
  233. package/dist/types/react/ui/SelectionMark.d.ts +0 -5
  234. package/dist/types/react/ui/Sheet.d.ts +0 -21
  235. package/dist/types/react/ui/Skeleton.d.ts +0 -8
  236. package/dist/types/react/ui/Stack.d.ts +0 -7
  237. package/dist/types/react/ui/StaticDataApp.d.ts +0 -4
  238. package/dist/types/react/ui/StatusPanel.d.ts +0 -10
  239. package/dist/types/react/ui/TableWidget.d.ts +0 -67
  240. package/dist/types/react/ui/Tabs.d.ts +0 -10
  241. package/dist/types/react/ui/TextContent.d.ts +0 -4
  242. package/dist/types/react/ui/TextWidget.d.ts +0 -20
  243. package/dist/types/react/ui/ThemeSelector.d.ts +0 -12
  244. package/dist/types/react/ui/Toast.d.ts +0 -8
  245. package/dist/types/react/ui/Tooltip.d.ts +0 -23
  246. package/dist/types/react/ui/TooltipSurface.d.ts +0 -3
  247. package/dist/types/react/ui/TrendChart.d.ts +0 -5
  248. package/dist/types/react/ui/UpdatedAt.d.ts +0 -9
  249. package/dist/types/react/ui/VariableBar.d.ts +0 -6
  250. package/dist/types/react/ui/VisualizationWidget.d.ts +0 -43
  251. package/dist/types/react/ui/WidgetDisclosure.d.ts +0 -6
  252. package/dist/types/react/ui/WidgetEvidence.d.ts +0 -12
  253. package/dist/types/react/ui/WidgetViewTabs.d.ts +0 -16
  254. package/dist/types/react/ui/chart-data.d.ts +0 -34
  255. package/dist/types/react/ui/chart-date-axis.d.ts +0 -15
  256. package/dist/types/react/ui/chart-interaction.d.ts +0 -21
  257. package/dist/types/react/ui/chart-primitives.d.ts +0 -22
  258. package/dist/types/react/ui/chart-time.d.ts +0 -16
  259. package/dist/types/react/ui/chartColor.d.ts +0 -2
  260. package/dist/types/react/ui/classNames.d.ts +0 -1
  261. package/dist/types/react/ui/csv-export.d.ts +0 -19
  262. package/dist/types/react/ui/data-context.d.ts +0 -76
  263. package/dist/types/react/ui/data-identifiers.d.ts +0 -32
  264. package/dist/types/react/ui/icons.d.ts +0 -47
  265. package/dist/types/react/ui/index.d.ts +0 -109
  266. package/dist/types/react/ui/journey-flow.d.ts +0 -49
  267. package/dist/types/react/ui/keyboard.d.ts +0 -6
  268. package/dist/types/react/ui/metric-comparison.d.ts +0 -30
  269. package/dist/types/react/ui/metric.d.ts +0 -11
  270. package/dist/types/react/ui/presentation.d.ts +0 -25
  271. package/dist/types/react/ui/search.d.ts +0 -6
  272. package/dist/types/react/ui/searchItems.d.ts +0 -36
  273. package/dist/types/react/ui/shortcuts.d.ts +0 -45
  274. package/dist/types/react/ui/story.d.ts +0 -20
  275. package/dist/types/react/ui/useAppAppearance.d.ts +0 -3
  276. package/dist/types/react/ui/useDataAppPresentation.d.ts +0 -3
  277. package/dist/types/react/ui/useSvgId.d.ts +0 -2
  278. package/dist/types/react/ui/variables.d.ts +0 -38
  279. package/dist/types/react/ui/widget-views.d.ts +0 -3
  280. package/dist/types/react/view-control-bar.d.ts +0 -16
  281. package/dist/types/react/view-controls.d.ts +0 -20
  282. package/dist/types/react/view-runtime.d.ts +0 -31
  283. package/dist/types/react/view.d.ts +0 -78
  284. package/dist/types/react/widgets.d.ts +0 -79
  285. package/dist/types/server/local.d.ts +0 -19
  286. package/dist/types/server/preview/host.d.ts +0 -1
  287. package/dist/types/server/preview/index.d.ts +0 -16
  288. package/dist/types/server/reload-channel.d.ts +0 -6
  289. package/dist/worker.js +0 -106
@@ -1,16 +1,84 @@
1
+ import type { QueryResult } from './operation-types.js';
2
+ type QueryValues = {
3
+ string: string;
4
+ number: number;
5
+ boolean: boolean;
6
+ null: null;
7
+ };
8
+ /** Primitive values after decoding, independent of SQL storage types. */
9
+ export type QueryValueType = keyof QueryValues;
10
+ export type QueryField = {
11
+ type: QueryValueType;
12
+ nullable?: boolean;
13
+ };
14
+ export type QueryProjections = Readonly<Record<string, QueryField>>;
15
+ type QueryValue<Field extends QueryField> = QueryValues[Field['type']] | (Field extends {
16
+ nullable: true;
17
+ } ? null : never);
18
+ export type QueryRow<Projections extends QueryProjections> = {
19
+ -readonly [Name in keyof Projections]: QueryValue<Projections[Name]>;
20
+ };
1
21
  export type QueryParameterValue = string | number | boolean | null;
22
+ /** Typed scalar parameters with optional fallback values. */
23
+ export type QueryParameter = {
24
+ [Type in QueryValueType]: {
25
+ type: Type;
26
+ nullable?: false;
27
+ defaultValue?: QueryValues[Type];
28
+ } | {
29
+ type: Type;
30
+ nullable: true;
31
+ defaultValue?: QueryValues[Type] | null;
32
+ };
33
+ }[QueryValueType];
34
+ /** Callers may omit values supplied by host context or declaration defaults. */
35
+ export type QueryInputParameters<Params extends Readonly<Record<string, QueryParameter>>> = {
36
+ [Name in keyof Params]?: QueryValue<Params[Name]>;
37
+ };
2
38
  type QueryDefinition = {
3
39
  statement: string;
4
- params: Readonly<Record<string, {
5
- defaultValue?: QueryParameterValue;
6
- }>>;
40
+ params: Readonly<Record<string, QueryParameter>>;
41
+ projections: QueryProjections;
7
42
  };
8
43
  export type QueryDefinitions = Readonly<Record<string, QueryDefinition>>;
44
+ export type IsUnion<Value, Whole = Value> = Value extends Whole ? [Whole] extends [Value] ? false : true : never;
45
+ export type KnownRecord<RecordType> = '__proto__' extends keyof RecordType ? never : string extends keyof RecordType ? never : Exclude<keyof RecordType, string> extends never ? true extends IsUnion<RecordType> ? never : RecordType : never;
46
+ type CheckedField<Field extends QueryField> = true extends IsUnion<Field> ? never : true extends IsUnion<Field['type']> ? never : 'nullable' extends keyof Field ? Field extends {
47
+ nullable: infer Nullable;
48
+ } ? boolean extends Nullable ? never : Field : never : Field;
49
+ type CheckedParameters<Params extends Readonly<Record<string, QueryParameter>>> = KnownRecord<Params> & {
50
+ [Name in keyof Params]: CheckedField<Params[Name]> & ('defaultValue' extends keyof Params[Name] ? undefined extends Params[Name]['defaultValue'] ? never : Params[Name] : Params[Name]);
51
+ };
52
+ type CheckedProjections<Projections extends QueryProjections> = KnownRecord<Projections> & (keyof Projections extends never ? never : '' extends keyof Projections ? never : {
53
+ [Name in keyof Projections]: CheckedField<Projections[Name]>;
54
+ });
55
+ /** Author declarations preserve finite names, fixed types, and one parameter map. */
56
+ export type CheckedQueries<Queries extends QueryDefinitions> = KnownRecord<Queries> & ('' extends keyof Queries ? never : unknown) & {
57
+ [Name in keyof Queries]: KnownRecord<Queries[Name]> & {
58
+ statement: Queries[Name]['statement'] extends '' ? never : Queries[Name]['statement'];
59
+ params: CheckedParameters<Queries[Name]['params']>;
60
+ projections: CheckedProjections<Queries[Name]['projections']>;
61
+ };
62
+ };
63
+ type FrozenField<Field extends QueryField> = Field extends unknown ? Readonly<Field> : never;
64
+ export type QuerySnapshot<Queries extends QueryDefinitions> = {
65
+ readonly [Name in keyof Queries]: {
66
+ readonly statement: Queries[Name]['statement'];
67
+ readonly params: {
68
+ readonly [Param in keyof Queries[Name]['params']]: FrozenField<Queries[Name]['params'][Param]>;
69
+ };
70
+ readonly projections: {
71
+ readonly [Field in keyof Queries[Name]['projections']]: FrozenField<Queries[Name]['projections'][Field]>;
72
+ };
73
+ };
74
+ };
9
75
  /** Parameters are scalar SQL values, never identifiers or SQL fragments. */
10
76
  export type QueryParameters = Readonly<Record<string, QueryParameterValue>>;
11
77
  export declare function isQueryParameters(value: unknown): value is QueryParameters;
12
- /** Retain authored statements and defaults, rejecting empty SQL and invalid scalar defaults. */
13
- export declare function snapshotQueries(definitions: QueryDefinitions): QueryDefinitions;
14
- /** Context owns protected values; callers supply filters; defaults fill remaining declarations. */
15
- export declare function resolveQueryParameters(declarations: QueryDefinition['params'], values: Partial<QueryParameters>, context: QueryParameters): QueryParameters;
78
+ /** Snapshot the query's SQL, parameter defaults, and decoded result contract. */
79
+ export declare function snapshotQueries<const Queries extends QueryDefinitions>(definitions: Queries): QuerySnapshot<Queries>;
80
+ /** Decode each returned cell once, matching aliases independently of result order. */
81
+ export declare function decodeQueryResult<Projections extends QueryProjections>(result: QueryResult, projections: Projections): QueryResult<QueryRow<Projections>>;
82
+ /** Host context supplies protected values; callers and defaults fill the remaining parameters. */
83
+ export declare function resolveQueryParameters(declarations: Readonly<Record<string, QueryParameter>>, values: Partial<QueryParameters>, context: QueryParameters): QueryParameters;
16
84
  export {};
@@ -1,4 +1,4 @@
1
- import type { DateRangeRequest } from './contract.js';
1
+ import { type DateRangeRequest } from './contract.js';
2
2
  export type DataReading<Value> = {
3
3
  loading: true;
4
4
  value?: never;
@@ -1,12 +1,18 @@
1
+ import type { IsUnion } from './queries.js';
2
+ import { facetSource, type FacetVariable } from './facets.js';
3
+ import type { SourceDimensionVariable } from './dimension-source.js';
1
4
  import { type DatePresetId, type DateRange } from './date-range.js';
2
5
  import type { DateRangeContract, DateRangeRequest } from './contract.js';
3
- import type { DimensionSelection, DimensionVariable } from './dimension.js';
6
+ import type { DimensionSelection, DimensionVariable, DimensionSelectionVariable } from './dimension.js';
4
7
  import type { NumberFilter, BooleanFilter } from './filters.js';
5
8
  import type { HistoryMode } from './navigation.js';
6
9
  export type { HistoryMode } from './navigation.js';
7
10
  export type VariablePresentation = {
8
11
  /** Scope changes the included data; display changes its presentation. Defaults to scope. */
9
12
  group?: 'scope' | 'display';
13
+ /** Widget controls render beside their visualization instead of in the toolbar.
14
+ * Scope filters remain available in the Filters sheet and active summaries. */
15
+ control?: 'toolbar' | 'widget';
10
16
  /** Secondary scope controls live in the Filters sheet with compact pickers when active; secondary display options follow primary options. Defaults to primary. */
11
17
  prominence?: 'primary' | 'secondary';
12
18
  };
@@ -26,10 +32,24 @@ export type AppVariable<Value, Kind extends string = string> = {
26
32
  valid: (value: Value) => boolean;
27
33
  same: (left: Value, right: Value) => boolean;
28
34
  };
29
- export type VariableCollection = Record<string, SearchVariable | ChoiceVariable | MultiChoiceVariable | DateRangeVariable | DimensionVariable<any> | NumberFilter | BooleanFilter>;
35
+ export type VariableCollection = Record<string, SearchVariable | ChoiceVariable<any> | MultiChoiceVariable | DateRangeVariable | DimensionVariable<any> | FacetVariable<any, any, string, unknown> | SourceDimensionVariable<any> | NumberFilter | BooleanFilter>;
30
36
  export type AppVariableValues<Variables> = {
31
- [Key in keyof Variables]: Variables[Key] extends DimensionVariable<infer Value> ? DimensionSelection<Value> : Variables[Key] extends AppVariable<infer Value, string> ? Value : never;
37
+ [Key in keyof Variables]: Variables[Key] extends DimensionSelectionVariable<infer Value> ? DimensionSelection<Value> : Variables[Key] extends AppVariable<infer Value, string> ? Value : never;
32
38
  };
39
+ /** Keep conditional declarations narrowed so every dependency has one contract. */
40
+ export type CheckedVariableDeclarations<Variables extends VariableCollection> = true extends IsUnion<Variables> ? never : string extends keyof Variables ? Variables : '__proto__' extends keyof Variables ? never : {
41
+ [Name in keyof Variables]: true extends IsUnion<Variables[Name]> ? never : Variables[Name];
42
+ };
43
+ /** Every facet dependency must be present with a compatible variable declaration. */
44
+ export type CheckedFacetContexts<Variables extends VariableCollection> = CheckedVariableDeclarations<Variables> & (string extends keyof Variables ? Extract<Variables[keyof Variables], {
45
+ [facetSource]: unknown;
46
+ }> extends never ? Variables : never : {
47
+ [Name in keyof Variables]: Variables[Name] extends {
48
+ [facetSource]: {
49
+ context: infer Context;
50
+ };
51
+ } ? string extends keyof Context ? never : Variables extends Context ? Variables[Name] : never : Variables[Name];
52
+ });
33
53
  /** Name variables once in the app. URL keys must be unique across its controls. */
34
54
  export declare function defineAppVariables<const Variables extends VariableCollection>(variables: Variables): Variables;
35
55
  type ScalarVariableOptions = {
@@ -45,7 +65,7 @@ export type ChoiceOption = {
45
65
  label: string;
46
66
  description?: string;
47
67
  };
48
- export type ChoiceVariable = AppVariable<string, 'choice'> & {
68
+ export type ChoiceVariable<Value extends string = string> = AppVariable<Value, 'choice'> & {
49
69
  options: readonly ChoiceOption[];
50
70
  };
51
71
  export type MultiChoiceVariable = AppVariable<readonly string[], 'multiChoice'> & {
@@ -56,15 +76,21 @@ export type MultiChoiceVariable = AppVariable<readonly string[], 'multiChoice'>
56
76
  export declare function searchVariable({ key, label, defaultValue, history, }: Omit<ScalarVariableOptions, 'presentation'>): SearchVariable;
57
77
  /** Validate labeled choices before controls or URL state consume them. */
58
78
  export declare function validateChoiceOptions(options: readonly ChoiceOption[]): void;
59
- export declare function choiceVariable({ key, label, defaultValue, options, history, presentation, }: ScalarVariableOptions & {
60
- defaultValue: string;
61
- options: readonly ChoiceOption[];
62
- }): ChoiceVariable;
63
- export declare function multiChoiceVariable({ key, label, defaultValue, options, maxSelected, history, presentation, }: Omit<ScalarVariableOptions, 'defaultValue'> & {
64
- defaultValue?: readonly string[];
65
- options: readonly ChoiceOption[];
79
+ export declare function choiceVariable<const Options extends readonly ChoiceOption[], const Presentation extends VariablePresentation | undefined = undefined>({ key, label, defaultValue, options, history, presentation, }: Omit<ScalarVariableOptions, 'presentation'> & {
80
+ presentation?: Presentation;
81
+ defaultValue: NoInfer<Options[number]['id']>;
82
+ options: Options & (Options extends readonly [] ? never : unknown);
83
+ }): ChoiceVariable<Options[number]['id']> & {
84
+ presentation?: Presentation;
85
+ };
86
+ export declare function multiChoiceVariable<const Options extends readonly ChoiceOption[], const Presentation extends VariablePresentation | undefined = undefined>({ key, label, defaultValue, options, maxSelected, history, presentation, }: Omit<ScalarVariableOptions, 'defaultValue' | 'presentation'> & {
87
+ presentation?: Presentation;
88
+ defaultValue?: readonly NoInfer<Options[number]['id']>[];
89
+ options: Options & (Options extends readonly [] ? never : unknown);
66
90
  maxSelected?: number;
67
- }): MultiChoiceVariable;
91
+ }): MultiChoiceVariable & {
92
+ presentation?: Presentation;
93
+ };
68
94
  export type DateRangeSelection = {
69
95
  kind: 'preset';
70
96
  id: DatePresetId;
@@ -1,3 +1,3 @@
1
1
  /** Portable data app declarations; safe in browser and server modules. */
2
2
  export { defineDataApp, dataAppTitle } from './core/config.js';
3
- export type { DataAppConfig, DataAppDefinition, QueryDefinitions, QueryParameterValue, } from './core/config.js';
3
+ export type { DataAppConfig, DataAppDefinition, QueryDefinitions, QueryParameterValue, QueryParameter, QueryValueType, QueryField, QueryProjections, QueryRow, } from './core/config.js';
@@ -0,0 +1,22 @@
1
+ /** Shared implementation for the coordinated data-app packages; not an app authoring API. */
2
+ export { downloadBlob } from './client/download.js';
3
+ export { localFrameBridge } from './client/iframe.js';
4
+ export { createBridgeEndpoint } from './core/bridge-endpoint.js';
5
+ export { type BridgeDiagnostic, type BridgeEventMessage, MAX_PENDING, PARENT_PARAM, REQUEST_TIMEOUT_MS, validId, } from './core/bridge.js';
6
+ export { type DataView, type DisplayedSnapshot, displayedSnapshot, resolveDataView, } from './core/data-view.js';
7
+ export { type DatePreset, type DatePresetId, type DateRange, availableDatePresets, inclusiveDays, withinBounds, } from './core/date-range.js';
8
+ export { type DimensionFilterSettings, type DimensionValue, dimensionMemberKey, } from './core/dimension.js';
9
+ export { numberOperatorLabels } from './core/filters.js';
10
+ export { invariant } from './core/invariant.js';
11
+ export { toDataOperationFailure } from './core/operation.js';
12
+ export { type DataAppPresentation, isDataAppPresentation, } from './core/presentation.js';
13
+ export { type DataReading, type MetricReading, type MetricValues, } from './core/reading.js';
14
+ export { randomUuid } from './core/uuid.js';
15
+ export { type AppVariable, type AppVariableValues, type ChoiceOption, type ChoiceVariable, type DateRangeSelection, type DateRangeVariable, type DateRangeVariableOptions, type HistoryMode, type MultiChoiceVariable, type SearchVariable, type VariableCollection, type VariablePresentation, choiceVariable, dateRangeVariable, defineAppVariables, multiChoiceVariable, searchVariable, validateChoiceOptions, } from './core/variables.js';
16
+ export { RequestBodyTooLargeError, readRequestBody, } from './server/request-body.js';
17
+ export { KEY_SEPARATOR } from './core/keys.js';
18
+ export { type CheckedFacetContexts, type CheckedVariableDeclarations, } from './core/variables.js';
19
+ export { type IsUnion } from './core/queries.js';
20
+ export { facetSource, type FacetVariable } from './core/facets.js';
21
+ export { createDimensionFilter, type DimensionSelectionVariable, } from './core/dimension.js';
22
+ export { dimensionSource, type SourceDimensionVariable, } from './core/dimension-source.js';
@@ -3,5 +3,4 @@
3
3
  * @module @altertable/data-app/server
4
4
  * @see https://github.com/altertable-ai/data-app/blob/main/docs/server.md
5
5
  */
6
- export { createDataHandler } from './handler.js';
7
- export type { RequestAccess } from './handler.js';
6
+ export { createDataHandler, type RequestAccess } from './handler.js';
@@ -11,12 +11,19 @@ Declare the query source of truth with `defineDataApp()`. Generate
11
11
  operations with `dataApp.defineOperation()` and execute queries by
12
12
  name with parameter values. When a query registry is supplied, use only its queries
13
13
  and preserve its SQL. Otherwise, inspect the data and declare the queries the app needs.
14
- Derive displays, exports, and findings from their results. See
15
- [named queries](contract.md#execute-named-queries).
14
+ Declare inspected result aliases in `projections` and derive displays, exports,
15
+ and findings from the typed rows. See [named queries](contract.md#execute-named-queries).
16
16
 
17
17
  Inspect the relevant catalogs, tables, and fields, their time coverage, and
18
18
  existing definitions. Choose a question the available data can answer.
19
19
 
20
+ ## Compose the exploration
21
+
22
+ Plan the question, analytical sequence, and role of each display before choosing
23
+ components. Follow [Compose an exploration](composition.md) to connect filters,
24
+ widgets, layout, and narrative into a coherent investigation, then distill its
25
+ supported findings into a story.
26
+
20
27
  ## Choose the visualizations
21
28
 
22
29
  Before implementing queries and rendering, identify the question each visual
@@ -59,7 +66,7 @@ refresh, and failure.
59
66
  | Task | Documentation |
60
67
  | ------------------------------------------------ | ----------------------------------------------------------------- |
61
68
  | Choose components, CSS tokens, and styling hooks | [Styling](styling.md) |
62
- | Define queries, inputs, and result parsing | [Operations](contract.md) |
69
+ | Define queries, inputs, and typed results | [Operations](contract.md) |
63
70
  | Build views, filters, and request states | [Views](views.md) |
64
71
  | Introduce and explain visualizations | [Narrative text](widgets.md#narrative-text) |
65
72
  | Find formatters and presentation helpers | [App helpers](formatting-and-appearance.md) |
@@ -69,6 +76,7 @@ refresh, and failure.
69
76
  | Export displayed data as CSV | [CSV export](stories-and-export.md#export-displayed-data-as-csv) |
70
77
  | Render widgets and custom visuals | [Widgets](widgets.md) |
71
78
  | Bind definitions and source evidence | [Data context](data-context.md#bind-evidence) |
79
+ | Look up props, signatures, and types | [API reference](../REFERENCE.md) |
72
80
 
73
81
  Declare reusable [datasets and metrics](widgets.md#declare-datasets-and-metrics)
74
82
  on the view so tables, exports, and stories share values and evidence.
@@ -82,7 +90,7 @@ Use the [standard layout](layout.md) and built-in toolbar actions.
82
90
  ### Organize the exploration
83
91
 
84
92
  Use sections for a focused question and for findings users should compare
85
- side by side. Add app-level `<Tabs>` from `/react/ui` when the exploration has
93
+ side by side. Add app-level `<Tabs>` from `@altertable/data-app-react/ui` when the exploration has
86
94
  distinct analytical questions, such as Overview, Retention, and Segments, each
87
95
  with its own context and group of widgets. Lead with the most useful overview
88
96
  and label tabs by the question or subject they explore.
package/docs/client.md CHANGED
@@ -15,18 +15,17 @@ const response = await client.query('activity', input, { signal });
15
15
  ```
16
16
 
17
17
  The app defines `operations`, `input`, and an optional cancellation `signal`.
18
- Operation input and output types are inferred from the server operation map. Keep the
19
- server operation map import type-only so its implementations stay on the server.
20
- The shared app declaration contains the query registry and is browser-safe.
18
+ Inputs and data are inferred from the operation map and `run()`. Keep the import
19
+ type-only so operation implementations stay on the server.
21
20
 
22
21
  The default endpoint is `/api/data`. Override it with
23
- `createDataClient({ endpoint, fetch })` to change the base URL or supply a Fetch
22
+ `createDataClient<typeof operations>({ endpoint, fetch })` to change the base URL or supply a Fetch
24
23
  implementation. Calls POST JSON to `/api/data/:operation`; the client sends
25
24
  operation inputs rather than SQL or credentials.
26
25
 
27
26
  `DataResponse` contains `data`, the exact request `input`, `requestId`,
28
27
  `queriedAt`, `queryIds`, and executed `queries`. Use the returned input when labeling stale data during a refresh.
29
- HTTP and iframe delivery validate the same success envelope: data, request ID,
28
+ HTTP and iframe delivery validate the success envelope: data, request ID,
30
29
  query timestamp, query IDs, and optional query evidence. Malformed responses
31
30
  reject with `invalid_response`.
32
31
 
@@ -72,7 +71,7 @@ the host through the existing bridge cancellation protocol.
72
71
 
73
72
  ## Iframe transport
74
73
 
75
- `createDataClient({ transport })` accepts a `DataTransport`. Without an explicit
74
+ `createDataClient<typeof operations>({ transport })` accepts a `DataTransport`. Without an explicit
76
75
  transport, endpoint, or Fetch implementation, it discovers an installed iframe
77
76
  transport before falling back to HTTP. Explicit endpoint/Fetch options select
78
77
  HTTP. `createHttpTransport()` provides the underlying operation delivery adapter.
@@ -0,0 +1,84 @@
1
+ # Compose an exploration
2
+
3
+ Start with the question the user needs to answer. Define its population, period,
4
+ measures, and comparison. Choose the analytical flow before choosing widgets;
5
+ a focused answer may need only a chart and a paragraph.
6
+
7
+ ## Build a sequence of questions
8
+
9
+ Lead with the strongest supported result and visible scope. Give each section a
10
+ question that advances the investigation: what happened, when or against what
11
+ baseline, where it differs, and which details support the finding. Omit steps
12
+ that add no useful evidence.
13
+
14
+ Give each element a purpose:
15
+
16
+ | Element | Purpose |
17
+ | --------- | ------------------------------------------------------------------------ |
18
+ | Metric | Establish magnitude or change. |
19
+ | Chart | Reveal the pattern that answers the section's question. |
20
+ | Narrative | Explain interpretation, qualify a claim, or suggest the next comparison. |
21
+ | Table | Support exact comparisons and inspection. |
22
+ | Filter | Test a relevant hypothesis or change the scope. |
23
+
24
+ Use `<Stack>` for reading order, `<SectionHeading>` for questions, and `<Grid>`
25
+ for peer widgets users should compare together. Give the main visual enough
26
+ space and preserve reading order on phones. Place explanations beside their
27
+ evidence, using `<TextContent>` for introductions or `<TextWidget>` for a panel.
28
+ See [layout](layout.md) and [widget selection](widgets.md#choose-a-visualization).
29
+
30
+ Keep a connected investigation on one page. Use app tabs for distinct analytical
31
+ questions and widget `views` for alternate representations of the same dataset.
32
+
33
+ ## Make filters serve the question
34
+
35
+ Offer controls with a clear analytical use, such as dates to locate a change or
36
+ channels to test whether it is widespread. Choose useful defaults with adequate
37
+ coverage and make each filter's scope clear.
38
+
39
+ Keep related metrics, charts, and prose consistent in population, definitions,
40
+ units, and comparison periods. Explain deliberate differences. Show counts
41
+ alongside rates when sample size matters; calculate overall rates from their
42
+ numerators and denominators rather than averaging subgroup rates.
43
+
44
+ Derive findings and qualifications from the displayed result and its input.
45
+ A claim about all channels may no longer hold after selecting one. Retain the
46
+ displayed scope during refresh or failure. See [variables](variables.md) and
47
+ [displayed results](views.md#preserve-displayed-results).
48
+
49
+ ## Example: where are we losing signups?
50
+
51
+ Define funnel entry, the completion window, and channel attribution. Compare
52
+ populations with equal opportunity to complete; identify incomplete observations.
53
+ Then compose the page in this order:
54
+
55
+ | Question | Display and purpose |
56
+ | -------------------------------------- | ---------------------------------------------------------------------------------------------------- |
57
+ | How many starters complete? | Conversion against a comparable prior period, with starter and completion counts to establish scale. |
58
+ | When does conversion change? | Trend to locate the change, with incomplete periods identified. |
59
+ | At which step, and for which channels? | Funnel and channel comparisons with counts and rates to locate differences. |
60
+ | What supports the comparison? | Table of channel and step counts, denominators, and rates for inspection and export. |
61
+
62
+ Use one declared view for these related datasets. Put outcome metrics in a
63
+ `<Grid>`, give the trend its own row, then show the funnel, channel comparison,
64
+ and table. Reuse datasets for charts and tables, and bind narrative to the same
65
+ source. See [views](views.md) and [bindings](widgets.md#declare-datasets-and-metrics).
66
+
67
+ Let the date filter select funnel entry dates and the channel filter affect every
68
+ section. Start with all channels and adequate coverage. Selecting one channel
69
+ should help compare its steps and periods; update the headline to match that scope.
70
+
71
+ ## Distill the story
72
+
73
+ Select one to four findings that answer the main question from the displayed
74
+ result. Reuse its bindings, scope, and evidence in the story and CSV export.
75
+ See [stories and export](stories-and-export.md).
76
+
77
+ For the signup example, present the conversion change, the step or channel where
78
+ the difference is largest, and any qualification about counts or coverage, when
79
+ supported. Observed differences suggest where to investigate; they do not
80
+ establish a cause.
81
+
82
+ Verify the initial scope and a changed filter: does each section advance the
83
+ question, and does the story agree with the visible evidence? Check reading order
84
+ and context on phones and through the [UI quality states](ui-quality.md).
package/docs/contract.md CHANGED
@@ -8,17 +8,12 @@ import operation types using `import type`.
8
8
 
9
9
  ## Execute named queries
10
10
 
11
- Declare SQL once with `defineDataApp()` to preserve exact query and parameter
12
- names. Use stable `lowerCamelCase` IDs describing the result, such as `products`,
13
- `productsByCategory`, or `dailyRevenue`. Use plural names for row lists; keep parameter
14
- values in `params`. Every query must include `params`; use `{}` when it declares no
15
- parameters.
16
- The app owns an immutable registry snapshot. Define operations with
17
- `dataApp.defineOperation()`.
11
+ Declare queries with `defineDataApp()` and operations with `dataApp.defineOperation()`.
12
+ Use descriptive `lowerCamelCase` query names. Declare parameter types in `params`
13
+ (use `{}` for none) and returned aliases in `projections`.
18
14
 
19
15
  ```ts
20
16
  import { defineDataApp } from '@altertable/data-app';
21
- import { rowsAsRecords } from '@altertable/data-app/contract';
22
17
 
23
18
  const dataApp = defineDataApp({
24
19
  title: 'Products',
@@ -27,8 +22,16 @@ const dataApp = defineDataApp({
27
22
  appearance: { theme: 'system' },
28
23
  queries: {
29
24
  products: {
30
- statement: 'SELECT * FROM products WHERE org_id = $orgId LIMIT $limit',
31
- params: { orgId: {}, limit: { defaultValue: 10 } },
25
+ statement:
26
+ 'SELECT name, unit_price AS "unitPrice" FROM products WHERE org_id = $orgId LIMIT $limit',
27
+ params: {
28
+ orgId: { type: 'string' },
29
+ limit: { type: 'number', defaultValue: 10 },
30
+ },
31
+ projections: {
32
+ name: { type: 'string' },
33
+ unitPrice: { type: 'number', nullable: true },
34
+ },
32
35
  },
33
36
  },
34
37
  });
@@ -39,21 +42,38 @@ const products = dataApp.defineOperation({
39
42
  policy: { maxQueryRows: 100, maxDurationMs: 15000 },
40
43
  async run({ query }, input) {
41
44
  const result = await query('products', input);
42
- return parseProducts(rowsAsRecords(result, ['name', 'price']));
45
+ return result.rows;
43
46
  },
44
47
  });
45
48
  ```
46
49
 
47
- `parseProductInput()` and `parseProducts()` are app-owned example functions, not
48
- package exports. Validate filter values in the input parser. Parse query rows once, in
49
- `run`: the value it returns is the operation's data and type, sent to the view as is. `{}` declares a required parameter; `{ defaultValue }` supplies
50
- a fallback. `query(name, params, { limit })` executes only registered queries and
51
- inherits the operation's row limit and cancellation signal.
50
+ `parseProductInput()` is app-owned. Validate inputs there and business rules in
51
+ `run()`. Derive operation data from `query()` rows; clients and views infer the
52
+ returned type. Handle empty results. HTTP results must be JSON-serializable.
53
+ Include representative valid inputs in `checks`.
52
54
 
53
- SQL and resolved parameter values pass unchanged to the backend. Results include
54
- query evidence; use `products.queryNames` with `createDataContext()` to bind it.
55
- For HTTP apps, authorization can supply protected `queryParams`, such as `orgId`.
56
- The host/backend enforces data access and limits.
55
+ Host `queryParams` supplies protected parameters; callers cannot override them.
56
+ Other values come from `query()` arguments or `defaultValue`. Missing values are
57
+ checked before execution. `query(name, params, { limit })` inherits the operation's
58
+ row limit and cancellation signal.
59
+
60
+ ### Declare query projections
61
+
62
+ Inspect each query and declare every returned alias with `{ type, nullable? }`.
63
+ Result keys keep the exact SQL names; alias columns in SQL to change casing, as
64
+ with `"unitPrice"` above.
65
+ Determine nullability from the schema and SQL, even when sampled rows contain no
66
+ nulls. Update projections when changing SQL.
67
+
68
+ `query()` converts result cells to the declared types before `run()` uses them.
69
+ Numbers that cannot be converted become `"##ERROR##"`; booleans use JavaScript
70
+ truthiness. Nulls pass through unless `nullable: false`. Parameters are validated
71
+ without conversion. For exact numeric precision, return SQL text
72
+ and declare `string`.
73
+
74
+ Results include query evidence; use `products.queryNames` with `createDataContext()`
75
+ to bind it. The host/backend enforces data access and limits; see
76
+ [server authorization](server.md).
57
77
 
58
78
  ## Shared date ranges
59
79
 
@@ -93,7 +113,7 @@ import {
93
113
  defineMessageRoute,
94
114
  navigationUpdateRoute,
95
115
  } from '@altertable/data-app/contract';
96
- import { createNavigationHandler } from '@altertable/data-app/embed';
116
+ import { createNavigationHandler } from '@altertable/data-app-embed';
97
117
 
98
118
  const routes = {
99
119
  'demo:echo': defineMessageRoute({ input: parseString, output: parseString }),
@@ -2,6 +2,8 @@
2
2
 
3
3
  Set `dataContext: context` in each view for source descriptions, glossary, and
4
4
  permitted query evidence. App inspection and the view's sections use that context.
5
+ Keep glossary query references scoped to that view's executed queries. Detail
6
+ views declare their own context when their queries differ.
5
7
  Render registered identifiers where `<DataIdentifier>` is used.
6
8
 
7
9
  Physical source identifiers name inspected tables and columns. Glossary entries
@@ -10,12 +12,12 @@ to their execution evidence. Keep all three explicit.
10
12
 
11
13
  ## Register source identifiers
12
14
 
13
- Use `defineDataIdentifiers()` from `/react` to register exact catalog, schema,
15
+ Use `defineDataIdentifiers()` from `@altertable/data-app-react` to register exact catalog, schema,
14
16
  table, and field names. Use `<DataIdentifier>` in descriptions and glossary
15
17
  entries to render those source references consistently.
16
18
 
17
19
  ```tsx
18
- import { defineDataIdentifiers } from '@altertable/data-app/react';
20
+ import { defineDataIdentifiers } from '@altertable/data-app-react';
19
21
 
20
22
  const identifiers = defineDataIdentifiers({
21
23
  tables: {
@@ -83,7 +85,7 @@ const finding = context.finding({
83
85
 
84
86
  Query inspection shows the executed SQL and resolved parameters; copy actions include both.
85
87
 
86
- Import context and identifier factories from `/react`. Use the operation’s derived `queryNames` for evidence.
88
+ Import context and identifier factories from `@altertable/data-app-react`. Use the operation’s derived `queryNames` for evidence.
87
89
 
88
90
  Use `view.metric(definition, select)` to register and bind a metric in one call.
89
91
  Declare dataset evidence references inside `view.dataset()`; the view registers
package/docs/embed.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Embed a data app
2
2
 
3
- Import framework-neutral host APIs from `@altertable/data-app/embed`. For React
3
+ Import framework-neutral host APIs from `@altertable/data-app-embed`. For React
4
4
  hosts, see [React embedding](react-embed.md). Neither embedding entry requires the
5
5
  app UI stylesheet.
6
6
 
@@ -10,7 +10,7 @@ app UI stylesheet.
10
10
  message delivery. The host supplies an iframe and a validated message dispatcher:
11
11
 
12
12
  ```ts
13
- import { attachDataAppBridge } from '@altertable/data-app/embed';
13
+ import { attachDataAppBridge } from '@altertable/data-app-embed';
14
14
 
15
15
  const host = attachDataAppBridge({
16
16
  iframe,
@@ -59,7 +59,7 @@ For other hosts that own their HTML and security policy, bundle this initializer
59
59
  into the bootstrap document before any app code:
60
60
 
61
61
  ```ts
62
- import { startDataAppBootstrap } from '@altertable/data-app/embed';
62
+ import { startDataAppBootstrap } from '@altertable/data-app-embed';
63
63
 
64
64
  const dispose = startDataAppBootstrap({
65
65
  parentOrigin: 'https://host.example.com',
@@ -121,7 +121,7 @@ import {
121
121
  createMessageRouter,
122
122
  sqlQueryRoute,
123
123
  } from '@altertable/data-app/contract';
124
- import { createSqlQueryHandler } from '@altertable/data-app/embed';
124
+ import { createSqlQueryHandler } from '@altertable/data-app-embed';
125
125
 
126
126
  const router = createMessageRouter(
127
127
  { 'data:sql': sqlQueryRoute },
@@ -35,7 +35,7 @@ formatCount(2_200_000); // "2,200,000"
35
35
  For signed or fractional measures, use `formatNumber()` with
36
36
  `notation: 'compact'` and preserve the measure's units.
37
37
 
38
- Import `chartColor()` from `/react` to select colors from the configured palette.
38
+ Import `chartColor()` from `@altertable/data-app-react` to select colors from the configured palette.
39
39
  `<PeriodSummary>` describes reporting periods; `<UpdatedAt>` and
40
40
  `<DateTimeTooltip>` expose readable timestamps with exact-date details.
41
41
  `<DataTableTimestamp>` and `<DataTableShare>` format custom table cells.
@@ -15,6 +15,10 @@ Replace the sample app declaration, operations, filters, data context, CSV expor
15
15
  an exploration of the source data you inspected. The starter uses two SQL
16
16
  `VALUES` rows, so it needs no production table.
17
17
 
18
+ `defineDataApp()` requires `scope`, and `<DataApp>` from `/react` requires
19
+ `story` and `datasets`; the [API reference](../REFERENCE.md) marks every
20
+ optional prop with `?`.
21
+
18
22
  For execution details, see [browser-owned operations](client.md#browser-owned-operations-for-bundle-apps).
19
23
 
20
24
  ## Convert a local data app
@@ -1,8 +1,9 @@
1
1
  # React embedding
2
2
 
3
- Import `<DataAppBridge>` from `@altertable/data-app/react/embed`. This entry depends
3
+ Import `<DataAppBridge>` from `@altertable/data-app-embed/react`. This entry depends
4
4
  on React and the embedding engine, and does not load the app's widgets, React
5
- Query, or CSS.
5
+ Query, or CSS. `@altertable/data-app-react` builds the UI inside the iframe;
6
+ neither package imports the other. Both use the base package's contracts.
6
7
 
7
8
  The bridge owns iframe setup and `postMessage()` communication. The consuming
8
9
  frontend or CLI owns its shell: fetching a bundle, subscriptions, layout, loading
@@ -16,8 +17,8 @@ only the iframe; it adds no loading, error, or retry UI and does not hide the fr
16
17
 
17
18
  ```tsx
18
19
  import { useReducer, useState } from 'react';
19
- import { DataAppBridge } from '@altertable/data-app/react/embed';
20
- import type { DataAppStatus } from '@altertable/data-app/embed';
20
+ import { DataAppBridge } from '@altertable/data-app-embed/react';
21
+ import type { DataAppStatus } from '@altertable/data-app-embed';
21
22
 
22
23
  function Shell() {
23
24
  const [status, setStatus] = useState<DataAppStatus>('connecting');
@@ -69,7 +70,7 @@ owns a loaded iframe and its security policy:
69
70
 
70
71
  ```tsx
71
72
  import { useState, type ComponentRef } from 'react';
72
- import { DataAppBridge } from '@altertable/data-app/react/embed';
73
+ import { DataAppBridge } from '@altertable/data-app-embed/react';
73
74
 
74
75
  function Host() {
75
76
  const [iframe, setIframe] = useState<ComponentRef<'iframe'> | null>(null);
@@ -95,7 +96,7 @@ are mutually exclusive.
95
96
  ## Loading an embedded app
96
97
 
97
98
  The host owns loading and generation UI while an app starts. Use a neutral
98
- status that does not imply a particular app layout. `/react/embed` remains
99
+ status that does not imply a particular app layout. `@altertable/data-app-embed/react` remains
99
100
  independent of UI components and styles. Once the app loads, its query and
100
101
  widget loading states describe the content they replace.
101
102