Repository navigation
Adopt @canup/contracts: dependency rename + shared error kernel - #27
Merged
Merged
Conversation
The shared wire-contract package was renamed. Update the dependency, all import specifiers, and the lockfile to match. Mechanical; no behavior change.
Both packages shipped their own error type — the UI a local CanupError (emitting NETWORK_ERROR, carrying a details bag) and the CLI an ApiError (field statusCode) — duplicating, and diverging from, the canonical kernel that @canup/contracts already exports. Delete both local classes and adopt the shared CanupError, unwrapResponse, toCanupError, and isCanupError. Behavior changes, with the contract as the source of truth: - Error codes are now the contract's vocabulary. The client-transport failure code is TRANSPORT_ERROR (was NETWORK_ERROR in the UI and HttpError in the CLI); neither old code exists in the contract. Server codes still pass through verbatim via the open union. - The HTTP status field is httpStatus (was the CLI's statusCode). - Response decoding goes through the contract's unwrapResponse, which also guards a non-JSON body — previously unguarded in the CLI client. Tests updated to assert the contract vocabulary (TRANSPORT_ERROR, httpStatus); they encode the adopted contract, not a behavior tweak. The kernel is bundled into each package's dist, so consumers gain no runtime dependency.
Coverage Report for @canup/ui (packages/ui)
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Coverage Report for @canup/cli (packages/cli)
File Coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings both SDK packages onto the published
@canup/contractswire-contract package and its shared error kernel.1. Depend on
@canup/contracts(renamed from@canup/types)Mechanical rename of the dependency, all import specifiers, and the lockfile. Un-breaks install (the old package name was removed from npm).
2. Adopt the shared error kernel
Both packages shipped their own error type — the UI a local
CanupError(emittingNETWORK_ERROR, carrying adetailsbag) and the CLI anApiError(fieldstatusCode) — duplicating, and diverging from, the canonical kernel@canup/contractsalready exports. Both local classes are deleted in favor of the sharedCanupError,unwrapResponse,toCanupError, andisCanupError.Behavior changes (contract is the source of truth):
TRANSPORT_ERROR(wasNETWORK_ERRORin the UI,HttpErrorin the CLI) — neither old code exists in the contract. Server codes still pass through verbatim via the open union.httpStatus(was the CLI'sstatusCode).unwrapResponse, which guards a non-JSON body — previously unguarded in the CLI client.The kernel is bundled into each package's
dist, so consumers gain no runtime dependency.Verification
test(358 cli + 115 ui),lint,typecheck,buildall green. Bundle: cli 22 kB gzip, ui 14 kB gzip.Follow-up (not in this PR)
Deduplicating the hardcoded
https://canup.linkdefault origin into a sharedCANUP_API_URLconstant is a separate change — it needs@canup/contractsrepublished (patch, 0.2.1) first.