Skip to content

Conversation

avallete
Copy link
Member

What kind of change does this PR introduce?

  • Follow up refactor isolating duplicated typescript generation logic into their own dedicated functions

@avallete avallete requested review from a team as code owners September 24, 2025 09:59
@avallete avallete requested a review from soedirgo September 24, 2025 09:59
Comment on lines 620 to 633
export const Constants = {
${schemas
.sort(({ name: a }, { name: b }) => a.localeCompare(b))
.map((schema) => {
const schemaEnums = types
.filter((type) => type.schema === schema.name && type.enums.length > 0)
.sort(({ name: a }, { name: b }) => a.localeCompare(b))
return `${JSON.stringify(schema.name)}: {
${schemas.map((schema) => {
const schemaEnums = introspectionBySchema[schema.name].enums
return `${JSON.stringify(schema.name)}: {
Enums: {
${schemaEnums.map(
(enum_) =>
`${JSON.stringify(enum_.name)}: [${enum_.enums
.map((variant) => JSON.stringify(variant))
.join(', ')}]`
)}
}
}`
})}
})}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note

Forgot to remove this loop, now we can use the introspectionSchema directly where the values are already filtered and sorted.

Comment on lines -234 to -240
${relationships
.filter(
(relationship) =>
relationship.schema === table.schema &&
relationship.referenced_schema === table.schema &&
relationship.relation === table.name
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant