WIP: feature/zod-schemas #2225

Draft
dpschen wants to merge 2 commits from dpschen/frontend:feature/zod-schemas into main
Member

This builds upon the abstract service ts branch.
First I separated the model types from the models.

Then I experiment a bit with zod.
It seems like using such a tool could help us a lot having good typing everywhere. I think most models can completely be replaced by zod schemas. The few methods that the models have could be helpers that you import on demand.

EDIT: Diff is better visible here: https://kolaente.dev/dpschen/frontend/compare/feature/convert-abstract-service-to-ts...feature/zod-schemas

This builds upon the abstract service ts branch. First I separated the model types from the models. Then I experiment a bit with [zod](https://github.com/colinhacks/zod). It seems like using such a tool could help us a lot having good typing everywhere. I think most models can completely be replaced by zod schemas. The few methods that the models have could be helpers that you import on demand. EDIT: Diff is better visible here: https://kolaente.dev/dpschen/frontend/compare/feature/convert-abstract-service-to-ts...feature/zod-schemas
dpschen added 21 commits 2022-08-05 16:51:26 +00:00
Author
Member

I have no clue if yup would make more sense to use. Since I don't have experience with these kind of libs I just picked one.

I have no clue if [yup](https://github.com/jquense/yup) would make more sense to use. Since I don't have experience with these kind of libs I just picked one.
dpschen force-pushed feature/zod-schemas from 48a83a4fd8 to 8cc08582be 2022-08-10 18:08:49 +00:00 Compare
dpschen force-pushed feature/zod-schemas from 8cc08582be to 32b3078ee1 2022-08-13 13:28:27 +00:00 Compare
dpschen force-pushed feature/zod-schemas from 32b3078ee1 to b3ae11e0c3 2022-08-18 16:21:25 +00:00 Compare
dpschen force-pushed feature/zod-schemas from b3ae11e0c3 to 8705ebbe45 2022-09-05 19:26:45 +00:00 Compare
dpschen force-pushed feature/zod-schemas from 8705ebbe45 to 4fcd63c8b6 2022-09-06 09:25:29 +00:00 Compare
Member

Hi dpschen!

Thank you for creating a PR!

I've deployed the changes of this PR on a preview environment under this URL: https://2225-feature-zod-schemas--vikunja-frontend-preview.netlify.app

You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/.

Have a nice day!

Beep boop, I'm a bot.

Hi dpschen! Thank you for creating a PR! I've deployed the changes of this PR on a preview environment under this URL: https://2225-feature-zod-schemas--vikunja-frontend-preview.netlify.app You can use this url to view the changes live and test them out. You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/. Have a nice day! > Beep boop, I'm a bot.
dpschen force-pushed feature/zod-schemas from 4fcd63c8b6 to 5198e6b06e 2022-09-06 09:41:37 +00:00 Compare
dpschen force-pushed feature/zod-schemas from 5198e6b06e to 8a5017b2d6 2022-09-13 15:12:29 +00:00 Compare
dpschen added the
help wanted
kind/feature
labels 2022-09-29 09:03:12 +00:00
dpschen self-assigned this 2022-09-29 09:03:16 +00:00
dpschen force-pushed feature/zod-schemas from 8a5017b2d6 to 2c6b7d622a 2023-03-02 10:57:00 +00:00 Compare
Contributor

While we're at it, has an idea of generating schema-like like files from the backend repo been considered?

While we're at it, has an idea of generating schema-like like files from the backend repo been considered?
Author
Member

While we're at it, has an idea of generating schema-like like files from the backend repo been considered?

Yes. But afaik not really possible (at least for zod types) because the current backend provides the API in a non-valid OpenAPI 2 (not 3!).

This let's all generators that I tried fail. Regardless of this we would need to manually improve the types because a 1:1 mapping is not possible. The types defined in this PR could be a good base (but are not fully to date).

Do you have any other idea, or did you have something completely different in mind?

> While we're at it, has an idea of generating schema-like like files from the backend repo been considered? Yes. But afaik not really possible (at least for zod types) because the current backend provides the API in a non-valid OpenAPI 2 (not 3!). This let's all generators that I tried fail. Regardless of this we would need to manually improve the types because a 1:1 mapping is not possible. The types defined in this PR could be a good base (but are not fully to date). Do you have any other idea, or did you have something completely different in mind?
Contributor

I'll be honest, I have not seen what I suggested in the wild, so I'm not good in the field.

This let's all generators that I tried fail.

You got some references handy? Issues, forum posts?

I'll be honest, I have not seen what I suggested in the wild, so I'm not good in the field. > This let's all generators that I tried fail. You got some references handy? Issues, forum posts?
Author
Member
See under: https://github.com/colinhacks/zod#ecosystem
Author
Member

I think we should use the equivalent in js for the frontend, similar to how we use camelCase for variable names.

#3323 (comment)

> I think we should use the equivalent in js for the frontend, similar to how we use camelCase for variable names. _https://kolaente.dev/vikunja/frontend/pulls/3323#issuecomment-47645_
konrad force-pushed feature/zod-schemas from 2c6b7d622a to ba5c729046 2024-02-07 10:54:14 +00:00 Compare
konrad referenced this issue from a commit 2024-02-08 10:49:10 +00:00
This repo is archived. You cannot comment on pull requests.
No description provided.