@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.
Files changed (92) hide show
  1. package/README.md +211 -395
  2. package/package.json +1 -1
  3. package/src/application/README.md +46 -225
  4. package/src/application/ports/README.md +42 -97
  5. package/src/domain/README.md +36 -384
  6. package/src/domain/constants/README.md +0 -56
  7. package/src/domain/entities/README.md +43 -169
  8. package/src/domain/errors/README.md +33 -287
  9. package/src/domain/value-objects/README.md +43 -179
  10. package/src/domains/README.md +52 -0
  11. package/src/domains/README.md.bak +274 -0
  12. package/src/domains/config/README.md +93 -383
  13. package/src/domains/config/domain/README.md +37 -0
  14. package/src/domains/config/domain/entities/README.md +41 -0
  15. package/src/domains/paywall/README.md +99 -369
  16. package/src/domains/paywall/components/README.md +34 -178
  17. package/src/domains/paywall/entities/README.md +34 -193
  18. package/src/domains/paywall/hooks/README.md +34 -122
  19. package/src/domains/wallet/README.md +34 -275
  20. package/src/domains/wallet/README.md.bak +209 -0
  21. package/src/domains/wallet/domain/README.md +34 -101
  22. package/src/domains/wallet/domain/entities/README.md +34 -115
  23. package/src/domains/wallet/domain/errors/README.md +34 -151
  24. package/src/domains/wallet/infrastructure/README.md +34 -89
  25. package/src/domains/wallet/presentation/components/README.md +34 -224
  26. package/src/domains/wallet/presentation/hooks/README.md +34 -248
  27. package/src/infrastructure/README.md +37 -496
  28. package/src/infrastructure/mappers/README.md +0 -13
  29. package/src/infrastructure/repositories/README.md +74 -360
  30. package/src/infrastructure/services/README.md +95 -370
  31. package/src/presentation/README.md +123 -408
  32. package/src/presentation/README.md.bak +172 -0
  33. package/src/presentation/components/README.md +151 -179
  34. package/src/presentation/components/README.md.bak +217 -0
  35. package/src/presentation/components/details/CreditRow.md +65 -310
  36. package/src/presentation/components/details/DetailRow.md +63 -255
  37. package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
  38. package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
  39. package/src/presentation/components/details/README.md +97 -447
  40. package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
  41. package/src/presentation/components/feedback/README.md +97 -445
  42. package/src/presentation/components/paywall/PaywallModal.md +66 -416
  43. package/src/presentation/components/paywall/README.md +50 -186
  44. package/src/presentation/components/sections/README.md +97 -466
  45. package/src/presentation/components/sections/SubscriptionSection.md +92 -244
  46. package/src/presentation/hooks/README.md +154 -741
  47. package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
  48. package/src/presentation/hooks/useAuthGate.md +61 -375
  49. package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
  50. package/src/presentation/hooks/useCreditChecker.md +73 -378
  51. package/src/presentation/hooks/useCredits.md +74 -313
  52. package/src/presentation/hooks/useCredits.md.bak +231 -0
  53. package/src/presentation/hooks/useCreditsGate.md +66 -318
  54. package/src/presentation/hooks/useDeductCredit.md +96 -156
  55. package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
  56. package/src/presentation/hooks/useFeatureGate.md +105 -150
  57. package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
  58. package/src/presentation/hooks/useInitializeCredits.md +64 -430
  59. package/src/presentation/hooks/usePaywall.md +61 -306
  60. package/src/presentation/hooks/usePaywallOperations.md +64 -458
  61. package/src/presentation/hooks/usePaywallVisibility.md +67 -316
  62. package/src/presentation/hooks/usePremium.md +84 -226
  63. package/src/presentation/hooks/usePremiumGate.md +60 -395
  64. package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
  65. package/src/presentation/hooks/useSubscription.md +66 -422
  66. package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
  67. package/src/presentation/hooks/useSubscriptionGate.md +80 -164
  68. package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
  69. package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
  70. package/src/presentation/hooks/useUserTier.md +63 -328
  71. package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
  72. package/src/presentation/screens/README.md +48 -190
  73. package/src/presentation/types/README.md +0 -16
  74. package/src/presentation/utils/README.md +0 -21
  75. package/src/revenuecat/README.md +99 -518
  76. package/src/revenuecat/application/README.md +43 -0
  77. package/src/revenuecat/application/ports/README.md +41 -0
  78. package/src/revenuecat/domain/README.md +42 -141
  79. package/src/revenuecat/domain/constants/README.md +41 -0
  80. package/src/revenuecat/domain/entities/README.md +42 -0
  81. package/src/revenuecat/domain/errors/README.md +47 -191
  82. package/src/revenuecat/domain/types/README.md +41 -0
  83. package/src/revenuecat/domain/value-objects/README.md +41 -0
  84. package/src/revenuecat/infrastructure/README.md +41 -0
  85. package/src/revenuecat/infrastructure/config/README.md +32 -23
  86. package/src/revenuecat/infrastructure/handlers/README.md +41 -0
  87. package/src/revenuecat/infrastructure/managers/README.md +34 -42
  88. package/src/revenuecat/infrastructure/services/README.md +42 -0
  89. package/src/revenuecat/infrastructure/utils/README.md +41 -0
  90. package/src/revenuecat/presentation/README.md +42 -0
  91. package/src/revenuecat/presentation/hooks/README.md +29 -35
  92. 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
