@altertable/data-app 0.76.0 → 0.77.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 (45) hide show
  1. package/REFERENCE.md +365 -257
  2. package/dist/chunks/{contract-DsyRYgN_.js → contract-BQsFReRp.js} +323 -169
  3. package/dist/chunks/contract-BQsFReRp.js.map +1 -0
  4. package/dist/chunks/{contract-kNFYPHRK.js → contract-VhY9V9wd.js} +184 -91
  5. package/dist/chunks/contract-VhY9V9wd.js.map +1 -0
  6. package/dist/chunks/{date-time-range-value-TE8KCsfV.js → date-time-range-value-CnlTr1U1.js} +8 -8
  7. package/dist/chunks/date-time-range-value-CnlTr1U1.js.map +1 -0
  8. package/dist/chunks/{diagnostics-DhCqGklq.js → diagnostics-Dyj-rUsY.js} +2 -2
  9. package/dist/chunks/{diagnostics-DhCqGklq.js.map → diagnostics-Dyj-rUsY.js.map} +1 -1
  10. package/dist/chunks/{operation-7tiT4cpJ.js → operation-BVRM-A5Y.js} +3 -3
  11. package/dist/chunks/{operation-7tiT4cpJ.js.map → operation-BVRM-A5Y.js.map} +1 -1
  12. package/dist/client/index.js +65 -50
  13. package/dist/client/index.js.map +1 -1
  14. package/dist/core/config.js +1 -1
  15. package/dist/core/config.js.map +1 -1
  16. package/dist/core/contract.js +4 -4
  17. package/dist/core/format.js +1 -1
  18. package/dist/internal.js +6 -124
  19. package/dist/internal.js.map +1 -1
  20. package/dist/server/index.js +3 -3
  21. package/dist/types/chunks/contract.d.ts +358 -309
  22. package/dist/types/chunks/contract2.d.ts +16 -2
  23. package/dist/types/chunks/index.d.ts +32 -5
  24. package/dist/types/client/index.d.ts +3 -3
  25. package/dist/types/core/config.d.ts +7 -3
  26. package/dist/types/core/contract.d.ts +3 -3
  27. package/dist/types/index.d.ts +1 -1
  28. package/dist/types/internal.d.ts +5 -5
  29. package/dist/types/server/index.d.ts +1 -1
  30. package/docs/app-authoring.md +15 -10
  31. package/docs/client.md +12 -7
  32. package/docs/contract.md +33 -51
  33. package/docs/data-context.md +9 -5
  34. package/docs/filters.md +295 -0
  35. package/docs/hosted-apps.md +4 -3
  36. package/docs/layout.md +24 -18
  37. package/docs/stories-and-export.md +19 -10
  38. package/docs/ui.md +6 -5
  39. package/docs/views.md +62 -26
  40. package/docs/widgets.md +38 -14
  41. package/package.json +1 -1
  42. package/dist/chunks/contract-DsyRYgN_.js.map +0 -1
  43. package/dist/chunks/contract-kNFYPHRK.js.map +0 -1
  44. package/dist/chunks/date-time-range-value-TE8KCsfV.js.map +0 -1
  45. package/docs/variables.md +0 -280
@@ -1,5 +1,19 @@
1
1
  import { n as DateTimeRange } from "./date-time-range.js";
2
- import { Bt as OperationContracts, Dt as QueryParameters, Ft as DataQueryInput, Ht as QueryResult, J as NavigationUpdate, Pt as DataQueryBody, Ut as TransportResponse, Vt as OutputOf } from "./contract.js";
2
+ import { $ as DataQueryInput, Ct as DimensionFilterSettings, F as NavigationUpdate, Ft as FacetFilter, Ot as DimensionValue, Q as DataQueryBody, at as OutputOf, gt as QueryParameters, it as OperationContracts, ot as QueryResult, st as TransportResponse } from "./contract.js";
3
+ //#region src/core/facet-filter.d.ts
4
+ type FacetFilterOptions<Value extends DimensionValue, Operation extends string> = DimensionFilterSettings<Value> & {
5
+ /** The registered operation that returns this dimension's options. */
6
+ options: Operation;
7
+ };
8
+ /** Options load from `options`, an operation returning `DimensionOption[]`; the
9
+ * client checks that it is registered. Validate selections like any dimension. */
10
+ declare function facetFilter<const Operation extends string>(config: FacetFilterOptions<string, Operation> & {
11
+ valueType: 'string';
12
+ }): FacetFilter<string, Operation>;
13
+ declare function facetFilter<const Operation extends string>(config: FacetFilterOptions<number, Operation> & {
14
+ valueType: 'number';
15
+ }): FacetFilter<number, Operation>;
16
+ //#endregion
3
17
  //#region src/core/date-time-range-sql.d.ts
