rmp135 / sql-ts

Generate TypeScript interfaces from a SQL database.
MIT License
476 stars 65 forks source link

Version 2.0 Notice #139

Open rmp135 opened 8 months ago

rmp135 commented 8 months ago

Hi all,

First off, sorry for the radio silence, just haven't been feeling motivated but I'm back and have been chipping away on a total overhaul.

Version 2.0 is here and there's a number of changes I'd like to go over.

Migration Guide

Because it now exports as an ES module, consumer projects must also be of type module.

The biggest change is how the node module now works. Previously it was a couple of random functions that I never quite liked. Now, it uses a fluent API to chain operations together. See the node module docs for more details.

import { Client } from '@rmp135/sql-ts'

const config = { }

const ts = await Client
  .withConfig(config)
  .fetchDatabase()
  .mapColumn('public.users.name', ((column, table, schema) => ({ ...column, propertyName: 'newName' })))
  .toTypescript()

For CLI users, there's no specific changes required, however please report if you find anything untoward.

For those with custom templates:

The folder config option has been removed, just use filename with a path.

laurent22 commented 2 weeks ago

Honestly I question how useful these breaking changes are, when they were apparently done for aesthetic reasons. We're certainly not going to update if it means we have to migrate everything, especially since we gain nothing in the process.

Sometimes it's ok to stick with ugly APIs and not break everybody's build. As a dev I can understand you want to clean up your package, but it's not important to anybody else. As a user, we just want something that works and your package did that just fine.

Not to mention that you'll now get bug reports for both v1 and v2 because people will stick with the older version.