@altertable/data-app 0.76.0 → 0.78.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.
- package/CONTRIBUTING.md +3 -0
- package/REFERENCE.md +392 -276
- package/dist/chunks/contract-gu1rDsV0.js +1588 -0
- package/dist/chunks/contract-gu1rDsV0.js.map +1 -0
- package/dist/chunks/data-client-BMdL73Ab.js +122 -0
- package/dist/chunks/data-client-BMdL73Ab.js.map +1 -0
- package/dist/chunks/{date-time-range-value-TE8KCsfV.js → date-time-range-value-D-XfqVTT.js} +28 -31
- package/dist/chunks/date-time-range-value-D-XfqVTT.js.map +1 -0
- package/dist/chunks/{diagnostics-DhCqGklq.js → diagnostics-CX9SsU79.js} +240 -63
- package/dist/chunks/diagnostics-CX9SsU79.js.map +1 -0
- package/dist/chunks/record-Cr4Uk1K3.js +9 -0
- package/dist/chunks/record-Cr4Uk1K3.js.map +1 -0
- package/dist/client/index.js +4 -86
- package/dist/client/index.js.map +1 -1
- package/dist/core/appearance.js +3 -5
- package/dist/core/appearance.js.map +1 -1
- package/dist/core/config.js +11 -3
- package/dist/core/config.js.map +1 -1
- package/dist/core/contract.js +3 -4
- package/dist/core/format.js +1 -1
- package/dist/internal.js +58 -124
- package/dist/internal.js.map +1 -1
- package/dist/types/chunks/contract.d.ts +592 -308
- package/dist/types/chunks/data-client.d.ts +46 -0
- package/dist/types/chunks/date-time-range-value.d.ts +28 -2
- package/dist/types/chunks/index.d.ts +65 -53
- package/dist/types/client/index.d.ts +4 -3
- package/dist/types/core/config.d.ts +16 -6
- package/dist/types/core/contract.d.ts +3 -5
- package/dist/types/core/format.d.ts +1 -2
- package/dist/types/index.d.ts +4 -4
- package/dist/types/internal.d.ts +26 -7
- package/docs/app-authoring.md +23 -14
- package/docs/client.md +14 -48
- package/docs/contract.md +58 -56
- package/docs/data-context.md +13 -6
- package/docs/diagnostics.md +16 -23
- package/docs/embed.md +60 -25
- package/docs/filters.md +271 -0
- package/docs/hosted-apps.md +11 -10
- package/docs/layout.md +45 -18
- package/docs/local-data-apps.md +5 -6
- package/docs/react-embed.md +44 -2
- package/docs/react.md +1 -2
- package/docs/server-bun.md +8 -5
- package/docs/stories-and-export.md +23 -14
- package/docs/styling.md +2 -1
- package/docs/ui.md +18 -8
- package/docs/views.md +63 -26
- package/docs/widgets.md +40 -16
- package/docs/worker.md +1 -1
- package/package.json +1 -5
- package/dist/chunks/contract-DsyRYgN_.js +0 -626
- package/dist/chunks/contract-DsyRYgN_.js.map +0 -1
- package/dist/chunks/contract-kNFYPHRK.js +0 -713
- package/dist/chunks/contract-kNFYPHRK.js.map +0 -1
- package/dist/chunks/date-time-range-value-TE8KCsfV.js.map +0 -1
- package/dist/chunks/diagnostics-DhCqGklq.js.map +0 -1
- package/dist/chunks/operation-7tiT4cpJ.js +0 -134
- package/dist/chunks/operation-7tiT4cpJ.js.map +0 -1
- package/dist/chunks/request-body-H1qPmmTN.js +0 -50
- package/dist/chunks/request-body-H1qPmmTN.js.map +0 -1
- package/dist/server/index.js +0 -90
- package/dist/server/index.js.map +0 -1
- package/dist/types/chunks/contract2.d.ts +0 -207
- package/dist/types/chunks/date-time-range.d.ts +0 -29
- package/dist/types/server/index.d.ts +0 -17
- package/docs/server.md +0 -41
- package/docs/variables.md +0 -280
package/docs/views.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Views and displayed results
|
|
2
2
|
|
|
3
|
-
Keep the starter's client and hooks.
|
|
4
|
-
when
|
|
5
|
-
|
|
3
|
+
Keep the starter's client and hooks. Define one view per operation. Widgets may
|
|
4
|
+
share a view when they show the same rows or related metrics from one summary.
|
|
5
|
+
The examples below use sample-count operations and bindings to illustrate the
|
|
6
|
+
contracts; keep the selected starter's domain names when adapting its source.
|
|
6
7
|
|
|
7
8
|
## Bind a view
|
|
8
9
|
|
|
@@ -11,25 +12,15 @@ import {
|
|
|
11
12
|
createDataHooks,
|
|
12
13
|
DataApp,
|
|
13
14
|
DataSection,
|
|
14
|
-
searchVariable,
|
|
15
15
|
TableWidget,
|
|
16
16
|
} from '@altertable/data-app-react';
|
|
17
17
|
|
|
18
18
|
// ... client, operations, and sampleDataContext
|
|
19
|
-
const {
|
|
19
|
+
const { defineView } = createDataHooks(client);
|
|
20
20
|
|
|
21
|
-
const sampleCountsView =
|
|
21
|
+
const sampleCountsView = defineView({
|
|
22
22
|
dataContext: sampleDataContext,
|
|
23
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
24
|
isEmpty: rows => rows.length === 0,
|
|
34
25
|
emptyFallback: { title: 'No matching groups' },
|
|
35
26
|
});
|
|
@@ -47,10 +38,51 @@ function App() {
|
|
|
47
38
|
}
|
|
48
39
|
```
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
The view's filters, reporting period, metric comparisons, and scope come from
|
|
42
|
+
the [filters](filters.md) its operation declares. Set `describeInput` only when
|
|
43
|
+
the derived scope needs specific copy.
|
|
44
|
+
|
|
45
|
+
## Give each independent result its own view
|
|
46
|
+
|
|
47
|
+
In this example, the total and group counts are independent results with separate
|
|
48
|
+
operations and views. `<DataApp view>` loads with the page; other views load when
|
|
49
|
+
their sections near the viewport unless listed in `summaryViews`. Both operations
|
|
50
|
+
read the same `groupName` filter, and `<DataApp>` renders its control once:
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
// ... client, operations, sampleDataContext, and section contents
|
|
54
|
+
const { defineView } = createDataHooks(client);
|
|
55
|
+
|
|
56
|
+
const sampleCountsView = defineView({
|
|
57
|
+
dataContext: sampleDataContext,
|
|
58
|
+
operation: 'sampleCountsByGroup',
|
|
59
|
+
isEmpty: rows => rows.length === 0,
|
|
60
|
+
emptyFallback: { title: 'No matching groups' },
|
|
61
|
+
});
|
|
62
|
+
const sampleTotalView = defineView({
|
|
63
|
+
dataContext: sampleDataContext,
|
|
64
|
+
operation: 'sampleTotal',
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function App() {
|
|
68
|
+
return (
|
|
69
|
+
<DataApp view={sampleCountsView}>
|
|
70
|
+
<Stack>
|
|
71
|
+
<DataSection content={totalContent} />
|
|
72
|
+
<DataSection content={countsContent} />
|
|
73
|
+
</Stack>
|
|
74
|
+
</DataApp>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Define every view rendered inside one `<DataApp>` from the same
|
|
80
|
+
`createDataHooks()` result; its client owns their filter controls.
|
|
81
|
+
|
|
82
|
+
Share one [data context](data-context.md) across the app's views. Group widgets
|
|
83
|
+
in one view when they show the same result, such as a chart and the table
|
|
84
|
+
of its rows, or related metrics derived from one summary. A story or export that
|
|
85
|
+
reads other views lists them in [`summaryViews`](stories-and-export.md).
|
|
54
86
|
|
|
55
87
|
## Preserve displayed results
|
|
56
88
|
|
|
@@ -60,8 +92,8 @@ refresh or failure. Use `result.scope` in content and `view.scope(snapshot)` in
|
|
|
60
92
|
stories. Let views and bound widgets own request state and loading feedback.
|
|
61
93
|
Keep static introductions outside loading boundaries.
|
|
62
94
|
|
|
63
|
-
A measured zero is valid data. Set `isEmpty`
|
|
64
|
-
|
|
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.
|
|
65
97
|
|
|
66
98
|
## Detail destinations
|
|
67
99
|
|
|
@@ -70,9 +102,8 @@ The destination owns its input parser, operation, datasets, context, and content
|
|
|
70
102
|
Pass its content to `<DataApp details={[groupDetail]}>`:
|
|
71
103
|
|
|
72
104
|
```tsx
|
|
73
|
-
// ...
|
|
74
|
-
|
|
75
|
-
|
|
105
|
+
// ... operations, sampleDataContext, main view, datasets, and story
|
|
106
|
+
// ... defineDetailView from the main view's createDataHooks() result
|
|
76
107
|
const groupView = defineDetailView({
|
|
77
108
|
id: 'group',
|
|
78
109
|
title: 'Group counts',
|
|
@@ -111,8 +142,14 @@ function App() {
|
|
|
111
142
|
}
|
|
112
143
|
```
|
|
113
144
|
|
|
114
|
-
|
|
115
|
-
|
|
145
|
+
- The destination's operation lists the displayed filters it reads in
|
|
146
|
+
`filters` and parses only its own fields, such as a record ID, with `input`.
|
|
147
|
+
- An action or `metric.records()` returns those own fields and any filter it
|
|
148
|
+
narrows, such as the clicked group; the other filters carry over.
|
|
149
|
+
- Pass serializable IDs, never records or credentials. `parseInput` can reuse
|
|
150
|
+
the operation's `input`.
|
|
151
|
+
- Detail content receives `result.scope`; `describeInput` defaults to the
|
|
152
|
+
filters' description.
|
|
116
153
|
|
|
117
154
|
### Contributing metric records
|
|
118
155
|
|
package/docs/widgets.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Choose a widget
|
|
4
4
|
|
|
5
|
-
Metrics, tables, and visualizations from `@altertable/data-app-react` consume view
|
|
5
|
+
Metrics, tables, and visualizations from `@altertable/data-app-react` consume a view's datasets or metrics and a source. For static displays, use
|
|
6
6
|
[direct UI composition](ui.md).
|
|
7
7
|
Manage requests in [views](views.md).
|
|
8
8
|
|
|
@@ -24,7 +24,7 @@ only when changing spans or shell composition.
|
|
|
24
24
|
Choose the component by the user's question. Compose dataset visuals inside
|
|
25
25
|
`<VisualizationWidget>`; use `<MetricWidget>` for a headline value. Built-in
|
|
26
26
|
charts come from `@altertable/data-app-react/ui`; `<Ranking>`, `<Breakdown>`, and `<Comparison>`
|
|
27
|
-
|
|
27
|
+
come from the root `@altertable/data-app-react` entry.
|
|
28
28
|
|
|
29
29
|
| Question | Component and constraint |
|
|
30
30
|
| -------------------------------- | ------------------------------------------------------------------------------- |
|
|
@@ -48,16 +48,17 @@ values available in a table when they matter.
|
|
|
48
48
|
|
|
49
49
|
## Declare datasets and metrics
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
`@altertable/data-app-react/ui`.
|
|
53
|
-
Bind reusable selections to the view. Declare evidence references directly;
|
|
51
|
+
The sample-count example below uses the views from [views](views.md).
|
|
52
|
+
Use `<BarChart>` from `@altertable/data-app-react/ui`.
|
|
53
|
+
Bind reusable selections to the view whose operation returns them. Declare evidence references directly;
|
|
54
54
|
the view validates them against its own context. A dataset's columns supply both formatted
|
|
55
55
|
table cells and raw CSV values. Widgets derive their readings, evidence, and empty fallback from the binding.
|
|
56
56
|
Declare at least one dataset column. Metric selectors may return `previous`
|
|
57
|
-
only
|
|
57
|
+
only when the view's operation reads a `dateTimeRangeFilter()` with
|
|
58
|
+
`comparison`.
|
|
58
59
|
|
|
59
60
|
```tsx
|
|
60
|
-
// ... sampleCountsView and imports
|
|
61
|
+
// ... sampleCountsView, sampleTotalView, and imports
|
|
61
62
|
const sampleCounts = sampleCountsView.dataset({
|
|
62
63
|
name: 'Sample counts',
|
|
63
64
|
select: rows => rows,
|
|
@@ -68,18 +69,21 @@ const sampleCounts = sampleCountsView.dataset({
|
|
|
68
69
|
sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
|
|
69
70
|
},
|
|
70
71
|
});
|
|
71
|
-
const totalSamples =
|
|
72
|
+
const totalSamples = sampleTotalView.metric(
|
|
72
73
|
{
|
|
73
74
|
id: 'total-samples',
|
|
74
75
|
glossaryId: 'sampleCount',
|
|
75
76
|
label: 'Total samples',
|
|
76
77
|
format: { kind: 'count', compact: true },
|
|
77
78
|
},
|
|
78
|
-
|
|
79
|
+
total => ({ current: total.sampleCount })
|
|
79
80
|
);
|
|
80
|
-
const
|
|
81
|
+
const totalContent = sampleTotalView.content(result => (
|
|
82
|
+
<MetricWidget metric={totalSamples} source={result} />
|
|
83
|
+
));
|
|
84
|
+
// The table and chart are two representations of the same rows.
|
|
85
|
+
const countsContent = sampleCountsView.content(result => (
|
|
81
86
|
<Grid columns={2}>
|
|
82
|
-
<MetricWidget metric={totalSamples} source={result} />
|
|
83
87
|
<TableWidget dataset={sampleCounts} source={result} />
|
|
84
88
|
<VisualizationWidget dataset={sampleCounts} source={result}>
|
|
85
89
|
{rows => (
|
|
@@ -99,10 +103,12 @@ const sampleContent = sampleCountsView.content(result => (
|
|
|
99
103
|
));
|
|
100
104
|
```
|
|
101
105
|
|
|
106
|
+
Render each content in its own `<DataSection>`.
|
|
107
|
+
|
|
102
108
|
Column keys supply IDs and default labels; set `label` for a different header.
|
|
103
109
|
Keep row keys stable and unique. Custom cells use `format: row => ...`; CSV uses
|
|
104
|
-
the raw `value` accessor. Metric comparisons require
|
|
105
|
-
Reuse bindings in stories with
|
|
110
|
+
the raw `value` accessor. Metric comparisons require that reporting period.
|
|
111
|
+
Reuse bindings in stories with the snapshot of the view that owns them.
|
|
106
112
|
|
|
107
113
|
Tables search and paginate only supplied rows. Use query-backed pagination with a
|
|
108
114
|
stable sort and total `count` for larger datasets. Provide useful `emptyFallback`
|
|
@@ -143,8 +149,26 @@ express the requirement; see [direct UI composition](ui.md).
|
|
|
143
149
|
|
|
144
150
|
## Exploration actions
|
|
145
151
|
|
|
146
|
-
Declare actions on their dataset or metric and pass them to its widget.
|
|
147
|
-
|
|
152
|
+
Declare actions on their dataset or metric and pass them to its widget. A detail
|
|
153
|
+
mapping receives the row and the displayed operation input. It returns the
|
|
154
|
+
destination's own fields and any filter it narrows, such as the clicked group;
|
|
155
|
+
the other filters the destination's operation reads carry over from the
|
|
156
|
+
displayed scope.
|
|
157
|
+
Narrow a dimension filter to the clicked member with an include selection, and
|
|
158
|
+
use `when` to offer an action only on the rows it applies to:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
// ... breakdown rows with { kind, id }, and an ordersView reading { country }
|
|
162
|
+
action.detail({
|
|
163
|
+
label: 'View orders',
|
|
164
|
+
target: ordersView,
|
|
165
|
+
when: row => row.kind === 'country',
|
|
166
|
+
input: row => ({
|
|
167
|
+
country: { kind: 'include', members: [{ kind: 'value', value: row.id }] },
|
|
168
|
+
}),
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
148
172
|
Both `children` and alternate-view `render` callbacks receive the displayed rows
|
|
149
173
|
and the same action resolver.
|
|
150
174
|
|
|
@@ -191,7 +215,7 @@ metric actions use `metric.actions()` and `<MetricWidget>`. Actions must belong
|
|
|
191
215
|
to the binding rendered by the widget. Metric mappings receive `undefined` for
|
|
192
216
|
the row and displayed input as their second argument.
|
|
193
217
|
|
|
194
|
-
`view.filter()` targets
|
|
218
|
+
`view.filter()` targets filters, not display choices. An optional `breakdown` explicitly updates
|
|
195
219
|
one chart's display choice in the same history entry. Filters preserve unrelated selections. Declare chart breakdown choices
|
|
196
220
|
independently of scope filters.
|
|
197
221
|
|
package/docs/worker.md
CHANGED
|
@@ -36,7 +36,7 @@ Exact entries must be bare HTTP(S) origins. Keep an exact origin first for the
|
|
|
36
36
|
default parent.
|
|
37
37
|
|
|
38
38
|
The Worker sets CSP and trusted frame ancestors. Data queries use the
|
|
39
|
-
[host's
|
|
39
|
+
[host's registered query route](embed.md#registered-query-route); the Worker does not
|
|
40
40
|
execute queries.
|
|
41
41
|
|
|
42
42
|
For file-based deployment tools such as Terraform, copy the resolved asset
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altertable/data-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.0",
|
|
4
4
|
"description": "Portable definitions, contracts, formatting, browser clients, and request handlers for Altertable data apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"altertable",
|
|
@@ -70,10 +70,6 @@
|
|
|
70
70
|
"types": "./dist/types/client/index.d.ts",
|
|
71
71
|
"import": "./dist/client/index.js"
|
|
72
72
|
},
|
|
73
|
-
"./server": {
|
|
74
|
-
"types": "./dist/types/server/index.d.ts",
|
|
75
|
-
"import": "./dist/server/index.js"
|
|
76
|
-
},
|
|
77
73
|
"./internal": {
|
|
78
74
|
"types": "./dist/types/internal.d.ts",
|
|
79
75
|
"import": "./dist/internal.js"
|