4
18
  /** DuckDB timestamp expressions using the query session's timezone for relative anchors.
5
19
  * Absolute fields remain UTC-rebased TIMESTAMP values. Start is inclusive, end exclusive.
@@ -203,5 +217,5 @@ declare class DataSourceError extends Error {
203
217
  options?: ErrorOptions);
204
218
  }
205
219
  //#endregion
206
- export { dataAppRoutes as A, MessageRoute as C, RoutedMessage as D, MessageTransport as E, dateTimeRangeSql as F, defineMessageRoute as M, navigationUpdateRoute as N, SqlQueryInput as O, sqlQueryRoute as P, MessageOutput as S, MessageRoutingError as T, DataQueryRoute as _, OpenExternalLink as a, MessageHandlers as b, resolveExternalLinkTarget as c, annotationDraftRoute as d, annotationEditorStateRoute as f, parseDataAppAnnotationDraft as g, annotationUpdateRoute as h, ExternalLinkTarget as i, defineDataQueryRoute as j, createMessageRouter as k, DataAppAnnotationDraft as l, annotationSendRoute as m, ExternalLinkModifiers as n, openExternalLinkRoute as o, annotationModeRoute as p, ExternalLinkResult as r, parseExternalUrl as s, DataSourceError as t, DataAppAnnotationPresentation as u, MessageContext as v, MessageRoutes as w, MessageInput as x, MessageDispatcher as y };
220
+ export { dataAppRoutes as A, MessageRoute as C, RoutedMessage as D, MessageTransport as E, dateTimeRangeSql as F, facetFilter as I, defineMessageRoute as M, navigationUpdateRoute as N, SqlQueryInput as O, sqlQueryRoute as P, MessageOutput as S, MessageRoutingError as T, DataQueryRoute as _, OpenExternalLink as a, MessageHandlers as b, resolveExternalLinkTarget as c, annotationDraftRoute as d, annotationEditorStateRoute as f, parseDataAppAnnotationDraft as g, annotationUpdateRoute as h, ExternalLinkTarget as i, defineDataQueryRoute as j, createMessageRouter as k, DataAppAnnotationDraft as l, annotationSendRoute as m, ExternalLinkModifiers as n, openExternalLinkRoute as o, annotationModeRoute as p, ExternalLinkResult as r, parseExternalUrl as s, DataSourceError as t, DataAppAnnotationPresentation as u, MessageContext as v, MessageRoutes as w, MessageInput as x, MessageDispatcher as y };
207
221
  //# sourceMappingURL=contract2.d.ts.map
@@ -1,4 +1,4 @@
1
- import { Dt as QueryParameters, Ht as QueryResult, K as AppLocation, Lt as InputOf, Nt as DataOperations, Pt as DataQueryBody, Rt as Lakehouse, Ut as TransportResponse, Vt as OutputOf, bt as IsUnion, q as HistoryMode, xt as KnownRecord } from "./contract.js";
1
+ import { Ft as FacetFilter, N as AppLocation, P as HistoryMode, Q as DataQueryBody, S as FilterCollection, Tt as DimensionOption, Z as DataOperations, at as OutputOf, gt as QueryParameters, lt as IsUnion, nt as Lakehouse, ot as QueryResult, st as TransportResponse, tt as InputOf, ut as KnownRecord } from "./contract.js";
2
2
  import { D as RoutedMessage, E as MessageTransport, S as MessageOutput, l as DataAppAnnotationDraft, n as ExternalLinkModifiers, r as ExternalLinkResult, w as MessageRoutes, x as MessageInput } from "./contract2.js";
3
3
  //#region src/core/logger.d.ts
4
4
  /** Host-owned log sink; compatible with console and frontend createLogger(). */
@@ -36,10 +36,18 @@ type DataResponse<Output, Input = unknown> = DataQueryBody<Output> & {
36
36
  /** The exact browser input that produced this response. */
37
37
  input: Input;
38
38
  };
39
+ /** The filters each operation reads, for operations that read any. */
40
+ type OperationFilters<Operations extends DataOperations> = { readonly [Name in keyof Operations as Operations[Name] extends {
41
+ filters: infer Filters extends FilterCollection;
42
+ } ? keyof Filters extends never ? never : Name : never]: Operations[Name] extends {
43
+ filters: infer Filters;
44
+ } ? Filters : never; };
39
45
  declare const clientContract: unique symbol;
40
46
  type DataClient<Operations extends DataOperations> = {
41
47
  /** Preserve the operation registry when passing clients through helpers. */
42
48
  readonly [clientContract]: (operations: Operations) => Operations;
49
+ /** Each operation's filters; views derive their inputs and controls from them. */
50
+ readonly filters: Readonly<Record<string, FilterCollection>>;
43
51
  query<Name extends keyof Operations & string>(this: void, name: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown), input: InputOf<Operations[NoInfer<Name>]>, options?: {
44
52
  signal?: AbortSignal;
45
53
  }): Promise<DataResponse<OutputOf<Operations[Name]>, InputOf<Operations[Name]>>>;
@@ -51,6 +59,24 @@ type TransportOptions = {
51
59
  endpoint?: string;
52
60
  fetch?: typeof fetch;
53
61
  };
62
+ /** Server-owned operations stay type-only, so the browser receives their filters. */
63
+ type TransportFilters<Operations extends DataOperations> = keyof OperationFilters<Operations> extends never ? {
64
+ filters?: OperationFilters<Operations>;
65
+ } : {
66
+ /** Pass the same filter declarations the server operations read. */
67
+ filters: OperationFilters<Operations>;
68
+ };
69
+ /** Distribute over conditional filter members so each possible facet is checked. */
70
+ type UncheckedFacet<Operations extends DataOperations, Filter, Key> = Filter extends FacetFilter<infer Value, infer Source> ? Source extends keyof Operations ? OutputOf<Operations[Source]> extends readonly DimensionOption<Value>[] ? never : Key : Key : never;
71
+ /** The filter names whose facet options are missing or mistyped. Only known names:
72
+ * a typed contract may widen `filters` with an index signature. */
73
+ type UncheckedFacetNames<Operations extends DataOperations, Filters> = { [Key in keyof Filters as string extends Key ? never : Key]: UncheckedFacet<Operations, Filters[Key], Key>; } extends (infer Checked) ? Checked[keyof Checked] : never;
74
+ /** Every facet filter loads its options from a registered operation returning them. */
75
+ type CheckedFacets<Operations extends DataOperations> = { [Name in keyof Operations]: Operations[Name] extends {
76
+ filters: infer Filters;
77
+ } ? UncheckedFacetNames<Operations, Filters> : never; }[keyof Operations] extends never ? unknown : {
78
+ 'Facet filter options must name a registered operation returning DimensionOption[]': never;
79
+ };
54
80
  /** Browser operations and named-operation delivery are mutually exclusive. */
