@altertable/data-app-examples 0.74.0 → 0.76.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.
Files changed (52) hide show
  1. package/README.md +8 -4
  2. package/dist/index.js +38 -11
  3. package/dist/index.js.map +1 -1
  4. package/dist/types/index.d.ts +20 -0
  5. package/package.json +13 -1
  6. package/templates/starter-finding-data-app/LICENSE +21 -0
  7. package/templates/starter-finding-data-app/index.tsx +282 -0
  8. package/templates/starter-local-data-app/AGENTS.md +9 -9
  9. package/templates/starter-local-data-app/README.md +4 -4
  10. package/templates/starter-local-data-app/package.json +3 -3
  11. package/templates/starter-local-finding-data-app/.bun-version +1 -0
  12. package/templates/starter-local-finding-data-app/.node-version +1 -0
  13. package/templates/starter-local-finding-data-app/.oxfmtrc.json +11 -0
  14. package/templates/starter-local-finding-data-app/.oxlintrc.json +33 -0
  15. package/templates/starter-local-finding-data-app/AGENTS.md +18 -0
  16. package/templates/starter-local-finding-data-app/LICENSE +21 -0
  17. package/templates/starter-local-finding-data-app/README.md +43 -0
  18. package/templates/starter-local-finding-data-app/_gitignore +3 -0
  19. package/templates/starter-local-finding-data-app/app.ts +59 -0
  20. package/templates/starter-local-finding-data-app/bunfig.toml +2 -0
  21. package/templates/starter-local-finding-data-app/package.json +36 -0
  22. package/templates/starter-local-finding-data-app/src/App.tsx +165 -0
  23. package/templates/starter-local-finding-data-app/src/assets.d.ts +1 -0
  24. package/templates/starter-local-finding-data-app/src/data-context.ts +13 -0
  25. package/templates/starter-local-finding-data-app/src/favicon.svg +13 -0
  26. package/templates/starter-local-finding-data-app/src/index.html +14 -0
  27. package/templates/starter-local-finding-data-app/src/main.tsx +8 -0
  28. package/templates/starter-local-finding-data-app/src/operations.ts +50 -0
  29. package/templates/starter-local-finding-data-app/src/server.ts +7 -0
  30. package/templates/starter-local-finding-data-app/tsconfig.json +21 -0
  31. package/templates/starter-local-metric-data-app/.bun-version +1 -0
  32. package/templates/starter-local-metric-data-app/.node-version +1 -0
  33. package/templates/starter-local-metric-data-app/.oxfmtrc.json +11 -0
  34. package/templates/starter-local-metric-data-app/.oxlintrc.json +33 -0
  35. package/templates/starter-local-metric-data-app/AGENTS.md +18 -0
  36. package/templates/starter-local-metric-data-app/LICENSE +21 -0
  37. package/templates/starter-local-metric-data-app/README.md +43 -0
  38. package/templates/starter-local-metric-data-app/_gitignore +3 -0
  39. package/templates/starter-local-metric-data-app/app.ts +39 -0
  40. package/templates/starter-local-metric-data-app/bunfig.toml +2 -0
  41. package/templates/starter-local-metric-data-app/package.json +36 -0
  42. package/templates/starter-local-metric-data-app/src/App.tsx +124 -0
  43. package/templates/starter-local-metric-data-app/src/assets.d.ts +1 -0
  44. package/templates/starter-local-metric-data-app/src/data-context.ts +19 -0
  45. package/templates/starter-local-metric-data-app/src/favicon.svg +13 -0
  46. package/templates/starter-local-metric-data-app/src/index.html +14 -0
  47. package/templates/starter-local-metric-data-app/src/main.tsx +8 -0
  48. package/templates/starter-local-metric-data-app/src/operations.ts +50 -0
  49. package/templates/starter-local-metric-data-app/src/server.ts +7 -0
  50. package/templates/starter-local-metric-data-app/tsconfig.json +21 -0
  51. package/templates/starter-metric-data-app/LICENSE +21 -0
  52. package/templates/starter-metric-data-app/index.tsx +229 -0
