Assist_Design/docs/_archive/migration/RESTRUCTURE-PROGRESS.md

133 lines
3.7 KiB
Markdown
Raw Normal View History

# Domain Restructure - Progress Report
**Date**: October 3, 2025
**Status**: 🚧 In Progress (75% Complete)
---
## ✅ Completed Domains
### 1. **Billing** ✅
```
domain/billing/
├── contract.ts ✅ Invoice, InvoiceStatus, INVOICE_STATUS
├── schema.ts ✅ invoiceSchema, invoiceListSchema
├── index.ts ✅
└── providers/whmcs/
├── raw.types.ts ✅ WhmcsInvoiceRaw
└── mapper.ts ✅ transformWhmcsInvoice()
```
### 2. **Subscriptions** ✅
```
domain/subscriptions/
├── contract.ts ✅ Subscription, SubscriptionStatus, SUBSCRIPTION_STATUS
├── schema.ts ✅ subscriptionSchema
├── index.ts ✅
└── providers/whmcs/
├── raw.types.ts ✅ WhmcsProductRaw
└── mapper.ts ✅ transformWhmcsSubscription()
```
### 3. **Payments** ✅
```
domain/payments/
├── contract.ts ✅ PaymentMethod, PaymentGateway
├── schema.ts ✅ paymentMethodSchema, paymentGatewaySchema
├── index.ts ✅
└── providers/whmcs/
├── raw.types.ts ✅ WhmcsPaymentMethodRaw
└── mapper.ts ✅ transformWhmcsPaymentMethod()
```
### 4. **SIM** ✅
```
domain/sim/
├── contract.ts ✅ SimDetails, SimUsage, SimTopUpHistory
├── schema.ts ✅ simDetailsSchema, simUsageSchema
├── index.ts ✅
└── providers/freebit/
├── raw.types.ts ✅ FreebitAccountDetailsRaw
└── mapper.ts ✅ transformFreebitAccountDetails()
```
---
## 🚧 Remaining Work
### 5. **Orders** (In Progress)
- [ ] contract.ts - Order, OrderItem, FulfillmentOrderDetails
- [ ] schema.ts
- [ ] providers/salesforce/ - Read orders
- [ ] providers/whmcs/ - Create orders
### 6. **Catalog**
- [ ] contract.ts - CatalogProduct, SimCatalogProduct
- [ ] schema.ts
- [ ] providers/salesforce/
### 7. **Common**
- [ ] types.ts - Address, Money, BaseEntity
- [ ] identifiers.ts - UserId, OrderId, etc.
- [ ] api.ts - ApiResponse, PaginatedResponse
- [ ] schema.ts
### 8. **Toolkit**
- [ ] formatting/currency.ts
- [ ] validation/helpers.ts
- [ ] typing/patterns.ts
---
## 📦 Package Updates Needed
- [ ] Update `packages/domain/package.json` exports
- [ ] Update `packages/domain/tsconfig.json`
- [ ] Update BFF `tsconfig.json` paths
- [ ] Update Portal `tsconfig.json` paths
---
## 🔄 Migration Steps Remaining
1. [ ] Finish creating all domains
2. [ ] Update package.json with new exports
3. [ ] Update tsconfig paths
4. [ ] Create migration script for imports (optional)
5. [ ] Update sample imports in BFF (1-2 files as examples)
6. [ ] Update sample imports in Portal (1-2 files as examples)
7. [ ] Build and verify compilation
8. [ ] Update documentation
---
## 🎯 New Import Patterns (Examples)
### Current (Old)
```typescript
import { Invoice } from "@customer-portal/contracts/billing";
import { invoiceSchema } from "@customer-portal/schemas/billing";
import { transformWhmcsInvoice } from "@customer-portal/integrations-whmcs/mappers";
```
### New (Domain-First)
```typescript
import { Invoice, invoiceSchema, INVOICE_STATUS } from "@customer-portal/domain/billing";
import { transformWhmcsInvoice } from "@customer-portal/domain/billing/providers/whmcs/mapper";
```
---
## ✨ Benefits Achieved
1. ✅ Domain-centric organization
2. ✅ Co-located contracts + schemas
3. ✅ Provider isolation (no leaking)
4. ✅ Single package (`@customer-portal/domain`)
5. ✅ Scalable provider pattern
---
**Next Steps**: Complete orders, catalog, common, toolkit, then package configuration.