@umituz/react-native-subscription 2.37.39 → 2.37.41

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 (132) hide show
  1. package/package.json +1 -1
  2. package/src/domains/credits/application/CreditLimitCalculator.ts +1 -9
  3. package/src/domains/credits/application/DeductCreditsCommand.ts +16 -7
  4. package/src/domains/credits/application/RefundCreditsCommand.ts +1 -5
  5. package/src/domains/credits/application/credit-strategies/TrialCreditStrategy.ts +1 -5
  6. package/src/domains/credits/application/creditDocumentHelpers.ts +2 -9
  7. package/src/domains/credits/core/Credits.ts +0 -23
  8. package/src/domains/credits/core/CreditsMapper.ts +0 -6
  9. package/src/domains/credits/core/UserCreditsDocument.ts +0 -12
  10. package/src/domains/credits/infrastructure/CreditsRepositoryManager.ts +0 -21
  11. package/src/domains/credits/infrastructure/operations/CreditsWriter.ts +2 -1
  12. package/src/domains/credits/presentation/deduct-credit/useDeductCredit.ts +2 -2
  13. package/src/domains/credits/presentation/useCredits.ts +10 -9
  14. package/src/domains/paywall/components/PaywallContainer.types.ts +0 -28
  15. package/src/domains/paywall/components/PaywallModal.styles.ts +0 -4
  16. package/src/domains/paywall/entities/types.ts +0 -5
  17. package/src/domains/paywall/hooks/usePaywallActions.ts +1 -15
  18. package/src/domains/revenuecat/core/errors/RevenueCatError.ts +0 -6
  19. package/src/domains/revenuecat/core/errors/RevenueCatErrorHandler.ts +0 -24
  20. package/src/domains/revenuecat/core/errors/RevenueCatErrorMessages.ts +0 -18
  21. package/src/domains/revenuecat/core/errors/index.ts +0 -4
  22. package/src/domains/revenuecat/core/types/RevenueCatConfig.ts +3 -7
  23. package/src/domains/revenuecat/core/types/RevenueCatData.ts +4 -9
  24. package/src/domains/revenuecat/core/types/RevenueCatTypes.ts +5 -65
  25. package/src/domains/revenuecat/core/types/index.ts +0 -4
  26. package/src/domains/revenuecat/infrastructure/services/UserSwitchMutex.ts +1 -24
  27. package/src/domains/subscription/application/SubscriptionAuthListener.ts +5 -21
  28. package/src/domains/subscription/application/SubscriptionInitializerTypes.ts +1 -5
  29. package/src/domains/subscription/application/SubscriptionSyncProcessor.ts +6 -2
  30. package/src/domains/subscription/application/SubscriptionSyncService.ts +11 -2
  31. package/src/domains/subscription/application/SubscriptionSyncUtils.ts +1 -1
  32. package/src/domains/subscription/application/initializer/BackgroundInitializer.ts +15 -2
  33. package/src/domains/subscription/application/initializer/ServiceConfigurator.ts +9 -2
  34. package/src/domains/subscription/constants/thresholds.ts +0 -9
  35. package/src/domains/subscription/core/SubscriptionConstants.ts +0 -4
  36. package/src/domains/subscription/core/SubscriptionStatus.ts +11 -21
  37. package/src/domains/subscription/core/SubscriptionStatusHandlers.ts +4 -7
  38. package/src/domains/subscription/infrastructure/handlers/PurchaseStatusResolver.ts +1 -1
  39. package/src/domains/subscription/infrastructure/hooks/subscriptionQueryKeys.ts +0 -13
  40. package/src/domains/subscription/infrastructure/hooks/usePurchasePackage.ts +0 -18
  41. package/src/domains/subscription/infrastructure/hooks/useRestorePurchase.ts +3 -17
  42. package/src/domains/subscription/infrastructure/hooks/useRevenueCatTrialEligibility.ts +0 -17
  43. package/src/domains/subscription/infrastructure/hooks/useSubscriptionPackages.ts +0 -19
  44. package/src/domains/subscription/infrastructure/hooks/useSubscriptionQueries.ts +0 -6
  45. package/src/domains/subscription/infrastructure/managers/subscriptionManagerUtils.ts +0 -17
  46. package/src/domains/subscription/infrastructure/state/initializationState.ts +0 -25
  47. package/src/domains/subscription/infrastructure/utils/InitializationCache.ts +0 -21
  48. package/src/domains/subscription/infrastructure/utils/PremiumStatusSyncer.ts +2 -7
  49. package/src/domains/subscription/infrastructure/utils/authPurchaseState.ts +19 -6
  50. package/src/domains/subscription/infrastructure/utils/renewal/PackageTierComparator.ts +1 -0
  51. package/src/domains/subscription/infrastructure/utils/trialEligibilityUtils.ts +0 -18
  52. package/src/domains/subscription/presentation/components/details/PremiumDetailsCard.styles.ts +0 -5
  53. package/src/domains/subscription/presentation/components/details/PremiumDetailsCardTypes.ts +0 -5
  54. package/src/domains/subscription/presentation/components/feedback/paywallFeedbackStyles.ts +0 -5
  55. package/src/domains/subscription/presentation/stores/index.ts +0 -4
  56. package/src/domains/subscription/presentation/stores/purchaseLoadingStore.ts +0 -13
  57. package/src/domains/subscription/presentation/useAuthAwarePurchase.ts +35 -21
  58. package/src/domains/subscription/presentation/usePaywallVisibility.ts +0 -9
  59. package/src/domains/subscription/presentation/useSubscriptionStatus.ts +8 -11
  60. package/src/domains/subscription/utils/authGuards.ts +3 -0
  61. package/src/domains/trial/application/TrialService.ts +0 -9
  62. package/src/domains/trial/core/TrialTypes.ts +0 -8
  63. package/src/domains/wallet/domain/mappers/TransactionMapper.ts +0 -5
  64. package/src/domains/wallet/domain/types/transaction.types.ts +0 -7
  65. package/src/domains/wallet/index.ts +0 -7
  66. package/src/domains/wallet/infrastructure/config/walletConfig.ts +0 -11
  67. package/src/domains/wallet/presentation/hooks/useTransactionHistory.ts +6 -3
  68. package/src/domains/wallet/presentation/hooks/useWallet.ts +0 -7
  69. package/src/domains/wallet/utils/transactionIconMap.ts +0 -10
  70. package/src/global.d.ts +0 -6
  71. package/src/index.ts +1 -4
  72. package/src/init/createSubscriptionInitModule.ts +12 -2
  73. package/src/init/index.ts +1 -5
  74. package/src/presentation/hooks/feedback/useFeedbackSubmit.ts +0 -11
  75. package/src/shared/application/FeedbackService.ts +3 -21
  76. package/src/shared/application/ports/ISubscriptionRepository.ts +0 -4
  77. package/src/shared/infrastructure/SubscriptionEventBus.ts +0 -13
  78. package/src/shared/infrastructure/firestore/collectionUtils.ts +1 -17
  79. package/src/shared/infrastructure/firestore/index.ts +0 -4
  80. package/src/shared/infrastructure/firestore/resultUtils.ts +0 -12
  81. package/src/shared/infrastructure/react-query/hooks/usePreviousUserCleanup.ts +0 -17
  82. package/src/shared/infrastructure/react-query/queryConfig.ts +0 -15
  83. package/src/shared/utils/BaseError.ts +0 -5
  84. package/src/shared/utils/Result.ts +0 -20
  85. package/src/shared/utils/dateConverter.ts +6 -46
  86. package/src/utils/appUtils.ts +0 -16
  87. package/src/utils/creditMapper.ts +0 -7
  88. package/src/utils/dateUtils.compare.ts +0 -24
  89. package/src/utils/dateUtils.core.ts +0 -39
  90. package/src/utils/dateUtils.format.ts +0 -41
  91. package/src/utils/dateUtils.math.ts +0 -41
  92. package/src/utils/dateUtils.ts +0 -5
  93. package/src/utils/packagePeriodUtils.ts +0 -20
  94. package/src/utils/packageTypeDetector.ts +1 -21
  95. package/src/utils/premiumStatusUtils.ts +1 -14
  96. package/src/utils/priceUtils.ts +0 -35
  97. package/src/utils/tierUtils.ts +1 -8
  98. package/src/utils/types.ts +1 -25
  99. package/src/utils/validation.ts +1 -7
  100. package/src/domains/README.md +0 -52
  101. package/src/domains/config/domain/README.md +0 -37
  102. package/src/domains/config/domain/entities/README.md +0 -41
  103. package/src/domains/paywall/README.md +0 -101
  104. package/src/domains/paywall/entities/README.md +0 -40
  105. package/src/domains/paywall/hooks/README.md +0 -41
  106. package/src/domains/subscription/application/syncConstants.ts +0 -1
  107. package/src/domains/subscription/infrastructure/README.md +0 -41
  108. package/src/domains/subscription/infrastructure/config/README.md +0 -49
  109. package/src/domains/subscription/infrastructure/handlers/README.md +0 -41
  110. package/src/domains/subscription/infrastructure/hooks/README.md +0 -50
  111. package/src/domains/subscription/infrastructure/managers/README.md +0 -41
  112. package/src/domains/subscription/infrastructure/services/README.md +0 -42
  113. package/src/domains/subscription/infrastructure/utils/README.md +0 -41
  114. package/src/domains/subscription/presentation/components/README.md +0 -155
  115. package/src/domains/subscription/presentation/components/details/CreditRow.md +0 -92
  116. package/src/domains/subscription/presentation/components/details/DetailRow.md +0 -91
  117. package/src/domains/subscription/presentation/components/details/PremiumDetailsCard.md +0 -93
  118. package/src/domains/subscription/presentation/components/details/PremiumStatusBadge.md +0 -91
  119. package/src/domains/subscription/presentation/components/details/README.md +0 -99
  120. package/src/domains/subscription/presentation/components/feedback/PaywallFeedbackModal.md +0 -90
  121. package/src/domains/subscription/presentation/components/feedback/README.md +0 -99
  122. package/src/domains/subscription/presentation/components/paywall/PaywallModal.md +0 -94
  123. package/src/domains/subscription/presentation/components/paywall/README.md +0 -54
  124. package/src/domains/subscription/presentation/components/sections/README.md +0 -99
  125. package/src/domains/subscription/presentation/components/sections/SubscriptionSection.md +0 -94
  126. package/src/domains/subscription/presentation/utils/README.md +0 -31
  127. package/src/domains/wallet/README.md +0 -51
  128. package/src/domains/wallet/domain/README.md +0 -41
  129. package/src/domains/wallet/infrastructure/README.md +0 -41
  130. package/src/domains/wallet/presentation/components/README.md +0 -41
  131. package/src/domains/wallet/presentation/hooks/README.md +0 -41
  132. package/src/shared/application/ports/README.md +0 -48
