@umituz/react-native-subscription 2.14.99 → 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 -394
  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 +50 -238
  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 +23 -376
  14. package/src/domains/config/domain/entities/README.md +34 -343
  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 +0 -76
  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 +35 -150
  77. package/src/revenuecat/application/ports/README.md +34 -162
  78. package/src/revenuecat/domain/README.md +42 -141
  79. package/src/revenuecat/domain/constants/README.md +34 -176
  80. package/src/revenuecat/domain/entities/README.md +34 -374
  81. package/src/revenuecat/domain/errors/README.md +47 -191
  82. package/src/revenuecat/domain/types/README.md +34 -366
  83. package/src/revenuecat/domain/value-objects/README.md +34 -434
  84. package/src/revenuecat/infrastructure/README.md +34 -43
  85. package/src/revenuecat/infrastructure/config/README.md +32 -23
  86. package/src/revenuecat/infrastructure/handlers/README.md +34 -211
  87. package/src/revenuecat/infrastructure/managers/README.md +34 -42
  88. package/src/revenuecat/infrastructure/services/README.md +35 -318
  89. package/src/revenuecat/infrastructure/utils/README.md +34 -375
  90. package/src/revenuecat/presentation/README.md +34 -176
  91. package/src/revenuecat/presentation/hooks/README.md +29 -35
  92. package/src/utils/README.md +38 -525
@@ -1,390 +1,100 @@
1
1
  # Config Domain
2
2
 
3
- Abonelik planları, ürün konfigürasyonları ve paket yönetimi için merkezi konfigürasyon sistemi.
3
+ Central configuration system for subscription plans, product configurations, and package management.
4
4
 
5
- ## Özellikler
5
+ ## Location
6
6
 
7
- - **Plan Yönetimi**: Aylık, yıllık ve_lifetime plan konfigürasyonları
8
- - **Ürün Metadata**: RevenueCat ürünleri için metadata yönetimi
9
- - **Validasyon**: Konfigürasyon validasyonu ve tip güvenliği
10
- - **Helper Fonksiyonlar**: Plan karşılaştırma ve filtreleme araçları
11
-
12
- ## Temel Kavramlar
13
-
14
- ### Plan (Plan Entity)
15
-
16
- Abonelik planını temsil eden temel entity:
7
+ - **Base Path**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/domains/config/`
8
+ - **Domain**: `src/domains/config/domain/`
9
+ - **Entities**: `src/domains/config/domain/entities/`
17
10
 
18
- ```typescript
19
- import { Plan } from '@umituz/react-native-subscription';
20
-
21
- interface Plan {
22
- id: string; // 'premium_monthly'
23
- productId: string; // RevenueCat product ID
24
- period: 'monthly' | 'annual' | 'lifetime';
25
- price: number; // Fiyat (kusur Sayı)
26
- currency: string; // 'USD', 'EUR', 'TRY'
27
- credits?: number; // İlk kredi miktarı
28
- features: string[]; // ['feature1', 'feature2']
29
- metadata?: Record<string, any>;
30
- }
31
- ```
11
+ ## Strategy
32
12
 
33
- ## Kullanım
34
-
35
- ### Plan Oluşturma
36
-
37
- ```typescript
38
- import { Plan } from '@umituz/react-native-subscription';
39
-
40
- const monthlyPlan = Plan.create({
41
- id: 'premium_monthly',
42
- productId: 'com.app.premium.monthly',
43
- period: 'monthly',
44
- price: 9.99,
45
- currency: 'USD',
46
- credits: 100,
47
- features: ['unlimited_access', 'ai_tools', 'no_ads'],
48
- metadata: {
49
- popular: false,
50
- discount: 0,
51
- },
52
- });
13
+ ### Plan Management
53
14
 
