Skip to content

Conversation

@bra1nDump
Copy link
Contributor

Summary

  • Migrated server to use the new centralized happy-api-client package for type definitions
  • Eliminated dependency on deprecated @happy/shared-types package
  • Ensures type consistency across CLI, mobile app, and server

Changes

  • Added happy-api-client as a dependency
  • Updated sources/storage/types.ts to import types from happy-api-client
  • Fixed type import to use SessionMessageContent (encrypted) instead of DecryptedMessageContent
  • All Prisma JSON field types now properly mapped

New Package

The centralized API client is now available at: https://github.com/slopus/happy-api-client

The server uses this package for:

  • Type definitions (Session, Machine, UpdateBody, UsageReport)
  • Zod schemas for validation
  • Ensuring consistency with client applications

Benefits

  • Type Consistency: Server uses exact same types as clients
  • Single Source of Truth: Type changes propagate to all projects
  • Reduced Errors: No more type mismatches between server and clients
  • Better Validation: Shared Zod schemas ensure data integrity

Test Results

✅ TypeScript compilation successful
✅ All server tests passing (24 tests passed)
✅ Prisma generation successful with new types

E2E Testing

The new API client package includes comprehensive E2E tests that validate:

  • Authentication flow with challenge-response
  • Session creation and encryption
  • WebSocket message exchange
  • Real-time updates

This ensures the entire Happy ecosystem works together seamlessly.

🤖 Generated with Claude Code

bra1nDump and others added 5 commits August 20, 2025 01:52
- Removed local shared-types.ts copy (742 lines of duplicated code)
- Simplified types.ts to just map Prisma JSON types to shared package
- Added update-account type to shared UpdateBody union
- Added happy-api-client as a dependency
- Replaced @happy/shared-types imports with happy-api-client
- Fixed import for encrypted SessionMessageContent type
- Updated Prisma JSON type mappings to use correct types
- All TypeScript compilation successful

This change ensures the server uses the same type definitions as CLI and mobile app, maintaining consistency across the ecosystem.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced file reference with npm package version ^0.1.0
- All TypeScript compilation and tests passing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Added ConnectivityStatus enum (never_connected, online, offline)
- Added connectivity fields to Session and Machine models
- Update connectivity status when sockets connect/disconnect
- Track connectivity reason and timestamp for debugging

This allows real-time tracking of which sessions and machines are currently connected to the server.
@rrnewton
Copy link

Well, that seems like a nice change -- type safety ftw. Why didn't it happen?

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.

3 participants