@umituz/react-native-subscription 2.14.99 → 2.14.100

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 (92) hide show
  1. package/README.md +211 -394
  2. package/package.json +1 -1
  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/errors/README.md +33 -287
  9. package/src/domain/value-objects/README.md +43 -179
  10. package/src/domains/README.md +50 -238
  11. package/src/domains/README.md.bak +274 -0
  12. package/src/domains/config/README.md +93 -383
  13. package/src/domains/config/domain/README.md +23 -376
  14. package/src/domains/config/domain/entities/README.md +34 -343
  15. package/src/domains/paywall/README.md +99 -369
  16. package/src/domains/paywall/components/README.md +34 -178
  17. package/src/domains/paywall/entities/README.md +34 -193
  18. package/src/domains/paywall/hooks/README.md +34 -122
  19. package/src/domains/wallet/README.md +34 -275
  20. package/src/domains/wallet/README.md.bak +209 -0
  21. package/src/domains/wallet/domain/README.md +34 -101
  22. package/src/domains/wallet/domain/entities/README.md +34 -115
  23. package/src/domains/wallet/domain/errors/README.md +34 -151
  24. package/src/domains/wallet/infrastructure/README.md +34 -89
  25. package/src/domains/wallet/presentation/components/README.md +34 -224
  26. package/src/domains/wallet/presentation/hooks/README.md +34 -248
  27. package/src/infrastructure/README.md +37 -496
  28. package/src/infrastructure/mappers/README.md +0 -13
  29. package/src/infrastructure/repositories/README.md +74 -360
  30. package/src/infrastructure/services/README.md +95 -370
  31. package/src/presentation/README.md +123 -408
  32. package/src/presentation/README.md.bak +172 -0
  33. package/src/presentation/components/README.md +151 -179
  34. package/src/presentation/components/README.md.bak +217 -0
  35. package/src/presentation/components/details/CreditRow.md +65 -310
  36. package/src/presentation/components/details/DetailRow.md +63 -255
  37. package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
  38. package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
  39. package/src/presentation/components/details/README.md +97 -447
  40. package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
  41. package/src/presentation/components/feedback/README.md +97 -445
  42. package/src/presentation/components/paywall/PaywallModal.md +66 -416
  43. package/src/presentation/components/paywall/README.md +50 -186
  44. package/src/presentation/components/sections/README.md +97 -466
  45. package/src/presentation/components/sections/SubscriptionSection.md +92 -244
  46. package/src/presentation/hooks/README.md +154 -741
  47. package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
  48. package/src/presentation/hooks/useAuthGate.md +61 -375
  49. package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
  50. package/src/presentation/hooks/useCreditChecker.md +73 -378
  51. package/src/presentation/hooks/useCredits.md +74 -313
  52. package/src/presentation/hooks/useCredits.md.bak +231 -0
  53. package/src/presentation/hooks/useCreditsGate.md +66 -318
  54. package/src/presentation/hooks/useDeductCredit.md +0 -76
  55. package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
  56. package/src/presentation/hooks/useFeatureGate.md +105 -150
  57. package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
  58. package/src/presentation/hooks/useInitializeCredits.md +64 -430
  59. package/src/presentation/hooks/usePaywall.md +61 -306
  60. package/src/presentation/hooks/usePaywallOperations.md +64 -458
  61. package/src/presentation/hooks/usePaywallVisibility.md +67 -316
  62. package/src/presentation/hooks/usePremium.md +84 -226
  63. package/src/presentation/hooks/usePremiumGate.md +60 -395
  64. package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
  65. package/src/presentation/hooks/useSubscription.md +66 -422
  66. package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
  67. package/src/presentation/hooks/useSubscriptionGate.md +80 -164
  68. package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
  69. package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
  70. package/src/presentation/hooks/useUserTier.md +63 -328
  71. package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
  72. package/src/presentation/screens/README.md +48 -190
  73. package/src/presentation/types/README.md +0 -16
  74. package/src/presentation/utils/README.md +0 -21
  75. package/src/revenuecat/README.md +99 -518
  76. package/src/revenuecat/application/README.md +35 -150
  77. package/src/revenuecat/application/ports/README.md +34 -162
  78. package/src/revenuecat/domain/README.md +42 -141
  79. package/src/revenuecat/domain/constants/README.md +34 -176
  80. package/src/revenuecat/domain/entities/README.md +34 -374
  81. package/src/revenuecat/domain/errors/README.md +47 -191
  82. package/src/revenuecat/domain/types/README.md +34 -366
  83. package/src/revenuecat/domain/value-objects/README.md +34 -434
  84. package/src/revenuecat/infrastructure/README.md +34 -43
  85. package/src/revenuecat/infrastructure/config/README.md +32 -23
  86. package/src/revenuecat/infrastructure/handlers/README.md +34 -211
  87. package/src/revenuecat/infrastructure/managers/README.md +34 -42
  88. package/src/revenuecat/infrastructure/services/README.md +35 -318
  89. package/src/revenuecat/infrastructure/utils/README.md +34 -375
  90. package/src/revenuecat/presentation/README.md +34 -176
  91. package/src/revenuecat/presentation/hooks/README.md +29 -35
  92. package/src/utils/README.md +38 -525
