@altertable/data-app 0.73.0 → 0.75.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 (53) hide show
  1. package/AGENTS.md +11 -3
  2. package/CONTRIBUTING.md +54 -7
  3. package/REFERENCE.md +178 -24
  4. package/dist/chunks/{contract-BeLPJwlO.js → contract-B3s0ybE2.js} +179 -34
  5. package/dist/chunks/contract-B3s0ybE2.js.map +1 -0
  6. package/dist/chunks/{contract-Di8SP74I.js → contract-DcPjfm0R.js} +255 -4
  7. package/dist/chunks/contract-DcPjfm0R.js.map +1 -0
  8. package/dist/chunks/{iframe-C3uCZEXh.js → diagnostics-DVwQ5PDK.js} +161 -3
  9. package/dist/chunks/diagnostics-DVwQ5PDK.js.map +1 -0
  10. package/dist/chunks/format-5hMYUWk3.js +793 -0
  11. package/dist/chunks/format-5hMYUWk3.js.map +1 -0
  12. package/dist/chunks/{operation-CBxhjNhK.js → operation-CGuN7Zcb.js} +10 -7
  13. package/dist/chunks/operation-CGuN7Zcb.js.map +1 -0
  14. package/dist/client/index.js +73 -7
  15. package/dist/client/index.js.map +1 -1
  16. package/dist/core/config.js +4 -3
  17. package/dist/core/config.js.map +1 -1
  18. package/dist/core/contract.js +4 -3
  19. package/dist/core/format.js +1 -1
  20. package/dist/internal.js +8 -7
  21. package/dist/internal.js.map +1 -1
  22. package/dist/server/index.js +3 -3
  23. package/dist/server/index.js.map +1 -1
  24. package/dist/types/chunks/contract.d.ts +168 -10
  25. package/dist/types/chunks/date-time-range-value.d.ts +46 -0
  26. package/dist/types/chunks/index.d.ts +64 -2
  27. package/dist/types/client/index.d.ts +3 -3
  28. package/dist/types/core/config.d.ts +6 -4
  29. package/dist/types/core/contract.d.ts +3 -2
  30. package/dist/types/core/format.d.ts +20 -1
  31. package/dist/types/index.d.ts +3 -2
  32. package/dist/types/internal.d.ts +9 -4
  33. package/dist/types/server/index.d.ts +2 -2
  34. package/docs/app-authoring.md +51 -14
  35. package/docs/composition.md +4 -23
  36. package/docs/contract.md +41 -9
  37. package/docs/diagnostics.md +82 -0
  38. package/docs/embed.md +41 -0
  39. package/docs/hosted-apps.md +7 -4
  40. package/docs/local-data-apps.md +17 -2
  41. package/docs/react.md +6 -3
  42. package/docs/stories-and-export.md +14 -5
  43. package/docs/ui-quality.md +3 -2
  44. package/docs/ui.md +77 -1
  45. package/docs/variables.md +61 -0
  46. package/docs/views.md +2 -2
  47. package/package.json +3 -2
  48. package/dist/chunks/contract-BeLPJwlO.js.map +0 -1
  49. package/dist/chunks/contract-Di8SP74I.js.map +0 -1
  50. package/dist/chunks/format-BdFlv_xa.js +0 -148
  51. package/dist/chunks/format-BdFlv_xa.js.map +0 -1
  52. package/dist/chunks/iframe-C3uCZEXh.js.map +0 -1
  53. package/dist/chunks/operation-CBxhjNhK.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Dt as HistoryMode, Et as AppLocation, Qt as KnownRecord, Zt as IsUnion, _ as MessageRoutes, _n as OutputOf, b as RoutedMessage, h as MessageOutput, ln as DataOperations, m as MessageInput, mn as Lakehouse, n as DataAppAnnotationDraft, pn as InputOf, rn as QueryParameters, un as DataQueryBody, vn as QueryResult, y as MessageTransport, yn as TransportResponse } from "./contract.js";
1
+ import { D as RoutedMessage, Dn as DataOperations, E as MessageTransport, Fn as OutputOf, Ft as HistoryMode, In as QueryResult, Ln as TransportResponse, Mn as Lakehouse, On as DataQueryBody, Pt as AppLocation, S as MessageOutput, hn as KnownRecord, jn as InputOf, l as DataAppAnnotationDraft, mn as IsUnion, n as ExternalLinkModifiers, r as ExternalLinkResult, w as MessageRoutes, x as MessageInput, xn as QueryParameters } from "./contract.js";
2
2
  //#region src/core/logger.d.ts
3
3
  /** Host-owned log sink; compatible with console and frontend createLogger(). */
