@altertable/data-app 0.71.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.
Files changed (130) hide show
  1. package/AGENTS.md +5 -61
  2. package/CONTRIBUTING.md +93 -173
  3. package/README.md +3 -3
  4. package/REFERENCE.md +30 -341
  5. package/dist/chunks/contract-BeLPJwlO.js +558 -0
  6. package/dist/chunks/contract-BeLPJwlO.js.map +1 -0
  7. package/dist/chunks/contract-Di8SP74I.js +462 -0
  8. package/dist/chunks/contract-Di8SP74I.js.map +1 -0
  9. package/dist/chunks/format-BdFlv_xa.js +148 -0
  10. package/dist/chunks/format-BdFlv_xa.js.map +1 -0
  11. package/dist/chunks/iframe-C3uCZEXh.js +809 -0
  12. package/dist/chunks/iframe-C3uCZEXh.js.map +1 -0
  13. package/dist/chunks/operation-CBxhjNhK.js +131 -0
  14. package/dist/chunks/operation-CBxhjNhK.js.map +1 -0
  15. package/dist/chunks/request-body-H1qPmmTN.js +50 -0
  16. package/dist/chunks/request-body-H1qPmmTN.js.map +1 -0
  17. package/dist/client/index.js +253 -285
  18. package/dist/client/index.js.map +1 -13
  19. package/dist/core/appearance.js +171 -162
  20. package/dist/core/appearance.js.map +1 -10
  21. package/dist/core/config.js +49 -11
  22. package/dist/core/config.js.map +1 -9
  23. package/dist/core/contract.js +3 -73
  24. package/dist/core/format.js +1 -26
  25. package/dist/index.js +1 -12
  26. package/dist/internal.js +352 -397
  27. package/dist/internal.js.map +1 -15
  28. package/dist/server/index.js +85 -97
  29. package/dist/server/index.js.map +1 -10
  30. package/dist/types/chunks/appearance.d.ts +45 -0
  31. package/dist/types/chunks/contract.d.ts +720 -0
  32. package/dist/types/chunks/index.d.ts +189 -0
  33. package/dist/types/client/index.d.ts +3 -13
  34. package/dist/types/core/appearance.d.ts +2 -42
  35. package/dist/types/core/config.d.ts +44 -48
  36. package/dist/types/core/contract.d.ts +2 -114
  37. package/dist/types/core/format.d.ts +44 -17
  38. package/dist/types/index.d.ts +3 -3
  39. package/dist/types/internal.d.ts +312 -22
  40. package/dist/types/server/index.d.ts +15 -4
  41. package/docs/app-authoring.md +72 -112
  42. package/docs/client.md +29 -63
  43. package/docs/composition.md +44 -75
  44. package/docs/contract.md +60 -100
  45. package/docs/data-context.md +35 -61
  46. package/docs/embed.md +83 -55
  47. package/docs/formatting-and-appearance.md +17 -38
  48. package/docs/hosted-apps.md +12 -15
  49. package/docs/layout.md +30 -47
  50. package/docs/local-data-apps.md +7 -7
  51. package/docs/react-embed.md +20 -26
  52. package/docs/react.md +10 -27
  53. package/docs/server-bun.md +3 -28
  54. package/docs/server.md +6 -12
  55. package/docs/stories-and-export.md +38 -40
  56. package/docs/styling.md +14 -22
  57. package/docs/ui-quality.md +5 -5
  58. package/docs/ui.md +68 -70
  59. package/docs/variables.md +142 -254
  60. package/docs/views.md +85 -116
  61. package/docs/widgets.md +100 -153
  62. package/docs/worker.md +15 -27
  63. package/package.json +3 -3
  64. package/dist/chunks/index-5a27erdg.js +0 -54
  65. package/dist/chunks/index-5a27erdg.js.map +0 -10
  66. package/dist/chunks/index-9yxr7nmm.js +0 -742
  67. package/dist/chunks/index-9yxr7nmm.js.map +0 -17
  68. package/dist/chunks/index-j5q5n3ra.js +0 -151
  69. package/dist/chunks/index-j5q5n3ra.js.map +0 -10
  70. package/dist/chunks/index-q75zm3a7.js +0 -153
  71. package/dist/chunks/index-q75zm3a7.js.map +0 -11
  72. package/dist/chunks/index-vhaec7m5.js +0 -30
  73. package/dist/chunks/index-vhaec7m5.js.map +0 -10
  74. package/dist/chunks/index-zp78caex.js +0 -1047
  75. package/dist/chunks/index-zp78caex.js.map +0 -19
  76. package/dist/core/contract.js.map +0 -9
  77. package/dist/core/format.js.map +0 -9
  78. package/dist/index.js.map +0 -9
  79. package/dist/types/client/annotations.d.ts +0 -27
  80. package/dist/types/client/data-client.d.ts +0 -43
  81. package/dist/types/client/download.d.ts +0 -5
  82. package/dist/types/client/iframe.d.ts +0 -59
  83. package/dist/types/client/location.d.ts +0 -13
  84. package/dist/types/client/logger.d.ts +0 -14
  85. package/dist/types/client/messages.d.ts +0 -7
  86. package/dist/types/client/navigation.d.ts +0 -15
  87. package/dist/types/client/transport.d.ts +0 -15
  88. package/dist/types/core/annotations.d.ts +0 -99
  89. package/dist/types/core/bridge-endpoint.d.ts +0 -21
  90. package/dist/types/core/bridge.d.ts +0 -172
  91. package/dist/types/core/data-view.d.ts +0 -46
  92. package/dist/types/core/date-format.d.ts +0 -24
  93. package/dist/types/core/date-range.d.ts +0 -20
  94. package/dist/types/core/dimension-source.d.ts +0 -64
  95. package/dist/types/core/dimension.d.ts +0 -71
  96. package/dist/types/core/facets.d.ts +0 -13
  97. package/dist/types/core/filters.d.ts +0 -45
  98. package/dist/types/core/invariant.d.ts +0 -2
  99. package/dist/types/core/keys.d.ts +0 -2
  100. package/dist/types/core/logger.d.ts +0 -12
  101. package/dist/types/core/messages.d.ts +0 -62
  102. package/dist/types/core/navigation.d.ts +0 -11
  103. package/dist/types/core/operation-types.d.ts +0 -80
  104. package/dist/types/core/operation.d.ts +0 -20
  105. package/dist/types/core/presentation.d.ts +0 -9
  106. package/dist/types/core/queries.d.ts +0 -84
  107. package/dist/types/core/reading.d.ts +0 -17
  108. package/dist/types/core/uuid.d.ts +0 -2
  109. package/dist/types/core/variables.d.ts +0 -133
  110. package/dist/types/server/handler.d.ts +0 -13
  111. package/dist/types/server/request-body.d.ts +0 -4
  112. package/examples/starter-data-app/index.tsx +0 -193
  113. package/examples/starter-local-data-app/.bun-version +0 -1
  114. package/examples/starter-local-data-app/.node-version +0 -1
  115. package/examples/starter-local-data-app/.oxfmtrc.json +0 -4
  116. package/examples/starter-local-data-app/.oxlintrc.json +0 -33
  117. package/examples/starter-local-data-app/AGENTS.md +0 -22
  118. package/examples/starter-local-data-app/README.md +0 -56
  119. package/examples/starter-local-data-app/app.ts +0 -28
  120. package/examples/starter-local-data-app/bunfig.toml +0 -2
  121. package/examples/starter-local-data-app/package.json +0 -35
  122. package/examples/starter-local-data-app/src/App.tsx +0 -8
  123. package/examples/starter-local-data-app/src/assets.d.ts +0 -1
  124. package/examples/starter-local-data-app/src/data-context.ts +0 -21
  125. package/examples/starter-local-data-app/src/favicon.svg +0 -13
  126. package/examples/starter-local-data-app/src/index.html +0 -14
  127. package/examples/starter-local-data-app/src/main.tsx +0 -7
  128. package/examples/starter-local-data-app/src/operations.ts +0 -6
  129. package/examples/starter-local-data-app/src/server.ts +0 -6
  130. package/examples/starter-local-data-app/tsconfig.json +0 -21