55
81
  type DataClientOptions<Operations extends DataOperations> = (KnownRecord<Operations> extends never ? never : true extends { [Name in keyof Operations]: IsUnion<Operations[Name]>; }[keyof Operations] ? never : unknown) & ({
56
82
  operations: Operations;
@@ -58,13 +84,14 @@ type DataClientOptions<Operations extends DataOperations> = (KnownRecord<Operati
58
84
  transport?: never;
59
85
  endpoint?: never;
60
86
  fetch?: never;
61
- } | TransportOptions);
87
+ filters?: never;
88
+ } | (TransportOptions & TransportFilters<Operations>)) & CheckedFacets<Operations>;
62
89
  /** Named HTTP operations, or browser-owned operations executed through an authorized SQL bridge. */
63
- declare function createDataClient<Operations extends DataOperations>(options: DataClientOptions<Operations>): DataClient<Operations>;
64
90
  /** Named clients derive data from the declared operations' run return types. */
65
- declare function createDataClient<Operations extends DataOperations>(...args: DataClientOptions<Operations> extends never ? [options: never] : []): DataClient<Operations>;
91
+ declare function createDataClient<Operations extends DataOperations>(...args: DataClientOptions<Operations> extends never ? [options: never] : keyof OperationFilters<Operations> extends never ? [] : [options: never]): DataClient<Operations>;
66
92
  /** Without an operation contract, external operation data remains unknown. */
67
93
  declare function createDataClient(options?: TransportOptions): DataClient<DataOperations>;
94
+ declare function createDataClient<Operations extends DataOperations>(options: DataClientOptions<Operations>): DataClient<Operations>;
68
95
  //#endregion
69
96
  //#region src/client/location.d.ts
70
97
  type DataAppLocation = {
@@ -248,5 +275,5 @@ declare function navigateNewWindow(url: string, options?: NavigationOptions): Pr
248
275
  /** Send only modifier keys, never the DOM/React event. Shift requests a window, Ctrl/Cmd a tab; otherwise no navigation. */
249
276
  declare function navigateNewWindowOrTab(url: string, event: ExternalLinkModifiers, options?: NavigationOptions): Promise<ExternalLinkResult>;
250
277
  //#endregion
251
- 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 };
278
+ export { createDataClient as C, DataAppLogger as D, createHttpTransport as E, LogEntry as O, OperationFilters as S, DataTransport 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, DataAppError as w, DataResponse as x, DataClient as y };
252
279
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
- import { K as AppLocation, Lt as InputOf, Vt as OutputOf } 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
+ import { N as AppLocation, at as OutputOf, tt as InputOf } from "../chunks/contract.js";
2
+ import { C as createDataClient, D as DataAppLogger, E as createHttpTransport, S as OperationFilters, T as DataTransport, 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 DataAppError, 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 OperationFilters, type OutputOf, appDiagnostics, createAnnotationClient, createDataAppNavigation, createDataClient, createHttpTransport, createIframeTransport, createMessageClient, getDataAppNavigation, getDataAppTransport, installDataAppTransport, navigateNewTab, navigateNewWindow, navigateNewWindowOrTab };
@@ -1,5 +1,5 @@
1
1
  import { a as RelativeOffset, i as RelativeDateTime, n as DateTimeRange, o as RelativeUnit, r as RelativeAnchor, t as AbsoluteOrRelativeDateTime } from "../chunks/date-time-range.js";
2
- import { At as QuerySnapshot, Ct as QueryDefinitions, Et as QueryParameterValue, Ot as QueryProjections, Tt as QueryParameter, at as DimensionSourceConfig, i as OperationDefinition, jt as QueryValueType, kt as QueryRow, l as defineOperation, ot as DimensionSourceQueryName, st as SourceDimensionVariable, wt as QueryField, yt as CheckedQueries } from "../chunks/contract.js";
2
+ import { J as SourceDimensionFilter, K as DimensionSourceConfig, S as FilterCollection, _t as QueryProjections, bt as QueryValueType, ct as CheckedQueries, ft as QueryDefinitions, ht as QueryParameterValue, i as InputOperationDefinition, m as FilterInput, mt as QueryParameter, n as DefinedOperation, pt as QueryField, q as DimensionSourceQueryName, r as FilterOperationDefinition, s as WithFilterInput, vt as QueryRow, yt as QuerySnapshot } from "../chunks/contract.js";
3
3
  import { o as AppearanceOptions } from "../chunks/appearance.js";
4
4
  //#region src/core/config.d.ts
5
5
  export type DataAppConfig<Queries extends QueryDefinitions = QueryDefinitions> = {
@@ -28,11 +28,15 @@ export type DataAppDefinition<Queries extends QueryDefinitions = QueryDefinition
28
28
  source: {
29
29
  query: DimensionSourceQueryName<Queries, NoInfer<Type>>;
30
30
  };
31
- }): SourceDimensionVariable<{
31
+ }): SourceDimensionFilter<{
32
32
  string: string;
33
33
  number: number;
34
34
  }[Type]>;
35
- defineOperation<Input, Output>(operation: OperationDefinition<Input, Output, Queries>): ReturnType<typeof defineOperation<Input, Output, Queries>>;
35
+ /** Parse a destination's own input, such as a record id, and list valid `checks`.
36
+ * Declare `filters` too when it reads the displayed scope. */
37
+ defineOperation<Input, Output, const Filters extends FilterCollection = {}>(operation: InputOperationDefinition<Input, Output, Queries, Filters>): DefinedOperation<WithFilterInput<Filters, Input>, Output, Queries, keyof Filters extends never ? undefined : Filters>;
38
+ /** Declare the filters the operation reads; its input, checks, and views derive from them. */
39
+ defineOperation<const Filters extends FilterCollection = {}, Output = unknown>(operation: FilterOperationDefinition<Filters, Output, Queries>): DefinedOperation<FilterInput<Filters>, Output, Queries, Filters>;
36
40
  };
