Add Gel support#20
Conversation
WalkthroughAdds Gel and SingleStore support across the code generator: updates env URLs and package scripts, adjusts Docker/init templates and images, converts Gel SQL schema and query helpers to Gel client/Drizzle patterns, and extends type/schema generation to map Drizzle dialects to specific DB implementations. Changes
Sequence Diagram(s)sequenceDiagram
participant Generator as Code Generator
participant AppInit as Generated App (runtime)
participant GelClient as Gel.createClient()
participant DB as Gel DB
Note over Generator: Generator emits connection code and queries
Generator->>AppInit: write connectionMap (createClient/getEnv)
AppInit->>GelClient: createClient(getEnv("DATABASE_URL"))
GelClient->>DB: open connection (5656)
AppInit->>GelClient: queryRequiredSingle / querySingle
GelClient->>DB: execute Gel query (insert/select)
DB-->>GelClient: result row
GelClient-->>AppInit: typed record / null
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (3)
🧰 Additional context used🧬 Code graph analysis (2)src/generators/project/generateImportsBlock.ts (1)
src/generators/db/generateDatabaseTypes.ts (2)
🔇 Additional comments (15)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/generators/configurations/generateEnv.ts(1 hunks)src/generators/configurations/generatePackageJson.ts(3 hunks)src/generators/db/dockerInitTemplates.ts(2 hunks)src/generators/db/generateDatabaseTypes.ts(2 hunks)src/generators/db/generateDockerContainer.ts(1 hunks)src/generators/db/generateDrizzleSchema.ts(1 hunks)src/generators/db/handlerTemplates.ts(2 hunks)src/generators/db/scaffoldDatabase.ts(1 hunks)src/generators/project/generateDBBlock.ts(1 hunks)src/generators/project/generateImportsBlock.ts(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-22T04:55:44.021Z
Learnt from: bnziv
Repo: absolutejs/create-absolutejs PR: 11
File: src/generators/configurations/generateEnv.ts:17-17
Timestamp: 2025-11-22T04:55:44.021Z
Learning: The mssql npm package supports Windows-style connection string format (key=value pairs separated by semicolons) in addition to URI format. Connection strings like "Server=localhost,1433;Database=master;User Id=sa;Password=SApassword1;Encrypt=true;TrustServerCertificate=true" are valid for the mssql package.
Applied to files:
src/generators/configurations/generateEnv.ts
🧬 Code graph analysis (3)
src/generators/db/generateDatabaseTypes.ts (2)
src/types.ts (3)
DatabaseEngine(45-47)DatabaseHost(49-49)AuthProvider(40-40)src/typeGuards.ts (1)
isDrizzleDialect(27-30)
src/generators/configurations/generatePackageJson.ts (1)
src/generators/db/dockerInitTemplates.ts (1)
initTemplates(127-156)
src/generators/project/generateImportsBlock.ts (1)
src/typeGuards.ts (1)
isDrizzleDialect(27-30)
🔇 Additional comments (15)
src/generators/db/generateDrizzleSchema.ts (1)
4-11: LGTM! Gel dialect now properly supports native JSON.The addition of
jsonto the builders array and switching fromtext()tojson()for the JSON type aligns the Gel dialect with other databases that have native JSON support. This is consistent with how MySQL, PostgreSQL, and SingleStore handle JSON fields.src/generators/configurations/generateEnv.ts (1)
14-14: LGTM! Gel connection URL updated consistently with Docker configuration.The new URL format (
gel://admin@localhost:5656/main?tls_security=insecure) correctly aligns with:
- Docker port mapping (5656:5656 in
generateDockerContainer.ts)- CLI parameters (
-u admin,-P 5656,--tls-security insecureindockerInitTemplates.ts)- Insecure dev mode environment variable
src/generators/configurations/generatePackageJson.ts (2)
38-42: LGTM! Gel database scripts configuration added correctly.The
clientCmdcorrectly usesgel(interactive mode) rather thangel query(for executing queries), which is appropriate for thedb:gelscript that opens an interactive client session.
250-252: No issues found.The
gelpackage version2.1.1is a valid published version on npm.src/generators/project/generateDBBlock.ts (1)
10-12: LGTM! Gel client initialization updated to usecreateClient.The change from
gelClient({ url: ... })tocreateClient(getEnv("DATABASE_URL"))aligns with the import statement ingenerateImportsBlock.tswhich importscreateClientfrom thegelpackage.src/generators/db/scaffoldDatabase.ts (1)
101-106: LGTM!databaseEnginecorrectly propagated to type generation.Passing
databaseEngineenablesgenerateDatabaseTypesto select the appropriate Drizzle database type (e.g.,GelJsDatabase,BunSQLDatabase) when no remote host is specified.src/generators/project/generateImportsBlock.ts (3)
119-122: LGTM! Gel-specific Drizzle imports added correctly.The imports align with the Gel driver setup:
createClientfromgelfor client instantiationdrizzlefromdrizzle-orm/gelfor the Drizzle wrapper
108-112: LGTM! User type import added for absoluteAuth.Adding the
Usertype import whenabsoluteAuthis enabled provides proper typing for user handlers. This is exported fromgenerateDatabaseTypes.tsat lines 65-66.
154-157: LGTM! Gel imports for non-ORM case added.Consistent with the Drizzle case, providing
createClientfromgelandgetEnvfor database URL retrieval.src/generators/db/generateDatabaseTypes.ts (2)
1-8: LGTM! Type generation now supports engine-based fallback.The updated signature accepting
databaseEngineenables properDatabaseTypeselection for local development scenarios where no remote host is configured.
30-57: Ignore this review comment.The original comment assumes
cockroachdbwould pass theisDrizzleDialectguard and reach the switch statement, butcockroachdbis not inavailableDrizzleDialects. The available Drizzle dialects are:gel,mysql,postgresql,sqlite, andsinglestore. SinceisDrizzleDialectchecks membership against this list,cockroachdbwill never enter the conditional block (lines 30–57), so no case is missing.Likely an incorrect or invalid review comment.
src/generators/db/generateDockerContainer.ts (1)
24-31: LGTM! Gel Docker image configuration verified and correct.The
geldata/gel:latesttag exists on Docker Hub, confirming the configuration is valid. All settings align with Gel requirements:
GEL_SERVER_SECURITY: insecure_dev_modefor local development- Port 5656 matches connection URL and CLI commands
- Volume path
/var/lib/gel/datais the standard Gel data directorysrc/generators/db/dockerInitTemplates.ts (1)
132-135: LGTM!The updated CLI and wait commands correctly use the
gel querysyntax with appropriate connection parameters (-H localhost -P 5656 -u admin --tls-security insecure). The trailing space on line 133 is appropriate for command concatenation.src/generators/db/handlerTemplates.ts (2)
330-338: LGTMThe
gel:drizzle:localdriver configuration is correct and properly implements Drizzle ORM's Gel support. The configuration follows the established pattern used by other Drizzle drivers (e.g.,postgresql:drizzle:local), uses valid imports from thedrizzle-orm/gelentrypoint, and referencesdrizzleQueryOperationswhich contains all required database operations.
339-343: TheClientexport and import statement are correct.Verification confirms the gel package exports
Clientwith the required methods. ThegelClientQueryOperationsconfiguration uses only valid Client methods (queryRequiredSingle()andquerySingle()) that are confirmed in the gel package API. The import change fromGelClienttoClientis correct and properly aligned with the current package export.
50cc90f to
59e3dfc
Compare
59e3dfc to
759806b
Compare
| const databaseURLS = { | ||
| cockroachdb: 'postgresql://root@localhost:26257/database', | ||
| gel: 'gel://user:password@localhost:5432/database', | ||
| gel: 'gel://admin@localhost:5656/main?tls_security=insecure', |
There was a problem hiding this comment.
is using insecure a problem further down the line, like i think that means it needs to run on https correct? if its one of those things where its different for dev and prod we will need to put some sort of toggle
| databaseEngine !== 'mongodb' && | ||
| databaseEngine !== 'singlestore' && // TODO: Add support for singlestore | ||
| databaseEngine !== 'gel' // TODO: Add support for gel | ||
| databaseEngine !== 'singlestore' // TODO: Add support for singlestore |
There was a problem hiding this comment.
remove the code comment since you added it
| gel: { | ||
| cli: 'psql -U user -d database -c', | ||
| wait: 'until pg_isready -U user -h localhost --quiet; do sleep 1; done' | ||
| cli: 'gel query -H localhost -P 5656 -u admin --tls-security insecure -b main ', |
There was a problem hiding this comment.
same question as above about tls insecure
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
src/generators/configurations/generateEnv.ts(1 hunks)src/generators/configurations/generatePackageJson.ts(3 hunks)src/generators/db/dockerInitTemplates.ts(2 hunks)src/generators/db/generateDatabaseTypes.ts(1 hunks)src/generators/db/generateDockerContainer.ts(1 hunks)src/generators/db/handlerTemplates.ts(2 hunks)src/generators/project/generateDBBlock.ts(1 hunks)src/generators/project/generateImportsBlock.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- src/generators/configurations/generateEnv.ts
- src/generators/db/generateDockerContainer.ts
- src/generators/project/generateDBBlock.ts
- src/generators/project/generateImportsBlock.ts
- src/generators/db/generateDatabaseTypes.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/generators/configurations/generatePackageJson.ts (1)
src/generators/db/dockerInitTemplates.ts (1)
initTemplates(128-157)
🔇 Additional comments (7)
src/generators/configurations/generatePackageJson.ts (3)
33-42: Gel dbScripts entry is consistent with existing patternsThe
gelentry mirrors how other engines are wired (interactive client command + reuse ofinitTemplates.gel.wait), so it should integrate cleanly with thedb:*scripts.If you haven’t already, please run the generated
db:gelscript once to confirm the CLI flags match the Gel CLI you’re targeting.
211-235: Including Gel in local docker-managed DB setup looks correctRelaxing the condition so that only
sqliteandmongodbare excluded means Gel will now getdb:up/db:downscripts like the other SQL-ish engines. This aligns with the presence ofdbScripts.gel.Please double-check that the generated
db/docker-compose.db.ymlcontains adbservice for Gel so these scripts actually work for that engine.
257-259: Adding thegelruntime dependency for local Gel setupsWiring
gelintodependencies(notdevDependencies) whenisLocal && databaseEngine === 'gel'matches how the handler templates importClientfrom'gel'.Confirm that the package name (
gel) and version (2.1.1) match the published NPM package and the API shape you’re using (e.g.,Client,GelJsDatabase).src/generators/db/dockerInitTemplates.ts (2)
80-92: Gel users type definition looks goodThe Gel
userstype matches the other backends’ shape, and the JSON default viato_json('{}')avoids the<json>{}empty-set pitfall.
133-135: Gel init CLI/wait wiring is aligned with other enginesUsing
gel query ...for bothcliand readiness check mirrors howpsql/cockroach sqlare used elsewhere and should work for running the generated schema and health probe.Once the semicolon fix is in, it’s worth running the generated init script (
db:initfor Gel) to confirm theselect 1wait loop and schema application succeed end-to-end.src/generators/db/handlerTemplates.ts (2)
173-194: Gel client query operations are consistent with the Gel schemaThe four operations (insert/select for users and count_history) line up with the Gel types:
countas<int16>,uidfiltered as<int64>$uidfor the sequence-backed key, and JSON metadata inserted via<json>$metadata. UsingqueryRequiredSinglefor inserts andquerySinglefor selects matches the intended “must-return vs optional” semantics.Please confirm against the Gel JS client docs that
Client.queryRequiredSingle/Client.querySingleaccept JS objects for<json>parameters as used here (metadata: userIdentity) without needing manualJSON.stringify.
330-343: New Gel driver configurations hook into the right query setsThe new
'gel:drizzle:local'entry and the updated'gel:sql:local'entry correctly:
- Use
GelJsDatabase<SchemaType>withdrizzle-orm/gelanddrizzleQueryOperationsfor the Drizzle path.- Use
Clientfrom'gel'withgelClientQueryOperationsfor the client path.This keeps the Gel flows aligned with how other engines are configured.
Double-check that
GelJsDatabaseis the correct exported type fromdrizzle-orm/geland thatClientfrom'gel'matches the version you’re pinning inpackage.json, so the generated imports compile.
e97f954 to
8ddbf6d
Compare
Summary by CodeRabbit
New Features
Behavioral Changes
✏️ Tip: You can customize this high-level summary in your review settings.