Skip to content
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

Could we export the Collections also as type to make use of the models in the sdk #1

Closed
michael-scheurer opened this issue Jul 11, 2023 · 3 comments

Comments

@michael-scheurer
Copy link

We could make use of the Collections in the Directus SDK. But const directus = new Directus<Collections>('url') wouldn't work, because the <Collections> must extend from TypeMap by definition. To overcome this, we could simply generate the Collections also as type.

That way:

export type DirectusCollections = {
  directus_folders: DirectusFolder;
  directus_roles: DirectusRole;
  ...
}

What do you think?

@ChappIO
Copy link
Owner

ChappIO commented Jul 12, 2023

Have you tested this for your use-case? If that works I'm all for it, but I did not make this extension for the Directus sdk. I explicitly developed it to improve the development experience of developing extension.

Let me know if you tested this, how you tested it and how it worked for you.

You don't have to change Chappio/directus-extension-models to test it, just edit the generated sources and try to run your application. If that works well for you I will consider publishing the change in this repo.

@michael-scheurer
Copy link
Author

Indeed, I'm testing it on a new project for some days now and it perfectly works.
In my case it makes the front-end development work combined with the sdk way more simpler or at least type safer.
I would definitely recommend it.
...and drop a hint in the docs ;) I could open a PR once the change here is made.

@ChappIO
Copy link
Owner

ChappIO commented Jul 27, 2023

Thanks, it took a moment for me to find the time but I created a new release 2.1.0 which has this change.

@ChappIO ChappIO closed this as completed Jul 27, 2023
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

No branches or pull requests

2 participants