@altertable/data-app 0.78.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.
- package/AGENTS.md +3 -0
- package/CONTRIBUTING.md +2 -1
- package/REFERENCE.md +34 -152
- package/dist/chunks/{contract-gu1rDsV0.js → contract-BTG-BUwW.js} +7 -6
- package/dist/chunks/{contract-gu1rDsV0.js.map → contract-BTG-BUwW.js.map} +1 -1
- package/dist/chunks/{data-client-BMdL73Ab.js → data-client-C4Pay-UE.js} +3 -3
- package/dist/chunks/{data-client-BMdL73Ab.js.map → data-client-C4Pay-UE.js.map} +1 -1
- package/dist/chunks/{diagnostics-CX9SsU79.js → diagnostics-BwpM9wGn.js} +2 -2
- package/dist/chunks/{diagnostics-CX9SsU79.js.map → diagnostics-BwpM9wGn.js.map} +1 -1
- package/dist/client/index.js +3 -3
- package/dist/core/config.js +3 -2
- package/dist/core/config.js.map +1 -1
- package/dist/core/contract.js +1 -1
- package/dist/internal.js +2 -2
- package/dist/types/chunks/contract.d.ts +6 -1
- package/dist/types/core/config.d.ts +3 -0
- package/docs/app-authoring.md +160 -76
- package/docs/contract.md +16 -15
- package/docs/data-context.md +7 -10
- package/docs/filters.md +10 -12
- package/docs/formatting-and-appearance.md +2 -5
- package/docs/hosted-apps.md +2 -2
- package/docs/local-data-apps.md +5 -1
- package/docs/react.md +1 -3
- package/docs/stories-and-export.md +1 -2
- package/docs/ui.md +25 -7
- package/docs/views.md +6 -8
- package/docs/widgets.md +7 -8
- package/package.json +1 -1
package/dist/core/contract.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as resolveDateTimeRange, i as parseDateTimeRange, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, t as formatDateTimeBound } from "../chunks/date-time-range-value-D-XfqVTT.js";
|
|
2
|
-
import { A as resolvedDateTimeRangeParams, C as parseCount, D as dateTimeRangePresets, E as dateTimeRangeFilter, G as searchFilter, I as parseBooleanSelection, L as parseNumberSelection, N as booleanFilter, O as queryDateTimeRangeParams, P as numberFilter, S as defineQueryNames, T as parseTrue, U as displayChoice, V as choiceFilter, W as multiChoiceFilter, _ as navigationUpdateRoute, a as annotationDraftRoute, at as parseDimensionSelection, b as connectionCheck, c as annotationSendRoute, d as parseDataAppAnnotationDraft, f as MessageRoutingError, g as defineMessageRoute, h as defineDataOperationRoute, i as resolveExternalLinkTarget, it as dimensionPredicate, j as facetFilter, k as dateTimeRangeSql, l as annotationUpdateRoute, m as dataAppRoutes, n as openExternalLinkRoute, nt as dimensionFilter, o as annotationEditorStateRoute, ot as parseFacetOptions, p as createMessageRouter, r as parseExternalUrl, s as annotationModeRoute, t as DataSourceError, v as registeredQueryRoute, w as parseLabel, x as defineOperation } from "../chunks/contract-
|
|
2
|
+
import { A as resolvedDateTimeRangeParams, C as parseCount, D as dateTimeRangePresets, E as dateTimeRangeFilter, G as searchFilter, I as parseBooleanSelection, L as parseNumberSelection, N as booleanFilter, O as queryDateTimeRangeParams, P as numberFilter, S as defineQueryNames, T as parseTrue, U as displayChoice, V as choiceFilter, W as multiChoiceFilter, _ as navigationUpdateRoute, a as annotationDraftRoute, at as parseDimensionSelection, b as connectionCheck, c as annotationSendRoute, d as parseDataAppAnnotationDraft, f as MessageRoutingError, g as defineMessageRoute, h as defineDataOperationRoute, i as resolveExternalLinkTarget, it as dimensionPredicate, j as facetFilter, k as dateTimeRangeSql, l as annotationUpdateRoute, m as dataAppRoutes, n as openExternalLinkRoute, nt as dimensionFilter, o as annotationEditorStateRoute, ot as parseFacetOptions, p as createMessageRouter, r as parseExternalUrl, s as annotationModeRoute, t as DataSourceError, v as registeredQueryRoute, w as parseLabel, x as defineOperation } from "../chunks/contract-BTG-BUwW.js";
|
|
3
3
|
export { DataSourceError, MessageRoutingError, annotationDraftRoute, annotationEditorStateRoute, annotationModeRoute, annotationSendRoute, annotationUpdateRoute, booleanFilter, choiceFilter, connectionCheck, createMessageRouter, dataAppRoutes, dateTimeRangeFilter, dateTimeRangePresets, dateTimeRangeSql, defineDataOperationRoute, defineMessageRoute, defineOperation, defineQueryNames, dimensionFilter, dimensionPredicate, displayChoice, facetFilter, formatDateTimeBound, formatDateTimeRange, multiChoiceFilter, navigationUpdateRoute, numberFilter, openExternalLinkRoute, parseBooleanSelection, parseCount, parseDataAppAnnotationDraft, parseDateTimeBound, parseDateTimeRange, parseDimensionSelection, parseExternalUrl, parseFacetOptions, parseLabel, parseNumberSelection, parseTrue, queryDateTimeRangeParams, registeredQueryRoute, resolveDateTimeRange, resolveExternalLinkTarget, resolvedDateTimeRangeParams, searchFilter, serializeDateTimeRange };
|
package/dist/internal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as resolveDateTimeRange, i as parseDateTimeRange, l as invariant, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, s as fixedUnitMilliseconds, t as formatDateTimeBound } from "./chunks/date-time-range-value-D-XfqVTT.js";
|
|
2
|
-
import { B as resolveFilterInput, D as dateTimeRangePresets, E as dateTimeRangeFilter, F as numberOperatorLabels, G as searchFilter, H as defineAppFilters, K as validateChoiceOptions, M as facetSource, Q as REGISTERED_QUERY_ID_PATTERN, R as combineOperationFilters, U as displayChoice, V as choiceFilter, W as multiChoiceFilter, Y as dimensionSource, Z as MAX_QUERY_ROWS, et as unsupportedParameterReference, rt as dimensionMemberKey, st as KEY_SEPARATOR, tt as createDimensionFilter, z as dateFilterName } from "./chunks/contract-
|
|
3
|
-
import { _ as toDataOperationFailure, a as localFrameBridge, c as isDataAppPresentation, d as PARENT_PARAM, f as REQUEST_TIMEOUT_MS, h as randomUuid, l as createBridgeEndpoint, m as parseAppDiagnosticReport, p as validId, u as MAX_PENDING } from "./chunks/diagnostics-
|
|
2
|
+
import { B as resolveFilterInput, D as dateTimeRangePresets, E as dateTimeRangeFilter, F as numberOperatorLabels, G as searchFilter, H as defineAppFilters, K as validateChoiceOptions, M as facetSource, Q as REGISTERED_QUERY_ID_PATTERN, R as combineOperationFilters, U as displayChoice, V as choiceFilter, W as multiChoiceFilter, Y as dimensionSource, Z as MAX_QUERY_ROWS, et as unsupportedParameterReference, rt as dimensionMemberKey, st as KEY_SEPARATOR, tt as createDimensionFilter, z as dateFilterName } from "./chunks/contract-BTG-BUwW.js";
|
|
3
|
+
import { _ as toDataOperationFailure, a as localFrameBridge, c as isDataAppPresentation, d as PARENT_PARAM, f as REQUEST_TIMEOUT_MS, h as randomUuid, l as createBridgeEndpoint, m as parseAppDiagnosticReport, p as validId, u as MAX_PENDING } from "./chunks/diagnostics-BwpM9wGn.js";
|
|
4
4
|
//#region src/client/download.ts
|
|
5
5
|
/** Start a browser download and release its temporary anchor and object URL. */
|
|
6
6
|
function downloadBlob({ filename, blob }) {
|
|
@@ -625,7 +625,12 @@ type RegisteredQuery<Queries extends QueryDefinitions> = <Name extends keyof Que
|
|
|
625
625
|
type OperationRun<Input, Output, Queries extends QueryDefinitions> = (context: Pick<OperationContext, 'signal'> & {
|
|
626
626
|
query: RegisteredQuery<NoInfer<Queries>>;
|
|
627
627
|
}, input: Input) => Promise<Output>;
|
|
628
|
-
type
|
|
628
|
+
type ResolvedOperationPolicy = DataOperation<unknown, unknown>['policy'];
|
|
629
|
+
/** Limits for one operation. `maxQueryRows` caps each query. */
|
|
630
|
+
type OperationPolicy = Omit<ResolvedOperationPolicy, 'maxDurationMs'> & {
|
|
631
|
+
/** @default 15000 */
|
|
632
|
+
maxDurationMs?: number;
|
|
633
|
+
};
|
|
629
634
|
/** An operation that reads app filters. Its input has one field per filter, validated by
|
|
630
635
|
* the filters themselves; views derive their filters, scope, and period from it. */
|
|
631
636
|
type FilterOperationDefinition<Filters extends FilterCollection, Output, Queries extends QueryDefinitions> = {
|
|
@@ -29,6 +29,9 @@ export type DataAppOperationRegistry<Operations extends DataOperations> = Operat
|
|
|
29
29
|
/** An app declaration with operations bound to its query registry. */
|
|
30
30
|
export type DataAppDefinition<Queries extends QueryDefinitions = QueryDefinitions> = Readonly<Omit<DataAppConfig<Queries>, 'queries'>> & {
|
|
31
31
|
readonly queries: QuerySnapshot<Queries>;
|
|
32
|
+
/** Every registered query name, keyed by itself. Pass it to `createDataContext()`,
|
|
33
|
+
* then cite the queries behind each glossary entry. */
|
|
34
|
+
readonly queryNames: { readonly [Name in keyof Queries & string]: Name; };
|
|
32
35
|
defineDimension<const Type extends 'string' | 'number'>(config: DimensionSourceConfig<Type> & {
|
|
33
36
|
source: {
|
|
34
37
|
query: DimensionSourceQueryName<Queries, NoInfer<Type>>;
|
package/docs/app-authoring.md
CHANGED
|
@@ -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.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Hosted apps stay in one file with public package imports
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
|
195
|
+
Search [REFERENCE.md](../REFERENCE.md) for the exact export or method first:
|
|
116
196
|
|
|
117
197
|
```sh
|
|
118
|
-
rg '
|
|
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
|
|
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
|
|
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
|
|
61
|
+
policy: { maxQueryRows: 10 },
|
|
62
62
|
async run({ query }, { groupName }) {
|
|
63
|
-
const
|
|
64
|
-
|
|
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:
|
|
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.
|
|
86
|
-
integer no greater than 10,000
|
|
87
|
-
for more than
|
|
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`
|
|
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 `
|
|
97
|
+
Use `dataApp.queryNames` for context and evidence.
|
|
97
98
|
|
|
98
99
|
### Bind date ranges
|
|
99
100
|
|
package/docs/data-context.md
CHANGED
|
@@ -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
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
// ...
|
|
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
|
-
// ...
|
|
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/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
|
|
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
|
|
30
|
+
policy: { maxQueryRows: 10 },
|
|
31
31
|
async run({ query }, { groupName }) {
|
|
32
|
-
const
|
|
33
|
-
|
|
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:
|
|
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
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
presentation, or navigation URL keys.
|
|
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: {
|
|
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
|
```
|
package/docs/hosted-apps.md
CHANGED
|
@@ -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
|
|
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.
|
package/docs/local-data-apps.md
CHANGED
|
@@ -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
|
|
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.
|
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
|
-
|
|
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
|
|
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
|
|
4
|
-
|
|
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>`
|
|
8
|
-
|
|
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
|
-
|
|
189
|
-
|
|
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
|
|