@altertable/data-app 0.72.0 → 0.73.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 (111) hide show
  1. package/AGENTS.md +5 -61
  2. package/CONTRIBUTING.md +93 -180
  3. package/README.md +3 -4
  4. package/REFERENCE.md +30 -345
  5. package/dist/chunks/contract-BeLPJwlO.js +558 -0
  6. package/dist/chunks/contract-BeLPJwlO.js.map +1 -0
  7. package/dist/chunks/contract-Di8SP74I.js +462 -0
  8. package/dist/chunks/contract-Di8SP74I.js.map +1 -0
  9. package/dist/chunks/format-BdFlv_xa.js +148 -0
  10. package/dist/chunks/format-BdFlv_xa.js.map +1 -0
  11. package/dist/chunks/iframe-C3uCZEXh.js +809 -0
  12. package/dist/chunks/iframe-C3uCZEXh.js.map +1 -0
  13. package/dist/chunks/operation-CBxhjNhK.js +131 -0
  14. package/dist/chunks/operation-CBxhjNhK.js.map +1 -0
  15. package/dist/chunks/request-body-H1qPmmTN.js +50 -0
  16. package/dist/chunks/request-body-H1qPmmTN.js.map +1 -0
  17. package/dist/client/index.js +253 -285
  18. package/dist/client/index.js.map +1 -13
  19. package/dist/core/appearance.js +171 -162
  20. package/dist/core/appearance.js.map +1 -10
  21. package/dist/core/config.js +49 -11
  22. package/dist/core/config.js.map +1 -9
  23. package/dist/core/contract.js +3 -73
  24. package/dist/core/format.js +1 -26
  25. package/dist/index.js +1 -12
  26. package/dist/internal.js +352 -397
  27. package/dist/internal.js.map +1 -15
  28. package/dist/server/index.js +85 -97
  29. package/dist/server/index.js.map +1 -10
  30. package/dist/types/chunks/appearance.d.ts +45 -0
  31. package/dist/types/chunks/contract.d.ts +720 -0
  32. package/dist/types/chunks/index.d.ts +189 -0
  33. package/dist/types/client/index.d.ts +3 -13
  34. package/dist/types/core/appearance.d.ts +2 -42
  35. package/dist/types/core/config.d.ts +36 -39
  36. package/dist/types/core/contract.d.ts +2 -114
  37. package/dist/types/core/format.d.ts +44 -17
  38. package/dist/types/index.d.ts +3 -3
  39. package/dist/types/internal.d.ts +312 -22
  40. package/dist/types/server/index.d.ts +15 -4
  41. package/docs/app-authoring.md +72 -128
  42. package/docs/client.md +29 -63
  43. package/docs/composition.md +44 -75
  44. package/docs/contract.md +60 -100
  45. package/docs/data-context.md +35 -61
  46. package/docs/embed.md +83 -55
  47. package/docs/formatting-and-appearance.md +17 -38
  48. package/docs/hosted-apps.md +7 -14
  49. package/docs/layout.md +30 -47
  50. package/docs/local-data-apps.md +7 -7
  51. package/docs/react-embed.md +20 -26
  52. package/docs/react.md +10 -27
  53. package/docs/server-bun.md +2 -27
  54. package/docs/server.md +6 -12
  55. package/docs/stories-and-export.md +38 -40
  56. package/docs/styling.md +14 -22
  57. package/docs/ui-quality.md +5 -5
  58. package/docs/ui.md +68 -70
  59. package/docs/variables.md +142 -254
  60. package/docs/views.md +85 -116
  61. package/docs/widgets.md +100 -153
  62. package/docs/worker.md +15 -27
  63. package/package.json +3 -2
  64. package/dist/chunks/index-5a27erdg.js +0 -54
  65. package/dist/chunks/index-5a27erdg.js.map +0 -10
  66. package/dist/chunks/index-9yxr7nmm.js +0 -742
  67. package/dist/chunks/index-9yxr7nmm.js.map +0 -17
  68. package/dist/chunks/index-j5q5n3ra.js +0 -151
  69. package/dist/chunks/index-j5q5n3ra.js.map +0 -10
  70. package/dist/chunks/index-q75zm3a7.js +0 -153
  71. package/dist/chunks/index-q75zm3a7.js.map +0 -11
  72. package/dist/chunks/index-vhaec7m5.js +0 -30
  73. package/dist/chunks/index-vhaec7m5.js.map +0 -10
  74. package/dist/chunks/index-zp78caex.js +0 -1047
  75. package/dist/chunks/index-zp78caex.js.map +0 -19
  76. package/dist/core/contract.js.map +0 -9
  77. package/dist/core/format.js.map +0 -9
  78. package/dist/index.js.map +0 -9
  79. package/dist/types/client/annotations.d.ts +0 -27
  80. package/dist/types/client/data-client.d.ts +0 -43
  81. package/dist/types/client/download.d.ts +0 -5
  82. package/dist/types/client/iframe.d.ts +0 -59
  83. package/dist/types/client/location.d.ts +0 -13
  84. package/dist/types/client/logger.d.ts +0 -14
  85. package/dist/types/client/messages.d.ts +0 -7
  86. package/dist/types/client/navigation.d.ts +0 -15
  87. package/dist/types/client/transport.d.ts +0 -15
  88. package/dist/types/core/annotations.d.ts +0 -99
  89. package/dist/types/core/bridge-endpoint.d.ts +0 -21
  90. package/dist/types/core/bridge.d.ts +0 -172
  91. package/dist/types/core/data-view.d.ts +0 -46
  92. package/dist/types/core/date-format.d.ts +0 -24
  93. package/dist/types/core/date-range.d.ts +0 -20
  94. package/dist/types/core/dimension-source.d.ts +0 -64
  95. package/dist/types/core/dimension.d.ts +0 -71
  96. package/dist/types/core/facets.d.ts +0 -13
  97. package/dist/types/core/filters.d.ts +0 -45
  98. package/dist/types/core/invariant.d.ts +0 -2
  99. package/dist/types/core/keys.d.ts +0 -2
  100. package/dist/types/core/logger.d.ts +0 -12
  101. package/dist/types/core/messages.d.ts +0 -62
  102. package/dist/types/core/navigation.d.ts +0 -11
  103. package/dist/types/core/operation-types.d.ts +0 -80
  104. package/dist/types/core/operation.d.ts +0 -20
  105. package/dist/types/core/presentation.d.ts +0 -9
  106. package/dist/types/core/queries.d.ts +0 -84
  107. package/dist/types/core/reading.d.ts +0 -17
  108. package/dist/types/core/uuid.d.ts +0 -2
  109. package/dist/types/core/variables.d.ts +0 -133
  110. package/dist/types/server/handler.d.ts +0 -13
  111. package/dist/types/server/request-body.d.ts +0 -4
