feat: improve SDK ergonomics and developer experience#192
Open
IldySilva wants to merge 14 commits into
Open
Conversation
chore: expand gitignore for generated files
fix: redact auth tokens in string output
feat: add nhost_flutter package with auth DX and partial auth api
Replaces raw AuthResponse nullable-field inspection with a sealed class: - SignInSuccess — session is active, user is available - SignInNeedsMfa — server returned an MFA ticket; pass to completeMfaSignIn() - SignInNeedsEmailVerification — session is null because email is unverified; the previously silent/ambiguous case now has an explicit type NhostAuthClientSignInX.signIn() wraps signInEmailPassword() and maps the response. Failures (wrong password, network error) still throw ApiException. Example app updated: _SignInScreen now uses signIn() with an exhaustive switch, navigates to a new _MfaScreen on SignInNeedsMfa, and shows a snackbar with a Resend action on SignInNeedsEmailVerification. 5 tests added covering all three result variants plus exception propagation.
…ption ApiException now exposes structured fields without dynamic casts: - errorCode — body['error'] (e.g. "invalid-request", "email-already-in-use") - errorMessage — body['message'] (human-readable server message) - isUnauthorized, isForbidden, isNotFound, isValidationError, isServerError NhostNetworkException extends NhostException and wraps SocketException, TimeoutException, and any other connection-level failure thrown by ApiClient. Callers no longer need to catch raw Dart exceptions separately. All Nhost errors now share a type hierarchy rooted at NhostException: NhostException ├── ApiException (server responded with 4xx/5xx) └── NhostNetworkException (no connection, DNS failure, timeout) NhostException and NhostNetworkException exported through nhost_dart barrel. Example app updated to use errorMessage and handle NhostNetworkException. 13 tests added covering all new fields and both exception types.
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.
Part 6 of the split of draft #184. Focuses on developer ergonomics and API usability improvements.
What's here