37
41
  /**
38
42
  * Define the app's query source of truth while preserving exact query and parameter names.
@@ -1,5 +1,5 @@
1
1
  import { i as RelativeDateTime, n as DateTimeRange, s as ResolvedDateTimeRange, t as AbsoluteOrRelativeDateTime } from "../chunks/date-time-range.js";
2
- import { $ as NumberSelection, Bt as OperationContracts, Ct as QueryDefinitions, D as parseDimensionSelection, Dt as QueryParameters, E as dimensionPredicate, Et as QueryParameterValue, Ft as DataQueryInput, Gt as DateTimeRangeRequest, Ht as QueryResult, It as DisclosedQuery, J as NavigationUpdate, Mt as DataOperation, Nt as DataOperations, O as parseFacetOptions, Ot as QueryProjections, Pt as DataQueryBody, Q as NumberOperator, Rt as Lakehouse, S as DimensionVariable, Tt as QueryParameter, Ut as TransportResponse, Wt as DateTimeRangeContract, X as BooleanSelection, Y as BooleanFilter, Z as NumberFilter, _ as DimensionMember, _t as dateTimeRangePresets, a as RegisteredQuery, c as defineDateRangeContract, d as parseCount, dt as DateTimeRangeComparisonSelection, et as booleanFilter, f as parseEmptyInput, ft as DateTimeRangeComparisonVariable, gt as DateTimeRangeVariableOptions, h as DimensionFilterOptions, ht as DateTimeRangeVariable, i as OperationDefinition, it as parseNumberSelection, jt as QueryValueType, kt as QueryRow, l as defineOperation, lt as variableInput, m as parseTrue, mt as DateTimeRangePreset, n as DateRangeContract, o as ReportingPeriod, p as parseLabel, pt as DateTimeRangeComparisonVariableOptions, r as DateRangeContractOptions, rt as parseBooleanSelection, s as connectionCheck, t as ConnectionOperation, tt as numberFilter, u as defineQueryNames, ut as DateTimeRangeComparisonRequest, v as DimensionOption, vt as dateTimeRangeVariable, w as dimensionFilter, wt as QueryField, y as DimensionSelection, zt as OperationContext } from "../chunks/contract.js";
2
+ import { $ as DataQueryInput, A as multiChoiceFilter, At as dimensionFilter, B as NumberSelection, Bt as DateTimeRangePreset, C as FilterPresentation, D as choiceFilter, E as SearchFilter, Et as DimensionSelection, F as NavigationUpdate, Ft as FacetFilter, G as parseNumberSelection, Gt as DateTimeRangeInput, H as numberFilter, Ht as DateTimeRangeSelection, I as BooleanFilter, Kt as DateTimeRangePolicy, L as BooleanSelection, Lt as DateTimeRangeComparison, Mt as dimensionPredicate, Nt as parseDimensionSelection, Pt as parseFacetOptions, Q as DataQueryBody, R as NumberFilter, Rt as DateTimeRangeFilter, S as FilterCollection, St as DimensionFilterOptions, T as MultiChoiceFilter, Tt as DimensionOption, Ut as dateTimeRangeFilter, V as booleanFilter, W as parseBooleanSelection, Wt as dateTimeRangePresets, X as DataOperation, Z as DataOperations, _t as QueryProjections, a as RegisteredQuery, b as ChoiceFilter, bt as QueryValueType, c as connectionCheck, d as parseCount, et as DisclosedQuery, f as parseLabel, ft as QueryDefinitions, gt as QueryParameters, ht as QueryParameterValue, i as InputOperationDefinition, it as OperationContracts, j as searchFilter, k as displayChoice, l as defineOperation, m as FilterInput, mt as QueryParameter, n as DefinedOperation, nt as Lakehouse, o as ReportingPeriod, ot as QueryResult, p as parseTrue, pt as QueryField, r as FilterOperationDefinition, rt as OperationContext, s as WithFilterInput, st as TransportResponse, t as ConnectionOperation, u as defineQueryNames, v as AppFilter, vt as QueryRow, w as FilterValues, wt as DimensionMember, x as ChoiceOption, xt as DimensionFilter, z as NumberOperator, zt as DateTimeRangeFilterOptions } from "../chunks/contract.js";
3
+ import { A as dataAppRoutes, C as MessageRoute, D as RoutedMessage, E as MessageTransport, F as dateTimeRangeSql, I as facetFilter, M as defineMessageRoute, N as navigationUpdateRoute, O as SqlQueryInput, P as sqlQueryRoute, S as MessageOutput, T as MessageRoutingError, _ as DataQueryRoute, a as OpenExternalLink, b as MessageHandlers, c as resolveExternalLinkTarget, d as annotationDraftRoute, f as annotationEditorStateRoute, g as parseDataAppAnnotationDraft, h as annotationUpdateRoute, i as ExternalLinkTarget, j as defineDataQueryRoute, k as createMessageRouter, l as DataAppAnnotationDraft, m as annotationSendRoute, n as ExternalLinkModifiers, o as openExternalLinkRoute, p as annotationModeRoute, r as ExternalLinkResult, s as parseExternalUrl, t as DataSourceError, u as DataAppAnnotationPresentation, v as MessageContext, w as MessageRoutes, x as MessageInput, y as MessageDispatcher } from "../chunks/contract2.js";
3
4
  import { a as resolveDateTimeRange, i as parseDateTimeRange, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, t as formatDateTimeBound } from "../chunks/date-time-range-value.js";
4
- import { A as dataAppRoutes, C as MessageRoute, D as RoutedMessage, E as MessageTransport, F as dateTimeRangeSql, M as defineMessageRoute, N as navigationUpdateRoute, O as SqlQueryInput, P as sqlQueryRoute, S as MessageOutput, T as MessageRoutingError, _ as DataQueryRoute, a as OpenExternalLink, b as MessageHandlers, c as resolveExternalLinkTarget, d as annotationDraftRoute, f as annotationEditorStateRoute, g as parseDataAppAnnotationDraft, h as annotationUpdateRoute, i as ExternalLinkTarget, j as defineDataQueryRoute, k as createMessageRouter, l as DataAppAnnotationDraft, m as annotationSendRoute, n as ExternalLinkModifiers, o as openExternalLinkRoute, p as annotationModeRoute, r as ExternalLinkResult, s as parseExternalUrl, t as DataSourceError, u as DataAppAnnotationPresentation, v as MessageContext, w as MessageRoutes, x as MessageInput, y as MessageDispatcher } from "../chunks/contract2.js";
5
- 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 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, parseDateTimeBound, parseDateTimeRange, parseDimensionSelection, parseEmptyInput, parseExternalUrl, parseFacetOptions, parseLabel, parseNumberSelection, parseTrue, resolveDateTimeRange, resolveExternalLinkTarget, serializeDateTimeRange, sqlQueryRoute, variableInput };
5
+ export { type AbsoluteOrRelativeDateTime, type AppFilter, type BooleanFilter, type BooleanSelection, type ChoiceFilter, type ChoiceOption, type ConnectionOperation, type DataAppAnnotationDraft, type DataAppAnnotationPresentation, type DataOperation, type DataOperations, type DataQueryBody, type DataQueryInput, type DataQueryRoute, DataSourceError, type DateTimeRange, type DateTimeRangeComparison, type DateTimeRangeFilter, type DateTimeRangeFilterOptions, type DateTimeRangeInput, type DateTimeRangePolicy, type DateTimeRangePreset, type DateTimeRangeSelection, type DefinedOperation, type DimensionFilter, type DimensionFilterOptions, type DimensionMember, type DimensionOption, type DimensionSelection, type DisclosedQuery, type ExternalLinkModifiers, type ExternalLinkResult, type ExternalLinkTarget, type FacetFilter, type FilterCollection, type FilterInput, type FilterOperationDefinition, type FilterPresentation, type FilterValues, type InputOperationDefinition, type Lakehouse, type MessageContext, type MessageDispatcher, type MessageHandlers, type MessageInput, type MessageOutput, type MessageRoute, type MessageRoutes, MessageRoutingError, type MessageTransport, type MultiChoiceFilter, type NavigationUpdate, type NumberFilter, type NumberOperator, type NumberSelection, type OpenExternalLink, type OperationContext, type OperationContracts, 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 SearchFilter, type SqlQueryInput, type TransportResponse, type WithFilterInput, annotationDraftRoute, annotationEditorStateRoute, annotationModeRoute, annotationSendRoute, annotationUpdateRoute, booleanFilter, choiceFilter, connectionCheck, createMessageRouter, dataAppRoutes, dateTimeRangeFilter, dateTimeRangePresets, dateTimeRangeSql, defineDataQueryRoute, defineMessageRoute, defineOperation, defineQueryNames, dimensionFilter, dimensionPredicate, displayChoice, facetFilter, formatDateTimeBound, formatDateTimeRange, multiChoiceFilter, navigationUpdateRoute, numberFilter, openExternalLinkRoute, parseBooleanSelection, parseCount, parseDataAppAnnotationDraft, parseDateTimeBound, parseDateTimeRange, parseDimensionSelection, parseExternalUrl, parseFacetOptions, parseLabel, parseNumberSelection, parseTrue, resolveDateTimeRange, resolveExternalLinkTarget, searchFilter, serializeDateTimeRange, sqlQueryRoute };
@@ -1,4 +1,4 @@
1
1
  import { a as RelativeOffset, i as RelativeDateTime, n as DateTimeRange, o as RelativeUnit, r as RelativeAnchor, t as AbsoluteOrRelativeDateTime } from "./chunks/date-time-range.js";
2
- import { Ct as QueryDefinitions, Et as QueryParameterValue, Ot as QueryProjections, Tt as QueryParameter, jt as QueryValueType, kt as QueryRow, wt as QueryField } from "./chunks/contract.js";
2
+ import { _t as QueryProjections, bt as QueryValueType, ft as QueryDefinitions, ht as QueryParameterValue, mt as QueryParameter, pt as QueryField, vt as QueryRow } from "./chunks/contract.js";
3
3
  import { DataAppConfig, DataAppDefinition, dataAppTitle, defineDataApp } from "./core/config.js";
4
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,8 +1,8 @@
1
1
  import { i as RelativeDateTime, n as DateTimeRange, o as RelativeUnit, t as AbsoluteOrRelativeDateTime } from "./chunks/date-time-range.js";
2
- import { A as facetSource, B as VariablePresentation, C as createDimensionFilter, F as ChoiceOption, G as validateChoiceOptions, Gt as DateTimeRangeRequest, H as defineAppVariables, I as ChoiceVariable, L as MultiChoiceVariable, M as AppVariableValues, N as CheckedFacetContexts, P as CheckedVariableDeclarations, R as SearchVariable, St as MAX_QUERY_ROWS, T as dimensionMemberKey, U as multiChoiceVariable, V as choiceVariable, W as searchVariable, _t as dateTimeRangePresets, b as DimensionSelectionVariable, bt as IsUnion, ct as dimensionSource, dt as DateTimeRangeComparisonSelection, ft as DateTimeRangeComparisonVariable, g as DimensionFilterSettings, gt as DateTimeRangeVariableOptions, ht as DateTimeRangeVariable, j as AppVariable, k as FacetVariable, mt as DateTimeRangePreset, nt as numberOperatorLabels, pt as DateTimeRangeComparisonVariableOptions, q as HistoryMode, st as SourceDimensionVariable, ut as DateTimeRangeComparisonRequest, vt as dateTimeRangeVariable, x as DimensionValue, z as VariableCollection } from "./chunks/contract.js";
3
- import { a as resolveDateTimeRange, i as parseDateTimeRange, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, t as formatDateTimeBound } from "./chunks/date-time-range-value.js";
2
+ import { A as multiChoiceFilter, Bt as DateTimeRangePreset, C as FilterPresentation, Ct as DimensionFilterSettings, D as choiceFilter, Dt as DimensionSelectionFilter, E as SearchFilter, Ft as FacetFilter, Gt as DateTimeRangeInput, Ht as DateTimeRangeSelection, It as facetSource, J as SourceDimensionFilter, Lt as DateTimeRangeComparison, M as validateChoiceOptions, O as defineAppFilters, Ot as DimensionValue, P as HistoryMode, Rt as DateTimeRangeFilter, S as FilterCollection, T as MultiChoiceFilter, U as numberOperatorLabels, Ut as dateTimeRangeFilter, Vt as DateTimeRangeRequest, Wt as dateTimeRangePresets, Y as dimensionSource, _ as resolveFilterInput, b as ChoiceFilter, dt as MAX_QUERY_ROWS, g as dateFilterName, h as combineOperationFilters, j as searchFilter, jt as dimensionMemberKey, k as displayChoice, kt as createDimensionFilter, lt as IsUnion, m as FilterInput, v as AppFilter, w as FilterValues, x as ChoiceOption, y as CheckedFilterDeclarations, zt as DateTimeRangeFilterOptions } from "./chunks/contract.js";
4
3
  import { u as DataAppAnnotationPresentation } from "./chunks/contract2.js";
5
- import { D as LogEntry, _ as localFrameBridge, s as parseAppDiagnosticReport } from "./chunks/index.js";
4
+ import { a as resolveDateTimeRange, i as parseDateTimeRange, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, t as formatDateTimeBound } from "./chunks/date-time-range-value.js";
5
+ import { O as LogEntry, _ as localFrameBridge, s as parseAppDiagnosticReport } from "./chunks/index.js";
6
6
  import { c as Theme } from "./chunks/appearance.js";
7
7
  //#region src/core/bridge.d.ts
8
8
  /** Data app delivery protocol. IDs identify a document, a shell session, and an individual call. */
