@umituz/react-native-subscription 2.37.12 → 2.37.14
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/credits/application/PurchaseMetadataGenerator.ts +1 -1
- package/src/domains/credits/application/credit-strategies/CreditAllocationOrchestrator.ts +1 -1
- package/src/domains/credits/application/creditDocumentHelpers.ts +0 -14
- package/src/domains/credits/presentation/deduct-credit/index.ts +0 -1
- package/src/domains/credits/presentation/useCredits.ts +1 -6
- package/src/domains/credits/utils/creditValidation.ts +3 -3
- package/src/domains/paywall/components/PaywallFeatures.tsx +1 -1
- package/src/domains/paywall/hooks/usePaywallActions.ts +1 -1
- package/src/domains/revenuecat/core/errors/RevenueCatError.ts +1 -14
- package/src/domains/revenuecat/core/errors/RevenueCatErrorHandler.ts +1 -1
- package/src/domains/revenuecat/core/types/RevenueCatTypes.ts +3 -3
- package/src/domains/revenuecat/infrastructure/services/ConfigurationStateManager.ts +1 -1
- package/src/domains/revenuecat/infrastructure/services/RevenueCatInitializer.ts +0 -2
- package/src/domains/revenuecat/infrastructure/services/UserSwitchMutex.ts +9 -0
- package/src/domains/subscription/application/initializer/index.ts +1 -1
- package/src/domains/subscription/core/SubscriptionStatus.ts +4 -10
- package/src/domains/subscription/core/SubscriptionStatusHandlers.ts +1 -1
- package/src/domains/subscription/infrastructure/handlers/PackageHandler.ts +0 -2
- package/src/domains/subscription/infrastructure/hooks/usePurchasePackage.ts +1 -1
- package/src/domains/subscription/infrastructure/hooks/useRevenueCatTrialEligibility.ts +1 -2
- package/src/domains/subscription/infrastructure/hooks/useSubscriptionQueries.ts +0 -4
- package/src/domains/subscription/infrastructure/services/OfferingsFetcher.ts +1 -1
- package/src/domains/subscription/infrastructure/services/RestoreHandler.ts +1 -1
- package/src/domains/subscription/infrastructure/services/RevenueCatService.ts +1 -2
- package/src/domains/subscription/infrastructure/services/revenueCatServiceInstance.ts +0 -4
- package/src/domains/subscription/infrastructure/utils/renewal/index.ts +1 -1
- package/src/domains/subscription/presentation/components/details/CreditRow.tsx +1 -1
- package/src/domains/subscription/presentation/components/details/DetailRow.tsx +1 -1
- package/src/domains/subscription/presentation/components/feedback/FeedbackOption.tsx +0 -2
- package/src/domains/subscription/presentation/components/feedback/FeedbackTextInput.tsx +1 -1
- package/src/domains/subscription/presentation/featureGateRefs.ts +1 -1
- package/src/domains/subscription/presentation/screens/components/CreditsList.tsx +2 -2
- package/src/domains/subscription/presentation/screens/components/SubscriptionHeader.tsx +0 -2
- package/src/domains/subscription/presentation/stores/index.ts +0 -5
- package/src/domains/subscription/presentation/stores/purchaseLoadingStore.ts +3 -7
- package/src/domains/subscription/presentation/useAuthAwarePurchase.ts +2 -8
- package/src/domains/subscription/presentation/useFeatureGate.ts +0 -2
- package/src/domains/subscription/presentation/usePaywallVisibility.ts +1 -1
- package/src/domains/subscription/utils/authGuards.ts +0 -23
- package/src/domains/subscription/utils/syncStatus.ts +1 -1
- package/src/domains/wallet/index.ts +0 -112
- package/src/domains/wallet/infrastructure/config/walletConfig.ts +1 -23
- package/src/domains/wallet/infrastructure/repositories/transaction/CollectionBuilder.ts +1 -1
- package/src/domains/wallet/infrastructure/repositories/transaction/index.ts +0 -9
- package/src/domains/wallet/presentation/components/BalanceCard.tsx +1 -1
- package/src/domains/wallet/presentation/components/TransactionItem.tsx +0 -2
- package/src/domains/wallet/presentation/components/TransactionList.tsx +3 -2
- package/src/domains/wallet/presentation/hooks/useTransactionHistory.ts +2 -2
- package/src/domains/wallet/presentation/hooks/useWallet.ts +2 -2
- package/src/shared/application/FeedbackService.ts +2 -2
- package/src/shared/infrastructure/SubscriptionEventBus.ts +1 -1
- package/src/shared/infrastructure/firestore/collectionUtils.ts +0 -7
- package/src/shared/infrastructure/firestore/resultUtils.ts +3 -39
- package/src/shared/presentation/layouts/ScreenLayout.tsx +1 -1
- package/src/shared/utils/numberUtils.core.ts +0 -27
- package/src/shared/utils/numberUtils.ts +1 -9
- package/src/shared/utils/validators.ts +0 -58
- package/src/domains/config/domain/entities/Plan.ts +0 -44
- package/src/domains/config/domain/index.ts +0 -2
- package/src/domains/config/domain/value-objects/Config.ts +0 -49
- package/src/domains/config/index.ts +0 -6
- package/src/domains/config/utils/planSelectors.ts +0 -56
- package/src/domains/paywall/components/FeatureItem.tsx +0 -50
- package/src/domains/paywall/components/FeatureList.tsx +0 -34
- package/src/domains/paywall/components/PaywallHeader.tsx +0 -112
- package/src/domains/paywall/hooks/usePaywallTranslations.ts +0 -78
- package/src/domains/paywall/hooks/useSubscriptionModal.ts +0 -45
- package/src/domains/paywall/index.ts +0 -13
- package/src/domains/revenuecat/core/constants/RevenueCatConstants.ts +0 -201
- package/src/domains/revenuecat/core/constants/index.ts +0 -5
- package/src/domains/revenuecat/core/customerInfoHelpers.ts +0 -21
- package/src/domains/revenuecat/core/index.ts +0 -7
- package/src/domains/revenuecat/index.ts +0 -7
- package/src/domains/revenuecat/infrastructure/index.ts +0 -5
- package/src/domains/revenuecat/infrastructure/services/index.ts +0 -7
- package/src/domains/subscription/infrastructure/hooks/customer-info/index.ts +0 -2
- package/src/domains/subscription/infrastructure/hooks/customer-info/types.ts +0 -9
- package/src/domains/subscription/infrastructure/hooks/customer-info/useCustomerInfo.ts +0 -52
- package/src/domains/subscription/infrastructure/hooks/useInitializeSubscription.ts +0 -30
- package/src/domains/subscription/infrastructure/hooks/usePaywallFlow.ts +0 -78
- package/src/domains/subscription/infrastructure/hooks/useRevenueCat.ts +0 -119
- package/src/domains/subscription/presentation/components/feedback/FeedbackConstants.ts +0 -6
- package/src/domains/subscription/presentation/screens/components/SubscriptionActions.tsx +0 -56
- package/src/domains/subscription/utils/dateFormatters.ts +0 -28
- package/src/domains/wallet/domain/entities/CreditCost.ts +0 -45
- package/src/domains/wallet/domain/entities/README.md +0 -41
- package/src/domains/wallet/domain/errors/README.md +0 -40
- package/src/domains/wallet/domain/errors/WalletError.ts +0 -17
- package/src/domains/wallet/domain/errors/WalletError.types.ts +0 -30
- package/src/domains/wallet/domain/errors/WalletErrorClasses.ts +0 -82
- package/src/domains/wallet/domain/errors/WalletErrorFactory.ts +0 -24
- package/src/domains/wallet/domain/errors/WalletErrorMessages.ts +0 -17
- package/src/domains/wallet/domain/types/credit-cost.types.ts +0 -86
- package/src/domains/wallet/domain/types/index.ts +0 -33
- package/src/domains/wallet/domain/types/wallet.types.ts +0 -50
- package/src/domains/wallet/infrastructure/services/product-metadata/CacheManager.ts +0 -30
- package/src/domains/wallet/infrastructure/services/product-metadata/FirebaseFetcher.ts +0 -17
- package/src/domains/wallet/infrastructure/services/product-metadata/ProductMetadataService.ts +0 -57
- package/src/domains/wallet/infrastructure/services/product-metadata/ServiceManager.ts +0 -29
- package/src/domains/wallet/infrastructure/services/product-metadata/index.ts +0 -7
- package/src/domains/wallet/presentation/hooks/index.ts +0 -8
- package/src/domains/wallet/presentation/hooks/useProductMetadata.ts +0 -72
- package/src/domains/wallet/utils/index.ts +0 -1
- package/src/shared/application/ActivationHandler.ts +0 -108
- package/src/shared/application/ports/ISubscriptionService.ts +0 -27
- package/src/shared/infrastructure/index.ts +0 -6
- package/src/shared/infrastructure/react-query/queryInvalidation.ts +0 -46
- package/src/shared/presentation/hooks/index.ts +0 -6
- package/src/shared/presentation/hooks/useAsyncState.ts +0 -72
- package/src/shared/presentation/hooks/useServiceCall.ts +0 -77
- package/src/shared/types/ReactTypes.ts +0 -80
- package/src/shared/utils/InsufficientCreditsError.ts +0 -32
- package/src/shared/utils/Logger.ts +0 -81
- package/src/shared/utils/SubscriptionConfig.ts +0 -15
- package/src/shared/utils/SubscriptionError.ts +0 -47
- package/src/shared/utils/appValidators.ts +0 -38
- package/src/shared/utils/arrayUtils.core.ts +0 -81
- package/src/shared/utils/arrayUtils.query.ts +0 -118
- package/src/shared/utils/arrayUtils.transforms.ts +0 -116
- package/src/shared/utils/arrayUtils.ts +0 -19
- package/src/shared/utils/errorUtils.ts +0 -32
- package/src/shared/utils/index.ts +0 -14
- package/src/shared/utils/numberUtils.aggregate.ts +0 -35
- package/src/shared/utils/numberUtils.format.ts +0 -42
- package/src/shared/utils/numberUtils.math.ts +0 -48
- package/src/shared/utils/queryKeyFactory.ts +0 -9
- package/src/shared/utils/stringUtils.case.ts +0 -64
- package/src/shared/utils/stringUtils.check.ts +0 -65
- package/src/shared/utils/stringUtils.format.ts +0 -84
- package/src/shared/utils/stringUtils.generate.ts +0 -47
- package/src/shared/utils/stringUtils.modify.ts +0 -67
- package/src/shared/utils/stringUtils.ts +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.37.
|
|
3
|
+
"version": "2.37.14",
|
|
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",
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
import { detectPackageType } from "../../../utils/packageTypeDetector";
|
|
9
9
|
import { PACKAGE_TYPE, PURCHASE_TYPE, type Platform } from "../../subscription/core/SubscriptionConstants";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
interface MetadataGeneratorConfig {
|
|
12
12
|
productId: string;
|
|
13
13
|
source: PurchaseSource;
|
|
14
14
|
type: PurchaseType;
|
|
@@ -6,7 +6,7 @@ import { StandardPurchaseCreditStrategy } from "./StandardPurchaseCreditStrategy
|
|
|
6
6
|
/**
|
|
7
7
|
* Orchestrator to coordinate credit allocation logic using the Strategy Pattern.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
class CreditAllocationOrchestrator {
|
|
10
10
|
private strategies: ICreditStrategy[] = [
|
|
11
11
|
new SyncCreditStrategy(),
|
|
12
12
|
new TrialCreditStrategy(),
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
import type { UserCreditsDocumentRead } from "../core/UserCreditsDocument";
|
|
7
7
|
import { serverTimestamp, type DocumentSnapshot } from "@umituz/react-native-firebase";
|
|
8
8
|
import { SUBSCRIPTION_STATUS, type Platform } from "../../subscription/core/SubscriptionConstants";
|
|
9
|
-
import { PROCESSED_PURCHASES_WINDOW } from "../core/CreditsConstants";
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
10
|
* Get existing credit document or create default
|
|
13
11
|
*/
|
|
@@ -54,15 +52,3 @@ export function getCreditDocumentOrDefault(
|
|
|
54
52
|
|
|
55
53
|
return defaultDocument;
|
|
56
54
|
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Add purchase ID to processed purchases list
|
|
60
|
-
* Maintains last N purchases (default: PROCESSED_PURCHASES_WINDOW)
|
|
61
|
-
*/
|
|
62
|
-
export function addProcessedPurchase(
|
|
63
|
-
existing: string[],
|
|
64
|
-
purchaseId: string,
|
|
65
|
-
limit: number = PROCESSED_PURCHASES_WINDOW
|
|
66
|
-
): string[] {
|
|
67
|
-
return [...existing, purchaseId].slice(-limit);
|
|
68
|
-
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { isValidNumber, isNonNegativeNumber } from "../../../shared/utils/validators";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const isValidBalance = (balance: number | null | undefined): balance is number => {
|
|
4
4
|
return isValidNumber(balance) && isNonNegativeNumber(balance);
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const isValidCost = (cost: number): boolean => {
|
|
8
8
|
return isValidNumber(cost) && isNonNegativeNumber(cost);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const isValidMaxCredits = (max: number): boolean => {
|
|
12
12
|
return isValidNumber(max) && max > 0;
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -11,7 +11,7 @@ export const PaywallFeatures: React.FC<{ features: SubscriptionFeature[] }> = ({
|
|
|
11
11
|
return (
|
|
12
12
|
<View style={[styles.features, { backgroundColor: tokens.colors.surfaceSecondary }]}>
|
|
13
13
|
{features.map((feature, idx) => (
|
|
14
|
-
<View key={
|
|
14
|
+
<View key={`${feature.icon}-${feature.text}`} style={styles.featureRow}>
|
|
15
15
|
<View style={[styles.featureIcon, { backgroundColor: tokens.colors.primaryLight }]}>
|
|
16
16
|
<AtomicIcon name={feature.icon} customSize={16} customColor={tokens.colors.primary} />
|
|
17
17
|
</View>
|
|
@@ -7,7 +7,7 @@ import type { PurchasesPackage } from "react-native-purchases";
|
|
|
7
7
|
import { usePurchaseLoadingStore } from "../../subscription/presentation/stores";
|
|
8
8
|
import type { PurchaseSource } from "../../subscription/core/SubscriptionConstants";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface UsePaywallActionsParams {
|
|
11
11
|
packages?: PurchasesPackage[];
|
|
12
12
|
onPurchase?: (pkg: PurchasesPackage) => Promise<void | boolean>;
|
|
13
13
|
onRestore?: () => Promise<void | boolean>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { BaseError } from "../../../../shared/utils/BaseError";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
class RevenueCatError extends BaseError {
|
|
9
9
|
constructor(message: string, code: string = 'REVENUE_CAT_ERROR', cause?: Error) {
|
|
10
10
|
super(message, code, cause);
|
|
11
11
|
this.name = "RevenueCatError";
|
|
@@ -19,13 +19,6 @@ export class RevenueCatInitializationError extends RevenueCatError {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export class RevenueCatConfigurationError extends RevenueCatError {
|
|
23
|
-
constructor(message = "RevenueCat configuration is invalid", cause?: Error) {
|
|
24
|
-
super(message, 'REVENUE_CAT_CONFIGURATION_ERROR', cause);
|
|
25
|
-
this.name = "RevenueCatConfigurationError";
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
22
|
export class RevenueCatPurchaseError extends RevenueCatError {
|
|
30
23
|
public readonly productId: string | undefined;
|
|
31
24
|
|
|
@@ -57,9 +50,3 @@ export class RevenueCatNetworkError extends RevenueCatError {
|
|
|
57
50
|
}
|
|
58
51
|
}
|
|
59
52
|
|
|
60
|
-
export class RevenueCatExpoGoError extends RevenueCatError {
|
|
61
|
-
constructor(message = "RevenueCat is not available in Expo Go. Use a development build or test store.", cause?: Error) {
|
|
62
|
-
super(message, 'REVENUE_CAT_EXPO_GO_ERROR', cause);
|
|
63
|
-
this.name = "RevenueCatExpoGoError";
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -54,7 +54,7 @@ const ERROR_CODE_MAP = new Map<string, PurchasesErrorCode>([
|
|
|
54
54
|
* @param errorCode - Error code string from RevenueCat error
|
|
55
55
|
* @returns ErrorMessage configuration
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
function getErrorMessageForCode(errorCode: string | null | undefined): ErrorMessage {
|
|
58
58
|
if (!errorCode) {
|
|
59
59
|
return DEFAULT_ERROR_MESSAGE;
|
|
60
60
|
}
|
|
@@ -9,7 +9,7 @@ import type { CustomerInfo, PurchasesEntitlementInfo, PurchasesPackage } from "r
|
|
|
9
9
|
* Default entitlement identifier
|
|
10
10
|
* Can be overridden in RevenueCatConfig
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const DEFAULT_ENTITLEMENT_ID = "premium";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Store type - Directly from RevenueCat SDK
|
|
@@ -34,7 +34,7 @@ export type PackageType = PurchasesPackage['packageType'];
|
|
|
34
34
|
* RevenueCat Entitlement Info
|
|
35
35
|
* Represents active entitlement data from CustomerInfo
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
interface RevenueCatEntitlement {
|
|
38
38
|
identifier: string;
|
|
39
39
|
productIdentifier: string;
|
|
40
40
|
isSandbox: boolean;
|
|
@@ -50,7 +50,7 @@ export interface RevenueCatEntitlement {
|
|
|
50
50
|
/**
|
|
51
51
|
* RevenueCat Purchase Error with userCancelled flag
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
interface RevenueCatPurchaseErrorInfo extends Error {
|
|
54
54
|
userCancelled?: boolean;
|
|
55
55
|
code?: string;
|
|
56
56
|
readableErrorCode?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InitializeResult } from "../../../../shared/application/ports/IRevenueCatService";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
class ConfigurationStateManager {
|
|
4
4
|
private _isPurchasesConfigured = false;
|
|
5
5
|
private _configurationPromise: Promise<InitializeResult> | null = null;
|
|
6
6
|
private _resolveConfiguration: ((value: InitializeResult) => void) | null = null;
|
|
@@ -5,8 +5,6 @@ import { FAILED_INITIALIZATION_RESULT, CONFIGURATION_RETRY_DELAY_MS, MAX_INIT_RE
|
|
|
5
5
|
import { configState } from "./ConfigurationStateManager";
|
|
6
6
|
import { handleUserSwitch, handleInitialConfiguration, fetchCurrentUserData } from "./userSwitchHandler";
|
|
7
7
|
|
|
8
|
-
export type { InitializerDeps } from "./RevenueCatInitializer.types";
|
|
9
|
-
|
|
10
8
|
const MAX_CONFIG_START_RETRIES = 3;
|
|
11
9
|
|
|
12
10
|
export async function initializeSDK(
|
|
@@ -43,6 +43,15 @@ class UserSwitchMutexImpl {
|
|
|
43
43
|
}
|
|
44
44
|
await new Promise<void>(resolve => setTimeout(() => resolve(), delayNeeded));
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
// Re-check after delay: another caller may have acquired the lock during our wait
|
|
48
|
+
if (this.activeSwitchPromise) {
|
|
49
|
+
if (this.activeUserId === userId) {
|
|
50
|
+
return { shouldProceed: false, existingPromise: this.activeSwitchPromise };
|
|
51
|
+
}
|
|
52
|
+
// Another switch started for a different user — recurse to wait again
|
|
53
|
+
return this.acquire(userId);
|
|
54
|
+
}
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
this.activeUserId = userId;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { initializeSubscription } from "./SubscriptionInitializer";
|
|
2
|
-
export type {
|
|
2
|
+
export type { CreditPackageConfig, SubscriptionInitConfig } from "../SubscriptionInitializerTypes";
|
|
@@ -11,11 +11,10 @@ import {
|
|
|
11
11
|
ActiveStatusHandler
|
|
12
12
|
} from "./SubscriptionStatusHandlers";
|
|
13
13
|
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type
|
|
18
|
-
type SubscriptionStatusType
|
|
14
|
+
export {
|
|
15
|
+
PERIOD_TYPE,
|
|
16
|
+
type PeriodType,
|
|
17
|
+
type SubscriptionStatusType
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
export interface SubscriptionStatus {
|
|
@@ -46,11 +45,6 @@ export const isSubscriptionValid = (status: SubscriptionStatus | null): boolean
|
|
|
46
45
|
return timezoneService.isFuture(new Date(status.expiresAt));
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
export const calculateDaysRemaining = (expiresAt: string | null): number | null => {
|
|
50
|
-
if (!expiresAt) return null;
|
|
51
|
-
return timezoneService.getDaysUntil(new Date(expiresAt));
|
|
52
|
-
};
|
|
53
|
-
|
|
54
48
|
export interface StatusResolverInput {
|
|
55
49
|
isPremium: boolean;
|
|
56
50
|
willRenew?: boolean;
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./SubscriptionConstants";
|
|
6
6
|
import type { StatusResolverInput } from "./SubscriptionStatus";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
abstract class BaseStatusHandler {
|
|
9
9
|
protected next?: BaseStatusHandler;
|
|
10
10
|
|
|
11
11
|
setNext(handler: BaseStatusHandler): BaseStatusHandler {
|
|
@@ -20,7 +20,7 @@ import { creditsQueryKeys } from "../../../credits/presentation/creditsQueryKeys
|
|
|
20
20
|
import { getErrorMessage } from "../../../revenuecat/core/errors";
|
|
21
21
|
|
|
22
22
|
/** Purchase mutation result - simplified for presentation layer */
|
|
23
|
-
|
|
23
|
+
interface PurchaseMutationResult {
|
|
24
24
|
success: boolean;
|
|
25
25
|
productId: string;
|
|
26
26
|
}
|
|
@@ -14,9 +14,8 @@ import {
|
|
|
14
14
|
type TrialEligibilityMap,
|
|
15
15
|
} from "../utils/trialEligibilityUtils";
|
|
16
16
|
|
|
17
|
-
export type { ProductTrialEligibility, TrialEligibilityMap };
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
interface UseRevenueCatTrialEligibilityResult {
|
|
20
19
|
/** Map of product IDs to their trial eligibility */
|
|
21
20
|
eligibilityMap: TrialEligibilityMap;
|
|
22
21
|
/** Whether eligibility check is in progress */
|
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
* Generic hooks for 100+ apps
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export {
|
|
8
|
-
SUBSCRIPTION_QUERY_KEYS,
|
|
9
|
-
} from "./subscriptionQueryKeys";
|
|
10
|
-
export { useInitializeSubscription } from "./useInitializeSubscription";
|
|
11
7
|
export { useSubscriptionPackages } from "./useSubscriptionPackages";
|
|
12
8
|
export { usePurchasePackage } from "./usePurchasePackage";
|
|
13
9
|
export { useRestorePurchase } from "./useRestorePurchase";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "../../../revenuecat/core/types";
|
|
15
15
|
import { notifyRestoreCompleted } from "../utils/PremiumStatusSyncer";
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
interface RestoreHandlerDeps {
|
|
18
18
|
config: RevenueCatConfig;
|
|
19
19
|
isInitialized: () => boolean;
|
|
20
20
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { initializeRevenueCatService, getRevenueCatService, resetRevenueCatService } from "./revenueCatServiceInstance";
|
|
1
|
+
export { initializeRevenueCatService, getRevenueCatService } from "./revenueCatServiceInstance";
|
|
@@ -11,7 +11,3 @@ export const initializeRevenueCatService = (config: RevenueCatConfig): RevenueCa
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const getRevenueCatService = (): RevenueCatService | null => revenueCatServiceInstance;
|
|
14
|
-
|
|
15
|
-
export const resetRevenueCatService = (): void => {
|
|
16
|
-
revenueCatServiceInstance = null;
|
|
17
|
-
};
|
|
@@ -2,7 +2,7 @@ import React, { useMemo } from "react";
|
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
3
|
import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface CreditRowProps {
|
|
6
6
|
label: string;
|
|
7
7
|
current: number;
|
|
8
8
|
total: number;
|
|
@@ -7,7 +7,7 @@ import React from "react";
|
|
|
7
7
|
import { View, StyleSheet, type ViewStyle, type TextStyle } from "react-native";
|
|
8
8
|
import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface DetailRowProps {
|
|
11
11
|
label: string;
|
|
12
12
|
value: string;
|
|
13
13
|
highlight?: boolean;
|
|
@@ -7,8 +7,6 @@ import { FEEDBACK_OPTION_OPACITY } from "./feedbackOptionConstants";
|
|
|
7
7
|
import { FeedbackRadioButton } from "./FeedbackRadioButton";
|
|
8
8
|
import { FeedbackTextInput } from "./FeedbackTextInput";
|
|
9
9
|
|
|
10
|
-
export type { FeedbackOptionProps } from "./FeedbackOption.types";
|
|
11
|
-
|
|
12
10
|
export const FeedbackOption: React.FC<FeedbackOptionProps> = React.memo(({
|
|
13
11
|
isSelected,
|
|
14
12
|
text,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useRef, useEffect, type MutableRefObject } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface FeatureGateRefs {
|
|
4
4
|
creditBalanceRef: MutableRefObject<number>;
|
|
5
5
|
hasSubscriptionRef: MutableRefObject<boolean>;
|
|
6
6
|
onShowPaywallRef: MutableRefObject<(requiredCredits?: number) => void>;
|
|
@@ -8,14 +8,14 @@ import { View, StyleSheet } from "react-native";
|
|
|
8
8
|
import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
|
|
9
9
|
import { CreditRow } from "../../components/details/CreditRow";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
interface CreditItem {
|
|
12
12
|
id: string;
|
|
13
13
|
label: string;
|
|
14
14
|
current: number;
|
|
15
15
|
total: number;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
interface CreditsListProps {
|
|
19
19
|
credits: readonly CreditItem[];
|
|
20
20
|
title?: string;
|
|
21
21
|
description?: string;
|
|
@@ -7,8 +7,6 @@ import { createSubscriptionHeaderStyles } from "./SubscriptionHeader.styles";
|
|
|
7
7
|
import { EXPIRATION_WARNING_THRESHOLD_DAYS as EXPIRING_SOON_THRESHOLD_DAYS } from "../../../constants/thresholds";
|
|
8
8
|
import { SubscriptionHeaderContent } from "./SubscriptionHeaderContent";
|
|
9
9
|
|
|
10
|
-
export type { SubscriptionHeaderProps } from "./SubscriptionHeader.types";
|
|
11
|
-
|
|
12
10
|
export const SubscriptionHeader: React.FC<SubscriptionHeaderProps> = ({
|
|
13
11
|
statusType,
|
|
14
12
|
showExpirationDate,
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import { create } from "zustand";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface PurchaseLoadingState {
|
|
11
11
|
/** Map of product IDs to purchase sources (supports concurrent purchases) */
|
|
12
12
|
activePurchases: Map<string, "manual" | "auto-execution">;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
interface PurchaseLoadingActions {
|
|
16
16
|
/** Start purchase loading state for a product */
|
|
17
17
|
startPurchase: (productId: string, source: "manual" | "auto-execution") => void;
|
|
18
18
|
/** End purchase loading state for a product */
|
|
@@ -23,7 +23,7 @@ export interface PurchaseLoadingActions {
|
|
|
23
23
|
reset: () => void;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
type PurchaseLoadingStore = PurchaseLoadingState & PurchaseLoadingActions;
|
|
27
27
|
|
|
28
28
|
const createInitialState = (): PurchaseLoadingState => ({
|
|
29
29
|
activePurchases: new Map(),
|
|
@@ -61,7 +61,3 @@ export const usePurchaseLoadingStore = create<PurchaseLoadingStore>((set, get) =
|
|
|
61
61
|
|
|
62
62
|
// Selectors for optimized re-renders
|
|
63
63
|
export const selectIsPurchasing = (state: PurchaseLoadingStore) => state.activePurchases.size > 0;
|
|
64
|
-
export const selectIsProductPurchasing = (productId: string) =>
|
|
65
|
-
(state: PurchaseLoadingStore) => state.activePurchases.has(productId);
|
|
66
|
-
export const selectPurchaseSource = (productId: string) =>
|
|
67
|
-
(state: PurchaseLoadingStore) => state.activePurchases.get(productId) ?? null;
|
|
@@ -9,16 +9,10 @@ import { usePremium } from "./usePremium";
|
|
|
9
9
|
import type { PurchaseSource } from "../core/SubscriptionConstants";
|
|
10
10
|
import { authPurchaseStateManager } from "../infrastructure/utils/authPurchaseState";
|
|
11
11
|
|
|
12
|
-
export type { PurchaseAuthProvider } from "../infrastructure/utils/authPurchaseState";
|
|
13
|
-
|
|
14
12
|
export const configureAuthProvider = (provider: import("../infrastructure/utils/authPurchaseState").PurchaseAuthProvider): void => {
|
|
15
13
|
authPurchaseStateManager.configure(provider);
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
export const cleanupAuthProvider = (): void => {
|
|
19
|
-
authPurchaseStateManager.cleanup();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
16
|
export const getSavedPurchase = (): { pkg: PurchasesPackage; source: PurchaseSource } | null => {
|
|
23
17
|
return authPurchaseStateManager.getSavedPurchase();
|
|
24
18
|
};
|
|
@@ -27,11 +21,11 @@ export const clearSavedPurchase = (): void => {
|
|
|
27
21
|
authPurchaseStateManager.clearSavedPurchase();
|
|
28
22
|
};
|
|
29
23
|
|
|
30
|
-
|
|
24
|
+
interface UseAuthAwarePurchaseParams {
|
|
31
25
|
source?: PurchaseSource;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
|
-
|
|
28
|
+
interface UseAuthAwarePurchaseResult {
|
|
35
29
|
handlePurchase: (pkg: PurchasesPackage, source?: PurchaseSource) => Promise<boolean>;
|
|
36
30
|
handleRestore: () => Promise<boolean>;
|
|
37
31
|
executeSavedPurchase: () => Promise<boolean>;
|
|
@@ -4,8 +4,6 @@ import { DEFAULT_REQUIRED_CREDITS, canExecuteAuthAction, canExecutePurchaseActio
|
|
|
4
4
|
import { useSyncedRefs } from "./featureGateRefs";
|
|
5
5
|
import { executeFeatureAction } from "./featureGateActions";
|
|
6
6
|
|
|
7
|
-
export type { UseFeatureGateParams, UseFeatureGateResult } from "./useFeatureGate.types";
|
|
8
|
-
|
|
9
7
|
export function useFeatureGate(params: UseFeatureGateParams): UseFeatureGateResult {
|
|
10
8
|
const {
|
|
11
9
|
isAuthenticated,
|
|
@@ -39,7 +39,7 @@ export const paywallControl = {
|
|
|
39
39
|
getSource: () => paywallState.source,
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
interface UsePaywallVisibilityResult {
|
|
43
43
|
showPaywall: boolean;
|
|
44
44
|
currentSource?: PurchaseSource;
|
|
45
45
|
setShowPaywall: (visible: boolean, source?: PurchaseSource) => void;
|
|
@@ -4,26 +4,3 @@ export function isAuthenticated(userId: string | null | undefined): userId is st
|
|
|
4
4
|
return isDefined(userId) && userId.length > 0;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Requires user to be authenticated, throws if not
|
|
9
|
-
* Type guard that asserts userId is string
|
|
10
|
-
*
|
|
11
|
-
* @param userId - User ID to check
|
|
12
|
-
* @param errorMessage - Custom error message (optional)
|
|
13
|
-
* @throws Error if user is not authenticated
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* function purchaseProduct(userId: string | null) {
|
|
17
|
-
* requireAuthentication(userId); // throws if null/undefined
|
|
18
|
-
* // TypeScript now knows userId is string
|
|
19
|
-
* await purchase(userId);
|
|
20
|
-
* }
|
|
21
|
-
*/
|
|
22
|
-
export function requireAuthentication(
|
|
23
|
-
userId: string | null | undefined,
|
|
24
|
-
errorMessage = "User not authenticated"
|
|
25
|
-
): asserts userId is string {
|
|
26
|
-
if (!isAuthenticated(userId)) {
|
|
27
|
-
throw new Error(errorMessage);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDefined } from "../../../shared/utils/validators";
|
|
2
2
|
import type { UserCredits } from "../../credits/core/Credits";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface SyncState {
|
|
5
5
|
statusLoading: boolean;
|
|
6
6
|
creditsLoading: boolean;
|
|
7
7
|
subscriptionActive: boolean;
|