@altertable/data-app-examples 0.0.0-stage → 0.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/dist/index.js +50 -0
  4. package/dist/index.js.map +10 -0
  5. package/dist/types/index.d.ts +18 -0
  6. package/package.json +31 -4
  7. package/templates/starter-data-app/LICENSE +21 -0
  8. package/templates/starter-data-app/index.tsx +193 -0
  9. package/templates/starter-local-data-app/.bun-version +1 -0
  10. package/templates/starter-local-data-app/.node-version +1 -0
  11. package/templates/starter-local-data-app/.oxfmtrc.json +4 -0
  12. package/templates/starter-local-data-app/.oxlintrc.json +33 -0
  13. package/templates/starter-local-data-app/AGENTS.md +26 -0
  14. package/templates/starter-local-data-app/LICENSE +21 -0
  15. package/templates/starter-local-data-app/README.md +55 -0
  16. package/templates/starter-local-data-app/_gitignore +3 -0
  17. package/templates/starter-local-data-app/app.ts +28 -0
  18. package/templates/starter-local-data-app/bunfig.toml +2 -0
  19. package/templates/starter-local-data-app/package.json +35 -0
  20. package/templates/starter-local-data-app/src/App.tsx +8 -0
  21. package/templates/starter-local-data-app/src/assets.d.ts +1 -0
  22. package/templates/starter-local-data-app/src/data-context.ts +21 -0
  23. package/templates/starter-local-data-app/src/favicon.svg +13 -0
  24. package/templates/starter-local-data-app/src/index.html +14 -0
  25. package/templates/starter-local-data-app/src/main.tsx +7 -0
  26. package/templates/starter-local-data-app/src/operations.ts +6 -0
  27. package/templates/starter-local-data-app/src/server.ts +6 -0
  28. package/templates/starter-local-data-app/tsconfig.json +21 -0
