@altertable/data-app 0.65.0 → 0.67.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 +38 -1
- package/CONTRIBUTING.md +54 -14
- package/README.md +1 -1
- package/dist/chunks/index-23dktynd.js +80 -0
- package/dist/chunks/index-23dktynd.js.map +10 -0
- package/dist/chunks/index-8qfxv0h5.js +14160 -0
- package/dist/chunks/index-8qfxv0h5.js.map +108 -0
- package/dist/chunks/index-ag0cgnvq.js +639 -0
- package/dist/chunks/index-ag0cgnvq.js.map +13 -0
- package/dist/chunks/index-dq7b35fn.js +307 -0
- package/dist/chunks/index-dq7b35fn.js.map +13 -0
- package/dist/chunks/{contract-a061yj6r.js → index-ev2b5aaf.js} +41 -72
- package/dist/chunks/index-ev2b5aaf.js.map +12 -0
- package/dist/chunks/{contract-awa2d5b1.js → index-f5cnbrjz.js} +19 -2
- package/dist/chunks/{contract-awa2d5b1.js.map → index-f5cnbrjz.js.map} +4 -3
- package/dist/chunks/{contract-sm7j7k95.js → index-ktmvs916.js} +9 -150
- package/dist/chunks/index-ktmvs916.js.map +13 -0
- package/dist/chunks/{contract-txjy0en2.js → index-m6n8ctfc.js} +64 -72
- package/dist/chunks/index-m6n8ctfc.js.map +10 -0
- package/dist/chunks/index-mt93ff2b.js +28 -0
- package/dist/chunks/index-mt93ff2b.js.map +10 -0
- package/dist/chunks/{contract-tf8c3qpv.js → index-qd5xgx6y.js} +46 -5
- package/dist/chunks/index-qd5xgx6y.js.map +13 -0
- package/dist/chunks/index-x69p7cv7.js +149 -0
- package/dist/chunks/index-x69p7cv7.js.map +10 -0
- package/dist/client/index.js +12 -7
- package/dist/client/index.js.map +1 -1
- package/dist/core/appearance.js +1 -1
- package/dist/core/config.js +7 -3
- package/dist/core/config.js.map +1 -1
- package/dist/core/contract.js +24 -6
- package/dist/core/contract.js.map +1 -1
- package/dist/core/format.js +1 -1
- package/dist/embed/index.js +16 -12
- package/dist/embed/index.js.map +4 -4
- package/dist/index.js +12 -0
- package/dist/index.js.map +9 -0
- package/dist/local.js +20 -30
- package/dist/local.js.map +7 -8
- package/dist/react/embed/index.js +1 -1
- package/dist/react/embed/index.js.map +2 -2
- package/dist/react/index.js +2567 -11542
- package/dist/react/index.js.map +16 -91
- package/dist/react/ui/index.js +2272 -0
- package/dist/react/ui/index.js.map +28 -0
- package/dist/server.js +13 -26
- package/dist/server.js.map +6 -7
- package/dist/types/client/annotations.d.ts +27 -0
- package/dist/types/client/data-client.d.ts +1 -2
- package/dist/types/client/iframe.d.ts +4 -2
- package/dist/types/client/index.d.ts +1 -0
- package/dist/types/core/annotations.d.ts +94 -0
- package/dist/types/core/appearance.d.ts +2 -2
- package/dist/types/core/config.d.ts +48 -4
- package/dist/types/core/contract.d.ts +21 -11
- package/dist/types/core/dimension.d.ts +6 -4
- package/dist/types/core/filters.d.ts +44 -0
- package/dist/types/core/messages.d.ts +2 -0
- package/dist/types/core/operation-types.d.ts +5 -2
- package/dist/types/core/operation.d.ts +3 -4
- package/dist/types/core/presentation.d.ts +2 -0
- package/dist/types/core/queries.d.ts +16 -0
- package/dist/types/core/uuid.d.ts +2 -0
- package/dist/types/core/variables.d.ts +34 -18
- package/dist/types/embed/runtime-html.d.ts +2 -0
- package/dist/types/embed/source.d.ts +2 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/react/annotations/AnnotationBar.d.ts +30 -0
- package/dist/types/react/annotations/AnnotationControls.d.ts +10 -0
- package/dist/types/react/annotations/AnnotationEditor.d.ts +16 -0
- package/dist/types/react/annotations/AnnotationMarkers.d.ts +19 -0
- package/dist/types/react/annotations/AnnotationSelectionLayer.d.ts +12 -0
- package/dist/types/react/annotations/AnnotationTarget.d.ts +9 -0
- package/dist/types/react/annotations/AnnotationTooltip.d.ts +9 -0
- package/dist/types/react/annotations/AnnotationTrigger.d.ts +10 -0
- package/dist/types/react/annotations/annotation-editor-state.d.ts +56 -0
- package/dist/types/react/annotations/annotation-screenshot.d.ts +4 -0
- package/dist/types/react/annotations/annotation-targets.d.ts +33 -0
- package/dist/types/react/annotations/getAnnotationProps.d.ts +15 -0
- package/dist/types/react/annotations/styles.d.ts +3 -0
- package/dist/types/react/annotations/useAnnotationGeometry.d.ts +22 -0
- package/dist/types/react/annotations/useDataAppAnnotations.d.ts +22 -0
- package/dist/types/react/app-context.d.ts +3 -0
- package/dist/types/react/bindings.d.ts +110 -0
- package/dist/types/react/content.d.ts +24 -11
- package/dist/types/react/hooks.d.ts +29 -787
- package/dist/types/react/index.d.ts +31 -106
- package/dist/types/react/mount.d.ts +6 -4
- package/dist/types/react/source-owner.d.ts +2 -0
- package/dist/types/react/style-contract.d.ts +80 -0
- package/dist/types/react/style-validation.d.ts +2 -0
- package/dist/types/react/ui/AboutData.d.ts +9 -1
- package/dist/types/react/ui/AppHeader.d.ts +1 -2
- package/dist/types/react/ui/AppLayout.d.ts +3 -9
- package/dist/types/react/ui/AppToolbar.d.ts +5 -8
- package/dist/types/react/ui/AreaChart.d.ts +7 -0
- package/dist/types/react/ui/BarChart.d.ts +6 -0
- package/dist/types/react/ui/Button.d.ts +3 -3
- package/dist/types/react/ui/ChartLegend.d.ts +31 -0
- package/dist/types/react/ui/Checkbox.d.ts +15 -4
- package/dist/types/react/ui/CheckboxGroup.d.ts +7 -0
- package/dist/types/react/ui/{Combobox.d.ts → ChoicePicker.d.ts} +10 -15
- package/dist/types/react/ui/{ComparisonVisual.d.ts → Comparison.d.ts} +3 -3
- package/dist/types/react/ui/ComposedChart.d.ts +41 -0
- package/dist/types/react/ui/ComposedChartLegend.d.ts +8 -0
- package/dist/types/react/ui/ContentSkeleton.d.ts +2 -0
- package/dist/types/react/ui/DataApp.d.ts +17 -58
- package/dist/types/react/ui/DataAppFrame.d.ts +41 -0
- package/dist/types/react/ui/DataBoundary.d.ts +4 -5
- package/dist/types/react/ui/DataSection.d.ts +6 -18
- package/dist/types/react/ui/DataSectionBoundary.d.ts +30 -0
- package/dist/types/react/ui/DataValue.d.ts +9 -0
- package/dist/types/react/ui/DataWidget.d.ts +2 -1
- package/dist/types/react/ui/DateTimeTooltip.d.ts +1 -1
- package/dist/types/react/ui/DimensionPicker.d.ts +1 -1
- package/dist/types/react/ui/ExportControl.d.ts +1 -1
- package/dist/types/react/ui/FilterActions.d.ts +10 -0
- package/dist/types/react/ui/FilterBar.d.ts +3 -0
- package/dist/types/react/ui/GettingStarted.d.ts +2 -4
- package/dist/types/react/ui/HelpPopover.d.ts +3 -4
- package/dist/types/react/ui/InspectionContext.d.ts +2 -0
- package/dist/types/react/ui/InspectionProvider.d.ts +29 -0
- package/dist/types/react/ui/LineChart.d.ts +7 -0
- package/dist/types/react/ui/Menu.d.ts +12 -0
- package/dist/types/react/ui/MetricWidget.d.ts +4 -3
- package/dist/types/react/ui/NumberField.d.ts +27 -0
- package/dist/types/react/ui/NumberFilterPicker.d.ts +9 -0
- package/dist/types/react/ui/PieChart.d.ts +11 -0
- package/dist/types/react/ui/PresentStory.d.ts +2 -5
- package/dist/types/react/ui/RadioGroup.d.ts +18 -0
- package/dist/types/react/ui/RefreshControl.d.ts +1 -2
- package/dist/types/react/ui/ScatterChart.d.ts +17 -0
- package/dist/types/react/ui/SearchField.d.ts +1 -2
- package/dist/types/react/ui/SearchInput.d.ts +3 -1
- package/dist/types/react/ui/Select.d.ts +14 -0
- package/dist/types/react/ui/SelectionMark.d.ts +2 -1
- package/dist/types/react/ui/Sheet.d.ts +2 -1
- package/dist/types/react/ui/Skeleton.d.ts +5 -2
- package/dist/types/react/ui/StaticDataApp.d.ts +4 -0
- package/dist/types/react/ui/TableWidget.d.ts +19 -16
- package/dist/types/react/ui/Tabs.d.ts +6 -2
- package/dist/types/react/ui/TextWidget.d.ts +2 -1
- package/dist/types/react/ui/Tooltip.d.ts +4 -3
- package/dist/types/react/ui/TooltipSurface.d.ts +3 -0
- package/dist/types/react/ui/TrendChart.d.ts +5 -0
- package/dist/types/react/ui/UpdatedAt.d.ts +1 -1
- package/dist/types/react/ui/VisualizationWidget.d.ts +12 -13
- package/dist/types/react/ui/WidgetViewTabs.d.ts +1 -1
- package/dist/types/react/ui/chart-data.d.ts +25 -0
- package/dist/types/react/ui/chart-primitives.d.ts +20 -0
- package/dist/types/react/ui/data-context.d.ts +18 -7
- package/dist/types/react/ui/icons.d.ts +2 -0
- package/dist/types/react/ui/index.d.ts +98 -0
- package/dist/types/react/ui/keyboard.d.ts +6 -0
- package/dist/types/react/ui/metric.d.ts +1 -1
- package/dist/types/react/ui/presentation.d.ts +5 -1
- package/dist/types/react/ui/shortcuts.d.ts +14 -1
- package/dist/types/react/ui/useAppAppearance.d.ts +1 -1
- package/dist/types/react/ui/variables.d.ts +4 -2
- package/dist/types/react/view-controls.d.ts +3 -1
- package/dist/types/react/view-runtime.d.ts +29 -0
- package/dist/types/react/view.d.ts +21 -4
- package/dist/types/react/widgets.d.ts +79 -0
- package/dist/types/server/handler.d.ts +4 -4
- package/dist/worker.js +20 -737
- package/docs/app-authoring.md +72 -50
- package/docs/client.md +8 -8
- package/docs/contract.md +42 -20
- package/docs/data-context.md +91 -0
- package/docs/embed.md +10 -2
- package/docs/formatting-and-appearance.md +68 -0
- package/docs/hosted-apps.md +9 -15
- package/docs/layout.md +5 -3
- package/docs/react-embed.md +5 -4
- package/docs/react.md +22 -317
- package/docs/server-bun.md +1 -1
- package/docs/server.md +4 -4
- package/docs/stories-and-export.md +52 -0
- package/docs/styling.md +62 -0
- package/docs/ui-quality.md +20 -0
- package/docs/ui.md +196 -0
- package/docs/variables.md +171 -0
- package/docs/views.md +123 -0
- package/docs/widgets.md +145 -0
- package/examples/starter-data-app/index.tsx +115 -86
- package/package.json +25 -12
- package/dist/chunks/contract-a061yj6r.js.map +0 -12
- package/dist/chunks/contract-g6hky7x6.js +0 -282
- package/dist/chunks/contract-g6hky7x6.js.map +0 -12
- package/dist/chunks/contract-sm7j7k95.js.map +0 -14
- package/dist/chunks/contract-tf8c3qpv.js.map +0 -11
- package/dist/chunks/contract-txjy0en2.js.map +0 -10
- package/dist/chunks/contract-wz59z8pq.js +0 -8
- package/dist/chunks/contract-wz59z8pq.js.map +0 -10
- package/dist/chunks/contract-yxbjea23.js +0 -328
- package/dist/chunks/contract-yxbjea23.js.map +0 -12
- package/dist/types/react/ui/RefreshRegion.d.ts +0 -9
- package/dist/types/react/ui/SelectableBarChart.d.ts +0 -15
- package/docs/releasing.md +0 -79
- /package/dist/chunks/{contract-mev09s5v.js → index-mev09s5v.js} +0 -0
- /package/dist/chunks/{contract-mev09s5v.js.map → index-mev09s5v.js.map} +0 -0
- /package/dist/types/react/ui/{comparison.d.ts → metric-comparison.d.ts} +0 -0
package/AGENTS.md
CHANGED
|
@@ -3,8 +3,45 @@
|
|
|
3
3
|
Build Altertable data apps with `@altertable/data-app`. They render in an iframe
|
|
4
4
|
in Altertable, a chat app, or locally in a browser.
|
|
5
5
|
|
|
6
|
-
Every
|
|
6
|
+
Every data app includes CSV export and a story in the built-in toolbar,
|
|
7
7
|
both derived from the displayed result. Setup and static screens may omit them.
|
|
8
8
|
|
|
9
9
|
Follow [app authoring](docs/app-authoring.md) for the shared workflow, the data app
|
|
10
10
|
and local data app paths, and task-specific documentation.
|
|
11
|
+
|
|
12
|
+
## Styling
|
|
13
|
+
|
|
14
|
+
Use components and typed props first; customize through app-owned `className`
|
|
15
|
+
and public tokens. Follow [Styling](docs/styling.md)
|
|
16
|
+
and [UI quality](docs/ui-quality.md).
|
|
17
|
+
Do not copy package classes onto markup or select private descendants.
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
Use `<Component>` notation for React components. Keep guidance concise; leave
|
|
22
|
+
prop details to TypeScript and JSDoc. Describe the current API without migration
|
|
23
|
+
or legacy instructions.
|
|
24
|
+
|
|
25
|
+
## App authoring
|
|
26
|
+
|
|
27
|
+
Read the matching guide before generating an app. Package contributors follow
|
|
28
|
+
[Contributing](CONTRIBUTING.md).
|
|
29
|
+
|
|
30
|
+
| Task | Read |
|
|
31
|
+
| -------------------------------------- | -------------------------------------------------------------- |
|
|
32
|
+
| Choose hosted or local execution | [App authoring](docs/app-authoring.md) |
|
|
33
|
+
| Load data and compose loading states | [Views](docs/views.md) |
|
|
34
|
+
| Add filters | [Variables](docs/variables.md) |
|
|
35
|
+
| Compose visuals, tables, and narrative | [Widgets](docs/widgets.md), [layout](docs/layout.md) |
|
|
36
|
+
| Define sources and evidence | [Data context](docs/data-context.md) |
|
|
37
|
+
| Present findings and export results | [Stories and export](docs/stories-and-export.md) |
|
|
38
|
+
| Format values and appearance | [Formatting and appearance](docs/formatting-and-appearance.md) |
|
|
39
|
+
|
|
40
|
+
Use `/react` with declared views and bound widgets. `/react/ui` is for setup,
|
|
41
|
+
static displays, and deliberately custom UI; see [direct composition](docs/ui.md).
|
|
42
|
+
Prefer derivation over repeated configuration. Keep static context outside loading boundaries. Derive labels, findings, and
|
|
43
|
+
exports from the displayed result and its input. Edit app-owned files; installed
|
|
44
|
+
package files are dependencies.
|
|
45
|
+
|
|
46
|
+
Keep `docs/` focused on knowledge agents need to build data apps. Put package
|
|
47
|
+
implementation, testing, and release guidance in `CONTRIBUTING.md`.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -4,6 +4,7 @@ Use the Bun and Node.js versions in `.bun-version` and `.node-version`.
|
|
|
4
4
|
|
|
5
5
|
```fish
|
|
6
6
|
bun install --frozen-lockfile
|
|
7
|
+
bash scripts/install-test-browser.sh
|
|
7
8
|
bun run check
|
|
8
9
|
```
|
|
9
10
|
|
|
@@ -36,12 +37,21 @@ fallbacks minimal.
|
|
|
36
37
|
|
|
37
38
|
## Verify changes
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
authorize and query it, compose a view, or embed an app
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
Write high-level public API tests with Vitest in `tests/public-api`. Define an
|
|
41
|
+
operation, authorize and query it, compose a view, or embed an app through
|
|
42
|
+
`@altertable/data-app/<entry>`. Assert consumer-visible results and errors. Supply
|
|
43
|
+
data and failures through public dependency injection; do not import private
|
|
44
|
+
source, fabricate internal state, or assert implementation details. Prefer queries by role and accessible name, or by label for form fields. Scope
|
|
45
|
+
content assertions to the relevant region, status, alert, or dialog; use text
|
|
46
|
+
queries for prose with no meaningful role. Do not invent ARIA roles for tests.
|
|
47
|
+
Group browser workflows by consumer capability in `apps-*.test.ts`; keep tests
|
|
48
|
+
self-contained and setup local until repetition warrants sharing it.
|
|
49
|
+
|
|
50
|
+
`bun run test` runs the complete suite against the built package. Browser
|
|
51
|
+
workflows launch Chromium through Playwright from Vitest. They use public
|
|
52
|
+
consumer fixtures, an isolated local server, and a fresh browser context per
|
|
53
|
+
test. Build first; run one file with `bun run test tests/public-api/apps-export.test.ts`
|
|
54
|
+
or one workflow with `bun run test -t "workflow name"`.
|
|
45
55
|
|
|
46
56
|
Update the relevant guide when changing public behavior. In documentation prose,
|
|
47
57
|
write functions as `functionName()` and components as `<ComponentName>`. Keep JSDoc for
|
|
@@ -56,16 +66,16 @@ checks. Build before running consumer tests individually.
|
|
|
56
66
|
| Command | Purpose |
|
|
57
67
|
| ------------------------------ | --------------------------------------------------- |
|
|
58
68
|
| `bun run build` | Build JavaScript, declarations, and injected styles |
|
|
69
|
+
| `bun run check:styles` | Validate authored styling hooks |
|
|
59
70
|
| `bun run typecheck` | Check source, tests, and scripts |
|
|
60
71
|
| `bun run lint` | Run type-aware lint checks |
|
|
61
72
|
| `bun run lint:md` | Check Markdown structure and syntax |
|
|
62
73
|
| `bun run check:links` | Validate local files, images, and heading links |
|
|
63
74
|
| `bun run check:links:external` | Check external URLs (requires network access) |
|
|
64
75
|
| `bun run format` | Format source and docs |
|
|
65
|
-
| `bun run test` | Verify public
|
|
66
|
-
| `bun run
|
|
67
|
-
| `bun run
|
|
68
|
-
| `bun run test:browser` | Verify browser interactions in Chromium |
|
|
76
|
+
| `bun run test` | Verify high-level public API workflows with Vitest |
|
|
77
|
+
| `bun run check:package` | Verify the npm archive as a consumer |
|
|
78
|
+
| `bun run check:starter` | Typecheck, lint, and build the starter |
|
|
69
79
|
| `bun run check:workflows` | Validate workflows and shell scripts |
|
|
70
80
|
|
|
71
81
|
Markdown checks cover all authored `.md` files, including `AGENTS.md` and the
|
|
@@ -78,10 +88,40 @@ It skips local development URLs and checks reachability without external heading
|
|
|
78
88
|
validation. It stays outside required checks because third-party availability and
|
|
79
89
|
rate limits can cause failures unrelated to a change.
|
|
80
90
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
`
|
|
91
|
+
Run `bun run dev` to preview UI examples at `http://127.0.0.1:27418/gallery`
|
|
92
|
+
and a playground at `/playground` (`dev/playground.tsx`, querying the demo
|
|
93
|
+
tables from `dev/seed.ts` that `scripts/dev.ts` seeds). It builds once, then rebuilds `dist` when `src`
|
|
94
|
+
changes; open pages reload on package, fixture, and playground edits. Restart it after changing
|
|
95
|
+
`dev/server.ts`; rerun `bun run build` to refresh declarations. Add `?delay=2000` to a host page URL
|
|
96
|
+
to delay its SQL responses and inspect loading states. It needs Docker: SQL runs
|
|
97
|
+
against a mocked Altertable API
|
|
98
|
+
([altertable-mock](https://github.com/altertable-ai/altertable-mock), DuckDB)
|
|
99
|
+
started with Testcontainers and stopped on exit. Public API tests use their own deterministic consumer fixtures.
|
|
100
|
+
|
|
101
|
+
Open the **Widgets** tab (`/gallery?view=widgets`) for one ready example of each
|
|
102
|
+
composable data display inside `<VisualizationWidget>`. The other tabs cover
|
|
103
|
+
composed apps, variants, and request states.
|
|
84
104
|
|
|
85
105
|
Use Conventional Commits and describe behavior changes and verification in PRs.
|
|
86
106
|
Flag breaking API changes. Release Please owns `CHANGELOG.md`; see
|
|
87
|
-
[Releasing](
|
|
107
|
+
[Releasing](https://github.com/altertable-ai/data-app/blob/main/.github/RELEASING.md) for release setup and recovery.
|
|
108
|
+
|
|
109
|
+
## Focused public API
|
|
110
|
+
|
|
111
|
+
Keep exports and options focused on concrete app needs. Prefer defaults and
|
|
112
|
+
derivation from existing state over new knobs; keep implementation details private.
|
|
113
|
+
|
|
114
|
+
For public changes, update the relevant guide, migrate callers and starters,
|
|
115
|
+
and verify published usage. Flag breaking changes in commits and PRs.
|
|
116
|
+
|
|
117
|
+
Docs help agents generate data apps: show current usage and focused examples.
|
|
118
|
+
Keep package architecture and contributor rules here.
|
|
119
|
+
|
|
120
|
+
## Component CSS
|
|
121
|
+
|
|
122
|
+
Keep defaults in authored CSS: inherited values in `tokens.css`, presets in
|
|
123
|
+
`appearance.css`, and optional overrides in native `var()` fallbacks at use sites.
|
|
124
|
+
Use the four layers (`atbl.tokens`, `atbl.base`, `atbl.components`,
|
|
125
|
+
`atbl.interaction`) and shared focus/state rules rather than duplicate control
|
|
126
|
+
paint. Keep geometry local. Document public variables beside declarations or
|
|
127
|
+
consumption sites; update the name contract in `style-contract.ts` when adding hooks.
|
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ For integrating apps into a host, see [embedding](docs/embed.md).
|
|
|
38
38
|
## Development
|
|
39
39
|
|
|
40
40
|
See [Contributing](CONTRIBUTING.md) for repository structure and focused checks.
|
|
41
|
-
Releases use [Release Please and npm trusted publishing](
|
|
41
|
+
Releases use [Release Please and npm trusted publishing](https://github.com/altertable-ai/data-app/blob/main/.github/RELEASING.md).
|
|
42
42
|
|
|
43
43
|
## License
|
|
44
44
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeDataOperation,
|
|
3
|
+
toDataOperationFailure
|
|
4
|
+
} from "./index-x69p7cv7.js";
|
|
5
|
+
import {
|
|
6
|
+
DataAppError2,
|
|
7
|
+
createHttpTransport2,
|
|
8
|
+
localFrameBridge,
|
|
9
|
+
getDataAppTransport2
|
|
10
|
+
} from "./index-ktmvs916.js";
|
|
11
|
+
import {
|
|
12
|
+
randomUuid
|
|
13
|
+
} from "./index-f5cnbrjz.js";
|
|
14
|
+
import {
|
|
15
|
+
MessageRoutingError2,
|
|
16
|
+
defineDataQueryRoute2
|
|
17
|
+
} from "./index-qd5xgx6y.js";
|
|
18
|
+
|
|
19
|
+
// src/client/data-client.ts
|
|
20
|
+
var dataQueryRoute = defineDataQueryRoute2();
|
|
21
|
+
function createDataClient2(options = {}) {
|
|
22
|
+
if (options.operations)
|
|
23
|
+
return createOperationClient({
|
|
24
|
+
operations: options.operations,
|
|
25
|
+
lakehouse: options.lakehouse
|
|
26
|
+
});
|
|
27
|
+
const http = createHttpTransport2(options);
|
|
28
|
+
const useHttp = options.endpoint !== undefined || options.fetch !== undefined;
|
|
29
|
+
return {
|
|
30
|
+
async query(name, input, { signal } = {}) {
|
|
31
|
+
const transport = options.transport ?? (useHttp ? http : localFrameBridge()?.transport ?? http);
|
|
32
|
+
const response = await transport(name, input, signal);
|
|
33
|
+
const ok = response.status >= 200 && response.status < 300;
|
|
34
|
+
let body;
|
|
35
|
+
try {
|
|
36
|
+
body = dataQueryRoute.output(response, { operation: name, input }).body;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (signal?.aborted)
|
|
39
|
+
throw error;
|
|
40
|
+
if (error instanceof MessageRoutingError2)
|
|
41
|
+
throw new DataAppError2(error.message, error.code, error.requestId);
|
|
42
|
+
throw new DataAppError2(ok ? "The data response was invalid." : "Could not load data.", ok ? "invalid_response" : "request_failed");
|
|
43
|
+
}
|
|
44
|
+
return { ...body, input };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function createOperationClient(options) {
|
|
49
|
+
return {
|
|
50
|
+
async query(name, input, { signal } = {}) {
|
|
51
|
+
signal?.throwIfAborted();
|
|
52
|
+
const requestId = randomUuid();
|
|
53
|
+
if (!Object.hasOwn(options.operations, name))
|
|
54
|
+
throw new DataAppError2("Unknown data operation.", "not_found", requestId);
|
|
55
|
+
const lakehouse = options.lakehouse ?? (typeof window === "undefined" ? undefined : getDataAppTransport2()?.lakehouse);
|
|
56
|
+
if (!lakehouse)
|
|
57
|
+
throw new DataAppError2("An authorized SQL bridge must be installed first.", "bridge_unavailable", requestId);
|
|
58
|
+
try {
|
|
59
|
+
const { body } = await executeDataOperation(options.operations[name], input, {
|
|
60
|
+
lakehouse,
|
|
61
|
+
signal: signal ?? new AbortController().signal,
|
|
62
|
+
requestId,
|
|
63
|
+
operationName: name
|
|
64
|
+
});
|
|
65
|
+
return { ...body, input };
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (signal?.aborted)
|
|
68
|
+
throw signal.reason;
|
|
69
|
+
if (error instanceof DataAppError2)
|
|
70
|
+
throw error;
|
|
71
|
+
const failure = toDataOperationFailure(error);
|
|
72
|
+
throw new DataAppError2(failure.message, failure.code, requestId);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { createDataClient2 };
|
|
79
|
+
|
|
80
|
+
//# debugId=F1FFBCC98547BBCD64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/client/data-client.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { randomUuid } from '@/src/core/uuid';\nimport { createHttpTransport, DataAppError } from '@/src/client/transport';\nimport { getDataAppTransport, localFrameBridge } from '@/src/client/iframe';\nimport {\n executeDataOperation,\n toDataOperationFailure,\n} from '@/src/core/operation';\nimport type { DataOperations, Lakehouse } from '@/src/core/contract';\nimport { defineDataQueryRoute, MessageRoutingError } from '@/src/core/messages';\nimport type { DataTransport } from '@/src/client/transport';\nimport type {\n DataQueryBody,\n InputOf,\n OutputOf,\n} from '@/src/core/operation-types';\nexport type { InputOf, OutputOf } from '@/src/core/operation-types';\n\n/**\n * Parsed operation data and query evidence.\n */\nexport type DataResponse<Output, Input = unknown> = DataQueryBody<Output> & {\n /** The exact browser input that produced this response. */\n input: Input;\n};\n\nexport type DataClient<Operations extends DataOperations> = {\n query<Name extends keyof Operations & string>(\n name: Name,\n input: InputOf<Operations[Name]>,\n options?: { signal?: AbortSignal }\n ): Promise<\n DataResponse<OutputOf<Operations[Name]>, InputOf<Operations[Name]>>\n >;\n};\n\n/** Browser operations and named-operation delivery are mutually exclusive configurations. */\nexport type DataClientOptions<Operations extends DataOperations> =\n | {\n operations: Operations;\n lakehouse?: Lakehouse;\n transport?: never;\n endpoint?: never;\n fetch?: never;\n }\n | {\n operations?: never;\n lakehouse?: never;\n transport?: DataTransport;\n endpoint?: string;\n fetch?: typeof fetch;\n };\n\nconst dataQueryRoute = defineDataQueryRoute();\n\n/** Named HTTP operations, or browser-owned operations executed through an authorized SQL bridge. */\nexport function createDataClient<Operations extends DataOperations>(\n options: DataClientOptions<Operations> = {}\n): DataClient<Operations> {\n if (options.operations)\n return createOperationClient({\n operations: options.operations,\n lakehouse: options.lakehouse,\n });\n const http = createHttpTransport(options);\n const useHttp = options.endpoint !== undefined || options.fetch !== undefined;\n\n return {\n async query(name, input, { signal } = {}) {\n const transport =\n options.transport ??\n (useHttp ? http : (localFrameBridge()?.transport ?? http));\n const response = await transport(name, input, signal);\n const ok = response.status >= 200 && response.status < 300;\n let body: Omit<DataResponse<OutputOf<Operations[typeof name]>>, 'input'>;\n try {\n body = dataQueryRoute.output(response, { operation: name, input })\n .body as typeof body;\n } catch (error) {\n if (signal?.aborted) throw error;\n if (error instanceof MessageRoutingError)\n throw new DataAppError(error.message, error.code, error.requestId);\n throw new DataAppError(\n ok ? 'The data response was invalid.' : 'Could not load data.',\n ok ? 'invalid_response' : 'request_failed'\n );\n }\n\n return { ...body, input };\n },\n };\n}\n\nfunction createOperationClient<Operations extends DataOperations>(options: {\n operations: Operations;\n lakehouse?: Lakehouse;\n}): DataClient<Operations> {\n return {\n async query(name, input, { signal } = {}) {\n signal?.throwIfAborted();\n const requestId = randomUuid();\n if (!Object.hasOwn(options.operations, name))\n throw new DataAppError(\n 'Unknown data operation.',\n 'not_found',\n requestId\n );\n const lakehouse =\n options.lakehouse ??\n (typeof window === 'undefined'\n ? undefined\n : getDataAppTransport()?.lakehouse);\n if (!lakehouse)\n throw new DataAppError(\n 'An authorized SQL bridge must be installed first.',\n 'bridge_unavailable',\n requestId\n );\n\n try {\n const { body } = await executeDataOperation(\n options.operations[name]!,\n input,\n {\n lakehouse,\n signal: signal ?? new AbortController().signal,\n requestId,\n operationName: name,\n }\n );\n\n return { ...body, input } as DataResponse<\n OutputOf<Operations[typeof name]>,\n InputOf<Operations[typeof name]>\n >;\n } catch (error) {\n if (signal?.aborted) throw signal.reason;\n if (error instanceof DataAppError) throw error;\n const failure = toDataOperationFailure(error);\n throw new DataAppError(failure.message, failure.code, requestId);\n }\n },\n };\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAoDA,IAAM,iBAAiB,sBAAqB;AAGrC,SAAS,iBAAmD,CACjE,UAAyC,CAAC,GAClB;AAAA,EACxB,IAAI,QAAQ;AAAA,IACV,OAAO,sBAAsB;AAAA,MAC3B,YAAY,QAAQ;AAAA,MACpB,WAAW,QAAQ;AAAA,IACrB,CAAC;AAAA,EACH,MAAM,OAAO,qBAAoB,OAAO;AAAA,EACxC,MAAM,UAAU,QAAQ,aAAa,aAAa,QAAQ,UAAU;AAAA,EAEpE,OAAO;AAAA,SACC,MAAK,CAAC,MAAM,SAAS,WAAW,CAAC,GAAG;AAAA,MACxC,MAAM,YACJ,QAAQ,cACP,UAAU,OAAQ,iBAAiB,GAAG,aAAa;AAAA,MACtD,MAAM,WAAW,MAAM,UAAU,MAAM,OAAO,MAAM;AAAA,MACpD,MAAM,KAAK,SAAS,UAAU,OAAO,SAAS,SAAS;AAAA,MACvD,IAAI;AAAA,MACJ,IAAI;AAAA,QACF,OAAO,eAAe,OAAO,UAAU,EAAE,WAAW,MAAM,MAAM,CAAC,EAC9D;AAAA,QACH,OAAO,OAAO;AAAA,QACd,IAAI,QAAQ;AAAA,UAAS,MAAM;AAAA,QAC3B,IAAI,iBAAiB;AAAA,UACnB,MAAM,IAAI,cAAa,MAAM,SAAS,MAAM,MAAM,MAAM,SAAS;AAAA,QACnE,MAAM,IAAI,cACR,KAAK,mCAAmC,wBACxC,KAAK,qBAAqB,gBAC5B;AAAA;AAAA,MAGF,OAAO,KAAK,MAAM,MAAM;AAAA;AAAA,EAE5B;AAAA;AAGF,SAAS,qBAAwD,CAAC,SAGvC;AAAA,EACzB,OAAO;AAAA,SACC,MAAK,CAAC,MAAM,SAAS,WAAW,CAAC,GAAG;AAAA,MACxC,QAAQ,eAAe;AAAA,MACvB,MAAM,YAAY,WAAW;AAAA,MAC7B,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,IAAI;AAAA,QACzC,MAAM,IAAI,cACR,2BACA,aACA,SACF;AAAA,MACF,MAAM,YACJ,QAAQ,cACP,OAAO,WAAW,cACf,YACA,qBAAoB,GAAG;AAAA,MAC7B,IAAI,CAAC;AAAA,QACH,MAAM,IAAI,cACR,qDACA,sBACA,SACF;AAAA,MAEF,IAAI;AAAA,QACF,QAAQ,SAAS,MAAM,qBACrB,QAAQ,WAAW,OACnB,OACA;AAAA,UACE;AAAA,UACA,QAAQ,UAAU,IAAI,gBAAgB,EAAE;AAAA,UACxC;AAAA,UACA,eAAe;AAAA,QACjB,CACF;AAAA,QAEA,OAAO,KAAK,MAAM,MAAM;AAAA,QAIxB,OAAO,OAAO;AAAA,QACd,IAAI,QAAQ;AAAA,UAAS,MAAM,OAAO;AAAA,QAClC,IAAI,iBAAiB;AAAA,UAAc,MAAM;AAAA,QACzC,MAAM,UAAU,uBAAuB,KAAK;AAAA,QAC5C,MAAM,IAAI,cAAa,QAAQ,SAAS,QAAQ,MAAM,SAAS;AAAA;AAAA;AAAA,EAGrE;AAAA;",
|
|
8
|
+
"debugId": "F1FFBCC98547BBCD64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|