@altertable/data-app 0.59.1

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 (174) hide show
  1. package/AGENTS.md +35 -0
  2. package/CONTRIBUTING.md +83 -0
  3. package/LICENSE +21 -0
  4. package/README.md +63 -0
  5. package/dist/bootstrap.js +388 -0
  6. package/dist/chunks/contract-14vxdcrs.js +192 -0
  7. package/dist/chunks/contract-14vxdcrs.js.map +10 -0
  8. package/dist/chunks/contract-8q35dcyh.js +9 -0
  9. package/dist/chunks/contract-8q35dcyh.js.map +10 -0
  10. package/dist/chunks/contract-jksbmt5q.js +133 -0
  11. package/dist/chunks/contract-jksbmt5q.js.map +10 -0
  12. package/dist/chunks/contract-mb5nfzwg.js +375 -0
  13. package/dist/chunks/contract-mb5nfzwg.js.map +12 -0
  14. package/dist/chunks/contract-mev09s5v.js +77 -0
  15. package/dist/chunks/contract-mev09s5v.js.map +10 -0
  16. package/dist/chunks/contract-nt819swq.js +321 -0
  17. package/dist/chunks/contract-nt819swq.js.map +11 -0
  18. package/dist/chunks/contract-ryyf6dme.js +21 -0
  19. package/dist/chunks/contract-ryyf6dme.js.map +10 -0
  20. package/dist/chunks/contract-tkkc28tg.js +213 -0
  21. package/dist/chunks/contract-tkkc28tg.js.map +12 -0
  22. package/dist/chunks/contract-tqrf3ykr.js +232 -0
  23. package/dist/chunks/contract-tqrf3ykr.js.map +11 -0
  24. package/dist/chunks/contract-wz59z8pq.js +8 -0
  25. package/dist/chunks/contract-wz59z8pq.js.map +10 -0
  26. package/dist/client/index.js +27 -0
  27. package/dist/client/index.js.map +9 -0
  28. package/dist/core/appearance.js +12 -0
  29. package/dist/core/appearance.js.map +9 -0
  30. package/dist/core/config.js +8 -0
  31. package/dist/core/config.js.map +9 -0
  32. package/dist/core/contract.js +55 -0
  33. package/dist/core/contract.js.map +9 -0
  34. package/dist/core/format.js +18 -0
  35. package/dist/core/format.js.map +9 -0
  36. package/dist/embed/index.js +91 -0
  37. package/dist/embed/index.js.map +11 -0
  38. package/dist/local.js +332 -0
  39. package/dist/local.js.map +15 -0
  40. package/dist/react/embed/index.js +130 -0
  41. package/dist/react/embed/index.js.map +11 -0
  42. package/dist/react/index.css +4478 -0
  43. package/dist/react/index.js +6105 -0
  44. package/dist/react/index.js.map +90 -0
  45. package/dist/react.css.d.ts +1 -0
  46. package/dist/server.js +231 -0
  47. package/dist/server.js.map +14 -0
  48. package/dist/types/client/iframe.d.ts +39 -0
  49. package/dist/types/client/index.d.ts +42 -0
  50. package/dist/types/client/location.d.ts +15 -0
  51. package/dist/types/client/messages.d.ts +7 -0
  52. package/dist/types/client/navigation.d.ts +14 -0
  53. package/dist/types/client/transport.d.ts +15 -0
  54. package/dist/types/core/appearance.d.ts +28 -0
  55. package/dist/types/core/bridge.d.ts +35 -0
  56. package/dist/types/core/config.d.ts +14 -0
  57. package/dist/types/core/contract.d.ts +139 -0
  58. package/dist/types/core/data-view.d.ts +46 -0
  59. package/dist/types/core/date-range.d.ts +20 -0
  60. package/dist/types/core/dimension.d.ts +60 -0
  61. package/dist/types/core/format.d.ts +40 -0
  62. package/dist/types/core/invariant.d.ts +2 -0
  63. package/dist/types/core/messages.d.ts +77 -0
  64. package/dist/types/core/reading.d.ts +17 -0
  65. package/dist/types/core/variables.d.ts +82 -0
  66. package/dist/types/embed/bootstrap.d.ts +5 -0
  67. package/dist/types/embed/host.d.ts +23 -0
  68. package/dist/types/embed/index.d.ts +11 -0
  69. package/dist/types/embed/navigation.d.ts +6 -0
  70. package/dist/types/embed/shell.d.ts +21 -0
  71. package/dist/types/embed/standalone.d.ts +1 -0
  72. package/dist/types/react/content.d.ts +23 -0
  73. package/dist/types/react/embed/bridge.d.ts +12 -0
  74. package/dist/types/react/embed/index.d.ts +9 -0
  75. package/dist/types/react/embed/shell.d.ts +10 -0
  76. package/dist/types/react/hooks.d.ts +831 -0
  77. package/dist/types/react/index.d.ts +11 -0
  78. package/dist/types/react/mount.d.ts +11 -0
  79. package/dist/types/react/ui/AboutData.d.ts +61 -0
  80. package/dist/types/react/ui/AltertableLogo.d.ts +3 -0
  81. package/dist/types/react/ui/AppFooter.d.ts +7 -0
  82. package/dist/types/react/ui/AppHeader.d.ts +12 -0
  83. package/dist/types/react/ui/AppLayout.d.ts +17 -0
  84. package/dist/types/react/ui/AppScope.d.ts +8 -0
  85. package/dist/types/react/ui/AppToolbar.d.ts +32 -0
  86. package/dist/types/react/ui/Breakdown.d.ts +14 -0
  87. package/dist/types/react/ui/Button.d.ts +12 -0
  88. package/dist/types/react/ui/Checkbox.d.ts +11 -0
  89. package/dist/types/react/ui/Combobox.d.ts +43 -0
  90. package/dist/types/react/ui/ComparisonVisual.d.ts +15 -0
  91. package/dist/types/react/ui/ContentSkeleton.d.ts +8 -0
  92. package/dist/types/react/ui/DataApp.d.ts +56 -0
  93. package/dist/types/react/ui/DataBoundary.d.ts +16 -0
  94. package/dist/types/react/ui/DataSection.d.ts +28 -0
  95. package/dist/types/react/ui/DataTable.d.ts +28 -0
  96. package/dist/types/react/ui/DataViewToast.d.ts +12 -0
  97. package/dist/types/react/ui/DataWidget.d.ts +39 -0
  98. package/dist/types/react/ui/DateRangePicker.d.ts +29 -0
  99. package/dist/types/react/ui/DateTimeTooltip.d.ts +10 -0
  100. package/dist/types/react/ui/DimensionPicker.d.ts +11 -0
  101. package/dist/types/react/ui/EmptyState.d.ts +9 -0
  102. package/dist/types/react/ui/GettingStarted.d.ts +9 -0
  103. package/dist/types/react/ui/GlossaryDefinition.d.ts +8 -0
  104. package/dist/types/react/ui/GlossaryExplanation.d.ts +17 -0
  105. package/dist/types/react/ui/GradientScroll.d.ts +16 -0
  106. package/dist/types/react/ui/Grid.d.ts +13 -0
  107. package/dist/types/react/ui/GridItem.d.ts +7 -0
  108. package/dist/types/react/ui/HelpPopover.d.ts +24 -0
  109. package/dist/types/react/ui/IconButton.d.ts +19 -0
  110. package/dist/types/react/ui/InspectionContext.d.ts +10 -0
  111. package/dist/types/react/ui/Kbd.d.ts +8 -0
  112. package/dist/types/react/ui/LiveControl.d.ts +11 -0
  113. package/dist/types/react/ui/MetricWidget.d.ts +48 -0
  114. package/dist/types/react/ui/PeriodSummary.d.ts +17 -0
  115. package/dist/types/react/ui/PresentStory.d.ts +34 -0
  116. package/dist/types/react/ui/QueryList.d.ts +15 -0
  117. package/dist/types/react/ui/Ranking.d.ts +14 -0
  118. package/dist/types/react/ui/RefreshControl.d.ts +11 -0
  119. package/dist/types/react/ui/RefreshRegion.d.ts +10 -0
  120. package/dist/types/react/ui/RequestHint.d.ts +21 -0
  121. package/dist/types/react/ui/SearchField.d.ts +23 -0
  122. package/dist/types/react/ui/SearchInput.d.ts +9 -0
  123. package/dist/types/react/ui/SearchMatch.d.ts +7 -0
  124. package/dist/types/react/ui/SelectableBarChart.d.ts +16 -0
  125. package/dist/types/react/ui/SelectionMark.d.ts +5 -0
  126. package/dist/types/react/ui/Sheet.d.ts +19 -0
  127. package/dist/types/react/ui/Skeleton.d.ts +6 -0
  128. package/dist/types/react/ui/Stack.d.ts +8 -0
  129. package/dist/types/react/ui/StatusPanel.d.ts +11 -0
  130. package/dist/types/react/ui/TableWidget.d.ts +57 -0
  131. package/dist/types/react/ui/Tabs.d.ts +6 -0
  132. package/dist/types/react/ui/ThemeSelector.d.ts +13 -0
  133. package/dist/types/react/ui/Tooltip.d.ts +23 -0
  134. package/dist/types/react/ui/UpdatedAt.d.ts +10 -0
  135. package/dist/types/react/ui/VariableBar.d.ts +7 -0
  136. package/dist/types/react/ui/VisualizationWidget.d.ts +52 -0
  137. package/dist/types/react/ui/WidgetDisclosure.d.ts +7 -0
  138. package/dist/types/react/ui/WidgetEvidence.d.ts +12 -0
  139. package/dist/types/react/ui/WidgetViewTabs.d.ts +17 -0
  140. package/dist/types/react/ui/chartColor.d.ts +1 -0
  141. package/dist/types/react/ui/classNames.d.ts +1 -0
  142. package/dist/types/react/ui/comparison.d.ts +30 -0
  143. package/dist/types/react/ui/data-context.d.ts +65 -0
  144. package/dist/types/react/ui/data-identifiers.d.ts +33 -0
  145. package/dist/types/react/ui/icons.d.ts +42 -0
  146. package/dist/types/react/ui/index.d.ts +129 -0
  147. package/dist/types/react/ui/metric.d.ts +11 -0
  148. package/dist/types/react/ui/search.d.ts +6 -0
  149. package/dist/types/react/ui/searchItems.d.ts +34 -0
  150. package/dist/types/react/ui/shortcuts.d.ts +32 -0
  151. package/dist/types/react/ui/story.d.ts +20 -0
  152. package/dist/types/react/ui/variables.d.ts +36 -0
  153. package/dist/types/react/ui/widget-views.d.ts +3 -0
  154. package/dist/types/react/view-controls.d.ts +17 -0
  155. package/dist/types/react/view.d.ts +49 -0
  156. package/dist/types/server/handler.d.ts +13 -0
  157. package/dist/types/server/index.d.ts +7 -0
  158. package/dist/types/server/local.d.ts +17 -0
  159. package/docs/app-authoring.md +26 -0
  160. package/docs/appearance.md +30 -0
  161. package/docs/bootstrap.md +76 -0
  162. package/docs/client.md +127 -0
  163. package/docs/config.md +21 -0
  164. package/docs/contract.md +95 -0
  165. package/docs/embed.md +98 -0
  166. package/docs/format.md +29 -0
  167. package/docs/react-embed.md +57 -0
  168. package/docs/react-styles.md +17 -0
  169. package/docs/react.md +248 -0
  170. package/docs/releasing.md +74 -0
  171. package/docs/server-bun.md +26 -0
  172. package/docs/server.md +47 -0
  173. package/docs/starter-agent-instructions.md +51 -0
  174. package/package.json +124 -0
