Skip to content

feat: improve SDK ergonomics and developer experience#192

Open
IldySilva wants to merge 14 commits into
nhost:mainfrom
IldySilva:sdk/api-ergonomics
Open

feat: improve SDK ergonomics and developer experience#192
IldySilva wants to merge 14 commits into
nhost:mainfrom
IldySilva:sdk/api-ergonomics

Conversation

@IldySilva

@IldySilva IldySilva commented Jul 8, 2026

Copy link
Copy Markdown

Part 6 of the split of draft #184. Focuses on developer ergonomics and API usability improvements.

What's here

  • helper methods to make the SDK more intuitive to use.

IldySilva added 14 commits June 6, 2026 21:49
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.
@IldySilva IldySilva changed the title Sdk/api ergonomics feat: improve SDK ergonomics and developer experience Jul 8, 2026
@PVUL PVUL self-requested a review July 14, 2026 11:00
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.

1 participant