@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,199 +1,40 @@
1
1
  # Paywall Entities
2
2
 
3
+ ## Location
3
4
  Domain entities for paywall configuration and state management.
4
5
 
5
- ## Overview
6
-
7
- This directory contains entities representing paywall configuration, triggers, and display logic.
8
-
9
- ## Entities
10
-
11
- ### PaywallTrigger
12
- Represents an event that triggers paywall display.
13
-
14
- ```typescript
15
- interface PaywallTrigger {
16
- type: PaywallTriggerType;
17
- feature?: string;
18
- packageName?: string;
19
- context?: Record<string, any>;
20
- timestamp: number;
21
- }
22
-
23
- type PaywallTriggerType =
24
- | 'premium_feature' // Premium feature access attempt
25
- | 'credit_gate' // Credit gate failure
26
- | 'manual' // User manually opened
27
- | 'onboarding_complete' // Post-onboarding
28
- | 'usage_limit' // Free tier limit reached
29
- | 'subscription_expired'; // Subscription expired
30
- ```
31
-
32
- **Usage:**
33
- ```typescript
34
- const trigger: PaywallTrigger = {
35
- type: 'premium_feature',
36
- feature: 'ai_generation',
37
- context: { cost: 5 },
38
- timestamp: Date.now(),
39
- };
40
- ```
41
-
42
- ### PaywallConfig
43
- Configuration for paywall display.
44
-
45
- ```typescript
46
- interface PaywallConfig {
47
- title: string;
48
- subtitle: string;
49
- description?: string;
50
- features: string[];
51
- highlightBenefit?: string; // Main value proposition
52
- packages: PaywallPackage[];
53
- defaultPackage?: string; // Pre-selected package
54
- dismissible: boolean;
55
- showCloseButton: boolean;
56
- onUpgrade: (pkg: PaywallPackage) => void;
57
- onDismiss: () => void;
58
- }
59
- ```
60
-
61
- **Usage:**
62
- ```typescript
63
- const config: PaywallConfig = {
64
- title: 'Upgrade to Premium',
65
- subtitle: 'Unlock all features',
66
- features: [
67
- 'Unlimited access',
68
- 'Priority support',
69
- 'Ad-free experience',
70
- ],
71
- packages: availablePackages,
72
- dismissible: true,
73
- showCloseButton: true,
74
- onUpgrade: (pkg) => purchasePackage(pkg),
75
- onDismiss: () => navigation.goBack(),
76
- };
77
- ```
78
-
79
- ### PaywallPackage
80
- Represents a subscription package displayed in paywall.
81
-
82
- ```typescript
83
- interface PaywallPackage {
84
- identifier: string; // Unique package ID
85
- productIdentifier: string; // RevenueCat product ID
86
- title: string; // Display title
87
- description: string; // Package description
88
- price: number; // Price in local currency
89
- pricePerMonth?: number; // Monthly equivalent (for annual)
90
- currencyCode: string; // Currency code
91
- period: PackagePeriod; // Billing period
92
- features: string[]; // Package features
93
- popular?: boolean; // Highlight as popular
94
- savings?: number; // Savings amount (for annual)
95
- badge?: string; // Custom badge text
96
- }
97
-
98
- type PackagePeriod = 'monthly' | 'annual' | 'lifetime';
99
- ```
100
-
101
- **Usage:**
102
- ```typescript
103
- const premiumPackage: PaywallPackage = {
104
- identifier: 'premium_annual',
105
- productIdentifier: 'com.app.premium.annual',
106
- title: 'Premium Annual',
107
- description: 'Best value - Save 50%',
108
- price: 99.99,
109
- pricePerMonth: 8.33,
110
- currencyCode: 'USD',
111
- period: 'annual',
112
- features: [
113
- 'Unlimited access',
114
- 'Priority support',
115
- 'Ad-free',
116
- 'Advanced features',
117
- ],
118
- popular: true,
119
- savings: 20.00,
120
- badge: 'BEST VALUE',
121
- };
122
- ```
123
-
124
- ### PaywallState
125
- Manages current paywall state and context.
126
-
127
- ```typescript
128
- interface PaywallState {
129
- visible: boolean;
130
- trigger?: PaywallTrigger;
131
- selectedPackage?: string;
132
- pendingAction?: () => void; // Execute after upgrade
133
- metadata?: {
134
- userId?: string;
135
- screen?: string; // Screen where paywall shown
136
- previousScreen?: string; // Screen before paywall
137
- };
138
- }
139
- ```
140
-
141
- **Usage:**
142
- ```typescript
143
- const state: PaywallState = {
144
- visible: true,
145
- trigger: {
146
- type: 'premium_feature',
147
- feature: 'ai_generation',
148
- timestamp: Date.now(),
149
- },
150
- selectedPackage: 'premium_annual',
151
- pendingAction: () => executeAIGeneration(),
152
- metadata: {
153
- userId: 'user-123',
154
- screen: 'AIGeneration',
155
- },
156
- };
157
- ```
158
-
159
- ## Key Operations
160
-
161
- ### Create Trigger
162
- ```typescript
163
- function createTrigger(
164
- type: PaywallTriggerType,
165
- context?: Record<string, any>
166
- ): PaywallTrigger {
167
- return {
168
- type,
169
- context,
170
- timestamp: Date.now(),
171
- };
172
- }
173
- ```
174
-
175
- ### Validate Config
176
- ```typescript
177
- function validatePaywallConfig(config: PaywallConfig): void {
178
- if (!config.title) throw new Error('Title is required');
179
- if (!config.packages || config.packages.length === 0) {
180
- throw new Error('At least one package is required');
181
- }
182
- if (config.defaultPackage && !config.packages.find(p => p.identifier === config.defaultPackage)) {
183
- throw new Error('Default package must be in packages list');
184
- }
185
- }
186
- ```
187
-
188
- ## Best Practices
189
-
190
- 1. **Rich Context**: Include context in triggers for analytics
191
- 2. **Validation**: Validate configurations before use
192
- 3. **Immutability**: Treat entities as immutable values
193
- 4. **Type Safety**: Use strict TypeScript types
194
- 5. **Analytics**: Track all paywall events and triggers
195
-
196
- ## Related
197
-
6
+ ## Strategy
7
+ This directory contains entities representing paywall configuration, triggers, and display logic with rich context for analytics.
8
+
9
+ ## Restrictions
10
+
11
+ ### REQUIRED
12
+ - Must include context in triggers for analytics
13
+ - Must validate configurations before use
14
+ - Must treat entities as immutable values
15
+ - Must use strict TypeScript types
16
+
17
+ ### PROHIBITED
18
+ - DO NOT create triggers without context
19
+ - DO NOT use unvalidated configurations
20
+ - DO NOT mutate entities after creation
21
+ - DO NOT bypass type safety
22
+
23
+ ### CRITICAL SAFETY
24
+ - All triggers MUST include analytics context
25
+ - All configurations MUST be validated before use
26
+ - All entities MUST be immutable
27
+ - Type safety MUST be maintained
28
+
29
+ ## AI Agent Guidelines
30
+ 1. Include rich context in triggers for analytics tracking
31
+ 2. Validate all configurations before using them
32
+ 3. Treat all entities as immutable values
33
+ 4. Use strict TypeScript types for all properties
34
+ 5. Track all paywall events and triggers
35
+ 6. Provide clear validation error messages
36
+ 7. Test entity creation and validation thoroughly
37
+
38
+ ## Related Documentation
198
39
  - [Paywall README](../README.md)
