feat: add type-safe sql queries with query registry #11
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.
Type-Safe SQL Queries with QueryRegistry
Summary
This PR introduces a compile-time type system for SQL queries, providing full type safety from query definition to result consumption. The system generates TypeScript types by analyzing SQL files and using
DESCRIBE QUERYagainst Databricks to infer result schemas without executing the actual queries.Features
QueryRegistry Type Generation
Automatically generates TypeScript interfaces for all SQL queries in your project:
SQL Parameter Type Safety
SQLDateMarker,SQLStringMarker,SQLNumberMarker,SQLBooleanMarker,SQLTimestampMarker,SQLBinaryMarker)INT,BIGINT,DECIMAL,FLOAT,DOUBLE, etc.) map toSQLNumberMarkerwithsql.number()helper@paramAnnotations: Declare parameter types in SQL files:sql.*()helper to useSQLTypeMarkerunion, still enforcing helper usageType-Safe Query Hook
useAnalyticsQuerynow provides full IntelliSense:Result Schema Inference
DESCRIBE QUERYto extract column metadata without executing queriesDECIMAL(38,6)→DECIMAL,ARRAY<STRING>→ARRAY)@sqlTypeJSDoc comments with full type info (e.g.,@sqlType DECIMAL(38,6))Developer Experience
anydataArchitecture
Test Plan
npx appkit-generate-typesand verifyappKitTypes.d.tsis generated correctlyuseAnalyticsQuery@paramannotationssql.*()helper