@altertable/data-app 0.70.0 → 0.72.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 +7 -1
- package/CONTRIBUTING.md +73 -33
- package/README.md +23 -26
- package/REFERENCE.md +1904 -0
- package/dist/chunks/index-5a27erdg.js +54 -0
- package/dist/chunks/index-5a27erdg.js.map +10 -0
- package/dist/chunks/{index-58kks6a8.js → index-9yxr7nmm.js} +330 -21
- package/dist/chunks/index-9yxr7nmm.js.map +17 -0
- package/dist/chunks/{index-wjt6cavj.js → index-j5q5n3ra.js} +5 -5
- package/dist/chunks/index-j5q5n3ra.js.map +10 -0
- package/dist/chunks/{index-22d576sn.js → index-q75zm3a7.js} +3 -3
- package/dist/chunks/{index-22d576sn.js.map → index-q75zm3a7.js.map} +3 -3
- package/dist/chunks/{index-9zqbrv2z.js → index-vhaec7m5.js} +4 -6
- package/dist/chunks/index-vhaec7m5.js.map +10 -0
- package/dist/chunks/{index-q1w84fv9.js → index-zp78caex.js} +345 -84
- package/dist/chunks/index-zp78caex.js.map +19 -0
- package/dist/client/index.js +284 -16
- package/dist/client/index.js.map +7 -3
- package/dist/core/appearance.js +181 -11
- package/dist/core/appearance.js.map +4 -3
- package/dist/core/config.js +3 -3
- package/dist/core/contract.js +10 -12
- package/dist/core/contract.js.map +1 -1
- package/dist/core/format.js +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.js +418 -0
- package/dist/internal.js.map +15 -0
- package/dist/server/index.js +102 -0
- package/dist/server/index.js.map +10 -0
- package/dist/types/client/annotations.d.ts +1 -1
- package/dist/types/client/iframe.d.ts +6 -6
- package/dist/types/client/index.d.ts +3 -4
- package/dist/types/client/location.d.ts +2 -2
- package/dist/types/client/logger.d.ts +1 -1
- package/dist/types/client/navigation.d.ts +1 -1
- package/dist/types/client/transport.d.ts +1 -1
- package/dist/types/core/bridge.d.ts +1 -1
- package/dist/types/core/config.d.ts +8 -9
- package/dist/types/core/filters.d.ts +1 -1
- package/dist/types/core/format.d.ts +1 -2
- package/dist/types/core/messages.d.ts +3 -3
- package/dist/types/core/operation-types.d.ts +1 -1
- package/dist/types/core/presentation.d.ts +1 -1
- package/dist/types/core/reading.d.ts +1 -1
- package/dist/types/internal.d.ts +22 -0
- package/dist/types/server/index.d.ts +1 -2
- package/docs/app-authoring.md +18 -1
- package/docs/client.md +1 -1
- package/docs/contract.md +1 -1
- package/docs/data-context.md +3 -3
- package/docs/embed.md +4 -4
- package/docs/formatting-and-appearance.md +1 -1
- package/docs/hosted-apps.md +16 -8
- package/docs/local-data-apps.md +1 -1
- package/docs/react-embed.md +7 -6
- package/docs/react.md +6 -6
- package/docs/server-bun.md +6 -6
- package/docs/stories-and-export.md +3 -3
- package/docs/styling.md +2 -2
- package/docs/ui.md +6 -6
- package/docs/views.md +2 -2
- package/docs/widgets.md +4 -4
- package/docs/worker.md +4 -4
- package/package.json +15 -92
- package/THIRD_PARTY_NOTICES +0 -18
- package/dist/chunks/index-2ajhmsc4.js +0 -355
- package/dist/chunks/index-2ajhmsc4.js.map +0 -13
- package/dist/chunks/index-58kks6a8.js.map +0 -13
- package/dist/chunks/index-7q99hf1z.js +0 -87
- package/dist/chunks/index-7q99hf1z.js.map +0 -10
- package/dist/chunks/index-9zqbrv2z.js.map +0 -10
- package/dist/chunks/index-cv36cyna.js +0 -180
- package/dist/chunks/index-cv36cyna.js.map +0 -10
- package/dist/chunks/index-q1w84fv9.js.map +0 -15
- package/dist/chunks/index-rew95tbg.js +0 -272
- package/dist/chunks/index-rew95tbg.js.map +0 -13
- package/dist/chunks/index-vtpygsbq.js +0 -17270
- package/dist/chunks/index-vtpygsbq.js.map +0 -126
- package/dist/chunks/index-wjt6cavj.js.map +0 -10
- package/dist/chunks/index-wss3gd3h.js +0 -319
- package/dist/chunks/index-wss3gd3h.js.map +0 -13
- package/dist/chunks/index-xzb7sx6g.js +0 -221
- package/dist/chunks/index-xzb7sx6g.js.map +0 -12
- package/dist/embed/index.js +0 -138
- package/dist/embed/index.js.map +0 -12
- package/dist/local.js +0 -465
- package/dist/local.js.map +0 -16
- package/dist/preview.js +0 -1456
- package/dist/preview.js.map +0 -17
- package/dist/react/embed/index.js +0 -117
- package/dist/react/embed/index.js.map +0 -10
- package/dist/react/index.js +0 -2890
- package/dist/react/index.js.map +0 -23
- package/dist/react/ui/index.js +0 -3514
- package/dist/react/ui/index.js.map +0 -36
- package/dist/server.js +0 -334
- package/dist/server.js.map +0 -15
- package/dist/types/core/time-interval.d.ts +0 -96
- package/dist/types/embed/bootstrap.d.ts +0 -5
- package/dist/types/embed/bridge.d.ts +0 -12
- package/dist/types/embed/host.d.ts +0 -36
- package/dist/types/embed/index.d.ts +0 -14
- package/dist/types/embed/navigation.d.ts +0 -6
- package/dist/types/embed/runtime-html.d.ts +0 -2
- package/dist/types/embed/source.d.ts +0 -16
- package/dist/types/embed/sql.d.ts +0 -4
- package/dist/types/react/actions.d.ts +0 -53
- package/dist/types/react/annotations/AnnotationBar.d.ts +0 -30
- package/dist/types/react/annotations/AnnotationControls.d.ts +0 -10
- package/dist/types/react/annotations/AnnotationEditor.d.ts +0 -16
- package/dist/types/react/annotations/AnnotationMarkers.d.ts +0 -19
- package/dist/types/react/annotations/AnnotationSelectionLayer.d.ts +0 -12
- package/dist/types/react/annotations/AnnotationTarget.d.ts +0 -9
- package/dist/types/react/annotations/AnnotationTooltip.d.ts +0 -9
- package/dist/types/react/annotations/AnnotationTrigger.d.ts +0 -10
- package/dist/types/react/annotations/annotation-editor-state.d.ts +0 -58
- package/dist/types/react/annotations/annotation-screenshot.d.ts +0 -4
- package/dist/types/react/annotations/annotation-targets.d.ts +0 -34
- package/dist/types/react/annotations/getAnnotationProps.d.ts +0 -17
- package/dist/types/react/annotations/styles.d.ts +0 -3
- package/dist/types/react/annotations/useAnnotationGeometry.d.ts +0 -22
- package/dist/types/react/annotations/useDataAppAnnotations.d.ts +0 -22
- package/dist/types/react/app-context.d.ts +0 -3
- package/dist/types/react/bindings.d.ts +0 -169
- package/dist/types/react/content.d.ts +0 -36
- package/dist/types/react/date-formatting.d.ts +0 -12
- package/dist/types/react/details.d.ts +0 -46
- package/dist/types/react/embed/bridge.d.ts +0 -21
- package/dist/types/react/embed/index.d.ts +0 -7
- package/dist/types/react/exploration.d.ts +0 -44
- package/dist/types/react/hooks.d.ts +0 -113
- package/dist/types/react/index.d.ts +0 -78
- package/dist/types/react/injectStyles.d.ts +0 -7
- package/dist/types/react/mount.d.ts +0 -13
- package/dist/types/react/search-suggestions.d.ts +0 -8
- package/dist/types/react/source-owner.d.ts +0 -2
- package/dist/types/react/style-contract.d.ts +0 -88
- package/dist/types/react/style-validation.d.ts +0 -2
- package/dist/types/react/styles.d.ts +0 -8
- package/dist/types/react/ui/AboutData.d.ts +0 -73
- package/dist/types/react/ui/AltertableLogo.d.ts +0 -3
- package/dist/types/react/ui/AppFooter.d.ts +0 -6
- package/dist/types/react/ui/AppHeader.d.ts +0 -10
- package/dist/types/react/ui/AppLayout.d.ts +0 -10
- package/dist/types/react/ui/AppScope.d.ts +0 -7
- package/dist/types/react/ui/AppToolbar.d.ts +0 -30
- package/dist/types/react/ui/AreaChart.d.ts +0 -7
- package/dist/types/react/ui/BarChart.d.ts +0 -6
- package/dist/types/react/ui/Breakdown.d.ts +0 -13
- package/dist/types/react/ui/Button.d.ts +0 -12
- package/dist/types/react/ui/ChartLegend.d.ts +0 -32
- package/dist/types/react/ui/Checkbox.d.ts +0 -21
- package/dist/types/react/ui/CheckboxGroup.d.ts +0 -7
- package/dist/types/react/ui/ChoicePicker.d.ts +0 -39
- package/dist/types/react/ui/Comparison.d.ts +0 -14
- package/dist/types/react/ui/ComposedChart.d.ts +0 -41
- package/dist/types/react/ui/ComposedChartLegend.d.ts +0 -9
- package/dist/types/react/ui/ContentSkeleton.d.ts +0 -7
- package/dist/types/react/ui/DataApp.d.ts +0 -24
- package/dist/types/react/ui/DataAppFrame.d.ts +0 -52
- package/dist/types/react/ui/DataBoundary.d.ts +0 -14
- package/dist/types/react/ui/DataSection.d.ts +0 -14
- package/dist/types/react/ui/DataSectionBoundary.d.ts +0 -30
- package/dist/types/react/ui/DataTable.d.ts +0 -29
- package/dist/types/react/ui/DataValue.d.ts +0 -9
- package/dist/types/react/ui/DataViewToast.d.ts +0 -11
- package/dist/types/react/ui/DataWidget.d.ts +0 -37
- package/dist/types/react/ui/DateDisplay.d.ts +0 -9
- package/dist/types/react/ui/DateRangePicker.d.ts +0 -30
- package/dist/types/react/ui/DateTimeTooltip.d.ts +0 -10
- package/dist/types/react/ui/DimensionPicker.d.ts +0 -13
- package/dist/types/react/ui/EmptyState.d.ts +0 -6
- package/dist/types/react/ui/ExplorationActionControl.d.ts +0 -60
- package/dist/types/react/ui/ExportControl.d.ts +0 -4
- package/dist/types/react/ui/FilterActions.d.ts +0 -10
- package/dist/types/react/ui/FilterBar.d.ts +0 -3
- package/dist/types/react/ui/FunnelChart.d.ts +0 -20
- package/dist/types/react/ui/GettingStarted.d.ts +0 -6
- package/dist/types/react/ui/GlossaryDefinition.d.ts +0 -7
- package/dist/types/react/ui/GlossaryExplanation.d.ts +0 -16
- package/dist/types/react/ui/GradientScroll.d.ts +0 -23
- package/dist/types/react/ui/Grid.d.ts +0 -12
- package/dist/types/react/ui/GridItem.d.ts +0 -7
- package/dist/types/react/ui/HelpPopover.d.ts +0 -21
- package/dist/types/react/ui/IconButton.d.ts +0 -19
- package/dist/types/react/ui/InspectionContext.d.ts +0 -12
- package/dist/types/react/ui/InspectionProvider.d.ts +0 -29
- package/dist/types/react/ui/JourneyChart.d.ts +0 -10
- package/dist/types/react/ui/Kbd.d.ts +0 -7
- package/dist/types/react/ui/LineChart.d.ts +0 -7
- package/dist/types/react/ui/LiveControl.d.ts +0 -10
- package/dist/types/react/ui/Menu.d.ts +0 -13
- package/dist/types/react/ui/MetricWidget.d.ts +0 -51
- package/dist/types/react/ui/NumberField.d.ts +0 -27
- package/dist/types/react/ui/NumberFilterPicker.d.ts +0 -11
- package/dist/types/react/ui/PeriodSummary.d.ts +0 -17
- package/dist/types/react/ui/PickerField.d.ts +0 -23
- package/dist/types/react/ui/PieChart.d.ts +0 -11
- package/dist/types/react/ui/PopoverSurface.d.ts +0 -5
- package/dist/types/react/ui/PresentStory.d.ts +0 -30
- package/dist/types/react/ui/QueryList.d.ts +0 -14
- package/dist/types/react/ui/RadioGroup.d.ts +0 -18
- package/dist/types/react/ui/Ranking.d.ts +0 -13
- package/dist/types/react/ui/RefreshControl.d.ts +0 -9
- package/dist/types/react/ui/RequestHint.d.ts +0 -20
- package/dist/types/react/ui/RetentionChart.d.ts +0 -27
- package/dist/types/react/ui/ScatterChart.d.ts +0 -17
- package/dist/types/react/ui/SearchField.d.ts +0 -23
- package/dist/types/react/ui/SearchInput.d.ts +0 -10
- package/dist/types/react/ui/SearchMatch.d.ts +0 -6
- package/dist/types/react/ui/SearchTypeahead.d.ts +0 -15
- package/dist/types/react/ui/SectionHeading.d.ts +0 -8
- package/dist/types/react/ui/Select.d.ts +0 -22
- package/dist/types/react/ui/SelectionMark.d.ts +0 -5
- package/dist/types/react/ui/Sheet.d.ts +0 -21
- package/dist/types/react/ui/Skeleton.d.ts +0 -8
- package/dist/types/react/ui/Stack.d.ts +0 -7
- package/dist/types/react/ui/StaticDataApp.d.ts +0 -4
- package/dist/types/react/ui/StatusPanel.d.ts +0 -10
- package/dist/types/react/ui/TableWidget.d.ts +0 -67
- package/dist/types/react/ui/Tabs.d.ts +0 -10
- package/dist/types/react/ui/TextContent.d.ts +0 -4
- package/dist/types/react/ui/TextWidget.d.ts +0 -20
- package/dist/types/react/ui/ThemeSelector.d.ts +0 -12
- package/dist/types/react/ui/Toast.d.ts +0 -8
- package/dist/types/react/ui/Tooltip.d.ts +0 -23
- package/dist/types/react/ui/TooltipSurface.d.ts +0 -3
- package/dist/types/react/ui/TrendChart.d.ts +0 -5
- package/dist/types/react/ui/UpdatedAt.d.ts +0 -9
- package/dist/types/react/ui/VariableBar.d.ts +0 -6
- package/dist/types/react/ui/VisualizationWidget.d.ts +0 -43
- package/dist/types/react/ui/WidgetDisclosure.d.ts +0 -6
- package/dist/types/react/ui/WidgetEvidence.d.ts +0 -12
- package/dist/types/react/ui/WidgetViewTabs.d.ts +0 -16
- package/dist/types/react/ui/chart-data.d.ts +0 -36
- package/dist/types/react/ui/chart-date-axis.d.ts +0 -15
- package/dist/types/react/ui/chart-interaction.d.ts +0 -27
- package/dist/types/react/ui/chart-primitives.d.ts +0 -22
- package/dist/types/react/ui/chart-time.d.ts +0 -19
- package/dist/types/react/ui/chartColor.d.ts +0 -2
- package/dist/types/react/ui/classNames.d.ts +0 -1
- package/dist/types/react/ui/csv-export.d.ts +0 -19
- package/dist/types/react/ui/data-context.d.ts +0 -76
- package/dist/types/react/ui/data-identifiers.d.ts +0 -32
- package/dist/types/react/ui/icons.d.ts +0 -49
- package/dist/types/react/ui/index.d.ts +0 -111
- package/dist/types/react/ui/journey-flow.d.ts +0 -49
- package/dist/types/react/ui/keyboard.d.ts +0 -6
- package/dist/types/react/ui/metric-comparison.d.ts +0 -30
- package/dist/types/react/ui/metric.d.ts +0 -11
- package/dist/types/react/ui/presentation.d.ts +0 -25
- package/dist/types/react/ui/search.d.ts +0 -6
- package/dist/types/react/ui/searchItems.d.ts +0 -36
- package/dist/types/react/ui/shortcuts.d.ts +0 -45
- package/dist/types/react/ui/story.d.ts +0 -20
- package/dist/types/react/ui/use-chart-scroll-to-end.d.ts +0 -2
- package/dist/types/react/ui/useAppAppearance.d.ts +0 -3
- package/dist/types/react/ui/useDataAppPresentation.d.ts +0 -3
- package/dist/types/react/ui/useSvgId.d.ts +0 -2
- package/dist/types/react/ui/variables.d.ts +0 -38
- package/dist/types/react/ui/widget-views.d.ts +0 -3
- package/dist/types/react/view-control-bar.d.ts +0 -18
- package/dist/types/react/view-controls.d.ts +0 -20
- package/dist/types/react/view-runtime.d.ts +0 -34
- package/dist/types/react/view.d.ts +0 -87
- package/dist/types/react/widgets.d.ts +0 -90
- package/dist/types/server/local.d.ts +0 -19
- package/dist/types/server/preview/host.d.ts +0 -1
- package/dist/types/server/preview/index.d.ts +0 -16
- package/dist/types/server/reload-channel.d.ts +0 -6
- package/dist/worker.js +0 -106
- package/examples/starter-data-app/index.tsx +0 -193
- package/examples/starter-local-data-app/.bun-version +0 -1
- package/examples/starter-local-data-app/.node-version +0 -1
- package/examples/starter-local-data-app/.oxfmtrc.json +0 -4
- package/examples/starter-local-data-app/.oxlintrc.json +0 -33
- package/examples/starter-local-data-app/AGENTS.md +0 -22
- package/examples/starter-local-data-app/README.md +0 -54
- package/examples/starter-local-data-app/app.ts +0 -28
- package/examples/starter-local-data-app/bunfig.toml +0 -2
- package/examples/starter-local-data-app/package.json +0 -33
- package/examples/starter-local-data-app/src/App.tsx +0 -8
- package/examples/starter-local-data-app/src/assets.d.ts +0 -1
- package/examples/starter-local-data-app/src/data-context.ts +0 -21
- package/examples/starter-local-data-app/src/favicon.svg +0 -13
- package/examples/starter-local-data-app/src/index.html +0 -14
- package/examples/starter-local-data-app/src/main.tsx +0 -7
- package/examples/starter-local-data-app/src/operations.ts +0 -6
- package/examples/starter-local-data-app/src/server.ts +0 -6
- package/examples/starter-local-data-app/tsconfig.json +0 -21
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { type ExplorationActions } from './actions.js';
|
|
2
|
-
import { type BreakdownTarget } from './exploration.js';
|
|
3
|
-
import { type ItemActions } from './ui/ExplorationActionControl.js';
|
|
4
|
-
import { type Dataset, type Metric, type ViewSource } from './bindings.js';
|
|
5
|
-
import { type MetricWidgetProps as DisplayMetricProps } from './ui/MetricWidget.js';
|
|
6
|
-
import { type TableWidgetProps as DisplayTableProps, type TableDisplayMode } from './ui/TableWidget.js';
|
|
7
|
-
import { type VisualizationWidgetProps as DisplayVisualProps, type VisualizationWidgetView as DisplayVisualizationView } from './ui/VisualizationWidget.js';
|
|
8
|
-
import { type TextWidgetProps as DisplayTextProps } from './ui/TextWidget.js';
|
|
9
|
-
import { type DataValueProps as DisplayValueProps } from './ui/DataValue.js';
|
|
10
|
-
import type { MetricValues } from '../core/reading.js';
|
|
11
|
-
import type { MetricDefinition } from './ui/metric.js';
|
|
12
|
-
import type { ReactNode } from 'react';
|
|
13
|
-
import type { DataReading } from '../core/reading.js';
|
|
14
|
-
import { MetricRecords } from './bindings.js';
|
|
15
|
-
export type MetricWidgetProps<Data = unknown, Input = unknown> = Omit<Extract<DisplayMetricProps, {
|
|
16
|
-
metric: MetricDefinition;
|
|
17
|
-
}>, 'metric' | 'reading' | 'records'> & {
|
|
18
|
-
metric: Metric<Data, Input>;
|
|
19
|
-
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
20
|
-
records?: MetricRecords<Data, Input, any, any>;
|
|
21
|
-
actions?: ExplorationActions<void, NoInfer<Input>>;
|
|
22
|
-
};
|
|
23
|
-
export declare function MetricWidget<Data, Input>({ metric, source, records, actions, action, ...presentation }: MetricWidgetProps<Data, Input>): import("react").JSX.Element;
|
|
24
|
-
type BoundTableProps<Row> = Extract<DisplayTableProps<Row>, {
|
|
25
|
-
reading: DataReading<readonly Row[]>;
|
|
26
|
-
}>;
|
|
27
|
-
type TablePresentation<Row> = Pick<BoundTableProps<Row>, 'title' | 'columns' | 'rowKey' | 'reading' | 'evidence' | 'emptyFallback'>;
|
|
28
|
-
export type TableWidgetProps<Row, Data = unknown, Input = unknown> = Omit<BoundTableProps<Row>, keyof TablePresentation<Row> | 'limit' | 'pagination'> & TableDisplayMode & {
|
|
29
|
-
dataset: Dataset<Data, Input, Row>;
|
|
30
|
-
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
31
|
-
title?: ReactNode;
|
|
32
|
-
actions?: ExplorationActions<NoInfer<Row>, NoInfer<Input>>;
|
|
33
|
-
};
|
|
34
|
-
export declare function TableWidget<Row, Data, Input>({ dataset, source, title, actions, ...presentation }: TableWidgetProps<Row, Data, Input>): import("react").JSX.Element;
|
|
35
|
-
type BoundVisual<Row> = Extract<DisplayVisualProps<readonly Row[]>, {
|
|
36
|
-
reading: DataReading<readonly Row[]>;
|
|
37
|
-
}>;
|
|
38
|
-
export type VisualizationWidgetView<Row> = Omit<DisplayVisualizationView<readonly Row[]>, 'render'> & {
|
|
39
|
-
render: (rows: readonly Row[], actions: ItemActions<Row>) => ReactNode;
|
|
40
|
-
};
|
|
41
|
-
type VisualContent<Row> = {
|
|
42
|
-
children: (rows: readonly Row[], actions: ItemActions<Row>) => ReactNode;
|
|
43
|
-
views?: never;
|
|
44
|
-
viewLabel?: never;
|
|
45
|
-
initialView?: never;
|
|
46
|
-
} | {
|
|
47
|
-
children?: never;
|
|
48
|
-
views: readonly VisualizationWidgetView<Row>[];
|
|
49
|
-
viewLabel: string;
|
|
50
|
-
initialView?: string;
|
|
51
|
-
};
|
|
52
|
-
export type VisualizationWidgetProps<Row, Data = unknown, Input = unknown> = Omit<BoundVisual<Row>, 'reading' | 'isEmpty' | 'emptyFallback' | 'evidence' | 'title' | 'children' | 'views' | 'viewLabel' | 'initialView'> & VisualContent<Row> & {
|
|
53
|
-
dataset: Dataset<Data, Input, Row>;
|
|
54
|
-
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
55
|
-
title?: ReactNode;
|
|
56
|
-
actions?: ExplorationActions<NoInfer<Row>, NoInfer<Input>>;
|
|
57
|
-
breakdown?: BreakdownTarget<any>;
|
|
58
|
-
};
|
|
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;
|
|
60
|
-
type NarrativeBinding<Data, Input, Row> = {
|
|
61
|
-
metric: Metric<Data, Input>;
|
|
62
|
-
dataset?: never;
|
|
63
|
-
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
64
|
-
children?: (values: MetricValues) => ReactNode;
|
|
65
|
-
} | {
|
|
66
|
-
metric?: never;
|
|
67
|
-
dataset: Dataset<Data, Input, Row>;
|
|
68
|
-
source: ViewSource<NoInfer<Data>, NoInfer<Input>>;
|
|
69
|
-
children: (rows: readonly Row[]) => ReactNode;
|
|
70
|
-
};
|
|
71
|
-
export type TextWidgetProps<Data = unknown, Input = unknown, Row = never> = Omit<Extract<DisplayTextProps<unknown>, {
|
|
72
|
-
reading: DataReading<unknown>;
|
|
73
|
-
}>, 'reading' | 'evidence' | 'children' | 'title' | 'emptyFallback'> & NarrativeBinding<Data, Input, Row> & {
|
|
74
|
-
title?: ReactNode;
|
|
75
|
-
};
|
|
76
|
-
export declare function TextWidget<Data, Input, Row>(props: TextWidgetProps<Data, Input, Row>): import("react").JSX.Element;
|
|
77
|
-
type InlinePresentation = Omit<DisplayValueProps<unknown>, 'reading' | 'children' | 'loadingFallback'> & {
|
|
78
|
-
loadingFallback?: ReactNode;
|
|
79
|
-
};
|
|
80
|
-
export type DataValueProps<Data = unknown, Input = unknown, Row = never> = InlinePresentation & ((NarrativeBinding<Data, Input, Row> & {
|
|
81
|
-
scope?: never;
|
|
82
|
-
}) | {
|
|
83
|
-
metric?: never;
|
|
84
|
-
dataset?: never;
|
|
85
|
-
source?: never;
|
|
86
|
-
scope: DataReading<string>;
|
|
87
|
-
children?: (scope: string) => ReactNode;
|
|
88
|
-
});
|
|
89
|
-
export declare function DataValue<Data, Input, Row>(props: DataValueProps<Data, Input, Row>): import("react").JSX.Element;
|
|
90
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
/** 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. */
|
|
19
|
-
export declare function localLakehouse(environment?: Record<string, string | undefined>, request?: typeof fetch): Lakehouse;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// src/embed/runtime-html.ts
|
|
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 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
|
-
function runtimeHtml(parentOrigin) {
|
|
5
|
-
const attribute = parentOrigin.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">").replaceAll("'", "'");
|
|
6
|
-
return `<!doctype html>
|
|
7
|
-
<html>
|
|
8
|
-
<head>
|
|
9
|
-
<meta charset="utf-8">
|
|
10
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
11
|
-
<meta http-equiv="Content-Security-Policy" content="${PAGE_CSP}">
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<div id="root"></div>
|
|
15
|
-
<script data-parent-origin="${attribute}">${inlineBootstrap}</script>
|
|
16
|
-
</body>
|
|
17
|
-
</html>
|
|
18
|
-
`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// src/worker/trusted-parent.ts
|
|
22
|
-
function exactOrigin(value) {
|
|
23
|
-
const url = new URL(value);
|
|
24
|
-
if (!/^https?:$/.test(url.protocol) || url.origin !== value) {
|
|
25
|
-
throw new Error("Expected an exact HTTP(S) parent origin.");
|
|
26
|
-
}
|
|
27
|
-
return url;
|
|
28
|
-
}
|
|
29
|
-
function trustedParent(config, searchParams) {
|
|
30
|
-
if (typeof config !== "string" || !config.trim()) {
|
|
31
|
-
throw new Error("Missing trusted parent origins.");
|
|
32
|
-
}
|
|
33
|
-
const allowed = config.trim().split(/\s+/).map((value) => {
|
|
34
|
-
const wildcard = value.startsWith("https://*.");
|
|
35
|
-
const url = exactOrigin(wildcard ? value.replace("*.", "") : value);
|
|
36
|
-
if (url.hostname.includes("*") || wildcard && url.port) {
|
|
37
|
-
throw new Error("Invalid parent origin pattern.");
|
|
38
|
-
}
|
|
39
|
-
return { value, url, wildcard };
|
|
40
|
-
});
|
|
41
|
-
const requested = searchParams.getAll("__altertable_parent");
|
|
42
|
-
if (!requested.length) {
|
|
43
|
-
const fallback = allowed.find((origin) => !origin.wildcard);
|
|
44
|
-
if (!fallback)
|
|
45
|
-
throw new Error("An exact default parent origin is required.");
|
|
46
|
-
return fallback.value;
|
|
47
|
-
}
|
|
48
|
-
if (requested.length !== 1)
|
|
49
|
-
return null;
|
|
50
|
-
let url;
|
|
51
|
-
try {
|
|
52
|
-
url = exactOrigin(requested[0]);
|
|
53
|
-
} catch {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const permitted = allowed.some((origin) => {
|
|
57
|
-
if (!origin.wildcard)
|
|
58
|
-
return origin.value === requested[0];
|
|
59
|
-
if (url.protocol !== "https:" || url.port)
|
|
60
|
-
return false;
|
|
61
|
-
const suffix = `.${origin.url.hostname}`;
|
|
62
|
-
return url.hostname.endsWith(suffix) && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(url.hostname.slice(0, -suffix.length));
|
|
63
|
-
});
|
|
64
|
-
return permitted ? requested[0] : null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// src/worker/index.ts
|
|
68
|
-
var TOKEN_RE = /^(?=.{1,63}$)[a-z0-9]+(?:-+[a-z0-9]+)+$/;
|
|
69
|
-
function isPreviewHost(hostname, domainName) {
|
|
70
|
-
const suffix = `.${domainName}`;
|
|
71
|
-
return hostname.endsWith(suffix) && TOKEN_RE.test(hostname.slice(0, -suffix.length));
|
|
72
|
-
}
|
|
73
|
-
var worker_default = {
|
|
74
|
-
runtimeHtml,
|
|
75
|
-
fetch(request, env) {
|
|
76
|
-
const url = new URL(request.url);
|
|
77
|
-
if (!isPreviewHost(url.hostname, env.DOMAIN_NAME) || url.pathname !== "/") {
|
|
78
|
-
return new Response(null, { status: 404 });
|
|
79
|
-
}
|
|
80
|
-
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
81
|
-
return new Response(null, {
|
|
82
|
-
status: 405,
|
|
83
|
-
headers: { Allow: "GET, HEAD" }
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
let parent;
|
|
87
|
-
try {
|
|
88
|
-
parent = trustedParent(env.PARENT_ORIGINS, url.searchParams);
|
|
89
|
-
} catch {
|
|
90
|
-
return new Response(null, { status: 503 });
|
|
91
|
-
}
|
|
92
|
-
if (!parent)
|
|
93
|
-
return new Response(null, { status: 403 });
|
|
94
|
-
return new Response(request.method === "HEAD" ? null : runtimeHtml(parent), {
|
|
95
|
-
headers: {
|
|
96
|
-
"Content-Type": "text/html; charset=utf-8",
|
|
97
|
-
"Content-Security-Policy": `${PAGE_CSP}; frame-ancestors ${env.PARENT_ORIGINS.trim().split(/\s+/).join(" ")}`,
|
|
98
|
-
"X-Content-Type-Options": "nosniff",
|
|
99
|
-
"Referrer-Policy": "no-referrer"
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
export {
|
|
105
|
-
worker_default as default
|
|
106
|
-
};
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { formatMetric } from '@altertable/data-app/format';
|
|
2
|
-
import { createDataClient } from '@altertable/data-app/client';
|
|
3
|
-
import { defineDataApp } from '@altertable/data-app';
|
|
4
|
-
import { parseCount } from '@altertable/data-app/contract';
|
|
5
|
-
import {
|
|
6
|
-
createDataContext,
|
|
7
|
-
createDataHooks,
|
|
8
|
-
DataApp,
|
|
9
|
-
DataSection,
|
|
10
|
-
DataValue,
|
|
11
|
-
TableWidget,
|
|
12
|
-
Grid,
|
|
13
|
-
Stack,
|
|
14
|
-
TextContent,
|
|
15
|
-
injectDataAppStyles,
|
|
16
|
-
mountDataApp,
|
|
17
|
-
MetricWidget,
|
|
18
|
-
searchVariable,
|
|
19
|
-
} from '@altertable/data-app/react';
|
|
20
|
-
|
|
21
|
-
const dataApp = defineDataApp({
|
|
22
|
-
title: 'Sample counts',
|
|
23
|
-
description: 'Explore sample counts by group.',
|
|
24
|
-
scope: { organization: 'demo', environment: 'sample' },
|
|
25
|
-
appearance: { theme: 'system' },
|
|
26
|
-
queries: {
|
|
27
|
-
sampleCountsByGroup: {
|
|
28
|
-
projections: {
|
|
29
|
-
group_name: { type: 'string' },
|
|
30
|
-
sample_count: { type: 'number' },
|
|
31
|
-
},
|
|
32
|
-
statement: `
|
|
33
|
-
WITH sample_counts(group_name, sample_count) AS (VALUES ('Alpha', 2200000), ('Beta', 0))
|
|
34
|
-
SELECT group_name, sample_count FROM sample_counts
|
|
35
|
-
WHERE $groupName = '' OR group_name = $groupName
|
|
36
|
-
ORDER BY group_name LIMIT $limit`,
|
|
37
|
-
params: {
|
|
38
|
-
groupName: { type: 'string', defaultValue: '' },
|
|
39
|
-
limit: { type: 'number', defaultValue: 10 },
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
function parseSampleCountFilter(value: unknown) {
|
|
45
|
-
if (
|
|
46
|
-
!value ||
|
|
47
|
-
typeof value !== 'object' ||
|
|
48
|
-
!('groupName' in value) ||
|
|
49
|
-
typeof value.groupName !== 'string' ||
|
|
50
|
-
value.groupName.length > 40
|
|
51
|
-
)
|
|
52
|
-
throw new Error('Expected a group name of at most 40 characters.');
|
|
53
|
-
return { groupName: value.groupName };
|
|
54
|
-
}
|
|
55
|
-
const operations = {
|
|
56
|
-
sampleCountsByGroup: dataApp.defineOperation({
|
|
57
|
-
input: parseSampleCountFilter,
|
|
58
|
-
checks: [
|
|
59
|
-
{ groupName: '' },
|
|
60
|
-
{ groupName: 'Alpha' },
|
|
61
|
-
{ groupName: 'missing' },
|
|
62
|
-
],
|
|
63
|
-
policy: { maxQueryRows: 10, maxDurationMs: 15000 },
|
|
64
|
-
async run({ query }, { groupName }) {
|
|
65
|
-
const queryResult = await query('sampleCountsByGroup', { groupName });
|
|
66
|
-
return queryResult.rows.map(row => ({
|
|
67
|
-
groupName: row.group_name,
|
|
68
|
-
sampleCount: parseCount(row.sample_count),
|
|
69
|
-
}));
|
|
70
|
-
},
|
|
71
|
-
}),
|
|
72
|
-
};
|
|
73
|
-
const queryNames = operations.sampleCountsByGroup.queryNames;
|
|
74
|
-
const sampleDataContext = createDataContext(queryNames)({
|
|
75
|
-
description:
|
|
76
|
-
'Two SQL VALUES rows demonstrate the host query path. Replace them with inspected source data before publishing findings.',
|
|
77
|
-
glossary: {
|
|
78
|
-
sampleCount: {
|
|
79
|
-
term: 'Sample count',
|
|
80
|
-
definition:
|
|
81
|
-
'A fixture value: Alpha is 2,200,000 and Beta is a measured zero.',
|
|
82
|
-
queryNames: [queryNames.sampleCountsByGroup],
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
const { defineDataView } = createDataHooks(createDataClient({ operations }));
|
|
87
|
-
const sampleCountsView = defineDataView({
|
|
88
|
-
dataContext: sampleDataContext,
|
|
89
|
-
operation: 'sampleCountsByGroup',
|
|
90
|
-
variables: {
|
|
91
|
-
groupName: searchVariable({
|
|
92
|
-
key: 'group',
|
|
93
|
-
label: 'Group',
|
|
94
|
-
defaultValue: '',
|
|
95
|
-
}),
|
|
96
|
-
},
|
|
97
|
-
describeInput: ({ groupName }) =>
|
|
98
|
-
groupName ? `group ${groupName}` : 'all groups',
|
|
99
|
-
isEmpty: sampleCounts => sampleCounts.length === 0,
|
|
100
|
-
emptyFallback: {
|
|
101
|
-
title: 'No matching groups',
|
|
102
|
-
description: 'Try Alpha, Beta, or clear the group filter.',
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
const sampleCounts = sampleCountsView.dataset({
|
|
106
|
-
name: 'Sample counts',
|
|
107
|
-
select: rows => rows,
|
|
108
|
-
rowKey: row => row.groupName,
|
|
109
|
-
columns: {
|
|
110
|
-
groupName: { label: 'Group', value: row => row.groupName },
|
|
111
|
-
sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
|
|
112
|
-
},
|
|
113
|
-
evidence: {
|
|
114
|
-
id: 'counts-by-group',
|
|
115
|
-
glossaryIds: ['sampleCount'],
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
const totalSamples = sampleCountsView.metric(
|
|
119
|
-
{
|
|
120
|
-
id: 'total-samples',
|
|
121
|
-
glossaryId: 'sampleCount',
|
|
122
|
-
label: 'Total samples',
|
|
123
|
-
format: { kind: 'count', compact: true },
|
|
124
|
-
},
|
|
125
|
-
rows => ({ current: rows.reduce((sum, row) => sum + row.sampleCount, 0) })
|
|
126
|
-
);
|
|
127
|
-
const sampleContent = sampleCountsView.content(result => (
|
|
128
|
-
<Stack aria-label="Sample results">
|
|
129
|
-
<TextContent>
|
|
130
|
-
<p>
|
|
131
|
-
Showing <DataValue scope={result.scope} />
|
|
132
|
-
</p>
|
|
133
|
-
</TextContent>
|
|
134
|
-
<Grid columns={2}>
|
|
135
|
-
<MetricWidget
|
|
136
|
-
metric={totalSamples}
|
|
137
|
-
source={result}
|
|
138
|
-
description="Sum of the fixture counts in the selected groups."
|
|
139
|
-
/>
|
|
140
|
-
<TableWidget
|
|
141
|
-
dataset={sampleCounts}
|
|
142
|
-
source={result}
|
|
143
|
-
title="Counts by group"
|
|
144
|
-
description="Alpha and Beta demonstrate measured values, including zero."
|
|
145
|
-
pagination={false}
|
|
146
|
-
/>
|
|
147
|
-
</Grid>
|
|
148
|
-
</Stack>
|
|
149
|
-
));
|
|
150
|
-
function App() {
|
|
151
|
-
return (
|
|
152
|
-
<DataApp
|
|
153
|
-
view={sampleCountsView}
|
|
154
|
-
datasets={[sampleCounts]}
|
|
155
|
-
story={snapshot => {
|
|
156
|
-
const total = totalSamples.read(snapshot);
|
|
157
|
-
const scope = sampleCountsView.scope(snapshot);
|
|
158
|
-
return [
|
|
159
|
-
{
|
|
160
|
-
id: 'total-samples',
|
|
161
|
-
headline: `Total samples: ${formatMetric(total.value.current, totalSamples.definition.format)}`,
|
|
162
|
-
context: `Demonstration values for ${scope}.`,
|
|
163
|
-
visual: <MetricWidget metric={totalSamples} source={snapshot} />,
|
|
164
|
-
visualKind: 'metric',
|
|
165
|
-
evidence: totalSamples,
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
id: 'counts-by-group',
|
|
169
|
-
headline: 'Counts by group',
|
|
170
|
-
context: `Demonstration values for ${scope}.`,
|
|
171
|
-
visual: (
|
|
172
|
-
<TableWidget
|
|
173
|
-
dataset={sampleCounts}
|
|
174
|
-
source={snapshot}
|
|
175
|
-
pagination={false}
|
|
176
|
-
/>
|
|
177
|
-
),
|
|
178
|
-
evidence: sampleCounts,
|
|
179
|
-
},
|
|
180
|
-
];
|
|
181
|
-
}}
|
|
182
|
-
>
|
|
183
|
-
<Stack>
|
|
184
|
-
<TextContent>
|
|
185
|
-
<h2>Sample counts</h2>
|
|
186
|
-
</TextContent>
|
|
187
|
-
<DataSection content={sampleContent} />
|
|
188
|
-
</Stack>
|
|
189
|
-
</DataApp>
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
injectDataAppStyles();
|
|
193
|
-
mountDataApp({ app: dataApp, component: App });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.4.2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
24.18.0
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
|
-
"plugins": ["eslint", "typescript", "unicorn", "oxc", "react", "jsx-a11y"],
|
|
4
|
-
"categories": {
|
|
5
|
-
"correctness": "error"
|
|
6
|
-
},
|
|
7
|
-
"options": {
|
|
8
|
-
"typeAware": true
|
|
9
|
-
},
|
|
10
|
-
"rules": {
|
|
11
|
-
"react/unsupported-syntax": "error",
|
|
12
|
-
"eslint/no-restricted-imports": [
|
|
13
|
-
"error",
|
|
14
|
-
{
|
|
15
|
-
"patterns": [
|
|
16
|
-
{
|
|
17
|
-
"regex": "^\\.\\.?/",
|
|
18
|
-
"message": "Use #app/* or #config for app-owned files."
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"func-style": [
|
|
24
|
-
"error",
|
|
25
|
-
"declaration",
|
|
26
|
-
{
|
|
27
|
-
"overrides": {
|
|
28
|
-
"namedExports": "declaration"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Build this local data app
|
|
2
|
-
|
|
3
|
-
Read [AGENTS.md](https://github.com/altertable-ai/data-app/blob/main/AGENTS.md) first, then use the app files below.
|
|
4
|
-
|
|
5
|
-
| Task | App-owned files |
|
|
6
|
-
| ---------------------------------------- | -------------------------------------------------------- |
|
|
7
|
-
| Define queries and inputs | `app.ts`, `src/operations.ts`, optional shared contracts |
|
|
8
|
-
| Build the exploration, export, and story | `src/App.tsx` |
|
|
9
|
-
| Bind definitions and source evidence | `src/data-context.ts` |
|
|
10
|
-
| Change identity and appearance | `app.ts` |
|
|
11
|
-
| Inject styles and mount React | `src/main.tsx` |
|
|
12
|
-
| Configure local serving | `src/server.ts` |
|
|
13
|
-
|
|
14
|
-
See [README.md](README.md) for setup and checks.
|
|
15
|
-
|
|
16
|
-
## Focused guidance
|
|
17
|
-
|
|
18
|
-
Read the installed package's `AGENTS.md` and `docs/app-authoring.md` before
|
|
19
|
-
changing the app. Follow their task routes for views, variables, widgets, evidence,
|
|
20
|
-
and stories/export. Prefer generated controls and bound readings; keep static
|
|
21
|
-
context visible during requests. Update this app's instructions when a reusable
|
|
22
|
-
app-specific convention changes. Package internals remain dependencies.
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# Local data app starter
|
|
2
|
-
|
|
3
|
-
Use this starter with the [local authoring guide](https://github.com/altertable-ai/data-app/blob/main/docs/local-data-apps.md).
|
|
4
|
-
See [AGENTS.md](AGENTS.md) for app-owned files.
|
|
5
|
-
|
|
6
|
-
A Bun and React app that imports the public `@altertable/data-app` package.
|
|
7
|
-
It starts with a lakehouse connectivity check. Replace that check with bounded
|
|
8
|
-
operations and views built from inspected data before sharing an analysis.
|
|
9
|
-
|
|
10
|
-
## Run from this repository
|
|
11
|
-
|
|
12
|
-
Use the Bun and Node versions in `.bun-version` and `.node-version`.
|
|
13
|
-
From the repository root:
|
|
14
|
-
|
|
15
|
-
```fish
|
|
16
|
-
bun install --frozen-lockfile
|
|
17
|
-
bun run build
|
|
18
|
-
bun install --frozen-lockfile
|
|
19
|
-
cd examples/starter-local-data-app
|
|
20
|
-
bun run dev
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The second install refreshes the local file dependency with the built exports.
|
|
24
|
-
|
|
25
|
-
Open <http://127.0.0.1:25837>. Missing credentials show the connection error state;
|
|
26
|
-
the page still runs. Set server-only credentials before starting the server:
|
|
27
|
-
|
|
28
|
-
```fish
|
|
29
|
-
set -gx ALTERTABLE_LAKEHOUSE_USERNAME your-username
|
|
30
|
-
read --silent --prompt-str 'Lakehouse password: ' ALTERTABLE_LAKEHOUSE_PASSWORD
|
|
31
|
-
set -gx ALTERTABLE_LAKEHOUSE_PASSWORD $ALTERTABLE_LAKEHOUSE_PASSWORD
|
|
32
|
-
bun run dev
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Alternatively, supply `ALTERTABLE_DATA_PROXY_URL` and
|
|
36
|
-
`ALTERTABLE_DATA_PROXY_TOKEN` for an existing CLI proxy. These values must stay
|
|
37
|
-
on the server. This local adapter does not authorize hosted viewers.
|
|
38
|
-
|
|
39
|
-
## Make it your app
|
|
40
|
-
|
|
41
|
-
This checkout uses `file:../..` to exercise the built package before publication.
|
|
42
|
-
When copying the starter elsewhere, replace that dependency with the published
|
|
43
|
-
package using `bun add @altertable/data-app`, `npm install @altertable/data-app`,
|
|
44
|
-
or `pnpm add @altertable/data-app`, then regenerate your lockfile.
|
|
45
|
-
|
|
46
|
-
```fish
|
|
47
|
-
bun run check
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Edit the `defineDataApp()` declaration in `app.ts` for identity, appearance,
|
|
51
|
-
and queries.
|
|
52
|
-
|
|
53
|
-
`bun run build` typechecks the app, then bundles the browser page into `dist/`. That browser artifact
|
|
54
|
-
still needs an authorized `/api/data` backend when hosted.
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { defineDataApp } from "@altertable/data-app";
|
|
2
|
-
|
|
3
|
-
export const dataApp = defineDataApp({
|
|
4
|
-
title: "Getting started",
|
|
5
|
-
description: "Check your lakehouse connection, then build an exploration.",
|
|
6
|
-
scope: {
|
|
7
|
-
organization: "Your organization",
|
|
8
|
-
environment: "your environment",
|
|
9
|
-
},
|
|
10
|
-
appearance: {
|
|
11
|
-
theme: "light",
|
|
12
|
-
baseColor: "neutral",
|
|
13
|
-
density: "comfortable",
|
|
14
|
-
cornerRadius: "medium",
|
|
15
|
-
elevation: "subtle",
|
|
16
|
-
typography: {
|
|
17
|
-
body: "system",
|
|
18
|
-
heading: "system",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
queries: {
|
|
22
|
-
connection: {
|
|
23
|
-
projections: { connection_check: { type: "number" } },
|
|
24
|
-
statement: "SELECT 1 AS connection_check",
|
|
25
|
-
params: {},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "data-app-starter",
|
|
3
|
-
"private": true,
|
|
4
|
-
"type": "module",
|
|
5
|
-
"imports": {
|
|
6
|
-
"#app/*": "./src/*",
|
|
7
|
-
"#config": "./app.ts"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"typecheck": "tsc --noEmit",
|
|
11
|
-
"lint": "oxlint --type-aware src",
|
|
12
|
-
"format": "oxfmt src app.ts",
|
|
13
|
-
"format:check": "oxfmt --check src app.ts",
|
|
14
|
-
"dev": "bun --hot src/server.ts",
|
|
15
|
-
"build": "bun run typecheck && bun build src/index.html --outdir=dist --production",
|
|
16
|
-
"check": "bun run lint && bun run format:check && bun run build"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@altertable/data-app": "file:../..",
|
|
20
|
-
"react": "19.3.0",
|
|
21
|
-
"react-dom": "19.3.0"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/bun": "1.4.2",
|
|
25
|
-
"@types/react": "19.3.0",
|
|
26
|
-
"@types/react-dom": "19.3.0",
|
|
27
|
-
"oxfmt": "0.70.0",
|
|
28
|
-
"oxlint": "1.85.0",
|
|
29
|
-
"oxlint-tsgolint": "7.0.2003",
|
|
30
|
-
"typescript": "7.0.2"
|
|
31
|
-
},
|
|
32
|
-
"packageManager": "bun@1.4.2"
|
|
33
|
-
}
|