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

Add protocol version #191

Merged
merged 24 commits into from
Mar 13, 2024
Merged

Add protocol version #191

merged 24 commits into from
Mar 13, 2024

Conversation

kirahsapong
Copy link
Contributor

closes #172

Copy link

changeset-bot bot commented Mar 1, 2024

🦋 Changeset detected

Latest commit: f9cb8af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@tbdex/protocol Minor
@tbdex/http-client Minor
@tbdex/http-server Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Mar 1, 2024

TBDocs Report

✅ No errors or warnings

@tbdex/protocol

  • Project entry file: packages/protocol/src/main.ts

@tbdex/http-client

  • Project entry file: packages/http-client/src/main.ts

@tbdex/http-server

  • Project entry file: packages/http-server/src/main.ts

TBDocs Report Updated at 2024-03-12T19:09:09Z f9cb8af

@kirahsapong
Copy link
Contributor Author

tests won't pass until TBD54566975/tbdex#244 is merged

@@ -44,6 +46,11 @@ export abstract class Message {
return typeid(messageKind).toString()
}

/** Gets the 'x.x' major/minor formatted version based on the current protocol release version */
static getProtocolVersion(): `${number}` {
Copy link
Contributor

Choose a reason for hiding this comment

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

Parsing this as a number is going to lead to weird comparisons, e.g. Version 1.2 > 1.12. What do you think of returning a string?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wait this is the version of the SDK, not the TBDex version. I think those two versions will be different, no? What are we using the SDK version for within the SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Parsing this as a number is going to lead to weird comparisons, e.g. Version 1.2 > 1.12. What do you think of returning a string?

this is a template literal type. it returns a number as a string. so we will get major and minor versions even if we pass '1.12.1' (we will get "1.12") and we will get a compiler error if we try to pass hello, diane! tl;dr: it is returning a string :)

Oh wait this is the version of the SDK, not the TBDex version. I think those two versions will be different, no? What are we using the SDK version for within the SDK?

yep realized afterward I conflated the two. there are weird gotchas with both so will be discussing more this week. its likely the source of the version will change but the rest in this pr will look about the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL template literals. thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

would this still allow number of any format to be passed in (i.e. 9000 or 0.12345?

the pattern we want is x.x like 1.1 or 2.0, per initial proposal https://hackmd.io/TucOUP8UQt-XKj8G9UsJ2Q ?

Copy link
Contributor

Choose a reason for hiding this comment

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

wow TIL template literal as well, very cool

@phoebe-lew phoebe-lew marked this pull request as ready for review March 11, 2024 23:35
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Merging #191 (f9cb8af) into main (1acffee) will increase coverage by 0.01%.
The diff coverage is 96.22%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
+ Coverage   93.22%   93.23%   +0.01%     
==========================================
  Files          37       37              
  Lines        3011     3047      +36     
  Branches      329      338       +9     
==========================================
+ Hits         2807     2841      +34     
- Misses        204      206       +2     
Components Coverage Δ
protocol 94.27% <96.22%> (+<0.01%) ⬆️
http-client 94.83% <ø> (ø)
http-server 89.49% <ø> (ø)

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: populate protocol within .create() rather than passing it as an parameter. This package only supports one possible version currently, so it could simplify DX.

Copy link
Member

Choose a reason for hiding this comment

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

agreed. i think protocol should be set internally and optionally overridable

Copy link
Contributor

Choose a reason for hiding this comment

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

So, default to 1.0 for now with no validation? Or hardcode the versions somewhere the way Kirah previously had it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what you mean by no validation, but either option sounds sufficient to me

Copy link
Member

Choose a reason for hiding this comment

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

default to 1.0 with no validation feels like easiest path forward right now. wdyt @phoebe-lew ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mistermoe agree that's easiest.

@diehuxx if overridable with no validation, someone could put in 666.6 or not even a number as the version

Copy link
Member

Choose a reason for hiding this comment

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

we can create an issue to track validating protocol and tackle post 1.0. i think we'll have a better sense for what "validation" entails beyond just the actual value (e.g. is this message conformant to the version specified) when we're closer to introducing a change to the protocol

Copy link
Contributor

Choose a reason for hiding this comment

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

@mistermoe ah i see, thanks! agreed let's not do validation for now and we'll follow up on it later

Copy link
Contributor

Choose a reason for hiding this comment

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

issue created: TBD54566975/tbdex#270

@@ -8,7 +8,7 @@ import { Parser } from '../parser.js'
*/
export type CreateCloseOptions = {
data: CloseData
metadata: Omit<CloseMetadata, 'id' | 'kind' | 'createdAt'>
metadata: Omit<CloseMetadata, 'id' | 'kind' | 'createdAt' | 'protocol'> & { protocol?: CloseMetadata['protocol'] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking: I kinda hate indexed access type syntax in typescript. Instead I prefer to just use the underlying type, in this case,

`${number}`
Suggested change
metadata: Omit<CloseMetadata, 'id' | 'kind' | 'createdAt' | 'protocol'> & { protocol?: CloseMetadata['protocol'] }
metadata: Omit<CloseMetadata, 'id' | 'kind' | 'createdAt' | 'protocol'> & { protocol?: `${number}` }

Up to you if you feel like doing this. Just a personal preference on my part.

Copy link
Contributor

Choose a reason for hiding this comment

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

Curious what you don't like about it! the way it looks, or is there something about the way it works that you dislike?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's a readability thing. it's an abstraction that i personally don't find helpful. i don't like needing to have to look at a separate file or type to figure out what i'm actually working with, especially if it's as simple as a number or string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh got it. I'm leaning towards leaving it as is because theoretically, the types could drift between CloseMetadata and this field if it's not referencing CloseMetadata.

@phoebe-lew phoebe-lew merged commit 46481e7 into main Mar 13, 2024
14 checks passed
@phoebe-lew phoebe-lew deleted the feat/add-protocol-version branch March 13, 2024 14:56
This was referenced Mar 14, 2024
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.

tbdex version changes add version property to metadata for both Resource and Message
6 participants