- ## Sorumluluklar
6
-
7
- - **Service Contracts**: Servis arayüzlerini tanımlama
8
- - **Use Cases**: İş kullanım durumlarını gerçekleştirme
9
- - **Business Logic**: Uygulama kurallarını yönetme
10
-
11
- ## Yapı
12
-
13
- ```
14
- application/
15
- ├── ports/
16
- │ ├── ISubscriptionService.ts # Subscription servisi kontratı
17
- │ └── ISubscriptionRepository.ts # Repository kontratı
18
- └── [future use cases]
19
- ```
20
-
21
- ## Port Interfaces
22
-
23
- ### ISubscriptionService
24
-
25
- Abonelik servisi için ana kontrat:
26
-
27
- ```typescript
28
- interface ISubscriptionService {
29
- getStatus(userId: string): Promise<SubscriptionStatus | null>;
30
- activateSubscription(
31
- userId: string,
32
- productId: string,
33
- expiresAt: string | null
34
- ): Promise<SubscriptionStatus>;
35
- deactivateSubscription(userId: string): Promise<SubscriptionStatus>;
36
- isPremium(userId: string): Promise<boolean>;
37
- }
38
- ```
39
-
40
- **Kullanım:**
41
-
42
- ```typescript
43
- import type { ISubscriptionService } from '@umituz/react-native-subscription';
44
-
45
- class MyService {
46
- constructor(private subscriptionService: ISubscriptionService) {}
47
-
48
- async checkUserAccess(userId: string) {
49
- const isPremium = await this.subscriptionService.isPremium(userId);
50
- return isPremium;
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
- ## Overview
6
-
7
- This directory contains port interfaces that define how the application layer interacts with external services and repositories. This enables dependency inversion and testability.
8
-
9
- ## Ports
10
-
11
- ### ISubscriptionService
12
- Port for subscription management service.
13
-
14
- ```typescript
15
- interface ISubscriptionService {
16
- getSubscriptionStatus(userId: string): Promise<SubscriptionStatus | null>;
17
- activateSubscription(
18
- userId: string,
19
- productId: string,
20
- expiresAt: string | null
21
- ): Promise<SubscriptionStatus | null>;
22
- deactivateSubscription(userId: string): Promise<void>;
23
- }
24
- ```
25
-
26
- **Implementation:** Infrastructure services implement this interface.
27
-
28
- ### ISubscriptionRepository
29
- Port for subscription data persistence.
30
-
31
- ```typescript
32
- interface ISubscriptionRepository {
33
- getSubscriptionStatus(userId: string): Promise<SubscriptionStatus | null>;
34
- saveSubscriptionStatus(userId: string, status: SubscriptionStatus): Promise<void>;
35
- deleteSubscriptionStatus(userId: string): Promise<void>;
36
- isSubscriptionValid(status: SubscriptionStatus | null): boolean;
37
- }
38
- ```
39
-
40
- **Implementation:** Infrastructure repositories implement this interface.
41
-
42
- ### ICreditsRepository
43
- Port for credits data persistence.
44
-
45
- ```typescript
46
- interface ICreditsRepository {
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)