package/LICENSE ADDED
@@ -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.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # @altertable/data-app-examples
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Canonical starter templates for Altertable data apps, shared by the CLI and
4
+ app authors. Templates use the published runtime packages and ship as editable
5
+ source files. This package has no runtime dependencies.
6
+
7
+ ## Use from scaffolding tools
8
+
9
+ ```ts
10
+ import { copyExample } from '@altertable/data-app-examples';
11
+
12
+ await copyExample('starter-local-data-app', destination);
13
+ ```
14
+
15
+ `dataAppExamples` supplies stable IDs, titles, descriptions, and execution modes
16
+ for tools that present a starter picker. Use the ID directly when the starter is
17
+ already known.
18
+ `copyExample()` copies the starter and restores `_gitignore` to `.gitignore`
19
+ (npm excludes `.gitignore` from published archives). The destination must not
20
+ exist. Keep project naming, destination checks, and dependency installation
21
+ in the consuming tool. Generated apps do not depend on this package.
22
+
23
+ `getExampleDirectory()` returns an absolute source path for tools that need to
24
+ inspect templates. Both functions reject unknown IDs.
25
+
26
+ ## Starters
27
+
28
+ | ID | Use |
29
+ | ------------------------ | ------------------------------------------------------------------------- |
30
+ | `starter-data-app` | [Hosted single-file app](templates/starter-data-app/index.tsx) |
31
+ | `starter-local-data-app` | [Local Bun and React project](templates/starter-local-data-app/README.md) |
32
+
33
+ Pin this package to an exact version in the CLI. Its version follows the runtime
34
+ packages, and the local starter pins compatible dependencies to the same release.
35
+ The SDK authoring guides and API reference ship in `@altertable/data-app`.
36
+
37
+ ## License
38
+
39
+ [MIT](LICENSE)
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ // packages/data-app-examples/src/index.ts
2
+ import { cp, mkdir, readdir, rename, rm } from "node:fs/promises";
3
+ import { join, relative, sep } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ var templateFileRenames = new Map([["_gitignore", ".gitignore"]]);
6
+ var dataAppExamples = [
7
+ {
8
+ id: "starter-data-app",
9
+ title: "Hosted data app",
10
+ description: "A single-file React app for hosted execution.",
11
+ mode: "hosted"
12
+ },
13
+ {
14
+ id: "starter-local-data-app",
15
+ title: "Local data app",
16
+ description: "A Bun and React project with server-side lakehouse access.",
17
+ mode: "local"
18
+ }
19
+ ];
20
+ function getExampleDirectory(id) {
21
+ const example = dataAppExamples.find((example) => example.id === id);
22
+ if (!example)
23
+ throw new Error(`Unknown data app example: ${id}`);
24
+ return fileURLToPath(new URL(`../templates/${example.id}/`, import.meta.url));
25
+ }
26
+ async function copyExample(id, destination) {
27
+ const source = getExampleDirectory(id);
28
+ await mkdir(destination);
29
+ try {
30
+ await cp(source, destination, {
31
+ recursive: true,
32
+ filter: (path) => relative(source, path).split(sep).every((part) => part !== "node_modules" && part !== "dist" && !part.startsWith(".env"))
33
+ });
34
+ for (const filename of await readdir(destination)) {
35
+ const target = templateFileRenames.get(filename);
36
+ if (target)
37
+ await rename(join(destination, filename), join(destination, target));
38
+ }
39
+ } catch (error) {
40
+ await rm(destination, { recursive: true, force: true });
41
+ throw error;
42
+ }
43
+ }
44
+ export {
45
+ copyExample,
46
+ dataAppExamples,
47
+ getExampleDirectory
48
+ };
49
+
50
+ //# debugId=94DD5381B73C22BD64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": [
5
+ "import { cp, mkdir, readdir, rename, rm } from 'node:fs/promises';\nimport { join, relative, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst templateFileRenames = new Map([['_gitignore', '.gitignore']]);\n\n/** Canonical starters available to scaffolding tools. IDs are stable across releases. */\nexport const dataAppExamples = [\n {\n id: 'starter-data-app',\n title: 'Hosted data app',\n description: 'A single-file React app for hosted execution.',\n mode: 'hosted',\n },\n {\n id: 'starter-local-data-app',\n title: 'Local data app',\n description: 'A Bun and React project with server-side lakehouse access.',\n mode: 'local',\n },\n] as const;\n\n/** Stable identifier for a canonical starter. */\nexport type DataAppExampleId = (typeof dataAppExamples)[number]['id'];\n\n/** Absolute source directory. Use copyExample() to restore npm-excluded filenames. */\nexport function getExampleDirectory(id: DataAppExampleId): string {\n const example = dataAppExamples.find(example => example.id === id);\n if (!example) throw new Error(`Unknown data app example: ${id}`);\n return fileURLToPath(new URL(`../templates/${example.id}/`, import.meta.url));\n}\n\n/** Copy a starter into a new directory; reject existing destinations. */\nexport async function copyExample(\n id: DataAppExampleId,\n destination: string\n): Promise<void> {\n const source = getExampleDirectory(id);\n await mkdir(destination);\n try {\n await cp(source, destination, {\n recursive: true,\n filter: path =>\n relative(source, path)\n .split(sep)\n .every(\n part =>\n part !== 'node_modules' &&\n part !== 'dist' &&\n !part.startsWith('.env')\n ),\n });\n for (const filename of await readdir(destination)) {\n const target = templateFileRenames.get(filename);\n if (target)\n await rename(join(destination, filename), join(destination, target));\n }\n } catch (error) {\n await rm(destination, { recursive: true, force: true });\n throw error;\n }\n}\n"
6
+ ],
7
+ "mappings": ";AAAA;AACA;AACA;AAEA,IAAM,sBAAsB,IAAI,IAAI,CAAC,CAAC,cAAc,YAAY,CAAC,CAAC;AAG3D,IAAM,kBAAkB;AAAA,EAC7B;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACR;AACF;AAMO,SAAS,mBAAmB,CAAC,IAA8B;AAAA,EAChE,MAAM,UAAU,gBAAgB,KAAK,aAAW,QAAQ,OAAO,EAAE;AAAA,EACjE,IAAI,CAAC;AAAA,IAAS,MAAM,IAAI,MAAM,6BAA6B,IAAI;AAAA,EAC/D,OAAO,cAAc,IAAI,IAAI,gBAAgB,QAAQ,OAAO,YAAY,GAAG,CAAC;AAAA;AAI9E,eAAsB,WAAW,CAC/B,IACA,aACe;AAAA,EACf,MAAM,SAAS,oBAAoB,EAAE;AAAA,EACrC,MAAM,MAAM,WAAW;AAAA,EACvB,IAAI;AAAA,IACF,MAAM,GAAG,QAAQ,aAAa;AAAA,MAC5B,WAAW;AAAA,MACX,QAAQ,UACN,SAAS,QAAQ,IAAI,EAClB,MAAM,GAAG,EACT,MACC,UACE,SAAS,kBACT,SAAS,UACT,CAAC,KAAK,WAAW,MAAM,CAC3B;AAAA,IACN,CAAC;AAAA,IACD,WAAW,YAAY,MAAM,QAAQ,WAAW,GAAG;AAAA,MACjD,MAAM,SAAS,oBAAoB,IAAI,QAAQ;AAAA,MAC/C,IAAI;AAAA,QACF,MAAM,OAAO,KAAK,aAAa,QAAQ,GAAG,KAAK,aAAa,MAAM,CAAC;AAAA,IACvE;AAAA,IACA,OAAO,OAAO;AAAA,IACd,MAAM,GAAG,aAAa,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IACtD,MAAM;AAAA;AAAA;",
8
+ "debugId": "94DD5381B73C22BD64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,18 @@
1
+ /** Canonical starters available to scaffolding tools. IDs are stable across releases. */
2
+ export declare const dataAppExamples: readonly [{
3
+ readonly id: 'starter-data-app';
4
+ readonly title: 'Hosted data app';
5
+ readonly description: 'A single-file React app for hosted execution.';
6
+ readonly mode: 'hosted';
7
+ }, {
8
+ readonly id: 'starter-local-data-app';
9
+ readonly title: 'Local data app';
10
+ readonly description: 'A Bun and React project with server-side lakehouse access.';
11
+ readonly mode: 'local';
12
+ }];
13
+ /** Stable identifier for a canonical starter. */
14
+ export type DataAppExampleId = (typeof dataAppExamples)[number]['id'];
15
+ /** Absolute source directory. Use copyExample() to restore npm-excluded filenames. */
16
+ export declare function getExampleDirectory(id: DataAppExampleId): string;
17
+ /** Copy a starter into a new directory; reject existing destinations. */
18
+ export declare function copyExample(id: DataAppExampleId, destination: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@altertable/data-app-examples",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.72.0",
4
+ "description": "Canonical starter templates for Altertable data apps.",
5
+ "license": "MIT",
6
+ "author": "Altertable",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/altertable-ai/data-app.git",
10
+ "directory": "packages/data-app-examples"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "templates",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "type": "module",
19
+ "sideEffects": false,
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/types/index.d.ts",
23
+ "import": "./dist/index.js"
24
+ }
25
+ },
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "registry": "https://registry.npmjs.org"
29
+ },
30
+ "scripts": {
31
+ "build": "bun ../../scripts/build.ts data-app-examples"
32
+ }
33
+ }
@@ -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,193 @@
1
+ import { formatMetric } from '@altertable/data-app/format';
2
+ import { createDataClient } from '@altertable/data-app/client';
3
+ import { defineDataApp } from '@altertable/data-app';
4
+ import { parseCount } from '@altertable/data-app/contract';
5
+ import {
6
+ createDataContext,
7
+ createDataHooks,
8
+ DataApp,
9
+ DataSection,
10
+ DataValue,
11
+ TableWidget,
12
+ Grid,
13
+ Stack,
14
+ TextContent,
15
+ injectDataAppStyles,
16
+ mountDataApp,
17
+ MetricWidget,
18
+ searchVariable,
19
+ } from '@altertable/data-app-react';
20
+
21
+ const dataApp = defineDataApp({
22
+ title: 'Sample counts',
23
+ description: 'Explore sample counts by group.',
24
+ scope: { organization: 'demo', environment: 'sample' },
25
+ appearance: { theme: 'system' },
26
+ queries: {
27
+ sampleCountsByGroup: {
28
+ projections: {
29
+ group_name: { type: 'string' },
30
+ sample_count: { type: 'number' },
31
+ },
32
+ statement: `
33
+ WITH sample_counts(group_name, sample_count) AS (VALUES ('Alpha', 2200000), ('Beta', 0))
34
+ SELECT group_name, sample_count FROM sample_counts
35
+ WHERE $groupName = '' OR group_name = $groupName
36
+ ORDER BY group_name LIMIT $limit`,
37
+ params: {
38
+ groupName: { type: 'string', defaultValue: '' },
39
+ limit: { type: 'number', defaultValue: 10 },
40
+ },
41
+ },
42
+ },
43
+ });
44
+ function parseSampleCountFilter(value: unknown) {
45
+ if (
46
+ !value ||
47
+ typeof value !== 'object' ||
48
+ !('groupName' in value) ||
49
+ typeof value.groupName !== 'string' ||
50
+ value.groupName.length > 40
51
+ )
52
+ throw new Error('Expected a group name of at most 40 characters.');
53
+ return { groupName: value.groupName };
54
+ }
55
+ const operations = {
56
+ sampleCountsByGroup: dataApp.defineOperation({
57
+ input: parseSampleCountFilter,
58
+ checks: [
59
+ { groupName: '' },
60
+ { groupName: 'Alpha' },
61
+ { groupName: 'missing' },
62
+ ],
63
+ policy: { maxQueryRows: 10, maxDurationMs: 15000 },
64
+ async run({ query }, { groupName }) {
65
+ const queryResult = await query('sampleCountsByGroup', { groupName });
66
+ return queryResult.rows.map(row => ({
67
+ groupName: row.group_name,
68
+ sampleCount: parseCount(row.sample_count),
69
+ }));
70
+ },
71
+ }),
72
+ };
73
+ const queryNames = operations.sampleCountsByGroup.queryNames;
74
+ const sampleDataContext = createDataContext(queryNames)({
75
+ description:
76
+ 'Two SQL VALUES rows demonstrate the host query path. Replace them with inspected source data before publishing findings.',
77
+ glossary: {
78
+ sampleCount: {
79
+ term: 'Sample count',
80
+ definition:
81
+ 'A fixture value: Alpha is 2,200,000 and Beta is a measured zero.',
82
+ queryNames: [queryNames.sampleCountsByGroup],
83
+ },
84
+ },
85
+ });
86
+ const { defineDataView } = createDataHooks(createDataClient({ operations }));
87
+ const sampleCountsView = defineDataView({
88
+ dataContext: sampleDataContext,
89
+ operation: 'sampleCountsByGroup',
90
+ variables: {
91
+ groupName: searchVariable({
92
+ key: 'group',
93
+ label: 'Group',
94
+ defaultValue: '',
95
+ }),
96
+ },
97
+ describeInput: ({ groupName }) =>
98
+ groupName ? `group ${groupName}` : 'all groups',
99
+ isEmpty: sampleCounts => sampleCounts.length === 0,
100
+ emptyFallback: {
101
+ title: 'No matching groups',
102
+ description: 'Try Alpha, Beta, or clear the group filter.',
103
+ },
104
+ });
105
+ const sampleCounts = sampleCountsView.dataset({
106
+ name: 'Sample counts',
107
+ select: rows => rows,
108
+ rowKey: row => row.groupName,
109
+ columns: {
110
+ groupName: { label: 'Group', value: row => row.groupName },
111
+ sampleCount: { value: row => row.sampleCount, format: { kind: 'count' } },
112
+ },
113
+ evidence: {
114
+ id: 'counts-by-group',
115
+ glossaryIds: ['sampleCount'],
116
+ },
117
+ });
118
+ const totalSamples = sampleCountsView.metric(
119
+ {
120
+ id: 'total-samples',
121
+ glossaryId: 'sampleCount',
122
+ label: 'Total samples',
123
+ format: { kind: 'count', compact: true },
124
+ },
125
+ rows => ({ current: rows.reduce((sum, row) => sum + row.sampleCount, 0) })
126
+ );
127
+ const sampleContent = sampleCountsView.content(result => (
128
+ <Stack aria-label="Sample results">
129
+ <TextContent>
130
+ <p>
131
+ Showing <DataValue scope={result.scope} />
132
+ </p>
133
+ </TextContent>
134
+ <Grid columns={2}>
135
+ <MetricWidget
136
+ metric={totalSamples}
137
+ source={result}
138
+ description="Sum of the fixture counts in the selected groups."
139
+ />
140
+ <TableWidget
141
+ dataset={sampleCounts}
142
+ source={result}
143
+ title="Counts by group"
144
+ description="Alpha and Beta demonstrate measured values, including zero."
145
+ pagination={false}
146
+ />
147
+ </Grid>
148
+ </Stack>
149
+ ));
150
+ function App() {
151
+ return (
152
+ <DataApp
153
+ view={sampleCountsView}
154
+ datasets={[sampleCounts]}
155
+ story={snapshot => {
156
+ const total = totalSamples.read(snapshot);
157
+ const scope = sampleCountsView.scope(snapshot);
158
+ return [
159
+ {
160
+ id: 'total-samples',
161
+ headline: `Total samples: ${formatMetric(total.value.current, totalSamples.definition.format)}`,
162
+ context: `Demonstration values for ${scope}.`,
163
+ visual: <MetricWidget metric={totalSamples} source={snapshot} />,
164
+ visualKind: 'metric',
165
+ evidence: totalSamples,
166
+ },
167
+ {
168
+ id: 'counts-by-group',
169
+ headline: 'Counts by group',
170
+ context: `Demonstration values for ${scope}.`,
171
+ visual: (
172
+ <TableWidget
173
+ dataset={sampleCounts}
174
+ source={snapshot}
175
+ pagination={false}
176
+ />
177
+ ),
178
+ evidence: sampleCounts,
179
+ },
180
+ ];
181
+ }}
182
+ >
183
+ <Stack>
184
+ <TextContent>
185
+ <h2>Sample counts</h2>
186
+ </TextContent>
187
+ <DataSection content={sampleContent} />
188
+ </Stack>
189
+ </DataApp>
190
+ );
191
+ }
192
+ injectDataAppStyles();
193
+ mountDataApp({ app: dataApp, component: App });
@@ -0,0 +1 @@
1
+ 24.18.0
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "ignorePatterns": ["dist/**", "bun.lock"]
4
+ }
@@ -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,26 @@
1
+ # Build this local data app
2
+
3
+ If dependencies are installed, read `node_modules/@altertable/data-app/AGENTS.md`
4
+ first. Otherwise, read the [version-matched SDK instructions](https://github.com/altertable-ai/data-app/blob/v0.72.0/AGENTS.md). <!-- x-release-please-version -->
5
+ Then use the app files below. Browse the latest
6
+ [SDK instructions](https://github.com/altertable-ai/data-app/blob/main/AGENTS.md) on GitHub.
7
+
8
+ | Task | App-owned files |
9
+ | ---------------------------------------- | -------------------------------------------------------- |
10
+ | Define queries and inputs | `app.ts`, `src/operations.ts`, optional shared contracts |
11
+ | Build the exploration, export, and story | `src/App.tsx` |
12
+ | Bind definitions and source evidence | `src/data-context.ts` |
13
+ | Change identity and appearance | `app.ts` |
14
+ | Inject styles and mount React | `src/main.tsx` |
15
+ | Configure local serving | `src/server.ts` |
16
+
17
+ See [README.md](README.md) for setup and checks.
18
+
19
+ ## Focused guidance
20
+
21
+ Read the SDK's `docs/app-authoring.md` before changing the app, and search its
22
+ `REFERENCE.md` for props and signatures. Use the installed package when available;
23
+ otherwise follow these files in the same version tag as the instructions above. Follow their task routes for views, variables, widgets, evidence,
24
+ and stories/export. Prefer generated controls and bound readings; keep static
25
+ context visible during requests. Update this app's instructions when a reusable
26
+ app-specific convention changes. Package internals remain dependencies.
@@ -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,55 @@
1
+ # Local data app starter
2
+
3
+ If dependencies are installed, use
4
+ `node_modules/@altertable/data-app/docs/local-data-apps.md` for this app's SDK version.
5
+ Otherwise, read the [version-matched local authoring guide](https://github.com/altertable-ai/data-app/blob/v0.72.0/docs/local-data-apps.md). <!-- x-release-please-version -->
6
+ Browse the latest [local authoring guide](https://github.com/altertable-ai/data-app/blob/main/docs/local-data-apps.md)
7
+ on GitHub.
8
+ See [AGENTS.md](AGENTS.md) for app-owned files.
9
+
10
+ A Bun and React starter for Altertable data apps using the published packages.
11
+ It starts with a lakehouse connectivity check. Replace that check with bounded
12
+ operations and views built from inspected data before sharing an analysis.
13
+
14
+ ## Usage
15
+
16
+ ### Run your app
17
+
18
+ From the copied starter directory:
19
+
20
+ ```fish
21
+ bun install
22
+ bun run dev
23
+ ```
24
+
25
+ Open <http://127.0.0.1:25837>. Missing credentials show the connection error state;
26
+ the page still runs. Set server-only credentials before starting the server:
27
+
28
+ ```fish
29
+ set -gx ALTERTABLE_LAKEHOUSE_USERNAME your-username
30
+ read --silent --prompt-str 'Lakehouse password: ' ALTERTABLE_LAKEHOUSE_PASSWORD
31
+ set -gx ALTERTABLE_LAKEHOUSE_PASSWORD $ALTERTABLE_LAKEHOUSE_PASSWORD
32
+ bun run dev
33
+ ```
34
+
35
+ Alternatively, supply `ALTERTABLE_DATA_PROXY_URL` and
36
+ `ALTERTABLE_DATA_PROXY_TOKEN` for an existing CLI proxy. These values must stay
37
+ on the server. This local adapter does not authorize hosted viewers.
38
+
39
+ ### Make it your app
40
+
41
+ This starter declares the published base, React, and Bun packages. Run `bun install` to install those packages from npm.
42
+
43
+ ```fish
44
+ bun run check
45
+ ```
46
+
47
+ Edit the `defineDataApp()` declaration in `app.ts` for identity, appearance,
48
+ and queries.
49
+
50
+ `bun run build` typechecks the app, then bundles the browser page into `dist/`. That browser artifact
51
+ still needs an authorized `/api/data` backend when hosted.
52
+
53
+ ## License
54
+
55
+ [MIT](LICENSE)
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ dist/
3
+ .env*
@@ -0,0 +1,28 @@
1
+ import { defineDataApp } from "@altertable/data-app";
2
+
3
+ export const dataApp = defineDataApp({
4
+ title: "Getting started",
5
+ description: "Check your lakehouse connection, then build an exploration.",
6
+ scope: {
7
+ organization: "Your organization",
8
+ environment: "your environment",
9
+ },
10
+ appearance: {
11
+ theme: "light",
12
+ baseColor: "neutral",
13
+ density: "comfortable",
14
+ cornerRadius: "medium",
15
+ elevation: "subtle",
16
+ typography: {
17
+ body: "system",
18
+ heading: "system",
19
+ },
20
+ },
21
+ queries: {
22
+ connection: {
23
+ projections: { connection_check: { type: "number" } },
24
+ statement: "SELECT 1 AS connection_check",
25
+ params: {},
26
+ },
27
+ },
28
+ });
@@ -0,0 +1,2 @@
1
+ [install]
2
+ exact = true
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "data-app-starter",
3
+ "private": true,
4
+ "type": "module",
5
+ "imports": {
6
+ "#app/*": "./src/*",
7
+ "#config": "./app.ts"
8
+ },
9
+ "scripts": {
10
+ "typecheck": "tsc --noEmit",
11
+ "lint": "oxlint --type-aware src",
12
+ "format": "oxfmt src app.ts",
13
+ "format:check": "oxfmt --check src app.ts",
14
+ "dev": "bun --hot src/server.ts",
15
+ "build": "bun run typecheck && bun build src/index.html --outdir=dist --production",
16
+ "check": "bun run lint && bun run format:check && bun run build"
17
+ },
18
+ "dependencies": {
19
+ "@altertable/data-app": "0.72.0",
20
+ "@altertable/data-app-bun": "0.72.0",
21
+ "@altertable/data-app-react": "0.72.0",
22
+ "react": "19.3.0",
23
+ "react-dom": "19.3.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/bun": "1.4.2",
27
+ "@types/react": "19.3.0",
28
+ "@types/react-dom": "19.3.0",
29
+ "oxfmt": "0.70.0",
30
+ "oxlint": "1.85.0",
31
+ "oxlint-tsgolint": "7.0.2003",
32
+ "typescript": "7.0.2"
33
+ },
34
+ "packageManager": "bun@1.4.2"
35
+ }
@@ -0,0 +1,8 @@
1
+ import { GettingStarted } from "@altertable/data-app-react/ui";
2
+ import { dataContext } from "#app/data-context.ts";
3
+
4
+ /** Connectivity-only screen. Investigate the requested question, then replace this with a view
5
+ * that leads with a supported finding and explores the useful angles behind it. */
6
+ export function App() {
7
+ return <GettingStarted dataContext={dataContext} />;
8
+ }
@@ -0,0 +1 @@
1
+ declare module "*.css";
@@ -0,0 +1,21 @@
1
+ import { createDataContext } from "@altertable/data-app-react";
2
+ import { dataApp } from "#config";
3
+
4
+ const connectionQueryNames = { connection: "connection" } satisfies Record<
5
+ string,
6
+ keyof typeof dataApp.queries
7
+ >;
8
+
9
+ /** Setup context only. Replace it with the exploration's scope, exact definitions, limitations,
10
+ * and query evidence after inspecting the source data. */
11
+ export const dataContext = createDataContext(connectionQueryNames)({
12
+ description:
13
+ "This starter runs a lightweight query to verify that the selected lakehouse profile can execute SQL. It does not check access to individual datasets. Replace the check with a query that answers a real question before sharing the app.",
14
+ glossary: {
15
+ connectionVerified: {
16
+ term: "Connected",
17
+ definition: "The latest connection-check query completed successfully.",
18
+ queryNames: [connectionQueryNames.connection],
19
+ },
20
+ },
21
+ });
@@ -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,7 @@
1
+ import { injectDataAppStyles, mountDataApp } from "@altertable/data-app-react";
2
+ import { App } from "#app/App.tsx";
3
+ import { dataApp as app } from "#config";
4
+
5
+ injectDataAppStyles();
6
+
7
+ mountDataApp({ app, component: App });
@@ -0,0 +1,6 @@
1
+ import { dataApp } from "#config";
2
+ import { connectionCheck } from "@altertable/data-app/contract";
3
+
4
+ /** Connectivity probe only: its successful query supplies no analytical result. Replace it with
5
+ * bounded, validated operations that cover the questions the finished app will answer. */
6
+ export const operations = { connection: connectionCheck(dataApp.queries) };
@@ -0,0 +1,6 @@
1
+ import page from "#app/index.html";
2
+ import { serveLocalApp } from "@altertable/data-app-bun";
3
+ import { operations } from "#app/operations.ts";
4
+ import { dataApp as app } from "#config";
5
+
6
+ serveLocalApp({ page, operations, title: app.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
+ }