package/docs/views.md CHANGED
@@ -1,154 +1,123 @@
1
1
  # Views and displayed results
2
2
 
3
+ Keep the starter's client and hooks. Use one view for related results; split only
4
+ when sections need independent requests. The examples continue the hosted
5
+ starter's `sampleCountsByGroup` operation and `sampleDataContext`.
6
+
3
7
  ## Bind a view
4
8
 
5
9
  ```tsx
6
- import { createDataClient } from '@altertable/data-app/client';
7
10
  import {
8
11
  createDataHooks,
9
12
  DataApp,
10
13
  DataSection,
14
+ searchVariable,
15
+ TableWidget,
11
16
  } from '@altertable/data-app-react';
12
- import type { operations } from '#app/operations.ts';
13
17
 
14
- const client = createDataClient<typeof operations>();
18
+ // ... client, operations, and sampleDataContext
15
19
  const { defineDataView } = createDataHooks(client);
16
- const activityView = defineDataView({
17
- dataContext,
18
- operation: 'activity',
19
- describeInput: () => 'all activity',
20
- isEmpty: data => data.rows.length === 0,
21
- emptyFallback: { title: 'No activity' },
20
+
21
+ const sampleCountsView = defineDataView({
22
+ dataContext: sampleDataContext,
23
+ operation: 'sampleCountsByGroup',
24
+ variables: {
25
+ groupName: searchVariable({
26
+ key: 'group',
27
+ label: 'Group',
28
+ defaultValue: '',
29
+ }),
30
+ },
31
+ describeInput: ({ groupName }) =>
32
+ groupName ? `group ${groupName}` : 'all groups',
33
+ isEmpty: rows => rows.length === 0,
34
+ emptyFallback: { title: 'No matching groups' },
22
35
  });
23
- const content = activityView.content(result => (
24
- <ActivityWidgets source={result} />
36
+ // ... sampleCounts dataset and story callback
37
+ const sampleContent = sampleCountsView.content(result => (
38
+ <TableWidget dataset={sampleCounts} source={result} />
25
39
  ));
26
40
 
27
41
  function App() {
28
42
  return (
29
- <DataApp view={activityView} story={story} datasets={[activityDataset]}>
30
- <DataSection content={content} />
43
+ <DataApp view={sampleCountsView} story={story} datasets={[sampleCounts]}>
44
+ <DataSection content={sampleContent} />
31
45
  </DataApp>
32
46
  );
33
47
  }
34
48
  ```
