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

update to [email protected] #735

Closed
Gozala opened this issue Apr 10, 2023 · 0 comments · Fixed by #774
Closed

update to [email protected] #735

Gozala opened this issue Apr 10, 2023 · 0 comments · Fixed by #774
Milestone

Comments

@Gozala
Copy link
Contributor

Gozala commented Apr 10, 2023

This is largest breaking change ucanto has ever introduced, which was motivated by:

  1. Implementing receipts per UCAN Invocation spec.
  2. Versioning wire protocol to make future breaking changes (which will happen as we implement specs and update between versions) less disruptive.

Here is a non exhaustive task list for this upgrade

  1. Invocations will return receipt promises as opposed to results. In the past await invocation.execute(connection) would resolve to the value that had Result type. After update it will resolve to receipts instead which will contain result under .out field.

  2. Result type has changed to align with Result in Invocatino spec. ucanto implementation used result that avoided boxing ok branch, and instead error branch had error: true so we used result?.error to differentiate.

    UCAN invocation spec was optimized for different use case and consequently it's Result type looks like type Result<T, X> = { ok: T } | { error: X }. Instead of translating between two all of ucanto has migrated to using later Result type.

    • This meant bunch of code that used to do if (!result?.error) { doSomething(result) } has to change to if (result.ok) { doSomething(result.ok) } else { doSomethingElse(result.error) }
  3. Result type on ok branch no longer supports falsy values implying that all the returns that are null or undefined are no longer supported. They changed to {} instead (as in unit type, empty js object). I don't suspect it would break any code but TS will likely report issues in places where null or undefined is success branch of the result type.

  4. Capability parser's derivse hook used to return Result<true, Failure>, which changed to Result<{}, Failure>. This is probably where most of the changes will be required, but they are pretty mechanical.

  5. Client and server no longer take transport encoder / decoder pairs. Now they take codec field instead that is Transport.OutboundCodec on client and Transport.InboundCodec on the server. That is because they can implement several formats and select one based on content-type and accept headers. Other than passing the different field it should not really affect client / servers.

  6. Schema stuff moved from @ucanto/validator to @ucanto/core although validator will still re-export it.

  7. To support old clients we have Transport.Legacy codecs which will detect if requests are coming from old clients and transcode responses in a format that those clients expect.

@Gozala Gozala changed the title update to [email protected] update to [email protected] Apr 11, 2023
@heyjay44 heyjay44 added this to the w3up phase 4 milestone Apr 11, 2023
Gozala added a commit that referenced this issue May 2, 2023
Supersedes #767
Fixes #735

### Overview

- Upgrades everything to ucanto@7
- All of the return types changed to new result types
- Removed idiosyncratic abstractions used by tests that made it
difficult to understand update them. Specifically it used bunch of
utility types that no longer were correct
- Changed all the handler closures in favor of functions that just take
extra `ctx` argument
   - removes bunch of types and indirection
- Added some new capabilities and handlers that only service can invoke
- This removed a need to pass some internal db refs to the tests that
made setup complex
- Instead those db queries are exposed as capabilities that test can
invoke
- I think we should just expose all our stores the same way which will
also allow us to introspect running system with right keys

---------

Co-authored-by: Vasco Santos <[email protected]>
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 a pull request may close this issue.

2 participants