@altertable/data-app 0.77.0 → 0.79.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 (70) hide show
  1. package/AGENTS.md +3 -0
  2. package/CONTRIBUTING.md +5 -1
  3. package/REFERENCE.md +70 -180
  4. package/dist/chunks/contract-BTG-BUwW.js +1589 -0
  5. package/dist/chunks/contract-BTG-BUwW.js.map +1 -0
  6. package/dist/chunks/data-client-C4Pay-UE.js +122 -0
  7. package/dist/chunks/data-client-C4Pay-UE.js.map +1 -0
  8. package/dist/chunks/{date-time-range-value-CnlTr1U1.js → date-time-range-value-D-XfqVTT.js} +21 -24
  9. package/dist/chunks/date-time-range-value-D-XfqVTT.js.map +1 -0
  10. package/dist/chunks/{diagnostics-Dyj-rUsY.js → diagnostics-BwpM9wGn.js} +240 -63
  11. package/dist/chunks/diagnostics-BwpM9wGn.js.map +1 -0
  12. package/dist/chunks/record-Cr4Uk1K3.js +9 -0
  13. package/dist/chunks/record-Cr4Uk1K3.js.map +1 -0
  14. package/dist/client/index.js +4 -101
  15. package/dist/client/index.js.map +1 -1
  16. package/dist/core/appearance.js +3 -5
  17. package/dist/core/appearance.js.map +1 -1
  18. package/dist/core/config.js +12 -3
  19. package/dist/core/config.js.map +1 -1
  20. package/dist/core/contract.js +3 -4
  21. package/dist/core/format.js +1 -1
  22. package/dist/internal.js +63 -11
  23. package/dist/internal.js.map +1 -1
  24. package/dist/types/chunks/contract.d.ts +260 -20
  25. package/dist/types/chunks/data-client.d.ts +46 -0
  26. package/dist/types/chunks/date-time-range-value.d.ts +28 -2
  27. package/dist/types/chunks/index.d.ts +65 -80
  28. package/dist/types/client/index.d.ts +4 -3
  29. package/dist/types/core/config.d.ts +13 -4
  30. package/dist/types/core/contract.d.ts +3 -5
  31. package/dist/types/core/format.d.ts +1 -2
  32. package/dist/types/index.d.ts +4 -4
  33. package/dist/types/internal.d.ts +25 -6
  34. package/docs/app-authoring.md +160 -72
  35. package/docs/client.md +14 -53
  36. package/docs/contract.md +47 -26
  37. package/docs/data-context.md +11 -11
  38. package/docs/diagnostics.md +16 -23
  39. package/docs/embed.md +60 -25
  40. package/docs/filters.md +39 -65
  41. package/docs/formatting-and-appearance.md +2 -5
  42. package/docs/hosted-apps.md +11 -11
  43. package/docs/layout.md +21 -0
  44. package/docs/local-data-apps.md +10 -7
  45. package/docs/react-embed.md +44 -2
  46. package/docs/react.md +2 -5
  47. package/docs/server-bun.md +8 -5
  48. package/docs/stories-and-export.md +5 -6
  49. package/docs/styling.md +2 -1
  50. package/docs/ui.md +37 -10
  51. package/docs/views.md +18 -19
  52. package/docs/widgets.md +10 -11
  53. package/docs/worker.md +1 -1
  54. package/package.json +1 -5
  55. package/dist/chunks/contract-BQsFReRp.js +0 -780
  56. package/dist/chunks/contract-BQsFReRp.js.map +0 -1
  57. package/dist/chunks/contract-VhY9V9wd.js +0 -806
  58. package/dist/chunks/contract-VhY9V9wd.js.map +0 -1
  59. package/dist/chunks/date-time-range-value-CnlTr1U1.js.map +0 -1
  60. package/dist/chunks/diagnostics-Dyj-rUsY.js.map +0 -1
  61. package/dist/chunks/operation-BVRM-A5Y.js +0 -134
  62. package/dist/chunks/operation-BVRM-A5Y.js.map +0 -1
  63. package/dist/chunks/request-body-H1qPmmTN.js +0 -50
  64. package/dist/chunks/request-body-H1qPmmTN.js.map +0 -1
  65. package/dist/server/index.js +0 -90
  66. package/dist/server/index.js.map +0 -1
  67. package/dist/types/chunks/contract2.d.ts +0 -221
  68. package/dist/types/chunks/date-time-range.d.ts +0 -29
  69. package/dist/types/server/index.d.ts +0 -17
  70. package/docs/server.md +0 -41