@@ -0,0 +1,59 @@
1
+ import { defineDataApp } from '@altertable/data-app';
2
+ import {
3
+ dateTimeRangeVariable,
4
+ defineDateRangeContract,
5
+ } from '@altertable/data-app/contract';
6
+
7
+ export const dataApp = defineDataApp({
8
+ title: 'Sample finding',
9
+ description:
10
+ 'Fixture evidence; replace with the Finding and its supporting queries.',
11
+ scope: { organization: 'demo', environment: 'sample' },
12
+ appearance: { theme: 'system' },
13
+ queries: {
14
+ samples: {
15
+ projections: {
16
+ period_start: { type: 'string' },
17
+ member: { type: 'string' },
18
+ selected: { type: 'boolean' },
19
+ sample_count: { type: 'number' },
20
+ },
21
+ statement: `
22
+ SELECT strftime(date_trunc($grain, sample_date), '%Y-%m-%d') AS period_start,
23
+ CASE WHEN $breakdown = 'group' THEN group_name ELSE segment_name END AS member,
24
+ sample_date >= CAST($selected_start AS TIMESTAMP) AS selected,
25
+ SUM(sample_count) AS sample_count
26
+ FROM starter_demo.daily_samples
27
+ WHERE sample_date >= CAST($start AS TIMESTAMP) AND sample_date < CAST($end AS TIMESTAMP)
28
+ GROUP BY ALL ORDER BY period_start, member LIMIT $limit`,
29
+ params: {
30
+ start: { type: 'string', defaultValue: '2026-03-09T00:00:00Z' },
31
+ end: { type: 'string', defaultValue: '2026-03-16T00:00:00Z' },
32
+ selected_start: {
33
+ type: 'string',
34
+ defaultValue: '2026-03-09T00:00:00Z',
35
+ },
36
+ grain: { type: 'string', defaultValue: 'day' },
37
+ breakdown: { type: 'string', defaultValue: 'segment' },
38
+ limit: { type: 'number', defaultValue: 500 },
39
+ },
40
+ },
41
+ },
42
+ });
43
+ export const calendar = defineDateRangeContract({
44
+ minDate: '2026-01-05',
45
+ maxDate: '2026-03-29',
46
+ maxRangeDays: 28,
47
+ timeZone: 'UTC',
48
+ });
49
+ export const findingPeriod = {
50
+ from: new Date('2026-03-09T00:00:00Z'),
51
+ to: new Date('2026-03-16T00:00:00Z'),
52
+ };
53
+ export const period = dateTimeRangeVariable({
54
+ key: 'period',
55
+ contract: calendar,
56
+ allowComparison: true,
57
+ defaultValue: findingPeriod,
58
+ presets: [{ label: 'Finding period', range: findingPeriod }],
59
+ });
@@ -0,0 +1,2 @@
1
+ [install]
2
+ exact = true
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "data-app-finding-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
+ "lint:fix": "oxlint --type-aware --fix src"
18
+ },
19
+ "dependencies": {
20
+ "@altertable/data-app": "0.76.0",
21
+ "@altertable/data-app-bun": "0.76.0",
22
+ "@altertable/data-app-react": "0.76.0",
23
+ "react": "19.3.1",
24
+ "react-dom": "19.3.1"
25
+ },
26
+ "devDependencies": {
27
+ "@types/bun": "1.4.3",
28
+ "@types/react": "19.3.0",
29
+ "@types/react-dom": "19.3.0",
30
+ "oxfmt": "0.71.0",
31
+ "oxlint": "1.86.0",
32
+ "oxlint-tsgolint": "7.0.2003",
33
+ "typescript": "7.0.2"
34
+ },
35
+ "packageManager": "bun@1.4.4"
36
+ }
@@ -0,0 +1,165 @@
1
+ import {
2
+ choiceVariable,
3
+ createDataHooks,
4
+ DataApp,
5
+ DataSection,
6
+ MetricWidget,
7
+ Stack,
8
+ TableWidget,
9
+ VisualizationWidget,
10
+ } from '@altertable/data-app-react';
11
+ import { BarChart, ComposedChart } from '@altertable/data-app-react/ui';
12
+ import { createDataClient } from '@altertable/data-app/client';
13
+
14
+ import { sampleDataContext } from '#app/data-context.ts';
15
+ import type { operations } from '#app/operations.ts';
16
+ import { period } from '#config';
17
+ const { defineTimeView } =
18
+ createDataHooks(createDataClient<typeof operations>());
19
+ const samplesView = defineTimeView({
20
+ dataContext: sampleDataContext,
21
+ operation: 'samples',
22
+ time: period,
23
+ variables: {
24
+ grain: choiceVariable({
25
+ key: 'grain',
26
+ label: 'Grain',
27
+ defaultValue: 'day',
28
+ options: [
29
+ { id: 'day', label: 'Day' },
30
+ { id: 'week', label: 'Week' },
31
+ ],
32
+ presentation: { group: 'display', control: 'widget' },
33
+ }),
34
+ breakdown: choiceVariable({
35
+ key: 'breakdown',
36
+ label: 'Breakdown',
37
+ defaultValue: 'segment',
38
+ options: [
39
+ { id: 'segment', label: 'Segment' },
40
+ { id: 'group', label: 'Group' },
41
+ ],
42
+ presentation: { group: 'display', control: 'widget' },
43
+ }),
44
+ },
45
+ isEmpty: rows => rows.length === 0,
46
+ emptyFallback: {
47
+ title: 'No samples in this period',
48
+ description: 'No observations are available for this period.',
49
+ },
50
+ });
51
+ type SampleRow = { sampleCount: number; selected: boolean };
52
+ function total(rows: readonly SampleRow[]) {
53
+ return rows.reduce((sum, row) => sum + row.sampleCount, 0);
54
+ }
55
+ function totalsBy<Row extends SampleRow>(
56
+ rows: readonly Row[],
57
+ key: (row: Row) => string
58
+ ) {
59
+ const totals = new Map<string, number>();
60
+ for (const row of rows)
61
+ totals.set(key(row), (totals.get(key(row)) ?? 0) + row.sampleCount);
62
+ return [...totals].map(([id, sampleCount]) => ({ id, sampleCount }));
63
+ }
64
+ const count = { kind: 'count' } as const;
65
+ const totalSamples = samplesView.metric(
66
+ {
67
+ id: 'total-samples',
68
+ label: 'Samples',
69
+ glossaryId: 'sampleCount',
70
+ format: count,
71
+ },
72
+ (rows, input) => ({
73
+ current: total(rows.filter(row => row.selected)),
74
+ ...(input.period.comparison && {
75
+ previous: total(rows.filter(row => !row.selected)),
76
+ }),
77
+ })
78
+ );
79
+ const trend = samplesView.dataset({
80
+ name: 'Samples over time',
81
+ select: rows => totalsBy(rows, row => row.periodStart),
82
+ rowKey: row => row.id,
83
+ columns: {
84
+ id: { label: 'Period start', value: row => row.id },
85
+ sampleCount: { value: row => row.sampleCount, format: count },
86
+ },
87
+ evidence: { id: 'samples-over-time', glossaryIds: ['sampleCount'] },
88
+ });
89
+ const breakdown = samplesView.dataset({
90
+ name: 'Samples by member',
91
+ select: rows =>
92
+ totalsBy(
93
+ rows.filter(row => row.selected),
94
+ row => row.member
95
+ ),
96
+ rowKey: row => row.id,
97
+ columns: {
98
+ id: { label: 'Member', value: row => row.id },
99
+ sampleCount: { value: row => row.sampleCount, format: count },
100
+ },
101
+ evidence: { id: 'samples-by-member', glossaryIds: ['sampleCount'] },
102
+ });
103
+ const sampleRows = samplesView.dataset({
104
+ name: 'Samples',
105
+ select: rows => rows.filter(row => row.selected),
106
+ rowKey: row => `${row.periodStart}:${row.member}`,
107
+ columns: {
108
+ periodStart: { label: 'Period start', value: row => row.periodStart },
109
+ member: { label: 'Member', value: row => row.member },
110
+ sampleCount: { value: row => row.sampleCount, format: count },
111
+ },
112
+ evidence: { id: 'samples', glossaryIds: ['sampleCount'] },
113
+ });
114
+ // The Finding's text is shown above the app; keep content to charts and captions.
115
+ const sampleContent = samplesView.content(result => (
116
+ <Stack>
117
+ <MetricWidget metric={totalSamples} source={result} />
118
+ <VisualizationWidget
119
+ dataset={trend}
120
+ source={result}
121
+ title="Samples over time"
122
+ description="Includes the previous period when comparison is on."
123
+ breakdown={samplesView.breakdown('grain')}
124
+ >
125
+ {rows => (
126
+ <ComposedChart
127
+ ariaLabel="Samples over time"
128
+ data={rows}
129
+ valueFormat={count}
130
+ >
131
+ <ComposedChart.XAxis dataKey="id" />
132
+ <ComposedChart.YAxis />
133
+ <ComposedChart.Line dataKey="sampleCount" name="Samples" />
134
+ <ComposedChart.Tooltip />
135
+ </ComposedChart>
136
+ )}
137
+ </VisualizationWidget>
138
+ <VisualizationWidget
139
+ dataset={breakdown}
140
+ source={result}
141
+ title="Samples by member"
142
+ breakdown={samplesView.breakdown('breakdown')}
143
+ >
144
+ {rows => (
145
+ <BarChart
146
+ ariaLabel="Samples by member"
147
+ unit="samples"
148
+ items={rows.map(row => ({
149
+ ...row,
150
+ label: row.id,
151
+ value: row.sampleCount,
152
+ }))}
153
+ />
154
+ )}
155
+ </VisualizationWidget>
156
+ <TableWidget dataset={sampleRows} source={result} title="Samples" />
157
+ </Stack>
158
+ ));
159
+ export function App() {
160
+ return (
161
+ <DataApp view={samplesView} showToolbar={false}>
162
+ <DataSection content={sampleContent} />
163
+ </DataApp>
164
+ );
165
+ }
@@ -0,0 +1 @@
1
+ declare module '*.css';
@@ -0,0 +1,13 @@
1
+ import { createDataContext } from '@altertable/data-app-react';
2
+ const queryNames = { samples: 'samples' } as const;
3
+ export const sampleDataContext = createDataContext(queryNames)({
4
+ description:
5
+ 'Fictional daily samples from starter_demo.daily_samples. Replace this evidence with the actual Finding queries.',
6
+ glossary: {
7
+ sampleCount: {
8
+ term: 'Sample count',
9
+ definition: 'Fixture samples recorded per day, group, and segment.',
10
+ queryNames: [queryNames.samples],
11
+ },
12
+ },
13
+ });
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 51 44">
2
+ <style>
3
+ path { fill: #01050b; }
4
+ @media (prefers-color-scheme: dark) {
5
+ path { fill: #fff; }
6
+ }
7
+ </style>
8
+ <path
9
+ fill-rule="evenodd"
10
+ clip-rule="evenodd"
11
+ d="M40.3274 28.9788L35.9663 28.8378L34.9541 28.6881L18.1066 10.301L24.1073 0L26.8738 0.545413L41.5212 25.6848L40.3274 28.9788ZM20.5319 20.1112L18.1894 15.6731L14.6154 16.2904L0 41.378L0.894584 44H12.9453L20.5769 20.4134L20.5319 20.1112ZM44.9804 31.6253L20.3808 36.9197L17.5838 41.2974L19.9001 44H49.2036L51 41.9551L44.9804 31.6253Z"
12
+ />
13
+ </svg>
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <meta name="theme-color" content="#ffffff" />
7
+ <title>Altertable app</title>
8
+ <link rel="icon" href="./favicon.svg" type="image/svg+xml" />
9
+ <script type="module" src="./main.tsx"></script>
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ </body>
14
+ </html>
@@ -0,0 +1,8 @@
1
+ import { injectDataAppStyles, mountDataApp } from '@altertable/data-app-react';
2
+
3
+ import { App } from '#app/App.tsx';
4
+ import { dataApp } from '#config';
5
+
6
+ injectDataAppStyles();
7
+
8
+ mountDataApp({ app: dataApp, component: App });
@@ -0,0 +1,50 @@
1
+ import { parseCount } from '@altertable/data-app/contract';
2
+
3
+ import { dataApp, period } from '#config';
4
+ export const operations = {
5
+ samples: dataApp.defineOperation({
6
+ input: value => {
7
+ const {
8
+ period: selection,
9
+ grain,
10
+ breakdown,
11
+ } = (value ?? {}) as Record<string, unknown>;
12
+ if (grain !== 'day' && grain !== 'week')
13
+ throw new Error('Expected a day or week grain.');
14
+ if (breakdown !== 'segment' && breakdown !== 'group')
15
+ throw new Error('Expected a segment or group breakdown.');
16
+ return { period: period.parseInput(selection), grain, breakdown };
17
+ },
18
+ checks: [
19
+ {
20
+ period: period.input({
21
+ ...period.defaultValue,
22
+ comparison: 'previous',
23
+ }),
24
+ grain: 'day',
25
+ breakdown: 'segment',
26
+ },
27
+ {
28
+ period: period.input(period.defaultValue),
29
+ grain: 'week',
30
+ breakdown: 'group',
31
+ },
32
+ ],
33
+ policy: { maxQueryRows: 500, maxDurationMs: 15000 },
34
+ async run({ query }, { period: { range, comparison }, grain, breakdown }) {
35
+ const result = await query('samples', {
36
+ start: (comparison?.from ?? range.from).toISOString(),
37
+ end: range.to.toISOString(),
38
+ selected_start: range.from.toISOString(),
39
+ grain,
40
+ breakdown,
41
+ });
42
+ return result.rows.map(row => ({
43
+ periodStart: row.period_start,
44
+ member: row.member,
45
+ sampleCount: parseCount(row.sample_count),
46
+ selected: row.selected,
47
+ }));
48
+ },
49
+ }),
50
+ };
@@ -0,0 +1,7 @@
1
+ import { serveLocalApp } from '@altertable/data-app-bun';
2
+
3
+ import page from '#app/index.html';
4
+ import { operations } from '#app/operations.ts';
5
+ import { dataApp } from '#config';
6
+
7
+ serveLocalApp({ page, operations, title: dataApp.title });
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "Preserve",
5
+ "moduleResolution": "bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "resolveJsonModule": true,
8
+ "jsx": "react-jsx",
9
+ "strict": true,
10
+ "noUncheckedIndexedAccess": true,
11
+ "noEmit": true,
12
+ "skipLibCheck": true,
13
+ "types": ["bun"],
14
+ "noImplicitReturns": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "noImplicitOverride": true,
17
+ "allowUnreachableCode": false,
18
+ "noUncheckedSideEffectImports": true
19
+ },
20
+ "include": ["src", "app.ts"]
21
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "ignorePatterns": ["dist/**", "bun.lock"],
4
+ "singleQuote": true,
5
+ "trailingComma": "es5",
6
+ "arrowParens": "avoid",
7
+ "printWidth": 80,
8
+ "endOfLine": "lf",
9
+ "sortImports": true,
10
+ "sortPackageJson": false
11
+ }
@@ -0,0 +1,33 @@
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
+ }
@@ -0,0 +1,18 @@
1
+ # Build this local data app
2
+
3
+ Read `node_modules/@altertable/data-app/docs/app-authoring.md` and use this project
4
+ as the selected scaffold. If dependencies are unavailable, read the
5
+ [version-matched recipe](https://github.com/altertable-ai/data-app/blob/v0.76.0/docs/app-authoring.md). <!-- x-release-please-version -->
6
+
7
+ | Task | App-owned files |
8
+ | ------------------------------------------ | -------------------------------------------------------- |
9
+ | Define queries and inputs | `app.ts`, `src/operations.ts`, optional shared contracts |
10
+ | Compose app content and supported features | `src/App.tsx` |
11
+ | Bind definitions and source evidence | `src/data-context.ts` |
12
+ | Change identity and appearance | `app.ts` |
13
+ | Inject styles and mount React | `src/main.tsx` |
14
+ | Configure local serving | `src/server.ts` |
15
+
16
+ See [README.md](README.md) for setup and checks.
17
+
18
+ Keep reusable app-specific conventions here.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Altertable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Local metric data app starter
2
+
3
+ Use `node_modules/@altertable/data-app/docs/app-authoring.md` for this SDK version.
4
+ Otherwise, read the [version-matched authoring recipe](https://github.com/altertable-ai/data-app/blob/v0.76.0/docs/app-authoring.md). <!-- x-release-please-version -->
5
+ See [AGENTS.md](AGENTS.md) for app-owned files.
6
+
7
+ The example queries require the seeded sample data described in the
8
+ [local preview guide](https://github.com/altertable-ai/data-app/blob/v0.76.0/docs/local-data-apps.md#preview-the-use-case-starters). <!-- x-release-please-version -->
9
+ Use that mock for development, or replace the example queries with verified data
10
+ in your lakehouse. The starter does not install a mock or create demo tables.
11
+
12
+ ## Run the app
13
+
14
+ From the copied starter directory, install dependencies and set server-only
15
+ credentials before starting:
16
+
17
+ ```fish
18
+ bun install
19
+ set -gx ALTERTABLE_LAKEHOUSE_USERNAME your-username
20
+ read --silent --prompt-str 'Lakehouse password: ' ALTERTABLE_LAKEHOUSE_PASSWORD
21
+ set -gx ALTERTABLE_LAKEHOUSE_PASSWORD $ALTERTABLE_LAKEHOUSE_PASSWORD
22
+ bun run dev
23
+ ```
24
+
25
+ Open <http://127.0.0.1:25837>. Alternatively, configure
26
+ `ALTERTABLE_DATA_PROXY_URL` and `ALTERTABLE_DATA_PROXY_TOKEN` for an existing
27
+ CLI proxy. Missing credentials stop startup.
28
+
29
+ ## Build the app
30
+
31
+ Replace the fixture queries and example content with the evidence and content
32
+ specified by the app brief. Change identity, appearance, and queries in `app.ts`.
33
+
34
+ ```fish
35
+ bun run check
36
+ ```
37
+
38
+ `bun run check` includes the build, which writes browser assets to `dist/`. Hosting them requires an authorized
39
+ `/api/data` backend; the local adapter does not authenticate hosted viewers.
40
+
41
+ ## License
42
+
43
+ [MIT](LICENSE)
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ dist/
3
+ .env*
@@ -0,0 +1,39 @@
1
+ import { defineDataApp } from '@altertable/data-app';
2
+ export const dataApp = defineDataApp({
3
+ title: 'Sample metric',
4
+ description: 'Fixture counts by group; replace with the requested metric.',
5
+ scope: { organization: 'demo', environment: 'sample' },
6
+ appearance: { theme: 'system' },
7
+ queries: {
8
+ sampleCountsBySegment: {
9
+ projections: {
10
+ segment_name: { type: 'string' },
11
+ sample_count: { type: 'number' },
12
+ },
13
+ statement: `
14
+ SELECT segment_name, sample_count FROM SEMANTIC_VIEW(
15
+ starter_sample_counts DIMENSIONS samples.segment_name METRICS samples.sample_count
16
+ WHERE $groupName = '' OR samples.group_name = $groupName
17
+ ) ORDER BY segment_name LIMIT $limit`,
18
+ params: {
19
+ groupName: { type: 'string', defaultValue: '' },
20
+ limit: { type: 'number', defaultValue: 10 },
21
+ },
22
+ },
23
+ sampleCountsByGroup: {
24
+ projections: {
25
+ group_name: { type: 'string' },
26
+ sample_count: { type: 'number' },
27
+ },
28
+ statement: `
29
+ SELECT group_name, sample_count FROM SEMANTIC_VIEW(
30
+ starter_sample_counts DIMENSIONS samples.group_name METRICS samples.sample_count
31
+ WHERE $groupName = '' OR samples.group_name = $groupName
32
+ ) ORDER BY group_name LIMIT $limit`,
33
+ params: {
34
+ groupName: { type: 'string', defaultValue: '' },
35
+ limit: { type: 'number', defaultValue: 10 },
36
+ },
37
+ },
38
+ },
39
+ });
@@ -0,0 +1,2 @@
1
+ [install]
2
+ exact = true
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "data-app-metric-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
+ "lint:fix": "oxlint --type-aware --fix src"
18
+ },
19
+ "dependencies": {
20
+ "@altertable/data-app": "0.76.0",
21
+ "@altertable/data-app-bun": "0.76.0",
22
+ "@altertable/data-app-react": "0.76.0",
23
+ "react": "19.3.1",
24
+ "react-dom": "19.3.1"
25
+ },
26
+ "devDependencies": {
27
+ "@types/bun": "1.4.3",
28
+ "@types/react": "19.3.0",
29
+ "@types/react-dom": "19.3.0",
30
+ "oxfmt": "0.71.0",
31
+ "oxlint": "1.86.0",
32
+ "oxlint-tsgolint": "7.0.2003",
33
+ "typescript": "7.0.2"
34
+ },
35
+ "packageManager": "bun@1.4.4"
36
+ }