@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.
Files changed (98) hide show
  1. package/README.md +211 -394
  2. package/package.json +3 -3
  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/entities/SubscriptionStatus.ts +1 -1
  9. package/src/domain/errors/README.md +33 -287
  10. package/src/domain/value-objects/README.md +43 -179
  11. package/src/domains/README.md +50 -238
  12. package/src/domains/README.md.bak +274 -0
  13. package/src/domains/config/README.md +93 -383
  14. package/src/domains/config/domain/README.md +23 -376
  15. package/src/domains/config/domain/entities/README.md +34 -343
  16. package/src/domains/paywall/README.md +99 -369
  17. package/src/domains/paywall/components/README.md +34 -178
  18. package/src/domains/paywall/entities/README.md +34 -193
  19. package/src/domains/paywall/hooks/README.md +34 -122
  20. package/src/domains/wallet/README.md +34 -275
  21. package/src/domains/wallet/README.md.bak +209 -0
  22. package/src/domains/wallet/domain/README.md +34 -101
  23. package/src/domains/wallet/domain/entities/README.md +34 -115
  24. package/src/domains/wallet/domain/errors/README.md +34 -151
  25. package/src/domains/wallet/infrastructure/README.md +34 -89
  26. package/src/domains/wallet/presentation/components/README.md +34 -224
  27. package/src/domains/wallet/presentation/components/TransactionItem.tsx +1 -1
  28. package/src/domains/wallet/presentation/hooks/README.md +34 -248
  29. package/src/infrastructure/README.md +37 -496
  30. package/src/infrastructure/mappers/README.md +0 -13
  31. package/src/infrastructure/repositories/README.md +74 -360
  32. package/src/infrastructure/services/ActivationHandler.ts +1 -1
  33. package/src/infrastructure/services/README.md +95 -370
  34. package/src/infrastructure/services/SubscriptionService.ts +1 -1
  35. package/src/presentation/README.md +123 -408
  36. package/src/presentation/README.md.bak +172 -0
  37. package/src/presentation/components/README.md +151 -179
  38. package/src/presentation/components/README.md.bak +217 -0
  39. package/src/presentation/components/details/CreditRow.md +65 -310
  40. package/src/presentation/components/details/DetailRow.md +63 -255
  41. package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
  42. package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
  43. package/src/presentation/components/details/README.md +97 -447
  44. package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
  45. package/src/presentation/components/feedback/README.md +97 -445
  46. package/src/presentation/components/paywall/PaywallModal.md +66 -416
  47. package/src/presentation/components/paywall/README.md +50 -186
  48. package/src/presentation/components/sections/README.md +97 -466
  49. package/src/presentation/components/sections/SubscriptionSection.md +92 -244
  50. package/src/presentation/hooks/README.md +154 -741
  51. package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
  52. package/src/presentation/hooks/useAuthGate.md +61 -375
  53. package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
  54. package/src/presentation/hooks/useCreditChecker.md +73 -378
  55. package/src/presentation/hooks/useCredits.md +74 -313
  56. package/src/presentation/hooks/useCredits.md.bak +231 -0
  57. package/src/presentation/hooks/useCreditsGate.md +66 -318
  58. package/src/presentation/hooks/useDeductCredit.md +0 -76
  59. package/src/presentation/hooks/useDeductCredit.ts +1 -1
  60. package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
  61. package/src/presentation/hooks/useFeatureGate.md +105 -150
  62. package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
  63. package/src/presentation/hooks/useInitializeCredits.md +64 -430
  64. package/src/presentation/hooks/usePaywall.md +61 -306
  65. package/src/presentation/hooks/usePaywallOperations.md +64 -458
  66. package/src/presentation/hooks/usePaywallVisibility.md +67 -316
  67. package/src/presentation/hooks/usePremium.md +84 -226
  68. package/src/presentation/hooks/usePremiumGate.md +60 -395
  69. package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
  70. package/src/presentation/hooks/useSubscription.md +66 -422
  71. package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
  72. package/src/presentation/hooks/useSubscriptionGate.md +80 -164
  73. package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
  74. package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
  75. package/src/presentation/hooks/useUserTier.md +63 -328
  76. package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
  77. package/src/presentation/screens/README.md +48 -190
  78. package/src/presentation/types/README.md +0 -16
  79. package/src/presentation/utils/README.md +0 -21
  80. package/src/presentation/utils/subscriptionDateUtils.ts +1 -1
  81. package/src/revenuecat/README.md +99 -518
  82. package/src/revenuecat/application/README.md +35 -150
  83. package/src/revenuecat/application/ports/README.md +34 -162
  84. package/src/revenuecat/domain/README.md +42 -141
  85. package/src/revenuecat/domain/constants/README.md +34 -176
  86. package/src/revenuecat/domain/entities/README.md +34 -374
  87. package/src/revenuecat/domain/errors/README.md +47 -191
  88. package/src/revenuecat/domain/types/README.md +34 -366
  89. package/src/revenuecat/domain/value-objects/README.md +34 -434
  90. package/src/revenuecat/infrastructure/README.md +34 -43
  91. package/src/revenuecat/infrastructure/config/README.md +32 -23
  92. package/src/revenuecat/infrastructure/handlers/README.md +34 -211
  93. package/src/revenuecat/infrastructure/managers/README.md +34 -42
  94. package/src/revenuecat/infrastructure/services/README.md +35 -318
  95. package/src/revenuecat/infrastructure/utils/README.md +34 -375
  96. package/src/revenuecat/presentation/README.md +34 -176
  97. package/src/revenuecat/presentation/hooks/README.md +29 -35
  98. package/src/utils/README.md +38 -525