4
4
  type DataAppLogger = {
@@ -81,6 +81,13 @@ declare function createIframeTransport({ parentOrigin, window: frame, timeoutMs,
81
81
  mode?: 'url' | 'bundle';
82
82
  loadScript?: (javascript: string) => void;
83
83
  }): {
84
+ diagnostics: {
85
+ snapshot: () => AppDiagnosticReport;
86
+ subscribe: (listener: () => void) => () => void;
87
+ record: (kind: AppFailure['kind'], name: string, error: unknown, identity?: string) => void;
88
+ clear: (kind: AppFailure['kind'], name: string, identity?: string) => void;
89
+ begin: () => () => void;
90
+ };
84
91
  logger: DataAppLogger;
85
92
  request: (message: RoutedMessage, signal?: AbortSignal) => Promise<unknown>;
86
93
  transport: (operation: string, input: unknown, signal?: AbortSignal) => Promise<TransportResponse>;
@@ -113,6 +120,13 @@ declare function localFrameBridge(window?: Window): LocalBridge | undefined;
113
120
  declare function installDataAppTransport(bridge: ReturnType<typeof createIframeTransport>, frame?: Window): () => void;
114
121
  /** The bootstrap installs this before executing app code. URL apps can install an explicit connection. */
115
122
  declare function getDataAppTransport(frame?: Window): {
123
+ diagnostics: {
124
+ snapshot: () => AppDiagnosticReport;
125
+ subscribe: (listener: () => void) => () => void;
126
+ record: (kind: AppFailure['kind'], name: string, error: unknown, identity?: string) => void;
127
+ clear: (kind: AppFailure['kind'], name: string, identity?: string) => void;
128
+ begin: () => () => void;
129
+ };
116
130
  logger: DataAppLogger;
117
131
  request: (message: RoutedMessage, signal?: AbortSignal) => Promise<unknown>;
118
132
  transport: (operation: string, input: unknown, signal?: AbortSignal) => Promise<TransportResponse>;
@@ -185,5 +199,53 @@ declare function createAnnotationClient(transport: MessageTransport): {
185
199
  }): Promise<null>;
186
200
  };
187
201
  //#endregion
188
- export { DataTransport as _, getDataAppNavigation as a, LogEntry as b, getDataAppTransport as c, DataAppLocation as d, DataClient as f, DataAppError as g, createDataClient as h, createDataAppNavigation as i, installDataAppTransport as l, DataResponse as m, createMessageClient as n, IframeTransport as o, DataClientOptions as p, DataAppNavigation as r, createIframeTransport as s, createAnnotationClient as t, localFrameBridge as u, createHttpTransport as v, DataAppLogger as y };
202
+ //#region src/core/diagnostics.d.ts
203
+ /** Failures observed during the checks and interactions actually exercised. */
204
+ type AppFailure = {
205
+ /** Mounted widget identity when multiple widgets share a label. */
206
+ id?: string;
207
+ kind: 'query' | 'operation' | 'render';
208
+ name: string;
209
+ message: string;
210
+ /** Sanitized filename and one-based line/column. Source contents are never included. */
211
+ source?: {
212
+ file: string;
213
+ line: number;
214
+ column: number;
215
+ };
216
+ };
217
+ type AppDiagnosticReport = {
218
+ /** Current observed failures, limited to 30 entries. */
219
+ failures: AppFailure[];
220
+ /** Observed checks that have not finished. */
221
+ pending: number;
222
+ /** Failures omitted from this report's bounded failure list. */
223
+ truncated: number;
224
+ };
225
+ /** Validate and project iframe reports. Unknown fields (including query inputs) never cross this boundary. */
226
+ declare function parseAppDiagnosticReport(value: unknown): AppDiagnosticReport;
227
+ //#endregion
228
+ //#region src/client/diagnostics.d.ts
229
+ /** Lightweight live observations only. No query values or result rows are retained. */
230
+ type Diagnostics = {
231
+ snapshot: () => AppDiagnosticReport;
232
+ subscribe: (listener: () => void) => () => void;
233
+ record: (kind: AppFailure['kind'], name: string, error: unknown, identity?: string) => void;
234
+ clear: (kind: AppFailure['kind'], name: string, identity?: string) => void;
235
+ begin: () => () => void;
236
+ };
237
+ declare const appDiagnostics: Diagnostics;
238
+ //#endregion
239
+ //#region src/client/external-link.d.ts
240
+ type NavigationOptions = {
241
+ signal?: AbortSignal;
242
+ };
243
+ /** Request a new tab through the host, or open directly when standalone. Browser settings determine placement. */
244
+ declare function navigateNewTab(url: string, options?: NavigationOptions): Promise<ExternalLinkResult>;
245
+ /** Request a separate window through the host, or a popup when standalone. Browser settings determine placement. */
246
+ declare function navigateNewWindow(url: string, options?: NavigationOptions): Promise<ExternalLinkResult>;
247
+ /** Send only modifier keys, never the DOM/React event. Shift requests a window, Ctrl/Cmd a tab; otherwise no navigation. */
248
+ declare function navigateNewWindowOrTab(url: string, event: ExternalLinkModifiers, options?: NavigationOptions): Promise<ExternalLinkResult>;
249
+ //#endregion
250
+ export { DataAppError as C, LogEntry as D, DataAppLogger as E, createDataClient as S, createHttpTransport as T, localFrameBridge as _, AppDiagnosticReport as a, DataClientOptions as b, createAnnotationClient as c, createDataAppNavigation as d, getDataAppNavigation as f, installDataAppTransport as g, getDataAppTransport as h, appDiagnostics as i, createMessageClient as l, createIframeTransport as m, navigateNewWindow as n, AppFailure as o, IframeTransport as p, navigateNewWindowOrTab as r, parseAppDiagnosticReport as s, navigateNewTab as t, DataAppNavigation as u, DataAppLocation as v, DataTransport as w, DataResponse as x, DataClient as y };
189
251
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
- import { Et as AppLocation, _n as OutputOf, pn as InputOf } from "../chunks/contract.js";
2
- import { _ as DataTransport, a as getDataAppNavigation, c as getDataAppTransport, d as DataAppLocation, f as DataClient, g as DataAppError, h as createDataClient, i as createDataAppNavigation, l as installDataAppTransport, m as DataResponse, n as createMessageClient, o as IframeTransport, p as DataClientOptions, r as DataAppNavigation, s as createIframeTransport, t as createAnnotationClient, v as createHttpTransport, y as DataAppLogger } from "../chunks/index.js";
3
- export { type AppLocation, DataAppError, type DataAppLocation, type DataAppLogger, type DataAppNavigation, type DataClient, type DataClientOptions, type DataResponse, type DataTransport, type IframeTransport, type InputOf, type OutputOf, createAnnotationClient, createDataAppNavigation, createDataClient, createHttpTransport, createIframeTransport, createMessageClient, getDataAppNavigation, getDataAppTransport, installDataAppTransport };
1
+ import { Fn as OutputOf, Pt as AppLocation, jn as InputOf } from "../chunks/contract.js";
2
+ import { C as DataAppError, E as DataAppLogger, S as createDataClient, T as createHttpTransport, a as AppDiagnosticReport, b as DataClientOptions, c as createAnnotationClient, d as createDataAppNavigation, f as getDataAppNavigation, g as installDataAppTransport, h as getDataAppTransport, i as appDiagnostics, l as createMessageClient, m as createIframeTransport, n as navigateNewWindow, o as AppFailure, p as IframeTransport, r as navigateNewWindowOrTab, t as navigateNewTab, u as DataAppNavigation, v as DataAppLocation, w as DataTransport, x as DataResponse, y as DataClient } from "../chunks/index.js";
3
+ export { type AppDiagnosticReport, type AppFailure, type AppLocation, DataAppError, type DataAppLocation, type DataAppLogger, type DataAppNavigation, type DataClient, type DataClientOptions, type DataResponse, type DataTransport, type IframeTransport, type InputOf, type OutputOf, appDiagnostics, createAnnotationClient, createDataAppNavigation, createDataClient, createHttpTransport, createIframeTransport, createMessageClient, getDataAppNavigation, getDataAppTransport, installDataAppTransport, navigateNewTab, navigateNewWindow, navigateNewWindowOrTab };
@@ -1,4 +1,5 @@
1
- import { $t as QueryDefinitions, Bt as DimensionSourceQueryName, L as defineOperation, M as OperationDefinition, Vt as SourceDimensionVariable, Xt as CheckedQueries, an as QueryRow, en as QueryField, in as QueryProjections, nn as QueryParameterValue, on as QuerySnapshot, sn as QueryValueType, tn as QueryParameter, zt as DimensionSourceConfig } from "../chunks/contract.js";
1
+ import { c as DateTimeRange, d as RelativeOffset, f as RelativeUnit, l as RelativeAnchor, s as AbsoluteOrRelativeDateTime, u as RelativeDateTime } from "../chunks/date-time-range-value.js";
2
+ import { Cn as QueryRow, Jt as DimensionSourceQueryName, Sn as QueryProjections, Tn as QueryValueType, W as defineOperation, Yt as SourceDimensionVariable, _n as QueryDefinitions, bn as QueryParameterValue, pn as CheckedQueries, qt as DimensionSourceConfig, vn as QueryField, wn as QuerySnapshot, yn as QueryParameter, z as OperationDefinition } from "../chunks/contract.js";
2
3
  import { o as AppearanceOptions } from "../chunks/appearance.js";
3
4
  //#region src/core/config.d.ts
4
5
  export type DataAppConfig<Queries extends QueryDefinitions = QueryDefinitions> = {
@@ -49,9 +50,10 @@ export type DataAppDefinition<Queries extends QueryDefinitions = QueryDefinition
49
50
  * references, and callbacks. Extraction reads literals without executing app code.
50
51
  * TypeScript and runtime query rules own configuration validation.
51
52
  *
52
- * SQL passes unchanged to the backend, which interprets placeholders such as `$orgId`.
53
+ * Scalar placeholders pass to the backend. Datetime-range bound references ($period.from/to)
54
+ * expand to DuckDB timestamp expressions while the range is bound as JSON.
53
55
  * Declare each parameter's type and optional defaultValue.
54
- * Values are finite numbers, strings, booleans, or null, never SQL fragments or identifiers.
56
+ * Values are scalars or declared datetime ranges, never SQL fragments or identifiers.
55
57
  * Host queryParams supply protected values; callers cannot override them.
56
58
  */
57
59
  export declare function defineDataApp<const Queries extends QueryDefinitions>(config: DataAppConfig<Queries> & {
@@ -59,5 +61,5 @@ export declare function defineDataApp<const Queries extends QueryDefinitions>(co
59
61
  }): DataAppDefinition<Queries>;
60
62
  export declare function dataAppTitle(config: Pick<DataAppConfig, 'title' | 'scope'>): string;
61
63
  //#endregion
62
- export type { QueryDefinitions, QueryField, QueryParameter, QueryParameterValue, QueryProjections, QueryRow, QueryValueType };
64
+ export type { AbsoluteOrRelativeDateTime, DateTimeRange, QueryDefinitions, QueryField, QueryParameter, QueryParameterValue, QueryProjections, QueryRow, QueryValueType, RelativeAnchor, RelativeDateTime, RelativeOffset, RelativeUnit };
63
65
  //# sourceMappingURL=config.d.ts.map
@@ -1,2 +1,3 @@
1
- import { $t as QueryDefinitions, A as DateRangeContractOptions, At as BooleanSelection, B as parseDateRangeInput, C as dataAppRoutes, D as sqlQueryRoute, E as navigationUpdateRoute, F as connectionCheck, Ft as numberFilter, G as DimensionFilterOptions, H as parseLabel, I as defineDateRangeContract, J as DimensionOption, Kt as DateRange, L as defineOperation, Lt as parseBooleanSelection, M as OperationDefinition, Mt as NumberOperator, N as RegisteredQuery, Nt as NumberSelection, O as ConnectionOperation, Ot as NavigationUpdate, P as ReportingPeriod, Pt as booleanFilter, Q as DimensionVariable, R as defineQueryNames, Rt as parseNumberSelection, S as createMessageRouter, T as defineMessageRoute, U as parseTrue, Ut as variableInput, V as parseEmptyInput, W as previousDateRange, Y as DimensionSelection, _ as MessageRoutes, a as annotationEditorStateRoute, an as QueryRow, b as RoutedMessage, c as annotationUpdateRoute, cn as DataOperation, d as MessageContext, dn as DataQueryInput, en as QueryField, et as dimensionFilter, f as MessageDispatcher, fn as DisclosedQuery, g as MessageRoute, gn as OperationContracts, h as MessageOutput, hn as OperationContext, i as annotationDraftRoute, in as QueryProjections, it as parseFacetOptions, j as DateRangeRequest, jt as NumberFilter, k as DateRangeContract, kt as BooleanFilter, l as parseDataAppAnnotationDraft, ln as DataOperations, m as MessageInput, mn as Lakehouse, n as DataAppAnnotationDraft, nn as QueryParameterValue, nt as dimensionPredicate, o as annotationModeRoute, p as MessageHandlers, q as DimensionMember, r as DataAppAnnotationPresentation, rn as QueryParameters, rt as parseDimensionSelection, s as annotationSendRoute, sn as QueryValueType, t as DataSourceError, tn as QueryParameter, u as DataQueryRoute, un as DataQueryBody, v as MessageRoutingError, vn as QueryResult, w as defineDataQueryRoute, x as SqlQueryInput, y as MessageTransport, yn as TransportResponse, z as parseCount } from "../chunks/contract.js";
2
- export { type BooleanFilter, type BooleanSelection, type ConnectionOperation, type DataAppAnnotationDraft, type DataAppAnnotationPresentation, type DataOperation, type DataOperations, type DataQueryBody, type DataQueryInput, type DataQueryRoute, DataSourceError, type DateRangeContract, type DateRangeContractOptions, type DateRange as DateRangeInput, type DateRangeRequest, type DimensionFilterOptions, type DimensionMember, type DimensionOption, type DimensionSelection, type DimensionVariable, type DisclosedQuery, type Lakehouse, type MessageContext, type MessageDispatcher, type MessageHandlers, type MessageInput, type MessageOutput, type MessageRoute, type MessageRoutes, MessageRoutingError, type MessageTransport, type NavigationUpdate, type NumberFilter, type NumberOperator, type NumberSelection, type OperationContext, type OperationContracts, type OperationDefinition, type QueryDefinitions, type QueryField, type QueryParameter, type QueryParameterValue, type QueryParameters, type QueryProjections, type QueryResult, type QueryRow, type QueryValueType, type RegisteredQuery, type ReportingPeriod, type RoutedMessage, type SqlQueryInput, type TransportResponse, annotationDraftRoute, annotationEditorStateRoute, annotationModeRoute, annotationSendRoute, annotationUpdateRoute, booleanFilter, connectionCheck, createMessageRouter, dataAppRoutes, defineDataQueryRoute, defineDateRangeContract, defineMessageRoute, defineOperation, defineQueryNames, dimensionFilter, dimensionPredicate, navigationUpdateRoute, numberFilter, parseBooleanSelection, parseCount, parseDataAppAnnotationDraft, parseDateRangeInput, parseDimensionSelection, parseEmptyInput, parseFacetOptions, parseLabel, parseNumberSelection, parseTrue, previousDateRange, sqlQueryRoute, variableInput };
1
+ import { a as resolveDateTimeRange, c as DateTimeRange, i as parseDateTimeRange, n as formatDateTimeRange, o as serializeDateTimeRange, p as ResolvedDateTimeRange, r as parseDateTimeBound, s as AbsoluteOrRelativeDateTime, t as formatDateTimeBound, u as RelativeDateTime } from "../chunks/date-time-range-value.js";
2
+ import { $ as DimensionFilterOptions, $t as DateTimeRangeComparisonSelection, A as dataAppRoutes, An as DisclosedQuery, B as RegisteredQuery, Bt as NumberOperator, C as MessageRoute, Cn as QueryRow, D as RoutedMessage, Dn as DataOperations, E as MessageTransport, En as DataOperation, F as ConnectionOperation, G as defineQueryNames, Gt as parseBooleanSelection, H as connectionCheck, Ht as booleanFilter, I as DateRangeContract, In as QueryResult, It as NavigationUpdate, J as parseEmptyInput, K as parseCount, Kt as parseNumberSelection, L as DateRangeContractOptions, Ln as TransportResponse, Lt as BooleanFilter, M as defineMessageRoute, Mn as Lakehouse, N as navigationUpdateRoute, Nn as OperationContext, O as SqlQueryInput, On as DataQueryBody, P as sqlQueryRoute, Pn as OperationContracts, Q as dateTimeRangeSql, Qt as DateTimeRangeComparisonRequest, R as DateRangeRequest, Rn as DateTimeRangeContract, Rt as BooleanSelection, S as MessageOutput, Sn as QueryProjections, T as MessageRoutingError, Tn as QueryValueType, U as defineDateRangeContract, Ut as numberFilter, V as ReportingPeriod, Vt as NumberSelection, W as defineOperation, X as parseTrue, Y as parseLabel, Z as previousDateRange, Zt as variableInput, _ as DataQueryRoute, _n as QueryDefinitions, a as OpenExternalLink, an as dateTimeRangePresets, b as MessageHandlers, bn as QueryParameterValue, c as resolveExternalLinkTarget, ct as dimensionFilter, d as annotationDraftRoute, dt as parseDimensionSelection, en as DateTimeRangeComparisonVariable, f as annotationEditorStateRoute, ft as parseFacetOptions, g as parseDataAppAnnotationDraft, h as annotationUpdateRoute, i as ExternalLinkTarget, in as DateTimeRangeVariableOptions, j as defineDataQueryRoute, k as createMessageRouter, kn as DataQueryInput, l as DataAppAnnotationDraft, ln as DateRange, m as annotationSendRoute, n as ExternalLinkModifiers, nn as DateTimeRangePreset, nt as DimensionOption, o as openExternalLinkRoute, on as dateTimeRangeVariable, ot as DimensionVariable, p as annotationModeRoute, q as parseDateRangeInput, r as ExternalLinkResult, rn as DateTimeRangeVariable, rt as DimensionSelection, s as parseExternalUrl, t as DataSourceError, tn as DateTimeRangeComparisonVariableOptions, tt as DimensionMember, u as DataAppAnnotationPresentation, ut as dimensionPredicate, v as MessageContext, vn as QueryField, w as MessageRoutes, x as MessageInput, xn as QueryParameters, y as MessageDispatcher, yn as QueryParameter, z as OperationDefinition, zn as DateTimeRangeRequest, zt as NumberFilter } from "../chunks/contract.js";
3
+ export { type AbsoluteOrRelativeDateTime, type BooleanFilter, type BooleanSelection, type ConnectionOperation, type DataAppAnnotationDraft, type DataAppAnnotationPresentation, type DataOperation, type DataOperations, type DataQueryBody, type DataQueryInput, type DataQueryRoute, DataSourceError, type DateRangeContract, type DateRangeContractOptions, type DateRange as DateRangeInput, type DateRangeRequest, type DateTimeRange, type DateTimeRangeComparisonRequest, type DateTimeRangeComparisonSelection, type DateTimeRangeComparisonVariable, type DateTimeRangeComparisonVariableOptions, type DateTimeRangeContract, type DateTimeRangePreset, type DateTimeRangeRequest, type DateTimeRangeVariable, type DateTimeRangeVariableOptions, type DimensionFilterOptions, type DimensionMember, type DimensionOption, type DimensionSelection, type DimensionVariable, type DisclosedQuery, type ExternalLinkModifiers, type ExternalLinkResult, type ExternalLinkTarget, type Lakehouse, type MessageContext, type MessageDispatcher, type MessageHandlers, type MessageInput, type MessageOutput, type MessageRoute, type MessageRoutes, MessageRoutingError, type MessageTransport, type NavigationUpdate, type NumberFilter, type NumberOperator, type NumberSelection, type OpenExternalLink, type OperationContext, type OperationContracts, type OperationDefinition, type QueryDefinitions, type QueryField, type QueryParameter, type QueryParameterValue, type QueryParameters, type QueryProjections, type QueryResult, type QueryRow, type QueryValueType, type RegisteredQuery, type RelativeDateTime, type ReportingPeriod, type ResolvedDateTimeRange, type RoutedMessage, type SqlQueryInput, type TransportResponse, annotationDraftRoute, annotationEditorStateRoute, annotationModeRoute, annotationSendRoute, annotationUpdateRoute, booleanFilter, connectionCheck, createMessageRouter, dataAppRoutes, dateTimeRangePresets, dateTimeRangeSql, dateTimeRangeVariable, defineDataQueryRoute, defineDateRangeContract, defineMessageRoute, defineOperation, defineQueryNames, dimensionFilter, dimensionPredicate, formatDateTimeBound, formatDateTimeRange, navigationUpdateRoute, numberFilter, openExternalLinkRoute, parseBooleanSelection, parseCount, parseDataAppAnnotationDraft, parseDateRangeInput, parseDateTimeBound, parseDateTimeRange, parseDimensionSelection, parseEmptyInput, parseExternalUrl, parseFacetOptions, parseLabel, parseNumberSelection, parseTrue, previousDateRange, resolveDateTimeRange, resolveExternalLinkTarget, serializeDateTimeRange, sqlQueryRoute, variableInput };
@@ -1,3 +1,22 @@
1
+ import { c as DateTimeRange, d as RelativeOffset, f as RelativeUnit, l as RelativeAnchor, n as formatDateTimeRange, s as AbsoluteOrRelativeDateTime, u as RelativeDateTime } from "../chunks/date-time-range-value.js";
2
+ //#region src/core/date-time-range-parser.d.ts
3
+ type DateTimeRangeParseFailureReason = 'empty' | 'unrecognized' | 'invalid-range' | 'ambiguous';
4
+ type DateTimeRangeParserOptions = {
5
+ /** UTC-encoded reference fields for omitted dates/years. Defaults to the current UTC date/time. */
6
+ now?: Date;
7
+ };
8
+ type ParseDateTimeRangeResult = {
9
+ ok: true;
10
+ range: DateTimeRange;
11
+ normalizedInput: string;
12
+ parser: 'relative' | 'calendar-preset' | 'calendar-range' | 'unix' | 'chrono';
13
+ } | {
14
+ ok: false;
15
+ reason: DateTimeRangeParseFailureReason;
16
+ normalizedInput: string;
17
+ };
18
+ export declare function parseDateTimeRangeInput(input: string, options?: DateTimeRangeParserOptions): ParseDateTimeRangeResult;
19
+ //#endregion
1
20
  //#region src/core/date-format.d.ts
2
21
  /** Formatting for calendar dates and instants without implicit time-zone parsing. */
3
22
  type DateFormatOptions = {
@@ -63,5 +82,5 @@ export declare function formatPercent(ratio: number | null | undefined, options?
63
82
  maximumFractionDigits?: number;
64
83
  }): string;
65
84
  //#endregion
66
- export type { DateFormat, DateFormatOptions, DateTimeFormatOptions };
85
+ export { type AbsoluteOrRelativeDateTime, type DateFormat, type DateFormatOptions, type DateTimeFormatOptions, type DateTimeRange, type DateTimeRangeParseFailureReason, type DateTimeRangeParserOptions, type ParseDateTimeRangeResult, type RelativeAnchor, type RelativeDateTime, type RelativeOffset, type RelativeUnit, formatDateTimeRange };
67
86
  //# sourceMappingURL=format.d.ts.map
@@ -1,3 +1,4 @@
1
- import { $t as QueryDefinitions, an as QueryRow, en as QueryField, in as QueryProjections, nn as QueryParameterValue, sn as QueryValueType, tn as QueryParameter } from "./chunks/contract.js";
1
+ import { c as DateTimeRange, d as RelativeOffset, f as RelativeUnit, l as RelativeAnchor, s as AbsoluteOrRelativeDateTime, u as RelativeDateTime } from "./chunks/date-time-range-value.js";
2
+ import { Cn as QueryRow, Sn as QueryProjections, Tn as QueryValueType, _n as QueryDefinitions, bn as QueryParameterValue, vn as QueryField, yn as QueryParameter } from "./chunks/contract.js";
2
3
  import { DataAppConfig, DataAppDefinition, dataAppTitle, defineDataApp } from "./core/config.js";
3
- export { type DataAppConfig, type DataAppDefinition, type QueryDefinitions, type QueryField, type QueryParameter, type QueryParameterValue, type QueryProjections, type QueryRow, type QueryValueType, dataAppTitle, defineDataApp };
4
+ export { type AbsoluteOrRelativeDateTime, type DataAppConfig, type DataAppDefinition, type DateTimeRange, type QueryDefinitions, type QueryField, type QueryParameter, type QueryParameterValue, type QueryProjections, type QueryRow, type QueryValueType, type RelativeAnchor, type RelativeDateTime, type RelativeOffset, type RelativeUnit, dataAppTitle, defineDataApp };
@@ -1,5 +1,6 @@
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";
1
+ import { a as resolveDateTimeRange, c as DateTimeRange, f as RelativeUnit, i as parseDateTimeRange, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, s as AbsoluteOrRelativeDateTime, t as formatDateTimeBound, u as RelativeDateTime } from "./chunks/date-time-range-value.js";
2
+ import { $t as DateTimeRangeComparisonSelection, At as defineAppVariables, Ct as DateRangeVariableOptions, Dt as VariablePresentation, Et as VariableCollection, Ft as HistoryMode, Mt as searchVariable, Nt as validateChoiceOptions, Ot as choiceVariable, Qt as DateTimeRangeComparisonRequest, R as DateRangeRequest, St as DateRangeVariable, Tt as SearchVariable, Wt as numberOperatorLabels, Xt as dimensionSource, Yt as SourceDimensionVariable, _t as CheckedFacetContexts, an as dateTimeRangePresets, at as DimensionValue, bt as ChoiceVariable, cn as DatePresetId, dn as inclusiveDays, en as DateTimeRangeComparisonVariable, et as DimensionFilterSettings, fn as withinBounds, gn as MAX_QUERY_ROWS, gt as AppVariableValues, ht as AppVariable, in as DateTimeRangeVariableOptions, it as DimensionSelectionVariable, jt as multiChoiceVariable, kt as dateRangeVariable, ln as DateRange, lt as dimensionMemberKey, mn as IsUnion, mt as facetSource, nn as DateTimeRangePreset, on as dateTimeRangeVariable, pt as FacetVariable, rn as DateTimeRangeVariable, sn as DatePreset, st as createDimensionFilter, tn as DateTimeRangeComparisonVariableOptions, u as DataAppAnnotationPresentation, un as availableDatePresets, vt as CheckedVariableDeclarations, wt as MultiChoiceVariable, xt as DateRangeSelection, yt as ChoiceOption, zn as DateTimeRangeRequest } from "./chunks/contract.js";
3
+ import { D as LogEntry, _ as localFrameBridge, s as parseAppDiagnosticReport } from "./chunks/index.js";
3
4
  import { c as Theme } from "./chunks/appearance.js";
4
5
  //#region src/core/bridge.d.ts
5
6
  /** Data app delivery protocol. IDs identify a document, a shell session, and an individual call. */
@@ -292,7 +293,7 @@ type MetricValues = {
292
293
  previous?: number | null;
293
294
  };
294
295
  type MetricReading = DataReading<MetricValues & {
295
- period?: DateRangeRequest;
296
+ period?: DateRangeRequest | DateTimeRangeRequest;
296
297
  }>;
297
298
  //#endregion
298
299
  //#region src/core/uuid.d.ts
@@ -308,5 +309,9 @@ export declare function readRequestBody(request: Request, maxBytes: number): Pro
308
309
  /** Separator for opaque composite keys, independent of URL and DOM ID formats. */
309
310
  export declare const KEY_SEPARATOR = ":";
310
311
  //#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
+ //#region src/core/time-units.d.ts
313
+ /** Fixed durations in UTC-rebased arithmetic; months and years are calendar-dependent. */
314
+ export declare const fixedUnitMilliseconds: Partial<Record<RelativeUnit, number>> & Record<'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK', number>;
315
+ //#endregion
316
+ export { type AbsoluteOrRelativeDateTime, 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 DateTimeRange, type DateTimeRangeComparisonRequest, type DateTimeRangeComparisonSelection, type DateTimeRangeComparisonVariable, type DateTimeRangeComparisonVariableOptions, type DateTimeRangePreset, type DateTimeRangeVariable, type DateTimeRangeVariableOptions, type DimensionFilterSettings, type DimensionSelectionVariable, type DimensionValue, type DisplayedSnapshot, type FacetVariable, type HistoryMode, type IsUnion, MAX_QUERY_ROWS, type MetricReading, type MetricValues, type MultiChoiceVariable, type RelativeDateTime, type SearchVariable, type SourceDimensionVariable, type VariableCollection, type VariablePresentation, availableDatePresets, choiceVariable, createDimensionFilter, dateRangeVariable, dateTimeRangePresets, dateTimeRangeVariable, defineAppVariables, dimensionMemberKey, dimensionSource, facetSource, formatDateTimeBound, formatDateTimeRange, inclusiveDays, localFrameBridge, multiChoiceVariable, numberOperatorLabels, parseAppDiagnosticReport, parseDateTimeBound, parseDateTimeRange, resolveDateTimeRange, searchVariable, serializeDateTimeRange, validateChoiceOptions, withinBounds };
312
317
  //# sourceMappingURL=internal.d.ts.map
@@ -1,9 +1,9 @@
1
- import { ln as DataOperations, mn as Lakehouse, rn as QueryParameters } from "../chunks/contract.js";
1
+ import { Dn as DataOperations, Mn as Lakehouse, xn as QueryParameters } from "../chunks/contract.js";
2
2
  //#region src/server/handler.d.ts
3
3
  /** Authorization result for one viewer request. A hosted adapter must scope its lakehouse client. */
4
4
  type RequestAccess = {
5
5
  lakehouse: Lakehouse;
6
- /** Trusted values shared across queries; each query uses only its declared keys. */
6
+ /** Trusted values shared across queries; each query uses only its declared keys. Datetime ranges use serializeDateTimeRange(); they are decoded and validated before SQL binding. */
7
7
  queryParams?: QueryParameters;
8
8
  };
9
9
  /**
@@ -1,7 +1,7 @@
1
1
  # Author a data app
2
2
 
3
- Build an exploration that answers the user's question and a story of its strongest
4
- findings.
3
+ Use the SDK to connect queries, operations, views, and widgets. The app brief determines the content structure. Component examples do not prescribe
4
+ which sections or features every app must contain.
5
5
 
6
6
  ## Use release-matched starters
7
7
 
@@ -13,20 +13,26 @@ for the requested change. For a new app, use the starter supplied by the authori
13
13
  | ----------------------- | ------------------------------------------------------------------- |
14
14
  | Hosted / remote / cloud | `starter-data-app/index.tsx` |
15
15
  | Local | `starter-local-data-app` |
16
-
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
16
+ | Hosted metric | `starter-metric-data-app/index.tsx` |
17
+ | Hosted Finding | `starter-finding-data-app/index.tsx` |
18
+ | Local metric | `starter-local-metric-data-app` |
19
+ | Local Finding | `starter-local-finding-data-app` |
20
+
21
+ Choose the runtime and use case supplied by the app brief. Each starter is editable
22
+ source; replace fixture queries and sample content before publishing. The hosted starter demonstrates query → operation
23
+ → context → view → dataset → widget composition, including a story example.
24
+ Hosted apps stay in one file with public package imports
19
25
  and a literal `defineDataApp()` declaration. Local apps use the same composition
20
26
  with their existing server/client wiring. Replace fixture data and connectivity screens; edit
21
27
  app-owned files, not installed packages.
22
28
 
23
- ## Build the exploration
29
+ ## Connect data and components
24
30
 
25
31
  1. **Define the question and scope.** Inspect relevant fields, definitions, time
26
32
  coverage, and missing or incomplete observations. Establish the population,
27
33
  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`
34
+ 2. **Replace the starter queries and operation.** Write queries
35
+ against inspected data and preserve supplied metric definitions. Declare `params`
30
36
  and result aliases in `projections`. Validate flat operation inputs, execute
31
37
  named queries with `query()`, and derive results from its typed rows.
32
38
  3. **Update context and bindings.** Describe definitions and coverage in the data
@@ -37,21 +43,45 @@ app-owned files, not installed packages.
37
43
  useful filters in `variables`; `<DataApp>` renders them. Use `defineTimeView()`
38
44
  for period-driven analysis and `defineDataView()` otherwise. Split views only
39
45
  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
46
+ 5. **Compose the content.** Follow the app brief for section order and narrative.
47
+ Use `<Stack>` for sections, `<Grid>` for peers, and bound widgets
42
48
  from `@altertable/data-app-react`. Keep static explanations outside loading
43
49
  boundaries. Use app tabs only for distinct questions and widget `views` only
44
50
  for alternate representations of one dataset. Keep default appearance;
45
51
  customize when requested. Use custom UI only when bound components cannot
46
52
  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.
53
+ 6. **Connect shell features.** See [stories and export](stories-and-export.md)
54
+ for the current `<DataApp>` requirements and how to bind these features to the
55
+ displayed result. The app brief determines presentation content and export
56
+ coverage.
50
57
 
51
58
  Keep credentials, authorization, and enforced query limits in the host/backend.
52
59
  The starter supplies transport and mounting; change them only for an explicit
53
60
  integration task.
54
61
 
62
+ ## Link to external pages
63
+
64
+ Use `<ExternalLink>` for HTTPS destinations in widget content:
65
+
66
+ ```tsx
67
+ import { ExternalLink } from '@altertable/data-app-react';
68
+
69
+ function ReportLink() {
70
+ return (
71
+ <ExternalLink href="https://example.com/report">
72
+ View full report
73
+ </ExternalLink>
74
+ );
75
+ }
76
+ ```
77
+
78
+ For programmatic navigation, import `navigateNewTab`, `navigateNewWindow`, or
79
+ `navigateNewWindowOrTab` from `@altertable/data-app/client`. For example,
80
+ `navigateNewWindowOrTab(url, event)` accepts a DOM or React event: Shift requests
81
+ a window, Ctrl/Cmd requests a tab, and an unmodified event does nothing.
82
+
83
+ Embedded hosts must enable the [external link route](embed.md#external-links).
84
+
55
85
  ## Verify the app
56
86
 
57
87
  Run the authoring workflow's validation, then inspect the app:
@@ -60,11 +90,17 @@ Run the authoring workflow's validation, then inspect the app:
60
90
  Distinguish measured zero, missing values, and empty results.
61
91
  - Change filters and exercise loading, empty, error, refresh, and stale states.
62
92
  Narrative, scope, story, and export must agree with the displayed result.
63
- - Present the story and check exported columns, raw values, filename, and scope.
93
+ - For exposed presentation and export features, check the story, exported
94
+ columns, raw values, filename, and scope.
64
95
  - Review app-owned content for clipping and readability at its intended width.
65
96
  Check custom layout or CSS at narrow and wide widths; check custom colors in
66
97
  both themes.
67
98
 
99
+ When an app fails, use the host's repair or copy action to send observed diagnostics
100
+ together. Repair requests preserve the existing authorization boundary and cover
101
+ only exercised checks and interactions. See [diagnostics and repair](diagnostics.md)
102
+ for host integration.
103
+
68
104
  ## Look up only what is missing
69
105
 
70
106
  Search [REFERENCE.md](../REFERENCE.md) for the exact symbol first:
@@ -79,6 +115,7 @@ Open only the section needed for a requirement the starter does not cover:
79
115
  | -------------------------------------------- | ----------------------------------------------------------------- |
80
116
  | Adding categorical, numeric, or time filters | [Variables](variables.md) |
81
117
  | Adding a chart or narrative binding | [Widgets](widgets.md) |
118
+ | Adding supplemental control hints | [Tooltips](ui.md#tooltips-and-explanations) |
82
119
  | Adding a detail destination | [Detail views](views.md#detail-destinations) |
83
120
  | Registering physical sources | [Source identifiers](data-context.md#register-source-identifiers) |
84
121
  | Customizing appearance or CSS | [Formatting](formatting-and-appearance.md), [styling](styling.md) |
@@ -1,13 +1,12 @@
1
- # Compose an exploration
1
+ # Compose data components
2
2
 
3
3
  Define the question, population, period, measures, and comparison before choosing
4
4
  widgets. A focused answer may need only a chart and a paragraph.
5
5
 
6
- ## Build a sequence of questions
6
+ ## Choose components
7
7
 
8
- Lead with the strongest supported result and visible scope. Give each section a
9
- question: what happened, when, where it differs, or what supports the finding.
10
- Omit sections that add no evidence.
8
+ The app brief determines the content and section order.
9
+ Choose components for the information each section needs to convey:
11
10
 
12
11
  | Element | Purpose |
13
12
  | --------- | ------------------------------------------------------ |
@@ -33,21 +32,3 @@ averaging subgroup rates.
33
32
  Derive claims from the [displayed result and its input](views.md#preserve-displayed-results).
34
33
  A claim about all channels may stop being valid after selecting one. Observed
35
34
  differences support investigation; they do not establish a cause.
36
-
37
- ## Example: where are we losing signups?
38
-
39
- Define funnel entry, completion window, and channel attribution. Compare
40
- populations with equal opportunity to complete and identify incomplete periods.
41
-
42
- | Question | Display |
43
- | ------------------------------------- | -------------------------------------------------------- |
44
- | How many starters complete? | Conversion versus a comparable prior period, with counts |
45
- | When does conversion change? | Trend with incomplete periods identified |
46
- | At which step and for which channels? | Funnel and channel comparisons with counts and rates |
47
- | What supports the comparison? | Table of counts, denominators, and rates |
48
-
49
- Use one view for these related datasets. Let dates select funnel entry dates and
50
- channel filters affect every section. Reuse datasets for charts and tables.
51
- Select one to four supported findings for the [story](stories-and-export.md).
52
- Verify that changing a filter updates every claim and preserves a useful reading
53
- order.
package/docs/contract.md CHANGED
@@ -33,8 +33,9 @@ ORDER BY group_name LIMIT $limit`,
33
33
  });
34
34
  ```
35
35
 
36
- Replace fixture SQL with inspected data. Preserve supplied registry SQL. Keep
37
- operation inputs flat; derive SQL parameters inside `run()`:
36
+ Replace fixture SQL with inspected data. Keep query declarations and projections
37
+ in sync when adapting SQL to the app's inputs. Preserve metric definitions.
38
+ Keep operation inputs flat; derive SQL parameters inside `run()`:
38
39
 
39
40
  ```ts
40
41
  import { parseCount } from '@altertable/data-app/contract';
@@ -68,7 +69,9 @@ HTTP results must be JSON-serializable.
68
69
 
69
70
  Host `queryParams` supplies protected parameters that callers cannot override.
70
71
  Other values come from `query()` arguments or defaults. The host/backend enforces
71
- data access and limits.
72
+ data access and limits. Operation policies must set `maxQueryRows` to a positive
73
+ integer no greater than 10,000. The shared SQL host handler also rejects requests
74
+ for more than 10,000 rows.
72
75
 
73
76
  ### Declare query projections
74
77
 
@@ -79,11 +82,39 @@ return SQL text and declare `string` when exact numeric precision matters.
79
82
 
80
83
  Use `operations.sampleCountsByGroup.queryNames` for context and evidence.
81
84
 
82
- ## Shared date ranges
85
+ ### Bind datetime ranges
83
86
 
84
- For period-driven analysis, declare `defineDateRangeContract()` from
85
- `@altertable/data-app/contract` once and share it between the operation's parser
86
- and `defineTimeView()`:
87
+ Declare a `dateTimeRange` parameter and pass a `DateTimeRange` to `query()`.
88
+ For a [comparison variable](variables.md#absolute-and-relative-datetime-ranges),
89
+ pass its `range` or `comparison` bounds. Reference those bounds in SQL:
90
+
91
+ ```ts
92
+ const dataApp = defineDataApp({
93
+ // ... title, description, and scope
94
+ queries: {
95
+ events: {
96
+ statement: `SELECT occurred_at AS "occurredAt" FROM events
97
+ WHERE occurred_at >= $period.from AND occurred_at < $period.to`,
98
+ params: { period: { type: 'dateTimeRange' } },
99
+ projections: { occurredAt: { type: 'string' } },
100
+ },
101
+ },
102
+ });
103
+ ```
104
+
105
+ The start is inclusive and the end exclusive. Relative values resolve at query
106
+ execution. Absolute values encode wall-clock fields in UTC: selecting 4 PM stores
107
+ 16:00Z.
108
+ SQL bounds are timezone-free timestamps. Configure the backend session to the
109
+ reporting timezone and interpret timestamp-with-timezone comparisons in that
110
+ same zone.
111
+
112
+ ## Share reporting policy
113
+
114
+ Pass an optional `defineDateRangeContract()` to `dateTimeRangeVariable()` to
115
+ share coverage, duration limits, and reporting timezone between the picker and
116
+ server parser. By default, coverage ends yesterday; set `completeDays: false`
117
+ to include today. Declare the policy once:
87
118
 
88
119
  ```ts
89
120
  import { defineDateRangeContract } from '@altertable/data-app/contract';
@@ -95,5 +126,6 @@ const calendar = defineDateRangeContract({
95
126
  });
96
127
  ```
97
128
 
98
- Use `calendar.parseRequest()` to validate periods. The contract owns source
99
- coverage, time zone, maximum range, and comparison rules.
129
+ Use the shared contract in the [datetime variable workflow](variables.md#absolute-and-relative-datetime-ranges),
130
+ including optional previous-period comparison. Calendar-only views share it with
131
+ `calendar.parseRequest()` and `defineTimeView()`.
@@ -0,0 +1,82 @@
1
+ # App diagnostics and repair
2
+
3
+ Live capture reports observed query, operation, and widget failures together.
4
+ Repair actions send the complete observed report. Unvisited views and interactions
5
+ remain unverified. Reports include unfinished checks and omitted failure counts.
6
+
7
+ ## Host integration
8
+
9
+ Create one session outside the viewer lifecycle. Restore and retain its updated
10
+ state across revisions, reloads, and viewer recreation, even if saving fails.
11
+ Change the revision identifier when app source changes.
12
+
13
+ ```tsx
14
+ import { createDataAppRepairSession } from '@altertable/data-app-embed';
15
+ import {
16
+ DataAppBridge,
17
+ DataAppRepairBanner,
18
+ } from '@altertable/data-app-embed/react';
19
+
20
+ const session = createDataAppRepairSession({
21
+ state: restoredState, // New app: { automaticRequests: 0, attemptedRevisions: [] }
22
+ onStateChange: saveRepairState,
23
+ onRepairRequest: requestAgentRepair,
24
+ });
25
+
26
+ const viewer = (
27
+ <>
28
+ <DataAppRepairBanner session={session} />
29
+ <DataAppBridge
30
+ source={{ type: 'bundle', javascript }}
31
+ title="Data app"
32
+ repair={{ session, revision }}
33
+ onMessage={onMessage}
34
+ />
35
+ </>
36
+ );
37
+ ```
38
+
39
+ The host owns authorization, delivery, and state retention. `onStateChange` is
40
+ awaited before automatic delivery; reject if state cannot be retained. Three automatic
41
+ requests are allowed per session; manual requests and healthy revisions do not
42
+ reset the allowance. Callback resolution means acceptance, not agent execution.
43
+ Omit `onRepairRequest` when delivery or reliable state retention is unavailable;
44
+ the banner offers diagnostics to copy instead. Avoid sensitive values in errors.
45
+ Source locations use generated filenames and positions.
46
+
47
+ ## Custom banners
48
+
49
+ Use `session.snapshot()` to read diagnostics, delivery status, the automatic
50
+ request count, and the latest request's start time. Subscribe with
51
+ `session.subscribe()` and request a fix with `session.requestRepair()`. These APIs
52
+ work without React or the default banner.
53
+
54
+ In React, pass the snapshot to your own banner:
55
+
56
+ ```tsx
57
+ import type { DataAppRepairSession } from '@altertable/data-app-embed';
58
+ import { useSyncExternalStore } from 'react';
59
+
60
+ import { RepairBanner } from './RepairBanner';
61
+
62
+ function AppRepair({ session }: { session: DataAppRepairSession }) {
63
+ const repair = useSyncExternalStore(
64
+ listener => session.subscribe(listener),
65
+ session.snapshot,
66
+ session.snapshot
67
+ );
68
+
69
+ return (
70
+ <RepairBanner
71
+ repair={repair}
72
+ onRequestRepair={() => void session.requestRepair()}
73
+ />
74
+ );
75
+ }
76
+ ```
77
+
78
+ The host owns agent activity and revision loading. Request acceptance does not
79
+ mean the agent has started or finished. Clear the previous attempt's activity
80
+ when requesting another fix, and clear progress when the updated revision's
81
+ diagnostics settle. Custom banners choose their own presentation; the default
82
+ `<DataAppRepairBanner>` accepts observed host activity through `progress`.
package/docs/embed.md CHANGED
@@ -86,6 +86,44 @@ Host Back/Forward events publish opaque host state through the bridge. The app's
86
86
  optional navigation adapter interprets search/hash and synchronizes controls;
87
87
  opaque apps keep that state in memory rather than modifying their document URL.
88
88
 
89
+ ## External links
90
+
91
+ Register the external link route to let apps request HTTPS navigation without
92
+ relaxing the iframe sandbox:
93
+
94
+ ```ts
95
+ import {
96
+ createMessageRouter,
97
+ openExternalLinkRoute,
98
+ } from '@altertable/data-app/contract';
99
+ import { createExternalLinkHandler } from '@altertable/data-app-embed';
100
+
101
+ const router = createMessageRouter(
102
+ { 'navigation:openExternal': openExternalLinkRoute },
103
+ {
104
+ 'navigation:openExternal': createExternalLinkHandler({
105
+ allowedOrigins: ['https://example.com'],
106
+ }),
107
+ }
108
+ );
109
+ // Pass router.dispatch as the bridge's onMessage handler.
110
+ ```
111
+
112
+ To use an existing modifier-based host navigation helper, register it directly:
113
+
114
+ ```ts
115
+ const openExternalLink = createExternalLinkHandler({
116
+ navigate: navigateNewWindowOrTab,
117
+ });
118
+ // Register openExternalLink for navigation:openExternal in the host router.
119
+ ```
120
+
121
+ Here `navigateNewWindowOrTab` is the host's `(url, event)` navigation helper.
122
+ Use the frontend helper, not the app-side bridge client with the same name.
123
+
124
+ Choose permitted origins according to the host's data policy: URLs can carry app
125
+ data, and the initial origin check does not constrain redirects at the destination.
126
+
89
127
  ## Status and diagnostics
90
128
 
91
129
  `onStatusChange` receives `connecting`, `connected`, `ready`, `failed`, or
@@ -216,3 +254,6 @@ and body heights automatic.
216
254
 
217
255
  If sizing fails to settle, the bridge restores frame scrolling. Toggle sizing or
218
256
  reload to retry. Switching to `'frame'` or disposing restores the authored height.
257
+
258
+ For shared diagnostic reports, bounded agent repair and the in-flow banner, see
259
+ [App diagnostics and repair](diagnostics.md).