@@ -1,27 +1,12 @@
1
- /**
2
- * Package Type Detector
3
- * Detects subscription package type from RevenueCat package identifier
4
- */
5
-
6
1
  import { PACKAGE_TYPE, type PackageType } from "../domains/subscription/core/SubscriptionConstants";
7
2
 
8
3
  export type SubscriptionPackageType = PackageType;
9
4
 
10
- /**
11
- * Check if identifier is a credit package (consumable purchase)
12
- * Credit packages use a different system and don't need type detection
13
- */
14
5
  export function isCreditPackage(identifier: string): boolean {
15
6
  if (!identifier) return false;
16
- // Matches "credit" as a word or part of a common naming pattern
17
- // More strict to avoid false positives (e.g. "accredited")
18
7
  return /(?:^|[._-])credit(?:$|[._-])/i.test(identifier);
19
8
  }
20
9
 
21
- /**
22
- * Detect package type from product identifier
23
- * Supports common RevenueCat naming patterns with regex for better accuracy
24
- */
25
10
  export function detectPackageType(productIdentifier: string): SubscriptionPackageType {
26
11
  if (!productIdentifier) {
27
12
  return PACKAGE_TYPE.UNKNOWN;
@@ -29,27 +14,22 @@ export function detectPackageType(productIdentifier: string): SubscriptionPackag
29
14
 
30
15
  const normalized = productIdentifier.toLowerCase();
31
16
 
32
- // Skip credit packages silently - they use creditPackageConfig instead
33
17
  if (isCreditPackage(normalized)) {
34
18
  return PACKAGE_TYPE.UNKNOWN;
35
19
  }
36
20
 
37
- // Weekly detection: matches "weekly" or "week" as distinct parts of the ID
38
21
  if (/\bweekly?\b|_week_|-week-|\.week\./i.test(normalized)) {
39
22
  return PACKAGE_TYPE.WEEKLY;
40
23
  }
41
24
 
42
- // Monthly detection: matches "monthly" or "month"
43
25
  if (/\bmonthly?\b|_month_|-month-|\.month\./i.test(normalized)) {
44
26
  return PACKAGE_TYPE.MONTHLY;
45
27
  }
46
28
 
47
- // Yearly detection: matches "yearly", "year", or "annual"
48
29
  if (/\byearly?\b|_year_|-year-|\.year\.|annual/i.test(normalized)) {
49
30
  return PACKAGE_TYPE.YEARLY;
50
31
  }
51
-
52
- // Lifetime detection: matches "lifetime"
32
+
53
33
  if (/\blifetime\b|_lifetime_|-lifetime-|\.lifetime\./i.test(normalized)) {
54
34
  return PACKAGE_TYPE.LIFETIME;
55
35
  }
@@ -1,27 +1,14 @@
1
- /**
2
- * Premium Status Utilities
3
- *
4
- * Core premium status determination logic
5
- */
6
-
7
1
  import type { PremiumStatusFetcher } from './types';
8
2
 
9
-
10
- /**
11
- * Get isPremium value with centralized logic
12
- */
13
3
  export function getIsPremium(
14
4
  isAnonymous: boolean,
15
5
  userId: string | null,
16
6
  isPremiumOrFetcher: boolean | PremiumStatusFetcher,
17
7
  ): Promise<boolean> {
18
- // Anonymous users NEVER have premium
19
8
  if (isAnonymous || userId === null) return Promise.resolve(false);
20
9
 
21
- // Sync mode: return the provided isPremium value
22
10
  if (typeof isPremiumOrFetcher === 'boolean') return Promise.resolve(isPremiumOrFetcher);
23
11
 
24
- // Async mode: fetch premium status
25
12
  return (async () => {
26
13
  try {
27
14
  return await isPremiumOrFetcher.isPremium(userId!);
@@ -31,4 +18,4 @@ export function getIsPremium(
31
18
  );
32
19
  }
33
20
  })();
34
- }
21
+ }
@@ -1,14 +1,3 @@
1
- /**
2
- * Price Formatting Utilities
3
- * Apple App Store Guideline 3.1.2 Compliance
4
- */
5
-
6
- /**
7
- * Format price for display
8
- * @param price - Price value
9
- * @param currencyCode - Currency code (e.g., 'USD', 'EUR')
10
- * @returns Formatted price string
11
- */
12
1
  export function formatPrice(price: number, currencyCode: string): string {
13
2
  try {
14
3
  return new Intl.NumberFormat('en-US', {
@@ -28,35 +17,11 @@ const PERIOD_SUFFIX_MAP: Record<string, string> = {
28
17
  yearly: '/year',
29
18
  };
30
19
 
31
- /**
32
- * Extract billing period suffix from package identifier
33
- * Apple App Store Guideline 3.1.2 Compliance:
34
- * - Displays billing frequency clearly and conspicuously
35
- * - Format: /week, /month, /year
36
- *
37
- * @param identifier - RevenueCat package identifier (e.g., "$rc_weekly", "$rc_monthly", "$rc_annual")
38
- * @returns Billing period suffix (e.g., "/week", "/month", "/year") or empty string
39
- */
40
20
  export function getBillingPeriodSuffix(identifier: string): string {
41
21
  const packageType = detectPackageType(identifier);
42
22
  return PERIOD_SUFFIX_MAP[packageType] ?? '';
43
23
  }
44
24
 
45
- /**
46
- * Format price with billing period
47
- * Apple App Store Guideline 3.1.2 Compliance:
48
- * - Combines price with billing frequency for clear display
49
- * - Format: $2.99/week, $14.99/month, $39.99/year
50
- *
51
- * RevenueCat Best Practice:
52
- * - Follows recommended price_per_period format
53
- * - Clear and conspicuous billing frequency display
54
- *
55
- * @param price - Price value
56
- * @param currencyCode - Currency code (e.g., 'USD', 'EUR')
57
- * @param identifier - RevenueCat package identifier
58
- * @returns Formatted price with billing period (e.g., "$2.99/week")
59
- */
60
25
  export function formatPriceWithPeriod(
61
26
  price: number,
62
27
  currencyCode: string,
@@ -1,12 +1,5 @@
1
- /**
2
- * User Tier Core Utilities
3
- *
4
- * Core logic for determining user tier and premium status
5
- */
6
-
7
1
  import { USER_TIER, type UserTierInfo } from './types';
8
2
 
9
-
10
3
  export function getUserTierInfo(
11
4
  isAnonymous: boolean,
12
5
  userId: string | null,
@@ -38,4 +31,4 @@ export function checkPremiumAccess(
38
31
  ): boolean {
39
32
  if (isAnonymous || userId === null) return false;
40
33
  return isPremium;
41
- }
34
+ }
@@ -1,40 +1,16 @@
1
- /**
2
- * User Tier Types
3
- *
4
- * Type definitions for user tier system
5
- */
6
-
7
1
  import { USER_TIER, type UserTierType } from '../domains/subscription/core/SubscriptionConstants';
8
2
 
9
3
  export type UserTier = UserTierType;
10
4
  export { USER_TIER };
11
5
 
12
6
  export interface UserTierInfo {
13
- /** User tier classification */
14
7
  tier: UserTier;
15
-
16
- /** Whether user has premium access */
17
8
  isPremium: boolean;
18
-
19
- /** Whether user is anonymous (not authenticated) */
20
9
  isAnonymous: boolean;
21
-
22
- /** Whether user is authenticated */
23
10
  isAuthenticated: boolean;
24
-
25
- /** User ID (null for anonymous users) */
26
11
  userId: string | null;
27
12
  }
28
13
 
29
- /**
30
- * Premium status fetcher interface
31
- * Apps should implement this to provide premium status from their database
32
- */
33
14
  export interface PremiumStatusFetcher {
34
- /**
35
- * Check if user has active premium subscription
36
- * @param userId - User ID (never null, this is only called for authenticated users)
37
- * @returns Promise<boolean> - Whether user has premium subscription
38
- */
39
15
  isPremium(userId: string): Promise<boolean>;
40
- }
16
+ }
@@ -1,9 +1,3 @@
1
- /**
2
- * User Tier Validation Utilities
3
- *
4
- * Type guards and validation functions for user tier system
5
- */
6
-
7
1
  import { USER_TIER, type UserTier, type UserTierInfo } from './types';
8
2
 
9
3
  export function isValidUserTier(value: unknown): value is UserTier {
@@ -20,4 +14,4 @@ export function isUserTierInfo(value: unknown): value is UserTierInfo {
20
14
  typeof obj.isAuthenticated === 'boolean' &&
21
15
  (obj.userId === null || typeof obj.userId === 'string')
22
16
  );
23
- }
17
+ }
@@ -1,52 +0,0 @@
1
- # Domains
2
-
3
- Specialized domain modules implementing specific business logic and features.
4
-
5
- ## Location
6
-
7
- `src/domains/`
8
-
9
- ## Strategy
10
-
11
- Implements Domain-Driven Design (DDD) principles with self-contained domains. Each domain includes domain layer (business logic, entities, value objects), infrastructure layer (external integrations, repositories), and presentation layer (domain-specific hooks and components).
12
-
13
- ## Restrictions
14
-
15
- ### REQUIRED
16
-
17
- - Domains MUST NOT directly depend on each other
18
- - MUST use well-defined interfaces between layers
19
- - MUST depend on abstractions, not concretions (Dependency Inversion)
20
- - All domains MUST be testable in isolation
21
-
22
- ### PROHIBITED
23
-
24
- - MUST NOT share domain logic between domains (use shared kernel if needed)
25
- - MUST NOT create circular dependencies between domains
26
- - MUST NOT bypass domain layer from presentation
27
- - MUST NOT expose infrastructure details to other domains
28
-
29
- ### CRITICAL
30
-
31
- - Always validate invariants at domain boundaries
32
- - Always implement domain errors for business rule violations
33
- - Never allow inconsistent domain state
34
- - Must implement proper transaction boundaries
35
- - Always sanitize inputs from external sources
36
-
37
- ## AI Agent Guidelines
38
-
39
- When working with domains:
40
- 1. Always respect domain boundaries
41
- 2. Always use dependency inversion
42
- 3. Always implement domain-specific errors
43
- 4. Always validate invariants at boundaries
44
- 5. Never create circular dependencies
45
-
46
- ## Related Documentation
47
-
48
- - [Wallet Domain](wallet/README.md)
49
- - [Paywall Domain](paywall/README.md)
50
- - [Config Domain](config/README.md)
51
- - [Domain Layer](../domain/README.md)
52
- - [Infrastructure](../infrastructure/README.md)
@@ -1,37 +0,0 @@
1
- # Config Domain
2
-
3
- ## Location
4
- Domain layer for configuration management.
5
-
6
- ## Strategy
7
- This directory contains the business logic and domain models for subscription and feature configuration.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must use entities for domain models
13
- - Must validate in constructor
14
- - Must keep entities immutable
15
-
16
- ### PROHIBITED
17
- - DO NOT bypass entity validation
18
- - DO NOT mutate entities after creation
19
- - DO NOT leak domain logic to application layer
20
-
21
- ### CRITICAL SAFETY
22
- - All business rules MUST be enforced in entities
23
- - Validation failures MUST fail fast
24
- - Type safety MUST be maintained at compile time
25
-
26
- ## AI Agent Guidelines
27
- 1. When creating new configurations, use existing entities
28
- 2. Always validate configuration data through entity constructors
29
- 3. Encapsulate business logic within domain entities
30
- 4. Implement proper equality methods for value objects
31
- 5. Provide formatting methods for display purposes
32
- 6. Maintain strict type safety with TypeScript
33
-
34
- ## Related Documentation
35
- - [Config Domain](../../README.md)
36
- - [Config Entities](./entities/README.md)
37
- - [Config Value Objects](./value-objects/README.md)
@@ -1,41 +0,0 @@
1
- # Config Domain Entities
2
-
3
- ## Location
4
- Domain entities for configuration management.
5
-
6
- ## Strategy
7
- This directory contains entity classes representing configuration concepts like packages, features, and paywalls with strict validation and immutability.
8
-
9
- ## Restrictions
10
-
11
- ### REQUIRED
12
- - Must validate all configuration in constructor
13
- - Must treat entities as immutable
14
- - Must provide clear error messages
15
- - Must use TypeScript strict mode
16
-
17
- ### PROHIBITED
18
- - DO NOT modify entities after creation
19
- - DO NOT bypass validation logic
20
- - DO NOT expose mutable internal state
21
- - DO NOT allow invalid configuration
22
-
23
- ### CRITICAL SAFETY
24
- - All validation MUST happen in constructor
25
- - Entities MUST fail fast on invalid input
26
- - Error messages MUST be descriptive
27
- - Factory functions MUST provide valid defaults
28
-
29
- ## AI Agent Guidelines
30
- 1. Always validate configuration data in entity constructors
31
- 2. Treat all entities as immutable values
32
- 3. Keep business logic encapsulated within entities
33
- 4. Provide factory functions for common configurations
34
- 5. Test validation logic thoroughly
35
- 6. Use TypeScript strict types for all properties
36
- 7. Return descriptive error messages for validation failures
37
-
38
- ## Related Documentation
39
- - [Config Domain](../README.md)
40
- - [Config Value Objects](../value-objects/README.md)
41
- - [Config Utils](../../utils/README.md)
@@ -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)