include-davis / Include-CMS

In-house CMS system for future clients to use and deploy for free
MIT License
1 stars 1 forks source link

Added schema generation but with errors in tsc #112

Open brandonw504 opened 1 month ago

brandonw504 commented 1 month ago

Gonna be getting rid of _schema soon, and I'll have to figure out something for the types migration generating script. I'm wondering whether it would be okay to change the files in _configs to .mjs files, since it seems I ought to be using a .mjs in _utils/mongodb (may experiment with .mts first).

brandonw504 commented 1 month ago

I made some changes to the types files, switching from .ts to .mjs (I haven't deleted the .ts ones yet in case). Would it be okay to fully make the switch? I switched over since my setup script should (I think) be an ES module.

Also, about migrations, since we're using migrate-mongo, it has its own commands, but I can map them to something custom in package.json if you'd like.

brandonw504 commented 1 month ago

So ultimately I ended up keeping _schema, and just generating the JSON schema validation, which I then use in the migration.

brandonw504 commented 2 weeks ago

My goal with the types migration was to keep the (api)/_schema directory and automatically generate the schema for the types into it. I know we thought about keeping the JSON schemas in the migration files directly, but the way I wrote database seeding uses them. We could generate based on the types files instead if we really feel like getting rid of _schema. I'm also generating the migrations automatically when you run npm run setup.

However, I'm not really sure how to integrate the schema in _configs/_schema since they're .ts files. I tried a couple things like having our project use ESM by default and changing other things to .ts, but I couldn't find a solution. For now, I replaced the .ts files with .mjs in _configs/_schema to make it work, but it causes problems in other places that expect Typescript files. I'll keep looking for a way to fix this.