From 4855c027d99c7d0bb763242cfd032533b5e8d45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Mon, 23 Nov 2026 16:21:53 +0100 Subject: [PATCH] feat(app): adopt data-app SDK 0.79.0 Distribute the published view-bound widget starter consistently across app creation, directory previews, single-file previews, and dependency upgrades. Refresh the corresponding frozen lockfiles and integration fixtures.\n\nDerive test expectations from the pinned starter to avoid release-only assertion churn, retain the historical upgrade case through the public CLI, and remove the README upgrades section. Keep source migrations author-owned without adding an upgrade dependency or embedded guides. --- CHANGELOG.md | 2 +- cli/bun.lock | 8 +- cli/package.json | 4 +- cli/scripts/smoke-data-app.ts | 8 +- cli/src/commands/app/create.test.ts | 2 +- cli/src/commands/app/lib/distribution.test.ts | 12 +- cli/src/commands/app/upgrade.test.ts | 35 +- data-app/README.md | 11 - data-app/file-preview/bun.lock | 16 +- data-app/file-preview/package.json | 8 +- data-app/starter/bun.lock | 14 +- data-app/tests/bun.lock | 10 +- data-app/tests/package.json | 4 +- data-app/tests/query-results.json | 413 +----------------- data-app/tests/server.ts | 17 +- data-app/tests/starter.spec.ts | 73 ++-- 16 files changed, 135 insertions(+), 502 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c83dd..0eec7a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Generate, preview, and upgrade data apps with data-app 0.78.0. New projects use the editable standalone example and a shared `app.ts` declaration; directory and file previews verify its scope statically. Upgrades preserve existing source and identity; older `app.json` projects require an author-owned source migration. +- Generate, preview, and upgrade data apps with data-app 0.79.0. New projects use the published starter with view-bound widgets and a shared `app.ts` declaration; directory and file previews verify its scope statically. Upgrades preserve existing source and identity; source changes for breaking SDK releases remain author-owned. - Raise the default `--connect-timeout` from 5 to 30 seconds, so queries that take a few seconds to start responding no longer time out. - Timeout errors now name the CLI flag that fired, explain that the limit is client-side (the request may still be running on the server, and slow networks can cause it), and say how to raise it. diff --git a/cli/bun.lock b/cli/bun.lock index fea442d..cf8b146 100644 --- a/cli/bun.lock +++ b/cli/bun.lock @@ -10,8 +10,8 @@ "yaml": "2.9.0", }, "devDependencies": { - "@altertable/data-app-examples": "0.78.0", - "@altertable/data-app-manifest": "0.78.0", + "@altertable/data-app-examples": "0.79.0", + "@altertable/data-app-manifest": "0.79.0", "@types/bun": "1.4.3", "eslint-plugin-no-relative-import-paths": "1.6.1", "knip": "6.32.2", @@ -25,9 +25,9 @@ }, }, "packages": { - "@altertable/data-app-examples": ["@altertable/data-app-examples@0.78.0", "", {}, "sha512-6mFLF0W+N/n1i448ZCJks3iytDN2e7RgnyYk9JOxpTHPgYeT7zvY30/GxeeOdS4N5nTr5paItoc6ZWxpoL6sjQ=="], + "@altertable/data-app-examples": ["@altertable/data-app-examples@0.79.0", "", {}, "sha512-zvOz2mQmV4gojUSlOcN0P2E9apJLpIjS0SY7xNKTFJtuvmbuusUgiqjLGKCqq8RPEye2GyqfUwNglprir8a22Q=="], - "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.78.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-uX7JmnPwbRstseMo80K98h5c5KIsnJKabCAPlueJ+P34rUvMdUFuc696hp/W1cNl81vDXd3eETNpoQnQLZ73XQ=="], + "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.79.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-7z9DTIuceocnwI88C5hLqhjPub0wzgLef7T9nVTk7bhC5ldh4r1rV1Tz3/4iS7dRpEsNq/XOtAUuW2+x+11khQ=="], "@babel/code-frame": ["@babel/code-frame@7.29.7", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.29.7", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw=="], diff --git a/cli/package.json b/cli/package.json index 6950b56..39c9981 100644 --- a/cli/package.json +++ b/cli/package.json @@ -55,8 +55,8 @@ "yaml": "2.9.0" }, "devDependencies": { - "@altertable/data-app-examples": "0.78.0", - "@altertable/data-app-manifest": "0.78.0", + "@altertable/data-app-examples": "0.79.0", + "@altertable/data-app-manifest": "0.79.0", "@types/bun": "1.4.3", "eslint-plugin-no-relative-import-paths": "1.6.1", "knip": "6.32.2", diff --git a/cli/scripts/smoke-data-app.ts b/cli/scripts/smoke-data-app.ts index 94bb216..f29f8b6 100644 --- a/cli/scripts/smoke-data-app.ts +++ b/cli/scripts/smoke-data-app.ts @@ -109,7 +109,7 @@ export async function smokeDataApp( throw new Error('File preview did not bundle the app.'); } const query = await fetch( - `${url}${singleFile ? '/api/query' : '/api/query/totalCost'}`, + `${url}${singleFile ? '/api/query' : '/api/query/sampleCountsByGroup'}`, { signal: AbortSignal.timeout(5000), method: 'POST', @@ -117,7 +117,7 @@ export async function smokeDataApp( body: JSON.stringify( singleFile ? { queryId: 'connection', limit: 1, params: {} } - : { limit: 1, params: { month: '2026-09', customerName: '' } } + : { limit: 1, params: { groupName: 'all' } } ), } ); @@ -126,7 +126,7 @@ export async function smokeDataApp( rows?: unknown[][]; data?: unknown; }; - if (result.rows?.[0]?.[0] !== (singleFile ? 1 : 1320000)) + if (result.rows?.[0]?.[0] !== (singleFile ? 1 : 'Alpha')) throw new Error('Preview did not return the lakehouse query result.'); } catch (error) { failure = error; @@ -204,7 +204,7 @@ export async function smokeDataApp( return new Response( statement === 'SELECT 1 AS connection_check' ? '{"query_id":"smoke"}\n[{"name":"connection_check","type":"INTEGER"}]\n[1]' - : '{"query_id":"smoke"}\n[{"name":"cost_cents","type":"BIGINT"},{"name":"customer_count","type":"BIGINT"}]\n[1320000,3]', + : '{"query_id":"smoke"}\n[{"name":"group_name","type":"VARCHAR"},{"name":"sample_count","type":"BIGINT"}]\n["Alpha",2000]', { headers: { 'content-type': 'application/x-ndjson' }, } diff --git a/cli/src/commands/app/create.test.ts b/cli/src/commands/app/create.test.ts index b64522d..e203fc3 100644 --- a/cli/src/commands/app/create.test.ts +++ b/cli/src/commands/app/create.test.ts @@ -112,7 +112,7 @@ describe('app create', () => { expect(paths).toContain('src/App.tsx'); expect(paths).toContain('.oxlintrc.json'); expect(readFileSync(join(directory, 'AGENTS.md'), 'utf8')).toContain( - 'https://github.com/altertable-ai/data-app/blob/v0.78.0/docs/app-authoring.md' + `https://github.com/altertable-ai/data-app/blob/v${recommendedDataAppVersion(dataAppPayload)}/docs/app-authoring.md` ); expect( paths.some(path => /tests|fixtures|node_modules|\.txt$/.test(path)) diff --git a/cli/src/commands/app/lib/distribution.test.ts b/cli/src/commands/app/lib/distribution.test.ts index 0b35fd5..6709b72 100644 --- a/cli/src/commands/app/lib/distribution.test.ts +++ b/cli/src/commands/app/lib/distribution.test.ts @@ -46,13 +46,11 @@ test('distribution embeds a deterministic starter with an exact package pin and title: identity.title, scope: identity.scope, }); - expect( - JSON.parse(files['package.json']!).dependencies['@altertable/data-app'] - ).toBe(recommendedDataAppVersion(dataAppPayload)); + const version = recommendedDataAppVersion(dataAppPayload); expect(JSON.parse(files['package.json']!).dependencies).toMatchObject({ - '@altertable/data-app': '0.78.0', - '@altertable/data-app-react': '0.78.0', - '@altertable/data-app-bun': '0.78.0', + '@altertable/data-app': version, + '@altertable/data-app-react': version, + '@altertable/data-app-bun': version, }); expect(files['src/main.tsx']).toContain("from '@altertable/data-app-react'"); expect(files['src/App.tsx']).toBe(payload.starter['src/App.tsx']); @@ -68,7 +66,7 @@ test('app-owned authoring links resolve within the generated files', async () => scope: { organization: 'Test', environment: 'test' }, }); expect(files['AGENTS.md']).toContain( - 'https://github.com/altertable-ai/data-app/blob/v0.78.0/docs/app-authoring.md' + `https://github.com/altertable-ai/data-app/blob/v${recommendedDataAppVersion(dataAppPayload)}/docs/app-authoring.md` ); for (const [name, content] of Object.entries(files)) { if (!name.endsWith('.md')) continue; diff --git a/cli/src/commands/app/upgrade.test.ts b/cli/src/commands/app/upgrade.test.ts index 9fb368a..25275dd 100644 --- a/cli/src/commands/app/upgrade.test.ts +++ b/cli/src/commands/app/upgrade.test.ts @@ -13,6 +13,7 @@ import { } from '@/commands/app/lib/package.ts'; import { loadDataAppPayload } from '@/commands/app/lib/payload.ts'; import { upgradeApp } from '@/commands/app/upgrade.ts'; +import { runCommandWithTestRuntime } from '@/test-utils/cli.ts'; const dataAppPayload = await loadDataAppPayload(); @@ -95,6 +96,17 @@ test('an exact current pin is a no-op', async () => { expect(await snapshot(directory)).toEqual(before); }); +test('upgrade reports an actionable error when the app lockfile is missing', async () => { + const directory = await fixture(); + await rm(join(directory, 'bun.lock')); + expect( + runCommandWithTestRuntime(['app', 'upgrade', '--dir', directory]) + ).rejects.toMatchObject({ + exitCode: 10, + message: expect.stringContaining('Cannot read a valid bun.lock'), + }); +}); + test('failed resolution restores the manifest and lockfile', async () => { const directory = await fixture(); await updateManifest(directory, pkg => { @@ -405,7 +417,18 @@ test('upgrades a published 0.77 app without replacing its identity or custom UI' }); } await install(); - expect(await upgradeApp(directory)).toBe(true); + const result = await runCommandWithTestRuntime([ + 'app', + 'upgrade', + '--dir', + directory, + ]); + expect(result.exitCode).toBe(0); + const output = JSON.parse(result.stdout.join('')); + expect(output).toMatchObject({ + upgraded: true, + runtimeVersion: recommendedDataAppVersion(dataAppPayload), + }); expect(await readFile(join(directory, 'app.ts'), 'utf8')).toBe(appSource); expect(await readFile(join(directory, 'src/App.tsx'), 'utf8')).toBe( customView @@ -413,4 +436,14 @@ test('upgrades a published 0.77 app without replacing its identity or custom UI' await install(true); const { checkAppProject } = await import('@/commands/app/lint.ts'); await checkAppProject(directory); + const current = await runCommandWithTestRuntime([ + 'app', + 'upgrade', + '--dir', + directory, + ]); + expect(JSON.parse(current.stdout.join(''))).toMatchObject({ + upgraded: false, + nextSteps: [], + }); }, 60_000); diff --git a/data-app/README.md b/data-app/README.md index 7ce0332..3a29228 100644 --- a/data-app/README.md +++ b/data-app/README.md @@ -67,17 +67,6 @@ bun install --cwd data-app/starter --lockfile-only Update the other lockfiles, then run setup and the verification below. Review and commit the lockfiles; never resolve `latest` during app creation. -## Upgrades - -`app upgrade` updates declared data-app dependencies and lockfiles to the CLI's tested version, -preserving source, identity, dependency placement, and unrelated packages. It does not downgrade -newer installations and restores the manifest and lockfile if resolution fails. - -SDK 0.78 uses a shared literal `app.ts` declaration, browser-run operations, and -`serveLocalApp({ app, page })`. Older `app.json` projects require an author-owned source migration -using their existing identity, queries, and UI. Upgrade never replaces their source with a demo. -Adapt the source using the installed SDK authoring recipe, run `app lint`, and restart previews. - ## Verify ```fish diff --git a/data-app/file-preview/bun.lock b/data-app/file-preview/bun.lock index 73bba62..21ab3e2 100644 --- a/data-app/file-preview/bun.lock +++ b/data-app/file-preview/bun.lock @@ -5,23 +5,23 @@ "": { "name": "data-app-file-preview", "dependencies": { - "@altertable/data-app": "0.78.0", - "@altertable/data-app-bun": "0.78.0", - "@altertable/data-app-manifest": "0.78.0", - "@altertable/data-app-react": "0.78.0", + "@altertable/data-app": "0.79.0", + "@altertable/data-app-bun": "0.79.0", + "@altertable/data-app-manifest": "0.79.0", + "@altertable/data-app-react": "0.79.0", "react": "19.3.1", "react-dom": "19.3.1", }, }, }, "packages": { - "@altertable/data-app": ["@altertable/data-app@0.78.0", "", { "dependencies": { "@internationalized/date": "3.12.4", "chrono-node": "2.10.3" } }, "sha512-oj+glu3jNiEwiTJu0Jd8pYe233ZOjK/xBMefxnahYJGBmaiDi0KostgOwZhFy7yuVfzftXlf5eWoLgeemYNHyA=="], + "@altertable/data-app": ["@altertable/data-app@0.79.0", "", { "dependencies": { "@internationalized/date": "3.12.4", "chrono-node": "2.10.3" } }, "sha512-ii9oIcN69/AikIBkfMnyMkDIpemyQ9iZzc4xwHKJpVsZvBOo9cORhni9Dba81eNUmHNPyPbBWygm1vLNPssBSw=="], - "@altertable/data-app-bun": ["@altertable/data-app-bun@0.78.0", "", { "dependencies": { "@altertable/data-app": "0.78.0", "@altertable/data-app-manifest": "0.78.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-blDoWq7CudLrtiEP7o8KxFoujyBM7ePZVmXocA6bpZ//YQ07CVyP2wLxSaRsdSgC+b4Lp29jzZT4BqvEiuUk7A=="], + "@altertable/data-app-bun": ["@altertable/data-app-bun@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@altertable/data-app-manifest": "0.79.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-cRJJ1ARn6fJG1MlpjBSf7xE/WeEoEe9Ra4EIBPPMJzNq8roYBdY6ugtpczGhzeA7KDUkqlmz6xr7guFCHjOz2A=="], - "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.78.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-uX7JmnPwbRstseMo80K98h5c5KIsnJKabCAPlueJ+P34rUvMdUFuc696hp/W1cNl81vDXd3eETNpoQnQLZ73XQ=="], + "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.79.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-7z9DTIuceocnwI88C5hLqhjPub0wzgLef7T9nVTk7bhC5ldh4r1rV1Tz3/4iS7dRpEsNq/XOtAUuW2+x+11khQ=="], - "@altertable/data-app-react": ["@altertable/data-app-react@0.78.0", "", { "dependencies": { "@altertable/data-app": "0.78.0", "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.107.1", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.73.0", "react-aria-components": "1.22.1", "recharts": "3.10.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-x6nugclGlg09trgJPz83WO1bPqx5mfR5rNR+pEJ1iFaEN+EU9bYpnqcQflkV+u1ImXXgpFmSN1O7a8ncasGM5g=="], + "@altertable/data-app-react": ["@altertable/data-app-react@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.107.1", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.73.0", "react-aria-components": "1.22.1", "recharts": "3.10.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-joX5dN3W+73NH4knKYrocI26rDpm2UMgUqhDW0xczKa4dXpDqh2vTMqYJvKT45oVKVPDa14x4+2zH/gHHiAg4g=="], "@altertable/lakehouse": ["@altertable/lakehouse@0.4.1", "", {}, "sha512-m7d15cWt+WUGW7lVw2KYGD+Se8MzO25G7SWSuFd+OasBxWmOJNa2IrgvOHGVEbnZ+kexTUy9NjAGQ69sG4V91w=="], diff --git a/data-app/file-preview/package.json b/data-app/file-preview/package.json index f80e37e..4f44c50 100644 --- a/data-app/file-preview/package.json +++ b/data-app/file-preview/package.json @@ -6,11 +6,11 @@ "dev": "data-app-preview" }, "dependencies": { - "@altertable/data-app": "0.78.0", - "@altertable/data-app-bun": "0.78.0", - "@altertable/data-app-react": "0.78.0", + "@altertable/data-app": "0.79.0", + "@altertable/data-app-bun": "0.79.0", + "@altertable/data-app-react": "0.79.0", "react": "19.3.1", "react-dom": "19.3.1", - "@altertable/data-app-manifest": "0.78.0" + "@altertable/data-app-manifest": "0.79.0" } } diff --git a/data-app/starter/bun.lock b/data-app/starter/bun.lock index 5a5375e..97c2e1e 100644 --- a/data-app/starter/bun.lock +++ b/data-app/starter/bun.lock @@ -5,9 +5,9 @@ "": { "name": "data-app-starter", "dependencies": { - "@altertable/data-app": "0.78.0", - "@altertable/data-app-bun": "0.78.0", - "@altertable/data-app-react": "0.78.0", + "@altertable/data-app": "0.79.0", + "@altertable/data-app-bun": "0.79.0", + "@altertable/data-app-react": "0.79.0", "react": "19.3.1", "react-dom": "19.3.1", }, @@ -23,13 +23,13 @@ }, }, "packages": { - "@altertable/data-app": ["@altertable/data-app@0.78.0", "", { "dependencies": { "@internationalized/date": "3.12.4", "chrono-node": "2.10.3" } }, "sha512-oj+glu3jNiEwiTJu0Jd8pYe233ZOjK/xBMefxnahYJGBmaiDi0KostgOwZhFy7yuVfzftXlf5eWoLgeemYNHyA=="], + "@altertable/data-app": ["@altertable/data-app@0.79.0", "", { "dependencies": { "@internationalized/date": "3.12.4", "chrono-node": "2.10.3" } }, "sha512-ii9oIcN69/AikIBkfMnyMkDIpemyQ9iZzc4xwHKJpVsZvBOo9cORhni9Dba81eNUmHNPyPbBWygm1vLNPssBSw=="], - "@altertable/data-app-bun": ["@altertable/data-app-bun@0.78.0", "", { "dependencies": { "@altertable/data-app": "0.78.0", "@altertable/data-app-manifest": "0.78.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-blDoWq7CudLrtiEP7o8KxFoujyBM7ePZVmXocA6bpZ//YQ07CVyP2wLxSaRsdSgC+b4Lp29jzZT4BqvEiuUk7A=="], + "@altertable/data-app-bun": ["@altertable/data-app-bun@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@altertable/data-app-manifest": "0.79.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-cRJJ1ARn6fJG1MlpjBSf7xE/WeEoEe9Ra4EIBPPMJzNq8roYBdY6ugtpczGhzeA7KDUkqlmz6xr7guFCHjOz2A=="], - "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.78.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-uX7JmnPwbRstseMo80K98h5c5KIsnJKabCAPlueJ+P34rUvMdUFuc696hp/W1cNl81vDXd3eETNpoQnQLZ73XQ=="], + "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.79.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-7z9DTIuceocnwI88C5hLqhjPub0wzgLef7T9nVTk7bhC5ldh4r1rV1Tz3/4iS7dRpEsNq/XOtAUuW2+x+11khQ=="], - "@altertable/data-app-react": ["@altertable/data-app-react@0.78.0", "", { "dependencies": { "@altertable/data-app": "0.78.0", "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.107.1", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.73.0", "react-aria-components": "1.22.1", "recharts": "3.10.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-x6nugclGlg09trgJPz83WO1bPqx5mfR5rNR+pEJ1iFaEN+EU9bYpnqcQflkV+u1ImXXgpFmSN1O7a8ncasGM5g=="], + "@altertable/data-app-react": ["@altertable/data-app-react@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.107.1", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.73.0", "react-aria-components": "1.22.1", "recharts": "3.10.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-joX5dN3W+73NH4knKYrocI26rDpm2UMgUqhDW0xczKa4dXpDqh2vTMqYJvKT45oVKVPDa14x4+2zH/gHHiAg4g=="], "@altertable/lakehouse": ["@altertable/lakehouse@0.4.1", "", {}, "sha512-m7d15cWt+WUGW7lVw2KYGD+Se8MzO25G7SWSuFd+OasBxWmOJNa2IrgvOHGVEbnZ+kexTUy9NjAGQ69sG4V91w=="], diff --git a/data-app/tests/bun.lock b/data-app/tests/bun.lock index 6c93eb6..d833d7b 100644 --- a/data-app/tests/bun.lock +++ b/data-app/tests/bun.lock @@ -5,8 +5,8 @@ "": { "name": "data-app-browser-tests", "dependencies": { - "@altertable/data-app": "0.78.0", - "@altertable/data-app-bun": "0.78.0", + "@altertable/data-app": "0.79.0", + "@altertable/data-app-bun": "0.79.0", }, "devDependencies": { "@playwright/test": "1.63.0", @@ -17,11 +17,11 @@ }, }, "packages": { - "@altertable/data-app": ["@altertable/data-app@0.78.0", "", { "dependencies": { "@internationalized/date": "3.12.4", "chrono-node": "2.10.3" } }, "sha512-oj+glu3jNiEwiTJu0Jd8pYe233ZOjK/xBMefxnahYJGBmaiDi0KostgOwZhFy7yuVfzftXlf5eWoLgeemYNHyA=="], + "@altertable/data-app": ["@altertable/data-app@0.79.0", "", { "dependencies": { "@internationalized/date": "3.12.4", "chrono-node": "2.10.3" } }, "sha512-ii9oIcN69/AikIBkfMnyMkDIpemyQ9iZzc4xwHKJpVsZvBOo9cORhni9Dba81eNUmHNPyPbBWygm1vLNPssBSw=="], - "@altertable/data-app-bun": ["@altertable/data-app-bun@0.78.0", "", { "dependencies": { "@altertable/data-app": "0.78.0", "@altertable/data-app-manifest": "0.78.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-blDoWq7CudLrtiEP7o8KxFoujyBM7ePZVmXocA6bpZ//YQ07CVyP2wLxSaRsdSgC+b4Lp29jzZT4BqvEiuUk7A=="], + "@altertable/data-app-bun": ["@altertable/data-app-bun@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@altertable/data-app-manifest": "0.79.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-cRJJ1ARn6fJG1MlpjBSf7xE/WeEoEe9Ra4EIBPPMJzNq8roYBdY6ugtpczGhzeA7KDUkqlmz6xr7guFCHjOz2A=="], - "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.78.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-uX7JmnPwbRstseMo80K98h5c5KIsnJKabCAPlueJ+P34rUvMdUFuc696hp/W1cNl81vDXd3eETNpoQnQLZ73XQ=="], + "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.79.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-7z9DTIuceocnwI88C5hLqhjPub0wzgLef7T9nVTk7bhC5ldh4r1rV1Tz3/4iS7dRpEsNq/XOtAUuW2+x+11khQ=="], "@altertable/lakehouse": ["@altertable/lakehouse@0.4.1", "", {}, "sha512-m7d15cWt+WUGW7lVw2KYGD+Se8MzO25G7SWSuFd+OasBxWmOJNa2IrgvOHGVEbnZ+kexTUy9NjAGQ69sG4V91w=="], diff --git a/data-app/tests/package.json b/data-app/tests/package.json index c30f144..7b99f8f 100644 --- a/data-app/tests/package.json +++ b/data-app/tests/package.json @@ -16,7 +16,7 @@ "typescript": "7.0.2" }, "dependencies": { - "@altertable/data-app": "0.78.0", - "@altertable/data-app-bun": "0.78.0" + "@altertable/data-app": "0.79.0", + "@altertable/data-app-bun": "0.79.0" } } diff --git a/data-app/tests/query-results.json b/data-app/tests/query-results.json index 017b797..cd01a69 100644 --- a/data-app/tests/query-results.json +++ b/data-app/tests/query-results.json @@ -1,403 +1,26 @@ { - "2026-09/all": { - "costBreakdown/service": { - "columns": [ - "member_name", - "cost_cents" - ], - "rows": [ - [ - "Compute", - 720000 - ], - [ - "Storage", - 480000 - ], - [ - "Networking", - 120000 - ], - [ - "Logging", - 0 - ] - ] - }, - "totalCost": { - "columns": [ - "cost_cents", - "customer_count" - ], - "rows": [ - [ - 1320000, - 3 - ] - ] - }, - "costsByCustomer": { - "columns": [ - "customer_name", - "cost_cents" - ], - "rows": [ - [ - "Atlas", - 420000 - ], - [ - "Beacon", - 210000 - ], - [ - "Cedar", - 90000 - ] - ] - }, - "costTrend": { - "columns": [ - "period_start", - "cost_cents" - ], - "rows": [ - [ - "2026-09-01", - 300000 - ], - [ - "2026-09-08", - 336000 - ], - [ - "2026-09-15", - 324000 - ], - [ - "2026-09-22", - 360000 - ] - ] - }, - "customerServiceMix": { - "columns": [ - "customer_name", - "service_name", - "cost_cents" - ], - "rows": [ - [ - "Atlas", - "Compute", - 420000 - ], - [ - "Atlas", - "Logging", - 0 - ], - [ - "Atlas", - "Networking", - 30000 - ], - [ - "Atlas", - "Storage", - 80000 - ], - [ - "Beacon", - "Compute", - 210000 - ], - [ - "Beacon", - "Logging", - 0 - ], - [ - "Beacon", - "Networking", - 60000 - ], - [ - "Beacon", - "Storage", - 280000 - ], - [ - "Cedar", - "Compute", - 90000 - ], - [ - "Cedar", - "Logging", - 0 - ], - [ - "Cedar", - "Networking", - 30000 - ], - [ - "Cedar", - "Storage", - 120000 - ] - ] - }, - "costBreakdown/customer": { - "columns": [ - "member_name", - "cost_cents" - ], - "rows": [ - [ - "Beacon", - 550000 - ], - [ - "Atlas", - 530000 - ], - [ - "Cedar", - 240000 - ] - ] + "all": { + "sampleCountsByGroup": { + "columns": ["group_name", "sample_count"], + "rows": [["Alpha", 2000], ["Beta", 450], ["Gamma", 0]] } }, - "2026-09/Atlas": { - "costBreakdown/service": { - "columns": [ - "member_name", - "cost_cents" - ], - "rows": [ - [ - "Compute", - 420000 - ], - [ - "Storage", - 80000 - ], - [ - "Networking", - 30000 - ], - [ - "Logging", - 0 - ] - ] - }, - "totalCost": { - "columns": [ - "cost_cents", - "customer_count" - ], - "rows": [ - [ - 530000, - 1 - ] - ] - }, - "costsByCustomer": { - "columns": [ - "customer_name", - "cost_cents" - ], - "rows": [ - [ - "Atlas", - 420000 - ] - ] - }, - "costTrend": { - "columns": [ - "period_start", - "cost_cents" - ], - "rows": [ - [ - "2026-09-01", - 111000 - ], - [ - "2026-09-08", - 148000 - ], - [ - "2026-09-15", - 117000 - ], - [ - "2026-09-22", - 154000 - ] - ] - }, - "customerServiceMix": { - "columns": [ - "customer_name", - "service_name", - "cost_cents" - ], - "rows": [ - [ - "Atlas", - "Compute", - 420000 - ], - [ - "Atlas", - "Logging", - 0 - ], - [ - "Atlas", - "Networking", - 30000 - ], - [ - "Atlas", - "Storage", - 80000 - ] - ] - }, - "costBreakdown/customer": { - "columns": [ - "member_name", - "cost_cents" - ], - "rows": [ - [ - "Atlas", - 530000 - ] - ] + "Alpha": { + "sampleCountsByGroup": { + "columns": ["group_name", "sample_count"], + "rows": [["Alpha", 2000]] } }, - "2026-08/Atlas": { - "costBreakdown/service": { - "columns": [ - "member_name", - "cost_cents" - ], - "rows": [ - [ - "Compute", - 380000 - ], - [ - "Storage", - 80000 - ], - [ - "Networking", - 20000 - ], - [ - "Logging", - 0 - ] - ] - }, - "totalCost": { - "columns": [ - "cost_cents", - "customer_count" - ], - "rows": [ - [ - 480000, - 1 - ] - ] - }, - "costsByCustomer": { - "columns": [ - "customer_name", - "cost_cents" - ], - "rows": [ - [ - "Atlas", - 380000 - ] - ] - }, - "costTrend": { - "columns": [ - "period_start", - "cost_cents" - ], - "rows": [ - [ - "2026-08-01", - 102000 - ], - [ - "2026-08-08", - 134000 - ], - [ - "2026-08-15", - 106000 - ], - [ - "2026-08-22", - 138000 - ] - ] - }, - "customerServiceMix": { - "columns": [ - "customer_name", - "service_name", - "cost_cents" - ], - "rows": [ - [ - "Atlas", - "Compute", - 380000 - ], - [ - "Atlas", - "Logging", - 0 - ], - [ - "Atlas", - "Networking", - 20000 - ], - [ - "Atlas", - "Storage", - 80000 - ] - ] - }, - "costBreakdown/customer": { - "columns": [ - "member_name", - "cost_cents" - ], - "rows": [ - [ - "Atlas", - 480000 - ] - ] + "Beta": { + "sampleCountsByGroup": { + "columns": ["group_name", "sample_count"], + "rows": [["Beta", 450]] + } + }, + "Gamma": { + "sampleCountsByGroup": { + "columns": ["group_name", "sample_count"], + "rows": [["Gamma", 0]] } } } diff --git a/data-app/tests/server.ts b/data-app/tests/server.ts index 3af0225..36cca6c 100644 --- a/data-app/tests/server.ts +++ b/data-app/tests/server.ts @@ -17,9 +17,10 @@ const lakehouse = Bun.serve({ if (request.headers.get('authorization') !== 'Bearer fixture-token') return new Response('Unauthorized', { status: 401 }); if (mode === 'failure') return new Response('Unavailable', { status: 503 }); - const { statement, params } = (await request.json()) as { + const { statement, params, limit } = (await request.json()) as { statement: string; params: Record; + limit: number; }; const query = Object.entries(dataApp.queries).find( ([, definition]) => definition.statement === statement @@ -30,12 +31,7 @@ const lakehouse = Bun.serve({ string, Record >; - const scenario = - scenarios[`${params.month}/${params.customerName || 'all'}`]; - const result = - scenario?.[ - query === 'costBreakdown' ? `${query}/${params.breakdown}` : query - ]; + const result = scenarios[params.groupName ?? 'all']?.[query]; if (!result) return new Response('Missing lakehouse fixture', { status: 400 }); return new Response( @@ -44,15 +40,12 @@ const lakehouse = Bun.serve({ JSON.stringify( result.columns.map(name => ({ name, - type: - name.endsWith('cents') || name.endsWith('count') - ? 'BIGINT' - : 'VARCHAR', + type: name.endsWith('count') ? 'BIGINT' : 'VARCHAR', })) ), ...(mode === 'empty' ? [] - : result.rows.map(row => JSON.stringify(row))), + : result.rows.slice(0, limit).map(row => JSON.stringify(row))), '', ].join('\n'), { headers: { 'content-type': 'application/x-ndjson' } } diff --git a/data-app/tests/starter.spec.ts b/data-app/tests/starter.spec.ts index a04f429..8185bcf 100644 --- a/data-app/tests/starter.spec.ts +++ b/data-app/tests/starter.spec.ts @@ -14,25 +14,21 @@ test('distributed example filters registered queries and supports inspection acr await expect( page.getByRole('heading', { name: 'CLI scaffold test', exact: true }) ).toBeVisible(); - const total = page.getByRole('region', { name: 'Total cost', exact: true }); - await expect(total.getByText('$13,200.00', { exact: true })).toBeVisible(); + const chart = page.getByLabel('Sample counts by group', { exact: true }); + await expect(chart).toBeVisible(); + await expect(chart).toContainText('Alpha'); + await expect(chart).toContainText('Beta'); await page - .getByRole('button', { name: 'All customers Customer', exact: true }) + .getByRole('button', { name: 'All groups Group', exact: true }) .click(); - await page.getByRole('option', { name: 'Atlas', exact: true }).click(); - await expect(total.getByText('$5,300.00', { exact: true })).toBeVisible(); - await page - .getByRole('button', { name: 'September 2026 Month', exact: true }) - .click(); - await page.getByRole('option', { name: 'August 2026', exact: true }).click(); - await expect(total.getByText('$4,800.00', { exact: true })).toBeVisible(); - await page - .getByRole('button', { name: 'Service Breakdown', exact: true }) - .click(); - await page.getByRole('option', { name: 'Customer', exact: true }).click(); - await expect( - page.getByLabel('Costs by customer', { exact: true }) - ).toBeVisible(); + await page.getByRole('option', { name: 'Gamma', exact: true }).click(); + await expect(chart).toContainText('Gamma'); + await expect(chart).not.toContainText('Alpha'); + await expect(page.getByText('No matching groups')).toHaveCount(0); + await page.getByRole('button', { name: 'Gamma Group', exact: true }).click(); + await page.getByRole('option', { name: 'Alpha', exact: true }).click(); + await expect(chart).toContainText('Alpha'); + await expect(chart).not.toContainText('Beta'); await page.screenshot({ path: testInfo.outputPath('starter-light.png'), fullPage: true, @@ -42,7 +38,7 @@ test('distributed example filters registered queries and supports inspection acr page.getByRole('button', { name: 'Switch to light theme' }) ).toBeVisible(); await expect( - page.getByRole('button', { name: 'August 2026 Month', exact: true }) + page.getByRole('button', { name: 'Alpha Group', exact: true }) ).toBeEnabled(); await page.screenshot({ animations: 'disabled', @@ -50,11 +46,11 @@ test('distributed example filters registered queries and supports inspection acr fullPage: true, }); await page - .getByRole('button', { name: 'Explore Total cost', exact: true }) + .getByRole('button', { name: 'Explore Samples by group', exact: true }) .click(); - await expect(page.getByRole('dialog')).toContainText('Allocated cost'); + await expect(page.getByRole('dialog')).toContainText('Sample count'); await page.getByRole('tab', { name: 'Queries', exact: true }).click(); - await expect(page.getByRole('dialog')).toContainText('totalCost'); + await expect(page.getByRole('dialog')).toContainText('sampleCountsByGroup'); expect( await page.evaluate( () => document.documentElement.scrollWidth <= innerWidth @@ -76,13 +72,14 @@ test('loading, empty, failure and recovery keep the example usable', async ({ await route.continue(); }); await page.goto('/'); - await expect(page.getByText('$13,200.00', { exact: true })).toHaveCount(0); + const chart = page.getByLabel('Sample counts by group', { exact: true }); + await expect(chart).toHaveCount(0); await page.screenshot({ path: testInfo.outputPath('starter-loading.png'), fullPage: true, }); release(); - await expect(page.getByText('$13,200.00', { exact: true })).toBeVisible(); + await expect(chart).toBeVisible(); await request.post(control, { data: 'failure' }); await page.reload(); await expect(page.getByRole('alert').first()).toBeVisible(); @@ -95,17 +92,11 @@ test('loading, empty, failure and recovery keep the example usable', async ({ .getByRole('button', { name: 'Retry', exact: true }) .first() .click(); - await expect(page.getByRole('alert')).toHaveCount(3); - for (let remaining = 3; remaining > 0; remaining--) { - await page - .getByRole('button', { name: 'Retry', exact: true }) - .first() - .click(); - await expect(page.getByRole('alert')).toHaveCount(remaining - 1); - } + await expect(page.getByRole('alert')).toHaveCount(0); + await expect(chart).toBeVisible(); await request.post(control, { data: 'empty' }); await page.reload(); - await expect(page.getByText('No allocations').first()).toBeVisible(); + await expect(page.getByText('No matching groups').first()).toBeVisible(); await page.screenshot({ path: testInfo.outputPath('starter-empty.png'), fullPage: true, @@ -115,31 +106,37 @@ test('loading, empty, failure and recovery keep the example usable', async ({ test('local transport only accepts registered queries and declared parameters', async ({ request, }) => { - const valid = await request.post('/api/query/totalCost', { - data: { limit: 1, params: { month: '2026-09', customerName: '' } }, + const valid = await request.post('/api/query/sampleCountsByGroup', { + data: { limit: 10, params: { groupName: 'all' } }, }); expect(valid.status()).toBe(200); - expect(await valid.json()).toMatchObject({ rows: [[1320000, 3]] }); + expect(await valid.json()).toMatchObject({ + rows: [ + ['Alpha', 2000], + ['Beta', 450], + ['Gamma', 0], + ], + }); expect( (await request.post('/api/query/missing', { data: { limit: 1 } })).status() ).toBe(404); expect( ( - await request.post('/api/query/totalCost', { + await request.post('/api/query/sampleCountsByGroup', { data: { statement: 'SELECT 1', limit: 1 }, }) ).status() ).toBe(400); expect( ( - await request.post('/api/query/totalCost', { + await request.post('/api/query/sampleCountsByGroup', { data: { limit: 1, params: { arbitrarySql: 'DROP TABLE x' } }, }) ).status() ).toBe(400); expect( ( - await request.post('/api/query/totalCost', { + await request.post('/api/query/sampleCountsByGroup', { headers: { origin: 'https://other.example' }, data: { limit: 1 }, })