@altertable/data-app 0.78.0 → 0.80.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 (40) hide show
  1. package/AGENTS.md +3 -0
  2. package/CONTRIBUTING.md +2 -1
  3. package/REFERENCE.md +60 -178
  4. package/dist/chunks/{contract-gu1rDsV0.js → contract-CNG8X16X.js} +22 -16
  5. package/dist/chunks/contract-CNG8X16X.js.map +1 -0
  6. package/dist/chunks/{data-client-BMdL73Ab.js → data-client-BC_Xsl95.js} +4 -4
  7. package/dist/chunks/{data-client-BMdL73Ab.js.map → data-client-BC_Xsl95.js.map} +1 -1
  8. package/dist/chunks/{date-time-range-value-D-XfqVTT.js → date-time-range-value-DA8GWV_U.js} +28 -88
  9. package/dist/chunks/date-time-range-value-DA8GWV_U.js.map +1 -0
  10. package/dist/chunks/{diagnostics-CX9SsU79.js → diagnostics-BU06BbS0.js} +112 -8
  11. package/dist/chunks/diagnostics-BU06BbS0.js.map +1 -0
  12. package/dist/client/index.js +3 -3
  13. package/dist/core/config.js +3 -2
  14. package/dist/core/config.js.map +1 -1
  15. package/dist/core/contract.js +2 -2
  16. package/dist/core/format.js +1 -1
  17. package/dist/internal.js +4 -4
  18. package/dist/types/chunks/contract.d.ts +6 -1
  19. package/dist/types/chunks/index.d.ts +28 -1
  20. package/dist/types/client/index.d.ts +1 -1
  21. package/dist/types/core/config.d.ts +3 -0
  22. package/dist/types/internal.d.ts +23 -2
  23. package/docs/app-authoring.md +160 -76
  24. package/docs/contract.md +16 -15
  25. package/docs/data-context.md +7 -10
  26. package/docs/embed.md +19 -0
  27. package/docs/filters.md +10 -12
  28. package/docs/formatting-and-appearance.md +2 -5
  29. package/docs/hosted-apps.md +2 -2
  30. package/docs/local-data-apps.md +5 -1
  31. package/docs/react-embed.md +2 -0
  32. package/docs/react.md +1 -3
  33. package/docs/stories-and-export.md +1 -2
  34. package/docs/ui.md +25 -7
  35. package/docs/views.md +6 -8
  36. package/docs/widgets.md +7 -8
  37. package/package.json +1 -1
  38. package/dist/chunks/contract-gu1rDsV0.js.map +0 -1
  39. package/dist/chunks/date-time-range-value-D-XfqVTT.js.map +0 -1
  40. package/dist/chunks/diagnostics-CX9SsU79.js.map +0 -1
@@ -14,82 +14,162 @@ for the requested change. For a new app, use the starter supplied by the authori
14
14
  | Hosted / remote / cloud | `starter-data-app/index.tsx` |
15
15
  | Local | `starter-local-data-app` |
16
16
  | Hosted metric | `starter-metric-data-app/index.tsx` |
17
- | Hosted Finding | `starter-finding-data-app/index.tsx` |
18
17
  | Local metric | `starter-local-metric-data-app` |
18
+ | Hosted Finding | `starter-finding-data-app/index.tsx` |
19
19
  | Local Finding | `starter-local-finding-data-app` |
20
20
 
