@altertable/data-app 0.68.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +10 -0
- package/CONTRIBUTING.md +27 -1
- package/README.md +18 -21
- package/THIRD_PARTY_NOTICES +18 -0
- package/dist/chunks/index-22d576sn.js +153 -0
- package/dist/chunks/index-22d576sn.js.map +11 -0
- package/dist/chunks/index-2ajhmsc4.js +355 -0
- package/dist/chunks/index-2ajhmsc4.js.map +13 -0
- package/dist/chunks/{index-ktmvs916.js → index-58kks6a8.js} +37 -21
- package/dist/chunks/index-58kks6a8.js.map +13 -0
- package/dist/chunks/{index-23dktynd.js → index-7q99hf1z.js} +19 -12
- package/dist/chunks/index-7q99hf1z.js.map +10 -0
- package/dist/chunks/{index-mt93ff2b.js → index-9zqbrv2z.js} +7 -3
- package/dist/chunks/index-9zqbrv2z.js.map +10 -0
- package/dist/chunks/{index-m6n8ctfc.js → index-cv36cyna.js} +4 -4
- package/dist/chunks/index-cv36cyna.js.map +10 -0
- package/dist/chunks/{index-ag0cgnvq.js → index-q1w84fv9.js} +178 -31
- package/dist/chunks/index-q1w84fv9.js.map +15 -0
- package/dist/chunks/{index-qd5xgx6y.js → index-rew95tbg.js} +89 -21
- package/dist/chunks/index-rew95tbg.js.map +13 -0
- package/dist/chunks/{index-gvers8jw.js → index-vtpygsbq.js} +5651 -2711
- package/dist/chunks/index-vtpygsbq.js.map +126 -0
- package/dist/chunks/{index-x69p7cv7.js → index-wjt6cavj.js} +6 -4
- package/dist/chunks/index-wjt6cavj.js.map +10 -0
- package/dist/chunks/{index-f5cnbrjz.js → index-wss3gd3h.js} +39 -9
- package/dist/chunks/index-wss3gd3h.js.map +13 -0
- package/dist/chunks/{index-ev2b5aaf.js → index-xzb7sx6g.js} +4 -4
- package/dist/client/index.js +6 -6
- package/dist/core/appearance.js +1 -1
- package/dist/core/config.js +3 -3
- package/dist/core/contract.js +7 -7
- package/dist/core/contract.js.map +1 -1
- package/dist/core/format.js +10 -2
- package/dist/core/format.js.map +1 -1
- package/dist/embed/index.js +26 -25
- package/dist/embed/index.js.map +4 -4
- package/dist/index.js +3 -3
- package/dist/local.js +200 -145
- package/dist/local.js.map +10 -7
- package/dist/preview.js +1456 -0
- package/dist/preview.js.map +17 -0
- package/dist/react/embed/index.js +1 -1
- package/dist/react/index.js +500 -401
- package/dist/react/index.js.map +10 -13
- package/dist/react/ui/index.js +1851 -1476
- package/dist/react/ui/index.js.map +24 -21
- package/dist/server.js +102 -58
- package/dist/server.js.map +9 -6
- package/dist/types/client/data-client.d.ts +21 -10
- package/dist/types/client/download.d.ts +5 -0
- package/dist/types/client/iframe.d.ts +4 -2
- package/dist/types/client/logger.d.ts +10 -2
- package/dist/types/core/annotations.d.ts +5 -0
- package/dist/types/core/appearance.d.ts +2 -0
- package/dist/types/core/bridge-endpoint.d.ts +2 -2
- package/dist/types/core/bridge.d.ts +22 -0
- package/dist/types/core/config.d.ts +25 -17
- package/dist/types/core/contract.d.ts +26 -14
- package/dist/types/core/date-format.d.ts +24 -0
- package/dist/types/core/dimension-source.d.ts +64 -0
- package/dist/types/core/dimension.d.ts +33 -24
- package/dist/types/core/facets.d.ts +13 -0
- package/dist/types/core/filters.d.ts +4 -3
- package/dist/types/core/format.d.ts +5 -3
- package/dist/types/core/keys.d.ts +2 -0
- package/dist/types/core/messages.d.ts +3 -1
- package/dist/types/core/operation-types.d.ts +12 -11
- package/dist/types/core/queries.d.ts +75 -7
- package/dist/types/core/time-interval.d.ts +96 -0
- package/dist/types/core/variables.d.ts +49 -14
- package/dist/types/embed/host.d.ts +4 -4
- package/dist/types/embed/sql.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react/actions.d.ts +53 -0
- package/dist/types/react/annotations/annotation-editor-state.d.ts +2 -0
- package/dist/types/react/annotations/annotation-targets.d.ts +1 -0
- package/dist/types/react/annotations/getAnnotationProps.d.ts +5 -3
- package/dist/types/react/annotations/useAnnotationGeometry.d.ts +2 -2
- package/dist/types/react/bindings.d.ts +62 -3
- package/dist/types/react/date-formatting.d.ts +12 -0
- package/dist/types/react/details.d.ts +46 -0
- package/dist/types/react/exploration.d.ts +44 -0
- package/dist/types/react/hooks.d.ts +82 -43
- package/dist/types/react/index.d.ts +10 -2
- package/dist/types/react/search-suggestions.d.ts +8 -0
- package/dist/types/react/style-contract.d.ts +1 -5
- package/dist/types/react/ui/AboutData.d.ts +9 -4
- package/dist/types/react/ui/AreaChart.d.ts +2 -2
- package/dist/types/react/ui/BarChart.d.ts +2 -2
- package/dist/types/react/ui/Button.d.ts +2 -1
- package/dist/types/react/ui/ChartLegend.d.ts +3 -2
- package/dist/types/react/ui/ChoicePicker.d.ts +2 -0
- package/dist/types/react/ui/ComposedChartLegend.d.ts +2 -1
- package/dist/types/react/ui/DataApp.d.ts +8 -4
- package/dist/types/react/ui/DataAppFrame.d.ts +14 -3
- package/dist/types/react/ui/DataTable.d.ts +6 -4
- package/dist/types/react/ui/DataWidget.d.ts +7 -0
- package/dist/types/react/ui/DateDisplay.d.ts +9 -0
- package/dist/types/react/ui/DateRangePicker.d.ts +3 -1
- package/dist/types/react/ui/DateTimeTooltip.d.ts +3 -2
- package/dist/types/react/ui/DimensionPicker.d.ts +5 -3
- package/dist/types/react/ui/EmptyState.d.ts +1 -1
- package/dist/types/react/ui/ExplorationActionControl.d.ts +60 -0
- package/dist/types/react/ui/GradientScroll.d.ts +8 -0
- package/dist/types/react/ui/Grid.d.ts +1 -1
- package/dist/types/react/ui/InspectionProvider.d.ts +2 -2
- package/dist/types/react/ui/LineChart.d.ts +2 -2
- package/dist/types/react/ui/Menu.d.ts +3 -2
- package/dist/types/react/ui/MetricWidget.d.ts +4 -0
- package/dist/types/react/ui/NumberFilterPicker.d.ts +3 -1
- package/dist/types/react/ui/PeriodSummary.d.ts +2 -1
- package/dist/types/react/ui/PickerField.d.ts +23 -0
- package/dist/types/react/ui/PieChart.d.ts +2 -2
- package/dist/types/react/ui/PopoverSurface.d.ts +5 -0
- package/dist/types/react/ui/RequestHint.d.ts +2 -2
- package/dist/types/react/ui/SearchField.d.ts +3 -1
- package/dist/types/react/ui/SearchTypeahead.d.ts +15 -0
- package/dist/types/react/ui/SectionHeading.d.ts +8 -0
- package/dist/types/react/ui/Select.d.ts +9 -1
- package/dist/types/react/ui/Sheet.d.ts +4 -2
- package/dist/types/react/ui/TableWidget.d.ts +8 -0
- package/dist/types/react/ui/Tabs.d.ts +4 -3
- package/dist/types/react/ui/TrendChart.d.ts +3 -3
- package/dist/types/react/ui/VariableBar.d.ts +1 -1
- package/dist/types/react/ui/VisualizationWidget.d.ts +1 -1
- package/dist/types/react/ui/chart-data.d.ts +8 -6
- package/dist/types/react/ui/chart-date-axis.d.ts +15 -0
- package/dist/types/react/ui/chart-interaction.d.ts +27 -0
- package/dist/types/react/ui/chart-primitives.d.ts +4 -4
- package/dist/types/react/ui/chart-time.d.ts +19 -0
- package/dist/types/react/ui/chartColor.d.ts +1 -1
- package/dist/types/react/ui/icons.d.ts +5 -1
- package/dist/types/react/ui/index.d.ts +10 -4
- package/dist/types/react/ui/metric-comparison.d.ts +2 -2
- package/dist/types/react/ui/metric.d.ts +2 -2
- package/dist/types/react/ui/presentation.d.ts +2 -0
- package/dist/types/react/ui/searchItems.d.ts +2 -0
- package/dist/types/react/ui/use-chart-scroll-to-end.d.ts +2 -0
- package/dist/types/react/ui/variables.d.ts +1 -1
- package/dist/types/react/view-control-bar.d.ts +18 -0
- package/dist/types/react/view-controls.d.ts +3 -2
- package/dist/types/react/view-runtime.d.ts +8 -3
- package/dist/types/react/view.d.ts +28 -7
- package/dist/types/react/widgets.d.ts +22 -11
- package/dist/types/server/local.d.ts +3 -1
- package/dist/types/server/preview/host.d.ts +1 -0
- package/dist/types/server/preview/index.d.ts +16 -0
- package/dist/types/server/reload-channel.d.ts +6 -0
- package/dist/types/server/request-body.d.ts +4 -0
- package/dist/worker.js +1 -1
- package/docs/app-authoring.md +27 -12
- package/docs/client.md +6 -7
- package/docs/composition.md +84 -0
- package/docs/contract.md +45 -26
- package/docs/data-context.md +2 -0
- package/docs/embed.md +11 -3
- package/docs/formatting-and-appearance.md +36 -5
- package/docs/layout.md +31 -8
- package/docs/react-embed.md +4 -4
- package/docs/react.md +1 -1
- package/docs/server-bun.md +25 -0
- package/docs/server.md +2 -2
- package/docs/styling.md +10 -27
- package/docs/ui.md +32 -18
- package/docs/variables.md +174 -25
- package/docs/views.md +60 -29
- package/docs/widgets.md +131 -26
- package/examples/starter-data-app/index.tsx +10 -23
- package/examples/starter-local-data-app/.bun-version +1 -0
- package/examples/starter-local-data-app/.node-version +1 -0
- package/examples/starter-local-data-app/.oxfmtrc.json +4 -0
- package/examples/starter-local-data-app/.oxlintrc.json +33 -0
- package/examples/starter-local-data-app/AGENTS.md +22 -0
- package/examples/starter-local-data-app/README.md +54 -0
- package/examples/starter-local-data-app/app.ts +28 -0
- package/examples/starter-local-data-app/bunfig.toml +2 -0
- package/examples/starter-local-data-app/package.json +33 -0
- package/examples/starter-local-data-app/src/App.tsx +8 -0
- package/examples/starter-local-data-app/src/assets.d.ts +1 -0
- package/examples/starter-local-data-app/src/data-context.ts +21 -0
- package/examples/starter-local-data-app/src/favicon.svg +13 -0
- package/examples/starter-local-data-app/src/index.html +14 -0
- package/examples/starter-local-data-app/src/main.tsx +7 -0
- package/examples/starter-local-data-app/src/operations.ts +6 -0
- package/examples/starter-local-data-app/src/server.ts +6 -0
- package/examples/starter-local-data-app/tsconfig.json +21 -0
- package/package.json +13 -3
- package/dist/chunks/index-23dktynd.js.map +0 -10
- package/dist/chunks/index-ag0cgnvq.js.map +0 -13
- package/dist/chunks/index-dq7b35fn.js +0 -307
- package/dist/chunks/index-dq7b35fn.js.map +0 -13
- package/dist/chunks/index-f5cnbrjz.js.map +0 -13
- package/dist/chunks/index-gvers8jw.js.map +0 -109
- package/dist/chunks/index-ktmvs916.js.map +0 -13
- package/dist/chunks/index-m6n8ctfc.js.map +0 -10
- package/dist/chunks/index-mev09s5v.js +0 -77
- package/dist/chunks/index-mev09s5v.js.map +0 -10
- package/dist/chunks/index-mt93ff2b.js.map +0 -10
- package/dist/chunks/index-qd5xgx6y.js.map +0 -13
- package/dist/chunks/index-x69p7cv7.js.map +0 -10
- package/dist/types/react/shellStyles.d.ts +0 -3
- package/dist/types/react/ui/DataAppSkeleton.d.ts +0 -7
- /package/dist/chunks/{index-ev2b5aaf.js.map → index-xzb7sx6g.js.map} +0 -0
|
@@ -5,13 +5,15 @@ import type { DisclosedQuery } from '../core/contract.js';
|
|
|
5
5
|
import type { EmptyContent } from './ui/presentation.js';
|
|
6
6
|
export type ViewResult<Data, Input> = {
|
|
7
7
|
dataContext: DataContext;
|
|
8
|
+
timeZone?: string;
|
|
8
9
|
view: DataView<Data, Input>;
|
|
9
10
|
snapshot?: DisplayedSnapshot<Data, Input>;
|
|
10
11
|
refetch: () => unknown;
|
|
11
12
|
cancel: () => unknown;
|
|
12
13
|
refreshing: boolean;
|
|
13
14
|
queries?: DisclosedQuery[];
|
|
14
|
-
|
|
15
|
+
searchControls?: ReactNode;
|
|
16
|
+
filterControls?: ReactNode;
|
|
15
17
|
emptyFallback: EmptyContent;
|
|
16
18
|
};
|
|
17
19
|
/** The executor is private; declarations expose data composition, not subscription hooks. */
|
|
@@ -19,11 +21,14 @@ export declare class DeclaredView<Data, Input, Definition = unknown> {
|
|
|
19
21
|
#private;
|
|
20
22
|
constructor(useResult: () => ViewResult<Data, Input>, definition?: Definition);
|
|
21
23
|
static definition<Data, Input, Definition>(view: DeclaredView<Data, Input, Definition>): Definition;
|
|
22
|
-
static useResult<
|
|
24
|
+
static useResult<View extends DeclaredView<unknown, unknown>>(view: View): DeclaredViewResult<View>;
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
/** Distribute across declarations so each result keeps its own data and input together. */
|
|
27
|
+
type DeclaredViewResult<View> = View extends DeclaredView<infer Data, infer Input> ? ViewResult<Data, Input> : never;
|
|
28
|
+
export declare function useDeclaredResult<View extends DeclaredView<unknown, unknown>>(view: View): DeclaredViewResult<View>;
|
|
25
29
|
export declare const PrimaryViewContext: import("react").Context<{
|
|
26
30
|
declaration: object;
|
|
27
31
|
result: ViewResult<unknown, unknown>;
|
|
28
32
|
} | null>;
|
|
29
33
|
export declare function getViewDefinition<Data, Input, Definition>(view: DeclaredView<Data, Input, Definition>): Definition;
|
|
34
|
+
export {};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { DataContext } from './ui/data-context.js';
|
|
2
2
|
import type { EmptyContent } from './ui/presentation.js';
|
|
3
|
-
import type { AppVariableValues, DateRangeVariable, VariableCollection } from '../core/variables.js';
|
|
3
|
+
import type { AppVariableValues, DateRangeVariable, VariableCollection, CheckedFacetContexts } from '../core/variables.js';
|
|
4
4
|
import type { DateRangeRequest } from '../core/contract.js';
|
|
5
|
+
type ResolvedVariable<Variable> = Variable extends DateRangeVariable ? DateRangeRequest : AppVariableValues<{
|
|
6
|
+
value: Variable;
|
|
7
|
+
}>['value'];
|
|
5
8
|
export type ResolvedVariables<Variables extends VariableCollection> = {
|
|
6
|
-
[Key in keyof Variables]: Variables[Key] extends
|
|
9
|
+
[Key in keyof Variables]: ResolvedVariable<Variables[Key]> | (string extends keyof Variables ? undefined : never);
|
|
7
10
|
};
|
|
8
11
|
type DateVariableKey<Variables extends VariableCollection> = {
|
|
9
12
|
[Key in keyof Variables]: Variables[Key] extends DateRangeVariable ? Key : never;
|
|
@@ -17,9 +20,28 @@ export type ViewDate<Variables extends VariableCollection, Input> = {
|
|
|
17
20
|
export type ViewBindings<Variables extends VariableCollection, Input> = Partial<{
|
|
18
21
|
[Key in keyof Variables]: (input: Input) => ResolvedVariables<Variables>[Key];
|
|
19
22
|
}>;
|
|
23
|
+
type RequiredFilterBindingKeys<Variables extends VariableCollection, Input> = {
|
|
24
|
+
[Key in keyof Variables]: Variables[Key]['kind'] extends 'dateRange' ? never : Variables[Key]['kind'] extends 'choice' ? [Input] extends [Record<Key, unknown>] ? ResolvedVariables<Variables>[Key] extends Input[Key] ? never : Key : Key : Extract<Variables[Key]['presentation'], {
|
|
25
|
+
group: 'display';
|
|
26
|
+
}> extends never ? [Input] extends [Record<Key, ResolvedVariables<Variables>[Key]>] ? [ResolvedVariables<Variables>[Key]] extends [Input[Key]] ? never : Key : Key : never;
|
|
27
|
+
}[keyof Variables];
|
|
28
|
+
/** Derive compatible top-level filter bindings; require readers for other input shapes. */
|
|
29
|
+
export type ViewBindingOptions<Variables extends VariableCollection, Input, AdditionalRequired extends keyof Variables = never> = [RequiredFilterBindingKeys<Variables, Input> | AdditionalRequired] extends [
|
|
30
|
+
never
|
|
31
|
+
] ? {
|
|
32
|
+
bindings?: ViewBindings<Variables, Input>;
|
|
33
|
+
} : {
|
|
34
|
+
bindings: ViewBindings<Variables, Input> & {
|
|
35
|
+
[Key in RequiredFilterBindingKeys<Variables, Input> | AdditionalRequired]-?: (input: Input) => ResolvedVariables<Variables>[Key];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
20
38
|
type SameViewInput<Variables extends VariableCollection, Input> = [
|
|
21
39
|
ResolvedVariables<Variables>
|
|
22
|
-
] extends [Input] ? [Input] extends [
|
|
40
|
+
] extends [Input] ? [Input] extends [
|
|
41
|
+
{
|
|
42
|
+
[Key in keyof Variables]: Variables[Key]['kind'] extends 'choice' ? string : ResolvedVariables<Variables>[Key];
|
|
43
|
+
}
|
|
44
|
+
] ? [Input] extends [Record<string, never>] ? true : [keyof Input] extends [keyof Variables] ? true : false : false : false;
|
|
23
45
|
type ViewInputMapping<Variables extends VariableCollection, Input> = SameViewInput<Variables, Input> extends true ? {
|
|
24
46
|
input?: (values: ResolvedVariables<Variables>) => Input;
|
|
25
47
|
} : {
|
|
@@ -28,16 +50,15 @@ type ViewInputMapping<Variables extends VariableCollection, Input> = SameViewInp
|
|
|
28
50
|
export type DataViewDefinition<Name extends string, Variables extends VariableCollection, Input, Data> = {
|
|
29
51
|
operation: Name;
|
|
30
52
|
dataContext: DataContext;
|
|
31
|
-
bindings?: ViewBindings<Variables, Input>;
|
|
32
53
|
/** App-owned semantics: measured zero need not mean an empty result. */
|
|
33
54
|
isEmpty: (data: Data) => boolean;
|
|
34
55
|
/** Inherited by DataSection unless it supplies its own copy. */
|
|
35
56
|
emptyFallback: EmptyContent;
|
|
36
57
|
} & (keyof Variables extends never ? {
|
|
37
|
-
variables?: Variables
|
|
58
|
+
variables?: Variables & CheckedFacetContexts<NoInfer<Variables>>;
|
|
38
59
|
} : {
|
|
39
|
-
variables: Variables
|
|
40
|
-
}) & ViewInputMapping<NoInfer<Variables>, Input> & ({
|
|
60
|
+
variables: Variables & CheckedFacetContexts<NoInfer<Variables>>;
|
|
61
|
+
}) & ViewInputMapping<NoInfer<Variables>, Input> & ViewBindingOptions<NoInfer<Variables>, Input> & ({
|
|
41
62
|
date: ViewDate<Variables, Input>;
|
|
42
63
|
describeInput?: (input: Input) => string;
|
|
43
64
|
} | {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { type ExplorationActions } from './actions.js';
|
|
2
|
+
import { type BreakdownTarget } from './exploration.js';
|
|
3
|
+
import { type ItemActions } from './ui/ExplorationActionControl.js';
|
|
1
4
|
import { type Dataset, type Metric, type ViewSource } from './bindings.js';
|
|
2
5
|
import { type MetricWidgetProps as DisplayMetricProps } from './ui/MetricWidget.js';
|
|
3
6
|
import { type TableWidgetProps as DisplayTableProps, type TableDisplayMode } from './ui/TableWidget.js';
|
|
@@ -8,29 +11,35 @@ import type { MetricValues } from '../core/reading.js';
|
|
|
8
11
|
import type { MetricDefinition } from './ui/metric.js';
|
|
9
12
|
import type { ReactNode } from 'react';
|
|
10
13
|
import type { DataReading } from '../core/reading.js';
|
|
14
|
+
import { MetricRecords } from './bindings.js';
|
|
11
15
|
export type MetricWidgetProps<Data = unknown, Input = unknown> = Omit<Extract<DisplayMetricProps, {
|
|
12
16
|
metric: MetricDefinition;
|
|
13
|
-
}>, 'metric' | 'reading'> & {
|
|
17
|
+
}>, 'metric' | 'reading' | 'records'> & {
|
|
14
18
|
metric: Metric<Data, Input>;
|
|
15
|
-
source: ViewSource<Data
|
|
19
|
+
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
20
|
+
records?: MetricRecords<Data, Input, any, any>;
|
|
21
|
+
actions?: ExplorationActions<void, NoInfer<Input>>;
|
|
16
22
|
};
|
|
17
|
-
export declare function MetricWidget<Data, Input>({ metric, source, ...presentation }: MetricWidgetProps<Data, Input>): import("react").JSX.Element;
|
|
23
|
+
export declare function MetricWidget<Data, Input>({ metric, source, records, actions, action, ...presentation }: MetricWidgetProps<Data, Input>): import("react").JSX.Element;
|
|
18
24
|
type BoundTableProps<Row> = Extract<DisplayTableProps<Row>, {
|
|
19
25
|
reading: DataReading<readonly Row[]>;
|
|
20
26
|
}>;
|
|
21
27
|
type TablePresentation<Row> = Pick<BoundTableProps<Row>, 'title' | 'columns' | 'rowKey' | 'reading' | 'evidence' | 'emptyFallback'>;
|
|
22
28
|
export type TableWidgetProps<Row, Data = unknown, Input = unknown> = Omit<BoundTableProps<Row>, keyof TablePresentation<Row> | 'limit' | 'pagination'> & TableDisplayMode & {
|
|
23
29
|
dataset: Dataset<Data, Input, Row>;
|
|
24
|
-
source: ViewSource<Data
|
|
30
|
+
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
25
31
|
title?: ReactNode;
|
|
32
|
+
actions?: ExplorationActions<NoInfer<Row>, NoInfer<Input>>;
|
|
26
33
|
};
|
|
27
|
-
export declare function TableWidget<Row, Data, Input>({ dataset, source, title, ...presentation }: TableWidgetProps<Row, Data, Input>): import("react").JSX.Element;
|
|
34
|
+
export declare function TableWidget<Row, Data, Input>({ dataset, source, title, actions, ...presentation }: TableWidgetProps<Row, Data, Input>): import("react").JSX.Element;
|
|
28
35
|
type BoundVisual<Row> = Extract<DisplayVisualProps<readonly Row[]>, {
|
|
29
36
|
reading: DataReading<readonly Row[]>;
|
|
30
37
|
}>;
|
|
31
|
-
export type VisualizationWidgetView<Row> = DisplayVisualizationView<readonly Row[]
|
|
38
|
+
export type VisualizationWidgetView<Row> = Omit<DisplayVisualizationView<readonly Row[]>, 'render'> & {
|
|
39
|
+
render: (rows: readonly Row[], actions: ItemActions<Row>) => ReactNode;
|
|
40
|
+
};
|
|
32
41
|
type VisualContent<Row> = {
|
|
33
|
-
children: (rows: readonly Row[]) => ReactNode;
|
|
42
|
+
children: (rows: readonly Row[], actions: ItemActions<Row>) => ReactNode;
|
|
34
43
|
views?: never;
|
|
35
44
|
viewLabel?: never;
|
|
36
45
|
initialView?: never;
|
|
@@ -42,19 +51,21 @@ type VisualContent<Row> = {
|
|
|
42
51
|
};
|
|
43
52
|
export type VisualizationWidgetProps<Row, Data = unknown, Input = unknown> = Omit<BoundVisual<Row>, 'reading' | 'isEmpty' | 'emptyFallback' | 'evidence' | 'title' | 'children' | 'views' | 'viewLabel' | 'initialView'> & VisualContent<Row> & {
|
|
44
53
|
dataset: Dataset<Data, Input, Row>;
|
|
45
|
-
source: ViewSource<Data
|
|
54
|
+
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
46
55
|
title?: ReactNode;
|
|
56
|
+
actions?: ExplorationActions<NoInfer<Row>, NoInfer<Input>>;
|
|
57
|
+
breakdown?: BreakdownTarget<any>;
|
|
47
58
|
};
|
|
48
|
-
export declare function VisualizationWidget<Row, Data, Input>({ dataset, source, title, ...presentation }: VisualizationWidgetProps<Row, Data, Input>): import("react").JSX.Element;
|
|
59
|
+
export declare function VisualizationWidget<Row, Data, Input>({ dataset, source, title, actions, breakdown, children, views, viewLabel, initialView, ...presentation }: VisualizationWidgetProps<Row, Data, Input>): import("react").JSX.Element;
|
|
49
60
|
type NarrativeBinding<Data, Input, Row> = {
|
|
50
61
|
metric: Metric<Data, Input>;
|
|
51
62
|
dataset?: never;
|
|
52
|
-
source: ViewSource<Data
|
|
63
|
+
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
53
64
|
children?: (values: MetricValues) => ReactNode;
|
|
54
65
|
} | {
|
|
55
66
|
metric?: never;
|
|
56
67
|
dataset: Dataset<Data, Input, Row>;
|
|
57
|
-
source: ViewSource<Data
|
|
68
|
+
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
58
69
|
children: (rows: readonly Row[]) => ReactNode;
|
|
59
70
|
};
|
|
60
71
|
export type TextWidgetProps<Data = unknown, Input = unknown, Row = never> = Omit<Extract<DisplayTextProps<unknown>, {
|
|
@@ -13,5 +13,7 @@ export declare function serveLocalApp({ page, operations, title, port, }: {
|
|
|
13
13
|
title: string;
|
|
14
14
|
port?: number;
|
|
15
15
|
}): Bun.Server<undefined>;
|
|
16
|
-
/**
|
|
16
|
+
/** Throw an actionable startup error when the selected lakehouse credentials are missing. */
|
|
17
|
+
export declare function validateLakehouseCredentials(environment?: Record<string, string | undefined>): void;
|
|
18
|
+
/** Server-only SDK adapter. Local development uses the selected CLI profile's proxy. */
|
|
17
19
|
export declare function localLakehouse(environment?: Record<string, string | undefined>, request?: typeof fetch): Lakehouse;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Lakehouse } from '../../core/contract.js';
|
|
2
|
+
export type AppFilePreviewOptions = {
|
|
3
|
+
/** Absolute path to the app source. */
|
|
4
|
+
file: string;
|
|
5
|
+
/** Localhost port. Use 0 to select an available port. Defaults to 25837. */
|
|
6
|
+
port?: number;
|
|
7
|
+
/** Server-only query backend; the caller owns credentials and profile selection. */
|
|
8
|
+
lakehouse: Lakehouse;
|
|
9
|
+
};
|
|
10
|
+
export type AppFilePreview = {
|
|
11
|
+
url: URL;
|
|
12
|
+
/** Stop serving, close reload connections, and release all file watchers. */
|
|
13
|
+
stop(): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
/** Preview a single-file app in the hosted sandbox. Requires the Bun runtime. */
|
|
16
|
+
export declare function serveAppFile({ file: appFile, port, lakehouse, }: AppFilePreviewOptions): Promise<AppFilePreview>;
|
package/dist/worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/embed/runtime-html.ts
|
|
2
2
|
var PAGE_CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; connect-src 'none'; form-action 'none'; base-uri 'none'";
|
|
3
|
-
var inlineBootstrap = '(()=>{function q(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,(r)=>r.toString(16).padStart(2,"0"));return[t.slice(0,4),t.slice(4,6),t.slice(6,8),t.slice(8,10),t.slice(10)].map((r)=>r.join("")).join("-")}function X(e){if(!e||typeof e!=="object")return!1;let t=e;return(t.method==="log"||t.method==="info"||t.method==="warn"||t.method==="error")&&Array.isArray(t.args)&&t.args.length<=128}var U="altertable:data-app";var J=128,Z=60000;function M(e){return typeof e==="string"&&/^[a-zA-Z0-9_-]{1,128}$/.test(e)}function g({wire:e,from:t,session:r,parse:n}){return{wire:e,from:t,session:r,parse:n}}function j(e){if(!M(e.id))throw Error("Invalid request ID.");return e.id}function L(e,t){let r=e[t];if(typeof r!=="string")throw Error(`Invalid ${t}.`);return r}function A(){return{}}var m={channel:U,version:1,events:{connect:g({wire:"bridge:connect",from:"host",session:"none",parse:A}),ready:g({wire:"bridge:ready",from:"app",session:"none",parse:A}),initialize:g({wire:"bridge:initialize",from:"host",session:"establish",parse:(e)=>({state:e.state})}),request:g({wire:"bridge:request",from:"app",session:"current",parse:(e)=>{let t=L(e,"route");if(!t||t.length>256)throw Error("Invalid message route.");return{id:j(e),route:t,payload:e.payload}}}),result:g({wire:"bridge:result",from:"host",session:"current",parse:(e)=>{if(!Object.hasOwn(e,"response"))throw Error("Missing response.");return{id:j(e),response:e.response}}}),error:g({wire:"bridge:error",from:"host",session:"current",parse:(e)=>{if(e.requestId!==void 0&&typeof e.requestId!=="string")throw Error("Invalid requestId.");return{id:j(e),code:L(e,"code"),message:L(e,"message"),...e.requestId===void 0?{}:{requestId:e.requestId}}}}),cancel:g({wire:"bridge:cancel",from:"app",session:"current",parse:(e)=>({id:j(e)})}),disconnect:g({wire:"bridge:disconnect",from:"app",session:"current",parse:A}),scriptLoad:g({wire:"script:load",from:"host",session:"current",parse:(e)=>({javascript:L(e,"javascript")})}),stateUpdate:g({wire:"state:update",from:"host",session:"current",parse:(e)=>({state:e.state})}),runtimeLog:g({wire:"runtime:log",from:"app",session:"current",parse:(e)=>{if(!X(e.payload))throw Error("Invalid log entry.");return{payload:e.payload}}}),runtimeReady:g({wire:"runtime:ready",from:"app",session:"current",parse:A}),runtimeError:g({wire:"runtime:error",from:"app",session:"current",parse:A})}},_=new Map;for(let e of Object.keys(m.events)){let t=m.events[e].wire;if(_.has(t))throw Error(`Duplicate bridge event: ${t}`);_.set(t,e)}function C(e){return _.get(e)}function F(e){if(!e||typeof e!=="object")return;let t=e;if(t.channel!==U||t.version!==m.version||typeof t.type!=="string"||typeof t.documentId!=="string"||!t.documentId||t.documentId.length>128||t.sessionId!==void 0&&!M(t.sessionId)||t.token!==void 0&&typeof t.token!=="string")return;return t}function W(e,t){try{return{channel:U,version:m.version,documentId:e.documentId,...e.sessionId===void 0?{}:{sessionId:e.sessionId},...e.token===void 0?{}:{token:e.token},type:t.wire,...t.parse(e)}}catch{return}}function Y(e){let t=F(e);if(!t)return;let r=C(t.type);if(!r)return;let n=m.events[r];if(n.session!=="none"&&t.sessionId===void 0)return;return W(t,n)}function ee({role:e,origin:t,source:r,opaque:n,context:o,post:d,diagnostic:a,invalidRequest:u,handlers:l}){let c=!1;function p(b,R){if(c)throw Error("The bridge endpoint has closed.");let i=m.events[b],f=o(),k=Y({...R,channel:m.channel,version:m.version,type:i.wire,documentId:b==="connect"?"host":f.documentId,sessionId:f.sessionId,token:n?f.token:void 0});if(!k||n&&!M(f.token))throw Error("The bridge is not ready to send this event.");if(a?.("send",i.wire),c)return;d(k)}function v(b){let R=r();if(c||!R||b.origin!==t||b.source!==R)return;let i=F(b.data);if(!i)return;let f=o(),k=e==="app"&&i.type===m.events.connect.wire;if(n&&(k?!M(i.token):!f.token||i.token!==f.token))return;let B=C(i.type);if(!B)return;let x=m.events[B];if(x.from===e)return;if(x.session==="establish"){if(i.documentId!==f.documentId||i.sessionId===void 0)return}else if(x.session==="current"){if(!f.sessionId||i.sessionId!==f.sessionId||i.documentId!==f.documentId)return}let N=W(i,x);if(!N){if(e==="host"&&B==="request"&&M(i.id))u?.(i.id);return}if(a?.("receive",x.wire),c)return;let T=l[B];T(N)}return{send:p,receive:v,dispose(){c=!0}}}function ge(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&Number.isFinite(e)}function V(e){return!!e&&typeof e==="object"&&!Array.isArray(e)&&Object.values(e).every(ge)}var te=Symbol.for("@altertable/data-app/MessageRoutingError");class h extends Error{code;requestId;[te]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[te]===!0}constructor(e,t,r){super(t);this.code=e;this.requestId=r;this.name="MessageRoutingError"}}function me(e){return e}function re(e){return{operations:e,input(t){if(!t||typeof t!=="object")throw Error("Invalid query.");let r=t;if(typeof r.operation!=="string"||!r.operation||r.operation.length>256||r.operation.includes("/"))throw Error("Invalid operation.");let n=e&&Object.hasOwn(e,r.operation)?e[r.operation]:void 0;if(e&&!n)throw Error("Unknown operation.");return{operation:r.operation,input:n?n.input(r.input):r.input}},output(t,r){if(!t||typeof t!=="object")throw Error("Invalid data response.");let n=t;if(!Number.isInteger(n.status)||n.status<100||n.status>599||!n.body||typeof n.body!=="object"||Array.isArray(n.body))throw Error("Invalid data response.");let o=n.body;if(n.status<200||n.status>=300){let a=o.error;throw new h(typeof a?.code==="string"?a.code:"request_failed",typeof a?.message==="string"?a.message:"Could not load data.",typeof a?.requestId==="string"?a.requestId:void 0)}if(!("data"in o)||typeof o.requestId!=="string"||typeof o.queriedAt!=="string"||!Array.isArray(o.queryIds)||!o.queryIds.every((a)=>typeof a==="string"))throw Error("Invalid data envelope.");if(o.queries!==void 0&&(!Array.isArray(o.queries)||!o.queries.every((a)=>a&&typeof a==="object"&&typeof a.name==="string"&&typeof a.statement==="string"&&(a.params===void 0||V(a.params))&&(a.queryId===void 0||typeof a.queryId==="string"))))throw Error("Invalid query evidence.");let d=e?.[r.operation];return{status:n.status,body:{...o,data:d?d.output(o.data):o.data}}}}}var ne=me({input(e){if(!e||typeof e!=="object")throw Error("Invalid SQL query.");let t=e;if(typeof t.statement!=="string"||!t.statement.trim()||typeof t.limit!=="number"||!Number.isSafeInteger(t.limit)||t.limit<1||t.params!==void 0&&!V(t.params))throw Error("Invalid SQL query.");return{statement:t.statement,limit:t.limit,...t.params===void 0?{}:{params:t.params}}},output(e,t){if(!e||typeof e!=="object")throw Error("Invalid query result.");let r=e;if(!Array.isArray(r.columns)||!r.columns.every((n)=>n&&typeof n.name==="string"&&(n.type===void 0||typeof n.type==="string"))||!Array.isArray(r.rows)||r.rows.length>t.limit||!r.rows.every((n)=>Array.isArray(n)&&n.length===r.columns.length)||r.queryId!==void 0&&typeof r.queryId!=="string")throw Error("Invalid query result.");return{columns:r.columns,rows:r.rows,...r.queryId===void 0?{}:{queryId:r.queryId}}}});function oe(e,t){return{async request(r,n,{signal:o}={}){if(o?.throwIfAborted(),!Object.hasOwn(e,r))throw new h("unknown_route","Unknown message route.");let d=e[r],a;try{a=d.input(n)}catch{throw new h("invalid_payload","Invalid message payload.")}let u=await t({route:r,payload:a},o);o?.throwIfAborted();try{return d.output(u,a)}catch(l){if(l instanceof h)throw l;throw new h("invalid_response","Invalid message response.")}}}}var se=Symbol.for("@altertable/data-app/DataAppError");class E extends Error{code;requestId;[se]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[se]===!0}constructor(e,t,r){super(e);this.code=t;this.requestId=r;this.name="DataAppError"}}function ae(e,t){function r(o){if(o.length===1&&typeof o[0]==="function"){let d=o[0]();return Array.isArray(d)?d:[d]}return o.map((d)=>typeof d==="function"?d():d)}function n(o,d){if(!e())return;try{t({method:o,args:r(d)})}catch{}}return{log:(...o)=>n("log",o),info:(...o)=>n("info",o),warn:(...o)=>n("warn",o),error:(...o)=>n("error",o)}}function ie(e,t){if(t.type==="runtime:log")return;e.log(()=>{let r={type:t.type};if("id"in t)r.id=t.id;if(t.type==="bridge:request"){r.route=t.route;let n=t.payload;if(t.route==="data:query"&&n&&typeof n==="object"&&"operation"in n&&typeof n.operation==="string")r.operation=n.operation}return["Sending message to parent",r]})}function de(e){if(e instanceof h)throw new E(e.message,e.code,e.requestId);throw e}function ue({parentOrigin:e,window:t=window,timeoutMs:r=Z,mode:n="url",loadScript:o}){if(new URL(e).origin!==e)throw Error("Expected an exact parent origin.");let d=q(),a,u,l=!1,c=new Map,p,v=new Set,b=ae(()=>!l&&!!u&&!!p&&typeof p==="object"&&("logging"in p)&&p.logging===!0,(s)=>i("runtimeLog",{payload:s})),R=ee({role:"app",origin:e,source:()=>t.parent,opaque:n==="bundle",context:()=>({documentId:d,sessionId:u,token:a}),post(s){t.parent.postMessage(s,e),ie(b,s)},handlers:{connect(s){if(n==="bundle")a=s.token;i("ready",{})},initialize(s){if(u&&u!==s.sessionId)for(let I of c.values())I.reject(new E("The preview reconnected. Retry the request.","bridge_reset"));let y=!u;if(u=s.sessionId,k(s.state),y)for(let I of c.values())I.start();if(l)return;if(n==="url")i("runtimeReady",{})},stateUpdate(s){k(s.state)},scriptLoad(s){if(n==="bundle")o?.(s.javascript)},result(s){c.get(s.id)?.resolve(s.response)},error(s){c.get(s.id)?.reject(new h(s.code,s.message,s.requestId))}}}),{send:i,receive:f}=R;function k(s){p=s;for(let y of v)y(s)}t.addEventListener("message",f);function B(s,y){return new Promise((I,w)=>{if(l)return w(new E("The preview has closed.","bridge_closed"));if(y?.aborted)return w(y.reason);if(c.size>=J)return w(new E("Too many pending data requests.","bridge_busy"));let O=q(),Q=!1;function P(){clearTimeout(ye),y?.removeEventListener("abort",G),c.delete(O)}function G(){if(Q)i("cancel",{id:O});P(),w(y?.reason)}let ye=setTimeout(()=>{if(Q)i("cancel",{id:O});P(),w(new E(u?"The data request timed out.":"The preview shell is unavailable. Reload the preview.",u?"timeout":"bridge_unavailable"))},r),K={start(){if(Q)return;try{i("request",{id:O,route:s.route,payload:s.payload}),Q=!0}catch{P(),w(new E("The message payload could not be sent.","invalid_payload"))}},resolve(S){P(),I(S)},reject(S){P(),w(S)}};if(c.set(O,K),y?.addEventListener("abort",G,{once:!0}),u)K.start();else if(n==="url"||a)i("ready",{})})}let x=oe({"data:query":re(),"data:sql":ne},B);function N(s,y,I){return x.request("data:query",{operation:s,input:y},{signal:I}).catch(de)}function T(){if(u)i("disconnect",{});u=void 0;for(let s of c.values())s.reject(new E("The preview has closed.","bridge_closed"))}function H(s){if(s.persisted&&(n==="url"||a))i("ready",{})}function fe(){if(l)return;T(),l=!0,R.dispose(),t.removeEventListener("message",f),t.removeEventListener("pagehide",T),t.removeEventListener("pageshow",H),v.clear()}if(t.addEventListener("pagehide",T),t.addEventListener("pageshow",H),n==="url")i("ready",{});return{logger:b,request:B,transport:N,lakehouse:{queryAll(s,{limit:y,signal:I,params:w}){return x.request("data:sql",{statement:s,limit:y,...w===void 0?{}:{params:w}},{signal:I}).catch(de)}},dispose:fe,mode:n,snapshot(){return p},subscribe(s){return v.add(s),()=>{v.delete(s)}},ready(){if(!l&&u)i("runtimeReady",{})},fail(){if(!l&&u)i("runtimeError",{})}}}var z=Symbol.for("altertable.localFrameBridge"),D=Symbol.for("altertable.installedTransport");function pe(e,t=window){let r=t;if(r[D])throw Error("A data app transport is already installed.");return r[z]=e,r[D]=e,()=>{if(r[z]===e)delete r[z];if(r[D]===e)delete r[D];e.dispose()}}function ce({parentOrigin:e,window:t=window}){let r,n=!1,o=`altertable-data-app-${q()}.js`,d=ue({parentOrigin:e,window:t,mode:"bundle",loadScript(p){if(r!==void 0){if(p===r)if(n)d.fail();else d.ready();else d.fail();return}r=p;try{let v=t.document.createElement("script");if(v.textContent=`${p}\n//# sourceURL=${o}`,t.document.body.append(v),!n)d.ready()}catch{a()}}});function a(){n=!0,d.fail()}function u(p){if(p.filename===o)a()}function l(p){if(p.reason instanceof Error&&p.reason.stack?.includes(o))a()}t.addEventListener("error",u),t.addEventListener("unhandledrejection",l);let c=pe(d,t);return()=>{t.removeEventListener("error",u),t.removeEventListener("unhandledrejection",l),c()}}var le=document.currentScript?.dataset.parentOrigin;if(!le)throw Error("Missing trusted parent origin.");ce({parentOrigin:le});})();\n'.replace(/<\/script/gi, (match) => `<\\${match.slice(1)}`);
|
|
3
|
+
var inlineBootstrap = '(()=>{function q(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,(r)=>r.toString(16).padStart(2,"0"));return[t.slice(0,4),t.slice(4,6),t.slice(6,8),t.slice(8,10),t.slice(10)].map((r)=>r.join("")).join("-")}function Y(e){if(!e||typeof e!=="object")return!1;let t=e;return(t.method==="log"||t.method==="info"||t.method==="warn"||t.method==="error")&&Array.isArray(t.args)&&t.args.length<=128}var C="altertable:data-app";var Z=128,ee=60000;function T(e){return typeof e==="string"&&/^[a-zA-Z0-9_-]{1,128}$/.test(e)}function w({wire:e,from:t,session:r,parse:n}){return{wire:e,from:t,session:r,parse:n}}function F(e){if(!T(e.id))throw Error("Invalid request ID.");return e.id}function S(e,t){let r=e[t];if(typeof r!=="string")throw Error(`Invalid ${t}.`);return r}function O(){return{}}var h={channel:C,version:1,events:{connect:w({wire:"bridge:connect",from:"host",session:"none",parse:O}),ready:w({wire:"bridge:ready",from:"app",session:"none",parse:O}),initialize:w({wire:"bridge:initialize",from:"host",session:"establish",parse:(e)=>({state:e.state})}),request:w({wire:"bridge:request",from:"app",session:"current",parse:(e)=>{let t=S(e,"route");if(!t||t.length>256)throw Error("Invalid message route.");return{id:F(e),route:t,payload:e.payload}}}),result:w({wire:"bridge:result",from:"host",session:"current",parse:(e)=>{if(!Object.hasOwn(e,"response"))throw Error("Missing response.");return{id:F(e),response:e.response}}}),error:w({wire:"bridge:error",from:"host",session:"current",parse:(e)=>{if(e.requestId!==void 0&&typeof e.requestId!=="string")throw Error("Invalid requestId.");return{id:F(e),code:S(e,"code"),message:S(e,"message"),...e.requestId===void 0?{}:{requestId:e.requestId}}}}),cancel:w({wire:"bridge:cancel",from:"app",session:"current",parse:(e)=>({id:F(e)})}),disconnect:w({wire:"bridge:disconnect",from:"app",session:"current",parse:O}),scriptLoad:w({wire:"script:load",from:"host",session:"current",parse:(e)=>({javascript:S(e,"javascript")})}),stateUpdate:w({wire:"state:update",from:"host",session:"current",parse:(e)=>({state:e.state})}),runtimeLog:w({wire:"runtime:log",from:"app",session:"current",parse:(e)=>{if(!Y(e.payload))throw Error("Invalid log entry.");return{payload:e.payload}}}),runtimeReady:w({wire:"runtime:ready",from:"app",session:"current",parse:O}),runtimeError:w({wire:"runtime:error",from:"app",session:"current",parse:O})}};function V(e){let t={type:e.type};if("id"in e)t.id=e.id;if(e.type==="bridge:request"){t.route=e.route;let r=e.payload;if(e.route==="data:query"&&r&&typeof r==="object"&&"operation"in r&&typeof r.operation==="string")t.operation=r.operation.slice(0,256)}if(e.type==="bridge:error")t.error={code:e.code,message:e.message,...e.requestId===void 0?{}:{requestId:e.requestId}};return t}var U=new Map;for(let e of Object.keys(h.events)){let t=h.events[e].wire;if(U.has(t))throw Error(`Duplicate bridge event: ${t}`);U.set(t,e)}function W(e){return U.get(e)}function z(e){if(!e||typeof e!=="object")return;let t=e;if(t.channel!==C||t.version!==h.version||typeof t.type!=="string"||typeof t.documentId!=="string"||!t.documentId||t.documentId.length>128||t.sessionId!==void 0&&!T(t.sessionId)||t.token!==void 0&&typeof t.token!=="string")return;return t}function K(e,t){try{return{channel:C,version:h.version,documentId:e.documentId,...e.sessionId===void 0?{}:{sessionId:e.sessionId},...e.token===void 0?{}:{token:e.token},type:t.wire,...t.parse(e)}}catch{return}}function te(e){let t=z(e);if(!t)return;let r=W(t.type);if(!r)return;let n=h.events[r];if(n.session!=="none"&&t.sessionId===void 0)return;return K(t,n)}function re({role:e,origin:t,source:r,opaque:n,context:o,post:i,diagnostic:l,invalidRequest:u,handlers:y}){let c=!1;function a(g,p){l?.({direction:"drop",reason:g,...typeof p==="string"?{type:p.slice(0,64)}:{}})}function b(g,p){if(c)throw Error("The bridge endpoint has closed.");let d=h.events[g],f=o(),E=te({...p,channel:h.channel,version:h.version,type:d.wire,documentId:g==="connect"?"host":f.documentId,sessionId:f.sessionId,token:n?f.token:void 0});if(!E||n&&!T(f.token))throw Error("The bridge is not ready to send this event.");if(l?.({direction:"send",...V(E)}),c)return;i(E)}function Q(g){let p=r();if(c||!p||g.origin!==t||g.source!==p)return;let d=z(g.data);if(!d){let k=g.data;if(k&&typeof k==="object"&&"channel"in k&&k.channel===h.channel)a("invalid_envelope","type"in k?k.type:void 0);return}let f=o(),E=e==="app"&&d.type===h.events.connect.wire;if(n&&(E?!T(d.token):!f.token||d.token!==f.token))return a("token_mismatch",d.type);let P=W(d.type);if(!P)return a("unexpected_type",d.type);let N=h.events[P];if(N.from===e)return a("unexpected_type",d.type);if(N.session==="establish"){if(d.documentId!==f.documentId||d.sessionId===void 0)return a("session_mismatch",d.type)}else if(N.session==="current"){if(!f.sessionId||d.sessionId!==f.sessionId||d.documentId!==f.documentId)return a("session_mismatch",d.type)}let B=K(d,N);if(!B){if(a("invalid_payload",d.type),e==="host"&&P==="request"&&T(d.id))u?.(d.id);return}if(l?.({direction:"receive",...V(B)}),c)return;let D=y[P];D(B)}return{send:b,receive:Q,dispose(){c=!0}}}function we(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&Number.isFinite(e)}function H(e){return!!e&&typeof e==="object"&&!Array.isArray(e)&&Object.values(e).every(we)}var ne=Symbol.for("@altertable/data-app/MessageRoutingError");class R extends Error{code;requestId;[ne]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[ne]===!0}constructor(e,t,r,n){super(t,n);this.code=e;this.requestId=r;this.name="MessageRoutingError"}}function he(e){return e}function oe(e){return{operations:e,input(t){if(!t||typeof t!=="object")throw Error("Invalid query.");let r=t;if(typeof r.operation!=="string"||!r.operation||r.operation.length>256||r.operation.includes("/"))throw Error("Invalid operation.");let n=e&&Object.hasOwn(e,r.operation)?e[r.operation]:void 0;if(e&&!n)throw Error("Unknown operation.");return{operation:r.operation,input:n?n.input(r.input):r.input}},output(t){if(!t||typeof t!=="object")throw Error("Invalid data response.");let r=t;if(!Number.isInteger(r.status)||r.status<100||r.status>599||!r.body||typeof r.body!=="object"||Array.isArray(r.body))throw Error("Invalid data response.");let n=r.body;if(r.status<200||r.status>=300){let o=n.error;throw new R(typeof o?.code==="string"?o.code:"request_failed",typeof o?.message==="string"?o.message:"Could not load data.",typeof o?.requestId==="string"?o.requestId:void 0)}if(!("data"in n)||typeof n.requestId!=="string"||typeof n.queriedAt!=="string"||!Array.isArray(n.queryIds)||!n.queryIds.every((o)=>typeof o==="string"))throw Error("Invalid data envelope.");if(n.queries!==void 0&&(!Array.isArray(n.queries)||!n.queries.every((o)=>o&&typeof o==="object"&&typeof o.name==="string"&&typeof o.statement==="string"&&(o.params===void 0||H(o.params))&&(o.queryId===void 0||typeof o.queryId==="string"))))throw Error("Invalid query evidence.");return{status:r.status,body:n}}}}var se=he({input(e){if(!e||typeof e!=="object")throw Error("Invalid SQL query.");let t=e;if(typeof t.statement!=="string"||!t.statement.trim()||typeof t.limit!=="number"||!Number.isSafeInteger(t.limit)||t.limit<1||t.params!==void 0&&!H(t.params))throw Error("Invalid SQL query.");return{statement:t.statement,limit:t.limit,...t.params===void 0?{}:{params:t.params}}},output(e,t){if(!e||typeof e!=="object")throw Error("Invalid query result.");let r=e;if(!Array.isArray(r.columns)||!r.columns.every((n)=>n&&typeof n.name==="string"&&(n.type===void 0||typeof n.type==="string"))||!Array.isArray(r.rows)||r.rows.length>t.limit||!r.rows.every((n)=>Array.isArray(n)&&n.length===r.columns.length)||r.queryId!==void 0&&typeof r.queryId!=="string")throw Error("Invalid query result.");return{columns:r.columns,rows:r.rows,...r.queryId===void 0?{}:{queryId:r.queryId}}}});function ae(e,t){return{async request(r,n,{signal:o}={}){if(o?.throwIfAborted(),!Object.hasOwn(e,r))throw new R("unknown_route","Unknown message route.");let i=e[r],l;try{l=i.input(n)}catch{throw new R("invalid_payload","Invalid message payload.")}let u=await t({route:r,payload:l},o);o?.throwIfAborted();try{return i.output(u,l)}catch(y){if(y instanceof R)throw y;throw new R("invalid_response","Invalid message response.")}}}}var ie=Symbol.for("@altertable/data-app/DataAppError");class x extends Error{code;requestId;[ie]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[ie]===!0}constructor(e,t,r){super(e);this.code=t;this.requestId=r;this.name="DataAppError"}}function de(e,t){function r(o){if(o.length===1&&typeof o[0]==="function"){let i=o[0]();return Array.isArray(i)?i:[i]}return o.map((i)=>typeof i==="function"?i():i)}function n(o,i){if(!e())return;try{t({method:o,args:r(i)})}catch{}}return{log:(...o)=>n("log",o),info:(...o)=>n("info",o),warn:(...o)=>n("warn",o),error:(...o)=>n("error",o)}}var be={send:"Sending message to parent",receive:"Received message from parent",drop:"Ignored message from parent"};function ue(e,{direction:t,...r}){if(r.type==="runtime:log")return;e.log(be[t],r)}function pe(e){if(e instanceof Error)return{name:e.name,message:e.message,...e.stack?{stack:e.stack}:{}};return{message:String(e)}}function ce(e){if(e instanceof R)throw new x(e.message,e.code,e.requestId);throw e}function le({parentOrigin:e,window:t=window,timeoutMs:r=ee,mode:n="url",loadScript:o}){if(new URL(e).origin!==e)throw Error("Expected an exact parent origin.");let i=q(),l,u,y=!1,c=new Map,a,b=new Set,Q=de(()=>!y&&!!u&&!!a&&typeof a==="object"&&("logging"in a)&&a.logging===!0,(s)=>p("runtimeLog",{payload:s})),g=re({role:"app",origin:e,source:()=>t.parent,opaque:n==="bundle",context:()=>({documentId:i,sessionId:u,token:l}),post(s){t.parent.postMessage(s,e)},diagnostic:(s)=>ue(Q,s),handlers:{connect(s){if(n==="bundle")l=s.token;p("ready",{})},initialize(s){if(u&&u!==s.sessionId){if(c.size)Q.warn("Preview reconnected; rejecting pending requests",{count:c.size});for(let I of c.values())I.reject(new x("The preview reconnected. Retry the request.","bridge_reset"))}let m=!u;if(u=s.sessionId,f(s.state),m)for(let I of c.values())I.start();if(y)return;if(n==="url")p("runtimeReady",{})},stateUpdate(s){f(s.state)},scriptLoad(s){if(n==="bundle")o?.(s.javascript)},result(s){c.get(s.id)?.resolve(s.response)},error(s){c.get(s.id)?.reject(new R(s.code,s.message,s.requestId))}}}),{send:p,receive:d}=g;function f(s){a=s;for(let m of b)m(s)}t.addEventListener("message",d);function E(s,m){return new Promise((I,v)=>{if(y)return v(new x("The preview has closed.","bridge_closed"));if(m?.aborted)return v(m.reason);if(c.size>=Z)return v(new x("Too many pending data requests.","bridge_busy"));let j=q(),M=!1;function A(){clearTimeout(me),m?.removeEventListener("abort",J),c.delete(j)}function J(){if(M)p("cancel",{id:j});A(),v(m?.reason)}let me=setTimeout(()=>{if(Q.warn("Message request timed out",{id:j,route:s.route,timeoutMs:r,sent:M}),M)p("cancel",{id:j});A(),v(new x(u?"The data request timed out.":"The preview shell is unavailable. Reload the preview.",u?"timeout":"bridge_unavailable"))},r),X={start(){if(M)return;try{p("request",{id:j,route:s.route,payload:s.payload}),M=!0}catch{A(),v(new x("The message payload could not be sent.","invalid_payload"))}},resolve(L){A(),I(L)},reject(L){A(),v(L)}};if(c.set(j,X),m?.addEventListener("abort",J,{once:!0}),u)X.start();else if(n==="url"||l)p("ready",{})})}let P=ae({"data:query":oe(),"data:sql":se},E);function N(s,m,I){return P.request("data:query",{operation:s,input:m},{signal:I}).catch(ce)}function B(){if(u)p("disconnect",{});u=void 0;for(let s of c.values())s.reject(new x("The preview has closed.","bridge_closed"))}function D(s){if(s.persisted&&(n==="url"||l))p("ready",{})}function k(){if(y)return;B(),y=!0,g.dispose(),t.removeEventListener("message",d),t.removeEventListener("pagehide",B),t.removeEventListener("pageshow",D),b.clear()}if(t.addEventListener("pagehide",B),t.addEventListener("pageshow",D),n==="url")p("ready",{});return{logger:Q,request:E,transport:N,lakehouse:{queryAll(s,{limit:m,signal:I,params:v}){return P.request("data:sql",{statement:s,limit:m,...v===void 0?{}:{params:v}},{signal:I}).catch(ce)}},dispose:k,mode:n,snapshot(){return a},subscribe(s){return b.add(s),()=>{b.delete(s)}},ready(){if(!y&&u)p("runtimeReady",{})},fail(s){if(y||!u)return;if(s!==void 0)Q.error(()=>["Data app failed",pe(s)]);p("runtimeError",{})}}}var G=Symbol.for("altertable.localFrameBridge"),_=Symbol.for("altertable.installedTransport");function ye(e,t=window){let r=t;if(r[_])throw Error("A data app transport is already installed.");return r[G]=e,r[_]=e,()=>{if(r[G]===e)delete r[G];if(r[_]===e)delete r[_];e.dispose()}}function fe({parentOrigin:e,window:t=window}){let r,n,o=`altertable-data-app-${q()}.js`,i=le({parentOrigin:e,window:t,mode:"bundle",loadScript(a){if(r!==void 0){if(a!==r)i.fail(Error("This frame already evaluated a different app script."));else if(n)i.fail(n.cause);else i.ready();return}r=a;try{let b=t.document.createElement("script");if(b.textContent=`${a}\n//# sourceURL=${o}`,t.document.body.append(b),!n)i.ready()}catch(b){l(b)}}});function l(a){n={cause:a},i.fail(a)}function u(a){if(a.filename===o)l(a.error??a.message)}function y(a){if(a.reason instanceof Error&&a.reason.stack?.includes(o))l(a.reason)}t.addEventListener("error",u),t.addEventListener("unhandledrejection",y);let c=ye(i,t);return()=>{t.removeEventListener("error",u),t.removeEventListener("unhandledrejection",y),c()}}var ge=document.currentScript?.dataset.parentOrigin;if(!ge)throw Error("Missing trusted parent origin.");fe({parentOrigin:ge});})();\n'.replace(/<\/script/gi, (match) => `<\\${match.slice(1)}`);
|
|
4
4
|
function runtimeHtml(parentOrigin) {
|
|
5
5
|
const attribute = parentOrigin.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">").replaceAll("'", "'");
|
|
6
6
|
return `<!doctype html>
|
package/docs/app-authoring.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Author a data app
|
|
2
2
|
|
|
3
3
|
Build an exploration that answers the user's question and a story that presents
|
|
4
|
-
its strongest findings. Include CSV export so
|
|
4
|
+
its strongest findings. Include CSV export so users can take the displayed
|
|
5
5
|
results into their own tools. Exploration, export, and story use the same
|
|
6
6
|
queries, definitions, and evidence.
|
|
7
7
|
|
|
@@ -11,12 +11,28 @@ Declare the query source of truth with `defineDataApp()`. Generate
|
|
|
11
11
|
operations with `dataApp.defineOperation()` and execute queries by
|
|
12
12
|
name with parameter values. When a query registry is supplied, use only its queries
|
|
13
13
|
and preserve its SQL. Otherwise, inspect the data and declare the queries the app needs.
|
|
14
|
-
|
|
15
|
-
[named queries](contract.md#execute-named-queries).
|
|
14
|
+
Declare inspected result aliases in `projections` and derive displays, exports,
|
|
15
|
+
and findings from the typed rows. See [named queries](contract.md#execute-named-queries).
|
|
16
16
|
|
|
17
17
|
Inspect the relevant catalogs, tables, and fields, their time coverage, and
|
|
18
18
|
existing definitions. Choose a question the available data can answer.
|
|
19
19
|
|
|
20
|
+
## Compose the exploration
|
|
21
|
+
|
|
22
|
+
Plan the question, analytical sequence, and role of each display before choosing
|
|
23
|
+
components. Follow [Compose an exploration](composition.md) to connect filters,
|
|
24
|
+
widgets, layout, and narrative into a coherent investigation, then distill its
|
|
25
|
+
supported findings into a story.
|
|
26
|
+
|
|
27
|
+
## Choose the visualizations
|
|
28
|
+
|
|
29
|
+
Before implementing queries and rendering, identify the question each visual
|
|
30
|
+
answers, [choose its component](widgets.md#choose-a-visualization), and establish
|
|
31
|
+
the required result shape: population, grain, units, ordering, and observation
|
|
32
|
+
status. Prefer a specialized chart when its semantics fit. Check the component's
|
|
33
|
+
input contract before reducing results to generic labels and values; preserve
|
|
34
|
+
supplied query definitions when adapting their results.
|
|
35
|
+
|
|
20
36
|
## Build the exploration
|
|
21
37
|
|
|
22
38
|
Choose the execution path:
|
|
@@ -37,7 +53,7 @@ and internal execution settings out of filter controls.
|
|
|
37
53
|
|
|
38
54
|
Register inspected tables and fields with `defineDataIdentifiers()` and use
|
|
39
55
|
`<DataIdentifier>` when naming sources. Register terms and query evidence so
|
|
40
|
-
|
|
56
|
+
users can inspect the source of each claim.
|
|
41
57
|
|
|
42
58
|
Connect visualizations with introductions and explanations. Use `<TextWidget>`
|
|
43
59
|
for a narrative panel with the standard widget frame, or `<TextContent>` for
|
|
@@ -50,7 +66,7 @@ refresh, and failure.
|
|
|
50
66
|
| Task | Documentation |
|
|
51
67
|
| ------------------------------------------------ | ----------------------------------------------------------------- |
|
|
52
68
|
| Choose components, CSS tokens, and styling hooks | [Styling](styling.md) |
|
|
53
|
-
| Define queries, inputs, and
|
|
69
|
+
| Define queries, inputs, and typed results | [Operations](contract.md) |
|
|
54
70
|
| Build views, filters, and request states | [Views](views.md) |
|
|
55
71
|
| Introduce and explain visualizations | [Narrative text](widgets.md#narrative-text) |
|
|
56
72
|
| Find formatters and presentation helpers | [App helpers](formatting-and-appearance.md) |
|
|
@@ -67,12 +83,12 @@ on the view so tables, exports, and stories share values and evidence.
|
|
|
67
83
|
Every data app supplies a [story and CSV export](stories-and-export.md)
|
|
68
84
|
from the displayed result. Export all distinct datasets at their displayed grain;
|
|
69
85
|
reuse a dataset when several visuals derive from the same rows. Present the
|
|
70
|
-
findings that answer the
|
|
86
|
+
findings that answer the user's question, rather than every row or chart.
|
|
71
87
|
Use the [standard layout](layout.md) and built-in toolbar actions.
|
|
72
88
|
|
|
73
89
|
### Organize the exploration
|
|
74
90
|
|
|
75
|
-
Use sections for a focused question and for findings
|
|
91
|
+
Use sections for a focused question and for findings users should compare
|
|
76
92
|
side by side. Add app-level `<Tabs>` from `/react/ui` when the exploration has
|
|
77
93
|
distinct analytical questions, such as Overview, Retention, and Segments, each
|
|
78
94
|
with its own context and group of widgets. Lead with the most useful overview
|
|
@@ -80,7 +96,7 @@ and label tabs by the question or subject they explore.
|
|
|
80
96
|
|
|
81
97
|
Use `<VisualizationWidget>`'s `views` for alternate representations of the same
|
|
82
98
|
dataset, such as a chart and its rows. Keep these choices within the widget;
|
|
83
|
-
use filter variables when the
|
|
99
|
+
use filter variables when the user is changing the data scope.
|
|
84
100
|
|
|
85
101
|
Navigation tabs, widget views, and declared data views have different roles.
|
|
86
102
|
A declared view owns inputs, requests, and displayed results; a tab does not
|
|
@@ -90,15 +106,14 @@ needs separate requests. Keep filter placement consistent across tabs and make
|
|
|
90
106
|
each filter's scope clear. Derive findings, story, and export from the displayed
|
|
91
107
|
results and their inputs.
|
|
92
108
|
|
|
93
|
-
Choose each visual for the question it answers; see
|
|
94
|
-
[visualization selection](widgets.md#choose-a-visualization).
|
|
95
|
-
|
|
96
109
|
## Verify the app
|
|
97
110
|
|
|
98
111
|
Follow the [UI quality contract](ui-quality.md) for hierarchy, responsive
|
|
99
112
|
composition, typography, and control states.
|
|
100
113
|
|
|
101
|
-
Verify
|
|
114
|
+
Verify that each visual answers its intended question and preserves the source
|
|
115
|
+
population, units, ordering, and missing or incomplete observations. Check
|
|
116
|
+
findings against the source and the user's question. Distinguish measured
|
|
102
117
|
zero, unavailable values, and empty results. Check filters, refresh, loading,
|
|
103
118
|
empty, error, and stale states, then present the story. Download CSV from the
|
|
104
119
|
standalone and embedded toolbar and verify its filename, columns, raw values,
|
package/docs/client.md
CHANGED
|
@@ -15,18 +15,17 @@ const response = await client.query('activity', input, { signal });
|
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
The app defines `operations`, `input`, and an optional cancellation `signal`.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
The shared app declaration contains the query registry and is browser-safe.
|
|
18
|
+
Inputs and data are inferred from the operation map and `run()`. Keep the import
|
|
19
|
+
type-only so operation implementations stay on the server.
|
|
21
20
|
|
|
22
21
|
The default endpoint is `/api/data`. Override it with
|
|
23
|
-
`createDataClient({ endpoint, fetch })` to change the base URL or supply a Fetch
|
|
22
|
+
`createDataClient<typeof operations>({ endpoint, fetch })` to change the base URL or supply a Fetch
|
|
24
23
|
implementation. Calls POST JSON to `/api/data/:operation`; the client sends
|
|
25
24
|
operation inputs rather than SQL or credentials.
|
|
26
25
|
|
|
27
26
|
`DataResponse` contains `data`, the exact request `input`, `requestId`,
|
|
28
27
|
`queriedAt`, `queryIds`, and executed `queries`. Use the returned input when labeling stale data during a refresh.
|
|
29
|
-
HTTP and iframe delivery validate the
|
|
28
|
+
HTTP and iframe delivery validate the success envelope: data, request ID,
|
|
30
29
|
query timestamp, query IDs, and optional query evidence. Malformed responses
|
|
31
30
|
reject with `invalid_response`.
|
|
32
31
|
|
|
@@ -53,7 +52,7 @@ const client = createDataClient({
|
|
|
53
52
|
const response = await client.query('connection', {});
|
|
54
53
|
```
|
|
55
54
|
|
|
56
|
-
The client runs input parsing
|
|
55
|
+
The client runs input parsing and operation logic in the browser.
|
|
57
56
|
Operation policy bounds rows, duration, and response size and records query evidence. Each query sends `{ statement, limit, params? }`
|
|
58
57
|
to the installed iframe bridge's `data:sql` route; the host needs no operation
|
|
59
58
|
registry. Results include query evidence. Credentials remain backend-owned.
|
|
@@ -72,7 +71,7 @@ the host through the existing bridge cancellation protocol.
|
|
|
72
71
|
|
|
73
72
|
## Iframe transport
|
|
74
73
|
|
|
75
|
-
`createDataClient({ transport })` accepts a `DataTransport`. Without an explicit
|
|
74
|
+
`createDataClient<typeof operations>({ transport })` accepts a `DataTransport`. Without an explicit
|
|
76
75
|
transport, endpoint, or Fetch implementation, it discovers an installed iframe
|
|
77
76
|
transport before falling back to HTTP. Explicit endpoint/Fetch options select
|
|
78
77
|
HTTP. `createHttpTransport()` provides the underlying operation delivery adapter.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Compose an exploration
|
|
2
|
+
|
|
3
|
+
Start with the question the user needs to answer. Define its population, period,
|
|
4
|
+
measures, and comparison. Choose the analytical flow before choosing widgets;
|
|
5
|
+
a focused answer may need only a chart and a paragraph.
|
|
6
|
+
|
|
7
|
+
## Build a sequence of questions
|
|
8
|
+
|
|
9
|
+
Lead with the strongest supported result and visible scope. Give each section a
|
|
10
|
+
question that advances the investigation: what happened, when or against what
|
|
11
|
+
baseline, where it differs, and which details support the finding. Omit steps
|
|
12
|
+
that add no useful evidence.
|
|
13
|
+
|
|
14
|
+
Give each element a purpose:
|
|
15
|
+
|
|
16
|
+
| Element | Purpose |
|
|
17
|
+
| --------- | ------------------------------------------------------------------------ |
|
|
18
|
+
| Metric | Establish magnitude or change. |
|
|
19
|
+
| Chart | Reveal the pattern that answers the section's question. |
|
|
20
|
+
| Narrative | Explain interpretation, qualify a claim, or suggest the next comparison. |
|
|
21
|
+
| Table | Support exact comparisons and inspection. |
|
|
22
|
+
| Filter | Test a relevant hypothesis or change the scope. |
|
|
23
|
+
|
|
24
|
+
Use `<Stack>` for reading order, `<SectionHeading>` for questions, and `<Grid>`
|
|
25
|
+
for peer widgets users should compare together. Give the main visual enough
|
|
26
|
+
space and preserve reading order on phones. Place explanations beside their
|
|
27
|
+
evidence, using `<TextContent>` for introductions or `<TextWidget>` for a panel.
|
|
28
|
+
See [layout](layout.md) and [widget selection](widgets.md#choose-a-visualization).
|
|
29
|
+
|
|
30
|
+
Keep a connected investigation on one page. Use app tabs for distinct analytical
|
|
31
|
+
questions and widget `views` for alternate representations of the same dataset.
|
|
32
|
+
|
|
33
|
+
## Make filters serve the question
|
|
34
|
+
|
|
35
|
+
Offer controls with a clear analytical use, such as dates to locate a change or
|
|
36
|
+
channels to test whether it is widespread. Choose useful defaults with adequate
|
|
37
|
+
coverage and make each filter's scope clear.
|
|
38
|
+
|
|
39
|
+
Keep related metrics, charts, and prose consistent in population, definitions,
|
|
40
|
+
units, and comparison periods. Explain deliberate differences. Show counts
|
|
41
|
+
alongside rates when sample size matters; calculate overall rates from their
|
|
42
|
+
numerators and denominators rather than averaging subgroup rates.
|
|
43
|
+
|
|
44
|
+
Derive findings and qualifications from the displayed result and its input.
|
|
45
|
+
A claim about all channels may no longer hold after selecting one. Retain the
|
|
46
|
+
displayed scope during refresh or failure. See [variables](variables.md) and
|
|
47
|
+
[displayed results](views.md#preserve-displayed-results).
|
|
48
|
+
|
|
49
|
+
## Example: where are we losing signups?
|
|
50
|
+
|
|
51
|
+
Define funnel entry, the completion window, and channel attribution. Compare
|
|
52
|
+
populations with equal opportunity to complete; identify incomplete observations.
|
|
53
|
+
Then compose the page in this order:
|
|
54
|
+
|
|
55
|
+
| Question | Display and purpose |
|
|
56
|
+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| How many starters complete? | Conversion against a comparable prior period, with starter and completion counts to establish scale. |
|
|
58
|
+
| When does conversion change? | Trend to locate the change, with incomplete periods identified. |
|
|
59
|
+
| At which step, and for which channels? | Funnel and channel comparisons with counts and rates to locate differences. |
|
|
60
|
+
| What supports the comparison? | Table of channel and step counts, denominators, and rates for inspection and export. |
|
|
61
|
+
|
|
62
|
+
Use one declared view for these related datasets. Put outcome metrics in a
|
|
63
|
+
`<Grid>`, give the trend its own row, then show the funnel, channel comparison,
|
|
64
|
+
and table. Reuse datasets for charts and tables, and bind narrative to the same
|
|
65
|
+
source. See [views](views.md) and [bindings](widgets.md#declare-datasets-and-metrics).
|
|
66
|
+
|
|
67
|
+
Let the date filter select funnel entry dates and the channel filter affect every
|
|
68
|
+
section. Start with all channels and adequate coverage. Selecting one channel
|
|
69
|
+
should help compare its steps and periods; update the headline to match that scope.
|
|
70
|
+
|
|
71
|
+
## Distill the story
|
|
72
|
+
|
|
73
|
+
Select one to four findings that answer the main question from the displayed
|
|
74
|
+
result. Reuse its bindings, scope, and evidence in the story and CSV export.
|
|
75
|
+
See [stories and export](stories-and-export.md).
|
|
76
|
+
|
|
77
|
+
For the signup example, present the conversion change, the step or channel where
|
|
78
|
+
the difference is largest, and any qualification about counts or coverage, when
|
|
79
|
+
supported. Observed differences suggest where to investigate; they do not
|
|
80
|
+
establish a cause.
|
|
81
|
+
|
|
82
|
+
Verify the initial scope and a changed filter: does each section advance the
|
|
83
|
+
question, and does the story agree with the visible evidence? Check reading order
|
|
84
|
+
and context on phones and through the [UI quality states](ui-quality.md).
|