@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.
- package/AGENTS.md +5 -61
- package/CONTRIBUTING.md +93 -180
- package/README.md +3 -4
- package/REFERENCE.md +30 -345
- package/dist/chunks/contract-BeLPJwlO.js +558 -0
- package/dist/chunks/contract-BeLPJwlO.js.map +1 -0
- package/dist/chunks/contract-Di8SP74I.js +462 -0
- package/dist/chunks/contract-Di8SP74I.js.map +1 -0
- package/dist/chunks/format-BdFlv_xa.js +148 -0
- package/dist/chunks/format-BdFlv_xa.js.map +1 -0
- package/dist/chunks/iframe-C3uCZEXh.js +809 -0
- package/dist/chunks/iframe-C3uCZEXh.js.map +1 -0
- package/dist/chunks/operation-CBxhjNhK.js +131 -0
- package/dist/chunks/operation-CBxhjNhK.js.map +1 -0
- package/dist/chunks/request-body-H1qPmmTN.js +50 -0
- package/dist/chunks/request-body-H1qPmmTN.js.map +1 -0
- package/dist/client/index.js +253 -285
- package/dist/client/index.js.map +1 -13
- package/dist/core/appearance.js +171 -162
- package/dist/core/appearance.js.map +1 -10
- package/dist/core/config.js +49 -11
- package/dist/core/config.js.map +1 -9
- package/dist/core/contract.js +3 -73
- package/dist/core/format.js +1 -26
- package/dist/index.js +1 -12
- package/dist/internal.js +352 -397
- package/dist/internal.js.map +1 -15
- package/dist/server/index.js +85 -97
- package/dist/server/index.js.map +1 -10
- package/dist/types/chunks/appearance.d.ts +45 -0
- package/dist/types/chunks/contract.d.ts +720 -0
- package/dist/types/chunks/index.d.ts +189 -0
- package/dist/types/client/index.d.ts +3 -13
- package/dist/types/core/appearance.d.ts +2 -42
- package/dist/types/core/config.d.ts +36 -39
- package/dist/types/core/contract.d.ts +2 -114
- package/dist/types/core/format.d.ts +44 -17
- package/dist/types/index.d.ts +3 -3
- package/dist/types/internal.d.ts +312 -22
- package/dist/types/server/index.d.ts +15 -4
- package/docs/app-authoring.md +72 -128
- package/docs/client.md +29 -63
- package/docs/composition.md +44 -75
- package/docs/contract.md +60 -100
- package/docs/data-context.md +35 -61
- package/docs/embed.md +83 -55
- package/docs/formatting-and-appearance.md +17 -38
- package/docs/hosted-apps.md +7 -14
- package/docs/layout.md +30 -47
- package/docs/local-data-apps.md +7 -7
- package/docs/react-embed.md +20 -26
- package/docs/react.md +10 -27
- package/docs/server-bun.md +2 -27
- package/docs/server.md +6 -12
- package/docs/stories-and-export.md +38 -40
- package/docs/styling.md +14 -22
- package/docs/ui-quality.md +5 -5
- package/docs/ui.md +68 -70
- package/docs/variables.md +142 -254
- package/docs/views.md +85 -116
- package/docs/widgets.md +100 -153
- package/docs/worker.md +15 -27
- package/package.json +3 -2
- package/dist/chunks/index-5a27erdg.js +0 -54
- package/dist/chunks/index-5a27erdg.js.map +0 -10
- package/dist/chunks/index-9yxr7nmm.js +0 -742
- package/dist/chunks/index-9yxr7nmm.js.map +0 -17
- package/dist/chunks/index-j5q5n3ra.js +0 -151
- package/dist/chunks/index-j5q5n3ra.js.map +0 -10
- package/dist/chunks/index-q75zm3a7.js +0 -153
- package/dist/chunks/index-q75zm3a7.js.map +0 -11
- package/dist/chunks/index-vhaec7m5.js +0 -30
- package/dist/chunks/index-vhaec7m5.js.map +0 -10
- package/dist/chunks/index-zp78caex.js +0 -1047
- package/dist/chunks/index-zp78caex.js.map +0 -19
- package/dist/core/contract.js.map +0 -9
- package/dist/core/format.js.map +0 -9
- package/dist/index.js.map +0 -9
- package/dist/types/client/annotations.d.ts +0 -27
- package/dist/types/client/data-client.d.ts +0 -43
- package/dist/types/client/download.d.ts +0 -5
- package/dist/types/client/iframe.d.ts +0 -59
- package/dist/types/client/location.d.ts +0 -13
- package/dist/types/client/logger.d.ts +0 -14
- package/dist/types/client/messages.d.ts +0 -7
- package/dist/types/client/navigation.d.ts +0 -15
- package/dist/types/client/transport.d.ts +0 -15
- package/dist/types/core/annotations.d.ts +0 -99
- package/dist/types/core/bridge-endpoint.d.ts +0 -21
- package/dist/types/core/bridge.d.ts +0 -172
- package/dist/types/core/data-view.d.ts +0 -46
- package/dist/types/core/date-format.d.ts +0 -24
- package/dist/types/core/date-range.d.ts +0 -20
- package/dist/types/core/dimension-source.d.ts +0 -64
- package/dist/types/core/dimension.d.ts +0 -71
- package/dist/types/core/facets.d.ts +0 -13
- package/dist/types/core/filters.d.ts +0 -45
- package/dist/types/core/invariant.d.ts +0 -2
- package/dist/types/core/keys.d.ts +0 -2
- package/dist/types/core/logger.d.ts +0 -12
- package/dist/types/core/messages.d.ts +0 -62
- package/dist/types/core/navigation.d.ts +0 -11
- package/dist/types/core/operation-types.d.ts +0 -80
- package/dist/types/core/operation.d.ts +0 -20
- package/dist/types/core/presentation.d.ts +0 -9
- package/dist/types/core/queries.d.ts +0 -84
- package/dist/types/core/reading.d.ts +0 -17
- package/dist/types/core/uuid.d.ts +0 -2
- package/dist/types/core/variables.d.ts +0 -133
- package/dist/types/server/handler.d.ts +0 -13
- package/dist/types/server/request-body.d.ts +0 -4
package/docs/embed.md
CHANGED
|
@@ -12,6 +12,7 @@ message delivery. The host supplies an iframe and a validated message dispatcher
|
|
|
12
12
|
```ts
|
|
13
13
|
import { attachDataAppBridge } from '@altertable/data-app-embed';
|
|
14
14
|
|
|
15
|
+
// ... iframe and authorized router
|
|
15
16
|
const host = attachDataAppBridge({
|
|
16
17
|
iframe,
|
|
17
18
|
source: { type: 'url', url: 'https://apps.example.com/report' },
|
|
@@ -19,10 +20,10 @@ const host = attachDataAppBridge({
|
|
|
19
20
|
});
|
|
20
21
|
```
|
|
21
22
|
|
|
22
|
-
The host defines `iframe` and `router`; see [message contracts](
|
|
23
|
+
The host defines `iframe` and `router`; see [message contracts](#message-routes).
|
|
23
24
|
Call `host.dispose()` before replacing the source or retrying. A URL source requires HTTP(S)
|
|
24
25
|
and a different origin from its host. The source bridge adds `__altertable_parent` to the
|
|
25
|
-
app URL.
|
|
26
|
+
app URL. An app loaded by URL must install a transport to its configured,
|
|
26
27
|
trusted parent origin using the [client API](client.md#iframe-transport).
|
|
27
28
|
The query parameter alone does not establish trust.
|
|
28
29
|
|
|
@@ -43,11 +44,8 @@ direct network access. Data requests go through the host's dispatcher.
|
|
|
43
44
|
Supply an HTTP(S) `bootstrapUrl` to use an externally served trusted bootstrap,
|
|
44
45
|
such as the [Worker asset](worker.md).
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Bundle mode uses `sandbox="allow-scripts"` and an opaque origin; it cannot read
|
|
49
|
-
the host document or use same-origin privileges. Both modes use
|
|
50
|
-
`referrerPolicy="no-referrer"`.
|
|
47
|
+
Supply a self-contained JavaScript bundle. Bundle mode uses an opaque
|
|
48
|
+
`sandbox="allow-scripts"` frame; both modes use `referrerPolicy="no-referrer"`.
|
|
51
49
|
|
|
52
50
|
## Trusted bootstrap
|
|
53
51
|
|
|
@@ -71,19 +69,15 @@ session token. Its hosting service must enforce its CSP. The bridge cannot impos
|
|
|
71
69
|
CSP on a remote response. A starting policy for self-contained scripts and styles
|
|
72
70
|
is `default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline';
|
|
73
71
|
img-src data: blob:; connect-src 'none'; base-uri 'none'; form-action 'none'`.
|
|
74
|
-
The initializer installs
|
|
75
|
-
|
|
76
|
-
no app navigation adapter. React mounting or URL controls attach navigation in the
|
|
77
|
-
app bundle; non-React apps use `createDataAppNavigation()` from `/client`.
|
|
72
|
+
The initializer installs the transport before evaluating app code. Non-React
|
|
73
|
+
apps attach [navigation](client.md#app-navigation) separately.
|
|
78
74
|
|
|
79
75
|
## Delivery and navigation
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
`connection: { type: 'origin', origin }` or `{ type: 'opaque', token }
|
|
83
|
-
`onMessage
|
|
84
|
-
|
|
85
|
-
wildcard delivery, but incoming messages still require the exact iframe window,
|
|
86
|
-
null origin, token, document, and session to match.
|
|
77
|
+
For an already loaded, host-owned iframe, supply
|
|
78
|
+
`connection: { type: 'origin', origin }` or `{ type: 'opaque', token }` with
|
|
79
|
+
`onMessage`. The host then owns loading and sandbox policy. Use source mode for
|
|
80
|
+
bundle loading and session setup.
|
|
87
81
|
|
|
88
82
|
`createNavigationHandler({ window, reservedSearchParams })` handles the shared
|
|
89
83
|
`navigation:update` route using browser history. Reserved host query parameters
|
|
@@ -100,17 +94,47 @@ client acknowledged initialization or a bundle script finished evaluation. It
|
|
|
100
94
|
does not mean asynchronous data queries finished. Script errors report `failed`.
|
|
101
95
|
The source bridge's `startupTimeoutMs` defaults to 30 seconds.
|
|
102
96
|
|
|
103
|
-
`onDiagnostic`
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Results and errors include `durationMs`, the host handling time. `drop` events
|
|
107
|
-
report why a message from the connected iframe was ignored, such as a stale
|
|
108
|
-
session or token; messages from other windows are not reported.
|
|
97
|
+
Use `onDiagnostic` or `logger` to inspect delivery and failures. Diagnostics omit
|
|
98
|
+
tokens and payloads. Handlers must authorize every data request; message
|
|
99
|
+
validation and iframe isolation do not grant data access.
|
|
109
100
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
## Message routes
|
|
102
|
+
|
|
103
|
+
Message contracts describe the payloads allowed between an embedded app and its
|
|
104
|
+
host. Share these contracts with the app; keep handlers and authorization in the
|
|
105
|
+
host/server.
|
|
106
|
+
|
|
107
|
+
Name routes `{scope}:{action}`, for example `data:query` or `navigation:update`.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import {
|
|
111
|
+
createMessageRouter,
|
|
112
|
+
defineMessageRoute,
|
|
113
|
+
navigationUpdateRoute,
|
|
114
|
+
} from '@altertable/data-app/contract';
|
|
115
|
+
import { createNavigationHandler } from '@altertable/data-app-embed';
|
|
116
|
+
|
|
117
|
+
function parseString(value: unknown) {
|
|
118
|
+
if (typeof value !== 'string') throw new Error('Expected a string.');
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const routes = {
|
|
123
|
+
'demo:echo': defineMessageRoute({ input: parseString, output: parseString }),
|
|
124
|
+
'navigation:update': navigationUpdateRoute,
|
|
125
|
+
};
|
|
126
|
+
const router = createMessageRouter(routes, {
|
|
127
|
+
'demo:echo': value => value,
|
|
128
|
+
'navigation:update': createNavigationHandler(),
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`router.dispatch()` validates route input and output. Use `MessageRoutingError`
|
|
133
|
+
for intentional public failures; other handler errors are hidden.
|
|
134
|
+
|
|
135
|
+
Use `defineDataQueryRoute(operationContracts)` for typed named operations or
|
|
136
|
+
`dataAppRoutes` for generic operation and navigation routes. Handlers must
|
|
137
|
+
validate operations, authorize data access, and enforce backend query limits.
|
|
114
138
|
|
|
115
139
|
## SQL query route
|
|
116
140
|
|
|
@@ -143,25 +167,17 @@ as public `source_*` errors with request IDs. Authorization failures return
|
|
|
143
167
|
`forbidden`; unknown query errors are hidden. Custom handlers can return deliberate
|
|
144
168
|
public failures with `MessageRoutingError`.
|
|
145
169
|
|
|
146
|
-
`
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
The route rejects empty statements, unsafe or nonpositive limits, malformed
|
|
151
|
-
results, and results exceeding the requested limit. The bridge's existing payload
|
|
152
|
-
and pending-call limits apply, and cancellation reaches the handler's signal.
|
|
153
|
-
Operation names and inputs stay in the app; query evidence is assembled there.
|
|
154
|
-
|
|
155
|
-
`dataAppRoutes` retains named `data:query` and navigation routes for existing
|
|
156
|
-
server-backed hosts. SQL hosts opt into `data:sql`; they need no named-operation
|
|
157
|
-
handler unless they also serve HTTP-style apps. Update the host before switching
|
|
158
|
-
an app to browser-owned operations. Older hosts reject `data:sql` as unknown.
|
|
170
|
+
The SQL route carries `{ statement, limit, params? }` and returns column
|
|
171
|
+
metadata and row arrays; see `SqlQueryInput` and `QueryResult` in the
|
|
172
|
+
[API reference](../REFERENCE.md). Keep SQL and parameters unchanged.
|
|
173
|
+
For server-owned named operations, use `dataAppRoutes` and `data:query` instead.
|
|
159
174
|
|
|
160
175
|
## Parent presentation
|
|
161
176
|
|
|
162
177
|
The parent declares where the iframe is mounted and owns its resolved theme:
|
|
163
178
|
|
|
164
179
|
```ts
|
|
180
|
+
// ... iframe and authorized router
|
|
165
181
|
const host = attachDataAppBridge({
|
|
166
182
|
iframe,
|
|
167
183
|
source: { type: 'url', url: 'https://apps.example.com/report' },
|
|
@@ -173,18 +189,30 @@ const host = attachDataAppBridge({
|
|
|
173
189
|
host.setPresentation({ surface: 'embedded', theme: 'light' });
|
|
174
190
|
```
|
|
175
191
|
|
|
176
|
-
|
|
177
|
-
`
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
192
|
+
Use `surface: 'embedded'` when the parent supplies page chrome and
|
|
193
|
+
`'standalone'` when the app supplies it. Resolve the parent theme to `'light'` or
|
|
194
|
+
`'dark'`. React `<DataApp>` applies presentation automatically: embedded surfaces
|
|
195
|
+
keep toolbar actions and hide header/footer. Updates do not reload the iframe.
|
|
196
|
+
Call `host.setPresentation(undefined)` to restore standalone defaults.
|
|
197
|
+
|
|
198
|
+
### Content sizing
|
|
199
|
+
|
|
200
|
+
By default the parent sizes the iframe and the app scrolls inside it. Set
|
|
201
|
+
`sizing: 'content'` when the parent page should scroll instead, as in a details
|
|
202
|
+
panel that stacks the app with other content:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
host.setPresentation({
|
|
206
|
+
surface: 'embedded',
|
|
207
|
+
theme: 'light',
|
|
208
|
+
sizing: 'content',
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
React `<DataApp>` supports content sizing automatically; framework-neutral apps
|
|
213
|
+
call `bridge.supportContentSizing()`. Keep iframe flex/grid stretching and
|
|
214
|
+
`max-height` constraints off so the reported height can apply. Keep app document
|
|
215
|
+
and body heights automatic.
|
|
216
|
+
|
|
217
|
+
If sizing fails to settle, the bridge restores frame scrolling. Toggle sizing or
|
|
218
|
+
reload to retry. Switching to `'frame'` or disposing restores the authored height.
|
|
@@ -35,10 +35,7 @@ formatCount(2_200_000); // "2,200,000"
|
|
|
35
35
|
For signed or fractional measures, use `formatNumber()` with
|
|
36
36
|
`notation: 'compact'` and preserve the measure's units.
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
`<PeriodSummary>` describes reporting periods; `<UpdatedAt>` and
|
|
40
|
-
`<DateTimeTooltip>` expose readable timestamps with exact-date details.
|
|
41
|
-
`<DataTableTimestamp>` and `<DataTableShare>` format custom table cells.
|
|
38
|
+
Use `chartColor()` from `@altertable/data-app-react` for palette colors.
|
|
42
39
|
|
|
43
40
|
## Display dates consistently
|
|
44
41
|
|
|
@@ -46,13 +43,17 @@ Declare date meaning on dataset columns so tables use readable values and CSV
|
|
|
46
43
|
keeps the originals:
|
|
47
44
|
|
|
48
45
|
```ts
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
// ... dailyCountsView with day and observed result fields
|
|
47
|
+
const dailyCounts = dailyCountsView.dataset({
|
|
48
|
+
// ... name, select, rowKey, and evidence
|
|
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
|
+
},
|
|
54
55
|
},
|
|
55
|
-
}
|
|
56
|
+
});
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
Calendar dates use `YYYY-MM-DD`. Instants accept epoch milliseconds or timestamp
|
|
@@ -68,32 +69,10 @@ ordering matters; exact-time details remain available on timestamps.
|
|
|
68
69
|
|
|
69
70
|
## Configure identity and appearance
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const dataApp = defineDataApp({
|
|
75
|
-
title: 'Product activity',
|
|
76
|
-
description: 'Explore product usage and trends.',
|
|
77
|
-
scope: { organization: 'Acme', environment: 'Production' },
|
|
78
|
-
appearance: {
|
|
79
|
-
theme: 'system',
|
|
80
|
-
baseColor: 'neutral',
|
|
81
|
-
density: 'comfortable',
|
|
82
|
-
},
|
|
83
|
-
queries: {},
|
|
84
|
-
});
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Scope labels describe the configured connection; they do not grant access.
|
|
88
|
-
|
|
89
|
-
Title and description explain the app and can be revised when regenerating it.
|
|
90
|
-
Omit appearance to use the standard defaults.
|
|
91
|
-
|
|
92
|
-
The default UI is neutral in light and dark themes. Use `baseColor` for the base
|
|
93
|
-
palette and `accentColor` with optional `darkAccentColor` for brand emphasis.
|
|
94
|
-
Configure chart colors separately with `chartColors`; preserve semantic status
|
|
95
|
-
colors for favorable and unfavorable outcomes.
|
|
72
|
+
Set `title`, `description`, and connection `scope` in `defineDataApp()`. Scope
|
|
73
|
+
labels describe the connection; they do not grant access.
|
|
96
74
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
75
|
+
Keep default appearance. Customize only when requested, configuring it once: `baseColor` for
|
|
76
|
+
the base palette, `accentColor` and optional `darkAccentColor` for emphasis,
|
|
77
|
+
and `chartColors` for charts. Preserve semantic favorable/unfavorable colors.
|
|
78
|
+
Embedded apps follow the parent's resolved theme.
|
package/docs/hosted-apps.md
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
# Author a data app
|
|
2
2
|
|
|
3
|
-
Follow the [shared authoring flow](app-authoring.md)
|
|
3
|
+
Follow the [shared authoring flow](app-authoring.md) with the version-matched `starter-data-app/index.tsx` for a hosted / remote / cloud data app. Keep the app in
|
|
4
4
|
one file with public package imports; omit server files, HTML, credentials, and
|
|
5
5
|
relative or app-alias imports.
|
|
6
6
|
|
|
7
|
-
Declare
|
|
8
|
-
`@altertable/data-app`.
|
|
9
|
-
and any variable name are allowed. Export only for other modules.
|
|
7
|
+
Declare `const dataApp = defineDataApp({ ... })` once at module scope using the
|
|
8
|
+
named import from `@altertable/data-app`.
|
|
10
9
|
|
|
11
10
|
Keep the argument literal: objects, arrays, strings (including templates without
|
|
12
11
|
interpolation), finite signed numbers, booleans, and null. Parentheses, `as`, and
|
|
13
12
|
`satisfies` are allowed. Keep executable composition outside the call; omit spreads,
|
|
14
13
|
computed keys, references, and callbacks. Static apps use `queries: {}`.
|
|
15
|
-
TypeScript checks configuration shape. Static extraction reads the literal data
|
|
16
|
-
without executing app code or interpreting SQL.
|
|
17
14
|
|
|
18
|
-
Replace
|
|
19
|
-
|
|
20
|
-
`VALUES` rows, so it needs no production table.
|
|
15
|
+
Replace sample queries and bindings with inspected source data. Supply `scope`
|
|
16
|
+
in `defineDataApp()` and `story` and `datasets` on `<DataApp>`.
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
optional prop with `?`.
|
|
25
|
-
|
|
26
|
-
For execution details, see [browser-owned operations](client.md#browser-owned-operations-for-bundle-apps).
|
|
18
|
+
Keep the starter's client, style injection, and mounting code. The host supplies
|
|
19
|
+
the transport; no bootstrap or message routes are needed in app code.
|
|
27
20
|
|
|
28
21
|
## Convert a local data app
|
|
29
22
|
|
package/docs/layout.md
CHANGED
|
@@ -1,56 +1,39 @@
|
|
|
1
|
-
# Layout
|
|
1
|
+
# Layout
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
external spacing. Keep widget customization inside the widget so its parent can maintain consistent
|
|
7
|
-
spacing between sections and cards.
|
|
8
|
-
|
|
9
|
-
Configure density once in `app.appearance`. `<Grid>` wraps to fit its container;
|
|
10
|
-
spans collapse when there is not enough space.
|
|
3
|
+
Use `<Stack>` for reading order, `<Grid>` for peer widgets, and `<GridItem>` for
|
|
4
|
+
spans. The shell owns page width and gutters; parents own spacing and widgets
|
|
5
|
+
own internal padding. Keep default density unless customization is requested.
|
|
11
6
|
|
|
12
7
|
```tsx
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
// ... sampleCountsView, sampleCounts, and totalSamples
|
|
9
|
+
const sampleContent = sampleCountsView.content(result => (
|
|
10
|
+
<Stack>
|
|
11
|
+
<SectionHeading>Sample counts</SectionHeading>
|
|
12
|
+
<TextContent>
|
|
13
|
+
<p>Explore the sources behind this finding.</p>
|
|
14
|
+
</TextContent>
|
|
15
|
+
<Grid columns={3}>
|
|
16
|
+
<GridItem span={2}>
|
|
17
|
+
<TableWidget dataset={sampleCounts} source={result} />
|
|
18
|
+
</GridItem>
|
|
19
|
+
<GridItem>
|
|
20
|
+
<MetricWidget metric={totalSamples} source={result} />
|
|
21
|
+
</GridItem>
|
|
22
|
+
</Grid>
|
|
23
|
+
</Stack>
|
|
24
|
+
));
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Use `<DataApp footer={...}>` for an optional source, coverage, or methodology
|
|
29
|
-
note below the app content. The footer provides muted body text across the content
|
|
30
|
-
width and top spacing. Compose paragraphs, links, lists, and inline components such
|
|
31
|
-
as `<DataIdentifier>` or `<DateDisplay>` directly; no `<TextContent>` wrapper is
|
|
32
|
-
needed. Keep headings and data widgets in the body, and app controls in
|
|
33
|
-
`footerActions`. Keep static notes outside loading sections.
|
|
27
|
+
Grids wrap to fit their container and spans collapse when needed. Set widget
|
|
28
|
+
`headingLevel={3}` beneath a section heading.
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<>
|
|
40
|
-
<p>
|
|
41
|
-
<strong>Coverage.</strong> Records include the last 90 days.
|
|
42
|
-
</p>
|
|
43
|
-
<p>Counts reflect current inventory, not an activity log.</p>
|
|
44
|
-
</>
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
<DataSection content={content} />
|
|
48
|
-
</DataApp>
|
|
49
|
-
```
|
|
30
|
+
Use `<DataApp footer={...}>` for static source, coverage, or methodology notes.
|
|
31
|
+
Compose paragraphs, links, and inline components directly; no `<TextContent>`
|
|
32
|
+
wrapper is needed. Keep headings and widgets in the body and controls in
|
|
33
|
+
`footerActions`.
|
|
50
34
|
|
|
51
35
|
## Verify rendered layouts
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
the ready content.
|
|
37
|
+
Review authored composition with realistic labels and values. For custom layout
|
|
38
|
+
or sizing, check spacing and overflow at narrow and wide iframe widths. Keep
|
|
39
|
+
the same grid during loading and ready states.
|
package/docs/local-data-apps.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Author a local data app
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Use the local scaffold supplied by your authoring workflow. Its README covers
|
|
4
|
+
setup and its AGENTS.md identifies app-owned files.
|
|
5
5
|
Replace the connectivity screen with the exploration, CSV export, and story from the
|
|
6
6
|
[shared authoring flow](app-authoring.md).
|
|
7
7
|
|
|
8
|
-
| Task
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
8
|
+
| Task | Documentation |
|
|
9
|
+
| ---------------------------- | ---------------------------------------- |
|
|
10
|
+
| Customize local serving | [Bun server](server-bun.md) |
|
|
11
|
+
| Authorize hosted viewers | [Server](server.md) |
|
|
12
|
+
| Customize the browser client | [HTTP client](client.md#http-operations) |
|
|
13
13
|
|
|
14
14
|
You can also [convert the local app to a hosted data app](hosted-apps.md#convert-a-local-data-app).
|
package/docs/react-embed.md
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
# React embedding
|
|
2
2
|
|
|
3
|
-
Import `<DataAppBridge>` from `@altertable/data-app-embed/react`.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
neither package imports the other. Both use the base package's contracts.
|
|
7
|
-
|
|
8
|
-
The bridge owns iframe setup and `postMessage()` communication. The consuming
|
|
9
|
-
frontend or CLI owns its shell: fetching a bundle, subscriptions, layout, loading
|
|
10
|
-
and error UI, and retry controls. Both hosts use the same bridge and transport.
|
|
3
|
+
Import `<DataAppBridge>` from `@altertable/data-app-embed/react`.
|
|
4
|
+
The bridge owns iframe setup and communication. The host owns bundle fetching,
|
|
5
|
+
layout, loading/error UI, and retry controls.
|
|
11
6
|
|
|
12
7
|
## Source-managed iframe
|
|
13
8
|
|
|
@@ -20,6 +15,7 @@ import { useReducer, useState } from 'react';
|
|
|
20
15
|
import { DataAppBridge } from '@altertable/data-app-embed/react';
|
|
21
16
|
import type { DataAppStatus } from '@altertable/data-app-embed';
|
|
22
17
|
|
|
18
|
+
// ... authorized router
|
|
23
19
|
function Shell() {
|
|
24
20
|
const [status, setStatus] = useState<DataAppStatus>('connecting');
|
|
25
21
|
const [attempt, retry] = useReducer(value => value + 1, 0);
|
|
@@ -41,12 +37,21 @@ function Shell() {
|
|
|
41
37
|
}
|
|
42
38
|
```
|
|
43
39
|
|
|
44
|
-
The host supplies `router` using [message contracts](
|
|
40
|
+
The host supplies `router` using [message contracts](embed.md#message-routes).
|
|
45
41
|
The local URL must have a different origin from its shell. For hosted bundles,
|
|
46
42
|
replace `source` with:
|
|
47
43
|
|
|
48
44
|
```tsx
|
|
49
|
-
|
|
45
|
+
function Shell() {
|
|
46
|
+
// ... javascript bundle and router
|
|
47
|
+
return (
|
|
48
|
+
<DataAppBridge
|
|
49
|
+
title="Activity report"
|
|
50
|
+
source={{ type: 'bundle', javascript }}
|
|
51
|
+
onMessage={router.dispatch}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
50
55
|
```
|
|
51
56
|
|
|
52
57
|
The host supplies the JavaScript bundle. Omit `bootstrapUrl` for the packaged
|
|
@@ -58,10 +63,8 @@ bridge's React `key` to retry with a fresh frame. Handler changes use the latest
|
|
|
58
63
|
callbacks without resetting the session. `startupTimeoutMs`, `onStatusChange`, and
|
|
59
64
|
`onDiagnostic` have the same meaning as in the framework-neutral API.
|
|
60
65
|
|
|
61
|
-
`iframeProps`
|
|
62
|
-
|
|
63
|
-
`sandbox`, `referrerPolicy`, `loading`, and the callback ref. Loading is always
|
|
64
|
-
`eager` so an iframe hidden until ready can start. Supply `title` directly.
|
|
66
|
+
Use `iframeProps` for styling, visibility, and accessibility attributes; supply
|
|
67
|
+
`title` directly. The bridge owns source, sandbox, loading, and ref attributes.
|
|
65
68
|
|
|
66
69
|
## Host-owned iframe
|
|
67
70
|
|
|
@@ -72,6 +75,7 @@ owns a loaded iframe and its security policy:
|
|
|
72
75
|
import { useState, type ComponentRef } from 'react';
|
|
73
76
|
import { DataAppBridge } from '@altertable/data-app-embed/react';
|
|
74
77
|
|
|
78
|
+
// ... appUrl and authorized router
|
|
75
79
|
function Host() {
|
|
76
80
|
const [iframe, setIframe] = useState<ComponentRef<'iframe'> | null>(null);
|
|
77
81
|
return (
|
|
@@ -87,18 +91,8 @@ function Host() {
|
|
|
87
91
|
}
|
|
88
92
|
```
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
mode renders nothing and handles delivery only. Use source mode for bundle
|
|
93
|
-
loading, sandbox policy, token rotation, and startup timeout. The two prop modes
|
|
94
|
-
are mutually exclusive.
|
|
95
|
-
|
|
96
|
-
## Loading an embedded app
|
|
97
|
-
|
|
98
|
-
The host owns loading and generation UI while an app starts. Use a neutral
|
|
99
|
-
status that does not imply a particular app layout. `@altertable/data-app-embed/react` remains
|
|
100
|
-
independent of UI components and styles. Once the app loads, its query and
|
|
101
|
-
widget loading states describe the content they replace.
|
|
94
|
+
Supply `appUrl` and `router`. A callback ref tracks iframe mounting and
|
|
95
|
+
replacement. This mode renders nothing; the host owns loading and security policy.
|
|
102
96
|
|
|
103
97
|
## Parent-owned presentation
|
|
104
98
|
|
package/docs/react.md
CHANGED
|
@@ -1,40 +1,23 @@
|
|
|
1
1
|
# React
|
|
2
2
|
|
|
3
|
-
Import
|
|
4
|
-
React
|
|
3
|
+
Import views, bound widgets, and layouts from `@altertable/data-app-react`.
|
|
4
|
+
React and React DOM 19.2 or newer are required. Start with
|
|
5
|
+
[app authoring](app-authoring.md).
|
|
5
6
|
|
|
6
7
|
## Mount the app
|
|
7
8
|
|
|
8
|
-
Use `mountDataApp({ app, component })` to mount into `#root`. When mounting
|
|
9
|
-
through another framework, wrap the root in `<DataAppProvider app={app}>` from `@altertable/data-app-react/ui`.
|
|
10
|
-
`<DataApp>` inherits identity and appearance from that root.
|
|
11
|
-
|
|
12
9
|
```tsx
|
|
13
10
|
import { injectDataAppStyles, mountDataApp } from '@altertable/data-app-react';
|
|
14
11
|
|
|
15
12
|
injectDataAppStyles();
|
|
16
|
-
mountDataApp({ app, component: App });
|
|
13
|
+
mountDataApp({ app: dataApp, component: App });
|
|
17
14
|
```
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
For a restrictive CSP, pass the permitted nonce on the first call.
|
|
21
|
-
See [Styling](styling.md) for appearance, CSS tokens, and overrides.
|
|
22
|
-
|
|
23
|
-
Use `@altertable/data-app-react` for declared views, bound widgets, and layouts. Use
|
|
24
|
-
[`@altertable/data-app-react/ui`](ui.md) for setup/static screens and direct UI composition.
|
|
25
|
-
|
|
26
|
-
## Choose a task
|
|
16
|
+
The app supplies `dataApp`, `App`, and a `#root` element.
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
| Configure date, text, select, and dimension controls | [Variables](variables.md) |
|
|
32
|
-
| Render metrics, charts, tables, and narrative | [Widgets](widgets.md) |
|
|
33
|
-
| Compose sections and responsive grids | [Layout](layout.md) |
|
|
34
|
-
| Register sources, definitions, metrics, and evidence | [Data context](data-context.md) |
|
|
35
|
-
| Present findings and export displayed data | [Stories and export](stories-and-export.md) |
|
|
36
|
-
| Format values and configure appearance | [Formatting and appearance](formatting-and-appearance.md) |
|
|
37
|
-
| Host an iframe from React | [React embed](react-embed.md) |
|
|
18
|
+
Keep the starter's mounting and client wiring. Use declared views and bound
|
|
19
|
+
widgets for exploration. Use `/ui` for setup/static screens or a custom component
|
|
20
|
+
only when bound components cannot express the requirement.
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
Hosts embedding an app use the separate `@altertable/data-app-embed` package;
|
|
23
|
+
that integration is outside ordinary app authoring.
|
package/docs/server-bun.md
CHANGED
|
@@ -10,7 +10,7 @@ when typechecking a Bun app.
|
|
|
10
10
|
```ts
|
|
11
11
|
import { serveLocalApp } from '@altertable/data-app-bun';
|
|
12
12
|
import page from './index.html';
|
|
13
|
-
import { operations } from './operations';
|
|
13
|
+
import { operations } from './operations.ts';
|
|
14
14
|
|
|
15
15
|
serveLocalApp({ page, operations, title: 'Activity' });
|
|
16
16
|
```
|
|
@@ -22,33 +22,8 @@ The server binds to `127.0.0.1`. Its default port is `25837`, overridable throug
|
|
|
22
22
|
`ALTERTABLE_DATA_PROXY_URL` and `ALTERTABLE_DATA_PROXY_TOKEN`. It also supports
|
|
23
23
|
server-only `ALTERTABLE_LAKEHOUSE_USERNAME` and
|
|
24
24
|
`ALTERTABLE_LAKEHOUSE_PASSWORD`, with an optional `ALTERTABLE_API_BASE`.
|
|
25
|
-
Missing credentials fail
|
|
25
|
+
Missing credentials fail at startup. Keep these variables out of browser code.
|
|
26
26
|
|
|
27
27
|
Local serving does not authenticate hosted viewers.
|
|
28
28
|
Use [the portable server handler](server.md) with per-request authorization when
|
|
29
29
|
hosting an app for other people.
|
|
30
|
-
|
|
31
|
-
## Preview a single-file app
|
|
32
|
-
|
|
33
|
-
Import `serveAppFile()` from `@altertable/data-app-bun/preview` to preview
|
|
34
|
-
an app in the hosted sandbox. The caller supplies the server-only lakehouse.
|
|
35
|
-
The runtime owns bundling, imported-file watching, reloads, navigation, and exports.
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import { serveAppFile } from '@altertable/data-app-bun/preview';
|
|
39
|
-
import { localLakehouse } from '@altertable/data-app-bun';
|
|
40
|
-
|
|
41
|
-
const preview = await serveAppFile({
|
|
42
|
-
file: '/absolute/path/index.tsx',
|
|
43
|
-
lakehouse: localLakehouse(),
|
|
44
|
-
});
|
|
45
|
-
console.log(preview.url);
|
|
46
|
-
// When the launcher stops:
|
|
47
|
-
await preview.stop();
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
The preview resolves `@altertable/data-app` and React from its own installation.
|
|
51
|
-
It binds to localhost and accepts SQL only from its own origin,
|
|
52
|
-
with a streaming limit of 100,000 UTF-8 bytes per query request. The caller
|
|
53
|
-
owns profile validation, dependency installation, and credentials. This entry requires Bun and adds no Bun installation or dependency
|
|
54
|
-
to browser consumers. Keep it separate from browser imports.
|
package/docs/server.md
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Import `createDataHandler()` and the `RequestAccess` type from
|
|
4
4
|
`@altertable/data-app/server`. The handler accepts a Web `Request` and returns a
|
|
5
|
-
`Promise<Response
|
|
6
|
-
React or the Bun local-development adapter.
|
|
5
|
+
`Promise<Response>` in Node or Bun.
|
|
7
6
|
|
|
8
7
|
```ts
|
|
9
8
|
import { createDataHandler } from '@altertable/data-app/server';
|
|
10
|
-
import { operations } from './operations';
|
|
9
|
+
import { operations } from './operations.ts';
|
|
11
10
|
|
|
12
11
|
export const handleDataRequest = createDataHandler(
|
|
13
12
|
operations,
|
|
@@ -36,12 +35,7 @@ See [operation contracts](contract.md), the [client](client.md), and the
|
|
|
36
35
|
|
|
37
36
|
## Request input limits
|
|
38
37
|
|
|
39
|
-
JSON request bodies are limited to
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
interrupted bodies return `400/invalid_input`; oversized bodies return
|
|
44
|
-
`413/input_too_large`.
|
|
45
|
-
|
|
46
|
-
`maxDurationMs` bounds execution after input parsing. It does not add a separate
|
|
47
|
-
body-read deadline. The hosting runtime controls the size of individual chunks.
|
|
38
|
+
JSON request bodies are limited to 16,384 encoded bytes. Oversized bodies return
|
|
39
|
+
`413/input_too_large`; invalid or interrupted bodies return `400/invalid_input`.
|
|
40
|
+
`maxDurationMs` bounds execution after parsing; configure body-read deadlines in
|
|
41
|
+
the hosting runtime.
|