amianthus
|
df8953248e
|
fix: 🐛 a bug where the breakdown didnt show the expires_at
|
2026-02-03 10:16:18 +00:00 |
|
John Yeo
|
d397696005
|
changed balance to always return a breakdown item
|
2025-12-29 15:54:59 -08:00 |
|
John Yeo
|
4e68c3dc9a
|
feat: created new features API version
|
2025-11-14 15:59:39 +00:00 |
|
John Yeo
|
f0e08e38e0
|
chore: openapi for v1.2 api - customers, entities, check, track
|
2025-11-13 19:43:15 +00:00 |
|
John Yeo
|
71cca85819
|
chore polishing up open api and plan methods
|
2025-11-13 12:05:16 +00:00 |
|
John Yeo
|
92510ed9c0
|
feat: deduct from redis new api schema
|
2025-11-11 16:01:14 +00:00 |
|
John Yeo
|
41c0e8e623
|
just started working on additional_balance & additional_granted_balance
|
2025-10-28 15:53:31 -07:00 |
|
John Yeo
|
dcc26b44a9
|
wip
|
2025-10-25 10:52:03 +01:00 |
|
John Yeo
|
908dd62eb1
|
feat: new versioning system
|
2025-10-08 09:16:42 +01:00 |
|
John Yeo
|
eefaf5b6c3
|
wip
|
2025-10-07 11:15:53 +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 |
|