@@ -0,0 +1,65 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DataIdentifierDefinition } from './data-identifiers.js';
3
+ import type { MetricFormat } from '../../core/format.js';
4
+ import type { MetricDefinition } from './metric.js';
5
+ import type { StoryFinding } from './story.js';
6
+ import type { WidgetEvidence } from './WidgetEvidence.js';
7
+ export type GlossaryEntry = {
8
+ term: string;
9
+ definition: ReactNode;
10
+ queryNames?: string[];
11
+ };
12
+ export type DataContext = {
13
+ description: ReactNode;
14
+ glossary: Record<string, GlossaryEntry>;
15
+ identifiers?: Readonly<Record<string, DataIdentifierDefinition>>;
16
+ queryNames?: Readonly<Record<string, string>>;
17
+ };
18
+ export declare function defineDataContext<const Context extends DataContext>(context: Context): Context;
19
+ export declare function evidenceFor<const Context extends DataContext, const Names extends Record<string, string> = Record<string, string>>(context: Context, names?: Names): (evidence: {
20
+ id: string;
21
+ glossaryIds?: readonly (keyof Context['glossary'] & string)[];
22
+ queryNames?: readonly Names[keyof Names][];
23
+ }) => {
24
+ id: string;
25
+ glossaryIds: (keyof Context["glossary"] & string)[] | undefined;
26
+ queryNames: Names[keyof Names][] | undefined;
27
+ };
28
+ /** Bind glossary query references and card evidence to the same registry. */
29
+ export declare function createDataContext<const Names extends Record<string, string>>(queryNames: Names): <const Context extends Omit<DataContext, 'glossary'> & {
30
+ glossary: Record<string, Omit<GlossaryEntry, 'queryNames'> & {
31
+ queryNames?: Names[keyof Names][];
32
+ }>;
33
+ }>(context: Context) => Context & {
34
+ queryNames: Names;
35
+ evidence: (input: {
36
+ id: string;
37
+ } & ({
38
+ glossaryIds: readonly [keyof Context["glossary"] & string, ...(keyof Context["glossary"] & string)[]];
39
+ queryNames?: readonly Names[keyof Names][];
40
+ } | {
41
+ queryNames: readonly [Names[keyof Names], ...Names[keyof Names][]];
42
+ glossaryIds?: readonly (keyof Context["glossary"] & string)[];
43
+ })) => WidgetEvidence;
44
+ finding: (input: Omit<StoryFinding, 'evidence'> & {
45
+ evidence: Parameters<(input: {
46
+ id: string;
47
+ } & ({
48
+ glossaryIds: readonly [keyof Context["glossary"] & string, ...(keyof Context["glossary"] & string)[]];
49
+ queryNames?: readonly Names[keyof Names][];
50
+ } | {
51
+ queryNames: readonly [Names[keyof Names], ...Names[keyof Names][]];
52
+ glossaryIds?: readonly (keyof Context["glossary"] & string)[];
53
+ })) => WidgetEvidence>[0];
54
+ }) => StoryFinding & {
55
+ evidence: WidgetEvidence;
56
+ };
57
+ metric: (definition: {
58
+ id: string;
59
+ glossaryId: keyof Context['glossary'] & string;
60
+ label?: string;
61
+ format: MetricFormat;
62
+ favorableDirection?: 'up' | 'down';
63
+ queryNames?: readonly Names[keyof Names][];
64
+ }) => MetricDefinition;
65
+ };
@@ -0,0 +1,33 @@
1
+
2
+ export type TableIdentifier = {
3
+ catalog: string;
4
+ schema: string;
5
+ name: string;
6
+ };
7
+ export type ColumnIdentifier<TableId extends string = string> = {
8
+ table: TableId;
9
+ name: string;
10
+ };
11
+ export type DataIdentifierDefinition = ({
12
+ kind: 'table';
13
+ } & TableIdentifier) | {
14
+ kind: 'column';
15
+ tableId: `tables.${string}`;
16
+ table: TableIdentifier;
17
+ name: string;
18
+ };
19
+ type IdentifierId<Tables extends Record<string, TableIdentifier>, Columns extends Record<string, ColumnIdentifier<Extract<keyof Tables, string>>>> = `tables.${Extract<keyof Tables, string>}` | {
20
+ [Id in Extract<keyof Columns, string>]: `columns.${Columns[Id]['table']}.${Id}`;
21
+ }[Extract<keyof Columns, string>];
22
+ /** Register exact source names once; returned JSX IDs are checked against this registry. */
23
+ export declare function defineDataIdentifiers<const Tables extends Record<string, TableIdentifier>, const Columns extends Record<string, ColumnIdentifier<Extract<keyof Tables, string>>>>({ tables, columns }: {
24
+ tables: Tables;
25
+ columns: Columns;
26
+ }): {
27
+ definitions: Readonly<Record<IdentifierId<Tables, Columns>, DataIdentifierDefinition>>;
28
+ DataIdentifier: ({ id, display, }: {
29
+ id: IdentifierId<Tables, Columns>;
30
+ display?: 'short' | 'qualified';
31
+ }) => import("react").JSX.Element;
32
+ };
33
+ export {};
@@ -0,0 +1,42 @@
1
+ import { type LucideProps } from 'lucide-react';
2
+ /** Use semantic names to keep icon meaning and optical size consistent across controls. */
3
+ declare const brandedIcons: {
4
+ readonly cancel: import("lucide-react").LucideIcon;
5
+ readonly calendar: import("lucide-react").LucideIcon;
6
+ readonly clock: import("lucide-react").LucideIcon;
7
+ readonly check: import("lucide-react").LucideIcon;
8
+ readonly disclosure: import("lucide-react").LucideIcon;
9
+ readonly previousMonth: import("lucide-react").LucideIcon;
10
+ readonly nextMonth: import("lucide-react").LucideIcon;
11
+ readonly explore: import("lucide-react").LucideIcon;
12
+ /** @deprecated Use openDetails for inspection triggers. */
13
+ readonly inspect: import("lucide-react").LucideIcon;
14
+ readonly info: import("lucide-react").LucideIcon;
15
+ readonly openDetails: import("lucide-react").LucideIcon;
16
+ readonly present: import("lucide-react").LucideIcon;
17
+ readonly error: import("lucide-react").LucideIcon;
18
+ readonly close: import("lucide-react").LucideIcon;
19
+ readonly previous: import("lucide-react").LucideIcon;
20
+ readonly next: import("lucide-react").LucideIcon;
21
+ readonly lightTheme: import("lucide-react").LucideIcon;
22
+ readonly darkTheme: import("lucide-react").LucideIcon;
23
+ readonly live: import("lucide-react").LucideIcon;
24
+ readonly loading: import("lucide-react").LucideIcon;
25
+ readonly refresh: import("lucide-react").LucideIcon;
26
+ readonly stop: import("lucide-react").LucideIcon;
27
+ readonly reset: import("lucide-react").LucideIcon;
28
+ readonly search: import("lucide-react").LucideIcon;
29
+ readonly copy: import("lucide-react").LucideIcon;
30
+ readonly sql: import("lucide-react").LucideIcon;
31
+ readonly wrap: import("lucide-react").LucideIcon;
32
+ readonly trendDown: import("lucide-react").LucideIcon;
33
+ readonly trendFlat: import("lucide-react").LucideIcon;
34
+ readonly trendUp: import("lucide-react").LucideIcon;
35
+ };
36
+ export type AppIconName = keyof typeof brandedIcons;
37
+ export type AppIconProps = Omit<LucideProps, 'size'> & {
38
+ name: AppIconName;
39
+ size?: number;
40
+ };
41
+ export declare function AppIcon({ name, size, strokeWidth, style, ...props }: AppIconProps): import("react").FunctionComponentElement<Omit<LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
42
+ export {};
@@ -0,0 +1,129 @@
1
+
2
+ export { DataApp } from './DataApp.js';
3
+ export type { DataAppProps, DataAppRequest } from './DataApp.js';
4
+ export { GettingStarted } from './GettingStarted.js';
5
+ export { AppLayout } from './AppLayout.js';
6
+ export type { AppLayoutProps } from './AppLayout.js';
7
+ export { AppHeader } from './AppHeader.js';
8
+ export type { AppHeaderProps } from './AppHeader.js';
9
+ export { AppScope } from './AppScope.js';
10
+ export type { AppScopeProps } from './AppScope.js';
11
+ export { AppToolbar } from './AppToolbar.js';
12
+ export type { AppToolbarProps } from './AppToolbar.js';
13
+ export { VariableBar } from './VariableBar.js';
14
+ export type { VariableBarProps } from './VariableBar.js';
15
+ export { AppFooter } from './AppFooter.js';
16
+ export type { AppFooterProps } from './AppFooter.js';
17
+ export { ThemeSelector, ThemeToggle } from './ThemeSelector.js';
18
+ export type { ThemeSelectorProps } from './ThemeSelector.js';
19
+ export { Stack } from './Stack.js';
20
+ export type { StackProps } from './Stack.js';
21
+ export { Grid } from './Grid.js';
22
+ export type { GridProps } from './Grid.js';
23
+ export { GridItem } from './GridItem.js';
24
+ export type { GridItemProps } from './GridItem.js';
25
+ export type { WidgetEvidence } from './WidgetEvidence.js';
26
+ export { DataWidget } from './DataWidget.js';
27
+ export type { WidgetStatus } from './RequestHint.js';
28
+ export type { DataWidgetProps } from './DataWidget.js';
29
+ export { VisualizationWidget } from './VisualizationWidget.js';
30
+ export type { VisualizationWidgetProps, VisualizationWidgetView, } from './VisualizationWidget.js';
31
+ export { TableWidget } from './TableWidget.js';
32
+ export type { TableWidgetColumn, TableWidgetProps, TableWidgetSearch, } from './TableWidget.js';
33
+ export { chartColor } from './chartColor.js';
34
+ export { Breakdown } from './Breakdown.js';
35
+ export type { BreakdownItem, BreakdownProps } from './Breakdown.js';
36
+ export { Ranking } from './Ranking.js';
37
+ export type { RankingItem, RankingProps } from './Ranking.js';
38
+ export { WidgetDisclosure } from './WidgetDisclosure.js';
39
+ export type { WidgetDisclosureProps } from './WidgetDisclosure.js';
40
+ export { WidgetViewTabs } from './WidgetViewTabs.js';
41
+ export type { WidgetView, WidgetViewTabsProps, } from './WidgetViewTabs.js';
42
+ export { ComparisonVisual } from './ComparisonVisual.js';
43
+ export type { ComparisonVisualProps } from './ComparisonVisual.js';
44
+ export { calendarMetricComparison } from './comparison.js';
45
+ export type { MetricComparison } from './comparison.js';
46
+ export { DataTable, DataTableEmptyRow, DataTableTimestamp, DataTableShare, } from './DataTable.js';
47
+ export type { DataTableProps, DataTableSearch, DataTableEmptyRowProps, DataTableTimestampProps, } from './DataTable.js';
48
+ export { MetricWidget } from './MetricWidget.js';
49
+ export type { MetricWidgetProps } from './MetricWidget.js';
50
+ export { SelectableBarChart } from './SelectableBarChart.js';
51
+ export type { SelectableBarChartProps, SelectableBarItem, } from './SelectableBarChart.js';
52
+ export { DimensionPicker } from './DimensionPicker.js';
53
+ export { dimensionFilter, parseDimensionSelection, parseFacetOptions, dimensionPredicate, } from '../../core/dimension.js';
54
+ export type { DimensionSelection, DimensionMember, DimensionOption, DimensionVariable, DimensionFilterOptions, } from '../../core/dimension.js';
55
+ export { EmptyState } from './EmptyState.js';
56
+ export type { EmptyStateProps } from './EmptyState.js';
57
+ export { Skeleton } from './Skeleton.js';
58
+ export type { SkeletonProps } from './Skeleton.js';
59
+ export { DataBoundary } from './DataBoundary.js';
60
+ export { resolveDataView } from '../../core/data-view.js';
61
+ export { displayedSnapshot } from '../../core/data-view.js';
62
+ export type { DataView, DataSnapshot, DisplayedSnapshot, } from '../../core/data-view.js';
63
+ export type { DataBoundaryProps } from './DataBoundary.js';
64
+ export { RefreshRegion } from './RefreshRegion.js';
65
+ export type { RefreshRegionProps } from './RefreshRegion.js';
66
+ export { DataSection } from './DataSection.js';
67
+ export type { DataSectionProps, SectionResult, } from './DataSection.js';
68
+ export { StatusPanel } from './StatusPanel.js';
69
+ export type { StatusPanelProps } from './StatusPanel.js';
70
+ export { ContentSkeleton } from './ContentSkeleton.js';
71
+ export type { ContentSkeletonProps } from './ContentSkeleton.js';
72
+ export { DataViewToast } from './DataViewToast.js';
73
+ export type { DataViewToastProps } from './DataViewToast.js';
74
+ export { UpdatedAt } from './UpdatedAt.js';
75
+ export type { UpdatedAtProps } from './UpdatedAt.js';
76
+ export { DateTimeTooltip } from './DateTimeTooltip.js';
77
+ export type { DateTimeTooltipProps } from './DateTimeTooltip.js';
78
+ export { LiveControl } from './LiveControl.js';
79
+ export type { LiveControlProps, LiveIntervalSeconds, } from './LiveControl.js';
80
+ export { DateRangePicker } from './DateRangePicker.js';
81
+ export type { DatePresetId, DateRange, DateRangePickerProps, } from './DateRangePicker.js';
82
+ export { defineAppVariables, textVariable, selectVariable, dateRangeVariable, dateRangeControl, useAppVariables, } from './variables.js';
83
+ export type { AppVariable, AppVariableValues, DateRangeSelection, DateRangeVariable, DateRangeVariableOptions, } from './variables.js';
84
+ export { PeriodSummary } from './PeriodSummary.js';
85
+ export type { ReportingPeriod, PeriodComparison, PeriodSummaryProps, } from './PeriodSummary.js';
86
+ export { SearchField } from './SearchField.js';
87
+ export type { SearchFieldProps } from './SearchField.js';
88
+ export { searchItems } from './searchItems.js';
89
+ export type { SearchAttribute, SearchHit, SearchItemsOptions, SearchMatchValue, SearchRange, } from './searchItems.js';
90
+ export { SearchMatch } from './SearchMatch.js';
91
+ export type { SearchMatchProps } from './SearchMatch.js';
92
+ export { Combobox } from './Combobox.js';
93
+ export type { ComboboxOption, ComboboxProps } from './Combobox.js';
94
+ export { GradientScroll } from './GradientScroll.js';
95
+ export type { GradientScrollProps } from './GradientScroll.js';
96
+ export { searchParams, slug, subscribeSearch, writeSearch, } from './search.js';
97
+ export { Tabs, TabList, Tab, TabPanels, TabPanel, useViewTab, } from './Tabs.js';
98
+ export { createDataContext, defineDataContext, evidenceFor, } from './data-context.js';
99
+ export type { DataContext, GlossaryEntry } from './data-context.js';
100
+ export { defineDataIdentifiers } from './data-identifiers.js';
101
+ export type { DataIdentifierDefinition, TableIdentifier, ColumnIdentifier, } from './data-identifiers.js';
102
+ export type { DisclosedQuery } from '../../core/contract.js';
103
+ export { GlossaryExplanation } from './GlossaryExplanation.js';
104
+ export type { GlossaryExplanationProps } from './GlossaryExplanation.js';
105
+ export { GlossaryDefinition } from './GlossaryDefinition.js';
106
+ export type { GlossaryDefinitionProps } from './GlossaryDefinition.js';
107
+ export { AboutData } from './AboutData.js';
108
+ export type { AboutDataProps, AboutEmpty, AboutSubject, AboutTab, } from './AboutData.js';
109
+ export { PresentStory } from './PresentStory.js';
110
+ export type { PresentStoryProps } from './PresentStory.js';
111
+ export type { StoryFinding, BoundStory } from './story.js';
112
+ export { Checkbox } from './Checkbox.js';
113
+ export type { CheckboxProps } from './Checkbox.js';
114
+ export { AppIcon } from './icons.js';
115
+ export type { AppIconName, AppIconProps } from './icons.js';
116
+ export { IconButton } from './IconButton.js';
117
+ export type { IconButtonProps } from './IconButton.js';
118
+ export { Kbd } from './Kbd.js';
119
+ export type { KbdProps } from './Kbd.js';
120
+ export { Sheet } from './Sheet.js';
121
+ export type { SheetDialogProps, SheetProps } from './Sheet.js';
122
+ export { Tooltip, TooltipProvider } from './Tooltip.js';
123
+ export type { TooltipProps, TooltipProviderProps, } from './Tooltip.js';
124
+ export { Button } from './Button.js';
125
+ export type { ButtonProps } from './Button.js';
126
+ export { HelpPopover } from './HelpPopover.js';
127
+ export type { HelpPopoverPanelProps, HelpPopoverProps, HelpPopoverTriggerProps, } from './HelpPopover.js';
128
+ export type { MetricDefinition } from './metric.js';
129
+ export type { DataReading, MetricReading, MetricValues, } from '../../core/reading.js';
@@ -0,0 +1,11 @@
1
+ import type { MetricFormat } from '../../core/format.js';
2
+ import type { WidgetEvidence } from './WidgetEvidence.js';
3
+ import type { MetricReading } from '../../core/reading.js';
4
+ export type MetricDefinition = {
5
+ id: string;
6
+ label: string;
7
+ format: MetricFormat;
8
+ favorableDirection?: 'up' | 'down';
9
+ evidence: WidgetEvidence;
10
+ };
11
+ export declare function metricComparison(metric: MetricDefinition, reading: MetricReading): import("./comparison.js").MetricComparison | undefined;
@@ -0,0 +1,6 @@
1
+ export declare function searchParams(): URLSearchParams;
2
+ /** Listen to Back/Forward and writes made by another runtime control. */
3
+ export declare function subscribeSearch(listener: () => void): () => void;
4
+ /** Write search keys. `null` removes a key. Skips the history write when nothing changed. */
5
+ export declare function writeSearch(update: Record<string, string | null>, mode?: 'replace' | 'push'): void;
6
+ export declare function slug(value: string): string;
@@ -0,0 +1,34 @@
1
+ export type SearchRange = {
2
+ start: number;
3
+ end: number;
4
+ };
5
+ /** The exact displayed text and its offsets stay together for safe rendering. */
6
+ export type SearchMatchValue = {
7
+ text: string;
8
+ ranges: readonly SearchRange[];
9
+ };
10
+ export type SearchAttribute<Item> = {
11
+ name: string;
12
+ getter: (item: Item) => string;
13
+ weight?: number;
14
+ };
15
+ export type SearchHit<Item> = {
16
+ item: Item;
17
+ score: number;
18
+ /** Render displayed fields with <SearchMatch match={hit.matches.fieldName} />. */
19
+ matches: Record<string, SearchMatchValue>;
20
+ };
21
+ export type SearchItemsOptions<Item> = {
22
+ attributes: readonly [SearchAttribute<Item>, ...SearchAttribute<Item>[]];
23
+ /** Literal filtering preserves source order; fuzzy search ranks discovery results. */
24
+ mode?: 'literal' | 'fuzzy';
25
+ limit?: number;
26
+ fuzzyThreshold?: number;
27
+ };
28
+ /**
29
+ * Search only a complete local collection. Empty queries retain every item.
30
+ * When a searched field is displayed, render its match with SearchMatch:
31
+ * `hits.map(hit => <SearchMatch match={hit.matches.name} />)`.
32
+ * Fields used only to find a row need no visible highlight.
33
+ */
34
+ export declare function searchItems<Item>(items: readonly Item[], query: string, options: SearchItemsOptions<Item>): SearchHit<Item>[];
@@ -0,0 +1,32 @@
1
+ /**
2
+ * `alt` is Alt/Option, leaving character keys and browser refresh untouched; `mod` is ⌘ on Apple
3
+ * platforms and Ctrl elsewhere.
4
+ */
5
+ export type Shortcut = {
6
+ modifier: 'alt' | 'mod';
7
+ shift?: boolean;
8
+ code: string;
9
+ key: string;
10
+ };
11
+ export declare const shortcuts: {
12
+ readonly refresh: {
13
+ readonly modifier: 'alt';
14
+ readonly code: 'KeyR';
15
+ readonly key: 'R';
16
+ };
17
+ readonly aboutData: {
18
+ readonly modifier: 'alt';
19
+ readonly code: 'KeyI';
20
+ readonly key: 'I';
21
+ };
22
+ readonly playStory: {
23
+ readonly modifier: 'mod';
24
+ readonly code: 'Enter';
25
+ readonly key: 'Enter';
26
+ };
27
+ };
28
+ export declare function shortcutLabel({ modifier, shift, key }: Shortcut): string;
29
+ export declare function ariaKeyShortcuts({ modifier, shift, key }: Shortcut): string;
30
+ export declare function isEditingTarget(target: EventTarget | null): boolean;
31
+ /** Bind a page-level shortcut. Ignored while typing or while a modal layer is open. */
32
+ export declare function useShortcut(shortcut: Shortcut, action: () => void, enabled?: boolean): void;
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DisplayedSnapshot } from '../../core/data-view.js';
3
+ import type { MetricDefinition } from './metric.js';
4
+ import type { StoryStep } from './PresentStory.js';
5
+ import type { WidgetEvidence } from './WidgetEvidence.js';
6
+ import type { DataContext } from './data-context.js';
7
+ /** One consequential, inspectable finding from the displayed result. */
8
+ export type StoryFinding = {
9
+ id: string;
10
+ headline: string;
11
+ context?: string;
12
+ visual: ReactNode;
13
+ visualKind?: 'metric' | 'chart';
14
+ evidence: WidgetEvidence | MetricDefinition;
15
+ };
16
+ /** One to four findings with unique, nonempty IDs and registered evidence.
17
+ * Receives the displayed result and its original input during refresh or failure. */
18
+ export type BoundStory<Data, Input> = (snapshot: DisplayedSnapshot<Data, Input>) => readonly StoryFinding[];
19
+ /** Validate the authored findings before handing them to the presentation UI. */
20
+ export declare function storySteps(findings: readonly StoryFinding[], context: DataContext): StoryStep[];
@@ -0,0 +1,36 @@
1
+ import type { DatePresetId, DateRange } from '../../core/date-range.js';
2
+ import { type AppVariableValues, type DateRangeSelection, type DateRangeVariable, type HistoryMode, type VariableCollection } from '../../core/variables.js';
3
+ export { defineAppVariables, textVariable, selectVariable, dateRangeVariable, } from '../../core/variables.js';
4
+ export type { AppVariable, AppVariableValues, DateRangeSelection, DateRangeVariable, DateRangeVariableOptions, VariableCollection, } from '../../core/variables.js';
5
+ /** Adapt one date variable to the controlled picker without giving the picker URL ownership. */
6
+ export declare function dateRangeControl(variable: DateRangeVariable, selection: DateRangeSelection, onChange: (selection: DateRangeSelection) => void): {
7
+ minDate?: string;
8
+ maxDate: string;
9
+ maxRangeDays: number;
10
+ timeZone: string;
11
+ value: DateRange;
12
+ label: string | undefined;
13
+ onChange(range: DateRange | null): void;
14
+ onPresetChange(id: DatePresetId): void;
15
+ selectedPresetId: DatePresetId | null;
16
+ onReset(): void;
17
+ isDefault: boolean;
18
+ resetValue: DateRange;
19
+ comparison?: {
20
+ enabled: boolean;
21
+ range: DateRange | null;
22
+ onChange(enabled: boolean): void;
23
+ } | undefined;
24
+ };
25
+ /** URL is the source of truth for app variables; one update can change dependent values atomically. */
26
+ export declare function useAppVariables<const Variables extends VariableCollection>(definitions: Variables): {
27
+ values: AppVariableValues<Variables>;
28
+ set: <Key extends keyof Variables & string>(name: Key, value: AppVariableValues<Variables>[Key]) => void;
29
+ reset: <Key extends keyof Variables & string>(name: Key) => void;
30
+ update: (next: Partial<AppVariableValues<Variables>>, history?: HistoryMode) => void;
31
+ bind: <Key extends keyof Variables & string>(name: Key) => {
32
+ value: AppVariableValues<Variables>[Key];
33
+ onChange(value: AppVariableValues<Variables>[Key]): void;
34
+ resetValue: AppVariableValues<Variables>[Key];
35
+ };
36
+ };
@@ -0,0 +1,3 @@
1
+ export declare function validateWidgetViews(views: readonly {
2
+ id: string;
3
+ }[], selected: string): void;
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type AppVariableValues, type VariableCollection } from './ui/variables.js';
3
+ import type { ResolvedVariables } from './view.js';
4
+ /** URL values resolve before facets; facet keys include their dependent inputs for cached, bounded loading. */
5
+ export declare function useViewVariables<Variables extends VariableCollection>(definitions: Variables, loadFacet: (operation: string, input: unknown, signal: AbortSignal) => Promise<unknown>): {
6
+ values: AppVariableValues<Variables>;
7
+ set: <Key extends keyof Variables & string>(name: Key, value: AppVariableValues<Variables>[Key]) => void;
8
+ reset: <Key extends keyof Variables & string>(name: Key) => void;
9
+ update: (next: Partial<AppVariableValues<Variables>>, history?: import("../core/variables.js").HistoryMode) => void;
10
+ bind: <Key extends keyof Variables & string>(name: Key) => {
11
+ value: AppVariableValues<Variables>[Key];
12
+ onChange(value: AppVariableValues<Variables>[Key]): void;
13
+ resetValue: AppVariableValues<Variables>[Key];
14
+ };
15
+ resolved: ResolvedVariables<Variables>;
16
+ controls: ReactNode[] | null;
17
+ };
@@ -0,0 +1,49 @@
1
+ import type { EmptyStateProps } from './ui/EmptyState.js';
2
+ import type { AppVariableValues, DateRangeVariable, VariableCollection } from '../core/variables.js';
3
+ import type { DateRangeRequest } from '../core/contract.js';
4
+ export type ResolvedVariables<Variables extends VariableCollection> = {
5
+ [Key in keyof Variables]: Variables[Key] extends DateRangeVariable ? DateRangeRequest : AppVariableValues<Variables>[Key];
6
+ };
7
+ type DateVariableKey<Variables extends VariableCollection> = {
8
+ [Key in keyof Variables]: Variables[Key] extends DateRangeVariable ? Key : never;
9
+ }[keyof Variables] & string;
10
+ export type ViewDate<Variables extends VariableCollection, Input> = {
11
+ variable: DateVariableKey<Variables>;
12
+ /** Extract the selected range and comparison unchanged, including from nested inputs. */
13
+ input: (input: Input) => DateRangeRequest;
14
+ };
15
+ /** Read variable values from a custom operation input; omitted keys use top-level fields. */
16
+ export type ViewBindings<Variables extends VariableCollection, Input> = Partial<{
17
+ [Key in keyof Variables]: (input: Input) => ResolvedVariables<Variables>[Key];
18
+ }>;
19
+ export type DataViewDefinition<Name extends string, Variables extends VariableCollection, Input, Data> = {
20
+ operation: Name;
21
+ variables: Variables;
22
+ input: (values: ResolvedVariables<Variables>) => Input;
23
+ bindings?: ViewBindings<Variables, Input>;
24
+ /** App-owned semantics: measured zero need not mean an empty result. */
25
+ isEmpty: (data: Data) => boolean;
26
+ empty: Pick<EmptyStateProps, 'title' | 'description'>;
27
+ } & ({
28
+ date: ViewDate<Variables, Input>;
29
+ describeInput?: (input: Input) => string;
30
+ } | {
31
+ date?: never;
32
+ describeInput: (input: Input) => string;
33
+ });
34
+ export declare function describeViewInput<Input>(definition: {
35
+ variables: VariableCollection;
36
+ bindings?: Partial<Record<string, (input: Input) => unknown>>;
37
+ date?: {
38
+ variable: string;
39
+ input: (input: Input) => DateRangeRequest;
40
+ };
41
+ describeInput?: (input: Input) => string;
42
+ }): (input: Input) => string;
43
+ export declare function resolveViewInput<Variables extends VariableCollection, Input>(definition: {
44
+ input: (values: ResolvedVariables<Variables>) => Input;
45
+ date?: ViewDate<Variables, Input>;
46
+ variables: Variables;
47
+ bindings?: ViewBindings<Variables, Input>;
48
+ }, values: ResolvedVariables<Variables>): Input;
49
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type DataOperations, type Lakehouse } from '../core/contract.js';
2
+ /** Authorization result for one viewer request. A hosted adapter must scope its lakehouse client. */
3
+ export type RequestAccess = {
4
+ lakehouse: Lakehouse;
5
+ canDiscloseSql: boolean;
6
+ };
7
+ /**
8
+ * Execute named operations on the server. The app supplies operations and viewer authorization.
9
+ * JSON, Origin, and Fetch Metadata checks reject cross-site browser POSTs; they do not
10
+ * authenticate another local process. SQL is returned only when both the operation and
11
+ * authorization result permit disclosure.
12
+ */
13
+ export declare function createDataHandler(operations: DataOperations, authorize: (request: Request, operation: string) => Promise<RequestAccess>): (request: Request) => Promise<Response>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Portable request handling with app-supplied authorization.
3
+ * @module @altertable/data-app/server
4
+ * @see https://github.com/altertable-ai/data-app/blob/main/docs/server.md
5
+ */
6
+ export { createDataHandler } from './handler.js';
7
+ export type { RequestAccess } from './handler.js';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Bun local-development serving and server-only lakehouse access.
3
+ * @module @altertable/data-app/server/bun
4
+ * @see https://github.com/altertable-ai/data-app/blob/main/docs/server-bun.md
5
+ */
6
+ import { type Lakehouse } from '../core/contract.js';
7
+ import type { DataOperations } from '../core/contract.js';
8
+ /** Serve one app on localhost through the CLI's lakehouse proxy during development.
9
+ * Hosted servers must authorize every viewer and must use `createDataHandler` directly. */
10
+ export declare function serveLocalApp({ page, operations, title, port, }: {
11
+ page: Bun.HTMLBundle;
12
+ operations: DataOperations;
13
+ title: string;
14
+ port?: number;
15
+ }): Bun.Server<undefined>;
16
+ /** Server-only lakehouse adapter. Local development uses the selected CLI profile's proxy. */
17
+ export declare function localLakehouse(environment?: Record<string, string | undefined>, request?: typeof fetch): Lakehouse;
@@ -0,0 +1,26 @@
1
+ # Author a data app
2
+
3
+ An app owns its question, SQL, result parsing, business definitions, configuration,
4
+ and presentation. The package supplies contracts, request handling, typed client
5
+ calls, and reusable React UI.
6
+
7
+ 1. Inspect the source data, time coverage, and existing definitions before choosing
8
+ the exploration. Build findings from observed results and distinguish
9
+ association from cause.
10
+ 2. Define named, bounded [operations](contract.md) on the server. Put shared input
11
+ contracts in a browser-safe module and validate outputs before returning them.
12
+ 3. Use a [server handler](server.md) that authorizes each request, or the
13
+ [Bun adapter](server-bun.md) for local development.
14
+ 4. Create a typed [client](client.md) and compose [React views](react.md). Import
15
+ the operation registry with `import type` in browser code.
16
+ 5. Define glossary and query evidence, handle empty results, and preserve the
17
+ displayed input while a request refreshes or fails. A measured zero and an
18
+ unavailable value must remain distinct.
19
+ 6. Verify the app's findings and interactions against the original question.
20
+ Inspect loading, error, stale, and empty states at desktop and phone widths.
21
+
22
+ Import through `@altertable/data-app/<entry>`. Installed package files are
23
+ dependencies; customize the app's own source rather than editing `node_modules`.
24
+ SQL, credentials, and viewer authorization belong on the server.
25
+
26
+ For agent-assisted authoring, see the [starter AGENTS.md template](starter-agent-instructions.md).
@@ -0,0 +1,30 @@
1
+ # Appearance
2
+
3
+ Import `parseAppearance`, `applyAppearance`, and `createThemeController` from
4
+ `@altertable/data-app/appearance`. Parsing is safe on the server; applying tokens
5
+ and controlling theme require a browser document.
6
+
7
+ ```ts
8
+ import { parseAppearance } from '@altertable/data-app/appearance';
9
+
10
+ const appearance = parseAppearance({
11
+ mode: 'system',
12
+ accentColor: '#405d47',
13
+ density: 'comfortable',
14
+ });
15
+ ```
16
+
17
+ `parseAppearance` fills omitted settings with defaults and rejects unknown keys
18
+ or invalid values. Settings include light/dark/system mode, neutral/slate/warm
19
+ base colors, accent colors, a chart palette, density, corner radius, elevation,
20
+ and body/heading typography. Colors are six-digit hexadecimal values.
21
+
22
+ `applyAppearance(appearance)` installs semantic CSS tokens on the document root
23
+ and returns a cleanup function for system-theme listening.
24
+ `createThemeController(appearance)` applies the initial theme and provides
25
+ `getMode`, `setMode`, and `subscribe`. Viewer mode persists in local storage
26
+ independently of app-authored brand settings. Storage failures do not prevent
27
+ the selection from applying to the current page.
28
+
29
+ The React `DataApp` shell manages appearance for normal app usage. See
30
+ [configuration](config.md), [React](react.md), and [styles](react-styles.md).