@@ -1,22 +1,312 @@
1
- /** Shared implementation for the coordinated data-app packages; not an app authoring API. */
2
- export { downloadBlob } from './client/download.js';
3
- export { localFrameBridge } from './client/iframe.js';
4
- export { createBridgeEndpoint } from './core/bridge-endpoint.js';
5
- export { type BridgeDiagnostic, type BridgeEventMessage, MAX_PENDING, PARENT_PARAM, REQUEST_TIMEOUT_MS, validId, } from './core/bridge.js';
6
- export { type DataView, type DisplayedSnapshot, displayedSnapshot, resolveDataView, } from './core/data-view.js';
7
- export { type DatePreset, type DatePresetId, type DateRange, availableDatePresets, inclusiveDays, withinBounds, } from './core/date-range.js';
8
- export { type DimensionFilterSettings, type DimensionValue, dimensionMemberKey, } from './core/dimension.js';
9
- export { numberOperatorLabels } from './core/filters.js';
10
- export { invariant } from './core/invariant.js';
11
- export { toDataOperationFailure } from './core/operation.js';
12
- export { type DataAppPresentation, isDataAppPresentation, } from './core/presentation.js';
13
- export { type DataReading, type MetricReading, type MetricValues, } from './core/reading.js';
14
- export { randomUuid } from './core/uuid.js';
15
- export { type AppVariable, type AppVariableValues, type ChoiceOption, type ChoiceVariable, type DateRangeSelection, type DateRangeVariable, type DateRangeVariableOptions, type HistoryMode, type MultiChoiceVariable, type SearchVariable, type VariableCollection, type VariablePresentation, choiceVariable, dateRangeVariable, defineAppVariables, multiChoiceVariable, searchVariable, validateChoiceOptions, } from './core/variables.js';
16
- export { RequestBodyTooLargeError, readRequestBody, } from './server/request-body.js';
17
- export { KEY_SEPARATOR } from './core/keys.js';
18
- export { type CheckedFacetContexts, type CheckedVariableDeclarations, } from './core/variables.js';
19
- export { type IsUnion } from './core/queries.js';
20
- export { facetSource, type FacetVariable } from './core/facets.js';
21
- export { createDimensionFilter, type DimensionSelectionVariable, } from './core/dimension.js';
22
- export { dimensionSource, type SourceDimensionVariable, } from './core/dimension-source.js';
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 { b as LogEntry, u as localFrameBridge } 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, 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
- * Portable request handling with app-supplied authorization.
3
- * @module @altertable/data-app/server
4
- * @see https://github.com/altertable-ai/data-app/blob/main/docs/server.md
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 { createDataHandler, type RequestAccess } from './handler.js';
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
@@ -1,127 +1,87 @@
1
1
  # Author a data app
