@umituz/react-native-subscription 2.37.38 → 2.37.40

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 (141) hide show
  1. package/package.json +1 -1
  2. package/src/domains/credits/application/CreditLimitCalculator.ts +1 -9
  3. package/src/domains/credits/application/CreditsInitializer.ts +5 -20
  4. package/src/domains/credits/application/DeductCreditsCommand.ts +13 -6
  5. package/src/domains/credits/application/RefundCreditsCommand.ts +1 -5
  6. package/src/domains/credits/application/credit-strategies/CreditAllocationOrchestrator.ts +1 -9
  7. package/src/domains/credits/application/credit-strategies/ICreditStrategy.ts +1 -5
  8. package/src/domains/credits/application/credit-strategies/TrialCreditStrategy.ts +1 -5
  9. package/src/domains/credits/application/creditDocumentHelpers.ts +2 -9
  10. package/src/domains/credits/application/creditOperationUtils.ts +1 -43
  11. package/src/domains/credits/core/Credits.ts +0 -23
  12. package/src/domains/credits/core/CreditsConstants.ts +0 -11
  13. package/src/domains/credits/core/CreditsMapper.ts +0 -6
  14. package/src/domains/credits/core/UserCreditsDocument.ts +0 -12
  15. package/src/domains/credits/infrastructure/CreditsRepository.ts +6 -1
  16. package/src/domains/credits/infrastructure/CreditsRepositoryManager.ts +0 -21
  17. package/src/domains/credits/infrastructure/operations/CreditsWriter.ts +52 -1
  18. package/src/domains/credits/presentation/deduct-credit/useDeductCredit.ts +2 -2
  19. package/src/domains/credits/presentation/useCredits.ts +10 -9
  20. package/src/domains/paywall/components/PaywallContainer.types.ts +0 -28
  21. package/src/domains/paywall/components/PaywallModal.styles.ts +0 -4
  22. package/src/domains/paywall/entities/types.ts +0 -5
  23. package/src/domains/paywall/hooks/usePaywallActions.ts +1 -15
  24. package/src/domains/revenuecat/core/errors/RevenueCatError.ts +0 -6
  25. package/src/domains/revenuecat/core/errors/RevenueCatErrorHandler.ts +0 -24
  26. package/src/domains/revenuecat/core/errors/RevenueCatErrorMessages.ts +0 -18
  27. package/src/domains/revenuecat/core/errors/index.ts +0 -4
  28. package/src/domains/revenuecat/core/types/RevenueCatConfig.ts +3 -7
  29. package/src/domains/revenuecat/core/types/RevenueCatData.ts +4 -9
  30. package/src/domains/revenuecat/core/types/RevenueCatTypes.ts +5 -65
  31. package/src/domains/revenuecat/core/types/index.ts +0 -4
  32. package/src/domains/revenuecat/infrastructure/services/UserSwitchMutex.ts +1 -24
  33. package/src/domains/subscription/application/SubscriptionAuthListener.ts +5 -21
  34. package/src/domains/subscription/application/SubscriptionInitializerTypes.ts +1 -5
  35. package/src/domains/subscription/application/SubscriptionSyncProcessor.ts +0 -4
  36. package/src/domains/subscription/application/SubscriptionSyncService.ts +4 -8
  37. package/src/domains/subscription/application/SubscriptionSyncUtils.ts +1 -1
  38. package/src/domains/subscription/application/initializer/BackgroundInitializer.ts +15 -2
  39. package/src/domains/subscription/application/initializer/ServiceConfigurator.ts +9 -2
  40. package/src/domains/subscription/application/statusChangeHandlers.ts +14 -27
  41. package/src/domains/subscription/application/syncIdGenerators.ts +0 -4
  42. package/src/domains/subscription/constants/thresholds.ts +0 -9
  43. package/src/domains/subscription/core/SubscriptionConstants.ts +0 -4
  44. package/src/domains/subscription/core/SubscriptionStatus.ts +11 -21
  45. package/src/domains/subscription/core/SubscriptionStatusHandlers.ts +4 -7
  46. package/src/domains/subscription/infrastructure/handlers/PurchaseStatusResolver.ts +1 -1
  47. package/src/domains/subscription/infrastructure/hooks/subscriptionQueryKeys.ts +0 -13
  48. package/src/domains/subscription/infrastructure/hooks/usePurchasePackage.ts +0 -18
  49. package/src/domains/subscription/infrastructure/hooks/useRestorePurchase.ts +3 -17
  50. package/src/domains/subscription/infrastructure/hooks/useRevenueCatTrialEligibility.ts +0 -17
  51. package/src/domains/subscription/infrastructure/hooks/useSubscriptionPackages.ts +0 -19
  52. package/src/domains/subscription/infrastructure/hooks/useSubscriptionQueries.ts +0 -6
  53. package/src/domains/subscription/infrastructure/managers/subscriptionManagerUtils.ts +0 -17
  54. package/src/domains/subscription/infrastructure/state/initializationState.ts +0 -25
  55. package/src/domains/subscription/infrastructure/utils/InitializationCache.ts +0 -21
  56. package/src/domains/subscription/infrastructure/utils/PremiumStatusSyncer.ts +3 -17
  57. package/src/domains/subscription/infrastructure/utils/authPurchaseState.ts +0 -5
  58. package/src/domains/subscription/infrastructure/utils/renewal/PackageTierComparator.ts +1 -0
  59. package/src/domains/subscription/infrastructure/utils/trialEligibilityUtils.ts +0 -18
  60. package/src/domains/subscription/presentation/components/details/PremiumDetailsCard.styles.ts +0 -5
  61. package/src/domains/subscription/presentation/components/details/PremiumDetailsCardTypes.ts +0 -5
  62. package/src/domains/subscription/presentation/components/feedback/paywallFeedbackStyles.ts +0 -5
  63. package/src/domains/subscription/presentation/stores/index.ts +0 -4
  64. package/src/domains/subscription/presentation/stores/purchaseLoadingStore.ts +0 -13
  65. package/src/domains/subscription/presentation/useAuthAwarePurchase.ts +30 -21
  66. package/src/domains/subscription/presentation/usePaywallVisibility.ts +0 -9
  67. package/src/domains/subscription/presentation/useSubscriptionStatus.ts +8 -11
  68. package/src/domains/subscription/utils/authGuards.ts +3 -0
  69. package/src/domains/trial/application/TrialService.ts +0 -9
  70. package/src/domains/trial/core/TrialTypes.ts +0 -8
  71. package/src/domains/wallet/domain/mappers/TransactionMapper.ts +0 -5
  72. package/src/domains/wallet/domain/types/transaction.types.ts +0 -7
  73. package/src/domains/wallet/index.ts +0 -7
  74. package/src/domains/wallet/infrastructure/config/walletConfig.ts +0 -11
  75. package/src/domains/wallet/presentation/hooks/useTransactionHistory.ts +6 -3
  76. package/src/domains/wallet/presentation/hooks/useWallet.ts +0 -7
  77. package/src/domains/wallet/utils/transactionIconMap.ts +0 -10
  78. package/src/global.d.ts +0 -6
  79. package/src/index.ts +1 -4
  80. package/src/init/createSubscriptionInitModule.ts +12 -2
  81. package/src/init/index.ts +1 -5
  82. package/src/presentation/hooks/feedback/useFeedbackSubmit.ts +0 -11
  83. package/src/shared/application/FeedbackService.ts +3 -21
  84. package/src/shared/application/ports/ISubscriptionRepository.ts +0 -4
  85. package/src/shared/infrastructure/SubscriptionEventBus.ts +0 -13
  86. package/src/shared/infrastructure/firestore/collectionUtils.ts +1 -17
  87. package/src/shared/infrastructure/firestore/index.ts +0 -4
  88. package/src/shared/infrastructure/firestore/resultUtils.ts +0 -12
  89. package/src/shared/infrastructure/react-query/hooks/usePreviousUserCleanup.ts +0 -17
  90. package/src/shared/infrastructure/react-query/queryConfig.ts +0 -15
  91. package/src/shared/utils/BaseError.ts +0 -5
  92. package/src/shared/utils/Result.ts +0 -20
  93. package/src/shared/utils/dateConverter.ts +6 -46
  94. package/src/utils/appUtils.ts +0 -16
  95. package/src/utils/creditMapper.ts +0 -7
  96. package/src/utils/dateUtils.compare.ts +0 -24
  97. package/src/utils/dateUtils.core.ts +0 -39
  98. package/src/utils/dateUtils.format.ts +0 -41
  99. package/src/utils/dateUtils.math.ts +0 -41
  100. package/src/utils/dateUtils.ts +0 -5
  101. package/src/utils/packagePeriodUtils.ts +0 -20
  102. package/src/utils/packageTypeDetector.ts +1 -21
  103. package/src/utils/premiumStatusUtils.ts +1 -14
  104. package/src/utils/priceUtils.ts +0 -35
  105. package/src/utils/tierUtils.ts +1 -8
  106. package/src/utils/types.ts +1 -25
  107. package/src/utils/validation.ts +1 -7
  108. package/src/domains/README.md +0 -52
  109. package/src/domains/config/domain/README.md +0 -37
  110. package/src/domains/config/domain/entities/README.md +0 -41
  111. package/src/domains/credits/application/credit-strategies/SyncCreditStrategy.ts +0 -24
  112. package/src/domains/paywall/README.md +0 -101
  113. package/src/domains/paywall/entities/README.md +0 -40
  114. package/src/domains/paywall/hooks/README.md +0 -41
  115. package/src/domains/subscription/application/syncConstants.ts +0 -1
  116. package/src/domains/subscription/infrastructure/README.md +0 -41
  117. package/src/domains/subscription/infrastructure/config/README.md +0 -49
  118. package/src/domains/subscription/infrastructure/handlers/README.md +0 -41
  119. package/src/domains/subscription/infrastructure/hooks/README.md +0 -50
  120. package/src/domains/subscription/infrastructure/managers/README.md +0 -41
  121. package/src/domains/subscription/infrastructure/services/README.md +0 -42
  122. package/src/domains/subscription/infrastructure/utils/README.md +0 -41
  123. package/src/domains/subscription/presentation/components/README.md +0 -155
  124. package/src/domains/subscription/presentation/components/details/CreditRow.md +0 -92
  125. package/src/domains/subscription/presentation/components/details/DetailRow.md +0 -91
  126. package/src/domains/subscription/presentation/components/details/PremiumDetailsCard.md +0 -93
  127. package/src/domains/subscription/presentation/components/details/PremiumStatusBadge.md +0 -91
  128. package/src/domains/subscription/presentation/components/details/README.md +0 -99
  129. package/src/domains/subscription/presentation/components/feedback/PaywallFeedbackModal.md +0 -90
  130. package/src/domains/subscription/presentation/components/feedback/README.md +0 -99
  131. package/src/domains/subscription/presentation/components/paywall/PaywallModal.md +0 -94
  132. package/src/domains/subscription/presentation/components/paywall/README.md +0 -54
  133. package/src/domains/subscription/presentation/components/sections/README.md +0 -99
  134. package/src/domains/subscription/presentation/components/sections/SubscriptionSection.md +0 -94
  135. package/src/domains/subscription/presentation/utils/README.md +0 -31
  136. package/src/domains/wallet/README.md +0 -51
  137. package/src/domains/wallet/domain/README.md +0 -41
  138. package/src/domains/wallet/infrastructure/README.md +0 -41
  139. package/src/domains/wallet/presentation/components/README.md +0 -41
  140. package/src/domains/wallet/presentation/hooks/README.md +0 -41
  141. package/src/shared/application/ports/README.md +0 -48
