Feat/migrate new dart client#245
Conversation
Replace the hand-written thingsboard_client (4.2.1, pub.dev) with the autogenerated thingsboard_ce_client 4.4.0 referenced via local path. - Route all API access through per-controller accessors that return Response<T>, unwrapped via .data. - Construct/mutate models with the built_value builder and rebuild APIs. - Move mobile-app info to getMobileAppControllerApi (pkgName/platform). - Add a barrel (thingsboard_client.dart) that hides generated types shadowing hand-written/Flutter counterparts and re-exports the hand-written auth models, keeping the import surface stable. - Add support helpers: toPageData adapter, alarm query keys, mobile basic info, platform version, pages layout, version info, and an AlarmCommentInfo extension. - Adapt to the community client surface: UserEmailInfo in place of UserInfo, AssetInfo listing endpoints, immutable additionalInfo via a session-local dashboard-access flag, EntityType.oAUTH2CLIENT, and an authorityFromString bridge between the generated and hand-written Authority types.
…tion - Re-apply the rotated JWT pair returned by changePassword so the stored refresh token stays valid and the session is not dropped. - Fix alarm assignee lookup, comment editing, and sort ordering that regressed against the new client's data shapes.
getAuthorityName switched over the generated built_value Authority using hand-written enum constants, so no case ever matched and the role label rendered blank. Bridge the value by name before matching.
Code reviewFound 3 issues:
flutter_thingsboard_app/lib/thingsboard_client_extensions.dart Lines 10 to 13 in 19ca50c
flutter_thingsboard_app/lib/modules/asset/assets_base.dart Lines 46 to 48 in 19ca50c 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- account deletion: bridge built_value Authority via authorityFromString so the tenant/customer delete branches actually match and run - alarm activity: guard nullable AlarmCommentInfo.comment (commentNode now nullable) to avoid NPE on system-generated entries - device claiming: report success only when the claim response is not an explicit failure, instead of firing done unconditionally - 2FA: suppress the duplicate global error overlay on 429 via extra ignoreErrors, and guard a null JWT token instead of masking it with '' - noauth QR login: add connect/receive timeouts, null-safe response parsing and a clear error when the target host returns no token - asset details: navigate to '/asset/:id' to match the route (was the stale '/assets/asset/:id', so the details page never opened)
|
Addressed in a5397f1. 1. Device claim false success — no longer fires 2. flutter_thingsboard_app/lib/thingsboard_client_extensions.dart Lines 10 to 18 in a5397f1 3. Asset details route mismatch — call site now navigates to flutter_thingsboard_app/lib/modules/asset/assets_base.dart Lines 44 to 48 in a5397f1 (Left parentNavigatorKey as-is — the device detail route and PE both omit it; will revisit if the bottom nav overlays the page during testing.)
Also fixed while in these files:
|
Summary
Migrates the app from the hand-written
thingsboard_client4.2.1 to the autogeneratedthingsboard_ce_client4.4.0. The data-access layer is rebuilt on the generated client while the auth/session/storage/websocket runtime is preserved.Key changes
getAlarmService(),getDeviceService(), …) replaced by generated per-controller APIs (getAlarmControllerApi(),getDeviceControllerApi(), …); responses are now DioResponse<T>and are unwrapped via.data.built_valuemodels with all-nullable fields replace the old mutable models; call sites updated for theBuilderpattern, defensive null handling, and enumunknownDefaultOpenApifallbacks.AlarmCommentJsonNodeaccess, platform-version helpers) restored on the app side via extensions.Review fixes (commit a5397f1)
Addresses the code-review findings on this PR plus a few related regressions found alongside:
commentNodemade nullable to avoid an NPE on system-generated alarm activity.Authorityto the hand-written enum (the comparisons were previously always false → dead code)./asset/:idroute.Testing
Manual verification of the migrated flows is in progress — priority on device claiming (response contract), 2FA 429 handling, and noauth QR edge cases.