@altertable/data-app-examples 0.0.0-stage → 0.73.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/LICENSE +21 -0
- package/README.md +29 -2
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +21 -0
- package/package.json +32 -4
- package/templates/starter-data-app/LICENSE +21 -0
- package/templates/starter-data-app/index.tsx +193 -0
- package/templates/starter-local-data-app/.bun-version +1 -0
- package/templates/starter-local-data-app/.node-version +1 -0
- package/templates/starter-local-data-app/.oxfmtrc.json +11 -0
- package/templates/starter-local-data-app/.oxlintrc.json +33 -0
- package/templates/starter-local-data-app/AGENTS.md +18 -0
- package/templates/starter-local-data-app/LICENSE +21 -0
- package/templates/starter-local-data-app/README.md +38 -0
- package/templates/starter-local-data-app/_gitignore +3 -0
- package/templates/starter-local-data-app/app.ts +28 -0
- package/templates/starter-local-data-app/bunfig.toml +2 -0
- package/templates/starter-local-data-app/package.json +36 -0
- package/templates/starter-local-data-app/src/App.tsx +9 -0
- package/templates/starter-local-data-app/src/assets.d.ts +1 -0
- package/templates/starter-local-data-app/src/data-context.ts +22 -0
- package/templates/starter-local-data-app/src/favicon.svg +13 -0
- package/templates/starter-local-data-app/src/index.html +14 -0
- package/templates/starter-local-data-app/src/main.tsx +8 -0
- package/templates/starter-local-data-app/src/operations.ts +7 -0
- package/templates/starter-local-data-app/src/server.ts +7 -0
- 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,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @altertable/data-app-examples
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Editable starter templates for app authors and scaffolding tools.
|
|
4
|
+
|
|
5
|
+
## Use from scaffolding tools
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { copyExample } from '@altertable/data-app-examples';
|
|
9
|
+
|
|
10
|
+
await copyExample('starter-local-data-app', destination);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Use `dataAppExamples` for a starter picker and `getExampleDirectory()` to inspect
|
|
14
|
+
a template. `copyExample()` requires a new destination and restores `.gitignore`.
|
|
15
|
+
The caller owns naming and dependency installation; generated apps do not depend
|
|
16
|
+
on this package.
|
|
17
|
+
|
|
18
|
+
## Starters
|
|
19
|
+
|
|
20
|
+
| ID | Use |
|
|
21
|
+
| ------------------------ | ------------------------------------------------------------------------- |
|
|
22
|
+
| `starter-data-app` | [Hosted single-file app](templates/starter-data-app/index.tsx) |
|
|
23
|
+
| `starter-local-data-app` | [Local Bun and React project](templates/starter-local-data-app/README.md) |
|
|
24
|
+
|
|
25
|
+
Pin to the same exact version as `@altertable/data-app`. Authoring guides and
|
|
26
|
+
API reference ship in that base package.
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
[MIT](LICENSE)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { cp, mkdir, readdir, rename, rm } from "node:fs/promises";
|
|
2
|
+
import { join, relative, sep } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const templateFileRenames = /* @__PURE__ */ new Map([["_gitignore", ".gitignore"]]);
|
|
6
|
+
/** Canonical starters available to scaffolding tools. IDs are stable across releases. */
|
|
7
|
+
const dataAppExamples = [{
|
|
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
|
+
id: "starter-local-data-app",
|
|
14
|
+
title: "Local data app",
|
|
15
|
+
description: "A Bun and React project with server-side lakehouse access.",
|
|
16
|
+
mode: "local"
|
|
17
|
+
}];
|
|
18
|
+
/** Absolute source directory. Use copyExample() to restore npm-excluded filenames. */
|
|
19
|
+
function getExampleDirectory(id) {
|
|
20
|
+
const example = dataAppExamples.find((example) => example.id === id);
|
|
21
|
+
if (!example) throw new Error(`Unknown data app example: ${id}`);
|
|
22
|
+
return fileURLToPath(new URL(`../templates/${example.id}/`, import.meta.url));
|
|
23
|
+
}
|
|
24
|
+
/** Copy a starter into a new directory; reject existing destinations. */
|
|
25
|
+
async function copyExample(id, destination) {
|
|
26
|
+
const source = getExampleDirectory(id);
|
|
27
|
+
await mkdir(destination);
|
|
28
|
+
try {
|
|
29
|
+
await cp(source, destination, {
|
|
30
|
+
recursive: true,
|
|
31
|
+
filter: (path) => relative(source, path).split(sep).every((part) => part !== "node_modules" && part !== "dist" && !part.startsWith(".env"))
|
|
32
|
+
});
|
|
33
|
+
for (const filename of await readdir(destination)) {
|
|
34
|
+
const target = templateFileRenames.get(filename);
|
|
35
|
+
if (target) await rename(join(destination, filename), join(destination, target));
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
await rm(destination, {
|
|
39
|
+
recursive: true,
|
|
40
|
+
force: true
|
|
41
|
+
});
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { copyExample, dataAppExamples, getExampleDirectory };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["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"],"mappings":";;;;AAIA,MAAM,sCAAsB,IAAI,IAAI,CAAC,CAAC,cAAc,YAAY,CAAC,CAAC;;AAGlE,MAAa,kBAAkB,CAC7B;CACE,IAAI;CACJ,OAAO;CACP,aAAa;CACb,MAAM;AACR,GACA;CACE,IAAI;CACJ,OAAO;CACP,aAAa;CACb,MAAM;AACR,CACF;;AAMA,SAAgB,oBAAoB,IAA8B;CAChE,MAAM,UAAU,gBAAgB,MAAK,YAAW,QAAQ,OAAO,EAAE;CACjE,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,6BAA6B,IAAI;CAC/D,OAAO,cAAc,IAAI,IAAI,gBAAgB,QAAQ,GAAG,IAAI,YAAY,GAAG,CAAC;AAC9E;;AAGA,eAAsB,YACpB,IACA,aACe;CACf,MAAM,SAAS,oBAAoB,EAAE;CACrC,MAAM,MAAM,WAAW;CACvB,IAAI;EACF,MAAM,GAAG,QAAQ,aAAa;GAC5B,WAAW;GACX,SAAQ,SACN,SAAS,QAAQ,IAAI,CAAC,CACnB,MAAM,GAAG,CAAC,CACV,OACC,SACE,SAAS,kBACT,SAAS,UACT,CAAC,KAAK,WAAW,MAAM,CAC3B;EACN,CAAC;EACD,KAAK,MAAM,YAAY,MAAM,QAAQ,WAAW,GAAG;GACjD,MAAM,SAAS,oBAAoB,IAAI,QAAQ;GAC/C,IAAI,QACF,MAAM,OAAO,KAAK,aAAa,QAAQ,GAAG,KAAK,aAAa,MAAM,CAAC;EACvE;CACF,SAAS,OAAO;EACd,MAAM,GAAG,aAAa;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACtD,MAAM;CACR;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
/** Canonical starters available to scaffolding tools. IDs are stable across releases. */
|
|
3
|
+
export declare const dataAppExamples: readonly [{
|
|
4
|
+
readonly id: 'starter-data-app';
|
|
5
|
+
readonly title: 'Hosted data app';
|
|
6
|
+
readonly description: 'A single-file React app for hosted execution.';
|
|
7
|
+
readonly mode: 'hosted';
|
|
8
|
+
}, {
|
|
9
|
+
readonly id: 'starter-local-data-app';
|
|
10
|
+
readonly title: 'Local data app';
|
|
11
|
+
readonly description: 'A Bun and React project with server-side lakehouse access.';
|
|
12
|
+
readonly mode: 'local';
|
|
13
|
+
}];
|
|
14
|
+
/** Stable identifier for a canonical starter. */
|
|
15
|
+
export type DataAppExampleId = (typeof dataAppExamples)[number]['id'];
|
|
16
|
+
/** Absolute source directory. Use copyExample() to restore npm-excluded filenames. */
|
|
17
|
+
export declare function getExampleDirectory(id: DataAppExampleId): string;
|
|
18
|
+
/** Copy a starter into a new directory; reject existing destinations. */
|
|
19
|
+
export declare function copyExample(id: DataAppExampleId, destination: string): Promise<void>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altertable/data-app-examples",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.73.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
|
+
"typecheck": "bun ../../node_modules/typescript/bin/tsc --noEmit -p tsconfig.build.json"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -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 { defineDataApp } from '@altertable/data-app';
|
|
2
|
+
import {
|
|
3
|
+
createDataContext,
|
|
4
|
+
createDataHooks,
|
|
5
|
+
DataApp,
|
|
6
|
+
DataSection,
|
|
7
|
+
DataValue,
|
|
8
|
+
TableWidget,
|
|
9
|
+
Grid,
|
|
10
|
+
Stack,
|
|
11
|
+
TextContent,
|
|
12
|
+
injectDataAppStyles,
|
|
13
|
+
mountDataApp,
|
|
14
|
+
MetricWidget,
|
|
15
|
+
searchVariable,
|
|
16
|
+
} from '@altertable/data-app-react';
|
|
17
|
+
import { createDataClient } from '@altertable/data-app/client';
|
|
18
|
+
import { parseCount } from '@altertable/data-app/contract';
|
|
19
|
+
import { formatMetric } from '@altertable/data-app/format';
|
|
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
|
+
1.4.3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24.18.0
|
|
@@ -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.73.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
|
+
| Build the exploration, export, and story | `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,38 @@
|
|
|
1
|
+
# Local 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.73.0/docs/app-authoring.md). <!-- x-release-please-version -->
|
|
5
|
+
See [AGENTS.md](AGENTS.md) for app-owned files.
|
|
6
|
+
|
|
7
|
+
## Run the app
|
|
8
|
+
|
|
9
|
+
From the copied starter directory, install dependencies and set server-only
|
|
10
|
+
credentials before starting:
|
|
11
|
+
|
|
12
|
+
```fish
|
|
13
|
+
bun install
|
|
14
|
+
set -gx ALTERTABLE_LAKEHOUSE_USERNAME your-username
|
|
15
|
+
read --silent --prompt-str 'Lakehouse password: ' ALTERTABLE_LAKEHOUSE_PASSWORD
|
|
16
|
+
set -gx ALTERTABLE_LAKEHOUSE_PASSWORD $ALTERTABLE_LAKEHOUSE_PASSWORD
|
|
17
|
+
bun run dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Open <http://127.0.0.1:25837>. Alternatively, configure
|
|
21
|
+
`ALTERTABLE_DATA_PROXY_URL` and `ALTERTABLE_DATA_PROXY_TOKEN` for an existing
|
|
22
|
+
CLI proxy. Missing credentials stop startup.
|
|
23
|
+
|
|
24
|
+
## Build the exploration
|
|
25
|
+
|
|
26
|
+
Replace the connectivity check with bounded operations, views, CSV export, and
|
|
27
|
+
story. Change identity, appearance, and queries in `app.ts`.
|
|
28
|
+
|
|
29
|
+
```fish
|
|
30
|
+
bun run check
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`bun run check` includes the build, which writes browser assets to `dist/`. Hosting them requires an authorized
|
|
34
|
+
`/api/data` backend; the local adapter does not authenticate hosted viewers.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
[MIT](LICENSE)
|
|
@@ -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,36 @@
|
|
|
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
|
+
"lint:fix": "oxlint --type-aware --fix src"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@altertable/data-app": "0.73.0",
|
|
21
|
+
"@altertable/data-app-bun": "0.73.0",
|
|
22
|
+
"@altertable/data-app-react": "0.73.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.3"
|
|
36
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GettingStarted } from '@altertable/data-app-react/ui';
|
|
2
|
+
|
|
3
|
+
import { dataContext } from '#app/data-context.ts';
|
|
4
|
+
|
|
5
|
+
/** Connectivity-only screen. Investigate the requested question, then replace this with a view
|
|
6
|
+
* that leads with a supported finding and explores the useful angles behind it. */
|
|
7
|
+
export function App() {
|
|
8
|
+
return <GettingStarted dataContext={dataContext} />;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '*.css';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createDataContext } from '@altertable/data-app-react';
|
|
2
|
+
|
|
3
|
+
import { dataApp } from '#config';
|
|
4
|
+
|
|
5
|
+
const connectionQueryNames = { connection: 'connection' } satisfies Record<
|
|
6
|
+
string,
|
|
7
|
+
keyof typeof dataApp.queries
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
/** Setup context only. Replace it with the exploration's scope, exact definitions, limitations,
|
|
11
|
+
* and query evidence after inspecting the source data. */
|
|
12
|
+
export const dataContext = createDataContext(connectionQueryNames)({
|
|
13
|
+
description:
|
|
14
|
+
'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.',
|
|
15
|
+
glossary: {
|
|
16
|
+
connectionVerified: {
|
|
17
|
+
term: 'Connected',
|
|
18
|
+
definition: 'The latest connection-check query completed successfully.',
|
|
19
|
+
queryNames: [connectionQueryNames.connection],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -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 { connectionCheck } from '@altertable/data-app/contract';
|
|
2
|
+
|
|
3
|
+
import { dataApp } from '#config';
|
|
4
|
+
|
|
5
|
+
/** Connectivity probe only: its successful query supplies no analytical result. Replace it with
|
|
6
|
+
* bounded, validated operations that cover the questions the finished app will answer. */
|
|
7
|
+
export const operations = { connection: connectionCheck(dataApp.queries) };
|
|
@@ -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
|
+
}
|