Skip to content

Conversation

@scott-enableyou
Copy link
Collaborator

Complete device linking flow with the following features:

API Endpoints:

  • POST /api/devices/link-code - Generate 6-digit link code
  • POST /api/devices/link - Link device to family with token
  • GET /api/devices/family/{familyId} - List family devices
  • GET /api/devices/family/{familyId}/{id} - Get device details
  • PUT /api/devices/family/{familyId}/{id} - Update device
  • POST /api/devices/family/{familyId}/{id}/unlink - Unlink device
  • DELETE /api/devices/family/{familyId}/{id} - Delete device
  • POST /api/devices/family/{familyId}/{id}/heartbeat - Record heartbeat

Domain:

  • Add Unlink, Rename, UpdateSettings, Activate, Deactivate methods
  • Device entity with full lifecycle support

Application:

  • GenerateLinkCodeCommand, LinkDeviceCommand (with token)
  • GetDeviceQuery, GetFamilyDevicesQuery
  • UpdateDeviceCommand, UnlinkDeviceCommand, DeleteDeviceCommand
  • RecordHeartbeatCommand for device status tracking

DTOs:

  • LinkedDeviceDto with JWT device token
  • DeviceHeartbeatDto for heartbeat response
  • DeviceSettingsDto for device configuration

Tests:

  • Unit tests for Device entity methods
  • Application tests for command handlers and validators

Closes Phase 1.2 in roadmap

Complete device linking flow with the following features:

API Endpoints:
- POST /api/devices/link-code - Generate 6-digit link code
- POST /api/devices/link - Link device to family with token
- GET /api/devices/family/{familyId} - List family devices
- GET /api/devices/family/{familyId}/{id} - Get device details
- PUT /api/devices/family/{familyId}/{id} - Update device
- POST /api/devices/family/{familyId}/{id}/unlink - Unlink device
- DELETE /api/devices/family/{familyId}/{id} - Delete device
- POST /api/devices/family/{familyId}/{id}/heartbeat - Record heartbeat

Domain:
- Add Unlink, Rename, UpdateSettings, Activate, Deactivate methods
- Device entity with full lifecycle support

Application:
- GenerateLinkCodeCommand, LinkDeviceCommand (with token)
- GetDeviceQuery, GetFamilyDevicesQuery
- UpdateDeviceCommand, UnlinkDeviceCommand, DeleteDeviceCommand
- RecordHeartbeatCommand for device status tracking

DTOs:
- LinkedDeviceDto with JWT device token
- DeviceHeartbeatDto for heartbeat response
- DeviceSettingsDto for device configuration

Tests:
- Unit tests for Device entity methods
- Application tests for command handlers and validators

Closes Phase 1.2 in roadmap
Remove dependency on packages.lock.json which doesn't exist.
Use Directory.Packages.props and .csproj files for cache key instead.
- Add 'new' keyword to IDeviceRepository.GetByIdAsync to fix CS0108
- Add 'new' keyword to IUserRepository.GetByIdAsync to fix CS0108
- Remove --no-restore from build step to ensure packages are available
The Nanoid package v3.0+ changed its namespace from 'Nanoid' to
'NanoidDotNet'. Updated all usages across domain entities and tests.
- Add `using Xunit;` to all test files that were missing it
- Add Microsoft.Extensions.Logging.Abstractions package to Application project
  for LoggingBehavior and PerformanceBehavior classes
…ge management

Add package version to Directory.Packages.props for central package
version management compliance.
- Use fully qualified FluentValidation.ValidationException in command handlers
  to resolve ambiguity with Luminous.Application.Common.Exceptions.ValidationException
- Make LinkedDeviceDto.RefreshToken nullable to match AuthResultDto.RefreshToken
Microsoft.Azure.Cosmos requires explicit Newtonsoft.Json reference
with version >= 10.0.2. Added v13.0.3 to central package management
and Infrastructure project.
- Add using alias `User = Luminous.Domain.Entities.User` in UserRepository
  to disambiguate from Microsoft.Azure.Cosmos.User
- Add `new` keyword to GetByIdAsync in both repositories
- Fix recursive calls by using `base.GetByIdAsync()` instead
- Make familyId parameter nullable in IDeviceRepository and IUserRepository
  to match base IReadRepository<T>.GetByIdAsync signature
- Update repository implementations to match interface signatures
- Remove async from CosmosDbContext.GetDatabaseAsync (no await needed)
- Remove async from CosmosDbContext.DisposeAsync, return ValueTask.CompletedTask
The command handlers throw FluentValidation.ValidationException, not
Luminous.Application.Common.Exceptions.ValidationException.
@trickpatty trickpatty merged commit 8539b7d into main Dec 24, 2025
3 checks passed
@trickpatty trickpatty deleted the claude/implement-device-linking-PoL0w branch December 24, 2025 01:15
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.

4 participants