amianthus
3efc82d88d
fix: 🐛 imports
2025-10-08 18:46:51 +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
John Yeo
feca672fab
working on get api cus feature
2025-10-06 14:16:51 +01:00
John Yeo
e7a78bfc8d
working on api versioning system
2025-10-06 10:03:12 +01:00
John Yeo
788fa32313
fix: added past due status to cus product
2025-10-03 20:00:27 +01:00
John Yeo
ee662e9c65
fix: v1.1 customer schema
2025-10-03 18:12:23 +01:00
John Yeo
9ab609d870
feat: added api / openapi models to shared folder
2025-10-03 11:57:40 +01:00
John Yeo
9b6f57f872
feat: Add OpenAPI schemas for Features, Entities, Core, and Customers (ENG-628)
...
- Created operation models and OpenAPI specs for Features (Create, Update, List, Get, Delete)
- Created operation models and OpenAPI specs for Entities (Create, List, Get, Delete)
- Created operation models and OpenAPI specs for Core endpoints (Cancel, Track, Query)
- Created operation models and OpenAPI specs for Customers (Create, Update, List, Get, Delete)
- Fixed bug: Added 'archived' field to UpdateProductV2Params
- Fixed enum usage: Changed z.enum() to z.nativeEnum() for TypeScript enums
- Updated all OpenAPI specs to use requestParams format (path/query with zod schemas)
- Created shared SuccessResponseSchema in common/commonResponses.ts
- Updated models.ts to export all new schemas and OpenAPI operations
- Changed OpenAPI export to JSON format (YAML export has serialization issues with zod schemas)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-02 14:55:58 +01:00
John Yeo
fd7361b0bd
fix: api customer schema
2025-10-02 13:48:01 +01:00
John Yeo
96e0e8c2ce
feat: created api product and api feature zod schemas
2025-09-30 19:08:50 +01:00
John Yeo
8778057e6f
chore: creating shared/api structure
2025-09-30 13:52:43 +01:00