21
- Choose the runtime and use case supplied by the app brief. Each starter is editable
22
- source; replace fixture queries and sample content before publishing. The starters demonstrate query → operation
23
- → context → view → dataset → widget composition.
24
- Hosted apps stay in one file with public package imports
25
- and a literal `defineDataApp()` declaration. Local apps use the same composition
26
- with their existing server/client wiring. Replace fixture queries and example content; edit
27
- app-owned files, not installed packages.
28
-
29
- ## Connect data and components
30
-
31
- 1. **Define the question and scope.** Inspect relevant fields, definitions, time
32
- coverage, and missing or incomplete observations. Establish the population,
33
- grain, measures, and comparison. Choose a chart that answers the question.
34
- 2. **Separate independent results.** Give each independently queried result its
35
- own named query and operation. Widgets may share one result when they show
36
- the same rows or derive related metrics from the same summary, such as total
37
- cost, customer count, and average cost. Keep unrelated results separate.
38
- Write queries against inspected data and preserve supplied
39
- metric definitions. Write DuckDB SQL with named parameters; declare `params`
40
- and result aliases in `projections`.
41
- Execute named queries with `query()` and derive results from its typed rows.
42
- 3. **Update context and bindings.** Describe definitions and coverage in the data
43
- context, using the operation's `queryNames` for evidence. Declare each dataset
44
- and metric once, with stable row keys, raw column values, and shared formats.
45
- 4. **Declare filters once, then one view per operation.** Declare each filter
46
- and display choice as a constant and list the ones each operation reads in
47
- its `filters`; the operation receives one flat input field per filter. Define
48
- each view with `defineView({ operation, dataContext })`: its filters,
49
- reporting period, and scope derive from the operation. Pass the headline view
50
- to `<DataApp view>`, which renders every filter's control, and render each
51
- view in its own `<DataSection>`. Keep protected values such as `orgId`
52
- backend-owned. See [views](views.md#give-each-independent-result-its-own-view) and
53
- [filters](filters.md).
54
- 5. **Compose the content.** Follow the app brief for section order and narrative.
55
- Use `<Stack>` for sections, `<Grid>` for peers, and bound widgets
56
- from `@altertable/data-app-react`. Keep static explanations outside loading
57
- boundaries. Use app tabs only for distinct questions and widget `views` only
58
- for alternate representations of one dataset. See [layout](layout.md#adapt-to-the-available-container)
59
- for container-based sizing. Keep default appearance;
60
- customize when requested. Use custom UI only when bound components cannot
61
- express the requirement.
62
- 6. **Connect shell features.** See [stories and export](stories-and-export.md)
63
- for the current `<DataApp>` requirements and how to bind these features to the
64
- displayed result. The app brief determines presentation content and export
65
- coverage.
66
-
67
- Keep credentials, authorization, and enforced query limits in the host/backend.
68
- The starter supplies transport and mounting; change them only for an explicit
69
- integration task.
70
-
71
- ## Link to external pages
72
-
73
- Use `<ExternalLink>` for HTTPS destinations in widget content:
74
-
75
- ```tsx
76
- import { ExternalLink } from '@altertable/data-app-react';
77
-
78
- function ReportLink() {
79
- return (
80
- <ExternalLink href="https://example.com/report">
81
- View full report
82
- </ExternalLink>
83
- );
84
- }
85
- ```
86
-
87
- For programmatic navigation, import `navigateNewTab`, `navigateNewWindow`, or
88
- `navigateNewWindowOrTab` from `@altertable/data-app/client`. For example,
89
- `navigateNewWindowOrTab(url, event)` accepts a DOM or React event: Shift requests
90
- a window, Ctrl/Cmd requests a tab, and an unmodified event does nothing.
91
-
92
- Embedded hosts must enable the [external link route](embed.md#external-links).
21
+ Choose the runtime and use case supplied by the app brief. The general starter
22
+ is one complete result: one query, operation, view, dataset, and chart. The
23
+ metric and Finding starters add a second result, drill-down, and comparison.
24
+ Hosted apps stay in one file with public package imports and a literal
25
+ `defineDataApp()` declaration. Local apps split the same code across app-owned
26
+ files. Edit app-owned files, not installed packages.
27
+
28
+ ## Write the app in order
29
+
30
+ Each step uses what the previous one declared. The snippets are the general
31
+ starter; repeat steps 2–7 for each independent result. Widgets share a result
32
+ when they show the same rows or metrics from one summary, such as a total, a
33
+ count, and their average.
34
+
35
+ 1. **Inspect the data.** Establish the population, grain, measures, and
36
+ comparison from real fields, definitions, time coverage, and missing
37
+ observations. Preserve supplied metric definitions.
38
+ 2. **Declare the query.** Write DuckDB SQL with named parameters, and declare
39
+ every parameter and result alias. See [queries](contract.md).
40
+
41
+ ```ts
42
+ export const dataApp = defineDataApp({
43
+ // ... title, description, and scope
44
+ queries: {
45
+ sampleCountsByGroup: {
46
+ statement: `
47
+ SELECT group_name, CAST(SUM(sample_count) AS BIGINT) AS sample_count
48
+ FROM sample_counts
49
+ WHERE $groupName = 'all' OR group_name = $groupName
50
+ GROUP BY group_name ORDER BY sample_count DESC, group_name LIMIT $limit`,
51
+ params: {
52
+ groupName: { type: 'string', defaultValue: 'all' },
53
+ limit: { type: 'number', defaultValue: 10 },
54
+ },
55
+ projections: {
56
+ group_name: { type: 'string' },
57
+ sample_count: { type: 'number' },
58
+ },
59
+ },
60
+ },
61
+ });
62
+ ```
63
+
64
+ 3. **Declare filters, then the operation that reads them.** Declare each filter
65
+ once as a constant. `run()` receives one field per filter and returns the
66
+ rows the app displays. See [filters](filters.md).
67
+
68
+ ```ts
69
+ const groupName = choiceFilter({
70
+ key: 'group',
71
+ label: 'Group',
72
+ defaultValue: 'all',
73
+ options: [
74
+ { id: 'all', label: 'All groups' },
75
+ { id: 'Alpha', label: 'Alpha' },
76
+ ],
77
+ });
78
+
79
+ export const operations = dataApp.defineOperations({
80
+ sampleCountsByGroup: dataApp.defineOperation({
81
+ filters: { groupName },
82
+ policy: { maxQueryRows: 10 },
83
+ async run({ query }, { groupName }) {
84
+ const { rows } = await query('sampleCountsByGroup', { groupName });
85
+ return rows.map(row => ({
86
+ groupName: row.group_name,
87
+ sampleCount: row.sample_count,
88
+ }));
89
+ },
90
+ }),
91
+ });
92
+ ```
93
+
94
+ 4. **Describe the data.** Define the terms readers need and cite the queries
95
+ behind each one. See [data context](data-context.md).
96
+
97
+ ```ts
98
+ const dataContext = createDataContext(dataApp.queryNames)({
99
+ description: 'Sample counts by group.',
100
+ glossary: {
101
+ sampleCount: {
102
+ term: 'Sample count',
103
+ definition: 'Sum of recorded samples in the selected group scope.',
104
+ queryNames: [dataApp.queryNames.sampleCountsByGroup],
105
+ },
106
+ },
107
+ });
108
+ ```
109
+
110
+ 5. **Define one view per operation.** Its filters, reporting period, and scope
111
+ derive from the operation. See [views](views.md).
112
+
113
+ ```ts
114
+ const { defineView } = createDataHooks(operations.createDataClient());
115
+ const sampleCountsView = defineView({
116
+ dataContext,
117
+ operation: 'sampleCountsByGroup',
118
+ emptyFallback: { title: 'No matching groups' },
119
+ });
120
+ ```
121
+
122
+ 6. **Bind a dataset or metric to the view.** A column named after a row field
123
+ reads it; a stable `rowKey` identifies each row. See
124
+ [widgets](widgets.md#declare-datasets-and-metrics).
125
+
126
+ ```ts
127
+ const sampleCounts = sampleCountsView.dataset({
128
+ name: 'Sample counts',
129
+ rowKey: row => row.groupName,
130
+ columns: {
131
+ groupName: { label: 'Group' },
132
+ sampleCount: { format: { kind: 'count' } },
133
+ },
134
+ evidence: { id: 'counts-by-group', glossaryIds: ['sampleCount'] },
135
+ });
136
+ ```
137
+
138
+ 7. **Render the result.** Pass the headline view to `<DataApp view>`, which
139
+ renders every filter's control, and give each view's content its own
140
+ `<DataSection>`. Follow the app brief for section order and narrative.
141
+
142
+ ```tsx
143
+ const countsContent = sampleCountsView.content(result => (
144
+ <VisualizationWidget dataset={sampleCounts} source={result}>
145
+ {rows => (
146
+ <BarChart
147
+ ariaLabel="Sample counts by group"
148
+ unit="samples"
149
+ items={rows.map(row => ({
150
+ id: row.groupName,
151
+ label: row.groupName,
152
+ value: row.sampleCount,
153
+ }))}
154
+ />
155
+ )}
156
+ </VisualizationWidget>
157
+ ));
158
+
159
+ function App() {
160
+ return (
161
+ <DataApp view={sampleCountsView} datasets={[sampleCounts]}>
162
+ <DataSection content={countsContent} />
163
+ </DataApp>
164
+ );
165
+ }
166
+ ```
167
+
168
+ Use bound widgets from `@altertable/data-app-react` for data-backed content.
169
+ Use [`/ui` components](ui.md) or custom UI only when a bound widget cannot
170
+ express the requirement. Keep credentials, authorization, protected values such
171
+ as `orgId`, and enforced query limits in the host/backend. The starter supplies
172
+ transport and mounting; change them only for an explicit integration task.
93
173
 
94
174
  ## Verify the app
95
175
 
@@ -112,10 +192,10 @@ for host integration.
112
192
 
113
193
  ## Look up only what is missing
114
194
 
115
- Search [REFERENCE.md](../REFERENCE.md) for the exact symbol first:
195
+ Search [REFERENCE.md](../REFERENCE.md) for the exact export or method first:
116
196
 
117
197
  ```sh
118
- rg '^LineChart\b' REFERENCE.md
198
+ rg '(^|\.)defineView\b' REFERENCE.md
119
199
  ```
120
200
 
121
201
  Open only the section needed for a requirement the starter does not cover:
@@ -124,8 +204,12 @@ Open only the section needed for a requirement the starter does not cover:
124
204
  | -------------------------------------------- | ----------------------------------------------------------------- |
125
205
  | Adding categorical, numeric, or time filters | [Filters](filters.md) |
126
206
  | Adding a chart or narrative binding | [Widgets](widgets.md) |
127
- | Adding supplemental control hints | [Tooltips](ui.md#tooltips-and-explanations) |
207
+ | Adding a second result or a summary | [Views](views.md#give-each-independent-result-its-own-view) |
128
208
  | Adding a detail destination | [Detail views](views.md#detail-destinations) |
209
+ | Adding a presentation story or CSV export | [Stories and export](stories-and-export.md) |
210
+ | Arranging sections or adapting to width | [Layout](layout.md) |
211
+ | Linking to external pages | [External links](ui.md#external-links) |
212
+ | Adding supplemental control hints | [Tooltips](ui.md#tooltips-and-explanations) |
129
213
  | Registering physical sources | [Source identifiers](data-context.md#register-source-identifiers) |
130
214
  | Customizing appearance or CSS | [Formatting](formatting-and-appearance.md), [styling](styling.md) |
131
215
 
package/docs/contract.md CHANGED
@@ -21,10 +21,10 @@ const dataApp = defineDataApp({
21
21
  statement: `
22
22
  WITH sample_counts(group_name, sample_count) AS (VALUES ('Alpha', 2200000), ('Beta', 0))
23
23
  SELECT group_name, sample_count FROM sample_counts
24
- WHERE $groupName = '' OR group_name = $groupName
24
+ WHERE $groupName = 'all' OR group_name = $groupName
25
25
  ORDER BY group_name LIMIT $limit`,
26
26
  params: {
27
- groupName: { type: 'string', defaultValue: '' },
27
+ groupName: { type: 'string', defaultValue: 'all' },
28
28
  limit: { type: 'number', defaultValue: 10 },
29
29
  },
30
30
  projections: {
@@ -42,7 +42,7 @@ List the [filters](filters.md) an operation reads; `run()` receives one flat
42
42
  field per filter, and you derive SQL parameters inside it:
43
43
 
44
44
  ```ts
45
- import { choiceFilter, parseCount } from '@altertable/data-app/contract';
45
+ import { choiceFilter } from '@altertable/data-app/contract';
46
46
 
47
47
  // ... dataApp
48
48
  const groupName = choiceFilter({
@@ -58,14 +58,12 @@ const groupName = choiceFilter({
58
58
  const operations = dataApp.defineOperations({
59
59
  sampleCountsByGroup: dataApp.defineOperation({
60
60
  filters: { groupName },
61
- policy: { maxQueryRows: 10, maxDurationMs: 15000 },
61
+ policy: { maxQueryRows: 10 },
62
62
  async run({ query }, { groupName }) {
63
- const result = await query('sampleCountsByGroup', {
64
- groupName: groupName === 'all' ? '' : groupName,
65
- });
66
- return result.rows.map(row => ({
63
+ const { rows } = await query('sampleCountsByGroup', { groupName });
64
+ return rows.map(row => ({
67
65
  groupName: row.group_name,
68
- sampleCount: parseCount(row.sample_count),
66
+ sampleCount: row.sample_count,
69
67
  }));
70
68
  },
71
69
  }),
@@ -82,18 +80,21 @@ returned type. HTTP results must be JSON-serializable.
82
80
 
83
81
  Host `queryParams` supplies protected parameters that callers cannot override.
84
82
  Other values come from `query()` arguments or defaults. The host/backend enforces
85
- data access and limits. Operation policies must set `maxQueryRows` to a positive
86
- integer no greater than 10,000. The shared SQL host handler also rejects requests
87
- for more than 10,000 rows.
83
+ data access and limits. Each operation's `policy` sets `maxQueryRows` to a positive
84
+ integer no greater than 10,000, which also limits each `query()` unless it passes
85
+ its own `limit`. The shared SQL host handler also rejects requests for more than
86
+ 10,000 rows.
88
87
 
89
88
  ### Declare query projections
90
89
 
91
90
  Declare every returned SQL alias with `{ type, nullable? }` and keep its exact
92
91
  casing. Infer nullability from the schema and SQL, not sampled rows. Update
93
- projections when changing SQL. `query()` converts cells to declared types;
94
- return SQL text and declare `string` when exact numeric precision matters.
92
+ projections when changing SQL. `query()` converts cells to declared types, so a
93
+ `number` projection is already a number; return SQL text and declare `string`
94
+ when exact numeric precision matters. Use `parseCount()` only to reject negative
95
+ or fractional counts.
95
96
 
96
- Use `operations.sampleCountsByGroup.queryNames` for context and evidence.
97
+ Use `dataApp.queryNames` for context and evidence.
97
98
 
98
99
  ### Bind date ranges
99
100
 
@@ -1,19 +1,16 @@
1
1
  # Data context and evidence
2
2
 
3
- Keep the selected starter's operations and context. Build one context from every
4
- operation's `queryNames` and share it across the app's views. Reference only
5
- queries the app executes.
3
+ Keep the selected starter's operations and context. Build one context from
4
+ `dataApp.queryNames` and share it across the app's views. Each glossary entry
5
+ and dataset cites the queries that support it.
6
6
 
7
7
  ## Bind evidence
8
8
 
9
9
  ```tsx
10
10
  import { createDataContext } from '@altertable/data-app-react';
11
11
 
12
- // ... operations
13
- const queryNames = {
14
- ...operations.sampleCountsByGroup.queryNames,
15
- ...operations.sampleTotal.queryNames,
16
- };
12
+ // ... dataApp
13
+ const { queryNames } = dataApp;
17
14
  const sampleDataContext = createDataContext(queryNames)({
18
15
  description: 'Sample counts for the selected groups.',
19
16
  glossary: {
@@ -58,8 +55,8 @@ const identifiers = defineDataIdentifiers({
58
55
  });
59
56
  const { DataIdentifier } = identifiers;
60
57
 
61
- // ... queryNames for the inspected source
62
- const eventDataContext = createDataContext(queryNames)({
58
+ // ... dataApp for the inspected source
59
+ const eventDataContext = createDataContext(dataApp.queryNames)({
63
60
  identifiers: identifiers.definitions,
64
61
  description: (
65
62
  <>
package/docs/embed.md CHANGED
@@ -86,6 +86,25 @@ Host Back/Forward events publish opaque host state through the bridge. The app's
86
86
  optional navigation adapter interprets search/hash and synchronizes controls;
87
87
  opaque apps keep that state in memory rather than modifying their document URL.
88
88
 
89
+ ## Focused widget states
90
+
91
+ Open `?_widget=event-log` to render the visualization declared with
92
+ `view.content(..., { id: 'event-log' })`. For hosted bundles, pass the query
93
+ through the navigation adapter. The query also accepts the selected view’s
94
+ filters and a theme override (`_theme=light` or `_theme=dark`).
95
+
96
+ Use a borderless, full-width, [content-sized iframe](#content-sizing) and
97
+ set the capture viewport to the desired layout width. Subscribe to
98
+ `onWidgetCaptureChange` on `attachDataAppBridge()` or `<DataAppBridge>`.
99
+ Capture the iframe or its wrapper when the active frame reports `ready` for
100
+ the requested `widgetId`. The callback reports the fitted `height` in CSS pixels.
101
+
102
+ Wait through `loading` with a timeout. Clear readiness on `undefined` and
103
+ end the capture attempt on `empty`, `error`, or `invalid-target`.
104
+
105
+ Inside the app document, the focused `<main>` exposes `data-widget-state`
106
+ and, for a valid target, `data-focused-widget`.
107
+
89
108
  ## External links
90
109
 
91
110
  Register the external link route to let apps request HTTPS navigation without
package/docs/filters.md CHANGED
@@ -10,7 +10,7 @@ renders. Import filters from `@altertable/data-app/contract`.
10
10
  This sample-count example shares one fixed group choice across operations:
11
11
 
12
12
  ```tsx
13
- import { choiceFilter, parseCount } from '@altertable/data-app/contract';
13
+ import { choiceFilter } from '@altertable/data-app/contract';
14
14
 
15
15
  // ... dataApp, sampleDataContext, and section contents
16
16
  const groupName = choiceFilter({
@@ -27,14 +27,12 @@ const groupName = choiceFilter({
27
27
  const operations = dataApp.defineOperations({
28
28
  sampleCountsByGroup: dataApp.defineOperation({
29
29
  filters: { groupName },
30
- policy: { maxQueryRows: 10, maxDurationMs: 15000 },
30
+ policy: { maxQueryRows: 10 },
31
31
  async run({ query }, { groupName }) {
32
- const result = await query('sampleCountsByGroup', {
33
- groupName: groupName === 'all' ? '' : groupName,
34
- });
35
- return result.rows.map(row => ({
32
+ const { rows } = await query('sampleCountsByGroup', { groupName });
33
+ return rows.map(row => ({
36
34
  groupName: row.group_name,
37
- sampleCount: parseCount(row.sample_count),
35
+ sampleCount: row.sample_count,
38
36
  }));
39
37
  },
40
38
  }),
@@ -44,7 +42,6 @@ const { defineView } = createDataHooks(operations.createDataClient());
44
42
  const sampleCountsView = defineView({
45
43
  dataContext: sampleDataContext,
46
44
  operation: 'sampleCountsByGroup',
47
- isEmpty: rows => rows.length === 0,
48
45
  emptyFallback: { title: 'No matching groups' },
49
46
  });
50
47
 
@@ -59,6 +56,8 @@ function App() {
59
56
 
60
57
  - Reuse the same constant on every operation that reads it; two filters with one
61
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`.
62
61
  - Omit `filters` for an operation without inputs.
63
62
  - A detail operation that also needs its own fields, such as a record ID, keeps
64
63
  `filters` for the scope and adds `input` and `checks` for those fields only.
@@ -230,7 +229,7 @@ const periodFilter = dateTimeRangeFilter({
230
229
  });
231
230
  const dailyCounts = dataApp.defineOperation({
232
231
  filters: { period: periodFilter, groupName },
233
- policy: { maxQueryRows: 100, maxDurationMs: 15000 },
232
+ policy: { maxQueryRows: 100 },
234
233
  async run({ query }, { period, groupName }) {
235
234
  const current = await query('dailyCounts', {
236
235
  ...queryDateTimeRangeParams(periodFilter, period, 'period').current,
@@ -266,6 +265,5 @@ Clear removes filter predicates and returns dates to defaults, preserving search
266
265
  and display choices. `resetAll()` restores all defaults. Filters apply immediately;
267
266
  use app-owned drafts only when the task needs Apply/Cancel.
268
267
 
269
- Custom control ownership is needed only when generated controls cannot express
270
- the requirement; use `/ui` for that case. Do not reuse reserved inspection,
271
- presentation, or navigation URL keys.
268
+ Filter keys cannot start with `_`: the runtime owns those keys for inspection,
269
+ presentation, navigation, and focused widgets.
@@ -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.
@@ -13,16 +13,20 @@ does not require a particular content structure or presentation story.
13
13
 
14
14
  You can also [convert the local app to a hosted data app](hosted-apps.md#convert-a-local-data-app).
15
15
 
16
- ## Preview the use-case starters
16
+ ## Preview the starters
17
17
 
18
18
  From the SDK repository, run `bun run dev:gallery` with Docker available. It starts
19
19
  and seeds the Altertable mock with fictional sample data.
20
20
 
21
21
  | Starter | Hosted preview | Local preview |
22
22
  | ------- | ------------------------------------------------- | ------------------------ |
23
+ | General | <http://127.0.0.1:27418/starter-data-app> | <http://127.0.0.1:27420> |
23
24
  | Metric | <http://127.0.0.1:27418/starter-metric-data-app> | <http://127.0.0.1:27421> |
24
25
  | Finding | <http://127.0.0.1:27418/starter-finding-data-app> | <http://127.0.0.1:27422> |
25
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
+
26
30
  Copied starters use the normal query connection. Replace their example queries
27
31
  with verified sources in the target lakehouse; the mock and seed belong only to
28
32
  local development. Never create demo objects in a user's lakehouse.
@@ -103,6 +103,8 @@ the session. Resolve system preference in the parent to `'light'` or `'dark'`.
103
103
  Inside an embedded surface, `<DataApp>` hides its header, footer, and page
104
104
  toolbar. See [parent presentation](embed.md#parent-presentation).
105
105
 
106
+ See [focused widget states](embed.md#focused-widget-states) for screenshot setup.
107
+
106
108
  ## Page actions
107
109
 
108
110
  Render the app's page actions in the parent with `onActionsChange`, and run them
package/docs/react.md CHANGED
@@ -17,9 +17,7 @@ The app supplies `dataApp`, `App`, and a `#root` element.
17
17
  Keep the selected starter's mounting and client wiring. The
18
18
  app brief selects the starter and content structure; the available runtime
19
19
  starters are listed in [app authoring](app-authoring.md#use-release-matched-starters).
20
- Use declared views and bound widgets for data-backed content. Use `/ui` for
21
- setup/static screens or a custom component only when bound components cannot
22
- express the requirement.
20
+ Render a setup or static screen with `<DataApp>` without a `view`.
23
21
 
24
22
  Hosts embedding an app use the separate `@altertable/data-app-embed` package;
25
23
  that integration is outside ordinary app authoring.
@@ -5,8 +5,7 @@ callback and optional nonempty `datasets` list. Omit either prop to omit its too
5
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
package/docs/ui.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Direct UI composition
2
2
 
3
- Import from `@altertable/data-app-react/ui` for setup/static screens, custom
4
- controls, or a deliberately custom shell. For data-backed content, prefer declared views
3
+ Import from `@altertable/data-app-react/ui` for charts, custom controls, or a
4
+ deliberately custom shell. For data-backed content, prefer declared views
5
5
  and bound widgets from `@altertable/data-app-react`.
6
6
 
7
- `<DataApp>` here renders a static screen and accepts optional direct CSV data.
8
- Direct widget forms accept local values or rows. `<DataWidget>` supplies a generic
7
+ `<DataApp>` from `@altertable/data-app-react` renders a setup or static screen
8
+ when it has a `dataContext` and no `view`. `<DataWidget>` supplies a generic
9
9
  frame for deliberately custom content. Use `<GettingStarted>` for
10
10
  connection setup. Fetched data belongs to a declared view; avoid inventing
11
11
  request states to populate a shell.
@@ -23,6 +23,25 @@ For framework mounting, `<DataAppProvider app={dataApp}>` supplies app identity,
23
23
  `mountDataApp()` installs styles. For a custom root using `DataAppProvider`, call
24
24
  `injectDataAppStyles()` before mounting; imports do not install styles.
25
25
 
26
+ ## External links
27
+
28
+ Use `<ExternalLink>` for HTTPS destinations in widget content:
29
+
30
+ ```tsx
31
+ import { ExternalLink } from '@altertable/data-app-react';
32
+
33
+ function ReportLink() {
34
+ return (
35
+ <ExternalLink href="https://example.com/report">
36
+ View full report
37
+ </ExternalLink>
38
+ );
39
+ }
40
+ ```
41
+
42
+ For programmatic navigation, import `navigateNewTab`, `navigateNewWindow`, or
43
+ `navigateNewWindowOrTab` from `@altertable/data-app/client`.
44
+
26
45
  ## Tooltips and explanations
27
46
 
28
47
  Use `<Tooltip>` for a short, supplemental description of an already labeled
@@ -185,9 +204,8 @@ conversion windows, and cohort definitions; these components visualize results.
185
204
  - `<JourneyChart>`: full ordered paths with counts and outcomes; preserve repeated
186
205
  events and mark cut-off paths as `truncated`.
187
206
 
188
- See the [complete component examples](https://github.com/altertable-ai/data-app/blob/main/dev/fixtures/gallery-basics.tsx)
189
- for input shapes and composition. Read the exported types and JSDoc for exact
190
- constraints before adapting displayed rows.
207
+ Search [REFERENCE.md](../REFERENCE.md) for `FunnelChartSeries`,
208
+ `RetentionChartPoint`, and `JourneyChartPath` before adapting displayed rows.
191
209
 
192
210
  ### Composed charts
193
211
 
package/docs/views.md CHANGED
@@ -21,7 +21,6 @@ const { defineView } = createDataHooks(client);
21
21
  const sampleCountsView = defineView({
22
22
  dataContext: sampleDataContext,
23
23
  operation: 'sampleCountsByGroup',
24
- isEmpty: rows => rows.length === 0,
25
24
  emptyFallback: { title: 'No matching groups' },
26
25
  });
27
26
  // ... sampleCounts dataset and story callback
@@ -56,7 +55,6 @@ const { defineView } = createDataHooks(client);
56
55
  const sampleCountsView = defineView({
57
56
  dataContext: sampleDataContext,
58
57
  operation: 'sampleCountsByGroup',
59
- isEmpty: rows => rows.length === 0,
60
58
  emptyFallback: { title: 'No matching groups' },
61
59
  });
62
60
  const sampleTotalView = defineView({
@@ -92,8 +90,10 @@ refresh or failure. Use `result.scope` in content and `view.scope(snapshot)` in
92
90
  stories. Let views and bound widgets own request state and loading feedback.
93
91
  Keep static introductions outside loading boundaries.
94
92
 
95
- A measured zero is valid data. Set `isEmpty` and useful `emptyFallback` copy when
96
- a result can be empty; omit both when it never is, such as a total.
93
+ A measured zero is valid data. A view whose operation returns no rows is empty;
94
+ give it useful `emptyFallback` copy. Set `isEmpty` for any other result that can
95
+ be empty, such as a nullable summary, and omit both for one that never is, such
96
+ as a total.
97
97
 
98
98
  ## Detail destinations
99
99
 
@@ -111,16 +111,14 @@ const groupView = defineDetailView({
111
111
  dataContext: sampleDataContext,
112
112
  parseInput: operations.sampleCountsByGroup.input,
113
113
  describeInput: ({ groupName }) => `group ${groupName}`,
114
- isEmpty: rows => rows.length === 0,
115
114
  emptyFallback: { title: 'No matching group' },
116
115
  });
117
116
  const groupCounts = groupView.dataset({
118
117
  name: 'Group counts',
119
- select: rows => rows,
120
118
  rowKey: row => row.groupName,
121
119
  columns: {
122
- groupName: { value: row => row.groupName },
123
- sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
120
+ groupName: {},
121
+ sampleCount: { format: { kind: 'count' } },
124
122
  },
125
123
  evidence: { id: 'group-counts', glossaryIds: ['sampleCount'] },
126
124
  });