@@ -1,350 +1,41 @@
1
1
  # Config Domain Entities
2
2
 
3
+ ## Location
3
4
  Domain entities for configuration management.
4
5
 
5
- ## Overview
6
-
7
- This directory contains entity classes representing configuration concepts like packages, features, and paywalls.
8
-
9
- ## Entities
10
-
11
- ### PackageConfig
12
-
13
- Represents a subscription package configuration.
14
-
15
- **File**: `PackageConfig.ts`
16
-
17
- ```typescript
18
- class PackageConfig {
19
- readonly identifier: string;
20
- readonly productId: string;
21
- readonly period: PackagePeriod;
22
- readonly price: Money;
23
- readonly features: string[];
24
- readonly credits?: number;
25
- readonly metadata: PackageMetadata;
26
-
27
- // Methods
28
- isAnnual(): boolean;
29
- isMonthly(): boolean;
30
- isLifetime(): boolean;
31
- hasCredits(): boolean;
32
- isRecommended(): boolean;
33
- isHighlighted(): boolean;
34
- getPerMonthPrice(): Money | null;
35
- getDiscountPercentage(): number | null;
36
- getBadge(): string | null;
37
- }
38
- ```
39
-
40
- **Usage:**
41
- ```typescript
42
- const pkg = new PackageConfig({
43
- identifier: 'premium_annual',
44
- productId: 'com.app.premium.annual',
45
- period: 'annual',
46
- price: 79.99,
47
- currency: 'USD',
48
- features: ['Unlimited Access', 'Ad-Free'],
49
- credits: 1200,
50
- metadata: {
51
- recommended: true,
52
- badge: 'Best Value',
53
- discount: { percentage: 20, description: 'Save 20%' },
54
- },
55
- });
56
-
57
- console.log(pkg.isAnnual()); // true
58
- console.log(pkg.getPerMonthPrice()?.format()); // '$6.67'
59
- console.log(pkg.getDiscountPercentage()); // 20
60
- ```
61
-
62
- ### FeatureConfig
63
-
64
- Represents a feature configuration with gating rules.
65
-
66
- **File**: `FeatureConfig.ts`
67
-
68
- ```typescript
69
- class FeatureConfig {
70
- readonly id: string;
71
- readonly name: string;
72
- readonly description?: string;
73
- readonly requiresPremium: boolean;
74
- readonly requiresCredits: boolean;
75
- readonly creditCost?: number;
76
- readonly enabled: boolean;
77
- readonly gateType: 'premium' | 'credits' | 'both';
78
-
79
- // Methods
80
- isAccessible(userHasPremium: boolean, userCredits: number): boolean;
81
- getRequiredCredits(): number;
82
- }
83
- ```
84
-
85
- **Usage:**
86
- ```typescript
87
- const feature = new FeatureConfig({
88
- id: 'ai_generation',
89
- name: 'AI Generation',
90
- requiresPremium: false,
91
- requiresCredits: true,
92
- creditCost: 5,
93
- enabled: true,
94
- gateType: 'credits',
95
- });
96
-
97
- console.log(feature.isAccessible(false, 10)); // true
98
- console.log(feature.isAccessible(false, 3)); // false
99
- console.log(feature.getRequiredCredits()); // 5
100
- ```
101
-
102
- ### PaywallConfig
103
-
104
- Represents a paywall screen configuration.
105
-
106
- **File**: `PaywallConfig.ts`
107
-
108
- ```typescript
109
- class PaywallConfig {
110
- readonly id: string;
111
- readonly title: string;
112
- readonly subtitle?: string;
113
- readonly features: string[];
114
- readonly packages: PackageConfig[];
115
- readonly highlightPackage?: string;
116
- readonly style: PaywallStyle;
117
- readonly triggers: PaywallTrigger[];
118
-
119
- // Methods
120
- getHighlightedPackage(): PackageConfig | null;
121
- getPackageByIdentifier(identifier: string): PackageConfig | null;
122
- shouldTrigger(triggerType: string): boolean;
123
- }
124
- ```
125
-
126
- **Usage:**
127
- ```typescript
128
- const paywall = new PaywallConfig({
129
- id: 'premium_upgrade',
130
- title: 'Upgrade to Premium',
131
- features: ['Unlimited Access', 'Ad-Free'],
132
- packages: [monthlyPkg, annualPkg],
133
- highlightPackage: 'premium_annual',
134
- style: {
135
- primaryColor: '#007AFF',
136
- backgroundColor: '#FFFFFF',
137
- },
138
- triggers: [{ type: 'credit_gate', enabled: true }],
139
- });
140
-
141
- const highlighted = paywall.getHighlightedPackage();
142
- console.log(highlighted?.identifier); // 'premium_annual'
143
- ```
144
-
145
- ### SubscriptionSettingsConfig
146
-
147
- Represents subscription settings configuration.
148
-
149
- **File**: `SubscriptionSettingsConfig.ts`
150
-
151
- ```typescript
152
- class SubscriptionSettingsConfig {
153
- readonly showSubscriptionDetails: boolean;
154
- readonly showCreditBalance: boolean;
155
- readonly allowRestorePurchases: boolean;
156
- readonly showManageSubscriptionButton: boolean;
157
- readonly subscriptionManagementURL: string;
158
- readonly supportEmail: string;
159
-
160
- // Methods
161
- getAvailableActions(): string[];
162
- isRestoreAllowed(): boolean;
163
- }
164
- ```
165
-
166
- **Usage:**
167
- ```typescript
168
- const settings = new SubscriptionSettingsConfig({
169
- showSubscriptionDetails: true,
170
- showCreditBalance: true,
171
- allowRestorePurchases: true,
172
- showManageSubscriptionButton: true,
173
- subscriptionManagementURL: 'https://apps.apple.com/account/subscriptions',
174
- supportEmail: 'support@example.com',
175
- });
176
-
177
- console.log(settings.isRestoreAllowed()); // true
178
- ```
179
-
180
- ## Supporting Types
181
-
182
- ### PackageMetadata
183
-
184
- ```typescript
185
- interface PackageMetadata {
186
- highlight?: boolean;
187
- recommended?: boolean;
188
- discount?: {
189
- percentage: number;
190
- description: string;
191
- };
192
- badge?: string;
193
- }
194
- ```
195
-
196
- ### PaywallStyle
197
-
198
- ```typescript
199
- interface PaywallStyle {
200
- primaryColor: string;
201
- backgroundColor: string;
202
- textColor?: string;
203
- image?: string;
204
- logo?: string;
205
- }
206
- ```
207
-
208
- ### PaywallTrigger
209
-
210
- ```typescript
211
- interface PaywallTrigger {
212
- type: string;
213
- enabled: boolean;
214
- conditions?: Record<string, unknown>;
215
- }
216
- ```
217
-
218
- ## Factory Functions
219
-
220
- ### createDefaultPackages
221
-
222
- Create default package configurations.
223
-
224
- ```typescript
225
- function createDefaultPackages(): PackageConfig[] {
226
- return [
227
- new PackageConfig({
228
- identifier: 'premium_monthly',
229
- productId: 'com.app.premium.monthly',
230
- period: 'monthly',
231
- price: 9.99,
232
- currency: 'USD',
233
- features: ['Unlimited Access', 'Ad-Free'],
234
- credits: 100,
235
- }),
236
- new PackageConfig({
237
- identifier: 'premium_annual',
238
- productId: 'com.app.premium.annual',
239
- period: 'annual',
240
- price: 79.99,
241
- currency: 'USD',
242
- features: ['Unlimited Access', 'Ad-Free', 'Save 20%'],
243
- credits: 1200,
244
- metadata: {
245
- recommended: true,
246
- badge: 'Best Value',
247
- discount: { percentage: 20, description: 'Save 20%' },
248
- },
249
- }),
250
- ];
251
- }
252
- ```
253
-
254
- ### createDefaultPaywall
255
-
256
- Create default paywall configuration.
257
-
258
- ```typescript
259
- function createDefaultPaywall(): PaywallConfig {
260
- return new PaywallConfig({
261
- id: 'default_paywall',
262
- title: 'Upgrade to Premium',
263
- subtitle: 'Get unlimited access to all features',
264
- features: [
265
- 'Unlimited Access',
266
- 'Ad-Free Experience',
267
- 'Priority Support',
268
- 'Exclusive Features',
269
- ],
270
- packages: createDefaultPackages(),
271
- highlightPackage: 'premium_annual',
272
- style: {
273
- primaryColor: '#007AFF',
274
- backgroundColor: '#FFFFFF',
275
- },
276
- triggers: [
277
- { type: 'premium_feature', enabled: true },
278
- { type: 'credit_gate', enabled: true },
279
- ],
280
- });
281
- }
282
- ```
283
-
284
- ## Usage Examples
285
-
286
- ### Validating Package Configuration
287
-
288
- ```typescript
289
- function validatePackage(config: PackageConfigData): boolean {
290
- try {
291
- new PackageConfig(config);
292
- return true;
293
- } catch (error) {
294
- console.error('Invalid package config:', error.message);
295
- return false;
296
- }
297
- }
298
- ```
299
-
300
- ### Finding Recommended Package
301
-
302
- ```typescript
303
- function findRecommendedPackage(packages: PackageConfig[]): PackageConfig | null {
304
- return packages.find(pkg => pkg.isRecommended()) ?? null;
305
- }
306
-
307
- const recommended = findRecommendedPackage(packages);
308
- console.log('Recommended:', recommended?.identifier);
309
- ```
310
-
311
- ### Filtering Packages by Period
312
-
313
- ```typescript
314
- function getPackagesByPeriod(packages: PackageConfig[], period: 'monthly' | 'annual'): PackageConfig[] {
315
- return packages.filter(pkg => {
316
- if (period === 'monthly') return pkg.isMonthly();
317
- if (period === 'annual') return pkg.isAnnual();
318
- return false;
319
- });
320
- }
321
-
322
- const monthlyPackages = getPackagesByPeriod(packages, 'monthly');
323
- ```
324
-
325
- ### Checking Feature Access
326
-
327
- ```typescript
328
- function canUserAccessFeature(feature: FeatureConfig, user: User): boolean {
329
- return feature.isAccessible(user.isPremium, user.credits);
330
- }
331
-
332
- const aiFeature = new FeatureConfig({ /* ... */ });
333
- const canAccess = canUserAccessFeature(aiFeature, currentUser);
334
- ```
335
-
336
- ## Best Practices
337
-
338
- 1. **Validation**: Always validate configuration in constructor
339
- 2. **Immutability**: Never modify entities after creation
340
- 3. **Business Logic**: Keep business logic in entities
341
- 4. **Type Safety**: Use TypeScript strictly
342
- 5. **Error Messages**: Provide clear error messages
343
- 6. **Defaults**: Provide factory functions for defaults
344
- 7. **Testing**: Test validation logic thoroughly
345
-
346
- ## Related
347
-
6
+ ## Strategy
7
+ This directory contains entity classes representing configuration concepts like packages, features, and paywalls with strict validation and immutability.
8
+
9
+ ## Restrictions
10
+
11
+ ### REQUIRED
12
+ - Must validate all configuration in constructor
13
+ - Must treat entities as immutable
14
+ - Must provide clear error messages
15
+ - Must use TypeScript strict mode
16
+
17
+ ### PROHIBITED
18
+ - DO NOT modify entities after creation
19
+ - DO NOT bypass validation logic
20
+ - DO NOT expose mutable internal state
21
+ - DO NOT allow invalid configuration
22
+
23
+ ### CRITICAL SAFETY
24
+ - All validation MUST happen in constructor
25
+ - Entities MUST fail fast on invalid input
26
+ - Error messages MUST be descriptive
27
+ - Factory functions MUST provide valid defaults
28
+
29
+ ## AI Agent Guidelines
30
+ 1. Always validate configuration data in entity constructors
31
+ 2. Treat all entities as immutable values
32
+ 3. Keep business logic encapsulated within entities
33
+ 4. Provide factory functions for common configurations
34
+ 5. Test validation logic thoroughly
35
+ 6. Use TypeScript strict types for all properties
36
+ 7. Return descriptive error messages for validation failures
37
+
38
+ ## Related Documentation
348
39
  - [Config Domain](../README.md)
349
40
  - [Config Value Objects](../value-objects/README.md)
350
41
  - [Config Utils](../../utils/README.md)