John Yeo
6d325cc7a4
refactored test suite g1 to bun
2025-10-22 22:03:52 +01:00
John Yeo
b653f46798
feat: moved some tests over to bun, writing tests for check
2025-10-22 17:47:42 +01:00
John Yeo
dc90d1dab4
feat: set up test and run tests easier
2025-10-20 10:32:26 +01:00
John Yeo
d8f6d07067
fix: update quantity flow, invoice true, account link
2025-10-14 17:53:22 +01:00
John Yeo
52ea92a5a5
chore: fix staging file
2025-10-10 10:32:00 +01:00
John Yeo
908dd62eb1
feat: new versioning system
2025-10-08 09:16:42 +01:00
John Yeo
9f734f54f3
wip
2025-10-06 20:54:08 +01:00
John Yeo
1847470403
feat: implement resource-based API versioning system with strong typing
...
## Summary
Implemented a comprehensive API versioning system with resource-level version changes,
strong typing using Zod schemas, and a composable getApi* pattern.
## Key Changes
### Versioning Infrastructure
- **VersionChange base class**: Now strongly typed with Zod schemas (TNewSchema, TOldSchema, TDataSchema)
- **Bidirectional transforms**: `transformRequest` (old→new) and `transformResponse` (new→old)
- **Input + Data pattern**: `input` for version-specific data, `data` for additional context
- **applyVersionChanges**: Fixed TypeScript errors and added biome-ignore comments for necessary `any` types
### Resource Organization
- **Folder structure**: Each resource gets its own `changes/` folder
- `shared/api/customers/changes/` - Customer-level changes
- `shared/api/customers/cusProducts/changes/` - Product-level changes
- `shared/api/customers/cusFeatures/changes/` - Feature-level changes
### Version Changes (Strongly Typed)
- **V0_2_ProductItems**: Products gained items field (V0_2+ → V0_1)
- **V1_2_FeaturesArrayToObject**: Features object ↔ array (V1_2 → V1_1)
- **V1_1_MergedResponse**: Merged customer response ↔ split (V1_1+ → V1_0)
- **V1_1_LegacyExpandInvoices**: Side-effect only (invoices auto-expand in V1_0)
### getApi* Pattern (server/src/internal/customers/cusUtils/apiCusUtils/)
- **getApiCusProduct**: Builds product in latest format, applies V0_2_ProductItems transform
- **getApiCusFeature**: Transforms balances (used→usage), applies V1_2_FeaturesArrayToObject
- **getApiCustomer**: Orchestrates products/features, merges, applies V1_1_MergedResponse
### V2 Handler Demo
- **handleGetCustomerV2**: Demonstrates zero version branching in handler
- Calls `getApiCustomer` which handles all versioning internally
- Side effects handled explicitly (expand invoices for V1_0)
## Type Safety
- All version changes use Zod schemas for input/output types
- Runtime validation with `parse()` ensures data integrity
- Compile-time type checking catches transformation errors
- Context data support via optional `data` parameter
## Benefits
✅ No scattered if-else version checks
✅ Composable resource-based architecture
✅ Strong typing with Zod schemas
✅ Self-documenting version changes
✅ Easy to add new versions
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-06 19:25:21 +01:00
John Yeo
46cc565ab7
feat: add dynamic port detection for multiple dev instances
...
Added automatic port detection to support running multiple instances of the repo simultaneously on local machines. The system detects available ports and automatically configures environment variables.
Changes:
- Created scripts/detect-ports.js for automatic port detection
- Created scripts/start-dev.js to orchestrate port detection and service startup
- Updated dev command to use new port detection system
- Modified server to use dynamic SERVER_PORT environment variable
- Modified vite config to use dynamic VITE_PORT environment variable
- Added dynamic CORS/trusted origins for ports 3000-3010 in development
- Organized setup scripts into scripts/ folder
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-06 09:23:20 +01:00