@umituz/react-native-subscription 2.14.98 → 2.14.100
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 -395
- package/package.json +1 -1
- 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/errors/README.md +33 -287
- package/src/domain/value-objects/README.md +43 -179
- package/src/domains/README.md +52 -0
- package/src/domains/README.md.bak +274 -0
- package/src/domains/config/README.md +93 -383
- package/src/domains/config/domain/README.md +37 -0
- package/src/domains/config/domain/entities/README.md +41 -0
- 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/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/README.md +95 -370
- 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 +96 -156
- 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/revenuecat/README.md +99 -518
- package/src/revenuecat/application/README.md +43 -0
- package/src/revenuecat/application/ports/README.md +41 -0
- package/src/revenuecat/domain/README.md +42 -141
- package/src/revenuecat/domain/constants/README.md +41 -0
- package/src/revenuecat/domain/entities/README.md +42 -0
- package/src/revenuecat/domain/errors/README.md +47 -191
- package/src/revenuecat/domain/types/README.md +41 -0
- package/src/revenuecat/domain/value-objects/README.md +41 -0
- package/src/revenuecat/infrastructure/README.md +41 -0
- package/src/revenuecat/infrastructure/config/README.md +32 -23
- package/src/revenuecat/infrastructure/handlers/README.md +41 -0
- package/src/revenuecat/infrastructure/managers/README.md +34 -42
- package/src/revenuecat/infrastructure/services/README.md +42 -0
- package/src/revenuecat/infrastructure/utils/README.md +41 -0
- package/src/revenuecat/presentation/README.md +42 -0
- package/src/revenuecat/presentation/hooks/README.md +29 -35
- package/src/utils/README.md +38 -525
|
@@ -2,228 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
Abonelik uygulamasının iş mantığını ve servis kontratlarını içeren katman.
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### ISubscriptionRepository
|
|
56
|
-
|
|
57
|
-
Abonelik verisi erişimi için kontrat:
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
interface ISubscriptionRepository {
|
|
61
|
-
getSubscriptionStatus(userId: string): Promise<SubscriptionStatus | null>;
|
|
62
|
-
saveSubscriptionStatus(
|
|
63
|
-
userId: string,
|
|
64
|
-
status: SubscriptionStatus
|
|
65
|
-
): Promise<void>;
|
|
66
|
-
deleteSubscriptionStatus(userId: string): Promise<void>;
|
|
67
|
-
isSubscriptionValid(status: SubscriptionStatus): boolean;
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
**Kullanım:**
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
import type { ISubscriptionRepository } from '@umituz/react-native-subscription';
|
|
75
|
-
|
|
76
|
-
class FirebaseRepository implements ISubscriptionRepository {
|
|
77
|
-
async getSubscriptionStatus(userId: string) {
|
|
78
|
-
// Firebase'den abonelik durumu getir
|
|
79
|
-
const doc = await firestore().collection('subscriptions').doc(userId).get();
|
|
80
|
-
return doc.data();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async saveSubscriptionStatus(userId: string, status: SubscriptionStatus) {
|
|
84
|
-
// Firebase'e abonelik durumu kaydet
|
|
85
|
-
await firestore().collection('subscriptions').doc(userId).set(status);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
isSubscriptionValid(status: SubscriptionStatus): boolean {
|
|
89
|
-
// Abonelik geçerliliğini kontrol et
|
|
90
|
-
return status.isActive && !isExpired(status.expirationDate);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Dependency Injection
|
|
96
|
-
|
|
97
|
-
Application layer bağımlılıkları dependency injection ile alır:
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
import { SubscriptionService } from '@umituz/react-native-subscription';
|
|
101
|
-
|
|
102
|
-
const subscriptionService = new SubscriptionService({
|
|
103
|
-
repository: myRepository,
|
|
104
|
-
onStatusChanged: (userId, newStatus) => {
|
|
105
|
-
console.log(`User ${userId} status changed to ${newStatus.type}`);
|
|
106
|
-
},
|
|
107
|
-
onError: (error) => {
|
|
108
|
-
console.error('Subscription error:', error);
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Repository Implementation
|
|
114
|
-
|
|
115
|
-
Kendi repository'nizi oluşturun:
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
import {
|
|
119
|
-
type ISubscriptionRepository,
|
|
120
|
-
SubscriptionStatus,
|
|
121
|
-
} from '@umituz/react-native-subscription';
|
|
122
|
-
|
|
123
|
-
class CustomRepository implements ISubscriptionRepository {
|
|
124
|
-
constructor(private db: Database) {}
|
|
125
|
-
|
|
126
|
-
async getSubscriptionStatus(userId: string): Promise<SubscriptionStatus | null> {
|
|
127
|
-
const data = await this.db.query(
|
|
128
|
-
'SELECT * FROM subscriptions WHERE user_id = ?',
|
|
129
|
-
[userId]
|
|
130
|
-
);
|
|
131
|
-
return data ? SubscriptionStatus.parse(data) : null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async saveSubscriptionStatus(
|
|
135
|
-
userId: string,
|
|
136
|
-
status: SubscriptionStatus
|
|
137
|
-
): Promise<void> {
|
|
138
|
-
await this.db.execute(
|
|
139
|
-
'INSERT OR REPLACE INTO subscriptions (user_id, status, expires_at) VALUES (?, ?, ?)',
|
|
140
|
-
[userId, status.type, status.expirationDate]
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async deleteSubscriptionStatus(userId: string): Promise<void> {
|
|
145
|
-
await this.db.execute(
|
|
146
|
-
'DELETE FROM subscriptions WHERE user_id = ?',
|
|
147
|
-
[userId]
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
isSubscriptionValid(status: SubscriptionStatus): boolean {
|
|
152
|
-
if (!status.isActive) return false;
|
|
153
|
-
if (!status.expirationDate) return true; // Lifetime
|
|
154
|
-
return new Date(status.expirationDate) > new Date();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## Best Practices
|
|
160
|
-
|
|
161
|
-
1. **Interface Segregation**: Küçük, odaklanmış interface'ler tanımlayın
|
|
162
|
-
2. **Dependency Inversion**: High-level modüller low-level modüllere bağımlı olmamalı
|
|
163
|
-
3. **Single Responsibility**: Her service/repository tek bir sorumluluğa sahip olmalı
|
|
164
|
-
4. **Error Handling**: Hataları uygun şekilde handle edin ve yukarı传播 edin
|
|
165
|
-
5. **Testing**: Interface'ler mock ile kolay test edilebilir
|
|
166
|
-
|
|
167
|
-
## Örnek: Service Kullanımı
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
import {
|
|
171
|
-
SubscriptionService,
|
|
172
|
-
type SubscriptionConfig,
|
|
173
|
-
} from '@umituz/react-native-subscription';
|
|
174
|
-
|
|
175
|
-
// Konfigürasyon
|
|
176
|
-
const config: SubscriptionConfig = {
|
|
177
|
-
repository: myRepository,
|
|
178
|
-
onStatusChanged: (userId, status) => {
|
|
179
|
-
// Status değiştiğinde çalışacak callback
|
|
180
|
-
analytics.track('subscription_status_changed', {
|
|
181
|
-
userId,
|
|
182
|
-
status: status.type,
|
|
183
|
-
});
|
|
184
|
-
},
|
|
185
|
-
onError: (error) => {
|
|
186
|
-
// Hata yönetimi
|
|
187
|
-
crashlytics().recordError(error);
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
// Service oluştur
|
|
192
|
-
const service = new SubscriptionService(config);
|
|
193
|
-
|
|
194
|
-
// Kullan
|
|
195
|
-
async function manageSubscription(userId: string) {
|
|
196
|
-
// Durumu kontrol et
|
|
197
|
-
const status = await service.getSubscriptionStatus(userId);
|
|
198
|
-
console.log('Current status:', status?.type);
|
|
199
|
-
|
|
200
|
-
// Premium kontrolü
|
|
201
|
-
const isPremium = await service.isPremium(userId);
|
|
202
|
-
if (!isPremium) {
|
|
203
|
-
// Aboneliği aktifleştir
|
|
204
|
-
await service.activateSubscription(
|
|
205
|
-
userId,
|
|
206
|
-
'com.app.premium.monthly',
|
|
207
|
-
'2025-01-01T00:00:00Z'
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Aboneliği iptal et
|
|
212
|
-
// await service.deactivateSubscription(userId);
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
## Type Safety
|
|
217
|
-
|
|
218
|
-
Tüm interface'ler tam tip güvenliği sağlar:
|
|
219
|
-
|
|
220
|
-
```typescript
|
|
221
|
-
// ✓ Type-safe
|
|
222
|
-
const status: SubscriptionStatus = await service.getStatus(userId);
|
|
223
|
-
|
|
224
|
-
// ✗ Compile error
|
|
225
|
-
const wrong = await service.getStatus(123);
|
|
226
|
-
|
|
227
|
-
// ✓ Type-safe repository
|
|
228
|
-
const repository: ISubscriptionRepository = new MyRepository();
|
|
229
|
-
```
|
|
5
|
+
## Location
|
|
6
|
+
|
|
7
|
+
`src/application/`
|
|
8
|
+
|
|
9
|
+
## Strategy
|
|
10
|
+
|
|
11
|
+
Ortak kullanım durumlarını gerçekleştiren, servis kontratlarını tanımlayan ve uygulama kurallarını yöneten katman. Dependency injection ve test edilebilirlik sağlar.
|
|
12
|
+
|
|
13
|
+
## Restrictions
|
|
14
|
+
|
|
15
|
+
### REQUIRED
|
|
16
|
+
|
|
17
|
+
- MUST use dependency injection pattern
|
|
18
|
+
- MUST define service contracts through interfaces
|
|
19
|
+
- MUST implement error handling and propagation
|
|
20
|
+
- MUST ensure type safety for all operations
|
|
21
|
+
- MUST support dependency inversion principle
|
|
22
|
+
|
|
23
|
+
### PROHIBITED
|
|
24
|
+
|
|
25
|
+
- MUST NOT contain direct infrastructure dependencies
|
|
26
|
+
- MUST NOT bypass repository interfaces
|
|
27
|
+
- MUST NOT leak implementation details
|
|
28
|
+
- MUST NOT mix business logic with presentation
|
|
29
|
+
|
|
30
|
+
### CRITICAL
|
|
31
|
+
|
|
32
|
+
- Keep interfaces small and focused (Interface Segregation)
|
|
33
|
+
- Maintain single responsibility for each service
|
|
34
|
+
- Always handle errors appropriately and propagate upward
|
|
35
|
+
- Ensure all operations are type-safe
|
|
36
|
+
|
|
37
|
+
## AI Agent Guidelines
|
|
38
|
+
|
|
39
|
+
When working with application layer:
|
|
40
|
+
1. Interface Segregation - küçük, odaklanmış interface'ler tanımlayın
|
|
41
|
+
2. Dependency Inversion - high-level modüller low-level modüllere bağımlı olmamalı
|
|
42
|
+
3. Single Responsibility - her service/repository tek bir sorumluluğa sahip olmalı
|
|
43
|
+
4. Error Handling - hataları uygun şekilde handle edin ve yukarı propagation edin
|
|
44
|
+
5. Testing - interface'ler mock ile kolay test edilebilir
|
|
45
|
+
|
|
46
|
+
## Related Documentation
|
|
47
|
+
|
|
48
|
+
- [Domain Layer](../domain/README.md)
|
|
49
|
+
- [Infrastructure Layer](../infrastructure/README.md)
|
|
50
|
+
- [Ports](./ports/README.md)
|
|
@@ -2,102 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
Interfaces defining contracts between application layer and external dependencies.
|
|
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
|
-
getCredits(userId: string): Promise<UserCredits | null>;
|
|
48
|
-
initializeCredits(
|
|
49
|
-
userId: string,
|
|
50
|
-
purchaseId?: string,
|
|
51
|
-
productId?: string
|
|
52
|
-
): Promise<CreditsResult>;
|
|
53
|
-
deductCredit(userId: string, amount: number): Promise<CreditsResult>;
|
|
54
|
-
addCredits(userId: string, amount: number): Promise<CreditsResult>;
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Usage in Application Layer
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
import type { ISubscriptionService } from '../application/ports/ISubscriptionService';
|
|
62
|
-
|
|
63
|
-
class SubscriptionManager {
|
|
64
|
-
constructor(private service: ISubscriptionService) {}
|
|
65
|
-
|
|
66
|
-
async manageSubscription(userId: string) {
|
|
67
|
-
// Port interface enables swapping implementations
|
|
68
|
-
const status = await this.service.getSubscriptionStatus(userId);
|
|
69
|
-
return status;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Testing with Mocks
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
const mockService: ISubscriptionService = {
|
|
78
|
-
getSubscriptionStatus: async (userId) => ({
|
|
79
|
-
productId: 'premium',
|
|
80
|
-
isActive: true,
|
|
81
|
-
type: 'premium',
|
|
82
|
-
expirationDate: null,
|
|
83
|
-
}),
|
|
84
|
-
activateSubscription: async () => ({} as any),
|
|
85
|
-
deactivateSubscription: async () => {},
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// Use mock in tests
|
|
89
|
-
const manager = new SubscriptionManager(mockService);
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Best Practices
|
|
93
|
-
|
|
94
|
-
1. **Interface Segregation** - Keep interfaces focused
|
|
95
|
-
2. **Clear Contracts** - Document behavior thoroughly
|
|
96
|
-
3. **Return Types** - Use domain entities in return types
|
|
97
|
-
4. **Async Operations** - All I/O operations should be async
|
|
98
|
-
|
|
99
|
-
## Related
|
|
100
|
-
|
|
101
|
-
- [Application README](../README.md)
|
|
5
|
+
## Location
|
|
6
|
+
|
|
7
|
+
`src/application/ports/`
|
|
8
|
+
|
|
9
|
+
## Strategy
|
|
10
|
+
|
|
11
|
+
Port interfaces define how the application layer interacts with external services and repositories, enabling dependency inversion and testability through clear contracts.
|
|
12
|
+
|
|
13
|
+
## Restrictions
|
|
14
|
+
|
|
15
|
+
### REQUIRED
|
|
16
|
+
|
|
17
|
+
- MUST use interface segregation (keep interfaces focused)
|
|
18
|
+
- MUST document behavior thoroughly
|
|
19
|
+
- MUST use domain entities in return types
|
|
20
|
+
- MUST make all I/O operations async
|
|
21
|
+
- MUST define clear contracts between layers
|
|
22
|
+
|
|
23
|
+
### PROHIBITED
|
|
24
|
+
|
|
25
|
+
- MUST NOT couple interfaces to specific implementations
|
|
26
|
+
- MUST NOT include infrastructure concerns in port definitions
|
|
27
|
+
- MUST NOT leak implementation details through interfaces
|
|
28
|
+
|
|
29
|
+
### CRITICAL
|
|
30
|
+
|
|
31
|
+
- Keep interfaces focused and segregated
|
|
32
|
+
- Document all behavior thoroughly
|
|
33
|
+
- Use domain entities in return types
|
|
34
|
+
- Ensure all I/O operations are async
|
|
35
|
+
|
|
36
|
+
## AI Agent Guidelines
|
|
37
|
+
|
|
38
|
+
When working with application ports:
|
|
39
|
+
1. Interface Segregation - keep interfaces focused
|
|
40
|
+
2. Clear Contracts - document behavior thoroughly
|
|
41
|
+
3. Return Types - use domain entities in return types
|
|
42
|
+
4. Async Operations - all I/O operations should be async
|
|
43
|
+
|
|
44
|
+
## Related Documentation
|
|
45
|
+
|
|
46
|
+
- [Application Layer](../README.md)
|
|
102
47
|
- [Infrastructure Services](../../infrastructure/services/README.md)
|
|
103
48
|
- [Infrastructure Repositories](../../infrastructure/repositories/README.md)
|