contentful-typescript-codegen icon indicating copy to clipboard operation
contentful-typescript-codegen copied to clipboard

Feature request: Node.js API

Open asbjornh opened this issue 5 years ago • 1 comments

I like what this tool does very much, but I don't care for the API. The magic getContentfulEnvironment.js file is sort of weird, and I also don't like exposing an entire Contentful client instance.

It would be super nice to be able to call this from Node, with the locales and content types as plain objects as opposed to a live client. Something like this:

const codegen = require('contentful-typescript-codegen');

const contentTypes = {}; // get from somewhere
const locales = []; // get from somewhere

const options = { output: "./some-file.ts" }; // same options as CLI flags

codegen({ contentTypes, locales }, options);

Just to be clear, I'm not talking about replacing the existing interface, just adding another one.

If you'd accept a PR that does this I'm happy to do the work!

asbjornh avatar Aug 07 '20 14:08 asbjornh

This would be great for complex use cases like multiple spaces or multiple organizations as well.

DoctorDerek avatar Aug 20 '21 02:08 DoctorDerek

Closing this as this repo seems dead and I'm not using Contentful at work anymore

asbjornh avatar Jan 16 '23 20:01 asbjornh