35
49
 
36
- Omit `variables` when there are no controls. Omit `input` when the resolved
37
- variables match the operation input; nested or different inputs need a mapper.
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
- `bindings` that read each selection back unchanged. Derive scalar SQL parameters
41
- inside the operation rather than replacing the selections in the view input.
42
- The operation and `ActivityWidgets` are app-owned. The bound widgets derive
43
- loading content from their source; see [widgets](widgets.md) and the
44
- [complete starter](app-authoring.md#use-release-matched-starters). Define
45
- [filters](variables.md), [context and evidence](data-context.md), and
46
- [story and datasets](stories-and-export.md) for the app's question.
47
-
48
- Render static text immediately; skeletonize only dynamic content. Keep section
49
- introductions outside request boundaries so they remain visible on empty and
50
- error states.
51
-
52
- Use `<DataSection>` for each independently fetched subtree and `view.content()`
53
- to share its loading and ready layout. Refreshes retain displayed content.
54
-
55
- Use `<DataValue>` for a dynamic value within static prose:
56
-
57
- ```tsx
58
- <p>
59
- Orders in the last 7 days: <DataValue metric={weeklyOrders} source={result} />
60
- </p>
61
- ```
62
-
63
- Bind the whole sentence with `<TextWidget>` when its wording depends on the result.
64
- Use `<DataValue scope={result.scope} />` for the displayed scope label.
65
-
66
- Use the same [date range contract](contract.md#shared-date-ranges) for the
67
- operation and its view. For nested inputs in `defineTimeView()`, use
68
- `bindings.period` to extract the selected period; see the
69
- [time-view example](variables.md#declare-controls-once).
70
-
71
- Use `result.scope` inside `view.content()` to show scope text. In stories and exports,
72
- `view.scope(snapshot)` returns the same label from the displayed input, using
73
- `describeInput` or the view's date label.
74
-
75
- Declare standard controls in the view's [variables](variables.md). Keep
76
- local-only filters out of the operation's `input`.
77
-
78
- For large tables, use query-backed pagination with a stable sort and total
79
- count. Client pagination and search cover only the rows already returned.
80
-
81
- Declare evidence references on `view.dataset()` for charts and tables. `<MetricWidget>` uses
82
- its metric definition for the label, format, and evidence; keep view-specific
83
- descriptions on the widget.
84
-
85
- `<MetricWidget>` and `<Comparison>` share a metric result. Comparisons
86
- follow the displayed result's range.
87
-
88
- Use the [format helpers](formatting-and-appearance.md) for metric formats and values in tables,
89
- charts, and custom views.
50
+ Keep operation input flat and named like the variables. Omit `input` and
51
+ `bindings` when those shapes match. Use `defineTimeView()` for period-driven
52
+ analysis and `defineDataView()` otherwise. Adapt an existing nested input only
53
+ when required; see [input mapping](variables.md#adapt-existing-input-shapes).
90
54
 
91
55
  ## Preserve displayed results
92
56
 
93
- Bind widgets to the source supplied by `view.content()`. Derive scope labels,
94
- stories, and exports from its displayed input, including during refreshes.
95
- Keep related datasets in one view so their results stay consistent; use
96
- `<DataSection>` for independently queried content. Let the view handle loading,
97
- errors, and refreshes instead of duplicating request state in app code.
57
+ Use the source from `view.content()` for every widget. Derive narrative, story,
58
+ export, and scope from that source and its displayed input, including during
59
+ refresh or failure. Use `result.scope` in content and `view.scope(snapshot)` in
60
+ stories. Let the view own request state; keep static introductions outside
61
+ loading boundaries.
98
62
 
99
- A measured zero is valid data. Define `isEmpty` for the analysis and provide
100
- useful `emptyFallback` copy.
63
+ A measured zero is valid data. Set `isEmpty` for the analysis and provide useful
64
+ `emptyFallback` copy.
101
65
 
102
66
  ## Detail destinations
103
67
 
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]}>`:
68
+ Add `defineDetailView()` only when readers need a scoped population or entity.
69
+ The destination owns its input parser, operation, datasets, context, and content.
70
+ Pass its content to `<DataApp details={[groupDetail]}>`:
107
71
 
108
72
  ```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' },
73
+ // ... client, operations, sampleDataContext, main view, datasets, and story
74
+ const { defineDetailView } = createDataHooks(client);
75
+
76
+ const groupView = defineDetailView({
77
+ id: 'group',
78
+ title: 'Group counts',
79
+ operation: 'sampleCountsByGroup',
80
+ dataContext: sampleDataContext,
81
+ parseInput: operations.sampleCountsByGroup.input,
82
+ describeInput: ({ groupName }) => `group ${groupName}`,
83
+ isEmpty: rows => rows.length === 0,
84
+ emptyFallback: { title: 'No matching group' },
85
+ });
86
+ const groupCounts = groupView.dataset({
87
+ name: 'Group counts',
88
+ select: rows => rows,
89
+ rowKey: row => row.groupName,
90
+ columns: {
91
+ groupName: { value: row => row.groupName },
92
+ sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
93
+ },
94
+ evidence: { id: 'group-counts', glossaryIds: ['sampleCount'] },
118
95
  });
119
- const ordersDetail = ordersView.content(source => (
120
- <TableWidget dataset={orders} source={source} />
96
+ const groupDetail = groupView.content(result => (
97
+ <TableWidget dataset={groupCounts} source={result} />
121
98
  ));
99
+
100
+ function App() {
101
+ return (
102
+ <DataApp
103
+ view={sampleCountsView}
104
+ datasets={[sampleCounts]}
105
+ story={story}
106
+ details={[groupDetail]}
107
+ >
108
+ <DataSection content={sampleContent} />
109
+ </DataApp>
110
+ );
111
+ }
122
112
  ```
123
113
 
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.
114
+ Pass serializable scope and IDs, not records or credentials. Validate dimension selections with
115
+ the dashboard's `variableInput()` parser. The main app owns stories and exports.
131
116
 
132
117
  ### Contributing metric records
133
118
 
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.
119
+ Use `metric.records()` when a detail shows the records behind that metric, then
120
+ pass it to `<MetricWidget records={...}>`. Match record inclusion to the metric
121
+ and explain non-additive measures or completeness limits. Query matching records
122
+ rather than filtering a capped dashboard preview; use server pagination for
123
+ larger populations.
package/docs/widgets.md CHANGED
@@ -4,9 +4,7 @@
4
4
 
5
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
- Manage requests in the [view and section](views.md); show skeletons for loading
8
- readings without inventing values. Use `isEmpty` for the predicate and
9
- `emptyFallback` for empty-result copy.
7
+ Manage requests in [views](views.md).
10
8
 
11
9
  | Need | Component |
12
10
  | ------------------------------------------------ | ----------------------- |
@@ -17,7 +15,8 @@ readings without inventing values. Use `isEmpty` for the predicate and
17
15
  | Borderless explanatory prose | `<TextContent>` |
18
16
  | One data-dependent phrase within static prose | `<DataValue>` |
19
17
 
20
- Use [layout](layout.md) for `<Stack>`, `<Grid>`, and responsive `<GridItem>` spans.
18
+ Use `<Stack>` for reading order and `<Grid>` for peers. Read [layout](layout.md)
19
+ only when changing spans or shell composition.
21
20
  `<Skeleton>` supports custom fallback content.
22
21
 
23
22
  ## Choose a visualization
@@ -27,34 +26,30 @@ Choose the component by the user's question. Compose dataset visuals inside
27
26
  charts come from `@altertable/data-app-react/ui`; `<Ranking>`, `<Breakdown>`, and `<Comparison>`
28
27
  are also available from `@altertable/data-app-react`.
29
28
 
30
- | Question or need | Component | Guidance |
31
- | ------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
32
- | How do categories compare? | `<BarChart>` | Compare nonnegative category values; order by value for rank or by a meaningful category order. |
33
- | Which items lead? | `<Ranking>` | Use a compact ordered list with values and optional detail. Tracks scale to the largest visible item, not a total. |
34
- | How does a measure, including conversion rate, change over calendar time? | `<LineChart>` | Use ordered, equally spaced samples to emphasize the trend. |
35
- | How large is the measure over time? | `<AreaChart>` | Use the same samples as a line chart when filled magnitude relative to zero helps answer the question. |
36
- | What makes up the whole? | `<PieChart>` | Use a few mutually exclusive parts of one total; include the remainder as Other. |
37
- | What share of an observed total does each part represent? | `<Breakdown>` | Use a compact display of values and shares with an explicit total, including when only some parts are shown. |
38
- | How do several measures relate on one plot? | `<ComposedChart>` | Compose bars, lines, areas, or scatter series; label units clearly and use separate axes for different units. |
39
- | How are two numeric measures related? | `<ScatterChart>` | Use independent X/Y observations to explore relationships, clusters, and outliers. |
40
- | Where does a population drop off across ordered steps? | `<FunnelChart>` | Show counts and drop-off across ordered steps within a population; optionally compare populations. See [inputs and examples](ui.md#product-analytics-charts). |
41
- | Do cohorts return at elapsed intervals after a starting event? | `<RetentionChart>` | Show return rates over elapsed intervals after a starting event; optionally compare cohorts or segments. See [inputs and examples](ui.md#product-analytics-charts). |
42
- | Which event paths do populations follow, and where do they branch? | `<JourneyChart>` | Explore full paths with population counts and outcomes. See [inputs and examples](ui.md#product-analytics-charts). |
43
- | How did one metric change between periods? | `<Comparison>` | Use the metric result and its displayed comparison period. |
44
- | What are the exact values or row details? | `<TableWidget>` | Use a bound table for lookup, search, and precise comparisons. |
45
-
46
- Prefer bars or a ranking when users need to compare similarly sized categories;
47
- use a pie for a simple composition question. Prefer a line when the trend is
48
- enough; use area when the fill adds meaning. Keep exact values available in a
49
- table when they matter. Follow the [chart input constraints](ui.md#charts). For custom combinations of series,
50
- use the [composed chart primitives](ui.md#composed-charts) within the same bound
51
- visualization workflow.
52
-
53
- Use widget `views` when a chart and another representation answer the same
54
- question from the same dataset.
29
+ | Question | Component and constraint |
30
+ | -------------------------------- | ------------------------------------------------------------------------------- |
31
+ | Compare categories | `<BarChart>` for nonnegative values; order by rank or meaningful category order |
32
+ | Show leaders | `<Ranking>`; tracks scale to the largest visible item |
33
+ | Show a time trend | `<LineChart>` for equally spaced samples |
34
+ | Show magnitude over time | `<AreaChart>` when fill relative to zero adds meaning |
35
+ | Show parts of a whole | `<PieChart>` for a few exclusive parts; include Other |
36
+ | Show shares of an observed total | `<Breakdown>` with an explicit total |
37
+ | Combine measures or marks | `<ComposedChart>`; label units and use separate axes when needed |
38
+ | Relate two numeric measures | `<ScatterChart>` with independent X/Y observations |
39
+ | Show ordered step drop-off | `<FunnelChart>` with counts from one population |
40
+ | Show return by elapsed interval | `<RetentionChart>` with cohort counts and rates |
41
+ | Explore event paths | `<JourneyChart>` with full paths, counts, and outcomes |
42
+ | Compare periods | `<Comparison>` with a bound metric |
43
+ | Inspect exact values | `<TableWidget>` with a dataset binding |
44
+
45
+ Use widget `views` for alternate representations of one dataset. Check
46
+ [chart input constraints](ui.md#charts) before adapting rows, and keep exact
47
+ values available in a table when they matter.
55
48
 
56
49
  ## Declare datasets and metrics
57
50
 
51
+ Continue the starter's `sampleCountsView`. Use `<BarChart>` from
52
+ `@altertable/data-app-react/ui`.
58
53
  Bind reusable selections to the view. Declare evidence references directly;
59
54
  the view validates them against its own context. A dataset's columns supply both formatted
60
55
  table cells and raw CSV values. Widgets derive their readings, evidence, and empty fallback from the binding.
@@ -62,64 +57,57 @@ Declare at least one dataset column. Metric selectors may return `previous`
62
57
  only for views with a date binding, including `defineTimeView()`.
63
58
 
64
59
  ```tsx
65
- const countries = activityView.dataset({
66
- name: 'Countries',
67
- select: data => data.countries,
68
- rowKey: row => row.country,
69
- evidence: { id: 'countries', glossaryIds: ['identities'] },
60
+ // ... sampleCountsView and imports
61
+ const sampleCounts = sampleCountsView.dataset({
62
+ name: 'Sample counts',
63
+ select: rows => rows,
64
+ rowKey: row => row.groupName,
65
+ evidence: { id: 'counts-by-group', glossaryIds: ['sampleCount'] },
70
66
  columns: {
71
- country: { value: row => row.country },
72
- count: { value: row => row.count, format: { kind: 'count' } },
67
+ groupName: { label: 'Group', value: row => row.groupName },
68
+ sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
73
69
  },
74
70
  });
75
- const total = activityView.metric(
71
+ const totalSamples = sampleCountsView.metric(
76
72
  {
77
- id: 'tracked-identities',
78
- glossaryId: 'identities',
73
+ id: 'total-samples',
74
+ glossaryId: 'sampleCount',
75
+ label: 'Total samples',
79
76
  format: { kind: 'count', compact: true },
80
77
  },
81
- data => ({
82
- current: data.count,
83
- previous: data.previousCount,
84
- })
78
+ rows => ({ current: rows.reduce((sum, row) => sum + row.sampleCount, 0) })
85
79
  );
86
- const content = activityView.content(result => (
80
+ const sampleContent = sampleCountsView.content(result => (
87
81
  <Grid columns={2}>
88
- <MetricWidget metric={total} source={result} />
89
- <TableWidget dataset={countries} source={result} />
90
- <VisualizationWidget dataset={countries} source={result}>
91
- {rows => <CountryChart rows={rows} />}
82
+ <MetricWidget metric={totalSamples} source={result} />
83
+ <TableWidget dataset={sampleCounts} source={result} />
84
+ <VisualizationWidget dataset={sampleCounts} source={result}>
85
+ {rows => (
86
+ <BarChart
87
+ ariaLabel="Sample counts by group"
88
+ unit="samples"
89
+ items={rows.map(row => ({
90
+ ...row,
91
+ id: row.groupName,
92
+ label: row.groupName,
93
+ value: row.sampleCount,
94
+ }))}
95
+ />
96
+ )}
92
97
  </VisualizationWidget>
93
98
  </Grid>
94
99
  ));
95
100
  ```
96
101
 
97
- Column keys supply unique IDs and readable default labels. Use `label` for a
98
- specific display/export header. Declare selectors, raw value accessors, and
99
- row-key callbacks explicitly; row keys must be stable and unique.
100
- Metric comparisons require a
101
- view date binding. `read()` returns a loading-aware value for custom prose.
102
- Pass the binding and `source={snapshot}` to reuse a widget in a story. Use the
103
- source supplied by that binding's own view. Table search, pagination, descriptions, and
104
- actions remain local choices. For custom cells, use `format: row => ...`; CSV
105
- still uses the raw `value` accessor. Datasets default to “No results”; supply
106
- `emptyFallback` for specific copy. See [export](stories-and-export.md).
107
-
108
- `<TableWidget>` automatically shows the count of matching supplied rows. Use
109
- `count` for a server total; other widgets can receive a count from the displayed result.
110
-
111
- Provide useful `emptyFallback` and `noMatchesFallback` copy. Local search offers
112
- Clear search automatically. For server-filtered tables, supply `onClearFilters`
113
- only while filters affecting that dataset are active, preserving unrelated filters,
114
- search, and display settings.
102
+ Column keys supply IDs and default labels; set `label` for a different header.
103
+ Keep row keys stable and unique. Custom cells use `format: row => ...`; CSV uses
104
+ the raw `value` accessor. Metric comparisons require a view date binding.
105
+ Reuse bindings in stories with `source={snapshot}` from the same view.
115
106
 
116
- ```tsx
117
- <TableWidget
118
- dataset={customers}
119
- source={source}
120
- onClearFilters={hasActiveCustomerFilters ? clearCustomerFilters : undefined}
121
- />
122
- ```
107
+ Tables search and paginate only supplied rows. Use query-backed pagination with a
108
+ stable sort and total `count` for larger datasets. Provide useful `emptyFallback`
109
+ and `noMatchesFallback` copy. Supply `onClearFilters` only while relevant server
110
+ filters are active, preserving unrelated selections.
123
111
 
124
112
  ## Narrative text
125
113
 
@@ -135,7 +123,7 @@ It derives its title and evidence. A metric formats its current value by default
135
123
  use a child renderer for authored prose. Dataset renderers receive displayed rows,
136
124
  including an empty selection, so they can explain zero activity.
137
125
 
138
- Use `<DataValue metric={total} source={result} />` for a formatted value inside
126
+ Use `<DataValue metric={totalSamples} source={result} />` for a formatted value inside
139
127
  static prose, or pass a dataset and row renderer. Its default loading fallback is
140
128
  an inline skeleton. Use `<DataValue scope={result.scope} />` for a scope label.
141
129
  Use `<TextContent>` for static instructions; local filters should feed the same
@@ -150,16 +138,8 @@ The dataset owns evidence and empty copy; an empty row selection shows that fall
150
138
  alternate-view selection shared with its inspection sheet. Give views stable IDs
151
139
  and keep interactive state above the widget, since inspection may render it again.
152
140
 
153
- `<TableWidget>` searches and paginates only the supplied rows. Use query-backed
154
- pagination with a stable sort and total count for larger datasets. The `limit`
155
- mode shows a bounded preview without local pagination. Custom tables can use
156
- `<DataTable>`, `<DataTableEmptyRow>`, `<DataTableTimestamp>`, and `<DataTableShare>`.
157
-
158
- For custom controls, tables, and overlays, see [direct UI composition](ui.md).
159
- For embedded theme and chrome, see [parent presentation](embed.md#parent-presentation).
160
-
161
- `<TooltipProvider>` shares hover timing outside `<DataApp>`; the app already
162
- provides it.
141
+ Use custom controls, tables, or overlays only when bound components cannot
142
+ express the requirement; see [direct UI composition](ui.md).
163
143
 
164
144
  ## Exploration actions
165
145
 
@@ -169,84 +149,51 @@ Both `children` and alternate-view `render` callbacks receive the displayed rows
169
149
  and the same action resolver.
170
150
 
171
151
  ```tsx
172
- const placeActions = places.actions(
152
+ // ... sampleCountsView, sampleCounts, and groupView
153
+ const groupActions = sampleCounts.actions(
173
154
  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
- },
155
+ group: action.detail({
156
+ label: 'View group',
157
+ target: groupView,
158
+ input: row => ({ groupName: row.groupName }),
204
159
  }),
205
160
  }),
206
- { primary: 'orders' }
161
+ { primary: 'group' }
207
162
  );
208
163
 
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>;
164
+ const sampleContent = sampleCountsView.content(result => (
165
+ <VisualizationWidget
166
+ dataset={sampleCounts}
167
+ source={result}
168
+ actions={groupActions}
169
+ >
170
+ {(rows, actions) => (
171
+ <BarChart
172
+ ariaLabel="Sample counts by group"
173
+ unit="samples"
174
+ items={rows.map(row => ({
175
+ ...row,
176
+ id: row.groupName,
177
+ label: row.groupName,
178
+ value: row.sampleCount,
179
+ }))}
180
+ itemActions={actions}
181
+ />
182
+ )}
183
+ </VisualizationWidget>
184
+ ));
224
185
  ```
225
186
 
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.
187
+ `groupView` is the destination from the detail-view example.
188
+ Keep domain fields when adapting chart items so action mappings retain IDs and
189
+ scope. Pass dataset actions to `<TableWidget>` or `<VisualizationWidget>`;
190
+ metric actions use `metric.actions()` and `<MetricWidget>`. Actions must belong
191
+ to the binding rendered by the widget. Metric mappings receive `undefined` for
192
+ the row and displayed input as their second argument.
244
193
 
245
194
  `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.
195
+ one chart's display choice in the same history entry. Filters preserve unrelated selections. Declare chart breakdown choices
196
+ independently of scope filters.
250
197
 
251
198
  A day drill passes its day. A value-band drill passes a stable band ID; validate
252
199
  it in the destination operation and derive bounds there. Query matching records
package/docs/worker.md CHANGED
@@ -27,30 +27,18 @@ and these string bindings:
27
27
  | `DOMAIN_NAME` | Runtime domain without scheme, port, or trailing dot | `apps.example.net` |
28
28
  | `PARENT_ORIGINS` | Space-separated trusted HTTP(S) origins; first exact origin is the default | `https://app.example.com https://*.preview.example.com` |
29
29
 
30
- The Worker serves only `/` on a single preview label under `DOMAIN_NAME` matching
31
- `/^(?=.{1,63}$)[a-z0-9]+(?:-+[a-z0-9]+)+$/`
32
- (any hyphenated lowercase DNS label; the host keeps each app's label unique). Other hosts and paths
33
- return 404. GET returns HTML; HEAD returns the same headers with no body. Other
34
- methods return 405 with `Allow: GET, HEAD`.
35
-
36
- `__altertable_parent` selects an **exact** parent origin only after validation
37
- against `PARENT_ORIGINS`. It cannot add trust. HTTPS wildcard entries allow one
38
- subdomain label, without a port, for staging previews. Their apex and deeper
39
- subdomains are rejected. Exact origins cannot contain paths, trailing slashes,
40
- credentials, queries, or fragments. Invalid, duplicate, or unapproved selections
41
- return 403. Missing or invalid origin configuration returns 503; an absent
42
- selection requires an exact default origin. Referrers and messages never supply
43
- trust.
44
-
45
- The Worker enforces a restrictive CSP with configured `frame-ancestors`,
46
- `no-referrer`, and `nosniff`. App scripts load through the authenticated bridge. Apps own styling and
47
- navigation. Bundle apps execute their operation registry in the browser and send
48
- SQL through the [host query route](embed.md#sql-query-route); the Worker does not
49
- resolve operation names or execute queries. Data requests require backend authorization.
50
-
51
- If Terraform reads a file, copy the resolved `@altertable/data-app-worker` asset unchanged to that
52
- file during deployment preparation. Configure `DOMAIN_NAME`, `PARENT_ORIGINS`,
53
- domains, routes, and deployment settings in Terraform. Upgrade the host package
54
- and Worker together for protocol changes.
55
- Custom hosts that bundle their own bootstrap can use `startDataAppBootstrap()` from
56
- [the embed package](embed.md#trusted-bootstrap).
30
+ Serve `/` on unique hyphenated lowercase preview labels under `DOMAIN_NAME`,
31
+ such as `report-123.apps.example.net`. Other hosts and paths return 404.
32
+
33
+ `__altertable_parent` selects an exact trusted origin from `PARENT_ORIGINS`; it
34
+ cannot add trust. Wildcards allow one HTTPS subdomain label without a port.
35
+ Exact entries must be bare HTTP(S) origins. Keep an exact origin first for the
36
+ default parent.
37
+
38
+ The Worker sets CSP and trusted frame ancestors. Data queries use the
39
+ [host's authorized SQL route](embed.md#sql-query-route); the Worker does not
40
+ execute queries.
41
+
42
+ For file-based deployment tools such as Terraform, copy the resolved asset
43
+ unchanged. Upgrade the host package and Worker together for protocol changes.
44
+ Custom bootstrap hosts use [startDataAppBootstrap()](embed.md#trusted-bootstrap).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altertable/data-app",
3
- "version": "0.72.0",
3
+ "version": "0.73.0",
4
4
  "description": "Portable definitions, contracts, formatting, browser clients, and request handlers for Altertable data apps.",
5
5
  "keywords": [
6
6
  "altertable",
@@ -73,7 +73,8 @@
73
73
  "registry": "https://registry.npmjs.org"
74
74
  },
75
75
  "scripts": {
76
- "build": "bun ../../scripts/build.ts data-app"
76
+ "build": "bun ../../scripts/build.ts data-app",
77
+ "typecheck": "bun ../../node_modules/typescript/bin/tsc --noEmit -p tsconfig.build.json"
77
78
  },
78
79
  "dependencies": {
79
80
  "@internationalized/date": "3.12.4"