Skip to content

POC: typescript generator #260

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

Closed
wants to merge 1 commit into from
Closed

POC: typescript generator #260

wants to merge 1 commit into from

Conversation

kiwicopple
Copy link
Member

Draft/POC

@@ -62,7 +64,7 @@
"pkg": "^5.5.2",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.5",
"ts-node-dev": "^1.1.6",
"ts-node-dev": "^2.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm on node v16 now - needed to bump this


`.trim()

export default template
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the main template, based on the spec in the RFC

Comment on lines +16 to +18
const { data: tables } = await pgMeta.tables.list({})
const { data: functions } = await pgMeta.functions.list({})
const definition = ejs.render(template, { tables, functions })
Copy link
Member Author

Choose a reason for hiding this comment

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

pgMeta already has the data in JSON format, so we have done the hard work - we just need to pass the data to the template

const { data: functions } = await pgMeta.functions.list({})
const definition = ejs.render(template, { tables, functions })

return reply.header('content-type', responseFormat).send(definition)
Copy link
Member Author

Choose a reason for hiding this comment

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

then we can send the data in text/plain, so that the CLI can dump it to disk (or we can display it on the Dashboard etc)

Result:

image

Copy link
Member

Choose a reason for hiding this comment

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

Do we need configurable responseFormat? Or can we make it text/plain always?

@soedirgo
Copy link
Member

soedirgo commented Jun 8, 2022

Closed in favor of #269

@soedirgo soedirgo closed this Jun 8, 2022
@soedirgo soedirgo deleted the feat/gen branch August 30, 2022 05:06
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.

2 participants