Repository navigation
feat: register queries and typed variables for hosted data apps #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fccfac5
feat: add registered queries and typed variable controls
robinvrd b3cb09c
feat: align local app authoring with registered queries
robinvrd e7d7522
feat!: separate registration and unify local iframe queries
robinvrd ede893d
Keep registered query rollout scoped to hosted data apps
robinvrd a1de1cf
docs: focus query guidance and remove repeated workflows
robinvrd 8b1257e
chore: merge main and resolve hosted preview conflicts
robinvrd 2ec617e
refactor: leave registered query parsing and execution to backend
robinvrd 9007d33
refactor: rename registered query adapter to queryById
robinvrd 3428dc4
refactor: remove leftovers from earlier query execution scope
robinvrd 2b3d6b3
feat: share compact calendar pickers across date controls
robinvrd 75d065e
style: tighten date input widths
robinvrd 0e472a2
style: narrow and center date picker inputs
robinvrd 779e530
refactor: pass DuckDB parameter values instead of typed variables
leonkenneth 9dae45f
Merge branch 'main' into robin/data-app-query-variables
leonkenneth e05043f
Remove legacy API
leonkenneth 4538156
Merge remote-tracking branch 'origin/main' into robin/data-app-query-…
leonkenneth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <title>Query variables</title> | ||
| </head> | ||
| <body style="margin: 0"> | ||
| <div id="root"></div> | ||
| <script type="module" src="./query-variables.tsx"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import { applyAppearance, type Theme } from '@altertable/data-app/appearance'; | ||
| import { useEffect, useState } from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
| import { | ||
| type QueryVariableDefinitions, | ||
| type VariableValue, | ||
| } from '@altertable/data-app/contract'; | ||
| import { | ||
| injectDataAppStyles, | ||
| VariableValueSelector, | ||
| } from '@altertable/data-app/react'; | ||
| const definitions = [ | ||
| { name: 'Text', nullable: false, type: 'STRING', default: 'hello' }, | ||
| { name: 'Count', nullable: false, type: 'INTEGER', default: 2 }, | ||
| { name: 'Fraction', nullable: false, type: 'FLOAT', default: 1.5 }, | ||
| { name: 'Enabled', type: 'BOOLEAN', default: false, nullable: true }, | ||
| { name: 'Interval', nullable: false, type: 'INTERVAL', default: 'DAILY' }, | ||
| { | ||
| name: 'Duration', | ||
| type: 'DURATION', | ||
| default: { amount: 1, unit: 'WEEK' }, | ||
| nullable: true, | ||
| }, | ||
| { | ||
| name: 'Date', | ||
| nullable: false, | ||
| type: 'DATETIME', | ||
| default: new Date('2026-10-01T10:00:00Z'), | ||
| }, | ||
| { | ||
| name: 'Period', | ||
| nullable: false, | ||
| type: 'DATETIMERANGE', | ||
| default: { from: new Date('2026-09-01T00:00:00Z'), to: null }, | ||
| }, | ||
| ] as const satisfies QueryVariableDefinitions; | ||
| function App() { | ||
| const [values, setValues] = useState<Record<string, VariableValue | null>>( | ||
| Object.fromEntries( | ||
| definitions.map(definition => [definition.name, definition.default]) | ||
| ) | ||
| ); | ||
| const [theme, setTheme] = useState<Theme>('light'); | ||
| useEffect(() => applyAppearance({ theme }), [theme]); | ||
| return ( | ||
| <main | ||
| className="altertable-data-app" | ||
| data-theme={theme} | ||
| style={{ | ||
| padding: 20, | ||
| minHeight: '100vh', | ||
| boxSizing: 'border-box', | ||
| color: 'var(--at-text)', | ||
| background: 'var(--at-background)', | ||
| fontFamily: 'var(--at-font)', | ||
| }} | ||
| > | ||
| <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}> | ||
| Toggle theme | ||
| </button> | ||
| <h1>Query variables</h1> | ||
| <p> | ||
| Try each variable selector. The values below update with their SQL | ||
| variable types. | ||
| </p> | ||
| <div style={{ display: 'grid', justifyItems: 'start', gap: 16 }}> | ||
| {definitions | ||
| .map(definition => [definition.name, definition] as const) | ||
| .map(([label, definition]) => ( | ||
| <VariableValueSelector | ||
| key={label} | ||
| label={label} | ||
| definition={definition} | ||
| value={values[label]!} | ||
| onChange={value => | ||
| setValues(previous => ({ ...previous, [label]: value })) | ||
| } | ||
| /> | ||
| ))} | ||
| </div> | ||
| <pre | ||
| data-testid="values" | ||
| style={{ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' }} | ||
| > | ||
| {JSON.stringify(values, null, 2)} | ||
| </pre> | ||
| </main> | ||
| ); | ||
| } | ||
| injectDataAppStyles(); | ||
| createRoot(document.getElementById('root')!).render(<App />); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove all things legacy