@@ -295,7 +295,7 @@ type MetricValues = {
295
295
  previous?: number | null;
296
296
  };
297
297
  type MetricReading = DataReading<MetricValues & {
298
- period?: DateTimeRangeRequest;
298
+ period?: DateTimeRangeInput;
299
299
  }>;
300
300
  //#endregion
301
301
  //#region src/core/uuid.d.ts
@@ -315,5 +315,5 @@ export declare const KEY_SEPARATOR = ":";
315
315
  /** Fixed durations in UTC-rebased arithmetic; months and years are calendar-dependent. */
316
316
  export declare const fixedUnitMilliseconds: Partial<Record<RelativeUnit, number>> & Record<'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK', number>;
317
317
  //#endregion
318
- 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 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, choiceVariable, createDimensionFilter, dateTimeRangePresets, dateTimeRangeVariable, defineAppVariables, dimensionMemberKey, dimensionSource, facetSource, formatDateTimeBound, formatDateTimeRange, localFrameBridge, multiChoiceVariable, numberOperatorLabels, parseAppDiagnosticReport, parseDateTimeBound, parseDateTimeRange, resolveDateTimeRange, searchVariable, serializeDateTimeRange, validateChoiceOptions };
318
+ export { type AbsoluteOrRelativeDateTime, type AppFilter, type BridgeDiagnostic, type BridgeEventMessage, type CheckedFilterDeclarations, type ChoiceFilter, type ChoiceOption, type DataAppPresentation, type DataReading, type DataView, type DateTimeRange, type DateTimeRangeComparison, type DateTimeRangeFilter, type DateTimeRangeFilterOptions, type DateTimeRangePreset, type DateTimeRangeRequest, type DateTimeRangeSelection, type DimensionFilterSettings, type DimensionSelectionFilter, type DimensionValue, type DisplayedSnapshot, type FacetFilter, type FilterCollection, type FilterInput, type FilterPresentation, type FilterValues, type HistoryMode, type IsUnion, MAX_QUERY_ROWS, type MetricReading, type MetricValues, type MultiChoiceFilter, type RelativeDateTime, type SearchFilter, type SourceDimensionFilter, choiceFilter, combineOperationFilters, createDimensionFilter, dateFilterName, dateTimeRangeFilter, dateTimeRangePresets, defineAppFilters, dimensionMemberKey, dimensionSource, displayChoice, facetSource, formatDateTimeBound, formatDateTimeRange, localFrameBridge, multiChoiceFilter, numberOperatorLabels, parseAppDiagnosticReport, parseDateTimeBound, parseDateTimeRange, resolveDateTimeRange, resolveFilterInput, searchFilter, serializeDateTimeRange, validateChoiceOptions };
319
319
  //# sourceMappingURL=internal.d.ts.map
