You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
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) }
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.
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.
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.
Schema stuff moved from @ucanto/validator to @ucanto/core although validator will still re-export it.
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.
The text was updated successfully, but these errors were encountered:
Supersedes #767Fixes#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]>
This is largest breaking change ucanto has ever introduced, which was motivated by:
Here is a non exhaustive task list for this upgrade
Invocations will return receipt promises as opposed to results. In the past
await invocation.execute(connection)
would resolve to the value that hadResult
type. After update it will resolve to receipts instead which will contain result under.out
field.Result
type has changed to align with Result in Invocatino spec. ucanto implementation used result that avoided boxingok
branch, and insteaderror
branch haderror: true
so we usedresult?.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.if (!result?.error) { doSomething(result) }
has to change toif (result.ok) { doSomething(result.ok) } else { doSomethingElse(result.error) }
Result
type onok
branch no longer supports falsy values implying that all the returns that arenull
orundefined
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 wherenull
orundefined
is success branch of the result type.Capability parser's
derivse
hook used to returnResult<true, Failure>
, which changed toResult<{}, Failure>
. This is probably where most of the changes will be required, but they are pretty mechanical.Client and server no longer take transport encoder / decoder pairs. Now they take
codec
field instead that isTransport.OutboundCodec
on client andTransport.InboundCodec
on the server. That is because they can implement several formats and select one based oncontent-type
andaccept
headers. Other than passing the different field it should not really affect client / servers.Schema stuff moved from
@ucanto/validator
to@ucanto/core
although validator will still re-export it.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.The text was updated successfully, but these errors were encountered: