-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
spike: Add TypeScriptTypes dumper #109
Conversation
That would be awesome. If we get to a stage where we can make the output match the output from this process, then we can slowly modify the output to resolve bugs like this.
Not really yet, but if you just start getting something workable, we can always rename. @soedirgo - if you have some ideas/opinions on the organization of the generators, feel free to add 👍 |
c43d6c9
to
cd556da
Compare
I'm still quite far from completing but let me know if you already see any red flags @kiwicopple @soedirgo:
|
Side note: have you looked into Zapatos? Feels like it's exactly what we want, but I don't know how good the generated types are. |
I have not, thanks for the heads up! Will investigate. Do you think it will be what we want longer term though, since we might want to dump to other languages as well? If we rely on |
Yeah, I think it's best if different languages are handled separately. All type systems have their own idiosyncrasies, so it's best to avoid adding abstractions esp. if it might end up being inflexible for future languages. That said, at first glance Zapatos has some type information that we don't need... ( |
I do that we will need to eventually do this ourselves (to get better granularity on specialty types like GIS columns). |
@soedirgo @kiwicopple I think the core logic is done, there are still some parts to work out:
Other notes:
|
🚀
@soedirgo thoughts? Ultimate we should be able to do something like import { generators } from '@supabase/postgres-meta'
const outputFile = './types/supabase.ts`
const { output, error } = await generators.typescript({ file: outputFile })
I think almost exactly for now (comments should come from Postgres Comments) and then we can improve it after we have parity
Does this help? postgres-meta/src/lib/sql/columns.sql Line 58 in b071b78
Sounds good! Make it work, then refactor when we're ready |
Hey @wasabigeek, sorry for the late response here, got sidetracked... I've given this some thought, and I think it's better to hold off the PR for now and wait for the updated type implementation in supabase-js 2.0 (following supabase/supabase-js#125). The reason is it's easier to start with designing the types keeping in mind it should support autocomplete & will be autogenerated through introspection, than:
Re: how it's used: not sure if it's better to implement it here or in the CLI—generating types seems to be far off the "manage Postgres objects" rhetoric, and the CLI is the only place we use the typegen for now, and introspection e.g. for the Dashboard can be done with just the postgres-meta server (and CMIIW but node-postgres, which this repo depends on, can't run in the browser). If implemented here ideally it can be used as a library as well as standalone. Side note: not sure how we'd generate types for other languages—e.g. Dart, and most other languages, don't have an equivalent of |
This is the main reason I would prefer it here. People can use it "outside of Supabase". Ideally this library can be useful as a standalone tool, and the CLI just becomes a thin wrapper which glues everything together. |
Hi friends, sorry for the MIA, but looks like that was a good thing in the end 😄 It's a little hard to move forward as I'm missing quite a fair bit of context. How would you like to proceed? FWIW, I do agree with @soedirgo that generating types is a separate concern. In my mind, type-generation could be a separate library - but I'd like to think we can leverage the abstractions here in the other library (e.g. P.S. please don't feel like we need to keep this PR, it is named "spike" after all - if it's decided this is not a good long term approach, let's close it 👍 |
superseded by #269 |
Opening a very early PR to discuss #103. I'm thinking to add a
TypeScriptTypes
class with adumps
method that:Does that sound good @kiwicopple @soedirgo? I know we want this to be reusable across different languages but it seems
PostgresColumn
is already a decent abstraction that can go into the various language dumpers.TODO: