@umituz/react-native-subscription 2.14.96 → 2.14.98

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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +462 -0
  3. package/package.json +3 -3
  4. package/src/application/README.md +229 -0
  5. package/src/application/ports/README.md +103 -0
  6. package/src/domain/README.md +402 -0
  7. package/src/domain/constants/README.md +80 -0
  8. package/src/domain/entities/README.md +176 -0
  9. package/src/domain/errors/README.md +307 -0
  10. package/src/domain/value-objects/README.md +186 -0
  11. package/src/domains/config/README.md +390 -0
  12. package/src/domains/paywall/README.md +371 -0
  13. package/src/domains/paywall/components/PaywallHeader.tsx +8 -11
  14. package/src/domains/paywall/components/README.md +185 -0
  15. package/src/domains/paywall/entities/README.md +199 -0
  16. package/src/domains/paywall/hooks/README.md +129 -0
  17. package/src/domains/wallet/README.md +292 -0
  18. package/src/domains/wallet/domain/README.md +108 -0
  19. package/src/domains/wallet/domain/entities/README.md +122 -0
  20. package/src/domains/wallet/domain/errors/README.md +157 -0
  21. package/src/domains/wallet/infrastructure/README.md +96 -0
  22. package/src/domains/wallet/presentation/components/BalanceCard.tsx +6 -12
  23. package/src/domains/wallet/presentation/components/README.md +231 -0
  24. package/src/domains/wallet/presentation/hooks/README.md +255 -0
  25. package/src/infrastructure/README.md +514 -0
  26. package/src/infrastructure/mappers/README.md +34 -0
  27. package/src/infrastructure/models/README.md +26 -0
  28. package/src/infrastructure/repositories/README.md +385 -0
  29. package/src/infrastructure/services/README.md +374 -0
  30. package/src/presentation/README.md +410 -0
  31. package/src/presentation/components/README.md +183 -0
  32. package/src/presentation/components/details/CreditRow.md +337 -0
  33. package/src/presentation/components/details/DetailRow.md +283 -0
  34. package/src/presentation/components/details/PremiumDetailsCard.md +266 -0
  35. package/src/presentation/components/details/PremiumStatusBadge.md +266 -0
  36. package/src/presentation/components/details/README.md +449 -0
  37. package/src/presentation/components/feedback/PaywallFeedbackModal.md +314 -0
  38. package/src/presentation/components/feedback/README.md +447 -0
  39. package/src/presentation/components/paywall/PaywallModal.md +444 -0
  40. package/src/presentation/components/paywall/README.md +190 -0
  41. package/src/presentation/components/sections/README.md +468 -0
  42. package/src/presentation/components/sections/SubscriptionSection.md +246 -0
  43. package/src/presentation/hooks/README.md +743 -0
  44. package/src/presentation/hooks/useAuthAwarePurchase.md +359 -0
  45. package/src/presentation/hooks/useAuthGate.md +403 -0
  46. package/src/presentation/hooks/useAuthSubscriptionSync.md +398 -0
  47. package/src/presentation/hooks/useCreditChecker.md +407 -0
  48. package/src/presentation/hooks/useCredits.md +342 -0
  49. package/src/presentation/hooks/useCreditsGate.md +346 -0
  50. package/src/presentation/hooks/useDeductCredit.md +160 -0
  51. package/src/presentation/hooks/useDevTestCallbacks.md +422 -0
  52. package/src/presentation/hooks/useFeatureGate.md +157 -0
  53. package/src/presentation/hooks/useInitializeCredits.md +458 -0
  54. package/src/presentation/hooks/usePaywall.md +334 -0
  55. package/src/presentation/hooks/usePaywallOperations.md +486 -0
  56. package/src/presentation/hooks/usePaywallVisibility.md +344 -0
  57. package/src/presentation/hooks/usePremium.md +230 -0
  58. package/src/presentation/hooks/usePremiumGate.md +423 -0
  59. package/src/presentation/hooks/usePremiumWithCredits.md +429 -0
  60. package/src/presentation/hooks/useSubscription.md +450 -0
  61. package/src/presentation/hooks/useSubscriptionDetails.md +438 -0
  62. package/src/presentation/hooks/useSubscriptionGate.md +168 -0
  63. package/src/presentation/hooks/useSubscriptionSettingsConfig.md +374 -0
  64. package/src/presentation/hooks/useSubscriptionStatus.md +424 -0
  65. package/src/presentation/hooks/useUserTier.md +356 -0
  66. package/src/presentation/hooks/useUserTierWithRepository.md +452 -0
  67. package/src/presentation/screens/README.md +194 -0
  68. package/src/presentation/types/README.md +38 -0
  69. package/src/presentation/utils/README.md +52 -0
  70. package/src/revenuecat/README.md +523 -0
  71. package/src/revenuecat/domain/README.md +147 -0
  72. package/src/revenuecat/domain/errors/README.md +197 -0
  73. package/src/revenuecat/infrastructure/config/README.md +40 -0
  74. package/src/revenuecat/infrastructure/managers/README.md +49 -0
  75. package/src/revenuecat/presentation/hooks/README.md +56 -0
  76. package/src/revenuecat/presentation/hooks/usePurchasePackage.ts +1 -1
  77. package/src/utils/README.md +529 -0
@@ -0,0 +1,390 @@
1
+ # Config Domain
2
+
3
+ Abonelik planları, ürün konfigürasyonları ve paket yönetimi için merkezi konfigürasyon sistemi.
4
+
5
+ ## Özellikler
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:
17
+
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
+ ```
32
+
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
+ });
53
+
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
+ ```