kossnocorp / typesaurus

🦕 Type-safe TypeScript-first ODM for Firestore
https://typesaurus.com
415 stars 36 forks source link

v8 and beyond #110

Closed jimlloyd closed 2 years ago

jimlloyd commented 2 years ago

I'm struggling a bit to build my first Firebase application. One of the biggest sources of friction for me is exactly what this project addresses. But another big source of friction is understanding the evolution the ecosystem and figuring out a compatible set of packages that I should pin to. I nearly concluded that Typesaurus has been abandoned given how long ago the last commit to master was.

I see there is a v8 branch in progress, but even that branch has not had any updates in quite some time. But I see that @SrBrahma's fork has added quite a few commits to the v8 branch with commits in the last week.

Is there a plan to release v8? Are you coordinating with @SrBrahma?

SrBrahma commented 2 years ago

I am considering to be a contributor for some months already, as this lib is important to me and I like it. As a matter of fact, I did something similar to it for Realtime Database when I used it and before knowing this lib (https://github.com/SrBrahma/firebase-database-modeler). Only one guy said to be interested in #85 and looks like it didn't go forward.

I am using my fork with those 5 PRs of mine in my front and backend and going to release my project soon. Working fine.

You can also use it via yarn add typesaurus@srbrahma/typesaurus#lib or its corresponding npm command.

I still have some issues that I want to fix, like undefined values being transformed into null automatically by typesaurus and maybe supporting firebase 9 if I have the time (unlikely to be done at any time soon, my queue is somewhat long already). I also have an issue with Dates, I have to use any type in my schemas and then typecast it when writing or reading. There is WriteModel auxiliar type but I still have issues with it. Tried some better workarounds but none worked.

I will probably email @kossnocorp if he doesn't see this soon.

Also, v8 works fine as far as I used it. Don't know why it hasn't been released back then. My fork uses it.

jimlloyd commented 2 years ago

Thanks for the response Henrique. I think I will give your package a try. Can you please specify which versions of firebase packages you use? Are there any known problems with any of the node versions supported by the firebase team? Do you by chance use https://www.npmjs.com/package/typed-ff, or know if there is any compatibility issues with it?

SrBrahma commented 2 years ago

"firebase-admin": "^9.12.0" in my Cloud Functions server. It uses node 14.

Just found out that there is firebase-admin v10 and node 16 is already supported, I may give them a try tomorrow and they will probably work fine.

"firebase": "8.10.0" in my React Native (Expo) app. You can't use firebase v9 because its usage is different from v8 (not typesaurus v8) and typesaurus doesn't support it (yet?). But using v8 isn't really an issue.

I never used the lib you linked. I simply don't like working with Firestore (or RTDB) triggers are they are somewhat bad, as there are no guarantees on how long it may take for them to take effect (but as far as I tested they are immediate, but still, I don't think it's worth to take the risks). My front never writes anything directly to the DB, as I had the experience in the past of a complexity hell in the security rules file. I just use Cloud Fuctions for any user action and have a clear and full control over them.

What I use is another lib of mine that I never properly published but it's really good for Cloud Functions, the firebase-functions-extended. My productivity is awesome with it. This is how I write a CF function with it (and with typesaurus):

image

(unfortunately typesaurus doesn't support nested type safe updates, but I rarely do them anyway)

I still haven't wrote a README for it but it's in my plans.

SrBrahma commented 2 years ago

Seems very cool, @jimlloyd! In a next project I will give it a better look!

sushantdhiman commented 2 years ago

When I started with Firebase, this project helped me a lot as firestore was missing proper type safety, even for basic get, update like operations.

But from many months this library is in limbo state, I actually written my new project with vanilla firebase-admin library, as Google has improved Typescript support a lot.

Today I even converted my initial project to use firebase-admin@11. I took this decision mainly because of two reasons :--

If this library is not update in near future, I suggest future users to explore firebase-admin with convertors. With that you don't need any wrapper library to get proper type-safety. This way you can even try new features as they are released.

jimlloyd commented 2 years ago

@sushantdhiman I agree. firebase-admin with converters is ok. The client API with converters is also ok. I think it would probably be nice if they were the same API, but given that I have client and server (firebase functions) code in the same repo, and have at times confused myself by starting to use server code in a client context or vice versa, maybe having them be different but similar APIs is all for the best.

kossnocorp commented 2 years ago

I don't know your reason for writing all that, but that's pretty demotivating to hear how much you are better without free open-source supported by a single person.

For the past few weeks, I've been working virtually full-time on a new version that will solve outstanding problems and bring more type safety with better API. If you want a sneak peek: https://twitter.com/kossnocorp/status/1525111483889242112

jimlloyd commented 2 years ago

@kossnocorp your sneak peek looks very cool. I kind of wish I knew about it in May (or sooner) when you posted that twitter thread. With all respect, if you do want others to contribute, you should make it clear that you prefer to use Twitter to coordinate instead of GitHub issues -- including responding to each issue with a link to your twitter ID. I created this issue to ask for info and you never responded. From that, it shouldn't be surprising that anyone might conclude that you had abandoned this project. I'm glad to hear that isn't the case. I am following you now on twitter in hopes of staying informed of your progress.

MRDGH2821 commented 12 months ago

Any updates? 😅

kossnocorp commented 12 months ago

@MRDGH2821 (and everyone who's interested) try typesaurus@10.0.0-beta.11 and see (WIP) docs: https://next.typesaurus.com/

You can contact me with questions https://t.me/kossnocorp or https://twitter.com/kossnocorp and I'll try to help.