-
-
Notifications
You must be signed in to change notification settings - Fork 106
Modularize the library for external use of internal function #620
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
I spotted these little issues.
import { TypedSqlTagTransformer } from './typedSqlTagTransformer.js'; | ||
import { TypescriptAndSqlTransformer } from './typescriptAndSqlTransformer.js'; | ||
import { debug } from './util.js'; | ||
export const debug = debugBase('pg-typegen'); |
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.
export const debug = debugBase('pg-typegen'); | |
const debug = debugBase('pg-typegen'); |
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.
redundant change
import type { Category } from '../customTypes.js'; | ||
|
||
export type categoryArray = (Category)[]; | ||
/** 'SqlSelectFromBooksWhereIdId' parameters type */ | ||
export interface ISqlSelectFromBooksWhereIdIdParams { | ||
id?: number | null | void; | ||
} | ||
|
||
/** 'SqlSelectFromBooksWhereIdId' return type */ | ||
export interface ISqlSelectFromBooksWhereIdIdResult { | ||
author_id: number | null; | ||
categories: categoryArray | null; | ||
id: number; | ||
name: string | null; | ||
rank: number | null; | ||
} | ||
|
||
/** 'SqlSelectFromBooksWhereIdId' query type */ | ||
export interface ISqlSelectFromBooksWhereIdIdQuery { | ||
params: ISqlSelectFromBooksWhereIdIdParams; | ||
result: ISqlSelectFromBooksWhereIdIdResult; | ||
} | ||
|
||
export function sql(s: `SELECT * FROM books WHERE id = $id`): ReturnType<typeof sourceSql<ISqlSelectFromBooksWhereIdIdQuery>>; |
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.
this looks like a bug?
With the release of pglite, one could really benefit from running a postgres (pglite) instance and pgtyped in a single script. This PR makes it easier by exposing an internal function from pgtyped for processing a single file with minimal configuration.
Most of the "modularize" work was to just divide the
@pgtyped/cli
package into two packages:@pgtyped/cli
and a new package@pgtyped/typegen
which is only responsible for generating TS types code and unlimitedly exposes a single functiongetTypes
which processes a single file. This function is then used by the CLI and can be used by the user.I also divided the config so the the typegen function only takes arguments that it really needs.
There is actually much more we can do with pglite in terms of types generation. With the right changes we probably don't even need to establish any TCP connection when working with pglite instance to generate types.