@umituz/react-native-subscription 2.14.99 → 2.14.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +211 -394
- package/package.json +3 -3
- package/src/application/README.md +46 -225
- package/src/application/ports/README.md +42 -97
- package/src/domain/README.md +36 -384
- package/src/domain/constants/README.md +0 -56
- package/src/domain/entities/README.md +43 -169
- package/src/domain/entities/SubscriptionStatus.ts +1 -1
- package/src/domain/errors/README.md +33 -287
- package/src/domain/value-objects/README.md +43 -179
- package/src/domains/README.md +50 -238
- package/src/domains/README.md.bak +274 -0
- package/src/domains/config/README.md +93 -383
- package/src/domains/config/domain/README.md +23 -376
- package/src/domains/config/domain/entities/README.md +34 -343
- package/src/domains/paywall/README.md +99 -369
- package/src/domains/paywall/components/README.md +34 -178
- package/src/domains/paywall/entities/README.md +34 -193
- package/src/domains/paywall/hooks/README.md +34 -122
- package/src/domains/wallet/README.md +34 -275
- package/src/domains/wallet/README.md.bak +209 -0
- package/src/domains/wallet/domain/README.md +34 -101
- package/src/domains/wallet/domain/entities/README.md +34 -115
- package/src/domains/wallet/domain/errors/README.md +34 -151
- package/src/domains/wallet/infrastructure/README.md +34 -89
- package/src/domains/wallet/presentation/components/README.md +34 -224
- package/src/domains/wallet/presentation/components/TransactionItem.tsx +1 -1
- package/src/domains/wallet/presentation/hooks/README.md +34 -248
- package/src/infrastructure/README.md +37 -496
- package/src/infrastructure/mappers/README.md +0 -13
- package/src/infrastructure/repositories/README.md +74 -360
- package/src/infrastructure/services/ActivationHandler.ts +1 -1
- package/src/infrastructure/services/README.md +95 -370
- package/src/infrastructure/services/SubscriptionService.ts +1 -1
- package/src/presentation/README.md +123 -408
- package/src/presentation/README.md.bak +172 -0
- package/src/presentation/components/README.md +151 -179
- package/src/presentation/components/README.md.bak +217 -0
- package/src/presentation/components/details/CreditRow.md +65 -310
- package/src/presentation/components/details/DetailRow.md +63 -255
- package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
- package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
- package/src/presentation/components/details/README.md +97 -447
- package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
- package/src/presentation/components/feedback/README.md +97 -445
- package/src/presentation/components/paywall/PaywallModal.md +66 -416
- package/src/presentation/components/paywall/README.md +50 -186
- package/src/presentation/components/sections/README.md +97 -466
- package/src/presentation/components/sections/SubscriptionSection.md +92 -244
- package/src/presentation/hooks/README.md +154 -741
- package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
- package/src/presentation/hooks/useAuthGate.md +61 -375
- package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
- package/src/presentation/hooks/useCreditChecker.md +73 -378
- package/src/presentation/hooks/useCredits.md +74 -313
- package/src/presentation/hooks/useCredits.md.bak +231 -0
- package/src/presentation/hooks/useCreditsGate.md +66 -318
- package/src/presentation/hooks/useDeductCredit.md +0 -76
- package/src/presentation/hooks/useDeductCredit.ts +1 -1
- package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
- package/src/presentation/hooks/useFeatureGate.md +105 -150
- package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
- package/src/presentation/hooks/useInitializeCredits.md +64 -430
- package/src/presentation/hooks/usePaywall.md +61 -306
- package/src/presentation/hooks/usePaywallOperations.md +64 -458
- package/src/presentation/hooks/usePaywallVisibility.md +67 -316
- package/src/presentation/hooks/usePremium.md +84 -226
- package/src/presentation/hooks/usePremiumGate.md +60 -395
- package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
- package/src/presentation/hooks/useSubscription.md +66 -422
- package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
- package/src/presentation/hooks/useSubscriptionGate.md +80 -164
- package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
- package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
- package/src/presentation/hooks/useUserTier.md +63 -328
- package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
- package/src/presentation/screens/README.md +48 -190
- package/src/presentation/types/README.md +0 -16
- package/src/presentation/utils/README.md +0 -21
- package/src/presentation/utils/subscriptionDateUtils.ts +1 -1
- package/src/revenuecat/README.md +99 -518
- package/src/revenuecat/application/README.md +35 -150
- package/src/revenuecat/application/ports/README.md +34 -162
- package/src/revenuecat/domain/README.md +42 -141
- package/src/revenuecat/domain/constants/README.md +34 -176
- package/src/revenuecat/domain/entities/README.md +34 -374
- package/src/revenuecat/domain/errors/README.md +47 -191
- package/src/revenuecat/domain/types/README.md +34 -366
- package/src/revenuecat/domain/value-objects/README.md +34 -434
- package/src/revenuecat/infrastructure/README.md +34 -43
- package/src/revenuecat/infrastructure/config/README.md +32 -23
- package/src/revenuecat/infrastructure/handlers/README.md +34 -211
- package/src/revenuecat/infrastructure/managers/README.md +34 -42
- package/src/revenuecat/infrastructure/services/README.md +35 -318
- package/src/revenuecat/infrastructure/utils/README.md +34 -375
- package/src/revenuecat/presentation/README.md +34 -176
- package/src/revenuecat/presentation/hooks/README.md +29 -35
- package/src/utils/README.md +38 -525
|
@@ -2,185 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
Value objects for the subscription domain.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
## Characteristics
|
|
48
|
-
|
|
49
|
-
### 1. Immutable
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
const config = SubscriptionConfig.create({...});
|
|
53
|
-
// config.apiKey = 'new_key'; // Error: Cannot assign
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### 2. Value-Based Equality
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
const config1 = SubscriptionConfig.create({...});
|
|
60
|
-
const config2 = SubscriptionConfig.create({...});
|
|
61
|
-
|
|
62
|
-
config1.equals(config2); // true (if same values)
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### 3. Self-Validating
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
const config = SubscriptionConfig.create({
|
|
69
|
-
apiKey: '', // Invalid!
|
|
70
|
-
entitlementId: 'premium',
|
|
71
|
-
});
|
|
72
|
-
// Throws ValidationError
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Creating Value Objects
|
|
76
|
-
|
|
77
|
-
### Factory Method
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
const config = SubscriptionConfig.create({
|
|
81
|
-
apiKey: 'your_key',
|
|
82
|
-
entitlementId: 'premium',
|
|
83
|
-
});
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Builder Pattern
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
const config = SubscriptionConfig.builder()
|
|
90
|
-
.apiKey('your_key')
|
|
91
|
-
.entitlementId('premium')
|
|
92
|
-
.addPlan('monthly', monthlyPlan)
|
|
93
|
-
.addPlan('annual', annualPlan)
|
|
94
|
-
.build();
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Common Value Objects
|
|
98
|
-
|
|
99
|
-
### Money
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
class Money {
|
|
103
|
-
private constructor(
|
|
104
|
-
private amount: number,
|
|
105
|
-
private currency: string
|
|
106
|
-
) {}
|
|
107
|
-
|
|
108
|
-
static create(amount: number, currency: string): Money {
|
|
109
|
-
if (amount < 0) throw new Error('Amount cannot be negative');
|
|
110
|
-
return new Money(amount, currency);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
format(): string {
|
|
114
|
-
return new Intl.NumberFormat('en-US', {
|
|
115
|
-
style: 'currency',
|
|
116
|
-
currency: this.currency,
|
|
117
|
-
}).format(this.amount);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
add(other: Money): Money {
|
|
121
|
-
if (this.currency !== other.currency) {
|
|
122
|
-
throw new Error('Cannot add different currencies');
|
|
123
|
-
}
|
|
124
|
-
return new Money(this.amount + other.amount, this.currency);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### DateRange
|
|
130
|
-
|
|
131
|
-
```typescript
|
|
132
|
-
class DateRange {
|
|
133
|
-
constructor(
|
|
134
|
-
private start: Date,
|
|
135
|
-
private end: Date
|
|
136
|
-
) {}
|
|
137
|
-
|
|
138
|
-
includes(date: Date): boolean {
|
|
139
|
-
return date >= this.start && date <= this.end;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
durationInDays(): number {
|
|
143
|
-
return Math.ceil(
|
|
144
|
-
(this.end.getTime() - this.start.getTime()) / (1000 * 60 * 60 * 24)
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Best Practices
|
|
151
|
-
|
|
152
|
-
1. **Make immutable** - All properties readonly
|
|
153
|
-
2. **Validate on creation** - Fail fast
|
|
154
|
-
3. **Override equality** - Compare by value, not reference
|
|
155
|
-
4. **Use for complex attributes** - Don't use for simple primitives
|
|
156
|
-
5. **Keep small** - Value objects should be focused
|
|
157
|
-
|
|
158
|
-
## Testing
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
describe('SubscriptionConfig', () => {
|
|
162
|
-
it('should create valid config', () => {
|
|
163
|
-
const config = SubscriptionConfig.create({
|
|
164
|
-
apiKey: 'test_key',
|
|
165
|
-
entitlementId: 'premium',
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
expect(config.apiKey).toBe('test_key');
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('should reject invalid config', () => {
|
|
172
|
-
expect(() => {
|
|
173
|
-
SubscriptionConfig.create({
|
|
174
|
-
apiKey: '',
|
|
175
|
-
entitlementId: 'premium',
|
|
176
|
-
});
|
|
177
|
-
}).toThrow();
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## Related
|
|
5
|
+
## Location
|
|
6
|
+
|
|
7
|
+
`src/domain/value-objects/`
|
|
8
|
+
|
|
9
|
+
## Strategy
|
|
10
|
+
|
|
11
|
+
Value objects are immutable objects that represent concepts by their attributes rather than identity. They ensure validity and prevent primitive obsession by providing type-safe, validated representations.
|
|
12
|
+
|
|
13
|
+
## Restrictions
|
|
14
|
+
|
|
15
|
+
### REQUIRED
|
|
16
|
+
|
|
17
|
+
- MUST be immutable (all properties readonly)
|
|
18
|
+
- MUST validate on creation (fail fast)
|
|
19
|
+
- MUST override equality (compare by value, not reference)
|
|
20
|
+
- MUST use for complex attributes (not simple primitives)
|
|
21
|
+
- MUST be small and focused
|
|
22
|
+
|
|
23
|
+
### PROHIBITED
|
|
24
|
+
|
|
25
|
+
- MUST NOT allow mutation after creation
|
|
26
|
+
- MUST NOT use reference equality for comparison
|
|
27
|
+
- MUST NOT contain invalid states
|
|
28
|
+
- MUST NOT have identity-based equality
|
|
29
|
+
|
|
30
|
+
### CRITICAL
|
|
31
|
+
|
|
32
|
+
- Always validate on creation
|
|
33
|
+
- Implement value-based equality comparison
|
|
34
|
+
- Keep value objects small and focused
|
|
35
|
+
- Use only for complex attributes, not simple primitives
|
|
36
|
+
|
|
37
|
+
## AI Agent Guidelines
|
|
38
|
+
|
|
39
|
+
When working with value objects:
|
|
40
|
+
1. Make immutable - all properties readonly
|
|
41
|
+
2. Validate on creation - fail fast
|
|
42
|
+
3. Override equality - compare by value, not reference
|
|
43
|
+
4. Use for complex attributes - don't use for simple primitives
|
|
44
|
+
5. Keep small - value objects should be focused
|
|
45
|
+
|
|
46
|
+
## Related Documentation
|
|
183
47
|
|
|
184
48
|
- [Domain Entities](../entities/README.md)
|
|
185
49
|
- [Domain Errors](../errors/README.md)
|
|
186
|
-
- [Domain Layer](
|
|
50
|
+
- [Domain Layer](../README.md)
|
package/src/domains/README.md
CHANGED
|
@@ -1,240 +1,52 @@
|
|
|
1
1
|
# Domains
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- [Wallet Domain
|
|
49
|
-
- [
|
|
50
|
-
- [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Manages paywall display, triggers, and purchase flows.
|
|
55
|
-
|
|
56
|
-
**Key Features:**
|
|
57
|
-
- Paywall visibility management
|
|
58
|
-
- Trigger-based paywall display
|
|
59
|
-
- Package selection and comparison
|
|
60
|
-
- Purchase operations
|
|
61
|
-
- Feedback collection
|
|
62
|
-
|
|
63
|
-
**Structure:**
|
|
64
|
-
```
|
|
65
|
-
paywall/
|
|
66
|
-
├── domain/ # Business logic
|
|
67
|
-
│ └── entities/ # PaywallTrigger, PaywallConfig, PaywallState
|
|
68
|
-
├── components/ # UI components
|
|
69
|
-
│ ├── PaywallScreen/
|
|
70
|
-
│ ├── PackageCard/
|
|
71
|
-
│ └── FeatureComparison/
|
|
72
|
-
└── hooks/ # React hooks
|
|
73
|
-
└── usePaywallOperations/
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
**Triggers:**
|
|
77
|
-
- `premium_feature`: User attempts premium feature
|
|
78
|
-
- `credit_gate`: Insufficient credits
|
|
79
|
-
- `manual`: Manually triggered
|
|
80
|
-
- `onboarding_complete`: After onboarding
|
|
81
|
-
- `usage_limit`: Reached usage limit
|
|
82
|
-
|
|
83
|
-
**Related:**
|
|
84
|
-
- [Paywall Domain README](./paywall/README.md)
|
|
85
|
-
- [Paywall Entities](./paywall/entities/README.md)
|
|
86
|
-
- [Paywall Components](./paywall/components/README.md)
|
|
87
|
-
|
|
88
|
-
### Config Domain (`config/`)
|
|
89
|
-
|
|
90
|
-
Manages subscription and feature configuration.
|
|
91
|
-
|
|
92
|
-
**Key Features:**
|
|
93
|
-
- Package configuration
|
|
94
|
-
- Feature flags
|
|
95
|
-
- Subscription settings
|
|
96
|
-
- Paywall customization
|
|
97
|
-
|
|
98
|
-
**Structure:**
|
|
99
|
-
```
|
|
100
|
-
config/
|
|
101
|
-
├── domain/ # Configuration entities
|
|
102
|
-
│ ├── entities/ # Config entities
|
|
103
|
-
│ └── value-objects/ # Configuration value objects
|
|
104
|
-
└── utils/ # Configuration utilities
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
**Related:**
|
|
108
|
-
- [Config Domain README](./config/README.md)
|
|
109
|
-
|
|
110
|
-
## Architecture Principles
|
|
111
|
-
|
|
112
|
-
### 1. Domain-Driven Design (DDD)
|
|
113
|
-
Each domain represents a distinct business capability with:
|
|
114
|
-
- Clear boundaries
|
|
115
|
-
- Ubiquitous language
|
|
116
|
-
- Domain entities
|
|
117
|
-
- Business rules
|
|
118
|
-
|
|
119
|
-
### 2. Clean Architecture
|
|
120
|
-
Each domain follows layered architecture:
|
|
121
|
-
- **Domain Layer**: Business logic, entities (pure)
|
|
122
|
-
- **Application Layer**: Use cases, orchestration
|
|
123
|
-
- **Infrastructure Layer**: External integrations (persistence, APIs)
|
|
124
|
-
- **Presentation Layer**: UI components, hooks
|
|
125
|
-
|
|
126
|
-
### 3. Independence
|
|
127
|
-
Domains are independent and can:
|
|
128
|
-
- Be developed in isolation
|
|
129
|
-
- Have their own data stores
|
|
130
|
-
- Be tested independently
|
|
131
|
-
- Scale independently
|
|
132
|
-
|
|
133
|
-
### 4. Communication
|
|
134
|
-
Domains communicate through:
|
|
135
|
-
- Well-defined interfaces
|
|
136
|
-
- Events (when needed)
|
|
137
|
-
- Shared kernels (when necessary)
|
|
138
|
-
|
|
139
|
-
## Usage Patterns
|
|
140
|
-
|
|
141
|
-
### Using Wallet Domain
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
import { useCredits } from './wallet/presentation/hooks';
|
|
145
|
-
import { CreditBalanceCard } from './wallet/presentation/components';
|
|
146
|
-
|
|
147
|
-
function MyComponent() {
|
|
148
|
-
const { credits, transactions } = useCredits({ userId: user?.uid });
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<CreditBalanceCard
|
|
152
|
-
credits={credits}
|
|
153
|
-
balance={calculateBalance(credits)}
|
|
154
|
-
/>
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Using Paywall Domain
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
import { usePaywallOperations } from './paywall/hooks';
|
|
163
|
-
|
|
164
|
-
function MyScreen() {
|
|
165
|
-
const { handlePurchase } = usePaywallOperations({
|
|
166
|
-
userId: user?.uid,
|
|
167
|
-
isAnonymous: false,
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const onBuyPress = () => {
|
|
171
|
-
handlePurchase(selectedPackage);
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Using Config Domain
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
import { getPackageConfiguration } from './config/utils';
|
|
180
|
-
|
|
181
|
-
const packages = getPackageConfiguration('premium');
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Adding New Domains
|
|
185
|
-
|
|
186
|
-
When adding a new domain:
|
|
187
|
-
|
|
188
|
-
1. **Create Domain Structure**
|
|
189
|
-
```bash
|
|
190
|
-
src/domains/your-domain/
|
|
191
|
-
├── domain/
|
|
192
|
-
│ ├── entities/
|
|
193
|
-
│ ├── value-objects/
|
|
194
|
-
│ └── types/
|
|
195
|
-
├── infrastructure/
|
|
196
|
-
│ ├── repositories/
|
|
197
|
-
│ └── services/
|
|
198
|
-
└── presentation/
|
|
199
|
-
├── hooks/
|
|
200
|
-
├── components/
|
|
201
|
-
└── screens/
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
2. **Define Entities**
|
|
205
|
-
- Create core business entities
|
|
206
|
-
- Define business rules
|
|
207
|
-
- Implement validations
|
|
208
|
-
|
|
209
|
-
3. **Implement Infrastructure**
|
|
210
|
-
- Create repositories for data persistence
|
|
211
|
-
- Implement external service integrations
|
|
212
|
-
- Add mappers for data transformation
|
|
213
|
-
|
|
214
|
-
4. **Create Presentation Layer**
|
|
215
|
-
- Implement React hooks
|
|
216
|
-
- Create UI components
|
|
217
|
-
- Build screens
|
|
218
|
-
|
|
219
|
-
5. **Add Documentation**
|
|
220
|
-
- Create README for domain
|
|
221
|
-
- Document entities
|
|
222
|
-
- Provide usage examples
|
|
223
|
-
|
|
224
|
-
## Best Practices
|
|
225
|
-
|
|
226
|
-
1. **Encapsulation**: Keep domain logic isolated
|
|
227
|
-
2. **Purity**: Domain layer should have no external dependencies
|
|
228
|
-
3. **Interfaces**: Depend on abstractions, not concretions
|
|
229
|
-
4. **Testing**: Each domain should be independently testable
|
|
230
|
-
5. **Documentation**: Document business rules and entities
|
|
231
|
-
6. **Type Safety**: Use TypeScript for all domain models
|
|
232
|
-
7. **Validation**: Validate at domain boundaries
|
|
233
|
-
8. **Error Handling**: Use domain-specific errors
|
|
234
|
-
|
|
235
|
-
## Related
|
|
236
|
-
|
|
237
|
-
- [Domain Layer README](../domain/README.md)
|
|
238
|
-
- [Application Layer README](../application/README.md)
|
|
239
|
-
- [Infrastructure Layer README](../infrastructure/README.md)
|
|
240
|
-
- [RevenueCat Integration README](../revenuecat/README.md)
|
|
3
|
+
Specialized domain modules implementing specific business logic and features.
|
|
4
|
+
|
|
5
|
+
## Location
|
|
6
|
+
|
|
7
|
+
`src/domains/`
|
|
8
|
+
|
|
9
|
+
## Strategy
|
|
10
|
+
|
|
11
|
+
Implements Domain-Driven Design (DDD) principles with self-contained domains. Each domain includes domain layer (business logic, entities, value objects), infrastructure layer (external integrations, repositories), and presentation layer (domain-specific hooks and components).
|
|
12
|
+
|
|
13
|
+
## Restrictions
|
|
14
|
+
|
|
15
|
+
### REQUIRED
|
|
16
|
+
|
|
17
|
+
- Domains MUST NOT directly depend on each other
|
|
18
|
+
- MUST use well-defined interfaces between layers
|
|
19
|
+
- MUST depend on abstractions, not concretions (Dependency Inversion)
|
|
20
|
+
- All domains MUST be testable in isolation
|
|
21
|
+
|
|
22
|
+
### PROHIBITED
|
|
23
|
+
|
|
24
|
+
- MUST NOT share domain logic between domains (use shared kernel if needed)
|
|
25
|
+
- MUST NOT create circular dependencies between domains
|
|
26
|
+
- MUST NOT bypass domain layer from presentation
|
|
27
|
+
- MUST NOT expose infrastructure details to other domains
|
|
28
|
+
|
|
29
|
+
### CRITICAL
|
|
30
|
+
|
|
31
|
+
- Always validate invariants at domain boundaries
|
|
32
|
+
- Always implement domain errors for business rule violations
|
|
33
|
+
- Never allow inconsistent domain state
|
|
34
|
+
- Must implement proper transaction boundaries
|
|
35
|
+
- Always sanitize inputs from external sources
|
|
36
|
+
|
|
37
|
+
## AI Agent Guidelines
|
|
38
|
+
|
|
39
|
+
When working with domains:
|
|
40
|
+
1. Always respect domain boundaries
|
|
41
|
+
2. Always use dependency inversion
|
|
42
|
+
3. Always implement domain-specific errors
|
|
43
|
+
4. Always validate invariants at boundaries
|
|
44
|
+
5. Never create circular dependencies
|
|
45
|
+
|
|
46
|
+
## Related Documentation
|
|
47
|
+
|
|
48
|
+
- [Wallet Domain](wallet/README.md)
|
|
49
|
+
- [Paywall Domain](paywall/README.md)
|
|
50
|
+
- [Config Domain](config/README.md)
|
|
51
|
+
- [Domain Layer](../domain/README.md)
|
|
52
|
+
- [Infrastructure](../infrastructure/README.md)
|