package/docs/embed.md CHANGED
@@ -170,45 +170,36 @@ const router = createMessageRouter(routes, {
170
170
  `router.dispatch()` validates route input and output. Use `MessageRoutingError`
171
171
  for intentional public failures; other handler errors are hidden.
172
172
 
173
- Use `defineDataQueryRoute(operationContracts)` for typed named operations or
174
- `dataAppRoutes` for generic operation and navigation routes. Handlers must
175
- validate operations, authorize data access, and enforce backend query limits.
173
+ Use `registeredQueryRoute` for data requests, or `dataAppRoutes` for the shared
174
+ registered-query and navigation contracts. Handlers must resolve IDs against
175
+ the saved app, authorize data access, and enforce backend query limits.
176
176
 
177
- ## SQL query route
177
+ ## Registered query route
178
178
 
179
- Hosts serving browser-owned operations register `sqlQueryRoute` explicitly:
179
+ Hosts serving browser-owned operations register `registeredQueryRoute`:
180
180
 
181
181
  ```ts
182
182
  import {
183
183
  createMessageRouter,
184
- sqlQueryRoute,
184
+ registeredQueryRoute,
185
185
  } from '@altertable/data-app/contract';
186
- import { createSqlQueryHandler } from '@altertable/data-app-embed';
187
186
 
188
187
  const router = createMessageRouter(
189
- { 'data:sql': sqlQueryRoute },
188
+ { 'data:query': registeredQueryRoute },
190
189
  {
191
- 'data:sql': createSqlQueryHandler(async (query, { signal }) => {
192
- return authorizedLakehouseForCurrentViewer(query, signal);
193
- }),
190
+ 'data:query': async ({ queryId, params, limit }, { signal }) =>
191
+ runRegisteredQueryForCurrentViewer({ queryId, params, limit, signal }),
194
192
  }
195
193
  );
196
194
  // Supply router.dispatch as the shell's onMessage handler.
197
195
  ```
198
196
 
199
- The host supplies `authorizedLakehouseForCurrentViewer()`. Its backend must enforce
200
- viewer/dataset permissions, permitted query behavior, maximum rows, execution
201
- time, concurrency, and response size independently of browser policy. Route
202
- validation is not SQL authorization. `createSqlQueryHandler()` calls authorization
203
- for each query, forwards cancellation, and preserves `DataSourceError` reasons
204
- as public `source_*` errors with request IDs. Authorization failures return
205
- `forbidden`; unknown query errors are hidden. Custom handlers can return deliberate
206
- public failures with `MessageRoutingError`.
207
-
208
- The SQL route carries `{ statement, limit, params? }` and returns column
209
- metadata and row arrays; see `SqlQueryInput` and `QueryResult` in the
210
- [API reference](../REFERENCE.md). Keep SQL and parameters unchanged.
211
- For server-owned named operations, use `dataAppRoutes` and `data:query` instead.
197
+ The host resolves `queryId` against the app's saved `defineDataApp({ queries })`
198
+ registry and runs that SQL with the supplied parameter values. It must enforce
199
+ viewer permissions, maximum rows, execution time, concurrency, and response size.
200
+ The route carries `{ queryId, limit, params? }` and returns column metadata and
201
+ row arrays; see `RegisteredQueryInput` and `QueryResult` in the
202
+ [API reference](../REFERENCE.md). Unknown IDs must fail before execution.
212
203
 
213
204
  ## Parent presentation
214
205
 
@@ -230,9 +221,53 @@ host.setPresentation({ surface: 'embedded', theme: 'light' });
230
221
  Use `surface: 'embedded'` when the parent supplies page chrome and
231
222
  `'standalone'` when the app supplies it. Resolve the parent theme to `'light'` or
232
223
  `'dark'`. React `<DataApp>` applies presentation automatically: embedded surfaces
233
- keep toolbar actions and hide header/footer. Updates do not reload the iframe.
224
+ hide the header, footer, and page toolbar, and offer its actions to the parent
225
+ through [page actions](#page-actions). Updates do not reload the iframe.
234
226
  Call `host.setPresentation(undefined)` to restore standalone defaults.
235
227
 
228
+ The parent also owns annotation mode whenever the app shows no toolbar, as on
229
+ embedded surfaces: set `annotations.active` (omitted means inactive) and handle
230
+ the `annotation:mode` route.
231
+
232
+ ### Page actions
233
+
234
+ An embedded app shows no toolbar. It offers its page actions to the parent,
235
+ which renders the controls and runs them through the bridge:
236
+
237
+ ```ts
238
+ // ... iframe, authorized router, and refreshButton
239
+ const host = attachDataAppBridge({
240
+ iframe,
241
+ source: { type: 'url', url: 'https://apps.example.com/report' },
242
+ presentation: { surface: 'embedded', theme: 'light' },
243
+ onActionsChange(actions) {
244
+ refreshButton.hidden = !actions.refresh;
245
+ refreshButton.disabled = actions.refresh?.refreshing ?? true;
246
+ },
247
+ onMessage: router.dispatch,
248
+ });
249
+
250
+ refreshButton.onclick = () => host.runAction({ type: 'refresh' });
251
+ ```
252
+
253
+ `onActionsChange` receives the complete `DataAppActions` on every change. Render
254
+ only the keys present:
255
+
256
+ | Offered state | Run | Notes |
257
+ | --------------------------------------- | --------------------------------- | ---------------------------------------------------------------------- |
258
+ | `refresh: { refreshing, cancellable }` | `refresh`, `cancelRefresh` | Cancel only while `refreshing` and `cancellable`. |
259
+ | `exportCsv: { enabled, tables }` | `exportCsv` with optional `table` | Omit `table` to export every dataset, as a ZIP when there are several. |
260
+ | `presentStory: { enabled, presenting }` | `presentStory`, `closeStory` | Shows the iframe fullscreen while presenting. |
261
+ | `aboutData: { enabled }` | `aboutData` | Opens the data inspector in the frame. |
262
+
263
+ Call `runAction()` from the user's click: the bridge needs that gesture to show
264
+ a story fullscreen. It exits fullscreen when the story closes, and leaving
265
+ fullscreen closes the story. `presentStory` and `aboutData` move focus into the
266
+ frame; when that story closes, focus returns to the control that ran it unless
267
+ the reader has moved elsewhere. The app ignores actions it does not currently
268
+ offer. While the app reconnects, actions reset to `{}` and `runAction()` does
269
+ nothing.
270
+
236
271
  ### Content sizing
237
272
 
238
273
  By default the parent sizes the iframe and the app scrolls inside it. Set
package/docs/filters.md CHANGED
@@ -7,33 +7,41 @@ renders. Import filters from `@altertable/data-app/contract`.
7
7
 
8
8
  ## Declare filters on operations
9
9
 
10
- The hosted starter's operations both read one group search:
10
+ This sample-count example shares one fixed group choice across operations:
11
11
 
12
12
  ```tsx
13
- import { parseCount, searchFilter } from '@altertable/data-app/contract';
13
+ import { choiceFilter } from '@altertable/data-app/contract';
14
14
 
15
15
  // ... dataApp, sampleDataContext, and section contents
16
- const groupName = searchFilter({ key: 'group', label: 'Group' });
16
+ const groupName = choiceFilter({
17
+ key: 'group',
18
+ label: 'Group',
19
+ defaultValue: 'all',
20
+ options: [
21
+ { id: 'all', label: 'All groups' },
22
+ { id: 'Alpha', label: 'Alpha' },
23
+ { id: 'Beta', label: 'Beta' },
24
+ ],
25
+ });
17
26
 
18
- const operations = {
27
+ const operations = dataApp.defineOperations({
19
28
  sampleCountsByGroup: dataApp.defineOperation({
20
29
  filters: { groupName },
21
- policy: { maxQueryRows: 10, maxDurationMs: 15000 },
30
+ policy: { maxQueryRows: 10 },
22
31
  async run({ query }, { groupName }) {
23
- const result = await query('sampleCountsByGroup', { groupName });
24
- return result.rows.map(row => ({
32
+ const { rows } = await query('sampleCountsByGroup', { groupName });
33
+ return rows.map(row => ({
25
34
  groupName: row.group_name,
26
- sampleCount: parseCount(row.sample_count),
35
+ sampleCount: row.sample_count,
27
36
  }));
28
37
  },
29
38
  }),
30
39
  // ... sampleTotal reads the same { groupName }
31
- };
32
- const { defineView } = createDataHooks(createDataClient({ operations }));
40
+ });
41
+ const { defineView } = createDataHooks(operations.createDataClient());
33
42
  const sampleCountsView = defineView({
34
43
  dataContext: sampleDataContext,
35
44
  operation: 'sampleCountsByGroup',
36
- isEmpty: rows => rows.length === 0,
37
45
  emptyFallback: { title: 'No matching groups' },
38
46
  });
39
47
 
@@ -48,6 +56,8 @@ function App() {
48
56
 
49
57
  - Reuse the same constant on every operation that reads it; two filters with one
50
58
  name, or one URL key, fail.
59
+ - Give a choice its unrestricted option, such as `all`, and handle that ID in
60
+ the query: `WHERE $groupName = 'all' OR group_name = $groupName`.
51
61
  - Omit `filters` for an operation without inputs.
52
62
  - A detail operation that also needs its own fields, such as a record ID, keeps
53
63
  `filters` for the scope and adds `input` and `checks` for those fields only.
@@ -69,27 +79,26 @@ function App() {
69
79
  | `numberFilter()`, `booleanFilter()` | `NumberSelection`, `BooleanSelection` |
70
80
  | `dateTimeRangeFilter()` | `{ range, comparison }` of resolved dates |
71
81
 
72
- Pass values to declared query parameters; never interpolate them into SQL. Date
73
- ranges bind as [`dateTimeRange` parameters](contract.md#bind-date-ranges). A
74
- dimension selection binds whole to a `{ type: 'dimension', valueType }`
75
- parameter; `$country.matches(column)` keeps the selected rows, including
76
- multiple members, missing values, and exclusion:
82
+ Pass values to declared query parameters; never interpolate them into SQL. Bind
83
+ date filter bounds as [separate parameters](contract.md#bind-date-ranges).
84
+ For a single-value choice, bind its selected ID as a string:
77
85
 
78
86
  ```ts
79
87
  // ... in defineDataApp({ queries })
80
88
  revenueByCampaign: {
81
89
  statement: `SELECT o.campaign, sum(o.amount) AS revenue
82
90
  FROM demo.orders o JOIN demo.customers c ON c.id = o.customer_id
83
- WHERE $country.matches(c.country)
91
+ WHERE c.country = $country
84
92
  GROUP BY o.campaign`,
85
- params: { country: { type: 'dimension', valueType: 'string' } },
93
+ params: { country: { type: 'string' } },
86
94
  projections: { campaign: { type: 'string' }, revenue: { type: 'number' } },
87
95
  },
88
96
  // ... in the operation: query('revenueByCampaign', { country: input.country })
89
97
  ```
90
98
 
91
- Dimension, number, and boolean selections support `{ kind: 'all' }`. Offer only
92
- predicates the registered query supports.
99
+ Dimension selections bind as JSON. Express multiple values, missing values, and
100
+ exclusion in DuckDB SQL. Dimension, number, and boolean selections support
101
+ `{ kind: 'all' }`. Offer only predicates the registered query supports.
93
102
 
94
103
  ## Categorical dimensions
95
104
 
@@ -208,9 +217,10 @@ period, time zone, and metric comparisons:
208
217
  import {
209
218
  dateTimeRangeFilter,
210
219
  dateTimeRangePresets,
220
+ queryDateTimeRangeParams,
211
221
  } from '@altertable/data-app/contract';
212
222
 
213
- const period = dateTimeRangeFilter({
223
+ const periodFilter = dateTimeRangeFilter({
214
224
  key: 'period',
215
225
  defaultValue: '30d',
216
226
  maxRangeDays: 90,
@@ -218,14 +228,14 @@ const period = dateTimeRangeFilter({
218
228
  presets: dateTimeRangePresets.analytics,
219
229
  });
220
230
  const dailyCounts = dataApp.defineOperation({
221
- filters: { period, groupName },
222
- policy: { maxQueryRows: 100, maxDurationMs: 15000 },
231
+ filters: { period: periodFilter, groupName },
232
+ policy: { maxQueryRows: 100 },
223
233
  async run({ query }, { period, groupName }) {
224
234
  const current = await query('dailyCounts', {
225
- period: period.range,
235
+ ...queryDateTimeRangeParams(periodFilter, period, 'period').current,
226
236
  groupName,
227
237
  });
228
- // ... query { period: period.comparison } when it is not null
238
+ // ... use .comparison for the previous period when selected
229
239
  return current.rows;
230
240
  },
231
241
  });
@@ -233,8 +243,8 @@ const dailyCounts = dataApp.defineOperation({
233
243
 
234
244
  - `run()` receives `{ range, comparison }` with resolved dates. Ranges include
235
245
  `from` and exclude `to`: September 24–30 queries `2026-09-24T00:00:00Z`
236
- through `2026-10-01T00:00:00Z`. Bind them to a
237
- [`dateTimeRange` parameter](contract.md#bind-date-ranges).
246
+ through `2026-10-01T00:00:00Z`. Bind them as
247
+ [separate parameters](contract.md#bind-date-ranges).
238
248
  - A range that runs past now ends at now: today picked in the calendar queries
239
249
  midnight through the current time.
240
250
  - `comparison: 'off'` or `'on'` offers the previous-period toggle, starting in
@@ -255,41 +265,5 @@ Clear removes filter predicates and returns dates to defaults, preserving search
255
265
  and display choices. `resetAll()` restores all defaults. Filters apply immediately;
256
266
  use app-owned drafts only when the task needs Apply/Cancel.
257
267
 
258
- Custom control ownership is needed only when generated controls cannot express
259
- the requirement; use `/ui` for that case. Do not reuse reserved inspection,
260
- presentation, or navigation URL keys.
261
-
262
- ## Share filters with HTTP and local apps
263
-
264
- HTTP and local apps keep operations on the server, so the browser imports them
265
- as types only. Declare filters in a browser-safe module that both sides import:
266
-
267
- ```ts
268
- // src/filters.ts
269
- import { choiceFilter } from '@altertable/data-app/contract';
270
-
271
- const groupName = choiceFilter({
272
- // ... key, label, defaultValue, and options
273
- });
274
-
275
- export const operationFilters = {
276
- sampleCountsByGroup: { groupName },
277
- sampleCountsBySegment: { groupName },
278
- };
279
- ```
280
-
281
- Each operation in `src/operations.ts` declares
282
- `filters: operationFilters.sampleCountsByGroup`, and the browser client receives
283
- the same map:
284
-
285
- ```ts
286
- // src/App.tsx
287
- import { operationFilters } from '#app/filters.ts';
288
- import type { operations } from '#app/operations.ts';
289
-
290
- const { defineView } = createDataHooks(
291
- createDataClient<typeof operations>({ filters: operationFilters })
292
- );
293
- ```
294
-
295
- The client's types require `filters` whenever an operation declares them.
268
+ The keys `view`, `about`, `tab`, `present`, `step`, and `details` are reserved
269
+ for inspection, presentation, and navigation.
@@ -47,11 +47,8 @@ keeps the originals:
47
47
  const dailyCounts = dailyCountsView.dataset({
48
48
  // ... name, select, rowKey, and evidence
49
49
  columns: {
50
- day: { value: row => row.day, format: { kind: 'date' } },
51
- observed: {
52
- value: row => row.observed,
53
- format: { kind: 'dateTime', precision: 'second' },
54
- },
50
+ day: { format: { kind: 'date' } },
51
+ observed: { format: { kind: 'dateTime', precision: 'second' } },
55
52
  },
56
53
  });
57
54
  ```
@@ -1,7 +1,7 @@
1
- # Author a data app
1
+ # Author a hosted data app
2
2
 
3
3
  Follow the [SDK integration guide](app-authoring.md) with a version-matched hosted
4
- starter selected by the authoring workflow. The shared starter
4
+ starter selected by the authoring workflow. The general starter
5
5
  is `starter-data-app/index.tsx`; its sample content is replaceable. Keep the app in
6
6
  one file with public package imports; omit server files, HTML, credentials, and
7
7
  relative or app-alias imports.
@@ -18,21 +18,21 @@ Replace sample queries, operations, and datasets with inspected source data. Sup
18
18
  in `defineDataApp()`. When using bound `<DataApp>`, follow its current
19
19
  [story and dataset requirements](stories-and-export.md).
20
20
 
21
- Keep the starter's client, style injection, and mounting code. The host supplies
22
- the transport; no bootstrap or message routes are needed in app code.
21
+ Keep the starter's client, style injection, and mounting code. The current
22
+ single-file starter collects the operations with `dataApp.defineOperations()`
23
+ and uses `operations.createDataClient()`. The operation's `run()` executes in
24
+ the iframe and sends its registered query IDs and parameter values through
25
+ `data:query`; no bootstrap or message routes are needed in app code.
23
26
 
24
27
  ## Convert a local data app
25
28
 
26
29
  1. Combine the app's filters, operations, data context, views, any presentation
27
30
  and export features, app declaration, and browser entry into one `index.tsx`, following the
28
31
  [single-file starter](app-authoring.md#use-release-matched-starters).
29
- 2. Replace the HTTP client with `createDataClient({ operations })`, using the
30
- operation registry as a value; it supplies the operations' filters, so drop
31
- the `filters` option. See [browser-owned operations](client.md#browser-owned-operations-for-bundle-apps)
32
- for execution through the host.
33
- 3. Remove the Bun server, HTML, server adapters, credentials, and relative or
34
- app-alias imports. Rewrite any operation that depends on server-only code
35
- to use the operation's `query()` helper.
32
+ 2. Keep `operations.createDataClient()`; the hosted bootstrap supplies its
33
+ query bridge. See [registered operations](client.md#registered-operations).
34
+ 3. Remove the Bun server, HTML, local query adapter installation, credentials,
35
+ and relative or app-alias imports.
36
36
  4. Confirm the host can query the same catalogs, tables, and fields.
37
37
  [Verify the app](app-authoring.md#verify-the-app) in the hosted runtime against
38
38
  the local version's filters and findings.
package/docs/layout.md CHANGED
@@ -38,6 +38,27 @@ Compose paragraphs, links, and inline components directly; no `<TextContent>`
38
38
  wrapper is needed. Keep headings and widgets in the body and controls in
39
39
  `footerActions`.
40
40
 
41
+ Embedded hosts supply the page chrome, so `<DataApp>` omits its header, footer,
42
+ `toolbarActions`, and `footerActions` there; the host runs refresh, export,
43
+ story, and inspection. Keep controls readers need in the body.
44
+
45
+ ## Adapt to the available container
46
+
47
+ Base layout decisions on the app's available width. An embedded panel can be
48
+ narrow inside a wide browser window. Use `<Grid>` and `<GridItem>` first: their
49
+ tracks and spans respond to the containing grid rather than a viewport breakpoint.
50
+ Choose the column count and reading order for the evidence in the app brief.
51
+
52
+ For custom layout that these primitives cannot express, give an app-owned wrapper
53
+ `container-type: inline-size` and, when needed, a `container-name`. Use CSS
54
+ `@container` queries to adapt its descendants to that wrapper's width. The
55
+ container must be an ancestor of the elements whose layout changes. Keep theme
56
+ and user-preference media queries separate from these width decisions.
57
+
58
+ Apply the same composition and container rules to hosted and local apps. Verify
59
+ both a narrow browser and a narrow embed inside a wide browser; neither should
60
+ clip controls or require horizontal page scrolling.
61
+
41
62
  ## Verify rendered layouts
42
63
 
43
64
  Review authored composition with realistic labels and values. For custom layout
@@ -2,28 +2,31 @@
2
2
 
3
3
  Use the local scaffold supplied by your authoring workflow. Its README covers
4
4
  setup and its AGENTS.md identifies app-owned files.
5
- Replace the connectivity screen or fixture examples with the content specified by
5
+ Replace the sample queries and views with the content specified by
6
6
  the app brief, using the [shared SDK patterns](app-authoring.md). Local execution
7
7
  does not require a particular content structure or presentation story.
8
8
 
9
- | Task | Documentation |
10
- | ---------------------------- | ---------------------------------------- |
11
- | Customize local serving | [Bun server](server-bun.md) |
12
- | Authorize hosted viewers | [Server](server.md) |
13
- | Customize the browser client | [HTTP client](client.md#http-operations) |
9
+ | Task | Documentation |
10
+ | ---------------------------- | ----------------------------------------- |
11
+ | Customize local serving | [Bun server](server-bun.md) |
12
+ | Customize the browser client | [Client](client.md#registered-operations) |
14
13
 
15
14
  You can also [convert the local app to a hosted data app](hosted-apps.md#convert-a-local-data-app).
16
15
 
17
- ## Preview the use-case starters
16
+ ## Preview the starters
18
17
 
19
18
  From the SDK repository, run `bun run dev:gallery` with Docker available. It starts
20
19
  and seeds the Altertable mock with fictional sample data.
21
20
 
22
21
  | Starter | Hosted preview | Local preview |
23
22
  | ------- | ------------------------------------------------- | ------------------------ |
23
+ | General | <http://127.0.0.1:27418/starter-data-app> | <http://127.0.0.1:27420> |
24
24
  | Metric | <http://127.0.0.1:27418/starter-metric-data-app> | <http://127.0.0.1:27421> |
25
25
  | Finding | <http://127.0.0.1:27418/starter-finding-data-app> | <http://127.0.0.1:27422> |
26
26
 
27
+ <http://127.0.0.1:27418/cost-dashboard> previews a larger example with summary
28
+ metrics, a breakdown, a stacked chart, and a detail destination.
29
+
27
30
  Copied starters use the normal query connection. Replace their example queries
28
31
  with verified sources in the target lakehouse; the mock and seed belong only to
29
32
  local development. Never create demo objects in a user's lakehouse.
@@ -100,5 +100,47 @@ Pass `presentation={{ surface: 'embedded', theme: resolvedTheme }}`
100
100
  to `<DataAppBridge>` in either source or connection mode. Use `'standalone'` when the app should render its own page chrome.
101
101
  Prop updates publish trusted state without reloading the iframe or reconnecting
102
102
  the session. Resolve system preference in the parent to `'light'` or `'dark'`.
103
- Inside an embedded surface, `<DataApp>` retains toolbar actions and hides its header
104
- and footer. See [parent presentation](embed.md#parent-presentation).
103
+ Inside an embedded surface, `<DataApp>` hides its header, footer, and page
104
+ toolbar. See [parent presentation](embed.md#parent-presentation).
105
+
106
+ ## Page actions
107
+
108
+ Render the app's page actions in the parent with `onActionsChange`, and run them
109
+ through the bridge's `ref`:
110
+
111
+ ```tsx
112
+ import { useRef, useState } from 'react';
113
+ import {
114
+ DataAppBridge,
115
+ type DataAppBridgeHandle,
116
+ } from '@altertable/data-app-embed/react';
117
+ import type { DataAppActions } from '@altertable/data-app-embed';
118
+
119
+ // ... javascript bundle and router
120
+ function Shell() {
121
+ const bridge = useRef<DataAppBridgeHandle>(null);
122
+ const [actions, setActions] = useState<DataAppActions>({});
123
+ return (
124
+ <>
125
+ {actions.refresh && (
126
+ <button
127
+ disabled={actions.refresh.refreshing}
128
+ onClick={() => bridge.current?.runAction({ type: 'refresh' })}
129
+ >
130
+ Refresh
131
+ </button>
132
+ )}
133
+ <DataAppBridge
134
+ ref={bridge}
135
+ title="Activity report"
136
+ source={{ type: 'bundle', javascript }}
137
+ presentation={{ surface: 'embedded', theme: 'light' }}
138
+ onActionsChange={setActions}
139
+ onMessage={router.dispatch}
140
+ />
141
+ </>
142
+ );
143
+ }
144
+ ```
145
+
146
+ See [page actions](embed.md#page-actions) for every action and its state.
package/docs/react.md CHANGED
@@ -7,9 +7,8 @@ React and React DOM 19.2 or newer are required. Start with
7
7
  ## Mount the app
8
8
 
9
9
  ```tsx
10
- import { injectDataAppStyles, mountDataApp } from '@altertable/data-app-react';
10
+ import { mountDataApp } from '@altertable/data-app-react';
11
11
 
12
- injectDataAppStyles();
13
12
  mountDataApp({ app: dataApp, component: App });
14
13
  ```
15
14
 
@@ -18,9 +17,7 @@ The app supplies `dataApp`, `App`, and a `#root` element.
18
17
  Keep the selected starter's mounting and client wiring. The
19
18
  app brief selects the starter and content structure; the available runtime
20
19
  starters are listed in [app authoring](app-authoring.md#use-release-matched-starters).
21
- Use declared views and bound widgets for data-backed content. Use `/ui` for
22
- setup/static screens or a custom component only when bound components cannot
23
- express the requirement.
20
+ Render a setup or static screen with `<DataApp>` without a `view`.
24
21
 
25
22
  Hosts embedding an app use the separate `@altertable/data-app-embed` package;
26
23
  that integration is outside ordinary app authoring.
@@ -10,13 +10,17 @@ when typechecking a Bun app.
10
10
  ```ts
11
11
  import { serveLocalApp } from '@altertable/data-app-bun';
12
12
  import page from './index.html';
13
- import { operations } from './operations.ts';
13
+ import { dataApp } from './app.ts';
14
14
 
15
- serveLocalApp({ page, operations, title: 'Activity' });
15
+ serveLocalApp({
16
+ page,
17
+ app: dataApp,
18
+ });
16
19
  ```
17
20
 
18
21
  The server binds to `127.0.0.1`. Its default port is `25837`, overridable through
19
- `PORT` or the `port` option. It serves the Bun HTML bundle and operation requests.
22
+ `PORT` or the `port` option. It serves the Bun HTML bundle and registered queries
23
+ by ID.
20
24
 
21
25
  `localLakehouse()` reads the CLI proxy URL and token from
22
26
  `ALTERTABLE_DATA_PROXY_URL` and `ALTERTABLE_DATA_PROXY_TOKEN`. It also supports
@@ -25,5 +29,4 @@ server-only `ALTERTABLE_LAKEHOUSE_USERNAME` and
25
29
  Missing credentials fail at startup. Keep these variables out of browser code.
26
30
 
27
31
  Local serving does not authenticate hosted viewers.
28
- Use [the portable server handler](server.md) with per-request authorization when
29
- hosting an app for other people.
32
+ Hosted apps authorize viewers in the host before executing registered queries.
@@ -2,11 +2,10 @@
2
2
 
3
3
  The bound `<DataApp>` from `@altertable/data-app-react` accepts an optional `story`
4
4
  callback and optional nonempty `datasets` list. Omit either prop to omit its toolbar
5
- control. Supplied features use the displayed snapshot, including during refresh or
5
+ control, or the matching [page action](embed.md#page-actions) when embedded. Supplied features use the displayed snapshot, including during refresh or
6
6
  failure. A story callback returning `[]` leaves a disabled presentation action.
7
7
  Set `showToolbar={false}` to omit page actions together; data loading, error states,
8
- and declared filters remain available. Setup and static screens can use `<DataApp>`
9
- from `/ui`.
8
+ and declared filters remain available. Setup and static screens omit `view`.
10
9
 
11
10
  These are component contracts. The app brief determines the
12
11
  intended presentation and export coverage. A presentation story is distinct from
@@ -14,8 +13,8 @@ explanatory prose in the app body.
14
13
 
15
14
  ## Present data with stories
16
15
 
17
- Continue the starter's `totalSamples` binding. Return one to four findings with a
18
- headline, visual, and registered dataset or
16
+ This example adds a story to the sample-count bindings in [widgets](widgets.md).
17
+ Return one to four findings with a headline, visual, and registered dataset or
19
18
  metric as `evidence`. The story receives `view`'s displayed snapshot, then one
20
19
  snapshot per entry in `summaryViews`. Reuse each binding with its own view's
21
20
  snapshot and derive scope from it:
@@ -53,7 +52,7 @@ function App() {
53
52
  List a view in `summaryViews` only when the story or export reads it: summary
54
53
  views load with the page instead of when their sections near the viewport.
55
54
 
56
- Keep the starter's `formatMetric()` import for formatted headlines.
55
+ Import `formatMetric()` from `@altertable/data-app/format` for formatted headlines.
57
56
 
58
57
  ## Export displayed data as CSV
59
58
 
package/docs/styling.md CHANGED
@@ -3,7 +3,8 @@
3
3
  Keep default appearance unless customization is requested. Use components and
4
4
  typed props first. Configure appearance once through
5
5
  `dataApp.appearance`; see [formatting and appearance](formatting-and-appearance.md).
6
- Call `injectDataAppStyles()` before mounting and use one `<DataApp>` per document.
6
+ `mountDataApp()` installs styles. When mounting `DataAppProvider` yourself, call
7
+ `injectDataAppStyles()` first. Use one `<DataApp>` per document.
7
8
 
8
9
  ## Customize
9
10