@@ -1,94 +0,0 @@
1
- # PaywallModal Component
2
-
3
- Modal paywall component for subscription upgrade.
4
-
5
- ## Location
6
-
7
- **Import Path**: `@umituz/react-native-subscription`
8
-
9
- **File**: `src/presentation/components/paywall/PaywallModal.tsx`
10
-
11
- **Type**: Component
12
-
13
- ## Strategy
14
-
15
- ### Paywall Display Flow
16
-
17
- 1. **Modal Visibility**: Control visibility via isVisible prop
18
- 2. **Configuration**: Display features, pricing, and benefits
19
- 3. **Package Display**: Show available subscription packages
20
- 4. **Purchase Handling**: Handle purchase initiation and completion
21
- 5. **Close Behavior**: Handle modal close/dismissal
22
- 6. **Responsive Design**: Adapt to different screen sizes
23
-
24
- ### Integration Points
25
-
26
- - **usePaywallVisibility**: For modal visibility control
27
- - **useSubscriptionPackages**: For available packages
28
- - **usePaywallOperations**: For purchase handling
29
- - **Analytics**: For tracking impressions and conversions
30
- - **Navigation**: For post-purchase navigation
31
-
32
- ## Restrictions
33
-
34
- ### REQUIRED
35
-
36
- - **Visibility Control**: MUST control via isVisible prop
37
- - **Close Handler**: MUST provide onClose callback
38
- - **Purchase Handler**: MUST implement onPurchase callback
39
- - **Package Display**: MUST show available packages
40
-
41
- ### PROHIBITED
42
-
43
- - **NEVER** trap users without close option
44
- - **NEVER** show without user trigger or clear reason
45
- - **DO NOT** show too frequently
46
- - **DO NOT** hide pricing information
47
-
48
- ### CRITICAL SAFETY
49
-
50
- - **ALWAYS** provide clear close button
51
- - **NEVER** trap users in modal
52
- - **MUST** handle all purchase outcomes
53
- - **ALWAYS** show pricing clearly
54
-
55
- ## AI Agent Guidelines
56
-
57
- ### When Implementing Paywall Modals
58
-
59
- 1. **Always** provide clear close button
60
- 2. **Always** show pricing transparently
61
- 3. **Always** handle all purchase outcomes
62
- 4. **Always** track impressions and conversions
63
- 5. **Never** trap users without exit
64
-
65
- ### Integration Checklist
66
-
67
- - [ ] Import from correct path: `@umituz/react-native-subscription`
68
- - [ ] Control visibility via isVisible prop
69
- - [ ] Implement onClose callback
70
- - [ ] Implement onPurchase callback
71
- - [ ] Configure features and benefits
72
- - [ ] Display package options
73
- - [ ] Handle loading states
74
- - [ ] Track analytics events
75
- - [ ] Test purchase flow
76
- - [ ] Test close behavior
77
- - [ ] Verify responsive design
78
-
79
- ### Common Patterns
80
-
81
- 1. **Manual Trigger**: Show on button press
82
- 2. **Usage Limit**: Show after N free uses
83
- 3. **Feature Gate**: Show when accessing premium feature
84
- 4. **Time-based**: Show after certain time/usage
85
- 5. **Event-driven**: Show on specific app events
86
- 6. **A/B Testing**: Test different copy and layouts
87
-
88
- ## Related Documentation
89
-
90
- - **usePaywall**: Paywall state management
91
- - **usePaywallOperations**: Purchase operations
92
- - **usePaywallVisibility**: Visibility control
93
- - **PaywallDomain**: `../../../domains/paywall/README.md`
94
- - **Paywall README**: `./README.md`
@@ -1,54 +0,0 @@
1
- # Paywall Components
2
-
3
- UI components specifically designed for paywall and subscription upgrade screens.
4
-
5
- ## Location
6
-
7
- `src/presentation/components/paywall/`
8
-
9
- ## Strategy
10
-
11
- Specialized components for displaying paywalls, package selection, and subscription upgrade prompts. These components handle the visual presentation of subscription offers and user purchase flows.
12
-
13
- ## Restrictions
14
-
15
- ### REQUIRED
16
-
17
- - Must use design tokens for consistent styling
18
- - Must support multiple display modes (card, list, minimal)
19
- - Must include loading states
20
- - Must handle accessibility requirements
21
- - Must support screen readers
22
- - Must provide proper touch targets
23
-
24
- ### PROHIBITED
25
-
26
- - MUST NOT hardcode pricing or product information
27
- - MUST NOT bypass payment validation
28
- - MUST NOT expose RevenueCat implementation details
29
- - MUST NOT create custom payment flows outside approved patterns
30
-
31
- ### CRITICAL
32
-
33
- - All purchase flows MUST go through RevenueCat
34
- - Never log or transmit sensitive payment information
35
- - Always handle errors gracefully with user-friendly messages
36
- - Must support cancellation and refund flows
37
-
38
- ## AI Agent Guidelines
39
-
40
- When modifying paywall components:
41
- 1. Maintain visual hierarchy for recommended packages
42
- 2. Ensure clear pricing display (price, period, per-month equivalent)
43
- 3. Keep features easy to understand
44
- 4. Include social proof elements (ratings, reviews, user counts)
45
- 5. Add trust signals (guarantees, badges, certifications)
46
- 6. Optimize for mobile screens
47
- 7. Lazy load images and avoid expensive animations
48
- 8. Always support accessibility standards
49
-
50
- ## Related Documentation
51
-
52
- - [Paywall Domain](../../../domains/paywall/README.md)
53
- - [Paywall Hooks](../../hooks/README.md)
54
- - [RevenueCat Integration](../../../revenuecat/README.md)
@@ -1,99 +0,0 @@
1
- # Sections Components
2
-
3
- Subscription-related section and card components.
4
-
5
- ## Location
6
-
7
- - **Base Path**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/presentation/components/sections/`
8
- - **Components**: `src/presentation/components/sections/`
9
-
10
- ## Strategy
11
-
12
- ### Section Components
13
-
14
- Organized sections for subscription information display.
15
-
16
- - **SubscriptionSection**: Subscription status and management section
17
- - **Status Display**: Clear status indicators
18
- - **Action Buttons**: Management and upgrade actions
19
- - **Navigation Support**: Deep linking to detail screens
20
-
21
- ### Display Features
22
-
23
- Comprehensive subscription information display.
24
-
25
- - **Status Indicators**: Active/inactive status display
26
- - **Expiration Dates**: Date formatting and display
27
- - **Management Actions**: Subscription management buttons
28
- - **Upgrade Options**: Premium upgrade prompts
29
-
30
- ### Interaction Design
31
-
32
- User-friendly interaction patterns.
33
-
34
- - **Press Actions**: Navigation to detail screens
35
- - **Long Press**: Quick management options
36
- - **Status-Based UI**: Different UI for different subscription states
37
- - **Refresh Support**: Pull-to-refresh capabilities
38
-
39
- ### Customization
40
-
41
- Flexible styling and behavior.
42
-
43
- - **Custom Actions**: Custom action handlers
44
- - **Style Props**: Custom styling support
45
- - **Translation Support**: Multi-language support
46
- - **Conditional Display**: Show/hide elements based on state
47
-
48
- ## Restrictions
49
-
50
- ### REQUIRED
51
-
52
- - **Status Clarity**: Status must be clearly visible
53
- - **Action Buttons**: Provide appropriate action buttons
54
- - **Loading States**: Show loading indicators
55
- - **Error Handling**: Handle errors gracefully
56
-
57
- ### PROHIBITED
58
-
59
- - **Hardcoded Text**: All text must support translations
60
- - **Missing Actions**: Never omit necessary actions
61
- - **Ambiguous Status**: Status must be unambiguous
62
- - **Blocking UI**: Never block app navigation
63
-
64
- ### CRITICAL
65
-
66
- - **Deep Links**: Include management deep links
67
- - **State Accuracy**: Display accurate subscription state
68
- - **User Actions**: Provide clear action options
69
- - **Platform Links**: Correct platform-specific management links
70
-
71
- ## AI Agent Guidelines
72
-
73
- ### When Modifying Section Components
74
-
75
- 1. **Component Interface**: Maintain consistent prop interfaces
76
- 2. **State Handling**: Proper state management
77
- 3. **Translations**: Ensure translation support
78
- 4. **Accessibility**: Include accessibility features
79
-
80
- ### When Adding Section Features
81
-
82
- 1. **Pattern Consistency**: Follow existing patterns
83
- 2. **Type Safety**: Define TypeScript types
84
- 3. **Documentation**: Document props and usage
85
- 4. **Testing**: Test with different subscription states
86
-
87
- ### When Fixing Section Component Bugs
88
-
89
- 1. **State Display**: Check state display logic
90
- 2. **Actions**: Verify action handlers
91
- 3. **Navigation**: Test navigation flows
92
- 4. **Edge Cases**: Test with null/undefined states
93
-
94
- ## Related Documentation
95
-
96
- - [Details Components](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/presentation/components/details/README.md)
97
- - [Feedback Components](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/presentation/components/feedback/README.md)
98
- - [Presentation Components](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/presentation/components/README.md)
99
- - [Paywall Domain](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/domains/paywall/README.md)
@@ -1,94 +0,0 @@
1
- # SubscriptionSection Component
2
-
3
- Section component displaying subscription status with details and actions.
4
-
5
- ## Location
6
-
7
- **Import Path**: `@umituz/react-native-subscription`
8
-
9
- **File**: `src/presentation/components/sections/SubscriptionSection.tsx`
10
-
11
- **Type**: Component
12
-
13
- ## Strategy
14
-
15
- ### Subscription Information Display
16
-
17
- 1. **Status Detection**: Display current subscription status (active/inactive/free)
18
- 2. **Detail Rendering**: Show expiration date, renewal status, product info
19
- 3. **Action Buttons**: Display manage or upgrade button based on status
20
- 4. **Loading States**: Handle loading and error states gracefully
21
- 5. **Translation Support**: Support custom translations for all text
22
- 6. **Visual Hierarchy**: Clear structure with status badge, details, and actions
23
-
24
- ### Integration Points
25
-
26
- - **useSubscriptionStatus**: For subscription status data
27
- - **usePremium**: For premium status check
28
- - **DetailRow**: For displaying individual detail items
29
- - **PremiumStatusBadge**: For status badge display
30
- - **Navigation**: For manage/upgrade button actions
31
-
32
- ## Restrictions
33
-
34
- ### REQUIRED
35
-
36
- - **Config Prop**: MUST provide valid subscription config object
37
- - **Callback Handling**: MUST implement button callbacks
38
- - **Loading State**: MUST handle loading state in UI
39
- - **Null Handling**: MUST handle null status values
40
-
41
- ### PROHIBITED
42
-
43
- - **NEVER** display without config data (show loading instead)
44
- - **NEVER** hardcode status text (use translations)
45
- - **DO NOT** show both manage and upgrade buttons simultaneously
46
- - **DO NOT** show buttons for loading state
47
-
48
- ### CRITICAL SAFETY
49
-
50
- - **ALWAYS** handle loading state before displaying data
51
- - **MUST** validate config object before rendering
52
- - **ALWAYS** provide clear button labels
53
- - **NEVER** expose sensitive implementation details
54
-
55
- ## AI Agent Guidelines
56
-
57
- ### When Implementing Subscription Sections
58
-
59
- 1. **Always** provide valid subscription config
60
- 2. **Always** handle loading state
61
- 3. **Always** implement both button callbacks
62
- 4. **Always** use translations for localization
63
- 5. **Never** hardcode status strings
64
-
65
- ### Integration Checklist
66
-
67
- - [ ] Import from correct path: `@umituz/react-native-subscription`
68
- - [ ] Provide valid subscription config
69
- - [ ] Implement onUpgradePress callback
70
- - [ ] Implement onManagePress callback
71
- - [ ] Handle loading state
72
- - [ ] Handle null dates
73
- - [ ] Provide translations for localization
74
- - [ ] Test with active subscription
75
- - [ ] Test with expired subscription
76
- - [ ] Test with free user
77
- - [ ] Test with lifetime subscription
78
-
79
- ### Common Patterns
80
-
81
- 1. **Settings Integration**: Add to settings screen
82
- 2. **Profile Display**: Show in user profile
83
- 3. **Status Card**: Display as standalone card
84
- 4. **With Navigation**: Navigate to detailed management
85
- 5. **Localized Display**: Use with i18n libraries
86
- 6. **Conditional Rendering**: Show/hide based on auth state
87
-
88
- ## Related Documentation
89
-
90
- - **PremiumDetailsCard**: Detailed premium card
91
- - **DetailRow**: Individual detail item
92
- - **PremiumStatusBadge**: Status badge component
93
- - **Subscription Hooks**: `../../hooks/README.md`
94
- - **Sections README**: `./README.md`
@@ -1,31 +0,0 @@
1
- # Presentation Utils
2
-
3
- Utility functions and helpers for the presentation layer.
4
-
5
- ## Overview
6
-
7
- This directory contains utility functions used by presentation components and hooks.
8
-
9
- ## Contents
10
-
11
- - **subscriptionDateUtils.ts** - Date formatting and manipulation for subscription display
12
- - **paywallUtils.ts** - Paywall-related utility functions
13
-
14
- ## Date Utilities
15
-
16
- ### formatDate
17
-
18
- Format ISO date string to localized date string.
19
-
20
- ### calculateDaysRemaining
21
-
22
- Calculate days between now and expiration date.
23
-
24
- ### convertPurchasedAt
25
-
26
- Convert purchasedAt date to ISO string.
27
-
28
- ## Related
29
-
30
- - [Hooks](../hooks/README.md)
31
- - [Types](../types/README.md)
@@ -1,51 +0,0 @@
1
- # Wallet Domain
2
-
3
- Credit balance management, transaction history tracking, and product metadata management.
4
-
5
- ## Location
6
-
7
- `src/domains/wallet/`
8
-
9
- ## Strategy
10
-
11
- Implements layered architecture for credit management with domain layer (entities, value objects, errors), infrastructure layer (repositories, Firebase services, mappers), and presentation layer (hooks, components). Handles initialization, operations, and transaction history with real-time updates.
12
-
13
- ## Restrictions
14
-
15
- ### REQUIRED
16
-
17
- - All operations require authenticated user
18
- - Credit operations MUST be validated server-side
19
- - All credit changes MUST be recorded in transaction history
20
- - MUST handle insufficient credits gracefully
21
-
22
- ### PROHIBITED
23
-
24
- - MUST NOT allow client-side credit modifications without server validation
25
- - MUST NOT deduct credits without sufficient balance
26
- - MUST NOT expose internal repository logic to UI
27
- - MUST NOT store credit balance in AsyncStorage (use secure backend)
28
-
29
- ### CRITICAL
30
-
31
- - Always validate credit amounts (must be positive)
32
- - Always implement optimistic updates with rollback
33
- - Never trust client-side credit balance for security decisions
34
- - Must implement retry logic for failed operations
35
- - Always sanitize transaction reasons to prevent injection attacks
36
-
37
- ## AI Agent Guidelines
38
-
39
- When implementing credit operations:
40
- 1. Always check balance before deducting
41
- 2. Always provide transaction reason and metadata
42
- 3. Always handle insufficient credits gracefully
43
- 4. Always implement optimistic updates with rollback
44
- 5. Never trust client-side balance for security
45
-
46
- ## Related Documentation
47
-
48
- - [Credits Repository](infrastructure/README.md)
49
- - [useCredits Hook](../../presentation/hooks/README.md)
50
- - [UserCredits Entity](domain/entities/README.md)
51
- - [Transaction Errors](domain/errors/README.md)
@@ -1,41 +0,0 @@
1
- # Wallet Domain
2
-
3
- ## Location
4
- Wallet domain containing credits and transaction management logic.
5
-
6
- ## Strategy
7
- The wallet domain manages user credits, transactions, and credit allocation strategies with duplicate protection, transactional operations, and complete audit trail.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must check credit balance before operations
13
- - Must handle credit exhaustion gracefully
14
- - Must track all credit transactions
15
- - Must reset credits on subscription renewal
16
-
17
- ### PROHIBITED
18
- - DO NOT perform operations without balance check
19
- - DO NOT allow duplicate credit allocations
20
- - DO NOT skip transaction logging
21
- - DO NOT bypass credit exhaustion handling
22
-
23
- ### CRITICAL SAFETY
24
- - Credit allocations MUST be protected against duplicates
25
- - All credit operations MUST be transactional
26
- - Transaction history MUST be complete and accurate
27
- - Credit exhaustion MUST trigger upgrade flow
28
-
29
- ## AI Agent Guidelines
30
- 1. Always verify credit balance before performing operations
31
- 2. Handle credit exhaustion with clear upgrade path
32
- 3. Log all credit transactions for audit trail
33
- 4. Implement monthly credit reset on subscription renewal
34
- 5. Test edge cases: zero credits, max credits, duplicates
35
- 6. Use ACCUMULATE mode for renewals, REPLACE for new purchases
36
- 7. Provide optimistic updates with rollback capability
37
-
38
- ## Related Documentation
39
- - [Credits README](./README.md)
40
- - [Credits Entity](./domain/entities/Credits.md)
41
- - [useCredits Hook](../../presentation/hooks/useCredits.md)
@@ -1,41 +0,0 @@
1
- # Wallet Infrastructure
2
-
3
- ## Location
4
- Infrastructure layer for wallet and credits functionality.
5
-
6
- ## Strategy
7
- This directory contains implementations for credit persistence, transactions, and credit operations with duplicate protection and optimistic updates.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must check credit balance before deducting
13
- - Must handle errors appropriately
14
- - Must use transactions for data consistency
15
- - Must log all credit operations
16
-
17
- ### PROHIBITED
18
- - DO NOT deduct credits without balance check
19
- - DO NOT allow duplicate credit allocations
20
- - DO NOT skip transaction boundaries
21
- - DO NOT ignore credit operation errors
22
-
23
- ### CRITICAL SAFETY
24
- - Duplicate allocations MUST be prevented based on purchaseId
25
- - Credit operations MUST be atomic
26
- - All operations MUST be logged for debugging
27
- - Input validation MUST be performed
28
-
29
- ## AI Agent Guidelines
30
- 1. Always verify credit balance before deduction operations
31
- 2. Implement comprehensive error handling for credit operations
32
- 3. Use transactions to ensure data consistency
33
- 4. Track all credit operations with detailed logging
34
- 5. Test edge cases: zero credits, max credits, duplicates
35
- 6. Validate all input parameters before processing
36
- 7. Implement duplicate protection based on purchaseId
37
-
38
- ## Related Documentation
39
- - [Wallet Domain](../domain/README.md)
40
- - [Credits Entity](../domain/entities/README.md)
41
- - [useCredits Hook](../../presentation/hooks/useCredits.md)
@@ -1,41 +0,0 @@
1
- # Wallet Presentation Components
2
-
3
- ## Location
4
- UI components for wallet and credit display.
5
-
6
- ## Strategy
7
- This directory contains React Native components for displaying credits, transactions, and wallet information with clear visual hierarchy and status indicators.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must show loading states appropriately
13
- - Must provide empty state messages
14
- - Must allow manual refresh capability
15
- - Must display transaction history clearly
16
-
17
- ### PROHIBITED
18
- - DO NOT hide credit balance from users
19
- - DO NOT show technical errors directly
20
- - DO NOT skip loading indicators
21
- - DO NOT obscure transaction details
22
-
23
- ### CRITICAL SAFETY
24
- - Credit balance MUST always be visible
25
- - Status indicators MUST be color-coded appropriately
26
- - Transaction history MUST be complete and accurate
27
- - Purchase links MUST be easily accessible
28
-
29
- ## AI Agent Guidelines
30
- 1. Emphasize important information with visual hierarchy
31
- 2. Use color coding to indicate status (low/warning/good)
32
- 3. Show skeleton screens while loading data
33
- 4. Provide helpful empty state messages
34
- 5. Allow users to manually refresh credit data
35
- 6. Display complete transaction history
36
- 7. Make credit purchases easily accessible
37
-
38
- ## Related Documentation
39
- - [Credit Row](../../../presentation/components/details/CreditRow.md)
40
- - [Credits Hook](../hooks/README.md)
41
- - [Wallet Domain](../../domain/README.md)
@@ -1,41 +0,0 @@
1
- # Wallet Presentation Hooks
2
-
3
- ## Location
4
- React hooks for wallet and credit functionality.
5
-
6
- ## Strategy
7
- This directory contains React hooks specifically for credit management and wallet operations with optimistic updates and proper error handling.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must check balance before deducting
13
- - Must handle loading states appropriately
14
- - Must handle deduction failures gracefully
15
- - Must log all credit operations
16
-
17
- ### PROHIBITED
18
- - DO NOT deduct credits without balance check
19
- - DO NOT skip error handling
20
- - DO NOT ignore loading states
21
- - DO NOT perform operations without tracking
22
-
23
- ### CRITICAL SAFETY
24
- - Balance checks MUST precede all deductions
25
- - Deduction failures MUST be handled gracefully
26
- - Optimistic updates MUST support rollback
27
- - All operations MUST be logged
28
-
29
- ## AI Agent Guidelines
30
- 1. Always check credit balance before deducting
31
- 2. Show appropriate loading states during operations
32
- 3. Handle deduction failures with graceful recovery
33
- 4. Use optimistic updates for better user experience
34
- 5. Log all credit operations for debugging
35
- 6. Initialize credits automatically after premium purchase
36
- 7. Test edge cases: zero credits, max credits, failures
37
-
38
- ## Related Documentation
39
- - [useCredits Hook Documentation](../../../presentation/hooks/useCredits.md)
40
- - [useDeductCredit Hook Documentation](../../../presentation/hooks/useDeductCredit.md)
41
- - [Credits Entity](../../domain/entities/README.md)
@@ -1,48 +0,0 @@
1
- # Application Ports
2
-
3
- Interfaces defining contracts between application layer and external dependencies.
4
-
5
- ## Location
6
-
7
- `src/application/ports/`
8
-
9
- ## Strategy
10
-
11
- Port interfaces define how the application layer interacts with external services and repositories, enabling dependency inversion and testability through clear contracts.
12
-
13
- ## Restrictions
14
-
15
- ### REQUIRED
16
-
17
- - MUST use interface segregation (keep interfaces focused)
18
- - MUST document behavior thoroughly
19
- - MUST use domain entities in return types
20
- - MUST make all I/O operations async
21
- - MUST define clear contracts between layers
22
-
23
- ### PROHIBITED
24
-
25
- - MUST NOT couple interfaces to specific implementations
26
- - MUST NOT include infrastructure concerns in port definitions
27
- - MUST NOT leak implementation details through interfaces
28
-
29
- ### CRITICAL
30
-
31
- - Keep interfaces focused and segregated
32
- - Document all behavior thoroughly
33
- - Use domain entities in return types
34
- - Ensure all I/O operations are async
35
-
36
- ## AI Agent Guidelines
37
-
38
- When working with application ports:
39
- 1. Interface Segregation - keep interfaces focused
40
- 2. Clear Contracts - document behavior thoroughly
41
- 3. Return Types - use domain entities in return types
42
- 4. Async Operations - all I/O operations should be async
43
-
44
- ## Related Documentation
45
-
46
- - [Application Layer](../README.md)
47
- - [Infrastructure Services](../../infrastructure/services/README.md)
48
- - [Infrastructure Repositories](../../infrastructure/repositories/README.md)