@@ -0,0 +1,172 @@
1
+ # Presentation Layer
2
+
3
+ UI/UX layer for the subscription system - React hooks, components, and screens.
4
+
5
+ ## Location
6
+
7
+ **Directory**: `src/presentation/`
8
+
9
+ **Type**: Layer
10
+
11
+ ## Strategy
12
+
13
+ ### Layer Responsibilities
14
+
15
+ The Presentation Layer is responsible for:
16
+
17
+ 1. **State Management**
18
+ - React hooks for data fetching and mutations
19
+ - TanStack Query for server state management
20
+ - Local state management for UI state
21
+
22
+ 2. **UI Components**
23
+ - Reusable subscription components
24
+ - Feature gating UI elements
25
+ - Credit display components
26
+ - Paywall components
27
+
28
+ 3. **User Interaction**
29
+ - Handle user actions
30
+ - Display appropriate feedback
31
+ - Guide users through purchase flows
32
+ - Show upgrade prompts at right time
33
+
34
+ ### Architecture Pattern
35
+
36
+ The presentation layer follows a layered architecture where:
37
+ - Hooks manage state and data fetching at the top level
38
+ - Components consume hooks and render UI
39
+ - Screens compose multiple components together
40
+ - All layers communicate with the domain layer for business logic
41
+
42
+ ### Integration Points
43
+
44
+ - **Domain Layer**: Business logic and data access
45
+ - **TanStack Query**: Server state management
46
+ - **RevenueCat**: Purchase operations
47
+ - **Navigation**: Screen routing
48
+
49
+ ## Restrictions
50
+
51
+ ### REQUIRED
52
+
53
+ - **Type Safety**: All components MUST be typed with TypeScript
54
+ - **Error Boundaries**: MUST implement error boundaries for all screens
55
+ - **Loading States**: MUST show loading indicators during async operations
56
+ - **User Feedback**: MUST provide feedback for all user actions
57
+
58
+ ### PROHIBITED
59
+
60
+ - **NEVER** include business logic in components (use hooks instead)
61
+ - **NEVER** make direct API calls from components (use hooks)
62
+ - **DO NOT** store sensitive data in component state
63
+ - **NEVER** hardcode strings (use localization)
64
+
65
+ ### CRITICAL SAFETY
66
+
67
+ - **ALWAYS** validate props before rendering
68
+ - **ALWAYS** handle loading and error states
69
+ - **NEVER** trust client-side state for security decisions
70
+ - **MUST** implement proper error boundaries
71
+ - **ALWAYS** sanitize user inputs before display
72
+
73
+ ## Rules
74
+
75
+ ### Component Structure
76
+
77
+ **CORRECT**: Proper component structure includes:
78
+ - Define TypeScript interface for props
79
+ - Import and use appropriate hooks for data fetching
80
+ - Return loading indicator when data is fetching
81
+ - Return error display when there's an error
82
+ - Render actual component only when data is available
83
+
84
+ **INCORRECT**: No loading/error handling
85
+ - Don't render component without checking if data is loading
86
+ - Don't display component without handling potential errors
87
+ - Never assume data is always available immediately
88
+
89
+ **INCORRECT**: Business logic in component
90
+ - Don't use useEffect to fetch data directly
91
+ - Don't manage complex state with useState for business logic
92
+ - Never include data transformation logic in components
93
+
94
+ ### Hook Usage
95
+
96
+ **CORRECT**: Use hooks for data fetching
97
+ - Call useCredits to get credit balance with loading and error states
98
+ - Call usePremium to check premium status
99
+ - Always check if loading is true before rendering
100
+ - Always check if error exists before rendering
101
+
102
+ **INCORRECT**: Direct API calls in component
103
+ - Don't use useEffect with axios or fetch to call APIs
104
+ - Don't manage async operations manually in components
105
+ - Never handle API responses directly in UI components
106
+
107
+ ### Error Boundaries
108
+
109
+ **CORRECT**: Wrap screens with error boundaries
110
+ - Import ErrorBoundary component
111
+ - Create fallback error screen component
112
+ - Wrap screen content with ErrorBoundary component
113
+ - Pass fallback component to ErrorBoundary
114
+
115
+ **INCORRECT**: No error boundary
116
+ - Don't export screens without error boundary wrapper
117
+ - Never let errors crash entire application
118
+ - Don't assume components will never throw errors
119
+
120
+ ## AI Agent Guidelines
121
+
122
+ ### When Building Presentation Layer
123
+
124
+ 1. **Always** use hooks for data fetching and state management
125
+ 2. **Always** handle loading and error states
126
+ 3. **Always** provide user feedback for actions
127
+ 4. **Always** implement error boundaries
128
+ 5. **Never** include business logic in components
129
+
130
+ ### Integration Checklist
131
+
132
+ - [ ] Use appropriate hooks for data access
133
+ - [ ] Handle loading states
134
+ - [ ] Handle error states
135
+ - [ ] Implement error boundaries
136
+ - [ ] Provide user feedback
137
+ - [ ] Test with various data states
138
+ - [ ] Test error scenarios
139
+ - [ ] Ensure type safety
140
+ - [ ] Use localization for all strings
141
+ - [ ] Test accessibility
142
+
143
+ ### Common Patterns
144
+
145
+ 1. **Compound Components**: Build complex UIs from simple components
146
+ 2. **Render Props**: Share stateful logic between components
147
+ 3. **Custom Hooks**: Extract reusable stateful logic
148
+ 4. **Error Boundaries**: Prevent crashes from propagating
149
+ 5. **Loading Skeletons**: Show placeholder during loading
150
+ 6. **Optimistic Updates**: Update UI immediately, rollback on failure
151
+ 7. **Graceful Degradation**: Show limited version on error
152
+ 8. **Responsive Design**: Support different screen sizes
153
+
154
+ ## Related Documentation
155
+
156
+ - **Hooks**: `hooks/README.md`
157
+ - **Components**: `components/README.md`
158
+ - **Screens**: `screens/README.md`
159
+ - **Wallet Domain**: `../../domains/wallet/README.md`
160
+ - **Paywall Domain**: `../../domains/paywall/README.md`
161
+ - **RevenueCat**: `../../revenuecat/README.md`
162
+
163
+ ## Directory Structure
164
+
165
+ The presentation layer contains:
166
+ - **hooks/** - React hooks for state management (usePremium, useSubscription, useCredits, useDeductCredit, useFeatureGate)
167
+ - **components/** - UI components organized by functionality
168
+ - **details/** - Detail cards, badges
169
+ - **feedback/** - Modals, feedback components
170
+ - **sections/** - Section components
171
+ - **paywall/** - Paywall components
172
+ - **screens/** - Full-screen components (SubscriptionDetailScreen)
@@ -2,182 +2,154 @@
2
2
 
3
3
  React Native UI components for subscription and paywall features.
4
4
 
5
- ## Overview
6
-
7
- This directory contains reusable UI components built with `@umituz/react-native-design-system`. All components are generic and app-agnostic, requiring configuration props for app-specific behavior.
8
-
9
- ## Component Structure
10
-
11
- ```
12
- presentation/components/
13
- ├── details/ # Subscription detail components
14
- │ ├── PremiumDetailsCard.md
15
- │ ├── PremiumStatusBadge.md
16
- │ ├── DetailRow.md
17
- │ └── CreditRow.md
18
- ├── sections/ # Section components for settings
19
- └── SubscriptionSection.md
20
- └── feedback/ # User feedback components
21
- └── PaywallFeedbackModal.md
22
- ```
23
-
24
- ## Components
25
-
26
- ### Detail Components
27
-
28
- #### [PremiumDetailsCard](./details/PremiumDetailsCard.md)
29
- Complete card displaying subscription details, status, and credits.
30
-
31
- ```typescript
32
- <PremiumDetailsCard
33
- statusType="active"
34
- isPremium={true}
35
- expirationDate="January 15, 2025"
36
- purchaseDate="January 15, 2024"
37
- credits={[{ id: 'monthly', label: 'Credits', current: 50, total: 100 }]}
38
- translations={translations}
39
- onManageSubscription={handleManage}
40
- onUpgrade={handleUpgrade}
41
- />
42
- ```
43
-
44
- #### [PremiumStatusBadge](./details/PremiumStatusBadge.md)
45
- Colored badge showing subscription status.
46
-
47
- ```typescript
48
- <PremiumStatusBadge
49
- status="active"
50
- activeLabel="Active"
51
- expiredLabel="Expired"
52
- noneLabel="Free"
53
- canceledLabel="Canceled"
54
- />
55
- ```
56
-
57
- #### [DetailRow](./details/DetailRow.md)
58
- Simple label-value row for displaying subscription details.
59
-
60
- ```typescript
61
- <DetailRow
62
- label="Expires"
63
- value="January 15, 2025"
64
- highlight={true}
65
- />
66
- ```
67
-
68
- #### [CreditRow](./details/CreditRow.md)
69
- Credit display with progress bar and color-coded thresholds.
70
-
71
- ```typescript
72
- <CreditRow
73
- label="Monthly Credits"
74
- current={50}
75
- total={100}
76
- remainingLabel="credits remaining"
77
- />
78
- ```
79
-
80
- ### Section Components
81
-
82
- #### [SubscriptionSection](./sections/SubscriptionSection.md)
83
- Settings section component with subscription details.
84
-
85
- ```typescript
86
- <SubscriptionSection
87
- config={subscriptionConfig}
88
- onPress={() => navigation.navigate('SubscriptionDetails')}
89
- />
90
- ```
91
-
92
- ### Feedback Components
93
-
94
- #### [PaywallFeedbackModal](./feedback/PaywallFeedbackModal.md)
95
- Modal for collecting user feedback on paywall decline.
96
-
97
- ```typescript
98
- <PaywallFeedbackModal
99
- visible={showFeedback}
100
- onClose={() => setShowFeedback(false)}
101
- onSubmit={(reason) => trackFeedback(reason)}
102
- />
103
- ```
104
-
105
- ## Usage Patterns
106
-
107
- ### In Settings Screen
108
-
109
- ```typescript
110
- function SettingsScreen() {
111
- const config = useSubscriptionSettingsConfig({
112
- userId: user?.uid,
113
- translations: englishTranslations,
114
- });
115
-
116
- return (
117
- <ScrollView>
118
- <SubscriptionSection
119
- config={config.sectionConfig}
120
- onPress={() => navigation.navigate('SubscriptionDetails')}
121
- />
122
- </ScrollView>
123
- );
124
- }
125
- ```
126
-
127
- ### In Paywall Screen
128
-
129
- ```typescript
130
- function PaywallScreen() {
131
- const [showFeedback, setShowFeedback] = useState(false);
132
-
133
- return (
134
- <View>
135
- <PaywallContent onClose={() => setShowFeedback(true)} />
136
-
137
- <PaywallFeedbackModal
138
- visible={showFeedback}
139
- onClose={() => setShowFeedback(false)}
140
- onSubmit={handleSubmitFeedback}
141
- />
142
- </View>
143
- );
144
- }
145
- ```
146
-
147
- ## Design System Integration
148
-
149
- All components use `@umituz/react-native-design-system` for:
150
-
151
- - **Tokens**: `useAppDesignTokens()` for colors, spacing, radius
152
- - **Typography**: `AtomicText` for consistent text styling
153
- - **Theming**: Automatic dark mode support via design tokens
154
-
155
- ## Styling Customization
156
-
157
- Components accept style overrides:
158
-
159
- ```typescript
160
- <PremiumDetailsCard
161
- translations={translations}
162
- containerStyle={{
163
- marginHorizontal: 16,
164
- borderRadius: 12,
165
- }}
166
- />
167
- ```
168
-
169
- ## Best Practices
170
-
171
- 1. **Use design tokens** - Leverage `useAppDesignTokens()` for consistency
172
- 2. **Provide translations** - Ensure all text is localized
173
- 3. **Handle all states** - Test premium, free, expired, canceled states
174
- 4. **Test edge cases** - Zero credits, max credits, long text
175
- 5. **Match design system** - Follow app's design language
176
- 6. **Accessibility** - Ensure proper contrast and touch targets
177
- 7. **Performance** - Memoize where appropriate
178
-
179
- ## Related
180
-
181
- - [Hooks](../hooks/README.md)
182
- - [Screens](../screens/README.md)
183
- - [Design System](https://github.com/umituz/react-native-design-system)
5
+ ## Location
6
+
7
+ **Directory**: `src/presentation/components/`
8
+
9
+ **Type**: Component Library
10
+
11
+ ## Strategy
12
+
13
+ ### Component Categories
14
+
15
+ Components are organized by functionality:
16
+
17
+ 1. **Details Components**
18
+ - CreditRow: Display credit balance and info
19
+ - DetailRow: Generic detail display row
20
+ - PremiumStatusBadge: Visual premium indicator
21
+ - PremiumDetailsCard: Premium subscription details
22
+
23
+ 2. **Feedback Components**
24
+ - PaywallFeedbackModal: User feedback collection
25
+ - Alert components: Warning and info displays
26
+
27
+ 3. **Section Components**
28
+ - SubscriptionSection: Subscription info section
29
+ - CreditsSection: Credits balance section
30
+
31
+ 4. **Paywall Components**
32
+ - PaywallModal: Upgrade/purchase modal
33
+ - Purchase options: Subscription and credit packages
34
+
35
+ ### Design Principles
36
+
37
+ All components follow these principles:
38
+ - **Reusable**: Composable and configurable
39
+ - **Typed**: Full TypeScript support
40
+ - **Accessible**: WCAG compliant where possible
41
+ - **Testable**: Easy to test in isolation
42
+ - **Themeable**: Support custom styling
43
+
44
+ ### Integration Points
45
+
46
+ - **React Native**: Core UI framework
47
+ - **Design System**: Shared UI components
48
+ - **Localization**: i18n string support
49
+ - **Theme**: Custom styling support
50
+
51
+ ## Restrictions
52
+
53
+ ### REQUIRED
54
+
55
+ - **Props Typing**: All components MUST have TypeScript interfaces
56
+ - **Default Props**: MUST provide sensible defaults
57
+ - **Accessibility**: MUST implement accessibility labels
58
+ - **Responsive**: MUST handle different screen sizes
59
+
60
+ ### PROHIBITED
61
+
62
+ - **NEVER** hardcode colors or sizes (use theme)
63
+ - **NEVER** include business logic in components
64
+ - **DO NOT** make direct API calls
65
+ - **NEVER** hardcode strings (use localization)
66
+
67
+ ### CRITICAL SAFETY
68
+
69
+ - **ALWAYS** validate props before rendering
70
+ - **ALWAYS** handle loading and error states
71
+ - **NEVER** trust user input for security decisions
72
+ - **MUST** implement proper error boundaries
73
+ - **ALWAYS** sanitize user-provided content
74
+
75
+ ## AI Agent Guidelines
76
+
77
+ ### When Building Components
78
+
79
+ 1. **Always** define TypeScript interfaces for props
80
+ 2. **Always** use theme for styling (no hardcoded values)
81
+ 3. **Always** implement accessibility labels
82
+ 4. **Always** handle loading and error states
83
+ 5. **Never** include business logic in components
84
+
85
+ ### Integration Checklist
86
+
87
+ - [ ] Define TypeScript interface for props
88
+ - [ ] Use theme for all styling
89
+ - [ ] Implement accessibility labels
90
+ - [ ] Handle loading state
91
+ - [ ] Handle error state
92
+ - [ ] Provide sensible defaults
93
+ - [ ] Test with different screen sizes
94
+ - [ ] Test accessibility
95
+ - [ ] Test with various prop combinations
96
+ - [ ] Document component usage
97
+
98
+ ### Common Patterns
99
+
100
+ 1. **Compound Components**: Build complex UIs from simple parts
101
+ 2. **Render Props**: Share stateful logic
102
+ 3. **Slot Pattern**: Allow content injection
103
+ 4. **Control Props**: Make components controlled or uncontrolled
104
+ 5. **Asynchronous States**: Handle loading, error, success states
105
+ 6. **Responsive Design**: Adapt to different screen sizes
106
+ 7. **Theme Integration**: Use design system tokens
107
+ 8. **Accessibility First**: Include a11y from the start
108
+
109
+ ## Related Documentation
110
+
111
+ - **Details Components**: `details/README.md`
112
+ - **Feedback Components**: `feedback/README.md`
113
+ - **Section Components**: `sections/README.md`
114
+ - **Paywall Components**: `paywall/README.md`
115
+ - **Design System**: External design system documentation
116
+ - **Hooks**: `../hooks/README.md`
117
+
118
+ ## Component Examples
119
+
120
+ ### CreditRow
121
+
122
+ Display user's credit balance with optional actions.
123
+
124
+ Usage:
125
+ - Set amount prop to number of credits
126
+ - Set isLoading to true during data fetch
127
+ - Provide onPress callback for navigation
128
+ - Component displays credit count and handles tap
129
+
130
+ ### PremiumStatusBadge
131
+
132
+ Visual indicator for premium subscription status.
133
+
134
+ Usage:
135
+ - Set isPremium to boolean status
136
+ - Set tier to subscription level (gold, silver, etc.)
137
+ - Component renders styled badge
138
+
139
+ ### PaywallModal
140
+
141
+ Modal for subscription and credit purchase.
142
+
143
+ Usage:
144
+ - Set isVisible to boolean for show/hide
145
+ - Provide onClose callback
146
+ - Pass features array for premium features list
147
+ - Modal handles purchase flow
148
+
149
+ ## Directory Structure
150
+
151
+ The components directory contains:
152
+ - **details/** - Detail display components (CreditRow, DetailRow, PremiumStatusBadge, PremiumDetailsCard)
153
+ - **feedback/** - Feedback and alert components (PaywallFeedbackModal)
154
+ - **sections/** - Section components (SubscriptionSection)
155
+ - **paywall/** - Paywall components (PaywallModal)