@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,421 +2,90 @@
2
2
 
3
3
  **Development-only** hook for testing subscription renewal and credit operations.
4
4
 
5
- ## Import
5
+ ## Location
6
6
 
7
- ```typescript
8
- import { useDevTestCallbacks } from '@umituz/react-native-subscription';
9
- ```
7
+ **Import Path**: `@umituz/react-native-subscription`
10
8
 
11
- ## Signature
9
+ **File**: `src/presentation/hooks/useDevTestCallbacks.ts`
12
10
 
13
- ```typescript
14
- function useDevTestCallbacks(): {
15
- onTestRenewal: () => void;
16
- onCheckCredits: () => void;
17
- onTestDuplicate: () => void;
18
- } | undefined
19
- ```
11
+ **Type**: Hook
20
12
 
21
- ## Returns
13
+ ## Strategy
22
14
 
23
- Returns `undefined` in production. In development, returns:
15
+ ### Development Testing Utilities
24
16
 
25
- | Property | Type | Description |
26
- |----------|------|-------------|
27
- | `onTestRenewal` | `() => void` | Simulate subscription renewal |
28
- | `onCheckCredits` | `() => void` | Show current credits in alert |
29
- | `onTestDuplicate` | `() => void` | Test duplicate renewal protection |
17
+ 1. **Renewal Simulation**: Simulate subscription renewal with credit allocation
18
+ 2. **Credits Inspection**: Display current credit balance and purchase date
19
+ 3. **Duplicate Protection Testing**: Test that duplicate renewals are prevented
20
+ 4. **Development Mode Guard**: Only available in `__DEV__` mode
21
+ 5. **Production Safety**: Returns `undefined` in production builds
22
+ 6. **Alert-Based Feedback**: Show test results in alert dialogs
30
23
 
31
- ## Important Notes
24
+ ### Integration Points
32
25
 
33
- โš ๏ธ **Development Only**
34
- - This hook only works in `__DEV__` mode
35
- - Returns `undefined` in production builds
36
- - Use for testing and development purposes only
26
+ - **useInitializeCredits**: For credit initialization testing
27
+ - **Credits Repository**: `src/domains/wallet/infrastructure/repositories/CreditsRepository.ts`
28
+ - **Development Tools**: For testing and debugging
29
+ - **Alert API**: For displaying test results
37
30
 
38
- ## Basic Usage
31
+ ## Restrictions
39
32
 
40
- ```typescript
41
- function DevTestSection() {
42
- const devCallbacks = useDevTestCallbacks();
33
+ ### REQUIRED
43
34
 
44
- // Don't render in production
45
- if (!devCallbacks) return null;
35
+ - **Development Only**: MUST only use in `__DEV__` mode
36
+ - **Guard Checks**: MUST check if hook returns undefined
37
+ - **Visual Distinction**: SHOULD make dev tools visually distinct
38
+ - **Documentation**: MUST document behavior for other developers
46
39
 
47
- const { onTestRenewal, onCheckCredits, onTestDuplicate } = devCallbacks;
40
+ ### PROHIBITED
48
41
 
49
- return (
50
- <View style={styles.devSection}>
51
- <Text style={styles.title}>Developer Tools</Text>
42
+ - **NEVER** use in production code paths
43
+ - **NEVER** ship dev UI to production
44
+ - **DO NOT** rely on dev tools for production features
45
+ - **DO NOT** expose dev functionality to end users
52
46
 
53
- <Button onPress={onTestRenewal} title="Test Renewal" />
54
- <Button onPress={onCheckCredits} title="Check Credits" />
55
- <Button onPress={onTestDuplicate} title="Test Duplicate Protection" />
56
- </View>
57
- );
58
- }
59
- ```
47
+ ### CRITICAL SAFETY
60
48
 
61
- ## Advanced Usage
49
+ - **ALWAYS** guard with `__DEV__` checks
50
+ - **NEVER** call hook functions in production
51
+ - **MUST** remove or disable before release
52
+ - **ALWAYS** test that dev tools don't affect production
62
53
 
63
- ### Complete Dev Test Panel
54
+ ## AI Agent Guidelines
64
55
 
