@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
package/docs/react.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # React
2
2
 
3
- Import hooks, components, and UI helpers from `@altertable/data-app/react`.
3
+ Import hooks, components, and UI helpers from `@altertable/data-app-react`.
4
4
  React 19.2 or newer and React DOM 19.2 or newer are peer dependencies.
5
5
 
6
6
  ## Mount the app
7
7
 
8
8
  Use `mountDataApp({ app, component })` to mount into `#root`. When mounting
9
- through another framework, wrap the root in `<DataAppProvider app={app}>` from `/react/ui`.
9
+ through another framework, wrap the root in `<DataAppProvider app={app}>` from `@altertable/data-app-react/ui`.
10
10
  `<DataApp>` inherits identity and appearance from that root.
11
11
 
12
12
  ```tsx
13
- import { injectDataAppStyles, mountDataApp } from '@altertable/data-app/react';
13
+ import { injectDataAppStyles, mountDataApp } from '@altertable/data-app-react';
14
14
 
15
15
  injectDataAppStyles();
16
16
  mountDataApp({ app, component: App });
@@ -20,8 +20,8 @@ Call `injectDataAppStyles()` before mounting; no separate stylesheet is needed.
20
20
  For a restrictive CSP, pass the permitted nonce on the first call.
21
21
  See [Styling](styling.md) for appearance, CSS tokens, and overrides.
22
22
 
23
- Use `/react` for declared views, bound widgets, and layouts. Use
24
- [`/react/ui`](ui.md) for setup/static screens and direct UI composition.
23
+ Use `@altertable/data-app-react` for declared views, bound widgets, and layouts. Use
24
+ [`@altertable/data-app-react/ui`](ui.md) for setup/static screens and direct UI composition.
25
25
 
26
26
  ## Choose a task
27
27
 
@@ -4,11 +4,11 @@ Use this Bun server for local data apps. Start from the CLI scaffold or
4
4
  [local data app starter](https://github.com/altertable-ai/data-app/tree/main/examples/starter-local-data-app).
5
5
 
6
6
  Import `serveLocalApp()` and `localLakehouse()` from
7
- `@altertable/data-app/server/bun`. This entry requires Bun; install `@types/bun`
7
+ `@altertable/data-app-bun`. This entry requires Bun; install `@types/bun`
8
8
  when typechecking a Bun app.
9
9
 
10
10
  ```ts
11
- import { serveLocalApp } from '@altertable/data-app/server/bun';
11
+ import { serveLocalApp } from '@altertable/data-app-bun';
12
12
  import page from './index.html';
13
13
  import { operations } from './operations';
14
14
 
@@ -30,13 +30,13 @@ hosting an app for other people.
30
30
 
31
31
  ## Preview a single-file app
32
32
 
33
- Import `serveAppFile()` from `@altertable/data-app/server/bun/preview` to preview
33
+ Import `serveAppFile()` from `@altertable/data-app-bun/preview` to preview
34
34
  an app in the hosted sandbox. The caller supplies the server-only lakehouse.
35
35
  The runtime owns bundling, imported-file watching, reloads, navigation, and exports.
36
36
 
