@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,101 +0,0 @@
1
- # Paywall Domain
2
-
3
- Subscription and credit purchase flow with user-friendly payment wall components and hooks.
4
-
5
- ## Location
6
-
7
- - **Base Path**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/domains/paywall/`
8
- - **Entities**: `src/domains/paywall/entities/`
9
- - **Components**: `src/domains/paywall/components/`
10
- - **Hooks**: `src/domains/paywall/hooks/`
11
-
12
- ## Strategy
13
-
14
- ### Paywall Management
15
-
16
- Centralized paywall system for subscription and credit purchase flows.
17
-
18
- - **Modal and Full-Screen Support**: Flexible paywall display options
19
- - **Multi-language Support**: Built-in i18n capabilities
20
- - **A/B Test Ready**: Easy creation of different paywall variants
21
- - **Analytics Integration**: User behavior tracking capabilities
22
-
23
- ### Component Architecture
24
-
25
- Ready-to-use paywall components with customization support.
26
-
27
- - **PaywallModal**: Modal-based paywall display
28
- - **PaywallContainer**: Paywall content wrapper
29
- - **PaywallScreen**: Full-screen paywall implementation
30
- - **Feature Lists**: Customizable feature display components
31
-
32
- ### Hook Integration
33
-
34
- Hooks for paywall state and behavior management.
35
-
36
- - **usePaywall**: Paywall visibility and state control
37
- - **usePaywallActions**: Purchase and restore action handling
38
- - **usePaywallTranslations**: Translation management
39
- - **useSubscriptionModal**: Subscription modal management
40
-
41
- ### Configuration Strategy
42
-
43
- Theme and content customization system.
44
-
45
- - **Theme Configuration**: Custom color schemes and styling
46
- - **Feature Lists**: Customizable feature display
47
- - **Translation Support**: Multi-language copy management
48
- - **Event Tracking**: Analytics integration points
49
-
50
- ## Restrictions
51
-
52
- ### REQUIRED
53
-
54
- - **Paywall Context**: All paywall components must be used within SubscriptionProvider
55
- - **Config Validation**: Paywall configuration must be validated before use
56
- - **Error Handling**: All paywall actions must have error handling
57
- - **Loading States**: Purchase operations must show loading indicators
58
-
59
- ### PROHIBITED
60
-
61
- - **Hardcoded Strings**: All text must support translations
62
- - **Direct RevenueCat Calls**: Use paywall hooks instead of direct SDK calls
63
- - **Missing Analytics**: All paywall interactions must be tracked
64
- - **Blocking UI**: Never block app flow without escape options
65
-
66
- ### CRITICAL
67
-
68
- - **User Experience**: Paywalls must be dismissible
69
- - **Purchase Flow**: Complete purchase flow must be handled
70
- - **Error Recovery**: Graceful error handling required
71
- - **State Management**: Paywall state must be properly managed
72
-
73
- ## AI Agent Guidelines
74
-
75
- ### When Modifying Paywall Components
76
-
77
- 1. **Maintain UX Standards**: Keep user experience consistent
78
- 2. **Test All States**: Test loading, success, and error states
79
- 3. **Analytics Integration**: Add tracking for new interactions
80
- 4. **Translation Support**: All new text must be translatable
81
-
82
- ### When Adding New Paywall Features
83
-
84
- 1. **Hook Pattern**: Create corresponding hook for new features
85
- 2. **Type Safety**: Define proper TypeScript types
86
- 3. **Documentation**: Document all props and usage
87
- 4. **Testing**: Test with different subscription states
88
-
89
- ### When Fixing Paywall Bugs
90
-
91
- 1. **RevenueCat Integration**: Check RevenueCat SDK integration
92
- 2. **State Management**: Verify state transitions
93
- 3. **Edge Cases**: Test with null/undefined states
94
- 4. **User Flows**: Test complete purchase flows
95
-
96
- ## Related Documentation
97
-
98
- - [RevenueCat Integration](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/revenuecat/README.md)
99
- - [Config Domain](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/domains/config/README.md)
100
- - [Wallet Domain](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/domains/wallet/README.md)
101
- - [Presentation Components](/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-subscription/src/presentation/components/README.md)
@@ -1,40 +0,0 @@
1
- # Paywall Entities
2
-
3
- ## Location
4
- Domain entities for paywall configuration and state management.
5
-
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
39
- - [Paywall README](../README.md)
40
- - [PaywallVisibility Hook](../../presentation/hooks/usePaywallVisibility.md)
@@ -1,41 +0,0 @@
1
- # Paywall Hooks
2
-
3
- ## Location
4
- React hooks for paywall management and subscription upgrades.
5
-
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
39
- - [usePaywallVisibility](../../presentation/hooks/usePaywallVisibility.md)
40
- - [usePaywallOperations](../../presentation/hooks/usePaywallOperations.md)
41
- - [PremiumGate Hook](../../presentation/hooks/usePremiumGate.md)
@@ -1 +0,0 @@
1
- export const NO_SUBSCRIPTION_PRODUCT_ID = 'no_subscription';
@@ -1,41 +0,0 @@
1
- # RevenueCat Infrastructure
2
-
3
- ## Location
4
- Infrastructure layer for RevenueCat integration.
5
-
6
- ## Strategy
7
- This directory contains concrete implementations of RevenueCat interfaces, handling communication with the RevenueCat SDK and external services with proper error handling and data transformation.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must integrate directly with RevenueCat SDK
13
- - Must convert SDK errors to domain errors
14
- - Must map SDK types to domain types
15
- - Must manage purchase and customer info events
16
-
17
- ### PROHIBITED
18
- - DO NOT expose SDK errors directly to application
19
- - DO NOT use SDK types in domain layer
20
- - DO NOT skip error mapping
21
- - DO NOT ignore lifecycle events
22
-
23
- ### CRITICAL SAFETY
24
- - All SDK errors MUST be converted to domain errors
25
- - All SDK types MUST be mapped to domain types
26
- - All events MUST be handled appropriately
27
- - Configuration MUST be set up correctly
28
-
29
- ## AI Agent Guidelines
30
- 1. Integrate directly with RevenueCat SDK
31
- 2. Convert all SDK errors to domain errors
32
- 3. Map all SDK types to domain types
33
- 4. Manage purchase and customer info events properly
34
- 5. Set up and configure RevenueCat correctly
35
- 6. Test SDK integration thoroughly
36
- 7. Handle all edge cases in SDK communication
37
-
38
- ## Related Documentation
39
- - [RevenueCat Integration](../README.md)
40
- - [RevenueCat Application](../application/README.md)
41
- - [RevenueCat Domain](../domain/README.md)
@@ -1,49 +0,0 @@
1
- # RevenueCat Infrastructure Config
2
-
3
- RevenueCat SDK configuration and initialization.
4
-
5
- ## Location
6
-
7
- `src/revenuecat/infrastructure/config/`
8
-
9
- ## Strategy
10
-
11
- Configuration utilities and setup for the RevenueCat SDK, providing centralized configuration management for the subscription system.
12
-
13
- ## Restrictions
14
-
15
- ### REQUIRED
16
-
17
- - MUST configure RevenueCat at app startup
18
- - MUST use valid API keys from environment configuration
19
- - MUST initialize before any purchase operations
20
- - MUST handle configuration errors gracefully
21
-
22
- ### PROHIBITED
23
-
24
- - MUST NOT expose API keys in source code
25
- - MUST NOT hardcode configuration values
26
- - MUST NOT initialize RevenueCat multiple times
27
- - MUST NOT bypass configuration validation
28
-
29
- ### CRITICAL
30
-
31
- - Always validate configuration before initialization
32
- - Never expose sensitive API keys or tokens
33
- - Handle all configuration errors gracefully
34
- - Ensure configuration is loaded before any operations
35
-
36
- ## AI Agent Guidelines
37
-
38
- When working with RevenueCat configuration:
39
- 1. Always validate configuration before use
40
- 2. Never hardcode API keys or secrets
41
- 3. Handle all configuration errors gracefully
42
- 4. Ensure proper initialization order
43
- 5. Test with both valid and invalid configurations
44
-
45
- ## Related Documentation
46
-
47
- - [Managers](../managers/README.md)
48
- - [Services](../services/README.md)
49
- - [RevenueCat README](../../README.md)
@@ -1,41 +0,0 @@
1
- # RevenueCat Infrastructure Handlers
2
-
3
- ## Location
4
- Event handlers for RevenueCat lifecycle events.
5
-
6
- ## Strategy
7
- This directory contains handler implementations for managing RevenueCat events including purchase callbacks, customer info changes, and error handling with proper data validation and recovery.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must handle all events gracefully
13
- - Must validate incoming data before processing
14
- - Must log all events for debugging
15
- - Must invoke callbacks appropriately
16
-
17
- ### PROHIBITED
18
- - DO NOT mutate incoming event data
19
- - DO NOT ignore event handling errors
20
- - DO NOT skip callback invocation
21
- - DO NOT process unvalidated data
22
-
23
- ### CRITICAL SAFETY
24
- - All incoming data MUST be validated
25
- - All events MUST be logged for debugging
26
- - All callbacks MUST be invoked appropriately
27
- - Recovery options MUST be provided when possible
28
-
29
- ## AI Agent Guidelines
30
- 1. Never mutate incoming event data
31
- 2. Handle all errors gracefully with proper boundaries
32
- 3. Log all events for debugging and monitoring
33
- 4. Invoke registered callbacks appropriately
34
- 5. Use async/await for asynchronous operations
35
- 6. Validate all incoming data before processing
36
- 7. Provide recovery options when possible
37
-
38
- ## Related Documentation
39
- - [RevenueCat Infrastructure](../README.md)
40
- - [RevenueCat Services](../services/README.md)
41
- - [RevenueCat Errors](../../domain/errors/README.md)
@@ -1,50 +0,0 @@
1
- # RevenueCat Presentation Hooks
2
-
3
- React hooks for accessing RevenueCat data and operations.
4
-
5
- ## Location
6
-
7
- `src/revenuecat/presentation/hooks/`
8
-
9
- ## Strategy
10
-
11
- React hooks that expose RevenueCat functionality to the presentation layer, providing access to customer info, subscription packages, and offerings.
12
-
13
- ## Restrictions
14
-
15
- ### REQUIRED
16
-
17
- - MUST handle loading states appropriately
18
- - MUST handle error states gracefully
19
- - MUST cache responses when appropriate
20
- - MUST subscribe to real-time updates when needed
21
- - MUST validate all data before use
22
-
23
- ### PROHIBITED
24
-
25
- - MUST NOT expose RevenueCat implementation details to components
26
- - MUST NOT bypass error handling
27
- - MUST NOT create infinite loops with subscriptions
28
- - MUST NOT assume data is always available
29
-
30
- ### CRITICAL
31
-
32
- - Always handle loading and error states
33
- - Unsubscribe from all listeners on unmount
34
- - Validate all data before using it in components
35
- - Handle null/undefined states properly
36
-
37
- ## AI Agent Guidelines
38
-
39
- When working with RevenueCat hooks:
40
- 1. Always handle loading and error states
41
- 2. Unsubscribe from listeners on unmount
42
- 3. Validate all data before use
43
- 4. Cache responses appropriately
44
- 5. Handle null/undefined states gracefully
45
-
46
- ## Related Documentation
47
-
48
- - [Main Hooks](../../../presentation/hooks/README.md)
49
- - [Domain](../../domain/README.md)
50
- - [Services](../infrastructure/services/README.md)
@@ -1,41 +0,0 @@
1
- # RevenueCat Infrastructure Managers
2
-
3
- ## Location
4
- Manager classes for coordinating RevenueCat operations.
5
-
6
- ## Strategy
7
- This directory contains high-level manager classes that coordinate between different RevenueCat services and handle complex operations like SDK configuration and entitlement access.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must coordinate between services properly
13
- - Must manage SDK configuration correctly
14
- - Must provide access to entitlement IDs
15
- - Must handle complex operations safely
16
-
17
- ### PROHIBITED
18
- - DO NOT bypass service coordination
19
- - DO NOT misconfigure SDK
20
- - DO NOT expose invalid entitlement IDs
21
- - DO NOT oversimplify complex operations
22
-
23
- ### CRITICAL SAFETY
24
- - Service coordination MUST be correct
25
- - SDK configuration MUST be valid
26
- - Entitlement access MUST be safe
27
- - Complex operations MUST be handled properly
28
-
29
- ## AI Agent Guidelines
30
- 1. Coordinate properly between RevenueCat services
31
- 2. Manage SDK configuration with correct parameters
32
- 3. Provide safe access to entitlement IDs
33
- 4. Handle complex operations with proper error handling
34
- 5. Test coordination logic thoroughly
35
- 6. Document manager responsibilities clearly
36
- 7. Maintain separation of concerns
37
-
38
- ## Related Documentation
39
- - [Services](../services/README.md)
40
- - [Config](../config/README.md)
41
- - [Domain](../../domain/README.md)
@@ -1,42 +0,0 @@
1
- # RevenueCat Infrastructure Services
2
-
3
- ## Location
4
- Service implementations for RevenueCat operations.
5
-
6
- ## Strategy
7
- This directory contains concrete implementations of RevenueCat interfaces, providing the actual integration with the RevenueCat SDK using singleton pattern with proper error handling and caching.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must use singleton pattern for service instance
13
- - Must wrap all service calls in try-catch
14
- - Must use TypeScript types for all operations
15
- - Must log all RevenueCat operations
16
-
17
- ### PROHIBITED
18
- - DO NOT create multiple service instances
19
- - DO NOT skip error handling
20
- - DO NOT bypass type safety
21
- - DO NOT skip logging operations
22
-
23
- ### CRITICAL SAFETY
24
- - Service MUST be configured only once
25
- - All calls MUST be wrapped in error handling
26
- - All operations MUST be type-safe
27
- - All operations MUST be logged
28
-
29
- ## AI Agent Guidelines
30
- 1. Use singleton pattern for service instance
31
- 2. Wrap all service calls in try-catch blocks
32
- 3. Use TypeScript types for all operations
33
- 4. Log all RevenueCat operations for debugging
34
- 5. Cache customer info and offerings appropriately
35
- 6. Validate parameters before calling SDK
36
- 7. Configure service only once at startup
37
- 8. Use mock implementations for testing
38
-
39
- ## Related Documentation
40
- - [RevenueCat Infrastructure](../README.md)
41
- - [RevenueCat Handlers](../handlers/README.md)
42
- - [RevenueCat Application Ports](../../application/ports/README.md)
@@ -1,41 +0,0 @@
1
- # RevenueCat Infrastructure Utils
2
-
3
- ## Location
4
- Utility functions for RevenueCat operations.
5
-
6
- ## Strategy
7
- This directory contains utility functions for common RevenueCat operations including error mapping, data transformation, validation, and formatting with proper type safety.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must use error mapping for user-facing messages
13
- - Must ensure types are validated before use
14
- - Must respect user locale for formatting
15
- - Must check for null/undefined values
16
-
17
- ### PROHIBITED
18
- - DO NOT show SDK errors directly to users
19
- - DO NOT use data without type validation
20
- - DO NOT ignore locale settings
21
- - DO NOT skip null checks
22
-
23
- ### CRITICAL SAFETY
24
- - All errors MUST be mapped to domain errors
25
- - All types MUST be validated before use
26
- - Locale MUST be respected for formatting
27
- - Null checks MUST be performed consistently
28
-
29
- ## AI Agent Guidelines
30
- 1. Always map SDK errors to domain errors for user-facing messages
31
- 2. Ensure type safety by validating types before use
32
- 3. Respect user locale when formatting prices and periods
33
- 4. Always check for null/undefined values before processing
34
- 5. Use debug helpers in development for troubleshooting
35
- 6. Validate all data before processing
36
- 7. Test utility functions with edge cases
37
-
38
- ## Related Documentation
39
- - [RevenueCat Infrastructure](../README.md)
40
- - [RevenueCat Domain Types](../../domain/types/README.md)
41
- - [RevenueCat Errors](../../domain/errors/README.md)
@@ -1,155 +0,0 @@
1
- # Presentation Components
2
-
3
- React Native UI components for subscription and paywall features.
4
-
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)