chore: dedup typescript typegen logic#993
Conversation
| @@ -628,7 +630,7 @@ export const Constants = { | |||
| )} | |||
| } | |||
| }` | |||
| })} | |||
| })} | |||
There was a problem hiding this comment.
note
Forgot to remove this loop, now we can use the introspectionSchema directly where the values are already filtered and sorted.
| ${relationships | ||
| .filter( | ||
| (relationship) => | ||
| relationship.schema === table.schema && | ||
| relationship.referenced_schema === table.schema && | ||
| relationship.relation === table.name | ||
| ) |
There was a problem hiding this comment.
note
Noticed that I forgot this loop, instead I now push those into the introspectedSchema object under each table/view so we don't have to filter and sort everytime.
Also extracted the typegen into it's own dedicated function reducing duplication across tables/views definitions.
| const getFunctionTsReturnType = (fn: PostgresFunction, returnType: string) => { | ||
| return `${returnType}${fn.is_set_returning_function ? '[]' : ''}` | ||
| } |
There was a problem hiding this comment.
Only used in one place, I think we can inline this
There was a problem hiding this comment.
Yup, those two will be growing a lot in the next PR though which is why I've did the split here. So in the next PR we can focus over the changes scoped to those functions: https://github.com/supabase/postgres-meta/pull/971/files#diff-c903ec71df16a8ae5f665c19c21b273f74c2f8eb02f5e8a3552ebe69d18be18fR214-R265
| return 'unknown' | ||
| } | ||
|
|
||
| const getFunctionSignatures = ( |
There was a problem hiding this comment.
Pull Request Test Coverage Report for Build 18155869351Details
💛 - Coveralls |
What kind of change does this PR introduce?