37
37
  ```ts
38
- import { serveAppFile } from '@altertable/data-app/server/bun/preview';
39
- import { localLakehouse } from '@altertable/data-app/server/bun';
38
+ import { serveAppFile } from '@altertable/data-app-bun/preview';
39
+ import { localLakehouse } from '@altertable/data-app-bun';
40
40
 
41
41
  const preview = await serveAppFile({
42
42
  file: '/absolute/path/index.tsx',
package/docs/server.md CHANGED
@@ -24,7 +24,7 @@ export const handleDataRequest = createDataHandler(
24
24
  The app supplies `authenticate()` and `lakehouseFor()`, then routes `/api/data/*`
25
25
  requests to the handler. Authorize every viewer and operation, and scope the
26
26
  returned lakehouse to the viewer's permitted data. Supply trusted registry
27
- parameters through `queryParams`; query callers cannot override these values. Origin and Fetch Metadata
27
+ parameters through `queryParams`; query callers cannot override them. Origin and Fetch Metadata
28
28
  checks reject cross-site browser requests; they do not authenticate viewers.
29
29
 
30
30
  The handler validates operation input, enforces query row and duration
@@ -1,14 +1,14 @@
1
1
  # Stories and CSV export
2
2
 
3
- Every `<DataApp>` from `/react` supplies both `story` and `datasets`, derived from
3
+ Every `<DataApp>` from `@altertable/data-app-react` supplies both `story` and `datasets`, derived from
4
4
  the displayed snapshot. Story and export selectors do not run before a result is available.
5
- Setup and static screens use `<DataApp>` from `/react/ui`; they may omit both
5
+ Setup and static screens use `<DataApp>` from `@altertable/data-app-react/ui`; they may omit both
6
6
  or pass a direct `CsvExport` object.
7
7
 
8
8
  ## Present data with stories
9
9
 
10
10
  Set `story` on `<DataApp>` to enable **Present story** in the toolbar.
11
- For custom shells, `/react/ui` provides `<PresentStory>`; see [direct UI composition](ui.md). Start from the [data app starter](../examples/starter-data-app/index.tsx).
11
+ For custom shells, `@altertable/data-app-react/ui` provides `<PresentStory>`; see [direct UI composition](ui.md). Start from the [data app starter](../examples/starter-data-app/index.tsx).
12
12
 
13
13
  Return one to four findings with a headline, a visual, and registered source
14
14
  evidence. Set `evidence` to the registered dataset or metric binding. The app
package/docs/styling.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Use components and typed props first: `<Stack>` for sections, `<Grid>` for peers,
4
4
  and `<TextContent>` for prose. Standard widgets use [views and bindings](widgets.md);
5
- custom controls and direct widget shells use [`/react/ui`](ui.md).
5
+ custom controls and direct widget shells use [`@altertable/data-app-react/ui`](ui.md).
6
6
 
7
7
  Configure theme, palette, accent, typography, density, radius, and elevation through
8
8
  `app.appearance`; see [appearance](formatting-and-appearance.md). Call
@@ -12,7 +12,7 @@ Configure theme, palette, accent, typography, density, radius, and elevation thr
12
12
 
13
13
  Add app-owned classes through `className`. Render package components rather than copying their classes onto markup;
14
14
  private descendants are not customization hooks. Public names and stable roots
15
- are listed in the [typed contract](https://github.com/altertable-ai/data-app/blob/main/src/react/style-contract.ts).
15
+ are listed in the [typed contract](https://github.com/altertable-ai/data-app/blob/main/packages/data-app-react/src/style-contract.ts).
16
16
 
17
17
  ```css
18
18
  .app-action {
@@ -26,6 +26,10 @@ fallback in app CSS. Use `:root` for shared theme overrides, including menus and
26
26
  Prefer `app.appearance` for brand and chart colors. When overriding accent tokens,
27
27
  choose a contrasting foreground too. Keep text inputs at least 16px on mobile.
28
28
 
29
+ Menus and selection dropdowns share `--atbl-dropdown-padding`,
30
+ `--atbl-dropdown-item-padding-block`, `--atbl-dropdown-item-padding-inline`, and
31
+ `--atbl-dropdown-item-gap`. Their default padding follows the control density.
32
+
29
33
  ## Native controls
30
34
 
31
35
  Use package controls when possible. For a custom native control:
package/docs/ui.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Direct UI composition
2
2
 
3
- Import from `@altertable/data-app/react/ui` for setup/static screens, custom
3
+ Import from `@altertable/data-app-react/ui` for setup/static screens, custom
4
4
  controls, or a deliberately custom shell. Standard data apps use declared views
5
- and bound widgets from `/react`.
5
+ and bound widgets from `@altertable/data-app-react`.
6
6
 
7
7
  `<DataApp>` here renders a static screen and accepts optional direct CSV data.
8
8
  Direct widget forms accept local values or rows. `<DataWidget>` supplies a generic
@@ -30,7 +30,7 @@ styles.
30
30
 
31
31
  ## Keyboard actions
32
32
 
33
- Use `isPlainKeyEvent()` from `/react/ui` in custom key handlers so local actions
33
+ Use `isPlainKeyEvent()` from `@altertable/data-app-react/ui` in custom key handlers so local actions
34
34
  leave shortcut modifiers and IME composition untouched:
35
35
 
36
36
  ```tsx
@@ -91,7 +91,7 @@ markup to single-choice items.
91
91
 
92
92
  Choose a chart using the [visualization guide](widgets.md#choose-a-visualization).
93
93
  Import `<BarChart>`, `<LineChart>`, `<AreaChart>`, `<PieChart>`, or `<ScatterChart>` from
94
- `/react/ui`; `<ComposedChart>` exposes the series primitives for custom plots.
94
+ `@altertable/data-app-react/ui`; `<ComposedChart>` exposes the series primitives for custom plots.
95
95
  Compose the visual inside `<VisualizationWidget dataset={dataset} source={result}>`
96
96
  so rows, loading state, evidence, and inspection come from that dataset.
97
97
  Pass ordered items with unique, nonblank IDs and finite numbers. Bar and pie
@@ -108,7 +108,7 @@ Use `useSvgId()` for stable IDs when composing custom SVG definitions.
108
108
 
109
109
  ### Product analytics charts
110
110
 
111
- Use `<FunnelChart>`, `<RetentionChart>`, and `<JourneyChart>` from `/react/ui`
111
+ Use `<FunnelChart>`, `<RetentionChart>`, and `<JourneyChart>` from `@altertable/data-app-react/ui`
112
112
  inside `<VisualizationWidget>`. Derive inputs from the displayed rows; the
113
113
  binding owns loading, evidence, CSV, and story content. The query owns counting,
114
114
  conversion windows, and cohort definitions; these components visualize results.
@@ -116,7 +116,8 @@ conversion windows, and cohort definitions; these components visualize results.
116
116
  - `<FunnelChart>`: ordered steps and aligned, nonincreasing counts per population.
117
117
  - `<RetentionChart>`: numeric offsets, fractional rates (`0.25`, not `25`), retained
118
118
  counts, and cohort size. Distinguish unobserved (`null`), observed zero, and
119
- observed but still accumulating (`incomplete`) periods.
119
+ observed but still accumulating (`incomplete`) periods. Offset labels come from
120
+ supplied points; numeric spacing preserves elapsed distance.
120
121
  - `<JourneyChart>`: full ordered paths with counts and outcomes; preserve repeated
121
122
  events and mark cut-off paths as `truncated`.
122
123
 
@@ -126,7 +127,7 @@ constraints before adapting displayed rows.
126
127
 
127
128
  ### Composed charts
128
129
 
129
- Use `<ComposedChart>` from `/react/ui` for multiple series or mixed marks inside
130
+ Use `<ComposedChart>` from `@altertable/data-app-react/ui` for multiple series or mixed marks inside
130
131
  `<VisualizationWidget>`. Pass the displayed rows and select fields with `dataKey`.
131
132
  `<ComposedChart.Bar>`, `<ComposedChart.Line>`, and `<ComposedChart.Area>` share the
132
133
  standalone charts' themed series primitives; axes, scatter, tooltip, and reference
@@ -151,6 +152,13 @@ primitives are also available.
151
152
  </VisualizationWidget>
152
153
  ```
153
154
 
155
+ For irregular time intervals, use `<ComposedChart.XAxis>` with ISO dates, zoned
156
+ ISO timestamps, or `Date` values; spacing follows elapsed time. Use `scale="utc"`
157
+ for epoch milliseconds, or `type="category"` to keep date-like labels categorical.
158
+ On UTC axes, supplied `ticks` and `tickFormatter` take precedence over automatic labels.
159
+ Preserve missing measures as `null` and choose `connectNulls` deliberately; do not
160
+ replace missing observations with zero.
161
+
154
162
  Label series and units clearly. See component JSDoc and the
155
163
  [Recharts API](https://recharts.github.io/en-US/api/ComposedChart/) for options.
156
164
  The dataset owns loading, empty results, evidence, CSV, and story content; keep
@@ -215,3 +223,6 @@ and `<NumberRangeField>` as inline input primitives when composing forms.
215
223
 
216
224
  Use `<Button variant="primary">` for the main committing action, such as Apply.
217
225
  Use outline and ghost buttons for secondary actions.
226
+ Use `<Button variant="inline">` for actions within text or table cells. It has no
227
+ control padding or background and underlines on hover. Keep button semantics for
228
+ opening a sheet; use links for navigation to a URL.
package/docs/variables.md CHANGED
@@ -13,9 +13,10 @@ Bindings are required when the operation input cannot supply a compatible
13
13
  top-level filter field or the calendar request. Keep parsed selections in the
14
14
  operation input and derive SQL parameters inside the operation.
15
15
 
16
- `dimensionFilter()` from `/contract` requires exactly one option source: fixed `options` or a `facet`.
17
- Use `defineFacetFilter()` to bind a facet operation and its typed input. `<DimensionPicker>` offers missing values separately and keeps selected values
18
- available when they have zero matches.
16
+ `dimensionFilter()` from `/contract` uses fixed `options`. Use `defineFacetFilter()`
17
+ for options derived from declared variable context, or `app.defineDimension()`
18
+ for independent source options and exact member lookup. `<DimensionPicker>` offers missing values separately and keeps selected values
19
+ available when options refresh or fail; unknown counts remain undisclosed.
19
20
 
20
21
  ## Declare controls once
21
22
 
@@ -82,7 +83,7 @@ suppress autocomplete for a particular app.
82
83
 
83
84
  Declare controls in priority order for the user's task. Keep useful scope filters
84
85
  visible and set `presentation.prominence: 'secondary'` for less frequent ones in
85
- the Filters sheet. Active secondary filters remain available for direct editing.
86
+ the Filters sheet. Active filter summaries reopen the same Filters sheet.
86
87
  Choose useful defaults rather than exposing every field; declare each label once.
87
88
 
88
89
  Set `presentation.group: 'display'` for ordering or presentation choices. These
@@ -160,22 +161,28 @@ facet operation returns parsed dimension options. Its input mapper uses current
160
161
  resolved variables, including other filters:
161
162
 
162
163
  ```ts
163
- const { defineFacetFilter, defineTimeView } = createDataHooks(client);
164
+ const { defineFacetFilter } = createDataHooks(client);
165
+ const period = dateRangeVariable({
166
+ key: 'period',
167
+ contract: calendar,
168
+ defaultValue: { kind: 'preset', id: 'last-7' },
169
+ });
164
170
  const region = defineFacetFilter({
165
171
  key: 'region',
166
172
  label: 'Region',
167
173
  valueType: 'string',
168
174
  selectionMode: 'multiple',
169
175
  facet: {
176
+ context: { period },
170
177
  operation: 'regions',
171
- input: values => ({ period: values.period as DateRangeRequest }),
178
+ input: values => ({ period: values.period }),
172
179
  },
173
180
  });
174
181
  ```
175
182
 
176
- The client's operation map defines `regions` and its typed period input;
177
- import `DateRangeRequest` from `/contract`. Put `region` in the view's `variables`
178
- alongside its period. Use `parseFacetOptions()` to validate facet results.
183
+ Declare mapper dependencies in `facet.context` (`{}` for none), and include them
184
+ alongside the facet in the view's `variables`. Mapper inputs and option values are
185
+ inferred from the variables and operation; options must match `valueType`.
179
186
  For the operation's input parser, use `parseDimensionSelection(value, region)` from `/contract`.
180
187
  A dimension without an explicit selection represents all members.
181
188
  Map parsed selections to the query's declared parameters; do not construct SQL
@@ -184,13 +191,16 @@ from filter values. Choose selection modes supported by the registered query.
184
191
  Choose `selectionMode: 'single'` when one value replaces another and
185
192
  `selectionMode: 'multiple'` for independent values. `All` is an explicit choice for a single-value
186
193
  filter and the meaning of an empty selection for a multiple-value filter.
194
+ Single-value filters always have a selection limit of one.
187
195
 
188
196
  ## Fixed choices
189
197
 
190
198
  `choiceVariable()` requires labeled `options` and a valid `defaultValue`.
191
199
  `multiChoiceVariable()` stores unique option IDs with an optional selection limit.
192
- An empty fixed-choice collection means no choices; categorical filters use
193
- `dimensionFilter()` when an empty selection should mean all records.
200
+ Fixed-choice declarations need at least one option. Inline options or `as const`
201
+ preserve their IDs so TypeScript checks defaults against them. An empty selected
202
+ collection means no choices; categorical filters use `dimensionFilter()` when
203
+ an empty selection should mean all records.
194
204
 
195
205
  ```ts
196
206
  const variables = {
@@ -246,3 +256,65 @@ with paired Apply/Cancel handlers; derive queries and visible controls from appl
246
256
  values while a draft is being edited.
247
257
 
248
258
  Filters apply immediately; use app-owned drafts only when the task needs Apply/Cancel.
259
+
260
+ ## Independent filters and chart breakdowns
261
+
262
+ Each dimension owns its selection. Readers can select Germany without selecting
263
+ a region; changing or clearing Region preserves Country and Customer. Filters
264
+ combine in the operation's query. Incompatible selections can return an empty
265
+ result; keep the selections visible so readers can correct them.
266
+
267
+ Use `dimensionFilter()` for static options or `app.defineDimension()` for query-backed
268
+ options. `variableInput()` from `/contract` validates named variables alongside an
269
+ app-owned base parser. Use it on every operation consuming these filters, including
270
+ details. Declare the same variables on the view and preserve them in operation input.
271
+
272
+ ```ts
273
+ const country = app.defineDimension({
274
+ key: 'country',
275
+ label: 'Country',
276
+ valueType: 'string',
277
+ selectionMode: 'single',
278
+ presentation: { prominence: 'secondary' },
279
+ source: { query: 'countries' },
280
+ });
281
+ const revenueBy = choiceVariable({
282
+ key: 'revenue-by',
283
+ label: 'Revenue breakdown',
284
+ defaultValue: 'region',
285
+ options: [
286
+ { id: 'region', label: 'Region' },
287
+ { id: 'country', label: 'Country' },
288
+ ],
289
+ presentation: { group: 'display', control: 'widget' },
290
+ });
291
+ const parseInput = variableInput(parsePeriodInput, { country, revenueBy });
292
+ ```
293
+
294
+ A breakdown is an ordinary display choice, independent of population filters.
295
+ `<VisualizationWidget breakdown={view.breakdown('revenueBy')}>` renders that
296
+ choice in its header. `presentation.control: 'widget'` omits it from the toolbar.
297
+ Scope filters still appear in the Filters sheet, active summaries, and Clear filters.
298
+ Primary controls stay in the toolbar. Active non-primary filters appear beside them
299
+ as editable controls. Once the toolbar scrolls above the viewport,
300
+ a floating summary shows every active filter and opens the Filters sheet.
301
+ Declare each chart's choice separately when readers should control them independently.
302
+
303
+ Each source query declares a nullable `member` parameter matching `valueType` and
304
+ nonnullable projections for `value` (the same type), `label` (string), and optional
305
+ `count` (number). `member = null` requests at most 200 options; a selected value requests
306
+ an exact lookup. Other query parameters need defaults or trusted server values.
307
+ Keep SQL and parameter declarations literal in `defineDataApp()`.
308
+
309
+ ```sql
310
+ SELECT code AS value, name AS label
311
+ FROM countries
312
+ WHERE ($member IS NULL OR code = $member)
313
+ ORDER BY name
314
+ ```
315
+
316
+ Exact selected-member lookups run before business queries, sharing authorization,
317
+ cancellation, execution limits, and query evidence. Labels resolve separately from
318
+ the options page, including when it fails. Picker search searches supplied options;
319
+ it does not fetch additional members. Clear filters preserves search and display
320
+ choices and returns dates to their configured defaults.
package/docs/views.md CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  createDataHooks,
9
9
  DataApp,
10
10
  DataSection,
11
- } from '@altertable/data-app/react';
11
+ } from '@altertable/data-app-react';
12
12
  import type { operations } from '#app/operations.ts';
13
13
 
14
14
  const client = createDataClient<typeof operations>();
@@ -35,8 +35,8 @@ function App() {
35
35
 
36
36
  Omit `variables` when there are no controls. Omit `input` when the resolved
37
37
  variables match the operation input; nested or different inputs need a mapper.
38
- Keep dimension, numeric, and boolean selections in required operation input fields
39
- with the same names to derive their bindings. Other input shapes require typed
38
+ Keep scope variable values in required operation input fields with the same names
39
+ to derive their bindings. Other input shapes require typed
40
40
  `bindings` that read each selection back unchanged. Derive scalar SQL parameters
41
41
  inside the operation rather than replacing the selections in the view input.
42
42
  The operation and `ActivityWidgets` are app-owned. The bound widgets derive
@@ -98,3 +98,57 @@ errors, and refreshes instead of duplicating request state in app code.
98
98
 
99
99
  A measured zero is valid data. Define `isEmpty` for the analysis and provide
100
100
  useful `emptyFallback` copy.
101
+
102
+ ## Detail destinations
103
+
104
+ Use `createDataHooks(client).defineDetailView()` for a scoped population or entity.
105
+ The destination owns its input parser, operation, datasets, evidence, and content.
106
+ Pass its content to `<DataApp details={[ordersDetail]}>`:
107
+
108
+ ```tsx
109
+ const ordersView = defineDetailView({
110
+ id: 'orders',
111
+ title: 'Contributing orders',
112
+ operation: 'orders',
113
+ dataContext,
114
+ parseInput: operations.orders.input,
115
+ describeInput: describeOrderScope,
116
+ isEmpty: data => data.rows.length === 0,
117
+ emptyFallback: { title: 'No contributing orders' },
118
+ });
119
+ const ordersDetail = ordersView.content(source => (
120
+ <TableWidget dataset={orders} source={source} />
121
+ ));
122
+ ```
123
+
124
+ Declare `orders` with `ordersView.dataset()`. Detail inputs contain serializable
125
+ scope and IDs; exclude entire records, credentials, and protected server values.
126
+ Validate selected members through the same `variableInput()` parser used by the dashboard.
127
+ Shared links validate before execution. Nested destinations replace the single
128
+ detail sheet; the main app retains ownership of exports and stories.
129
+ The complete route supports up to 20 destinations and 16,384 serialized characters;
130
+ navigation rejects overflow before changing history.
131
+
132
+ ### Contributing metric records
133
+
134
+ Attach a destination to a metric and supply it to the existing inspection trigger:
135
+
136
+ ```tsx
137
+ const contributingOrders = orderCount.records({
138
+ target: ordersView,
139
+ input: displayedInput => displayedInput,
140
+ });
141
+
142
+ <MetricWidget
143
+ metric={orderCount}
144
+ source={source}
145
+ records={contributingOrders}
146
+ />;
147
+ ```
148
+
149
+ Inspection tabs become Records, Glossary, Queries. Records load when their tab
150
+ is shown; the destination's `describeInput()` supplies their scope. Source context
151
+ belongs in Glossary. Match record inclusion to the metric and explain non-additive
152
+ metrics. State completeness limits visibly in destination content. Local pagination
153
+ covers only supplied rows; larger populations need explicit server paging or a
154
+ visible limit.
package/docs/widgets.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Choose a widget
4
4
 
5
- Metrics, tables, and visualizations from `/react` consume view bindings and a source. For static displays, use
5
+ Metrics, tables, and visualizations from `@altertable/data-app-react` consume view bindings and a source. For static displays, use
6
6
  [direct UI composition](ui.md).
7
7
  Manage requests in the [view and section](views.md); show skeletons for loading
8
8
  readings without inventing values. Use `isEmpty` for the predicate and
@@ -24,8 +24,8 @@ Use [layout](layout.md) for `<Stack>`, `<Grid>`, and responsive `<GridItem>` spa
24
24
 
25
25
  Choose the component by the user's question. Compose dataset visuals inside
26
26
  `<VisualizationWidget>`; use `<MetricWidget>` for a headline value. Built-in
27
- charts come from `/react/ui`; `<Ranking>`, `<Breakdown>`, and `<Comparison>`
28
- are also available from `/react`.
27
+ charts come from `@altertable/data-app-react/ui`; `<Ranking>`, `<Breakdown>`, and `<Comparison>`
28
+ are also available from `@altertable/data-app-react`.
29
29
 
30
30
  | Question or need | Component | Guidance |
31
31
  | ------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -58,6 +58,8 @@ question from the same dataset.
58
58
  Bind reusable selections to the view. Declare evidence references directly;
59
59
  the view validates them against its own context. A dataset's columns supply both formatted
60
60
  table cells and raw CSV values. Widgets derive their readings, evidence, and empty fallback from the binding.
61
+ Declare at least one dataset column. Metric selectors may return `previous`
62
+ only for views with a date binding, including `defineTimeView()`.
61
63
 
62
64
  ```tsx
63
65
  const countries = activityView.dataset({
@@ -142,7 +144,7 @@ filtered data to the text and its related visualization.
142
144
  ## Custom visuals and controls
143
145
 
144
146
  `<Ranking>`, `<Breakdown>`, and `<Comparison>`
145
- compose inside authored widgets. Use [built-in charts](ui.md#charts) from `/react/ui`
147
+ compose inside authored widgets. Use [built-in charts](ui.md#charts) from `@altertable/data-app-react/ui`
146
148
  inside `<VisualizationWidget dataset={dataset} source={result}>` for displayed rows.
147
149
  The dataset owns evidence and empty copy; an empty row selection shows that fallback. A visualization's `views` declaration keeps
148
150
  alternate-view selection shared with its inspection sheet. Give views stable IDs
@@ -158,3 +160,94 @@ For embedded theme and chrome, see [parent presentation](embed.md#parent-present
158
160
 
159
161
  `<TooltipProvider>` shares hover timing outside `<DataApp>`; the app already
160
162
  provides it.
163
+
164
+ ## Exploration actions
165
+
166
+ Declare actions on their dataset or metric and pass them to its widget. Detail
167
+ mappings receive the displayed operation input, including during refreshes.
168
+ Both `children` and alternate-view `render` callbacks receive the displayed rows
169
+ and the same action resolver.
170
+
171
+ ```tsx
172
+ const placeActions = places.actions(
173
+ action => ({
174
+ orders: action.detail({
175
+ label: 'View orders',
176
+ target: ordersView,
177
+ input: (row, displayedInput) => ({ ...displayedInput, placeId: row.id }),
178
+ }),
179
+ filter: action.filter({
180
+ label: 'Filter to this region',
181
+ when: row => row.dimension === 'region',
182
+ target: salesView.filter(),
183
+ values: row => ({
184
+ region: {
185
+ kind: 'include',
186
+ members: [{ kind: 'value', value: row.id }],
187
+ },
188
+ }),
189
+ }),
190
+ drill: action.filter({
191
+ label: 'Drill down',
192
+ when: row => row.dimension === 'region',
193
+ target: salesView.filter(),
194
+ values: row => ({
195
+ region: {
196
+ kind: 'include',
197
+ members: [{ kind: 'value', value: row.id }],
198
+ },
199
+ }),
200
+ breakdown: {
201
+ target: salesView.breakdown('revenueBy'),
202
+ value: () => 'country',
203
+ },
204
+ }),
205
+ }),
206
+ { primary: 'orders' }
207
+ );
208
+
209
+ <VisualizationWidget
210
+ dataset={places}
211
+ source={source}
212
+ actions={placeActions}
213
+ breakdown={salesView.breakdown('revenueBy')}
214
+ >
215
+ {(rows, actions) => (
216
+ <BarChart
217
+ ariaLabel="Revenue by place"
218
+ unit="USD"
219
+ items={rows.map(row => ({ ...row, value: row.revenue }))}
220
+ itemActions={actions}
221
+ />
222
+ )}
223
+ </VisualizationWidget>;
224
+ ```
225
+
226
+ Keep domain fields when adapting chart items. Bar, line, area, pie slices, and
227
+ pie legend items share the same action contract. Chart marks keep a sole or
228
+ declared `primary` action direct. The full pie legend row and bar label open the
229
+ menu; bar labels use a small inline disclosure chevron.
230
+
231
+ Menus retain every available action and group copying after exploration actions.
232
+ The first copy action names the text it copies. Copy summary includes the displayed
233
+ label, formatted value, unit, and pie share. Successful copies are silent; failures
234
+ are announced and shown on the chart.
235
+ Right-click opens the menu at the pointer; Shift+F10 anchors it to the control.
236
+ Breakdown controls keep their selected choice visible and their accessible names.
237
+ Custom controls can compose `<ExplorationActionControl>` from `/react/ui`.
238
+
239
+ `<TableWidget actions={placeActions}>` adds row actions without changing the
240
+ dataset or its CSV export. `<MetricWidget>` accepts actions declared with
241
+ `metric.actions()`; metric action mappings receive `undefined` for the row and
242
+ the displayed operation input as their second argument. Actions must belong to
243
+ the metric or dataset rendered by the widget.
244
+
245
+ `view.filter()` targets scope variables. An optional `breakdown` explicitly updates
246
+ one chart's display choice in the same history entry. Filters preserve unrelated
247
+ selections. Filter actions wait for displayed and applied scope to agree; actions
248
+ that also change a breakdown check that chart's displayed choice. No filter change
249
+ implicitly changes another filter or chart.
250
+
251
+ A day drill passes its day. A value-band drill passes a stable band ID; validate
252
+ it in the destination operation and derive bounds there. Query matching records
253
+ rather than filtering a capped dashboard preview. See [detail destinations](views.md#detail-destinations).
package/docs/worker.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Cloudflare Worker asset
2
2
 
3
- `@altertable/data-app/worker` resolves to a precompiled, self-contained ESM Worker
3
+ `@altertable/data-app-worker` resolves to a precompiled, self-contained ESM Worker
4
4
  script. Upload this one file as the deployment's main module. It includes the
5
5
  bootstrap and HTML; no bundling, HTML generation,
6
6
  runtime imports, or asset fetches are needed in the hosting backend.
@@ -13,7 +13,7 @@ its contents to your deployment tooling:
13
13
  import { readFile } from 'node:fs/promises';
14
14
 
15
15
  const workerScript = await readFile(
16
- new URL(import.meta.resolve('@altertable/data-app/worker')),
16
+ new URL(import.meta.resolve('@altertable/data-app-worker')),
17
17
  'utf8'
18
18
  );
19
19
  // Upload workerScript as worker.js, with main_module = "worker.js".
@@ -48,9 +48,9 @@ navigation. Bundle apps execute their operation registry in the browser and send
48
48
  SQL through the [host query route](embed.md#sql-query-route); the Worker does not
49
49
  resolve operation names or execute queries. Data requests require backend authorization.
50
50
 
51
- If Terraform reads a file, copy the resolved `/worker` asset unchanged to that
51
+ If Terraform reads a file, copy the resolved `@altertable/data-app-worker` asset unchanged to that
52
52
  file during deployment preparation. Configure `DOMAIN_NAME`, `PARENT_ORIGINS`,
53
53
  domains, routes, and deployment settings in Terraform. Upgrade the host package
54
54
  and Worker together for protocol changes.
55
55
  Custom hosts that bundle their own bootstrap can use `startDataAppBootstrap()` from
56
- [/embed](embed.md#trusted-bootstrap).
56
+ [the embed package](embed.md#trusted-bootstrap).
@@ -16,7 +16,7 @@ import {
16
16
  mountDataApp,
17
17
  MetricWidget,
18
18
  searchVariable,
19
- } from '@altertable/data-app/react';
19
+ } from '@altertable/data-app-react';
20
20
 
21
21
  const dataApp = defineDataApp({
22
22
  title: 'Sample counts',
@@ -25,14 +25,18 @@ const dataApp = defineDataApp({
25
25
  appearance: { theme: 'system' },
26
26
  queries: {
27
27
  sampleCountsByGroup: {
28
+ projections: {
29
+ group_name: { type: 'string' },
30
+ sample_count: { type: 'number' },
31
+ },
28
32
  statement: `
29
33
  WITH sample_counts(group_name, sample_count) AS (VALUES ('Alpha', 2200000), ('Beta', 0))
30
34
  SELECT group_name, sample_count FROM sample_counts
31
35
  WHERE $groupName = '' OR group_name = $groupName
32
36
  ORDER BY group_name LIMIT $limit`,
33
37
  params: {
34
- groupName: { defaultValue: '' },
35
- limit: { defaultValue: 10 },
38
+ groupName: { type: 'string', defaultValue: '' },
39
+ limit: { type: 'number', defaultValue: 10 },
36
40
  },
37
41
  },
38
42
  },
@@ -48,20 +52,6 @@ function parseSampleCountFilter(value: unknown) {
48
52
  throw new Error('Expected a group name of at most 40 characters.');
49
53
  return { groupName: value.groupName };
50
54
  }
51
- function parseSampleCounts(
52
- value: unknown
53
- ): { groupName: string; sampleCount: number }[] {
54
- if (!Array.isArray(value))
55
- throw new Error('Expected sample counts by group.');
56
- return value.map(row => {
57
- if (!row || typeof row !== 'object' || typeof row.groupName !== 'string')
58
- throw new Error('Expected a group name.');
59
- return {
60
- groupName: row.groupName,
61
- sampleCount: parseCount(row.sampleCount),
62
- };
63
- });
64
- }
65
55
  const operations = {
66
56
  sampleCountsByGroup: dataApp.defineOperation({
67
57
  input: parseSampleCountFilter,
@@ -73,12 +63,10 @@ const operations = {
73
63
  policy: { maxQueryRows: 10, maxDurationMs: 15000 },
74
64
  async run({ query }, { groupName }) {
75
65
  const queryResult = await query('sampleCountsByGroup', { groupName });
76
- return parseSampleCounts(
77
- queryResult.rows.map(([groupName, sampleCount]) => ({
78
- groupName,
79
- sampleCount,
80
- }))
81
- );
66
+ return queryResult.rows.map(row => ({
67
+ groupName: row.group_name,
68
+ sampleCount: parseCount(row.sample_count),
69
+ }));
82
70
  },
83
71
  }),
84
72
  };
@@ -16,7 +16,7 @@ See [README.md](README.md) for setup and checks.
16
16
  ## Focused guidance
17
17
 
18
18
  Read the installed package's `AGENTS.md` and `docs/app-authoring.md` before
19
- changing the app. Follow their task routes for views, variables, widgets, evidence,
19
+ changing the app. Search its `REFERENCE.md` for props and signatures. Follow their task routes for views, variables, widgets, evidence,
20
20
  and stories/export. Prefer generated controls and bound readings; keep static
21
21
  context visible during requests. Update this app's instructions when a reusable
22
22
  app-specific convention changes. Package internals remain dependencies.