@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
@@ -2,229 +2,87 @@
2
2
 
3
3
  Hook for checking and managing premium subscription status.
4
4
 
5
- ## Import
6
-
7
- ```typescript
8
- import { usePremium } from '@umituz/react-native-subscription';
9
- ```
10
-
11
- ## Signature
12
-
13
- ```typescript
14
- function usePremium(): {
15
- isPremium: boolean;
16
- isLoading: boolean;
17
- error: Error | null;
18
- subscription: SubscriptionStatus | null;
19
- refetch: () => Promise<void>;
20
- }
21
- ```
22
-
23
- ## Returns
24
-
25
- | Property | Type | Description |
26
- |----------|------|-------------|
27
- | `isPremium` | `boolean` | Whether user has active premium subscription |
28
- | `isLoading` | `boolean` | Whether hook is loading data |
29
- | `error` | `Error \| null` | Error if fetching failed |
30
- | `subscription` | `SubscriptionStatus \| null` | Full subscription status object |
31
- | `refetch` | `() => Promise<void>` | Function to manually refetch data |
32
-
33
- ## Basic Usage
34
-
35
- ```typescript
36
- function MyComponent() {
37
- const { isPremium, isLoading } = usePremium();
38
-
39
- if (isLoading) {
40
- return <ActivityIndicator />;
41
- }
42
-
43
- return (
44
- <View>
45
- <Text>
46
- {isPremium ? 'Premium User' : 'Free User'}
47
- </Text>
48
- </View>
49
- );
50
- }
51
- ```
52
-
53
- ## Advanced Usage
54
-
55
- ### With Error Handling
56
-
57
- ```typescript
58
- function PremiumContent() {
59
- const { isPremium, isLoading, error } = usePremium();
60
-
61
- useEffect(() => {
62
- if (error) {
63
- console.error('Failed to load premium status:', error);
64
- analytics.track('premium_check_failed', {
65
- error: error.message,
66
- });
67
- }
68
- }, [error]);
69
-
70
- if (isLoading) return <Skeleton />;
71
- if (error) return <ErrorState error={error} />;
72
-
73
- return <PremiumFeatures />;
74
- }
75
- ```
76
-
77
- ### With Refetch
78
-
79
- ```typescript
80
- function SettingsScreen() {
81
- const { isPremium, refetch, isLoading } = usePremium();
82
-
83
- const handleRefresh = async () => {
84
- await refetch();
85
- Alert.alert('Success', 'Status refreshed');
86
- };
87
-
88
- return (
89
- <View>
90
- <Text>Status: {isPremium ? 'Premium' : 'Free'}</Text>
91
-
92
- <Button
93
- onPress={handleRefresh}
94
- disabled={isLoading}
95
- title="Refresh Status"
96
- />
97
- </View>
98
- );
99
- }
100
- ```
101
-
102
- ### With Full Subscription Details
103
-
104
- ```typescript
105
- function SubscriptionInfo() {
106
- const { isPremium, subscription } = usePremium();
107
-
108
- if (!subscription) return null;
109
-
110
- return (
111
- <View>
112
- <Text>Type: {subscription.type}</Text>
113
- <Text>Active: {subscription.isActive ? 'Yes' : 'No'}</Text>
114
-
115
- {subscription.expirationDate && (
116
- <Text>
117
- Expires: {new Date(subscription.expirationDate).toLocaleDateString()}
118
- </Text>
119
- )}
120
-
121
- {subscription.willRenew && (
122
- <Text>Auto-renew: On</Text>
123
- )}
124
- </View>
125
- );
126
- }
127
- ```
128
-
129
- ## Examples
130
-
131
- ### Conditional Rendering
132
-
133
- ```typescript
134
- function FeatureList() {
135
- const { isPremium, isLoading } = usePremium();
136
-
137
- if (isLoading) return <LoadingSpinner />;
138
-
139
- return (
140
- <View>
141
- <Feature name="Basic Feature" available={true} />
142
- <Feature name="Premium Feature 1" available={isPremium} />
143
- <Feature name="Premium Feature 2" available={isPremium} />
144
- <Feature name="Premium Feature 3" available={isPremium} />
145
- </View>
146
- );
147
- }
148
- ```
149
-
150
- ### Premium Badge
151
-
152
- ```typescript
153
- function PremiumBadge() {
154
- const { isPremium } = usePremium();
155
-
156
- return (
157
- <View style={[
158
- styles.badge,
159
- isPremium && styles.badgePremium,
160
- ]}>
161
- <Text style={styles.badgeText}>
162
- {isPremium ? '⭐ PREMIUM' : 'FREE'}
163
- </Text>
164
- </View>
165
- );
166
- }
167
- ```
168
-
169
- ### Premium Gate
170
-
171
- ```typescript
172
- function PremiumOnlyComponent() {
173
- const { isPremium, isLoading } = usePremium();
174
-
175
- if (isLoading) {
176
- return <ActivityIndicator />;
177
- }
178
-
179
- if (!isPremium) {
180
- return (
181
- <View>
182
- <Text>This feature requires Premium</Text>
183
- <Button
184
- onPress={() => navigation.navigate('Paywall')}
185
- title="Upgrade to Premium"
186
- />
187
- </View>
188
- );
189
- }
190
-
191
- return <PremiumContent />;
192
- }
193
- ```
194
-
195
- ## Behavior
196
-
197
- ### Loading States
198
-
199
- The hook goes through these states:
200
-
201
- 1. **Initial**: `isLoading = true`, `isPremium = false`
202
- 2. **Loading**: Fetches subscription status
203
- 3. **Loaded**: `isLoading = false`, `isPremium` set to actual value
204
- 4. **Error**: `isLoading = false`, `error` set
205
-
206
- ### Automatic Updates
207
-
208
- The hook automatically updates when:
209
- - User logs in/logs out
210
- - Subscription status changes
211
- - App comes to foreground
212
-
213
- ### Caching
214
-
215
- The hook caches subscription status for:
216
- - Default: 5 minutes
217
- - Configurable via `staleTime` option
218
-
219
- ## Related Hooks
220
-
221
- - **usePremiumGate** - For gating premium features
222
- - **useSubscription** - For more subscription details
223
- - **useSubscriptionStatus** - For detailed status info
224
- - **usePremiumWithCredits** - For premium OR credits features
225
-
226
- ## See Also
227
-
228
- - [usePremiumGate](./usePremiumGate.md)
229
- - [useSubscription](./useSubscription.md)
230
- - [usePremiumWithCredits](./usePremiumWithCredits.md)
5
+ ## Location
6
+
7
+ **Import Path**: `@umituz/react-native-subscription`
8
+
9
+ **File**: `src/presentation/hooks/usePremium.ts`
10
+
11
+ **Type**: Hook
12
+
13
+ ## Strategy
14
+
15
+ ### Premium Status Flow
16
+
17
+ 1. **Initial Check**: Fetch current subscription status from repository
18
+ 2. **Status Evaluation**: Determine if user has active premium subscription
19
+ 3. **Real-time Updates**: Automatically update when user logs in/out or subscription changes
20
+ 4. **Caching**: Cache status for 5 minutes (configurable) to reduce API calls
21
+ 5. **Loading States**: Provide loading indicators during data fetch
22
+ 6. **Error Handling**: Handle fetch errors gracefully
23
+
24
+ ### Integration Points
25
+
26
+ - **Subscription Repository**: `src/infrastructure/repositories/SubscriptionRepository.ts`
27
+ - **TanStack Query**: For caching and real-time updates
28
+ - **Auth Context**: Sync with user authentication state
29
+ - **RevenueCat**: For subscription data source
30
+
31
+ ## Restrictions
32
+
33
+ ### REQUIRED
34
+
35
+ - **Loading State**: MUST handle loading state in UI
36
+ - **Error Handling**: MUST handle error state
37
+ - **Check Before Access**: MUST verify isPremium before showing premium features
38
+
39
+ ### PROHIBITED
40
+
41
+ - **NEVER** use for security decisions (server-side validation required)
42
+ - **NEVER** assume instant data availability (always check loading state)
43
+ - **DO NOT** use for guest users without proper handling
44
+
45
+ ### CRITICAL SAFETY
46
+
47
+ - **ALWAYS** handle loading state before rendering premium content
48
+ - **NEVER** trust client-side state for security enforcement
49
+ - **MUST** implement error boundaries when using this hook
50
+
51
+ ## AI Agent Guidelines
52
+
53
+ ### When Implementing Premium Features
54
+
55
+ 1. **Always** check loading state first
56
+ 2. **Always** handle error state
57
+ 3. **Always** verify isPremium before showing premium content
58
+ 4. **Never** use for security decisions without server validation
59
+ 5. **Always** provide upgrade path for non-premium users
60
+
61
+ ### Integration Checklist
62
+
63
+ - [ ] Import from correct path: `@umituz/react-native-subscription`
64
+ - [ ] Handle loading state (show ActivityIndicator or skeleton)
65
+ - [ ] Handle error state (show error message)
66
+ - [ ] Check isPremium before rendering premium content
67
+ - [ ] Provide upgrade path for free users
68
+ - [ ] Test with premium user
69
+ - [ ] Test with free user
70
+ - [ ] Test with guest user
71
+ - [ ] Test offline scenario
72
+
73
+ ### Common Patterns
74
+
75
+ 1. **Conditional Rendering**: Show/hide features based on isPremium
76
+ 2. **Premium Badge**: Display premium status badge
77
+ 3. **Feature Gating**: Use usePremiumGate instead of manual checks
78
+ 4. **Status Display**: Show subscription details with useSubscriptionDetails
79
+ 5. **Upgrade Prompts**: Guide free users to paywall
80
+
81
+ ## Related Documentation
82
+
83
+ - **usePremiumGate**: Gating premium features
84
+ - **useSubscription**: Detailed subscription status
85
+ - **useSubscriptionStatus**: Subscription status details
86
+ - **usePremiumWithCredits**: Hybrid premium/credits access
87
+ - **Subscription Repository**: `src/infrastructure/repositories/README.md`
88
+ - **Domain Layer**: `src/domain/README.md`