@altertable/data-app 0.66.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/CONTRIBUTING.md +22 -16
- package/dist/chunks/{contract-19ckn3n7.js → index-23dktynd.js} +8 -6
- package/dist/chunks/index-23dktynd.js.map +10 -0
- package/dist/chunks/{contract-havnjmdr.js → index-8qfxv0h5.js} +2272 -1123
- package/dist/chunks/index-8qfxv0h5.js.map +108 -0
- package/dist/chunks/{contract-rfbakka4.js → index-ag0cgnvq.js} +169 -35
- 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-e11m4y7f.js → index-ev2b5aaf.js} +11 -6
- package/dist/chunks/{contract-e11m4y7f.js.map → index-ev2b5aaf.js.map} +3 -3
- 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-13j5zb3c.js → index-ktmvs916.js} +8 -7
- package/dist/chunks/index-ktmvs916.js.map +13 -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/{contract-pk603qj7.js → index-x69p7cv7.js} +12 -9
- package/dist/chunks/index-x69p7cv7.js.map +10 -0
- package/dist/client/index.js +6 -6
- 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 +14 -6
- package/dist/core/contract.js.map +1 -1
- package/dist/core/format.js +1 -1
- package/dist/embed/index.js +12 -10
- 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 +57 -19
- package/dist/react/index.js.map +4 -4
- package/dist/react/ui/index.js +836 -178
- package/dist/react/ui/index.js.map +15 -9
- package/dist/server.js +13 -26
- package/dist/server.js.map +6 -7
- package/dist/types/client/annotations.d.ts +4 -0
- package/dist/types/client/data-client.d.ts +1 -2
- package/dist/types/client/iframe.d.ts +4 -2
- package/dist/types/core/annotations.d.ts +2 -0
- package/dist/types/core/config.d.ts +48 -4
- package/dist/types/core/contract.d.ts +20 -12
- 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/queries.d.ts +16 -0
- package/dist/types/core/uuid.d.ts +2 -0
- package/dist/types/core/variables.d.ts +32 -13
- 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 +7 -1
- package/dist/types/react/annotations/AnnotationEditor.d.ts +2 -1
- package/dist/types/react/annotations/useDataAppAnnotations.d.ts +3 -0
- package/dist/types/react/app-context.d.ts +3 -0
- package/dist/types/react/index.d.ts +3 -3
- package/dist/types/react/mount.d.ts +6 -4
- package/dist/types/react/style-contract.d.ts +22 -2
- 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/ComposedChart.d.ts +41 -0
- package/dist/types/react/ui/ComposedChartLegend.d.ts +8 -0
- package/dist/types/react/ui/DataAppFrame.d.ts +1 -2
- package/dist/types/react/ui/DimensionPicker.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/Menu.d.ts +12 -0
- 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 +5 -2
- package/dist/types/react/ui/RadioGroup.d.ts +18 -0
- package/dist/types/react/ui/SearchInput.d.ts +2 -2
- 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/TooltipSurface.d.ts +3 -0
- package/dist/types/react/ui/chart-data.d.ts +1 -1
- package/dist/types/react/ui/chart-primitives.d.ts +20 -0
- package/dist/types/react/ui/icons.d.ts +1 -0
- package/dist/types/react/ui/index.d.ts +26 -2
- package/dist/types/react/ui/keyboard.d.ts +6 -0
- package/dist/types/react/ui/shortcuts.d.ts +7 -0
- 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/server/handler.d.ts +4 -4
- package/dist/worker.js +20 -737
- package/docs/app-authoring.md +15 -1
- package/docs/client.md +8 -8
- package/docs/contract.md +42 -20
- package/docs/data-context.md +8 -6
- package/docs/embed.md +10 -2
- package/docs/formatting-and-appearance.md +23 -7
- package/docs/hosted-apps.md +9 -2
- package/docs/layout.md +1 -1
- package/docs/react-embed.md +3 -2
- package/docs/react.md +4 -3
- package/docs/server-bun.md +1 -1
- package/docs/server.md +4 -4
- package/docs/styling.md +10 -3
- package/docs/ui.md +158 -3
- package/docs/variables.md +80 -7
- package/docs/views.md +4 -8
- package/docs/widgets.md +16 -13
- package/examples/starter-data-app/index.tsx +34 -32
- package/package.json +16 -11
- package/dist/chunks/contract-13j5zb3c.js.map +0 -13
- package/dist/chunks/contract-19ckn3n7.js.map +0 -10
- package/dist/chunks/contract-h8a6f559.js +0 -286
- package/dist/chunks/contract-h8a6f559.js.map +0 -12
- package/dist/chunks/contract-havnjmdr.js.map +0 -99
- package/dist/chunks/contract-pk603qj7.js.map +0 -10
- package/dist/chunks/contract-rfbakka4.js.map +0 -13
- package/dist/chunks/contract-tf8c3qpv.js.map +0 -11
- package/dist/chunks/contract-wz59z8pq.js +0 -8
- package/dist/chunks/contract-wz59z8pq.js.map +0 -10
- /package/dist/chunks/{contract-m6n8ctfc.js → index-m6n8ctfc.js} +0 -0
- /package/dist/chunks/{contract-m6n8ctfc.js.map → index-m6n8ctfc.js.map} +0 -0
- /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/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
|
|
@@ -63,10 +73,9 @@ checks. Build before running consumer tests individually.
|
|
|
63
73
|
| `bun run check:links` | Validate local files, images, and heading links |
|
|
64
74
|
| `bun run check:links:external` | Check external URLs (requires network access) |
|
|
65
75
|
| `bun run format` | Format source and docs |
|
|
66
|
-
| `bun run test` | Verify public
|
|
67
|
-
| `bun run
|
|
68
|
-
| `bun run
|
|
69
|
-
| `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 |
|
|
70
79
|
| `bun run check:workflows` | Validate workflows and shell scripts |
|
|
71
80
|
|
|
72
81
|
Markdown checks cover all authored `.md` files, including `AGENTS.md` and the
|
|
@@ -79,18 +88,15 @@ It skips local development URLs and checks reachability without external heading
|
|
|
79
88
|
validation. It stays outside required checks because third-party availability and
|
|
80
89
|
rate limits can cause failures unrelated to a change.
|
|
81
90
|
|
|
82
|
-
For browser changes, run `bash scripts/install-test-browser.sh` once, then
|
|
83
|
-
`bun run test:browser`.
|
|
84
|
-
|
|
85
91
|
Run `bun run dev` to preview UI examples at `http://127.0.0.1:27418/gallery`
|
|
86
92
|
and a playground at `/playground` (`dev/playground.tsx`, querying the demo
|
|
87
|
-
tables `scripts/dev.ts` seeds). It builds once, then rebuilds `dist` when `src`
|
|
93
|
+
tables from `dev/seed.ts` that `scripts/dev.ts` seeds). It builds once, then rebuilds `dist` when `src`
|
|
88
94
|
changes; open pages reload on package, fixture, and playground edits. Restart it after changing
|
|
89
|
-
`
|
|
95
|
+
`dev/server.ts`; rerun `bun run build` to refresh declarations. Add `?delay=2000` to a host page URL
|
|
90
96
|
to delay its SQL responses and inspect loading states. It needs Docker: SQL runs
|
|
91
97
|
against a mocked Altertable API
|
|
92
98
|
([altertable-mock](https://github.com/altertable-ai/altertable-mock), DuckDB)
|
|
93
|
-
started with Testcontainers and stopped on exit.
|
|
99
|
+
started with Testcontainers and stopped on exit. Public API tests use their own deterministic consumer fixtures.
|
|
94
100
|
|
|
95
101
|
Open the **Widgets** tab (`/gallery?view=widgets`) for one ready example of each
|
|
96
102
|
composable data display inside `<VisualizationWidget>`. The other tabs cover
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeDataOperation,
|
|
3
3
|
toDataOperationFailure
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./index-x69p7cv7.js";
|
|
5
5
|
import {
|
|
6
6
|
DataAppError2,
|
|
7
7
|
createHttpTransport2,
|
|
8
8
|
localFrameBridge,
|
|
9
9
|
getDataAppTransport2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./index-ktmvs916.js";
|
|
11
|
+
import {
|
|
12
|
+
randomUuid
|
|
13
|
+
} from "./index-f5cnbrjz.js";
|
|
11
14
|
import {
|
|
12
15
|
MessageRoutingError2,
|
|
13
16
|
defineDataQueryRoute2
|
|
14
|
-
} from "./
|
|
17
|
+
} from "./index-qd5xgx6y.js";
|
|
15
18
|
|
|
16
19
|
// src/client/data-client.ts
|
|
17
20
|
var dataQueryRoute = defineDataQueryRoute2();
|
|
@@ -46,7 +49,7 @@ function createOperationClient(options) {
|
|
|
46
49
|
return {
|
|
47
50
|
async query(name, input, { signal } = {}) {
|
|
48
51
|
signal?.throwIfAborted();
|
|
49
|
-
const requestId =
|
|
52
|
+
const requestId = randomUuid();
|
|
50
53
|
if (!Object.hasOwn(options.operations, name))
|
|
51
54
|
throw new DataAppError2("Unknown data operation.", "not_found", requestId);
|
|
52
55
|
const lakehouse = options.lakehouse ?? (typeof window === "undefined" ? undefined : getDataAppTransport2()?.lakehouse);
|
|
@@ -56,7 +59,6 @@ function createOperationClient(options) {
|
|
|
56
59
|
const { body } = await executeDataOperation(options.operations[name], input, {
|
|
57
60
|
lakehouse,
|
|
58
61
|
signal: signal ?? new AbortController().signal,
|
|
59
|
-
includeSql: true,
|
|
60
62
|
requestId,
|
|
61
63
|
operationName: name
|
|
62
64
|
});
|
|
@@ -75,4 +77,4 @@ function createOperationClient(options) {
|
|
|
75
77
|
|
|
76
78
|
export { createDataClient2 };
|
|
77
79
|
|
|
78
|
-
//# debugId=
|
|
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
|
+
}
|