ftrackhq / ftrack-ts-schema-generator

Gets the schema from an ftrack instance and generates typescript interfaces for all the entity types in the instance.
Apache License 2.0
2 stars 1 forks source link

feat: strong typed schemas #27

Closed ffMathy closed 10 months ago

ffMathy commented 11 months ago

Builds on top of #26 and #25 to add strong-typed schema and associations.

Changes

Test

ffMathy commented 11 months ago

I will finish this and submit for review when the PR #26 and #25 are merged. This one is the glue that will bind it all together. It'll be great!

ffMathy commented 11 months ago

This is done now. Hmmm, since this includes #26 and #25, perhaps it just makes sense to review this all at once? Up to you.

gismya commented 11 months ago

Too many things to keep track of at the same time to review them simultaneously. But you could setup this one to point to the #26 branch (But that would have to be done in your repository), if you want me to be able to review this one before #26 is merged.

ffMathy commented 11 months ago

Yeah sure. One at a time is okay too 🙏

ffMathy commented 11 months ago

@gismya this one has also been resolved conflict-wise and is ready to merge!

ffMathy commented 11 months ago

Oh, and as part of this, I also spotted that in a prior PR I was all of a sudden using Python naming convention for the emitted types and object types. I changed that here too for consistency.

I hope that's OK.

ffMathy commented 10 months ago

Any chance this will make it before Christmas? It is the last PR we need to do something epic on our side.

gismya commented 10 months ago

Sorry for the delay, I've gone in to start looking at it a few times, but I get stuck in that I don't quite follow what's going on. Could you add further explanations of the PR to help me along?

ffMathy commented 10 months ago

Yeah sure @gismya! Which parts need elaboration? The purpose, or what the code is doing? Or maybe something else?

gismya commented 10 months ago

What is being emitted, and the use case for it. I'm not intimately familiar with the project schemas.

ffMathy commented 10 months ago

Ah, fair enough. I'll do my best.

The schemas decide which types can be assigned to particular object types, and also decide which statuses are available for those types.

By providing this information at runtime and compile time, there are various things we want to achieve with this:

Imagine how great it would be if an entity's custom attributes were strong-typed. Or maybe strong-typing parent more efficiently (by looking at which objects can be parents of other objects). All of this is achievable with this emitted code.

And because it's tree-shakeable, it's not a problem for the runtime bundle size if not used.

Does that help?

ffMathy commented 10 months ago

Thank you @gismya! We also hope we can contribute back soon and show how this can be useful in practice. Looking forward to it! ❤️

ffMathy commented 10 months ago

By the way @gismya. One more ask. Can you make a release to NPM also? Just so we can get all these PRs out also.

gismya commented 10 months ago

The work was on its way to release - there were some changes with linting and time zones for the tests that needed to be fixed. I must also determine why the test suite is not running for outside contributors on their PRs, but that's a later question.

It's been released now.

ffMathy commented 10 months ago

Thanks @gismya!

As for the failing PR, usually that's because something needs access to secrets, and secrets are not included for PRs by default.

Thats changeable in the repo setttings. Perhaps there's other interesting settings there too?

jimmycallin commented 10 months ago

Thanks @gismya!

As for the failing PR, usually that's because something needs access to secrets, and secrets are not included for PRs by default.

Thats changeable in the repo setttings. Perhaps there's other interesting settings there too?

https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow

Unfortunately it looks like secrets aren't passed to forked repositories, so not entirely sure what we can do to make them work for you. I think we need to run them ourselves.

ffMathy commented 10 months ago

Ah okay. But in that case, you can retry the build manually and it'll work.

I guess it makes sense from a security standpoint.