65
- ```typescript
66
- function DevTestPanel() {
67
- const devCallbacks = useDevTestCallbacks();
56
+ ### When Implementing Development Testing
68
57
 
69
- if (!__DEV__ || !devCallbacks) return null;
58
+ 1. **Always** guard with `__DEV__` checks
59
+ 2. **Always** check if hook returns undefined
60
+ 3. **Always** make dev tools visually distinct
61
+ 4. **Never** expose dev tools to production users
62
+ 5. **Always** document development-only behavior
70
63
 
71
- const { onTestRenewal, onCheckCredits, onTestDuplicate } = devCallbacks;
64
+ ### Integration Checklist
72
65
 
73
- return (
74
- <ScrollView style={styles.devPanel}>
75
- <Text style={styles.header}>Developer Test Panel</Text>
66
+ - [ ] Import from correct path: `@umituz/react-native-subscription`
67
+ - [ ] Guard with `__DEV__` check
68
+ - [ ] Check if hook returns undefined
69
+ - [ ] Make dev UI visually distinct
70
+ - [ ] Test renewal simulation
71
+ - [ ] Test credits inspection
72
+ - [ ] Test duplicate protection
73
+ - [ ] Verify undefined returned in production
74
+ - [ ] Remove or disable before release
76
75
 
77
- <View style={styles.section}>
78
- <Text style={styles.sectionTitle}>Renewal Testing</Text>
76
+ ### Common Patterns
79
77
 
80
- <TouchableOpacity
81
- style={styles.button}
82
- onPress={onTestRenewal}
83
- >
84
- <Text>Test Renewal (Add Credits)</Text>
85
- </TouchableOpacity>
78
+ 1. **Dev Test Panel**: Dedicated screen for testing
79
+ 2. **Settings Integration**: Add dev tools to settings screen
80
+ 3. **Debug Menu**: Hidden menu for testing
81
+ 4. **Flow Testing**: Test complete renewal flows
82
+ 5. **Edge Case Testing**: Test duplicate handling and errors
86
83
 
87
- <Text style={styles.help}>
88
- Simulates a subscription renewal and adds credits using ACCUMULATE mode
89
- </Text>
90
- </View>
84
+ ## Related Documentation
91
85
 
92
- <View style={styles.section}>
93
- <Text style={styles.sectionTitle}>Credits Inspection</Text>
94
-
95
- <TouchableOpacity
96
- style={styles.button}
97
- onPress={onCheckCredits}
98
- >
99
- <Text>Check Current Credits</Text>
100
- </TouchableOpacity>
101
-
102
- <Text style={styles.help}>
103
- Display current credit balance and purchase date
104
- </Text>
105
- </View>
106
-
107
- <View style={styles.section}>
108
- <Text style={styles.sectionTitle}>Duplicate Protection</Text>
109
-
110
- <TouchableOpacity
111
- style={styles.button}
112
- onPress={onTestDuplicate}
113
- >
114
- <Text>Test Duplicate Protection</Text>
115
- </TouchableOpacity>
116
-
117
- <Text style={styles.help}>
118
- Tests that duplicate renewals with the same ID are prevented
119
- </Text>
120
- </View>
121
- </ScrollView>
122
- );
123
- }
124
- ```
125
-
126
- ### With Settings Screen Integration
127
-
128
- ```typescript
129
- function SettingsScreen() {
130
- const devCallbacks = useDevTestCallbacks();
131
-
132
- return (
133
- <ScrollView>
134
- <Section title="Account">
135
- <SettingsItem label="Email" value={user?.email} />
136
- <SettingsItem label="Subscription" value={isPremium ? 'Premium' : 'Free'} />
137
- </Section>
138
-
139
- {/* Only show in development */}
140
- {__DEV__ && devCallbacks && (
141
- <Section title="Developer Tools">
142
- <SettingsItem
143
- label="Test Renewal"
144
- onPress={devCallbacks.onTestRenewal}
145
- />
146
- <SettingsItem
147
- label="Check Credits"
148
- onPress={devCallbacks.onCheckCredits}
149
- />
150
- <SettingsItem
151
- label="Test Duplicate Protection"
152
- onPress={devCallbacks.onTestDuplicate}
153
- />
154
- </Section>
155
- )}
156
- </ScrollView>
157
- );
158
- }
159
- ```
160
-
161
- ### With Debug Menu
162
-
163
- ```typescript
164
- function DebugMenu() {
165
- const devCallbacks = useDevTestCallbacks();
166
-
167
- if (!__DEV__) return null;
168
-
169
- return (
170
- <Menu>
171
- {devCallbacks && (
172
- <>
173
- <MenuItem onPress={devCallbacks.onTestRenewal}>
174
- Test Renewal
175
- </MenuItem>
176
- <MenuItem onPress={devCallbacks.onCheckCredits}>
177
- Check Credits
178
- </MenuItem>
179
- <MenuItem onPress={devCallbacks.onTestDuplicate}>
180
- Test Duplicate Protection
181
- </MenuItem>
182
- </>
183
- )}
184
- </Menu>
185
- );
186
- }
187
- ```
188
-
189
- ## Test Functions
190
-
191
- ### onTestRenewal
192
-
193
- Simulates a subscription renewal event:
194
-
195
- ```typescript
196
- const onTestRenewal = () => {
197
- // Simulates renewal with:
198
- // - renewalId: `dev_renewal_${Date.now()}`
199
- // - productId: 'test_yearly_subscription'
200
- // - Mode: ACCUMULATE (adds to existing credits)
201
-
202
- // Shows alert with:
203
- // - New credit balance
204
- // - Confirmation of ACCUMULATE mode
205
- };
206
- ```
207
-
208
- **Example output:**
209
- ```
210
- โœ… Test Renewal Success
211
- Credits Updated!
212
-
213
- New Balance: 1200
214
-
215
- (ACCUMULATE mode - credits added to existing)
216
- ```
217
-
218
- ### onCheckCredits
219
-
220
- Displays current credit information:
221
-
222
- ```typescript
223
- const onCheckCredits = () => {
224
- // Shows alert with:
225
- // - Current credit balance
226
- // - Purchase date (or "N/A")
227
- };
228
- ```
229
-
230
- **Example output:**
231
- ```
232
- ๐Ÿ“Š Current Credits
233
- Credits: 100
234
-
235
- Purchased: January 15, 2024
236
- ```
237
-
238
- ### onTestDuplicate
239
-
240
- Tests duplicate renewal protection:
241
-
242
- ```typescript
243
- const onTestDuplicate = () => {
244
- // Performs two initialization calls with same renewalId:
245
- // - First call: Adds credits
246
- // - Second call: Should be skipped
247
-
248
- // Shows alert with:
249
- // - First call result
250
- // - Second call result (should indicate protection worked)
251
- };
252
- ```
253
-
254
- **Example output:**
255
- ```
256
- Duplicate Test
257
- First call: โœ… Added credits
258
-
259
- Second call: โœ… Skipped (protection works!)
260
- ```
261
-
262
- ## Development Logging
263
-
264
- The hook logs detailed information in development:
265
-
266
- ```typescript
267
- // Test renewal
268
- ๐Ÿงช [Dev Test] Simulating auto-renewal...
269
- {
270
- userId: 'user-123',
271
- renewalId: 'dev_renewal_1705311234567'
272
- }
273
- โœ… [Dev Test] Renewal completed:
274
- {
275
- success: true,
276
- credits: 1100
277
- }
278
-
279
- // Check credits
280
- ๐Ÿ“Š Current Credits
281
- Credits: 100
282
- Purchased: January 15, 2024
283
-
284
- // Test duplicate
285
- ๐Ÿงช [Dev Test] Testing duplicate protection...
286
- First call: { credits: 100, ... }
287
- Second call: { credits: 100, ... }
288
- ```
289
-
290
- ## Examples
291
-
292
- ### Comprehensive Dev Dashboard
293
-
294
- ```typescript
295
- function DevDashboard() {
296
- const devCallbacks = useDevTestCallbacks();
297
-
298
- if (!__DEV__ || !devCallbacks) return null;
299
-
300
- const { user } = useAuth();
301
- const { credits } = useCredits();
302
-
303
- return (
304
- <View style={styles.dashboard}>
305
- <View style={styles.header}>
306
- <Text style={styles.title}>Development Dashboard</Text>
307
- <Text style={styles.subtitle}>
308
- User: {user?.uid || 'Not logged in'}
309
- </Text>
310
- <Text style={styles.subtitle}>
311
- Credits: {credits?.credits || 0}
312
- </Text>
313
- </View>
314
-
315
- <View style={styles.actions}>
316
- <TouchableOpacity
317
- style={styles.actionButton}
318
- onPress={devCallbacks.onTestRenewal}
319
- >
320
- <Icon name="refresh" size={20} />
321
- <Text>Simulate Renewal</Text>
322
- </TouchableOpacity>
323
-
324
- <TouchableOpacity
325
- style={styles.actionButton}
326
- onPress={devCallbacks.onCheckCredits}
327
- >
328
- <Icon name="search" size={20} />
329
- <Text>Inspect Credits</Text>
330
- </TouchableOpacity>
331
-
332
- <TouchableOpacity
333
- style={styles.actionButton}
334
- onPress={devCallbacks.onTestDuplicate}
335
- >
336
- <Icon name="shield" size={20} />
337
- <Text>Test Duplicate Protection</Text>
338
- </TouchableOpacity>
339
- </View>
340
-
341
- <View style={styles.info}>
342
- <Text style={styles.infoTitle}>Test Mode Active</Text>
343
- <Text style={styles.infoText}>
344
- All operations use test data and won't affect production
345
- </Text>
346
- </View>
347
- </View>
348
- );
349
- }
350
- ```
351
-
352
- ### With Flow Testing
353
-
354
- ```typescript
355
- function RenewalFlowTest() {
356
- const devCallbacks = useDevTestCallbacks();
357
-
358
- if (!__DEV__ || !devCallbacks) return null;
359
-
360
- const testRenewalFlow = async () => {
361
- // 1. Check initial credits
362
- devCallbacks.onCheckCredits();
363
-
364
- // 2. Simulate renewal
365
- await new Promise(resolve => setTimeout(resolve, 1000));
366
- devCallbacks.onTestRenewal();
367
-
368
- // 3. Verify credits increased
369
- await new Promise(resolve => setTimeout(resolve, 1000));
370
- devCallbacks.onCheckCredits();
371
-
372
- // 4. Test duplicate protection
373
- await new Promise(resolve => setTimeout(resolve, 1000));
374
- devCallbacks.onTestDuplicate();
375
- };
376
-
377
- return (
378
- <Button
379
- onPress={testRenewalFlow}
380
- title="Run Complete Renewal Flow Test"
381
- />
382
- );
383
- }
384
- ```
385
-
386
- ## Best Practices
387
-
388
- 1. **Development only** - Never use in production code
389
- 2. **Guard with `__DEV__`** - Always check if in development mode
390
- 3. **Clear UI** - Make dev tools visually distinct
391
- 4. **Test thoroughly** - Use for testing renewal flows
392
- 5. **Document behavior** - Leave clear comments for other developers
393
- 6. **Remove before release** - Ensure dev UI doesn't ship
394
- 7. **Test edge cases** - Duplicate handling, error cases
395
-
396
- ## Production Safety
397
-
398
- The hook is production-safe:
399
-
400
- ```typescript
401
- export const useDevTestCallbacks = (): DevTestActions | undefined => {
402
- // ... implementation
403
-
404
- if (!__DEV__) {
405
- return undefined; // โœ… Returns undefined in production
406
- }
407
-
408
- return { onTestRenewal, onCheckCredits, onTestDuplicate };
409
- };
410
- ```
411
-
412
- ## Related Hooks
413
-
414
- - **useCredits** - For accessing credits balance
415
- - **useInitializeCredits** - For credit initialization
416
- - **usePremiumWithCredits** - For premium + credits integration
417
-
418
- ## See Also
419
-
420
- - [Credits README](../../../domains/wallet/README.md)
421
- - [Renewal Testing Guide](../../../docs/RENEWAL_TESTING.md)
422
- - [Development Tools](../../../docs/DEV_TOOLS.md)
86
+ - **useCredits**: For accessing credits balance
87
+ - **useInitializeCredits**: For credit initialization
88
+ - **usePremiumWithCredits**: For premium + credits integration
89
+ - **Credits README**: `src/domains/wallet/README.md`
90
+ - **Renewal Testing Guide**: `src/docs/RENEWAL_TESTING.md`
91
+ - **Development Tools**: `src/docs/DEV_TOOLS.md`