@@ -1,4 +1,4 @@
1
- import { Dt as QueryParameters, Nt as DataOperations, Rt as Lakehouse } from "../chunks/contract.js";
1
+ import { Z as DataOperations, gt as QueryParameters, nt as Lakehouse } 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 = {
@@ -31,18 +31,23 @@ app-owned files, not installed packages.
31
31
  1. **Define the question and scope.** Inspect relevant fields, definitions, time
32
32
  coverage, and missing or incomplete observations. Establish the population,
33
33
  grain, measures, and comparison. Choose a chart that answers the question.
34
- 2. **Replace the starter queries and operation.** Write queries
35
- against inspected data and preserve supplied metric definitions. Declare `params`
36
- and result aliases in `projections`. Validate flat operation inputs, execute
37
- named queries with `query()`, and derive results from its typed rows.
34
+ 2. **Write one query and operation per widget.** Give each metric, chart, and
35
+ table its own named query and operation; do not combine unrelated results
36
+ into one query. Write queries against inspected data and preserve supplied
37
+ metric definitions. Declare `params` and result aliases in `projections`.
38
+ Execute named queries with `query()` and derive results from its typed rows.
38
39
  3. **Update context and bindings.** Describe definitions and coverage in the data
39
40
  context, using the operation's `queryNames` for evidence. Declare each dataset
40
41
  and metric once, with stable row keys, raw column values, and shared formats.
41
- 4. **Adapt the view.** Keep related results in one view. Use flat input fields
42
- matching variable names so `input` and `bindings` can be omitted. Declare
43
- useful filters in `variables`; `<DataApp>` renders them. Use `defineTimeView()`
44
- for period-driven analysis and `defineDataView()` otherwise. Split views only
45
- for independent requests. Keep protected values such as `orgId` backend-owned.
42
+ 4. **Declare filters once, then one view per operation.** Declare each filter
43
+ and display choice as a constant and list the ones each operation reads in
44
+ its `filters`; the operation receives one flat input field per filter. Define
45
+ each view with `defineView({ operation, dataContext })`: its filters,
46
+ reporting period, and scope derive from the operation. Pass the headline view
47
+ to `<DataApp view>`, which renders every filter's control, and render each
48
+ view in its own `<DataSection>`. Keep protected values such as `orgId`
49
+ backend-owned. See [views](views.md#give-each-widget-its-own-view) and
50
+ [filters](filters.md).
46
51
  5. **Compose the content.** Follow the app brief for section order and narrative.
47
52
  Use `<Stack>` for sections, `<Grid>` for peers, and bound widgets
48
53
  from `@altertable/data-app-react`. Keep static explanations outside loading
@@ -113,7 +118,7 @@ Open only the section needed for a requirement the starter does not cover:
113
118
 
114
119
  | When | Read |
115
120
  | -------------------------------------------- | ----------------------------------------------------------------- |
116
- | Adding categorical, numeric, or time filters | [Variables](variables.md) |
121
+ | Adding categorical, numeric, or time filters | [Filters](filters.md) |
117
122
  | Adding a chart or narrative binding | [Widgets](widgets.md) |
118
123
  | Adding supplemental control hints | [Tooltips](ui.md#tooltips-and-explanations) |
119
124
  | Adding a detail destination | [Detail views](views.md#detail-destinations) |
package/docs/client.md CHANGED
@@ -7,9 +7,12 @@ starter's client. Import `createDataClient()` from `@altertable/data-app/client`
7
7
 
8
8
  ```ts
9
9
  import { createDataClient } from '@altertable/data-app/client';
10
+ import { operationFilters } from './filters.ts';
10
11
  import type { operations } from './operations.ts';
11
12
 
12
- const client = createDataClient<typeof operations>();
13
+ const client = createDataClient<typeof operations>({
14
+ filters: operationFilters,
15
+ });
13
16
  const response = await client.query(
14
17
  'sampleCountsByGroup',
15
18
  { groupName: '' },
@@ -17,12 +20,13 @@ const response = await client.query(
17
20
  );
18
21
  ```
19
22
 
20
- The app supplies `operations` and an optional cancellation `signal`.
21
- Inputs and data are inferred from the operation map and `run()`. Keep the import
22
- type-only so operation implementations stay on the server.
23
+ Keep the operations import type-only so implementations stay on the server.
24
+ Pass the filters each operation reads from a browser-safe module both sides
25
+ import ([shared filters](filters.md#share-filters-with-http-and-local-apps)).
26
+ Inputs and data are inferred from the operation map and `run()`.
23
27
 
24
28
  The default endpoint is `/api/data`. Override it with
25
- `createDataClient<typeof operations>({ endpoint, fetch })` to change the base URL or supply a Fetch
29
+ `createDataClient<typeof operations>({ filters, endpoint, fetch })` to change the base URL or supply a Fetch
26
30
  implementation. Calls POST JSON to `/api/data/:operation`; the client sends
27
31
  operation inputs rather than SQL or credentials.
28
32
 
@@ -36,7 +40,8 @@ See [contracts](contract.md), [server handlers](server.md), and
36
40
 
37
41
  ## Browser-owned operations for bundle apps
38
42
 
39
- Bundle apps pass their operation registry as a value:
43
+ Bundle apps pass their operation registry as a value, which also supplies its
44
+ filters:
40
45
 
41
46
  ```ts
42
47
  import { createDataClient } from '@altertable/data-app/client';
@@ -56,7 +61,7 @@ must independently enforce access and resource limits.
56
61
 
57
62
  ## Iframe transport
58
63
 
59
- `createDataClient<typeof operations>({ transport })` accepts a `DataTransport`. Without an explicit
64
+ `createDataClient<typeof operations>({ filters, transport })` accepts a `DataTransport`. Without an explicit
60
65
  transport, endpoint, or Fetch implementation, it discovers an installed iframe
61
66
  transport before falling back to HTTP. Explicit endpoint/Fetch options select
62
67
  HTTP. `createHttpTransport()` provides the underlying operation delivery adapter.
package/docs/contract.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  Keep the starter's `defineDataApp()` declaration and operation registry. Declare
4
4
  named SQL queries with typed `params` and `projections`; execute them through
5
- `dataApp.defineOperation()`. Use descriptive `lowerCamelCase` query names.
5
+ `dataApp.defineOperation()`. Write one query and operation per widget result,
6
+ and use descriptive `lowerCamelCase` query names.
6
7
 
7
8
  ## Execute named queries
8
9
 
@@ -35,20 +36,17 @@ ORDER BY group_name LIMIT $limit`,
35
36
 
36
37
  Replace fixture SQL with inspected data. Keep query declarations and projections
37
38
  in sync when adapting SQL to the app's inputs. Preserve metric definitions.
38
- Keep operation inputs flat; derive SQL parameters inside `run()`:
39
+ List the [filters](filters.md) an operation reads; `run()` receives one flat
40
+ field per filter, and you derive SQL parameters inside it:
39
41
 
40
42
  ```ts
41
- import { parseCount } from '@altertable/data-app/contract';
43
+ import { parseCount, searchFilter } from '@altertable/data-app/contract';
42
44
 
43
- // ... dataApp and parseSampleCountFilter
45
+ // ... dataApp
46
+ const groupName = searchFilter({ key: 'group', label: 'Group' });
44
47
  const operations = {
45
48
  sampleCountsByGroup: dataApp.defineOperation({
46
- input: parseSampleCountFilter,
47
- checks: [
48
- { groupName: '' },
49
- { groupName: 'Alpha' },
50
- { groupName: 'missing' },
51
- ],
49
+ filters: { groupName },
52
50
  policy: { maxQueryRows: 10, maxDurationMs: 15000 },
53
51
  async run({ query }, { groupName }) {
54
52
  const result = await query('sampleCountsByGroup', { groupName });
@@ -61,11 +59,13 @@ const operations = {
61
59
  };
62
60
  ```
63
61
 
64
- The starter supplies `parseSampleCountFilter()` and `parseCount()`. Validate
65
- unknown input in the parser and business rules in `run()`. Include representative
66
- valid inputs in `checks`. Derive results from `query()` rows without duplicate
67
- schemas or type assertions; clients and views infer the returned type.
68
- HTTP results must be JSON-serializable.
62
+ The filters validate input and supply the operation's checks; enforce business
63
+ rules in `run()`. Omit `filters` for an operation without inputs. An operation
64
+ with its own fields, such as a detail record ID, adds an `input` parser and
65
+ representative valid `checks` for those fields; its `filters` still parse the
66
+ scope it reads. Derive results from `query()` rows
67
+ without duplicate schemas or type assertions; clients and views infer the
68
+ returned type. HTTP results must be JSON-serializable.
69
69
 
70
70
  Host `queryParams` supplies protected parameters that callers cannot override.
71
71
  Other values come from `query()` arguments or defaults. The host/backend enforces
@@ -82,51 +82,33 @@ return SQL text and declare `string` when exact numeric precision matters.
82
82
 
83
83
  Use `operations.sampleCountsByGroup.queryNames` for context and evidence.
84
84
 
85
- ### Bind datetime ranges
85
+ ### Bind date ranges
86
86
 
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:
87
+ Declare `{ type: 'dateTimeRange' }` and pass a date filter's `range` or
88
+ `comparison`. Reference its bounds as `$period.from` (inclusive) and
89
+ `$period.to` (exclusive):
90
90
 
91
91
  ```ts
92
92
  const dataApp = defineDataApp({
93
93
  // ... title, description, and scope
94
94
  queries: {
95
- events: {
96
- statement: `SELECT occurred_at AS "occurredAt" FROM events
97
- WHERE occurred_at >= $period.from AND occurred_at < $period.to`,
95
+ dailyOrders: {
96
+ statement: `SELECT CAST(ordered_at AS DATE) AS day, count(*) AS orders
97
+ FROM orders
98
+ WHERE ordered_at >= $period.from AND ordered_at < $period.to
99
+ GROUP BY day ORDER BY day`,
98
100
  params: { period: { type: 'dateTimeRange' } },
99
- projections: { occurredAt: { type: 'string' } },
101
+ projections: {
102
+ day: { type: 'string' },
103
+ orders: { type: 'number' },
104
+ },
100
105
  },
101
106
  },
102
107
  });
103
108
  ```
104
109
 
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:
118
-
119
- ```ts
120
- import { defineDateRangeContract } from '@altertable/data-app/contract';
121
-
122
- const calendar = defineDateRangeContract({
123
- minDate: '2026-01-01',
124
- maxRangeDays: 90,
125
- timeZone: 'UTC',
126
- });
127
- ```
128
-
129
- Use the shared contract in the [datetime variable workflow](variables.md#absolute-and-relative-datetime-ranges),
130
- including optional previous-period comparison. Resolved datetime requests include
131
- the start and exclude the end. Pass the variable to `defineTimeView()` and
132
- validate operation input with its parser.
110
+ Date filters pass resolved bounds in their `timeZone`, encoded as UTC wall-clock
111
+ fields: 4 PM in the reporting zone is 16:00Z. SQL bounds are therefore
112
+ timezone-free timestamps; interpret timestamp-with-timezone columns in that same
113
+ zone. Coverage and duration limits live on the
114
+ [date filter](filters.md#date-ranges).
@@ -1,7 +1,8 @@
1
1
  # Data context and evidence
2
2
 
3
- Continue the starter's operation and context. Use its derived `queryNames` for
4
- business definitions and evidence. Reference only queries the view executes.
3
+ Continue the starter's operations and context. Build one context from every
4
+ operation's `queryNames` and share it across the app's views. Reference only
5
+ queries the app executes.
5
6
 
6
7
  ## Bind evidence
7
8
 
@@ -9,21 +10,24 @@ business definitions and evidence. Reference only queries the view executes.
9
10
  import { createDataContext } from '@altertable/data-app-react';
10
11
 
11
12
  // ... operations
12
- const queryNames = operations.sampleCountsByGroup.queryNames;
13
+ const queryNames = {
14
+ ...operations.sampleCountsByGroup.queryNames,
15
+ ...operations.sampleTotal.queryNames,
16
+ };
13
17
  const sampleDataContext = createDataContext(queryNames)({
14
18
  description: 'Sample counts for the selected groups.',
15
19
  glossary: {
16
20
  sampleCount: {
17
21
  term: 'Sample count',
18
22
  definition: 'The number of samples in each group.',
19
- queryNames: [queryNames.sampleCountsByGroup],
23
+ queryNames: [queryNames.sampleCountsByGroup, queryNames.sampleTotal],
20
24
  },
21
25
  },
22
26
  });
23
27
  ```
24
28
 
25
29
  Import `createDataContext()` from `@altertable/data-app-react`. Supply
26
- `dataContext: sampleDataContext` on `sampleCountsView`, then use its glossary IDs
30
+ `dataContext: sampleDataContext` on each view, then use its glossary IDs
27
31
  in `view.metric()` and `view.dataset()`. Reuse those bindings in widgets and stories.
28
32
  Detail views need their own context when their queries differ.
29
33