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

Type parsing more strongly #29

Merged
merged 8 commits into from
Oct 5, 2023
Merged

Conversation

phoebe-lew
Copy link
Contributor

@phoebe-lew phoebe-lew commented Oct 4, 2023

closes #9 , #13 and refactors types

@@ -0,0 +1,35 @@
package protocol.models
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within our tests we have packages...

  • models
  • protocol
  • protocol.models

We should reconcile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you have a PR open to fix that?

@@ -0,0 +1,24 @@
package models

import typeid.TypeID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as an aside, when we first introduced the typeid-js dependency in tbdex-js we married ourselves to that particular package, which may or may not have multi-language support. In this case it appears it does have multi-language support. But, just a forewarning on rubber stamping new dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest NOT rolling our own token lib and implementing typeid in languages where it's currently not supported.


private fun verify() {
validate()
sealed class Message {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this belong in the web5 repo? Seems related to DWNs, and not specifically to tbdex.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andresuribe87 this is actually a tbdex message as described in the tbdex protocol here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ethan-tbd - is that the right place long term for it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, tbdex has two overarching data structures: resources and messages. The latter are static/immutable data structures and the latter are ephemeral chatty & context dependent structures. I recognize DWNs offer something similar but even in such a world the tbdex application (built on top of the platform primitives) would introduce these concepts. Coalescing the two message concepts is ill advised IMO if only because they are semantically distinct matters.

}

// TODO make private and add method for calling readTree
val objectMapper: ObjectMapper = ObjectMapper()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why you went with jackson for json serialization vs kotlinx serialization?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's just what we've been using. Is there an advantage to using kotlinx instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two advantages I know of:

  • Speed
  • Verbosity
    I don't know how well it's supported in different versions of kotlin though, or different platforms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relevant comment #31 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andresuribe87 , this was a grandfathered decision from @bradleydwyer and @tomdaffurn. I personally wanted to be able to use kotlinx, but also heard from @alecthomas that it wasn't ready for prime time. Kotlinx has a MUCH nicer interface.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried and failed to use kotlinx serialisation. I really liked the API too, but IIRC it was just generally quite restrictive and fiddly to use.

Copy link
Contributor

@jiyoonie9 jiyoonie9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super strong 💪

@phoebe-lew phoebe-lew merged commit 0fd430f into main Oct 5, 2023
1 check passed
@phoebe-lew phoebe-lew deleted the plew.type-parsing-more-strongly branch October 5, 2023 00:09
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

Successfully merging this pull request may close these issues.

Implement Quote and tests
6 participants