@umituz/react-native-subscription 3.0.0 → 3.0.1
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.
- package/package.json +1 -1
- package/src/domains/paywall/components/PaywallScreen.renderItem.tsx +1 -1
- package/src/domains/subscription/presentation/useSubscriptionFlow.ts +4 -1
- package/src/exports/analytics.ts +10 -45
- package/src/exports/experimental.ts +5 -86
- package/src/exports/onboarding.ts +7 -24
- package/src/exports/wallet.ts +10 -13
- package/src/index.components.ts +40 -0
- package/src/index.constants.ts +71 -0
- package/src/index.hooks.ts +41 -0
- package/src/index.infrastructure.ts +81 -0
- package/src/index.ts +14 -252
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
|
-
import { View
|
|
7
|
+
import { View } from "react-native";
|
|
8
8
|
import type { ImageSourcePropType } from "react-native";
|
|
9
9
|
import { AtomicText, AtomicIcon } from "@umituz/react-native-design-system/atoms";
|
|
10
10
|
import { Image } from "expo-image";
|
|
@@ -50,7 +50,6 @@ export interface SubscriptionFlowState {
|
|
|
50
50
|
export interface SubscriptionFlowActions {
|
|
51
51
|
// Flow actions
|
|
52
52
|
completeOnboarding: () => void;
|
|
53
|
-
checkPremiumStatus: () => void;
|
|
54
53
|
showPaywall: () => void;
|
|
55
54
|
completePaywall: (purchased: boolean) => void;
|
|
56
55
|
showFeedbackScreen: () => void;
|
|
@@ -62,6 +61,10 @@ export interface SubscriptionFlowActions {
|
|
|
62
61
|
// Sync actions
|
|
63
62
|
setSyncStatus: (status: SyncStatus, error?: string | null) => void;
|
|
64
63
|
|
|
64
|
+
// State setters (for internal use)
|
|
65
|
+
setInitialized: (initialized: boolean) => void;
|
|
66
|
+
setStatus: (status: SubscriptionFlowStatus) => void;
|
|
67
|
+
|
|
65
68
|
// Reset
|
|
66
69
|
resetFlow: () => void;
|
|
67
70
|
}
|
package/src/exports/analytics.ts
CHANGED
|
@@ -1,53 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SUBSCRIPTION ANALYTICS (Optional)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* NOTE: Analytics features coming soon
|
|
5
|
+
* This is a placeholder for future subscription analytics
|
|
5
6
|
*
|
|
6
7
|
* @example
|
|
7
|
-
* import { SubscriptionAnalytics
|
|
8
|
+
* // Future: import { SubscriptionAnalytics } from '@umituz/react-native-subscription/exports/analytics';
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ConversionFunnelData,
|
|
16
|
-
} from '../../presentation/hooks/analytics/useSubscriptionAnalytics.types';
|
|
11
|
+
// Reserved for future analytics features
|
|
12
|
+
// For now, use your own analytics solution with our hooks:
|
|
13
|
+
// - usePremiumStatus
|
|
14
|
+
// - useSubscriptionStatus
|
|
15
|
+
// - usePaywallVisibility
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
export type {
|
|
21
|
-
PaywallAnalyticsData,
|
|
22
|
-
PaywallImpressionData,
|
|
23
|
-
PaywallConversionData,
|
|
24
|
-
} from '../../domains/paywall/hooks/usePaywallAnalytics.types';
|
|
25
|
-
|
|
26
|
-
// Revenue Analytics
|
|
27
|
-
export { useRevenueAnalytics } from '../../domains/subscription/presentation/hooks/useRevenueAnalytics';
|
|
28
|
-
export type {
|
|
29
|
-
RevenueAnalyticsData,
|
|
30
|
-
RevenueMetrics,
|
|
31
|
-
ARPUData,
|
|
32
|
-
LTVData,
|
|
33
|
-
} from '../../domains/subscription/presentation/hooks/useRevenueAnalytics.types';
|
|
34
|
-
|
|
35
|
-
// Churn Analytics
|
|
36
|
-
export { useChurnAnalytics } from '../../domains/subscription/presentation/hooks/useChurnAnalytics';
|
|
37
|
-
export type {
|
|
38
|
-
ChurnAnalyticsData,
|
|
39
|
-
ChurnRiskData,
|
|
40
|
-
RetentionData,
|
|
41
|
-
} from '../../domains/subscription/presentation/hooks/useChurnAnalytics.types';
|
|
42
|
-
|
|
43
|
-
// Analytics Helpers
|
|
44
|
-
export {
|
|
45
|
-
trackSubscriptionEvent,
|
|
46
|
-
trackPaywallEvent,
|
|
47
|
-
trackRevenueEvent,
|
|
48
|
-
} from '../../utils/analyticsHelpers';
|
|
49
|
-
export type {
|
|
50
|
-
SubscriptionEventType,
|
|
51
|
-
PaywallEventType,
|
|
52
|
-
RevenueEventType,
|
|
53
|
-
} from '../../utils/analyticsHelpers.types';
|
|
17
|
+
export { useSubscriptionStatus } from '../domains/subscription/presentation/useSubscriptionStatus';
|
|
18
|
+
export { usePremiumStatus } from '../domains/subscription/presentation/usePremiumStatus';
|
|
@@ -1,93 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EXPERIMENTAL Features (Beta)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* NOTE: Experimental features coming soon
|
|
5
|
+
* This is a placeholder for future beta features
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* import { AIUpsell
|
|
8
|
+
* // Future: import { AIUpsell } from '@umituz/react-native-subscription/exports/experimental';
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
// AI-
|
|
13
|
-
// ============================================================================
|
|
14
|
-
|
|
15
|
-
// AI-Powered Upsell Recommendations
|
|
16
|
-
export { useAIUpsellRecommendations } from '../../domains/paywall/experimental/useAIUpsellRecommendations';
|
|
17
|
-
export type {
|
|
18
|
-
AIUpsellData,
|
|
19
|
-
UpsellRecommendation,
|
|
20
|
-
UpsellStrategy,
|
|
21
|
-
} from '../../domains/paywall/experimental/useAIUpsellRecommendations.types';
|
|
22
|
-
|
|
23
|
-
// Smart Paywall (Dynamic pricing based on user behavior)
|
|
24
|
-
export { SmartPaywall } from '../../domains/paywall/experimental/SmartPaywall';
|
|
25
|
-
export type {
|
|
26
|
-
SmartPaywallProps,
|
|
27
|
-
SmartPaywallConfig,
|
|
28
|
-
} from '../../domains/paywall/experimental/SmartPaywall.types';
|
|
29
|
-
|
|
30
|
-
// ============================================================================
|
|
31
|
-
// EXPERIMENTAL COMPONENTS
|
|
32
|
-
// ============================================================================
|
|
33
|
-
|
|
34
|
-
// Interactive Pricing Tiers
|
|
35
|
-
export { InteractivePricingTiers } from '../../domains/paywall/experimental/InteractivePricingTiers';
|
|
36
|
-
export type {
|
|
37
|
-
InteractivePricingTiersProps,
|
|
38
|
-
PricingTierConfig,
|
|
39
|
-
} from '../../domains/paywall/experimental/InteractivePricingTiers.types';
|
|
40
|
-
|
|
41
|
-
// Gamified Paywall (Rewards for engagement)
|
|
42
|
-
export { GamifiedPaywall } from '../../domains/paywall/experimental/GamifiedPaywall';
|
|
43
|
-
export type {
|
|
44
|
-
GamifiedPaywallProps,
|
|
45
|
-
GamificationConfig,
|
|
46
|
-
RewardConfig,
|
|
47
|
-
} from '../../domains/paywall/experimental/GamifiedPaywall.types';
|
|
48
|
-
|
|
49
|
-
// ============================================================================
|
|
50
|
-
// EXPERIMENTAL HOOKS
|
|
51
|
-
// ============================================================================
|
|
52
|
-
|
|
53
|
-
// Predictive Churn Prevention
|
|
54
|
-
export { usePredictiveChurnPrevention } from '../../domains/subscription/presentation/experimental/usePredictiveChurnPrevention';
|
|
55
|
-
export type {
|
|
56
|
-
ChurnPredictionData,
|
|
57
|
-
ChurnPreventionAction,
|
|
58
|
-
InterventionStrategy,
|
|
59
|
-
} from '../../domains/subscription/presentation/experimental/usePredictiveChurnPrevention.types';
|
|
60
|
-
|
|
61
|
-
// Dynamic Offer Generator
|
|
62
|
-
export { useDynamicOfferGenerator } from '../../domains/paywall/experimental/useDynamicOfferGenerator';
|
|
63
|
-
export type {
|
|
64
|
-
DynamicOfferData,
|
|
65
|
-
OfferConfig,
|
|
66
|
-
OfferStrategy,
|
|
67
|
-
} from '../../domains/paywall/experimental/useDynamicOfferGenerator.types';
|
|
68
|
-
|
|
69
|
-
// ============================================================================
|
|
70
|
-
// EXPERIMENTAL UTILS
|
|
71
|
-
// ============================================================================
|
|
72
|
-
|
|
73
|
-
// Behavioral Segmentation
|
|
74
|
-
export {
|
|
75
|
-
segmentUsersByBehavior,
|
|
76
|
-
getUserBehaviorScore,
|
|
77
|
-
} from '../../utils/experimental/behavioralSegmentation';
|
|
78
|
-
export type {
|
|
79
|
-
UserBehavior,
|
|
80
|
-
BehaviorSegment,
|
|
81
|
-
BehaviorScore,
|
|
82
|
-
} from '../../utils/experimental/behavioralSegmentation.types';
|
|
83
|
-
|
|
84
|
-
// Price Optimization
|
|
85
|
-
export {
|
|
86
|
-
optimizePriceForUser,
|
|
87
|
-
getOptimalPricePoint,
|
|
88
|
-
} from '../../utils/experimental/priceOptimization';
|
|
89
|
-
export type {
|
|
90
|
-
PriceOptimizationData,
|
|
91
|
-
PricePoint,
|
|
92
|
-
OptimizationStrategy,
|
|
93
|
-
} from '../../utils/experimental/priceOptimization.types';
|
|
11
|
+
// Reserved for future experimental features
|
|
12
|
+
// Check back later for AI-powered features, smart paywalls, etc.
|
|
@@ -4,31 +4,14 @@
|
|
|
4
4
|
* Advanced onboarding utilities for custom flows
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* import {
|
|
7
|
+
* import { useOnboardingProgress } from '@umituz/react-native-subscription/exports/onboarding';
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
export type { OnboardingProgressData } from '../../domains/subscription/presentation/hooks/useOnboardingProgress.types';
|
|
10
|
+
// NOTE: These are placeholder exports for future onboarding features
|
|
11
|
+
// Currently, onboarding is handled by ManagedSubscriptionFlow core
|
|
13
12
|
|
|
14
|
-
//
|
|
15
|
-
export {
|
|
16
|
-
export type {
|
|
17
|
-
OnboardingEvent,
|
|
18
|
-
OnboardingAnalyticsData,
|
|
19
|
-
} from '../../presentation/hooks/onboarding/useOnboardingAnalytics.types';
|
|
13
|
+
// Re-export core onboarding types
|
|
14
|
+
export { SubscriptionFlowStatus } from '../domains/subscription/presentation/useSubscriptionFlow';
|
|
20
15
|
|
|
21
|
-
// Onboarding
|
|
22
|
-
|
|
23
|
-
export type {
|
|
24
|
-
OnboardingCompletionData,
|
|
25
|
-
OnboardingCompletionOptions,
|
|
26
|
-
} from '../../presentation/hooks/onboarding/useOnboardingCompletion.types';
|
|
27
|
-
|
|
28
|
-
// Onboarding Utils
|
|
29
|
-
export {
|
|
30
|
-
calculateOnboardingProgress,
|
|
31
|
-
isOnboardingComplete,
|
|
32
|
-
getOnboardingStep,
|
|
33
|
-
} from '../../utils/onboardingUtils';
|
|
34
|
-
export type { OnboardingStep } from '../../utils/onboardingUtils.types';
|
|
16
|
+
// Onboarding is part of ManagedSubscriptionFlow core
|
|
17
|
+
// This file is reserved for future advanced onboarding utilities
|
package/src/exports/wallet.ts
CHANGED
|
@@ -10,26 +10,23 @@
|
|
|
10
10
|
// Wallet Screen
|
|
11
11
|
export {
|
|
12
12
|
WalletScreen as WalletScreenContainer,
|
|
13
|
-
} from '
|
|
13
|
+
} from '../domains/wallet/presentation/screens/WalletScreen';
|
|
14
14
|
|
|
15
15
|
export type {
|
|
16
16
|
WalletScreenProps,
|
|
17
17
|
WalletScreenTranslations,
|
|
18
|
-
} from '
|
|
18
|
+
} from '../domains/wallet/presentation/screens/WalletScreen.types';
|
|
19
19
|
|
|
20
20
|
// Wallet Hooks
|
|
21
|
-
export { useWallet } from '
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
export { useTransactionHistory } from '../../domains/wallet/presentation/hooks/useTransactionHistory';
|
|
25
|
-
export type { TransactionHistoryResult } from '../../domains/wallet/presentation/hooks/useTransactionHistory';
|
|
21
|
+
export { useWallet } from '../domains/wallet/presentation/hooks/useWallet';
|
|
22
|
+
export { useTransactionHistory } from '../domains/wallet/presentation/hooks/useTransactionHistory';
|
|
26
23
|
|
|
27
24
|
// Wallet Components
|
|
28
|
-
export { BalanceCard } from '
|
|
29
|
-
export type { BalanceCardProps } from '
|
|
25
|
+
export { BalanceCard } from '../domains/wallet/presentation/components/BalanceCard';
|
|
26
|
+
export type { BalanceCardProps } from '../domains/wallet/presentation/components/BalanceCard.types';
|
|
30
27
|
|
|
31
|
-
export { TransactionList } from '
|
|
32
|
-
export type { TransactionListProps } from '
|
|
28
|
+
export { TransactionList } from '../domains/wallet/presentation/components/TransactionList';
|
|
29
|
+
export type { TransactionListProps } from '../domains/wallet/presentation/components/TransactionList.types';
|
|
33
30
|
|
|
34
|
-
export { TransactionItem } from '
|
|
35
|
-
export type { TransactionItemProps } from '
|
|
31
|
+
export { TransactionItem } from '../domains/wallet/presentation/components/TransactionItem';
|
|
32
|
+
export type { TransactionItemProps } from '../domains/wallet/presentation/components/TransactionItem.types';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE Exports - Components
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Subscription Components
|
|
6
|
+
export { PremiumDetailsCard } from "./domains/subscription/presentation/components/details/PremiumDetailsCard";
|
|
7
|
+
export type {
|
|
8
|
+
PremiumDetailsTranslations,
|
|
9
|
+
PremiumDetailsCardProps,
|
|
10
|
+
} from "./domains/subscription/presentation/components/details/PremiumDetailsCardTypes";
|
|
11
|
+
|
|
12
|
+
export { PremiumStatusBadge } from "./domains/subscription/presentation/components/details/PremiumStatusBadge";
|
|
13
|
+
export type { PremiumStatusBadgeProps } from "./domains/subscription/presentation/components/details/PremiumStatusBadge.types";
|
|
14
|
+
|
|
15
|
+
export { SubscriptionSection } from "./domains/subscription/presentation/components/sections/SubscriptionSection";
|
|
16
|
+
export type { SubscriptionSectionProps } from "./domains/subscription/presentation/components/sections/SubscriptionSection.types";
|
|
17
|
+
|
|
18
|
+
export { PaywallFeedbackScreen } from "./domains/subscription/presentation/components/feedback/PaywallFeedbackScreen";
|
|
19
|
+
export type { PaywallFeedbackScreenProps } from "./domains/subscription/presentation/components/feedback/PaywallFeedbackScreen.types";
|
|
20
|
+
|
|
21
|
+
// Subscription Screens
|
|
22
|
+
export type {
|
|
23
|
+
SubscriptionDetailConfig,
|
|
24
|
+
SubscriptionDetailTranslations,
|
|
25
|
+
SubscriptionDisplayFlags,
|
|
26
|
+
UpgradePromptConfig,
|
|
27
|
+
} from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
28
|
+
|
|
29
|
+
export { SubscriptionDetailScreen } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen";
|
|
30
|
+
export type { SubscriptionDetailScreenProps } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
31
|
+
|
|
32
|
+
// Paywall Components
|
|
33
|
+
export { PaywallScreen } from "./domains/paywall/components/PaywallScreen";
|
|
34
|
+
export type { PaywallScreenProps } from "./domains/paywall/components/PaywallScreen.types";
|
|
35
|
+
|
|
36
|
+
// Root Flow Components
|
|
37
|
+
export { ManagedSubscriptionFlow } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
|
|
38
|
+
export type { ManagedSubscriptionFlowProps } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
|
|
39
|
+
export { SubscriptionFlowStatus } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
40
|
+
export { SubscriptionFlowProvider, useSubscriptionFlowStatus } from "./domains/subscription/presentation/providers/SubscriptionFlowProvider";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE Exports - Constants & Types
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Constants & Types
|
|
6
|
+
export {
|
|
7
|
+
USER_TIER,
|
|
8
|
+
SUBSCRIPTION_STATUS,
|
|
9
|
+
PERIOD_TYPE,
|
|
10
|
+
PACKAGE_TYPE,
|
|
11
|
+
PLATFORM,
|
|
12
|
+
PURCHASE_SOURCE,
|
|
13
|
+
PURCHASE_TYPE,
|
|
14
|
+
ANONYMOUS_CACHE_KEY,
|
|
15
|
+
} from "./domains/subscription/core/SubscriptionConstants";
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
UserTierType,
|
|
19
|
+
SubscriptionStatusType,
|
|
20
|
+
PeriodType,
|
|
21
|
+
PackageType,
|
|
22
|
+
Platform,
|
|
23
|
+
PurchaseSource,
|
|
24
|
+
PurchaseType,
|
|
25
|
+
} from "./domains/subscription/core/SubscriptionConstants";
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
createDefaultSubscriptionStatus,
|
|
29
|
+
isSubscriptionValid,
|
|
30
|
+
resolveSubscriptionStatus,
|
|
31
|
+
} from "./domains/subscription/core/SubscriptionStatus";
|
|
32
|
+
export type { SubscriptionStatus, StatusResolverInput } from "./domains/subscription/core/SubscriptionStatus";
|
|
33
|
+
|
|
34
|
+
// Domain Events
|
|
35
|
+
export { SUBSCRIPTION_EVENTS } from "./domains/subscription/core/events/SubscriptionEvents";
|
|
36
|
+
export type { SubscriptionEventType, SyncStatusChangedEvent } from "./domains/subscription/core/events/SubscriptionEvents";
|
|
37
|
+
export type { PurchaseCompletedEvent, RenewalDetectedEvent, PremiumStatusChangedEvent } from "./domains/subscription/core/SubscriptionEvents";
|
|
38
|
+
export { FLOW_EVENTS } from "./domains/subscription/core/events/FlowEvents";
|
|
39
|
+
export type { FlowEventType, OnboardingCompletedEvent, PaywallShownEvent, PaywallClosedEvent } from "./domains/subscription/core/events/FlowEvents";
|
|
40
|
+
|
|
41
|
+
export type { SubscriptionMetadata } from "./domains/subscription/core/types/SubscriptionMetadata";
|
|
42
|
+
export type { PremiumStatus as PremiumStatusMetadata } from "./domains/subscription/core/types/PremiumStatus";
|
|
43
|
+
export type { CreditInfo } from "./domains/subscription/core/types/CreditInfo";
|
|
44
|
+
|
|
45
|
+
// Credits Types
|
|
46
|
+
export type {
|
|
47
|
+
CreditType,
|
|
48
|
+
UserCredits,
|
|
49
|
+
CreditsConfig,
|
|
50
|
+
CreditsResult,
|
|
51
|
+
DeductCreditsResult,
|
|
52
|
+
} from "./domains/credits/core/Credits";
|
|
53
|
+
|
|
54
|
+
// Paywall Types
|
|
55
|
+
export type { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "./domains/paywall/entities/types";
|
|
56
|
+
|
|
57
|
+
// Application Layer - Ports
|
|
58
|
+
export type { ISubscriptionRepository } from "./shared/application/ports/ISubscriptionRepository";
|
|
59
|
+
export type { IRevenueCatService } from "./shared/application/ports/IRevenueCatService";
|
|
60
|
+
|
|
61
|
+
// Result Pattern
|
|
62
|
+
export {
|
|
63
|
+
success,
|
|
64
|
+
failure,
|
|
65
|
+
isSuccess,
|
|
66
|
+
isFailure,
|
|
67
|
+
unwrap,
|
|
68
|
+
unwrapOr,
|
|
69
|
+
tryCatch,
|
|
70
|
+
} from "./shared/utils/Result";
|
|
71
|
+
export type { Result, Success, Failure } from "./shared/utils/Result";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE Exports - Hooks
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Subscription Hooks
|
|
6
|
+
export { useAuthAwarePurchase } from "./domains/subscription/presentation/useAuthAwarePurchase";
|
|
7
|
+
export { useFeatureGate } from "./domains/subscription/presentation/useFeatureGate";
|
|
8
|
+
export { usePaywallVisibility, paywallControl } from "./domains/subscription/presentation/usePaywallVisibility";
|
|
9
|
+
export { usePremiumStatus } from "./domains/subscription/presentation/usePremiumStatus";
|
|
10
|
+
export { usePremiumPackages } from "./domains/subscription/presentation/usePremiumPackages";
|
|
11
|
+
export { usePremiumActions } from "./domains/subscription/presentation/usePremiumActions";
|
|
12
|
+
export { useSubscriptionFlowStore } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
13
|
+
export { useSubscriptionStatus } from "./domains/subscription/presentation/useSubscriptionStatus";
|
|
14
|
+
|
|
15
|
+
// Hook Types
|
|
16
|
+
export type { PremiumStatus } from "./domains/subscription/presentation/usePremiumStatus";
|
|
17
|
+
export type { PremiumPackages } from "./domains/subscription/presentation/usePremiumPackages";
|
|
18
|
+
export type { PremiumActions } from "./domains/subscription/presentation/usePremiumActions";
|
|
19
|
+
export type { SubscriptionFlowState, SubscriptionFlowActions, SubscriptionFlowStore } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
20
|
+
export type { SubscriptionStatusResult } from "./domains/subscription/presentation/useSubscriptionStatus.types";
|
|
21
|
+
|
|
22
|
+
// Credits Hooks
|
|
23
|
+
export { useCredits } from "./domains/credits/presentation/useCredits";
|
|
24
|
+
export { useDeductCredit } from "./domains/credits/presentation/deduct-credit/useDeductCredit";
|
|
25
|
+
|
|
26
|
+
// Feedback Hooks
|
|
27
|
+
export { usePaywallFeedback } from "./presentation/hooks/feedback/usePaywallFeedback";
|
|
28
|
+
export {
|
|
29
|
+
usePaywallFeedbackSubmit,
|
|
30
|
+
useSettingsFeedbackSubmit,
|
|
31
|
+
} from "./presentation/hooks/feedback/useFeedbackSubmit";
|
|
32
|
+
|
|
33
|
+
export type {
|
|
34
|
+
UsePaywallFeedbackSubmitOptions,
|
|
35
|
+
SettingsFeedbackData,
|
|
36
|
+
UseSettingsFeedbackSubmitOptions,
|
|
37
|
+
} from "./presentation/hooks/feedback/useFeedbackSubmit";
|
|
38
|
+
|
|
39
|
+
// Paywall Hooks
|
|
40
|
+
export { usePaywallOrchestrator } from "./domains/paywall/hooks/usePaywallOrchestrator";
|
|
41
|
+
export type { PaywallOrchestratorOptions } from "./domains/paywall/hooks/usePaywallOrchestrator";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE Exports - Infrastructure & Utils
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Infrastructure Layer - Core Services
|
|
6
|
+
export { initializeSubscription } from "./domains/subscription/application/initializer/SubscriptionInitializer";
|
|
7
|
+
export type { SubscriptionInitConfig, CreditPackageConfig } from "./domains/subscription/application/SubscriptionInitializerTypes";
|
|
8
|
+
|
|
9
|
+
export { CreditsRepository } from "./domains/credits/infrastructure/CreditsRepository";
|
|
10
|
+
export {
|
|
11
|
+
configureCreditsRepository,
|
|
12
|
+
getCreditsRepository,
|
|
13
|
+
getCreditsConfig,
|
|
14
|
+
isCreditsRepositoryConfigured
|
|
15
|
+
} from "./domains/credits/infrastructure/CreditsRepositoryManager";
|
|
16
|
+
|
|
17
|
+
export { CreditLimitService, calculateCreditLimit } from "./domains/credits/domain/services/CreditLimitService";
|
|
18
|
+
|
|
19
|
+
// Utils
|
|
20
|
+
export {
|
|
21
|
+
getCreditAllocation,
|
|
22
|
+
createCreditAmountsFromPackages,
|
|
23
|
+
} from "./utils/creditMapper";
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
isCreditPackage,
|
|
27
|
+
detectPackageType,
|
|
28
|
+
} from "./utils/packageTypeDetector";
|
|
29
|
+
export type { SubscriptionPackageType } from "./utils/packageTypeDetector";
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
formatPrice,
|
|
33
|
+
getBillingPeriodSuffix,
|
|
34
|
+
formatPriceWithPeriod,
|
|
35
|
+
} from "./utils/priceUtils";
|
|
36
|
+
|
|
37
|
+
export type { UserTierInfo, PremiumStatusFetcher } from "./utils/types";
|
|
38
|
+
|
|
39
|
+
export type { DateLike } from "./utils/dateUtils.core";
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
isNow,
|
|
43
|
+
isPast,
|
|
44
|
+
isFuture,
|
|
45
|
+
isValidDate,
|
|
46
|
+
toSafeDate,
|
|
47
|
+
formatISO,
|
|
48
|
+
now,
|
|
49
|
+
} from "./utils/dateUtils.core";
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
daysBetween,
|
|
53
|
+
daysUntil,
|
|
54
|
+
isSameDay,
|
|
55
|
+
isToday,
|
|
56
|
+
} from "./utils/dateUtils.compare";
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
formatRelative,
|
|
60
|
+
formatShort,
|
|
61
|
+
formatLong,
|
|
62
|
+
} from "./utils/dateUtils.format";
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
addDays,
|
|
66
|
+
addMonths,
|
|
67
|
+
addYears,
|
|
68
|
+
} from "./utils/dateUtils.math";
|
|
69
|
+
|
|
70
|
+
export { getAppVersion, validatePlatform } from "./utils/appUtils";
|
|
71
|
+
|
|
72
|
+
export { toDate, toISOString, toTimestamp, getCurrentISOString } from "./shared/utils/dateConverter";
|
|
73
|
+
|
|
74
|
+
export { createPaywallTranslations, createFeedbackTranslations } from "./domains/paywall/utils/paywallTranslationUtils";
|
|
75
|
+
|
|
76
|
+
// Init Module
|
|
77
|
+
export {
|
|
78
|
+
createSubscriptionInitModule,
|
|
79
|
+
cleanupSubscriptionModule,
|
|
80
|
+
type SubscriptionInitModuleConfig,
|
|
81
|
+
} from './init';
|
package/src/index.ts
CHANGED
|
@@ -1,256 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @umituz/react-native-subscription
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Complete subscription management with RevenueCat, paywall UI, and credits system
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Core features
|
|
8
|
+
* import { usePremiumStatus, ManagedSubscriptionFlow } from '@umituz/react-native-subscription';
|
|
9
|
+
*
|
|
10
|
+
* // Optional wallet
|
|
11
|
+
* import { WalletScreen } from '@umituz/react-native-subscription/exports/wallet';
|
|
6
12
|
*/
|
|
7
13
|
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
USER_TIER,
|
|
14
|
-
SUBSCRIPTION_STATUS,
|
|
15
|
-
PERIOD_TYPE,
|
|
16
|
-
PACKAGE_TYPE,
|
|
17
|
-
PLATFORM,
|
|
18
|
-
PURCHASE_SOURCE,
|
|
19
|
-
PURCHASE_TYPE,
|
|
20
|
-
ANONYMOUS_CACHE_KEY,
|
|
21
|
-
} from "./domains/subscription/core/SubscriptionConstants";
|
|
22
|
-
|
|
23
|
-
export type {
|
|
24
|
-
UserTierType,
|
|
25
|
-
SubscriptionStatusType,
|
|
26
|
-
PeriodType,
|
|
27
|
-
PackageType,
|
|
28
|
-
Platform,
|
|
29
|
-
PurchaseSource,
|
|
30
|
-
PurchaseType,
|
|
31
|
-
} from "./domains/subscription/core/SubscriptionConstants";
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
createDefaultSubscriptionStatus,
|
|
35
|
-
isSubscriptionValid,
|
|
36
|
-
resolveSubscriptionStatus,
|
|
37
|
-
} from "./domains/subscription/core/SubscriptionStatus";
|
|
38
|
-
export type { SubscriptionStatus, StatusResolverInput } from "./domains/subscription/core/SubscriptionStatus";
|
|
39
|
-
|
|
40
|
-
// ============================================================================
|
|
41
|
-
// DOMAIN EVENTS
|
|
42
|
-
// ============================================================================
|
|
43
|
-
|
|
44
|
-
export { SUBSCRIPTION_EVENTS } from "./domains/subscription/core/events/SubscriptionEvents";
|
|
45
|
-
export type { SubscriptionEventType, SyncStatusChangedEvent } from "./domains/subscription/core/events/SubscriptionEvents";
|
|
46
|
-
export type { PurchaseCompletedEvent, RenewalDetectedEvent, PremiumStatusChangedEvent } from "./domains/subscription/core/SubscriptionEvents";
|
|
47
|
-
export { FLOW_EVENTS } from "./domains/subscription/core/events/FlowEvents";
|
|
48
|
-
export type { FlowEventType, OnboardingCompletedEvent, PaywallShownEvent, PaywallClosedEvent } from "./domains/subscription/core/events/FlowEvents";
|
|
49
|
-
|
|
50
|
-
export type { SubscriptionMetadata } from "./domains/subscription/core/types/SubscriptionMetadata";
|
|
51
|
-
export type { PremiumStatus as PremiumStatusMetadata } from "./domains/subscription/core/types/PremiumStatus";
|
|
52
|
-
export type { CreditInfo } from "./domains/subscription/core/types/CreditInfo";
|
|
53
|
-
|
|
54
|
-
// ============================================================================
|
|
55
|
-
// CREDITS TYPES (Core credits, wallet is separate)
|
|
56
|
-
// ============================================================================
|
|
57
|
-
|
|
58
|
-
export type {
|
|
59
|
-
CreditType,
|
|
60
|
-
UserCredits,
|
|
61
|
-
CreditsConfig,
|
|
62
|
-
CreditsResult,
|
|
63
|
-
DeductCreditsResult,
|
|
64
|
-
} from "./domains/credits/core/Credits";
|
|
65
|
-
|
|
66
|
-
// ============================================================================
|
|
67
|
-
// PAYWALL TYPES
|
|
68
|
-
// ============================================================================
|
|
69
|
-
|
|
70
|
-
export type { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "./domains/paywall/entities/types";
|
|
71
|
-
|
|
72
|
-
// ============================================================================
|
|
73
|
-
// APPLICATION LAYER - Ports
|
|
74
|
-
// ============================================================================
|
|
75
|
-
|
|
76
|
-
export type { ISubscriptionRepository } from "./shared/application/ports/ISubscriptionRepository";
|
|
77
|
-
export type { IRevenueCatService } from "./shared/application/ports/IRevenueCatService";
|
|
78
|
-
|
|
79
|
-
// ============================================================================
|
|
80
|
-
// RESULT PATTERN
|
|
81
|
-
// ============================================================================
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
success,
|
|
85
|
-
failure,
|
|
86
|
-
isSuccess,
|
|
87
|
-
isFailure,
|
|
88
|
-
unwrap,
|
|
89
|
-
unwrapOr,
|
|
90
|
-
tryCatch,
|
|
91
|
-
} from "./shared/utils/Result";
|
|
92
|
-
export type { Result, Success, Failure } from "./shared/utils/Result";
|
|
93
|
-
|
|
94
|
-
// ============================================================================
|
|
95
|
-
// INFRASTRUCTURE LAYER - Core Services (No wallet)
|
|
96
|
-
// ============================================================================
|
|
97
|
-
|
|
98
|
-
export { initializeSubscription } from "./domains/subscription/application/initializer/SubscriptionInitializer";
|
|
99
|
-
export type { SubscriptionInitConfig, CreditPackageConfig } from "./domains/subscription/application/SubscriptionInitializerTypes";
|
|
100
|
-
|
|
101
|
-
export { CreditsRepository } from "./domains/credits/infrastructure/CreditsRepository";
|
|
102
|
-
export {
|
|
103
|
-
configureCreditsRepository,
|
|
104
|
-
getCreditsRepository,
|
|
105
|
-
getCreditsConfig,
|
|
106
|
-
isCreditsRepositoryConfigured
|
|
107
|
-
} from "./domains/credits/infrastructure/CreditsRepositoryManager";
|
|
108
|
-
|
|
109
|
-
export { CreditLimitService, calculateCreditLimit } from "./domains/credits/domain/services/CreditLimitService";
|
|
110
|
-
|
|
111
|
-
// ============================================================================
|
|
112
|
-
// PRESENTATION LAYER - Hooks (Core)
|
|
113
|
-
// ============================================================================
|
|
114
|
-
|
|
115
|
-
export { useAuthAwarePurchase } from "./domains/subscription/presentation/useAuthAwarePurchase";
|
|
116
|
-
export { useCredits } from "./domains/credits/presentation/useCredits";
|
|
117
|
-
export { useDeductCredit } from "./domains/credits/presentation/deduct-credit/useDeductCredit";
|
|
118
|
-
export { useFeatureGate } from "./domains/subscription/presentation/useFeatureGate";
|
|
119
|
-
export { usePaywallVisibility, paywallControl } from "./domains/subscription/presentation/usePaywallVisibility";
|
|
120
|
-
export { usePremiumStatus } from "./domains/subscription/presentation/usePremiumStatus";
|
|
121
|
-
export { usePremiumPackages } from "./domains/subscription/presentation/usePremiumPackages";
|
|
122
|
-
export { usePremiumActions } from "./domains/subscription/presentation/usePremiumActions";
|
|
123
|
-
export { useSubscriptionFlowStore } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
124
|
-
export type { SubscriptionFlowState, SubscriptionFlowActions, SubscriptionFlowStore } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
125
|
-
export { useSubscriptionStatus } from "./domains/subscription/presentation/useSubscriptionStatus";
|
|
126
|
-
export type { SubscriptionStatusResult } from "./domains/subscription/presentation/useSubscriptionStatus.types";
|
|
127
|
-
|
|
128
|
-
export type { PremiumStatus } from "./domains/subscription/presentation/usePremiumStatus";
|
|
129
|
-
export type { PremiumPackages } from "./domains/subscription/presentation/usePremiumPackages";
|
|
130
|
-
export type { PremiumActions } from "./domains/subscription/presentation/usePremiumActions";
|
|
131
|
-
|
|
132
|
-
export { usePaywallFeedback } from "./presentation/hooks/feedback/usePaywallFeedback";
|
|
133
|
-
export {
|
|
134
|
-
usePaywallFeedbackSubmit,
|
|
135
|
-
useSettingsFeedbackSubmit,
|
|
136
|
-
} from "./presentation/hooks/feedback/useFeedbackSubmit";
|
|
137
|
-
|
|
138
|
-
export type {
|
|
139
|
-
UsePaywallFeedbackSubmitOptions,
|
|
140
|
-
SettingsFeedbackData,
|
|
141
|
-
UseSettingsFeedbackSubmitOptions,
|
|
142
|
-
} from "./presentation/hooks/feedback/useFeedbackSubmit";
|
|
143
|
-
|
|
144
|
-
// ============================================================================
|
|
145
|
-
// PRESENTATION LAYER - Components (Core - No wallet)
|
|
146
|
-
// ============================================================================
|
|
147
|
-
|
|
148
|
-
export { PremiumDetailsCard } from "./domains/subscription/presentation/components/details/PremiumDetailsCard";
|
|
149
|
-
export type {
|
|
150
|
-
PremiumDetailsTranslations,
|
|
151
|
-
PremiumDetailsCardProps,
|
|
152
|
-
} from "./domains/subscription/presentation/components/details/PremiumDetailsCardTypes";
|
|
153
|
-
|
|
154
|
-
export { PremiumStatusBadge } from "./domains/subscription/presentation/components/details/PremiumStatusBadge";
|
|
155
|
-
export type { PremiumStatusBadgeProps } from "./domains/subscription/presentation/components/details/PremiumStatusBadge.types";
|
|
156
|
-
|
|
157
|
-
export { SubscriptionSection } from "./domains/subscription/presentation/components/sections/SubscriptionSection";
|
|
158
|
-
export type { SubscriptionSectionProps } from "./domains/subscription/presentation/components/sections/SubscriptionSection.types";
|
|
159
|
-
|
|
160
|
-
export { PaywallFeedbackScreen } from "./domains/subscription/presentation/components/feedback/PaywallFeedbackScreen";
|
|
161
|
-
export type { PaywallFeedbackScreenProps } from "./domains/subscription/presentation/components/feedback/PaywallFeedbackScreen.types";
|
|
162
|
-
|
|
163
|
-
export type {
|
|
164
|
-
SubscriptionDetailConfig,
|
|
165
|
-
SubscriptionDetailTranslations,
|
|
166
|
-
SubscriptionDisplayFlags,
|
|
167
|
-
UpgradePromptConfig,
|
|
168
|
-
} from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
169
|
-
|
|
170
|
-
export { SubscriptionDetailScreen } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen";
|
|
171
|
-
export type { SubscriptionDetailScreenProps } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
172
|
-
|
|
173
|
-
export { PaywallScreen } from "./domains/paywall/components/PaywallScreen";
|
|
174
|
-
export type { PaywallScreenProps } from "./domains/paywall/components/PaywallScreen.types";
|
|
175
|
-
|
|
176
|
-
export { usePaywallOrchestrator } from "./domains/paywall/hooks/usePaywallOrchestrator";
|
|
177
|
-
export type { PaywallOrchestratorOptions } from "./domains/paywall/hooks/usePaywallOrchestrator";
|
|
178
|
-
|
|
179
|
-
// ============================================================================
|
|
180
|
-
// ROOT FLOW COMPONENTS
|
|
181
|
-
// ============================================================================
|
|
182
|
-
|
|
183
|
-
export { ManagedSubscriptionFlow } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
|
|
184
|
-
export type { ManagedSubscriptionFlowProps } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
|
|
185
|
-
export { SubscriptionFlowStatus } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
186
|
-
export { SubscriptionFlowProvider, useSubscriptionFlowStatus } from "./domains/subscription/presentation/providers/SubscriptionFlowProvider";
|
|
187
|
-
|
|
188
|
-
// ============================================================================
|
|
189
|
-
// UTILS (Core)
|
|
190
|
-
// ============================================================================
|
|
191
|
-
|
|
192
|
-
export {
|
|
193
|
-
getCreditAllocation,
|
|
194
|
-
createCreditAmountsFromPackages,
|
|
195
|
-
} from "./utils/creditMapper";
|
|
196
|
-
|
|
197
|
-
export {
|
|
198
|
-
isCreditPackage,
|
|
199
|
-
detectPackageType,
|
|
200
|
-
} from "./utils/packageTypeDetector";
|
|
201
|
-
export type { SubscriptionPackageType } from "./utils/packageTypeDetector";
|
|
202
|
-
|
|
203
|
-
export {
|
|
204
|
-
formatPrice,
|
|
205
|
-
getBillingPeriodSuffix,
|
|
206
|
-
formatPriceWithPeriod,
|
|
207
|
-
} from "./utils/priceUtils";
|
|
208
|
-
|
|
209
|
-
export type { UserTierInfo, PremiumStatusFetcher } from "./utils/types";
|
|
210
|
-
|
|
211
|
-
export type { DateLike } from "./utils/dateUtils.core";
|
|
212
|
-
|
|
213
|
-
export {
|
|
214
|
-
isNow,
|
|
215
|
-
isPast,
|
|
216
|
-
isFuture,
|
|
217
|
-
isValidDate,
|
|
218
|
-
toSafeDate,
|
|
219
|
-
formatISO,
|
|
220
|
-
now,
|
|
221
|
-
} from "./utils/dateUtils.core";
|
|
222
|
-
|
|
223
|
-
export {
|
|
224
|
-
daysBetween,
|
|
225
|
-
daysUntil,
|
|
226
|
-
isSameDay,
|
|
227
|
-
isToday,
|
|
228
|
-
} from "./utils/dateUtils.compare";
|
|
229
|
-
|
|
230
|
-
export {
|
|
231
|
-
formatRelative,
|
|
232
|
-
formatShort,
|
|
233
|
-
formatLong,
|
|
234
|
-
} from "./utils/dateUtils.format";
|
|
235
|
-
|
|
236
|
-
export {
|
|
237
|
-
addDays,
|
|
238
|
-
addMonths,
|
|
239
|
-
addYears,
|
|
240
|
-
} from "./utils/dateUtils.math";
|
|
241
|
-
|
|
242
|
-
export { getAppVersion, validatePlatform } from "./utils/appUtils";
|
|
243
|
-
|
|
244
|
-
export { toDate, toISOString, toTimestamp, getCurrentISOString } from "./shared/utils/dateConverter";
|
|
245
|
-
|
|
246
|
-
export { createPaywallTranslations, createFeedbackTranslations } from "./domains/paywall/utils/paywallTranslationUtils";
|
|
247
|
-
|
|
248
|
-
// ============================================================================
|
|
249
|
-
// INIT MODULE
|
|
250
|
-
// ============================================================================
|
|
251
|
-
|
|
252
|
-
export {
|
|
253
|
-
createSubscriptionInitModule,
|
|
254
|
-
cleanupSubscriptionModule,
|
|
255
|
-
type SubscriptionInitModuleConfig,
|
|
256
|
-
} from './init';
|
|
14
|
+
// Re-export from categorized files for better organization
|
|
15
|
+
export * from './index.constants';
|
|
16
|
+
export * from './index.hooks';
|
|
17
|
+
export * from './index.components';
|
|
18
|
+
export * from './index.infrastructure';
|