@altertable/data-app 0.72.0 → 0.74.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 +130 -181
- package/README.md +3 -4
- package/REFERENCE.md +35 -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/diagnostics-BTZSlNtW.js +967 -0
- package/dist/chunks/diagnostics-BTZSlNtW.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/operation-CSM9UmO3.js +134 -0
- package/dist/chunks/operation-CSM9UmO3.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 +273 -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 +240 -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 +77 -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/diagnostics.md +45 -0
- package/docs/embed.md +86 -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 +93 -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/dist/types/internal.d.ts
CHANGED
|
@@ -1,22 +1,312 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { $ as createDimensionFilter, Ct as multiChoiceVariable, Dt as HistoryMode, Gt as DatePresetId, Ht as dimensionSource, It as numberOperatorLabels, Jt as inclusiveDays, K as DimensionFilterSettings, Kt as DateRange, St as defineAppVariables, Tt as validateChoiceOptions, Vt as SourceDimensionVariable, Wt as DatePreset, X as DimensionSelectionVariable, Yt as withinBounds, Z as DimensionValue, Zt as IsUnion, _t as SearchVariable, at as FacetVariable, bt as choiceVariable, ct as AppVariableValues, dt as ChoiceOption, ft as ChoiceVariable, gt as MultiChoiceVariable, ht as DateRangeVariableOptions, j as DateRangeRequest, lt as CheckedFacetContexts, mt as DateRangeVariable, ot as facetSource, pt as DateRangeSelection, qt as availableDatePresets, r as DataAppAnnotationPresentation, st as AppVariable, tt as dimensionMemberKey, ut as CheckedVariableDeclarations, vt as VariableCollection, wt as searchVariable, xt as dateRangeVariable, yt as VariablePresentation } from "./chunks/contract.js";
|
|
2
|
+
import { i as parseAppDiagnosticReport, m as localFrameBridge, w as LogEntry } from "./chunks/index.js";
|
|
3
|
+
import { c as Theme } from "./chunks/appearance.js";
|
|
4
|
+
//#region src/core/bridge.d.ts
|
|
5
|
+
/** Data app delivery protocol. IDs identify a document, a shell session, and an individual call. */
|
|
6
|
+
declare const BRIDGE = "altertable:data-app";
|
|
7
|
+
export declare const PARENT_PARAM = "__altertable_parent";
|
|
8
|
+
/** Bound pending requests in the client and host independently.
|
|
9
|
+
* The host enforces its own limit because frames can send messages directly. */
|
|
10
|
+
export declare const MAX_PENDING = 128;
|
|
11
|
+
export declare const REQUEST_TIMEOUT_MS = 60000;
|
|
12
|
+
export declare function validId(value: unknown): value is string;
|
|
13
|
+
type Fields = Record<string, unknown>;
|
|
14
|
+
type BridgeRole = 'host' | 'app';
|
|
15
|
+
/** Parsers project known fields; opaque values are validated by their owning route or adapter. */
|
|
16
|
+
declare const bridgeProtocol: {
|
|
17
|
+
readonly channel: "altertable:data-app";
|
|
18
|
+
readonly version: 1;
|
|
19
|
+
readonly events: {
|
|
20
|
+
readonly connect: {
|
|
21
|
+
wire: "bridge:connect";
|
|
22
|
+
from: "host";
|
|
23
|
+
session: "none";
|
|
24
|
+
parse: (fields: Fields) => {};
|
|
25
|
+
};
|
|
26
|
+
readonly ready: {
|
|
27
|
+
wire: "bridge:ready";
|
|
28
|
+
from: "app";
|
|
29
|
+
session: "none";
|
|
30
|
+
parse: (fields: Fields) => {};
|
|
31
|
+
};
|
|
32
|
+
readonly initialize: {
|
|
33
|
+
wire: "bridge:initialize";
|
|
34
|
+
from: "host";
|
|
35
|
+
session: "establish";
|
|
36
|
+
parse: (fields: Fields) => {
|
|
37
|
+
state: unknown;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
readonly request: {
|
|
41
|
+
wire: "bridge:request";
|
|
42
|
+
from: "app";
|
|
43
|
+
session: "current";
|
|
44
|
+
parse: (fields: Fields) => {
|
|
45
|
+
id: string;
|
|
46
|
+
route: string;
|
|
47
|
+
payload: unknown;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
readonly result: {
|
|
51
|
+
wire: "bridge:result";
|
|
52
|
+
from: "host";
|
|
53
|
+
session: "current";
|
|
54
|
+
parse: (fields: Fields) => {
|
|
55
|
+
id: string;
|
|
56
|
+
response: unknown;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
readonly error: {
|
|
60
|
+
wire: "bridge:error";
|
|
61
|
+
from: "host";
|
|
62
|
+
session: "current";
|
|
63
|
+
parse: (fields: Fields) => {
|
|
64
|
+
id: string;
|
|
65
|
+
code: string;
|
|
66
|
+
message: string;
|
|
67
|
+
requestId?: string | undefined;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly cancel: {
|
|
71
|
+
wire: "bridge:cancel";
|
|
72
|
+
from: "app";
|
|
73
|
+
session: "current";
|
|
74
|
+
parse: (fields: Fields) => {
|
|
75
|
+
id: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly disconnect: {
|
|
79
|
+
wire: "bridge:disconnect";
|
|
80
|
+
from: "app";
|
|
81
|
+
session: "current";
|
|
82
|
+
parse: (fields: Fields) => {};
|
|
83
|
+
};
|
|
84
|
+
readonly scriptLoad: {
|
|
85
|
+
wire: "script:load";
|
|
86
|
+
from: "host";
|
|
87
|
+
session: "current";
|
|
88
|
+
parse: (fields: Fields) => {
|
|
89
|
+
javascript: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
readonly stateUpdate: {
|
|
93
|
+
wire: "state:update";
|
|
94
|
+
from: "host";
|
|
95
|
+
session: "current";
|
|
96
|
+
parse: (fields: Fields) => {
|
|
97
|
+
state: unknown;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
readonly runtimeLog: {
|
|
101
|
+
wire: "runtime:log";
|
|
102
|
+
from: "app";
|
|
103
|
+
session: "current";
|
|
104
|
+
parse: (fields: Fields) => {
|
|
105
|
+
payload: LogEntry;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
readonly runtimeReady: {
|
|
109
|
+
wire: "runtime:ready";
|
|
110
|
+
from: "app";
|
|
111
|
+
session: "current";
|
|
112
|
+
parse: (fields: Fields) => {};
|
|
113
|
+
};
|
|
114
|
+
readonly runtimeError: {
|
|
115
|
+
wire: "runtime:error";
|
|
116
|
+
from: "app";
|
|
117
|
+
session: "current";
|
|
118
|
+
parse: (fields: Fields) => {};
|
|
119
|
+
};
|
|
120
|
+
/** Content height in CSS pixels; hosts apply it only to content-sized frames. */
|
|
121
|
+
readonly runtimeResize: {
|
|
122
|
+
wire: "runtime:resize";
|
|
123
|
+
from: "app";
|
|
124
|
+
session: "current";
|
|
125
|
+
parse: (fields: Fields) => {
|
|
126
|
+
height: number;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/** CSS pixels of a content-sized frame hidden above and below the parent's visible area. */
|
|
130
|
+
readonly viewportUpdate: {
|
|
131
|
+
wire: "viewport:update";
|
|
132
|
+
from: "host";
|
|
133
|
+
session: "current";
|
|
134
|
+
parse: (fields: Fields) => {
|
|
135
|
+
top: number;
|
|
136
|
+
bottom: number;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
type Events = typeof bridgeProtocol.events;
|
|
142
|
+
type BridgeEventName = keyof Events;
|
|
143
|
+
type BridgePayload<Name extends BridgeEventName> = ReturnType<Events[Name]['parse']>;
|
|
144
|
+
type BridgeEnvelope = {
|
|
145
|
+
channel: typeof BRIDGE;
|
|
146
|
+
version: typeof bridgeProtocol.version;
|
|
147
|
+
documentId: string;
|
|
148
|
+
sessionId?: string;
|
|
149
|
+
token?: string;
|
|
150
|
+
};
|
|
151
|
+
type BridgeEventMessage<Name extends BridgeEventName> = Name extends BridgeEventName ? BridgeEnvelope & {
|
|
152
|
+
type: Events[Name]['wire'];
|
|
153
|
+
} & (Events[Name]['session'] extends 'none' ? {} : {
|
|
154
|
+
sessionId: string;
|
|
155
|
+
}) & BridgePayload<Name> : never;
|
|
156
|
+
type BridgeMessage = { [Name in BridgeEventName]: BridgeEventMessage<Name>; }[BridgeEventName];
|
|
157
|
+
type BridgeEventsFrom<Role extends BridgeRole> = { [Name in BridgeEventName]: Events[Name]['from'] extends Role ? Name : never; }[BridgeEventName];
|
|
158
|
+
type BridgeHandlers<Role extends BridgeRole> = { [Name in BridgeEventsFrom<Role extends 'host' ? 'app' : 'host'>]: (message: BridgeEventMessage<Name>) => void; };
|
|
159
|
+
/** Delivery metadata safe to log on either side; never payloads or session credentials. */
|
|
160
|
+
type BridgeMessageMetadata = {
|
|
161
|
+
type: BridgeMessage['type'];
|
|
162
|
+
id?: string;
|
|
163
|
+
route?: string;
|
|
164
|
+
operation?: string;
|
|
165
|
+
error?: {
|
|
166
|
+
code: string;
|
|
167
|
+
message: string;
|
|
168
|
+
requestId?: string;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
/** Why a message from the connected peer was ignored. Messages from other windows are not reported. */
|
|
172
|
+
type BridgeDropReason = 'invalid_envelope' | 'token_mismatch' | 'unexpected_type' | 'session_mismatch' | 'invalid_payload';
|
|
173
|
+
type BridgeDiagnostic = ({
|
|
174
|
+
direction: 'send' | 'receive';
|
|
175
|
+
} & BridgeMessageMetadata) | {
|
|
176
|
+
direction: 'drop';
|
|
177
|
+
type?: string;
|
|
178
|
+
reason: BridgeDropReason;
|
|
179
|
+
};
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/client/download.d.ts
|
|
182
|
+
/** Start a browser download and release its temporary anchor and object URL. */
|
|
183
|
+
export declare function downloadBlob({ filename, blob }: {
|
|
184
|
+
filename: string;
|
|
185
|
+
blob: Blob;
|
|
186
|
+
}): void;
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/core/bridge-endpoint.d.ts
|
|
189
|
+
type ConnectionContext = Pick<BridgeEnvelope, 'sessionId' | 'token'> & {
|
|
190
|
+
documentId?: string;
|
|
191
|
+
};
|
|
192
|
+
/** The connection owns IDs and token rotation; callers can only supply event payloads. */
|
|
193
|
+
export declare function createBridgeEndpoint<const Role extends BridgeRole>({ role, origin, source, opaque, context, post, diagnostic, invalidRequest, handlers }: {
|
|
194
|
+
role: Role;
|
|
195
|
+
handlers: BridgeHandlers<NoInfer<Role>>;
|
|
196
|
+
origin: string;
|
|
197
|
+
source: () => MessageEventSource | null;
|
|
198
|
+
opaque: boolean;
|
|
199
|
+
context: () => ConnectionContext;
|
|
200
|
+
post: (message: BridgeMessage) => void;
|
|
201
|
+
diagnostic?: (event: BridgeDiagnostic) => void;
|
|
202
|
+
invalidRequest?: (id: string) => void;
|
|
203
|
+
}): {
|
|
204
|
+
send: <Name extends BridgeEventsFrom<Role>, const Payload extends BridgePayload<NoInfer<Name>>>(name: Name, payload: Payload & Record<Exclude<keyof Payload, keyof BridgePayload<NoInfer<Name>>>, never>) => void;
|
|
205
|
+
receive: (event: MessageEvent) => void;
|
|
206
|
+
dispose(): void;
|
|
207
|
+
};
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/core/data-view.d.ts
|
|
210
|
+
type DataView<T, Input = unknown> = {
|
|
211
|
+
kind: 'loading';
|
|
212
|
+
} | {
|
|
213
|
+
kind: 'empty';
|
|
214
|
+
input: Input;
|
|
215
|
+
} | {
|
|
216
|
+
kind: 'error';
|
|
217
|
+
error: Error;
|
|
218
|
+
} | {
|
|
219
|
+
kind: 'ready';
|
|
220
|
+
data: T;
|
|
221
|
+
input: Input;
|
|
222
|
+
} | {
|
|
223
|
+
kind: 'updating';
|
|
224
|
+
data: T;
|
|
225
|
+
requestedInput: Input;
|
|
226
|
+
displayedInput: Input;
|
|
227
|
+
message: string;
|
|
228
|
+
} | {
|
|
229
|
+
kind: 'stale-error';
|
|
230
|
+
data: T;
|
|
231
|
+
requestedInput: Input;
|
|
232
|
+
displayedInput: Input;
|
|
233
|
+
error: Error;
|
|
234
|
+
message: string;
|
|
235
|
+
};
|
|
236
|
+
type DataSnapshot<Data, Input> = {
|
|
237
|
+
data: Data;
|
|
238
|
+
input: Input;
|
|
239
|
+
};
|
|
240
|
+
type DisplayedSnapshot<Data, Input> = DataSnapshot<Data, Input> & {
|
|
241
|
+
state: 'ready' | 'updating' | 'stale-error';
|
|
242
|
+
};
|
|
243
|
+
/** The result currently shown to the reader, including the input that produced it. */
|
|
244
|
+
export declare function displayedSnapshot<Data, Input>(view: DataView<Data, Input>): DisplayedSnapshot<Data, Input> | undefined;
|
|
245
|
+
/** Keep the requested input separate from the input that produced visible data. */
|
|
246
|
+
export declare function resolveDataView<Data, Input>({ requestedInput, current, previous, pending, error, sameInput, describe, isEmpty }: {
|
|
247
|
+
requestedInput: Input;
|
|
248
|
+
current?: DataSnapshot<Data, Input>;
|
|
249
|
+
previous?: DataSnapshot<Data, Input>;
|
|
250
|
+
pending: boolean;
|
|
251
|
+
error?: Error;
|
|
252
|
+
sameInput: (a: Input, b: Input) => boolean;
|
|
253
|
+
describe: (input: Input) => string;
|
|
254
|
+
isEmpty: (data: Data) => boolean;
|
|
255
|
+
}): DataView<Data, Input>;
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/core/invariant.d.ts
|
|
258
|
+
/** Assert an author or data contract while preserving a useful failure message. */
|
|
259
|
+
export declare function invariant(condition: unknown, message: string): asserts condition;
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/core/operation.d.ts
|
|
262
|
+
export declare function toDataOperationFailure(error: unknown, aborted?: boolean): {
|
|
263
|
+
status: number;
|
|
264
|
+
code: string;
|
|
265
|
+
message: string;
|
|
266
|
+
};
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/core/presentation.d.ts
|
|
269
|
+
/** Presentation owned by the parent shell, delivered only over a trusted bridge. */
|
|
270
|
+
type DataAppPresentation = {
|
|
271
|
+
surface: 'embedded' | 'standalone';
|
|
272
|
+
theme: Theme;
|
|
273
|
+
annotations?: DataAppAnnotationPresentation;
|
|
274
|
+
/** `frame` (default): the parent sizes the iframe and the app scrolls inside it.
|
|
275
|
+
* `content`: the iframe follows the app's content height and the parent page scrolls. */
|
|
276
|
+
sizing?: 'frame' | 'content';
|
|
277
|
+
};
|
|
278
|
+
export declare function isDataAppPresentation(value: unknown): value is DataAppPresentation;
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/core/reading.d.ts
|
|
281
|
+
type DataReading<Value> = {
|
|
282
|
+
loading: true;
|
|
283
|
+
value?: never;
|
|
284
|
+
} | {
|
|
285
|
+
loading: false;
|
|
286
|
+
value: Value;
|
|
287
|
+
};
|
|
288
|
+
/** Zero is measured data. null or omitted means no previous measurement.
|
|
289
|
+
* Comparison activation belongs to the reading's period, not these values. */
|
|
290
|
+
type MetricValues = {
|
|
291
|
+
current: number;
|
|
292
|
+
previous?: number | null;
|
|
293
|
+
};
|
|
294
|
+
type MetricReading = DataReading<MetricValues & {
|
|
295
|
+
period?: DateRangeRequest;
|
|
296
|
+
}>;
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/core/uuid.d.ts
|
|
299
|
+
/** Opaque documents can lack randomUUID even when cryptographic randomness is available. */
|
|
300
|
+
export declare function randomUuid(): string;
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/server/request-body.d.ts
|
|
303
|
+
export declare class RequestBodyTooLargeError extends Error {}
|
|
304
|
+
/** Count encoded bytes before retaining chunks; cancellation also interrupts waiting reads. */
|
|
305
|
+
export declare function readRequestBody(request: Request, maxBytes: number): Promise<string>;
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/core/keys.d.ts
|
|
308
|
+
/** Separator for opaque composite keys, independent of URL and DOM ID formats. */
|
|
309
|
+
export declare const KEY_SEPARATOR = ":";
|
|
310
|
+
//#endregion
|
|
311
|
+
export { type AppVariable, type AppVariableValues, type BridgeDiagnostic, type BridgeEventMessage, type CheckedFacetContexts, type CheckedVariableDeclarations, type ChoiceOption, type ChoiceVariable, type DataAppPresentation, type DataReading, type DataView, type DatePreset, type DatePresetId, type DateRange, type DateRangeSelection, type DateRangeVariable, type DateRangeVariableOptions, type DimensionFilterSettings, type DimensionSelectionVariable, type DimensionValue, type DisplayedSnapshot, type FacetVariable, type HistoryMode, type IsUnion, type MetricReading, type MetricValues, type MultiChoiceVariable, type SearchVariable, type SourceDimensionVariable, type VariableCollection, type VariablePresentation, availableDatePresets, choiceVariable, createDimensionFilter, dateRangeVariable, defineAppVariables, dimensionMemberKey, dimensionSource, facetSource, inclusiveDays, localFrameBridge, multiChoiceVariable, numberOperatorLabels, parseAppDiagnosticReport, searchVariable, validateChoiceOptions, withinBounds };
|
|
312
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import { ln as DataOperations, mn as Lakehouse, rn as QueryParameters } from "../chunks/contract.js";
|
|
2
|
+
//#region src/server/handler.d.ts
|
|
3
|
+
/** Authorization result for one viewer request. A hosted adapter must scope its lakehouse client. */
|
|
4
|
+
type RequestAccess = {
|
|
5
|
+
lakehouse: Lakehouse;
|
|
6
|
+
/** Trusted values shared across queries; each query uses only its declared keys. */
|
|
7
|
+
queryParams?: QueryParameters;
|
|
8
|
+
};
|
|
1
9
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
10
|
+
* Execute named operations on the server. The app supplies operations and viewer authorization.
|
|
11
|
+
* JSON, Origin, and Fetch Metadata checks reject cross-site browser POSTs; they do not
|
|
12
|
+
* authenticate another local process. Query evidence accompanies every result.
|
|
5
13
|
*/
|
|
6
|
-
export
|
|
14
|
+
export declare function createDataHandler(operations: DataOperations, authorize: (request: Request, operation: string) => Promise<RequestAccess>): (request: Request) => Promise<Response>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export type { RequestAccess };
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
package/docs/app-authoring.md
CHANGED
|
@@ -1,143 +1,92 @@
|
|
|
1
1
|
# Author a data app
|
|
2
2
|
|
|
3
|
-
Build an exploration that answers the user's question and a story
|
|
4
|
-
|
|
5
|
-
results into their own tools. Exploration, export, and story use the same
|
|
6
|
-
queries, definitions, and evidence.
|
|
3
|
+
Build an exploration that answers the user's question and a story of its strongest
|
|
4
|
+
findings.
|
|
7
5
|
|
|
8
|
-
##
|
|
6
|
+
## Use release-matched starters
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
and preserve its SQL. Otherwise, inspect the data and declare the queries the app needs.
|
|
14
|
-
Declare inspected result aliases in `projections` and derive displays, exports,
|
|
15
|
-
and findings from the typed rows. See [named queries](contract.md#execute-named-queries).
|
|
8
|
+
For an existing app, keep its runtime and structure; apply only the steps needed
|
|
9
|
+
for the requested change. For a new app, use the starter supplied by the authoring workflow, matched to the app's SDK version.
|
|
10
|
+
`@altertable/data-app-examples` ships these templates:
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
| Runtime | Template in `node_modules/@altertable/data-app-examples/templates/` |
|
|
13
|
+
| ----------------------- | ------------------------------------------------------------------- |
|
|
14
|
+
| Hosted / remote / cloud | `starter-data-app/index.tsx` |
|
|
15
|
+
| Local | `starter-local-data-app` |
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
The hosted starter is the canonical query → operation → context → view → dataset
|
|
18
|
+
→ widget → story example. Hosted apps stay in one file with public package imports
|
|
19
|
+
and a literal `defineDataApp()` declaration. Local apps use the same composition
|
|
20
|
+
with their existing server/client wiring. Replace fixture data and connectivity screens; edit
|
|
21
|
+
app-owned files, not installed packages.
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
components. Follow [Compose an exploration](composition.md) to connect filters,
|
|
24
|
-
widgets, layout, and narrative into a coherent investigation, then distill its
|
|
25
|
-
supported findings into a story.
|
|
23
|
+
## Build the exploration
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
1. **Define the question and scope.** Inspect relevant fields, definitions, time
|
|
26
|
+
coverage, and missing or incomplete observations. Establish the population,
|
|
27
|
+
grain, measures, and comparison. Choose a chart that answers the question.
|
|
28
|
+
2. **Replace the starter queries and operation.** Keep supplied registry SQL
|
|
29
|
+
unchanged; otherwise write queries against inspected data. Declare `params`
|
|
30
|
+
and result aliases in `projections`. Validate flat operation inputs, execute
|
|
31
|
+
named queries with `query()`, and derive results from its typed rows.
|
|
32
|
+
3. **Update context and bindings.** Describe definitions and coverage in the data
|
|
33
|
+
context, using the operation's `queryNames` for evidence. Declare each dataset
|
|
34
|
+
and metric once, with stable row keys, raw column values, and shared formats.
|
|
35
|
+
4. **Adapt the view.** Keep related results in one view. Use flat input fields
|
|
36
|
+
matching variable names so `input` and `bindings` can be omitted. Declare
|
|
37
|
+
useful filters in `variables`; `<DataApp>` renders them. Use `defineTimeView()`
|
|
38
|
+
for period-driven analysis and `defineDataView()` otherwise. Split views only
|
|
39
|
+
for independent requests. Keep protected values such as `orgId` backend-owned.
|
|
40
|
+
5. **Compose the exploration.** Lead with the strongest supported finding and
|
|
41
|
+
visible scope. Use `<Stack>` for sections, `<Grid>` for peers, and bound widgets
|
|
42
|
+
from `@altertable/data-app-react`. Keep static explanations outside loading
|
|
43
|
+
boundaries. Use app tabs only for distinct questions and widget `views` only
|
|
44
|
+
for alternate representations of one dataset. Keep default appearance;
|
|
45
|
+
customize when requested. Use custom UI only when bound components cannot
|
|
46
|
+
express the requirement.
|
|
47
|
+
6. **Adapt the story.** Return one to four supported findings using the same
|
|
48
|
+
bindings and displayed input as the exploration. Supply every distinct
|
|
49
|
+
displayed dataset to `<DataApp datasets={...}>` for CSV export.
|
|
28
50
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
status. Prefer a specialized chart when its semantics fit. Check the component's
|
|
33
|
-
input contract before reducing results to generic labels and values; preserve
|
|
34
|
-
supplied query definitions when adapting their results.
|
|
51
|
+
Keep credentials, authorization, and enforced query limits in the host/backend.
|
|
52
|
+
The starter supplies transport and mounting; change them only for an explicit
|
|
53
|
+
integration task.
|
|
35
54
|
|
|
36
|
-
##
|
|
55
|
+
## Verify the app
|
|
37
56
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
| App | Guide |
|
|
41
|
-
| ---------------------------------- | --------------------------------------- |
|
|
42
|
-
| Data app (hosted / remote / cloud) | [Single-file authoring](hosted-apps.md) |
|
|
43
|
-
| Local data app | [Local authoring](local-data-apps.md) |
|
|
44
|
-
|
|
45
|
-
### Use release-matched starters
|
|
46
|
-
|
|
47
|
-
Install `@altertable/data-app-examples` at the same exact version as
|
|
48
|
-
`@altertable/data-app`. Use its installed templates when authoring an app:
|
|
49
|
-
|
|
50
|
-
- Hosted app: `node_modules/@altertable/data-app-examples/templates/starter-data-app/index.tsx`.
|
|
51
|
-
- Local app: `node_modules/@altertable/data-app-examples/templates/starter-local-data-app`.
|
|
52
|
-
Use `copyExample()` from the examples package to copy the local starter and
|
|
53
|
-
restore its `.gitignore`; see the installed examples package's README.
|
|
54
|
-
|
|
55
|
-
Browse the latest [hosted starter](https://github.com/altertable-ai/data-app/blob/main/packages/data-app-examples/templates/starter-data-app/index.tsx)
|
|
56
|
-
and [local starter](https://github.com/altertable-ai/data-app/tree/main/packages/data-app-examples/templates/starter-local-data-app)
|
|
57
|
-
on GitHub. These browsing links track `main`; the installed templates match your SDK release.
|
|
58
|
-
|
|
59
|
-
### Compose the app
|
|
60
|
-
|
|
61
|
-
Lead with a supported finding and expose the relevant fields as filter variables. Use a date filter for questions worth exploring over time,
|
|
62
|
-
or a fixed period snapshot for a deliberate historical analysis.
|
|
63
|
-
|
|
64
|
-
Use relevant user-controlled query parameters as app filters. Map filter values to
|
|
65
|
-
declared parameters through operation inputs, and reuse query defaults when they
|
|
66
|
-
match the initial selection. One filter may supply several parameters, such as a
|
|
67
|
-
date range supplying `start` and `end`. Keep protected parameters, such as `orgId`,
|
|
68
|
-
and internal execution settings out of filter controls.
|
|
69
|
-
|
|
70
|
-
Register inspected tables and fields with `defineDataIdentifiers()` and use
|
|
71
|
-
`<DataIdentifier>` when naming sources. Register terms and query evidence so
|
|
72
|
-
users can inspect the source of each claim.
|
|
73
|
-
|
|
74
|
-
Connect visualizations with introductions and explanations. Use `<TextWidget>`
|
|
75
|
-
for a narrative panel with the standard widget frame, or `<TextContent>` for
|
|
76
|
-
borderless prose. Render the app title, description, and instructions immediately. Use metric and dataset
|
|
77
|
-
bindings for dynamic values and `<DataValue>` for values within static prose.
|
|
78
|
-
Skeletonize only the content that needs data. Reuse bindings and the displayed
|
|
79
|
-
source in narrative so values, formatting, and evidence follow filter changes,
|
|
80
|
-
refresh, and failure.
|
|
81
|
-
|
|
82
|
-
| Task | Documentation |
|
|
83
|
-
| ------------------------------------------------ | ----------------------------------------------------------------- |
|
|
84
|
-
| Choose components, CSS tokens, and styling hooks | [Styling](styling.md) |
|
|
85
|
-
| Define queries, inputs, and typed results | [Operations](contract.md) |
|
|
86
|
-
| Build views, filters, and request states | [Views](views.md) |
|
|
87
|
-
| Introduce and explain visualizations | [Narrative text](widgets.md#narrative-text) |
|
|
88
|
-
| Find formatters and presentation helpers | [App helpers](formatting-and-appearance.md) |
|
|
89
|
-
| Register source names | [Source identifiers](data-context.md#register-source-identifiers) |
|
|
90
|
-
| Choose date and field filters | [Filter variables](variables.md) |
|
|
91
|
-
| Handle refresh and stale results | [Displayed results](views.md#preserve-displayed-results) |
|
|
92
|
-
| Export displayed data as CSV | [CSV export](stories-and-export.md#export-displayed-data-as-csv) |
|
|
93
|
-
| Render widgets and custom visuals | [Widgets](widgets.md) |
|
|
94
|
-
| Bind definitions and source evidence | [Data context](data-context.md#bind-evidence) |
|
|
95
|
-
| Look up props, signatures, and types | [API reference](../REFERENCE.md) |
|
|
96
|
-
|
|
97
|
-
Declare reusable [datasets and metrics](widgets.md#declare-datasets-and-metrics)
|
|
98
|
-
on the view so tables, exports, and stories share values and evidence.
|
|
99
|
-
|
|
100
|
-
Every data app supplies a [story and CSV export](stories-and-export.md)
|
|
101
|
-
from the displayed result. Export all distinct datasets at their displayed grain;
|
|
102
|
-
reuse a dataset when several visuals derive from the same rows. Present the
|
|
103
|
-
findings that answer the user's question, rather than every row or chart.
|
|
104
|
-
Use the [standard layout](layout.md) and built-in toolbar actions.
|
|
105
|
-
|
|
106
|
-
### Organize the exploration
|
|
107
|
-
|
|
108
|
-
Use sections for a focused question and for findings users should compare
|
|
109
|
-
side by side. Add app-level `<Tabs>` from `@altertable/data-app-react/ui` when the exploration has
|
|
110
|
-
distinct analytical questions, such as Overview, Retention, and Segments, each
|
|
111
|
-
with its own context and group of widgets. Lead with the most useful overview
|
|
112
|
-
and label tabs by the question or subject they explore.
|
|
113
|
-
|
|
114
|
-
Use `<VisualizationWidget>`'s `views` for alternate representations of the same
|
|
115
|
-
dataset, such as a chart and its rows. Keep these choices within the widget;
|
|
116
|
-
use filter variables when the user is changing the data scope.
|
|
117
|
-
|
|
118
|
-
Navigation tabs, widget views, and declared data views have different roles.
|
|
119
|
-
A declared view owns inputs, requests, and displayed results; a tab does not
|
|
120
|
-
require a separate data view. Keep related datasets in one view for a coherent
|
|
121
|
-
snapshot. Use independent views and `<DataSection>` boundaries when content
|
|
122
|
-
needs separate requests. Keep filter placement consistent across tabs and make
|
|
123
|
-
each filter's scope clear. Derive findings, story, and export from the displayed
|
|
124
|
-
results and their inputs.
|
|
57
|
+
Run the authoring workflow's validation, then inspect the app:
|
|
125
58
|
|
|
126
|
-
|
|
59
|
+
- Check findings against the source population, units, ordering, and coverage.
|
|
60
|
+
Distinguish measured zero, missing values, and empty results.
|
|
61
|
+
- Change filters and exercise loading, empty, error, refresh, and stale states.
|
|
62
|
+
Narrative, scope, story, and export must agree with the displayed result.
|
|
63
|
+
- Present the story and check exported columns, raw values, filename, and scope.
|
|
64
|
+
- Review app-owned content for clipping and readability at its intended width.
|
|
65
|
+
Check custom layout or CSS at narrow and wide widths; check custom colors in
|
|
66
|
+
both themes.
|
|
127
67
|
|
|
128
|
-
|
|
129
|
-
|
|
68
|
+
When an app fails, use the host's repair or copy action to send observed diagnostics
|
|
69
|
+
together. Repair requests preserve the existing authorization boundary and cover
|
|
70
|
+
only exercised checks and interactions. See [diagnostics and repair](diagnostics.md)
|
|
71
|
+
for host integration.
|
|
130
72
|
|
|
131
|
-
|
|
132
|
-
population, units, ordering, and missing or incomplete observations. Check
|
|
133
|
-
findings against the source and the user's question. Distinguish measured
|
|
134
|
-
zero, unavailable values, and empty results. Check filters, refresh, loading,
|
|
135
|
-
empty, error, and stale states, then present the story. Download CSV from the
|
|
136
|
-
standalone and embedded toolbar and verify its filename, columns, raw values,
|
|
137
|
-
and filter scope against the displayed result. Export and Present story must be
|
|
138
|
-
available once results are shown; initial loading, empty, and initial
|
|
139
|
-
errors keep both actions visible and disabled. Inspect both experiences
|
|
140
|
-
at phone and desktop widths in light and dark themes.
|
|
73
|
+
## Look up only what is missing
|
|
141
74
|
|
|
142
|
-
|
|
143
|
-
|
|
75
|
+
Search [REFERENCE.md](../REFERENCE.md) for the exact symbol first:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
rg '^LineChart\b' REFERENCE.md
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Open only the section needed for a requirement the starter does not cover:
|
|
82
|
+
|
|
83
|
+
| When | Read |
|
|
84
|
+
| -------------------------------------------- | ----------------------------------------------------------------- |
|
|
85
|
+
| Adding categorical, numeric, or time filters | [Variables](variables.md) |
|
|
86
|
+
| Adding a chart or narrative binding | [Widgets](widgets.md) |
|
|
87
|
+
| Adding a detail destination | [Detail views](views.md#detail-destinations) |
|
|
88
|
+
| Registering physical sources | [Source identifiers](data-context.md#register-source-identifiers) |
|
|
89
|
+
| Customizing appearance or CSS | [Formatting](formatting-and-appearance.md), [styling](styling.md) |
|
|
90
|
+
|
|
91
|
+
Keep the starter's working pattern when it meets the requirement. Host integration
|
|
92
|
+
guides apply only when building or changing a host.
|