199
40
  - [PaywallVisibility Hook](../../presentation/hooks/usePaywallVisibility.md)
@@ -1,129 +1,41 @@
1
1
  # Paywall Hooks
2
2
 
3
+ ## Location
3
4
  React hooks for paywall management and subscription upgrades.
4
5
 
5
- ## Overview
6
-
7
- This directory contains React hooks specifically for paywall functionality.
8
-
9
- ## Hooks
10
-
11
- ### usePaywallVisibility
12
- Manages paywall visibility state.
13
-
14
- ```typescript
15
- function usePaywallVisibility(): {
16
- showPaywall: boolean;
17
- setShowPaywall: (visible: boolean) => void;
18
- openPaywall: () => void;
19
- closePaywall: () => void;
20
- }
21
- ```
22
-
23
- **Usage:**
24
- ```typescript
25
- function PaywallWrapper() {
26
- const { showPaywall, closePaywall } = usePaywallVisibility();
27
-
28
- return (
29
- <>
30
- <YourApp />
31
- <Modal visible={showPaywall} onRequestClose={closePaywall}>
32
- <PaywallScreen onClose={closePaywall} />
33
- </Modal>
34
- </>
35
- );
36
- }
37
- ```
38
-
39
- ### usePaywallOperations
40
- Handles paywall purchase operations.
41
-
42
- ```typescript
43
- function usePaywallOperations(config: {
44
- userId: string | undefined;
45
- isAnonymous: boolean;
46
- onPaywallClose?: () => void;
47
- onPurchaseSuccess?: () => void;
48
- onAuthRequired?: () => void;
49
- }): {
50
- handlePurchase: (pkg: Package) => Promise<boolean>;
51
- handleRestore: () => Promise<boolean>;
52
- pendingPackage: Package | null;
53
- }
54
- ```
55
-
56
- **Usage:**
57
- ```typescript
58
- function Paywall() {
59
- const { handlePurchase, handleRestore } = usePaywallOperations({
60
- userId: user?.uid,
61
- isAnonymous: !user,
62
- onPurchaseSuccess: () => navigation.goBack(),
63
- onAuthRequired: () => showAuthModal(),
64
- });
65
-
66
- return (
67
- <View>
68
- <PackageList onSelectPackage={handlePurchase} />
69
- <Button onPress={handleRestore}>Restore</Button>
70
- </View>
71
- );
72
- }
73
- ```
74
-
75
- ## Usage Patterns
76
-
77
- ### Feature Gating
78
- ```typescript
79
- function useFeatureGate(feature: string) {
80
- const { openPaywall } = usePaywallVisibility();
81
- const { isPremium } = usePremium();
82
-
83
- const gateFeature = useCallback(() => {
84
- if (!isPremium) {
85
- analytics.track('paywall_triggered', { feature });
86
- openPaywall();
87
- return false;
88
- }
89
- return true;
90
- }, [isPremium, openPaywall]);
91
-
92
- return gateFeature;
93
- }
94
- ```
95
-
96
- ### Trigger-Based Paywall
97
- ```typescript
98
- function useTriggeredPaywall() {
99
- const { openPaywall } = usePaywallVisibility();
100
-
101
- const showPaywallForFeature = (feature: string, context?: any) => {
102
- openPaywall();
103
- // Store trigger context for analytics
104
- PaywallTracker.record({
105
- type: 'premium_feature',
106
- feature,
107
- context,
108
- timestamp: Date.now(),
109
- });
110
- };
111
-
112
- return { showPaywallForFeature };
113
- }
114
- ```
115
-
116
- ## Best Practices
117
-
118
- 1. **Centralized State**: Use global paywall visibility
119
- 2. **Auth Integration**: Handle authentication before purchase
120
- 3. **Pending Actions**: Store pending actions for post-purchase
121
- 4. **Analytics**: Track all paywall interactions
122
- 5. **Error Handling**: Handle purchase failures gracefully
123
- 6. **User Context**: Show relevant paywall based on context
124
-
125
- ## Related
126
-
6
+ ## Strategy
7
+ This directory contains React hooks specifically for paywall functionality with centralized state management and proper analytics tracking.
8
+
9
+ ## Restrictions
10
+
11
+ ### REQUIRED
12
+ - Must use centralized paywall visibility state
13
+ - Must handle authentication before purchase
14
+ - Must store pending actions for post-purchase
15
+ - Must track all paywall interactions
16
+
17
+ ### PROHIBITED
18
+ - DO NOT use local paywall state
19
+ - DO NOT skip authentication checks
20
+ - DO NOT lose pending actions
21
+ - DO NOT skip analytics tracking
22
+
23
+ ### CRITICAL SAFETY
24
+ - Authentication MUST be checked before purchase
25
+ - Pending actions MUST be preserved through purchase flow
26
+ - All interactions MUST be tracked for analytics
27
+ - Purchase failures MUST be handled gracefully
28
+
29
+ ## AI Agent Guidelines
30
+ 1. Use global state for paywall visibility management
31
+ 2. Handle authentication before initiating purchase
32
+ 3. Store pending actions for execution after purchase
33
+ 4. Track all paywall interactions for analytics
34
+ 5. Handle purchase failures with graceful recovery
35
+ 6. Show relevant paywall based on user context
36
+ 7. Test all paywall state transitions thoroughly
37
+
38
+ ## Related Documentation
127
39
  - [usePaywallVisibility](../../presentation/hooks/usePaywallVisibility.md)
128
40
  - [usePaywallOperations](../../presentation/hooks/usePaywallOperations.md)
129
41
  - [PremiumGate Hook](../../presentation/hooks/usePremiumGate.md)