2
2
 
3
- Build an exploration that answers the user's question and a story that presents
4
- its strongest findings. Include CSV export so users can take the displayed
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
- ## Inspect the data
6
+ ## Use release-matched starters
9
7
 
10
- Declare the query source of truth with `defineDataApp()`. Generate
11
- operations with `dataApp.defineOperation()` and execute queries by
12
- name with parameter values. When a query registry is supplied, use only its queries
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
- Inspect the relevant catalogs, tables, and fields, their time coverage, and
18
- existing definitions. Choose a question the available data can answer.
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
- ## Compose the exploration
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
- Plan the question, analytical sequence, and role of each display before choosing
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
- ## Choose the visualizations
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
- Before implementing queries and rendering, identify the question each visual
30
- answers, [choose its component](widgets.md#choose-a-visualization), and establish
31
- the required result shape: population, grain, units, ordering, and observation
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
- ## Build the exploration
55
+ ## Verify the app
37
56
 
38
- Choose the execution path:
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
- Lead with a supported finding and expose the relevant fields as filter variables. Use a date filter for questions worth exploring over time,
46
- or a fixed period snapshot for a deliberate historical analysis.
47
-
48
- Use relevant user-controlled query parameters as app filters. Map filter values to
49
- declared parameters through operation inputs, and reuse query defaults when they
50
- match the initial selection. One filter may supply several parameters, such as a
51
- date range supplying `start` and `end`. Keep protected parameters, such as `orgId`,
52
- and internal execution settings out of filter controls.
53
-
54
- Register inspected tables and fields with `defineDataIdentifiers()` and use
55
- `<DataIdentifier>` when naming sources. Register terms and query evidence so
56
- users can inspect the source of each claim.
57
-
58
- Connect visualizations with introductions and explanations. Use `<TextWidget>`
59
- for a narrative panel with the standard widget frame, or `<TextContent>` for
60
- borderless prose. Render the app title, description, and instructions immediately. Use metric and dataset
61
- bindings for dynamic values and `<DataValue>` for values within static prose.
62
- Skeletonize only the content that needs data. Reuse bindings and the displayed
63
- source in narrative so values, formatting, and evidence follow filter changes,
64
- refresh, and failure.
65
-
66
- | Task | Documentation |
67
- | ------------------------------------------------ | ----------------------------------------------------------------- |
68
- | Choose components, CSS tokens, and styling hooks | [Styling](styling.md) |
69
- | Define queries, inputs, and typed results | [Operations](contract.md) |
70
- | Build views, filters, and request states | [Views](views.md) |
71
- | Introduce and explain visualizations | [Narrative text](widgets.md#narrative-text) |
72
- | Find formatters and presentation helpers | [App helpers](formatting-and-appearance.md) |
73
- | Register source names | [Source identifiers](data-context.md#register-source-identifiers) |
74
- | Choose date and field filters | [Filter variables](variables.md) |
75
- | Handle refresh and stale results | [Displayed results](views.md#preserve-displayed-results) |
76
- | Export displayed data as CSV | [CSV export](stories-and-export.md#export-displayed-data-as-csv) |
77
- | Render widgets and custom visuals | [Widgets](widgets.md) |
78
- | Bind definitions and source evidence | [Data context](data-context.md#bind-evidence) |
79
- | Look up props, signatures, and types | [API reference](../REFERENCE.md) |
80
-
81
- Declare reusable [datasets and metrics](widgets.md#declare-datasets-and-metrics)
82
- on the view so tables, exports, and stories share values and evidence.
83
-
84
- Every data app supplies a [story and CSV export](stories-and-export.md)
85
- from the displayed result. Export all distinct datasets at their displayed grain;
86
- reuse a dataset when several visuals derive from the same rows. Present the
87
- findings that answer the user's question, rather than every row or chart.
88
- Use the [standard layout](layout.md) and built-in toolbar actions.
89
-
90
- ### Organize the exploration
91
-
92
- Use sections for a focused question and for findings users should compare
93
- side by side. Add app-level `<Tabs>` from `@altertable/data-app-react/ui` when the exploration has
94
- distinct analytical questions, such as Overview, Retention, and Segments, each
95
- with its own context and group of widgets. Lead with the most useful overview
96
- and label tabs by the question or subject they explore.
97
-
98
- Use `<VisualizationWidget>`'s `views` for alternate representations of the same
99
- dataset, such as a chart and its rows. Keep these choices within the widget;
100
- use filter variables when the user is changing the data scope.
101
-
102
- Navigation tabs, widget views, and declared data views have different roles.
103
- A declared view owns inputs, requests, and displayed results; a tab does not
104
- require a separate data view. Keep related datasets in one view for a coherent
105
- snapshot. Use independent views and `<DataSection>` boundaries when content
106
- needs separate requests. Keep filter placement consistent across tabs and make
107
- each filter's scope clear. Derive findings, story, and export from the displayed
108
- results and their inputs.
57
+ Run the authoring workflow's validation, then inspect the app:
109
58
 
110
- ## Verify the app
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.
111
67
 
112
- Follow the [UI quality contract](ui-quality.md) for hierarchy, responsive
113
- composition, typography, and control states.
68
+ ## Look up only what is missing
114
69
 
115
- Verify that each visual answers its intended question and preserves the source
116
- population, units, ordering, and missing or incomplete observations. Check
117
- findings against the source and the user's question. Distinguish measured
118
- zero, unavailable values, and empty results. Check filters, refresh, loading,
119
- empty, error, and stale states, then present the story. Download CSV from the
120
- standalone and embedded toolbar and verify its filename, columns, raw values,
121
- and filter scope against the displayed result. Export and Present story must be
122
- available once results are shown; initial loading, empty, and initial
123
- errors keep both actions visible and disabled. Inspect both experiences
124
- at phone and desktop widths in light and dark themes.
70
+ Search [REFERENCE.md](../REFERENCE.md) for the exact symbol first:
125
71
 
126
- Keep credentials, authorization, and enforced query limits in the host/backend.
127
- Edit app-owned files; installed package files are dependencies.
72
+ ```sh
73
+ rg '^LineChart\b' REFERENCE.md
74
+ ```
75
+
76
+ Open only the section needed for a requirement the starter does not cover:
77
+
78
+ | When | Read |
79
+ | -------------------------------------------- | ----------------------------------------------------------------- |
80
+ | Adding categorical, numeric, or time filters | [Variables](variables.md) |
81
+ | Adding a chart or narrative binding | [Widgets](widgets.md) |
82
+ | Adding a detail destination | [Detail views](views.md#detail-destinations) |
83
+ | Registering physical sources | [Source identifiers](data-context.md#register-source-identifiers) |
84
+ | Customizing appearance or CSS | [Formatting](formatting-and-appearance.md), [styling](styling.md) |
85
+
86
+ Keep the starter's working pattern when it meets the requirement. Host integration
87
+ guides apply only when building or changing a host.