54
- const annualPlan = Plan.create({
55
- id: 'premium_annual',
56
- productId: 'com.app.premium.annual',
57
- period: 'annual',
58
- price: 79.99,
59
- currency: 'USD',
60
- credits: 1200,
61
- features: ['unlimited_access', 'ai_tools', 'no_ads', 'priority_support'],
62
- metadata: {
63
- popular: true,
64
- discount: 33, // 33% indirim
65
- savings: 39.89,
66
- },
67
- });
68
- ```
69
-
70
- ### Plan Karşılaştırma
71
-
72
- ```typescript
73
- import { Plan } from '@umituz/react-native-subscription';
74
-
75
- // Planları karşılaştır
76
- const isAnnualBetter = annualPlan.isBetterValueThan(monthlyPlan); // true
77
-
78
- // Aylık eşdeğer fiyatı hesapla
79
- const monthlyEquivalent = annualPlan.getMonthlyEquivalent(); // 6.67
80
-
81
- // Tasarruf hesapla
82
- const savings = annualPlan.calculateSavings(monthlyPlan); // 39.89
83
- ```
84
-
85
- ### Plan Filtreleme
86
-
87
- ```typescript
88
- import { filterPlans, sortByPrice, sortByPeriod } from '@umituz/react-native-subscription';
89
-
90
- const plans = [monthlyPlan, annualPlan, lifetimePlan];
91
-
92
- // Periyoda göre filtrele
93
- const subscriptionPlans = filterPlans(plans, { period: ['monthly', 'annual'] });
94
-
95
- // Fiyata göre sırala
96
- const sortedByPrice = sortByPrice(plans, 'asc');
97
-
98
- // Özelliklere göre filtrele
99
- const plansWithAI = filterPlans(plans, { features: ['ai_tools'] });
100
- ```
101
-
102
- ## Helper Fonksiyonlar
103
-
104
- ### Plan Helpers
105
-
106
- ```typescript
107
- import {
108
- getPlanPeriod,
109
- isSubscriptionPlan,
110
- isLifetimePlan,
111
- formatPrice,
112
- calculateDiscount,
113
- } from '@umituz/react-native-subscription';
114
-
115
- // Plan periyodunu al
116
- const period = getPlanPeriod(plan); // 'monthly'
117
-
118
- // Plan tipi kontrolü
119
- const isSubscription = isSubscriptionPlan(plan); // true
120
- const isLifetime = isLifetimePlan(plan); // false
121
-
122
- // Fiyat formatlama
123
- const formatted = formatPrice(9.99, 'USD'); // '$9.99'
124
- const formattedTRY = formatPrice(99.99, 'TRY'); // '99,99 ₺'
125
-
126
- // İndirim hesaplama
127
- const discount = calculateDiscount(originalPrice, discountedPrice); // 20
128
- ```
129
-
130
- ### Package Helpers
131
-
132
- ```typescript
133
- import {
134
- getPackageType,
135
- isSubscriptionPackage,
136
- isInAppPurchase,
137
- extractPackagePeriod,
138
- filterPackagesByType,
139
- } from '@umituz/react-native-subscription';
140
-
141
- // Paket tipi belirleme
142
- const type = getPackageType(revenueCatPackage); // 'MONTHLY'
143
-
144
- // Paket filtreleme
145
- const subscriptions = filterPackagesByType(packages, 'subscription');
146
- const inAppPurchases = filterPackagesByType(packages, 'inapp');
147
-
148
- // Periyot çıkarma
149
- const period = extractPackagePeriod('com.app.premium.monthly'); // 'monthly'
150
- ```
151
-
152
- ## Validasyon
153
-
154
- ### Plan Validasyonu
155
-
156
- ```typescript
157
- import { Plan } from '@umituz/react-native-subscription';
158
-
159
- try {
160
- const plan = Plan.create({
161
- id: 'premium_monthly',
162
- productId: 'com.app.premium.monthly',
163
- period: 'monthly',
164
- price: -9.99, // Invalid: negatif fiyat
165
- currency: 'USD',
166
- });
167
- } catch (error) {
168
- console.error('Validation error:', error.message);
169
- }
170
- ```
171
-
172
- ### Config Validasyonu
173
-
174
- ```typescript
175
- import {
176
- validatePlanConfig,
177
- validatePackageConfig,
178
- type ValidationError,
179
- } from '@umituz/react-native-subscription';
180
-
181
- const validation = validatePlanConfig({
182
- plans: [monthlyPlan, annualPlan],
183
- defaultPlanId: 'premium_monthly',
184
- });
185
-
186
- if (!validation.isValid) {
187
- validation.errors.forEach((error: ValidationError) => {
188
- console.error(`Field: ${error.field}, Message: ${error.message}`);
189
- });
190
- }
191
- ```
192
-
193
- ## Konfigürasyon Nesneleri
194
-
195
- ### SubscriptionConfig
196
-
197
- ```typescript
198
- import { SubscriptionConfig } from '@umituz/react-native-subscription';
199
-
200
- const config: SubscriptionConfig = {
201
- revenueCatApiKey: 'your_api_key',
202
- revenueCatEntitlementId: 'premium',
203
-
204
- plans: {
205
- monthly: monthlyPlan,
206
- annual: annualPlan,
207
- lifetime: lifetimePlan,
208
- },
209
-
210
- defaultPlan: 'monthly',
211
-
212
- features: {
213
- requireAuth: true,
214
- allowRestore: true,
215
- syncWithFirebase: true,
216
- },
217
-
218
- ui: {
219
- showAnnualDiscount: true,
220
- highlightPopularPlan: true,
221
- showPerks: true,
222
- },
223
- };
224
- ```
225
-
226
- ### WalletConfig
227
-
228
- ```typescript
229
- import { WalletConfig } from '@umituz/react-native-subscription';
230
-
231
- const walletConfig: WalletConfig = {
232
- initialCredits: 100,
233
-
234
- creditPackages: [
235
- {
236
- id: 'credits_small',
237
- productId: 'com.app.credits.small',
238
- amount: 100,
239
- price: 0.99,
240
- },
241
- {
242
- id: 'credits_medium',
243
- productId: 'com.app.credits.medium',
244
- amount: 500,
245
- price: 3.99,
246
- },
247
- ],
248
-
249
- creditCosts: {
250
- ai_generation: 1,
251
- ai_analysis: 2,
252
- premium_feature: 5,
253
- },
254
-
255
- expiration: {
256
- enabled: true,
257
- daysUntilExpiration: 365,
258
- },
259
- };
260
- ```
261
-
262
- ## Best Practices
263
-
264
- 1. **Tip Güvenliği**: Her zaman tip tanımlamalarını kullanın
265
- 2. **Validasyon**: Konfigürasyonları çalıştırmadan önce doğrulayın
266
- 3. **Default Değerler**: Anlamlı default değerler sağlayın
267
- 4. **Immutable**: Plan objelerini değiştirmek yerine yeni kopyalar oluşturun
268
- 5. **Environment**: Farklı ortamlar için farklı konfigürasyonlar kullanın
269
-
270
- ## Örnek Uygulama
271
-
272
- ```typescript
273
- import {
274
- Plan,
275
- SubscriptionConfig,
276
- validatePlanConfig,
277
- formatPrice,
278
- calculateDiscount,
279
- } from '@umituz/react-native-subscription';
280
-
281
- // 1. Planları tanımlayın
282
- const plans = {
283
- monthly: Plan.create({
284
- id: 'premium_monthly',
285
- productId: 'com.app.premium.monthly',
286
- period: 'monthly',
287
- price: 9.99,
288
- currency: 'USD',
289
- credits: 100,
290
- features: ['unlimited_access', 'ai_tools'],
291
- }),
292
-
293
- annual: Plan.create({
294
- id: 'premium_annual',
295
- productId: 'com.app.premium.annual',
296
- period: 'annual',
297
- price: 79.99,
298
- currency: 'USD',
299
- credits: 1200,
300
- features: ['unlimited_access', 'ai_tools', 'priority_support'],
301
- metadata: { discount: 33, popular: true },
302
- }),
303
- };
304
-
305
- // 2. Konfigürasyonu oluşturun
306
- const config: SubscriptionConfig = {
307
- revenueCatApiKey: process.env.REVENUECAT_API_KEY,
308
- revenueCatEntitlementId: 'premium',
309
- plans,
310
- defaultPlan: 'monthly',
311
- };
312
-
313
- // 3. Doğrulayın
314
- const validation = validatePlanConfig(config);
315
- if (!validation.isValid) {
316
- throw new Error('Invalid config');
317
- }
318
-
319
- // 4. Kullanın
320
- function PricingCard() {
321
- const monthlyPrice = formatPrice(plans.monthly.price, 'USD');
322
- const annualPrice = formatPrice(plans.annual.price, 'USD');
323
- const discount = calculateDiscount(
324
- plans.monthly.price * 12,
325
- plans.annual.price
326
- );
327
-
328
- return (
329
- <View>
330
- <Text>Monthly: {monthlyPrice}</Text>
331
- <Text>Annual: {annualPrice} (Save {discount}%)</Text>
332
- </View>
333
- );
334
- }
335
- ```
336
-
337
- ## API Referansı
338
-
339
- ### Plan Entity
340
-
341
- ```typescript
342
- class Plan {
343
- readonly id: string;
344
- readonly productId: string;
345
- readonly period: PlanPeriod;
346
- readonly price: number;
347
- readonly currency: string;
348
- readonly credits?: number;
349
- readonly features: string[];
350
- readonly metadata?: Record<string, any>;
351
-
352
- // Metodlar
353
- isBetterValueThan(other: Plan): boolean;
354
- getMonthlyEquivalent(): number;
355
- calculateSavings(other: Plan): number;
356
- hasFeature(feature: string): boolean;
357
-
358
- // Static metodlar
359
- static create(config: PlanConfig): Plan;
360
- static fromRevenueCat(package: Package): Plan;
361
- }
362
- ```
363
-
364
- ### Tip Tanımlamaları
365
-
366
- ```typescript
367
- type PlanPeriod = 'monthly' | 'annual' | 'lifetime';
368
-
369
- interface PlanConfig {
370
- id: string;
371
- productId: string;
372
- period: PlanPeriod;
373
- price: number;
374
- currency: string;
375
- credits?: number;
376
- features: string[];
377
- metadata?: Record<string, any>;
378
- }
379
-
380
- interface ValidationError {
381
- field: string;
382
- message: string;
383
- value?: any;
384
- }
385
-
386
- interface ValidationResult {
387
- isValid: boolean;
388
- errors: ValidationError[];
389
- }
390
- ```
15
+ Comprehensive subscription plan configuration system.
16
+
17
+ - **Plan Types**: Monthly, annual, and lifetime plan configurations
18
+ - **Product Metadata**: RevenueCat product metadata management
19
+ - **Validation**: Configuration validation and type safety
20
+ - **Helper Functions**: Plan comparison and filtering utilities
21
+
22
+ ### Configuration Objects
23
+
24
+ Structured configuration for different aspects of the system.
25
+
26
+ - **SubscriptionConfig**: Main subscription configuration
27
+ - **WalletConfig**: Credit system configuration
28
+ - **Plan Entities**: Individual plan definitions
29
+ - **Validation Rules**: Configuration validation schemas
30
+
31
+ ### Helper Utilities
32
+
33
+ Plan comparison and manipulation functions.
34
+
35
+ - **Plan Comparison**: Value comparison between plans
36
+ - **Price Formatting**: Currency-aware price formatting
37
+ - **Discount Calculation**: Savings and discount calculations
38
+ - **Package Filtering**: Type-based package filtering
39
+
40
+ ### Validation System
41
+
42
+ Comprehensive configuration validation.
43
+
44
+ - **Plan Validation**: Plan entity validation rules
45
+ - **Config Validation**: Complete configuration validation
46
+ - **Type Safety**: TypeScript type definitions
47
+ - **Error Messages**: Detailed validation error reporting
48
+
49
+ ## Restrictions
50
+
51
+ ### REQUIRED
52
+
53
+ - **Type Safety**: Always use TypeScript type definitions
54
+ - **Validation**: Validate configurations before runtime use
55
+ - **Default Values**: Provide meaningful default values
56
+ - **Immutable Updates**: Create new copies instead of modifying
57
+
58
+ ### PROHIBITED
59
+
60
+ - **Invalid Prices**: Negative or zero prices not allowed
61
+ - **Missing IDs**: All plans must have valid IDs
62
+ - **Duplicate Plans**: No duplicate plan IDs allowed
63
+ - **Hardcoded Values**: Use configuration system
64
+
65
+ ### CRITICAL
66
+
67
+ - **Configuration Integrity**: All configurations must be valid
68
+ - **Plan Consistency**: Related plans must be consistent
69
+ - **Currency Handling**: Proper currency code usage
70
+ - **Feature Lists**: Accurate feature mapping
71
+
72
+ ## AI Agent Guidelines
73
+
74
+ ### When Modifying Configuration System
75
+
76
+ 1. **Type Definitions**: Update TypeScript types for new config
77
+ 2. **Validation Rules**: Add validation for new fields
78
+ 3. **Default Values**: Provide sensible defaults
79
+ 4. **Documentation**: Document configuration options
80
+
81
+ ### When Adding New Plan Types
82
+
83
+ 1. **Entity Pattern**: Follow existing entity patterns
84
+ 2. **Validation**: Add validation rules
85
+ 3. **Helper Functions**: Create helper functions
86
+ 4. **Testing**: Test with various configurations
87
+
88
+ ### When Fixing Configuration Bugs
89
+
90
+ 1. **Validation Logic**: Check validation rules
91
+ 2. **Type Definitions**: Verify type correctness
92
+ 3. **Default Values**: Ensure proper defaults
93
+ 4. **Edge Cases**: Test boundary conditions
94
+
95
+ ## Related Documentation
96
+
97
+ - [Paywall Domain](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/domains/paywall/README.md)
98
+ - [Wallet Domain](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/domains/wallet/README.md)
99
+ - [RevenueCat Integration](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/revenuecat/README.md)
100
+ - [Domain Layer](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/domain/README.md)