@umituz/react-native-subscription 2.27.72 → 2.27.73
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/core/Credits.ts +9 -4
- package/src/domains/credits/infrastructure/CreditsRepositoryProvider.ts +9 -15
- package/src/domains/credits/presentation/useDeductCredit.ts +2 -2
- package/src/domains/paywall/components/PaywallContainer.types.ts +1 -1
- package/src/domains/paywall/hooks/usePaywallActions.ts +1 -1
- package/src/domains/subscription/infrastructure/utils/PremiumStatusSyncer.ts +3 -3
- package/src/domains/subscription/presentation/useAuthAwarePurchase.ts +1 -1
- package/src/domains/subscription/presentation/usePaywallVisibility.ts +1 -1
- package/src/domains/subscription/presentation/useSubscriptionSettingsConfig.utils.ts +2 -2
- package/src/index.ts +0 -1
- package/src/shared/application/ActivationHandler.ts +3 -3
- package/src/shared/application/ports/ISubscriptionRepository.ts +1 -1
- package/src/shared/application/ports/ISubscriptionService.ts +1 -1
- package/src/shared/utils/SubscriptionConfig.ts +2 -2
- package/src/utils/aiCreditHelpers.ts +1 -1
- package/src/utils/creditChecker.ts +1 -1
- package/src/utils/creditMapper.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.73",
|
|
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",
|
|
@@ -15,6 +15,15 @@ import type {
|
|
|
15
15
|
PurchaseType
|
|
16
16
|
} from "./SubscriptionConstants";
|
|
17
17
|
|
|
18
|
+
export type {
|
|
19
|
+
SubscriptionStatusType,
|
|
20
|
+
PeriodType,
|
|
21
|
+
PackageType,
|
|
22
|
+
Platform,
|
|
23
|
+
PurchaseSource,
|
|
24
|
+
PurchaseType
|
|
25
|
+
};
|
|
26
|
+
|
|
18
27
|
export type CreditType = "text" | "image";
|
|
19
28
|
|
|
20
29
|
/** Single Source of Truth for user subscription + credits data */
|
|
@@ -91,7 +100,3 @@ export interface DeductCreditsResult {
|
|
|
91
100
|
};
|
|
92
101
|
}
|
|
93
102
|
|
|
94
|
-
export const DEFAULT_CREDITS_CONFIG: CreditsConfig = {
|
|
95
|
-
collectionName: "user_credits",
|
|
96
|
-
creditLimit: 0,
|
|
97
|
-
};
|
|
@@ -4,23 +4,19 @@
|
|
|
4
4
|
* Replaces Context API with a simpler, testable approach
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { CreditsConfig } from "
|
|
8
|
-
import { DEFAULT_CREDITS_CONFIG } from "../../domain/entities/Credits";
|
|
7
|
+
import type { CreditsConfig } from "../core/Credits";
|
|
9
8
|
import type { CreditsRepository } from "./CreditsRepository";
|
|
10
9
|
import { createCreditsRepository } from "./CreditsRepository";
|
|
11
10
|
|
|
12
11
|
let globalRepository: CreditsRepository | null = null;
|
|
13
|
-
let globalConfig: CreditsConfig =
|
|
12
|
+
let globalConfig: CreditsConfig | null = null;
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Configure credits repository for the application
|
|
17
16
|
* Must be called once during app initialization
|
|
18
17
|
*/
|
|
19
|
-
export function configureCreditsRepository(config:
|
|
20
|
-
globalConfig =
|
|
21
|
-
...DEFAULT_CREDITS_CONFIG,
|
|
22
|
-
...config,
|
|
23
|
-
};
|
|
18
|
+
export function configureCreditsRepository(config: CreditsConfig): void {
|
|
19
|
+
globalConfig = config;
|
|
24
20
|
globalRepository = createCreditsRepository(globalConfig);
|
|
25
21
|
}
|
|
26
22
|
|
|
@@ -48,13 +44,11 @@ export function getCreditsRepository(): CreditsRepository {
|
|
|
48
44
|
* Get the current credits configuration
|
|
49
45
|
*/
|
|
50
46
|
export function getCreditsConfig(): CreditsConfig {
|
|
47
|
+
if (!globalConfig) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
"CreditsConfig not configured. Call configureCreditsRepository() first."
|
|
50
|
+
);
|
|
51
|
+
}
|
|
51
52
|
return globalConfig;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
/**
|
|
55
|
-
* Reset repository (for testing)
|
|
56
|
-
*/
|
|
57
|
-
export function resetCreditsRepository(): void {
|
|
58
|
-
globalRepository = null;
|
|
59
|
-
globalConfig = DEFAULT_CREDITS_CONFIG;
|
|
60
|
-
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import { useCallback } from "react";
|
|
7
7
|
import { useMutation, useQueryClient } from "@umituz/react-native-design-system";
|
|
8
|
-
import type { UserCredits } from "
|
|
9
|
-
import { getCreditsRepository } from "
|
|
8
|
+
import type { UserCredits } from "../core/Credits";
|
|
9
|
+
import { getCreditsRepository } from "../infrastructure/CreditsRepositoryProvider";
|
|
10
10
|
import { creditsQueryKeys } from "./useCredits";
|
|
11
11
|
|
|
12
12
|
import { timezoneService } from "@umituz/react-native-design-system";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ImageSourcePropType } from "react-native";
|
|
7
7
|
import type { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "../entities/types";
|
|
8
|
-
import type { PurchaseSource, PackageAllocationMap } from "
|
|
8
|
+
import type { PurchaseSource, PackageAllocationMap } from "../../credits/core/Credits";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Trial display configuration
|
|
@@ -2,7 +2,7 @@ import { useCallback } from "react";
|
|
|
2
2
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
3
3
|
import { useRestorePurchase } from "../../../revenuecat/presentation/hooks/useRestorePurchase";
|
|
4
4
|
import { useAuthAwarePurchase } from "../../../presentation/hooks/useAuthAwarePurchase";
|
|
5
|
-
import type { PurchaseSource } from "
|
|
5
|
+
import type { PurchaseSource } from "../../credits/core/Credits";
|
|
6
6
|
|
|
7
7
|
interface UsePaywallActionsProps {
|
|
8
8
|
source?: PurchaseSource;
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { CustomerInfo } from "react-native-purchases";
|
|
7
|
-
import type { RevenueCatConfig } from "../../
|
|
8
|
-
import type { PurchaseSource } from "../../../
|
|
9
|
-
import { getPremiumEntitlement } from "../../
|
|
7
|
+
import type { RevenueCatConfig } from "../../core/RevenueCatConfig";
|
|
8
|
+
import type { PurchaseSource } from "../../../credits/core/Credits";
|
|
9
|
+
import { getPremiumEntitlement } from "../../core/RevenueCatTypes";
|
|
10
10
|
|
|
11
11
|
export async function syncPremiumStatus(
|
|
12
12
|
config: RevenueCatConfig,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { useCallback } from "react";
|
|
7
7
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
8
8
|
import { usePremium } from "./usePremium";
|
|
9
|
-
import type { PurchaseSource } from "../../
|
|
9
|
+
import type { PurchaseSource } from "../../credits/core/Credits";
|
|
10
10
|
|
|
11
11
|
export interface PurchaseAuthProvider {
|
|
12
12
|
isAuthenticated: () => boolean;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useMemo } from "react";
|
|
7
|
-
import type { UserCredits } from "../../
|
|
8
|
-
import { resolveSubscriptionStatus, type PeriodType, type SubscriptionStatusType } from "
|
|
7
|
+
import type { UserCredits } from "../../credits/core/Credits";
|
|
8
|
+
import { resolveSubscriptionStatus, type PeriodType, type SubscriptionStatusType } from "../core/SubscriptionStatus";
|
|
9
9
|
import type { SubscriptionSettingsTranslations } from "../types/SubscriptionSettingsTypes";
|
|
10
10
|
|
|
11
11
|
export interface CreditsInfo {
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { timezoneService } from "@umituz/react-native-design-system";
|
|
2
|
-
import type { ISubscriptionRepository } from "
|
|
3
|
-
import type { SubscriptionStatus } from "../../
|
|
4
|
-
import { SubscriptionRepositoryError } from "
|
|
2
|
+
import type { ISubscriptionRepository } from "../application/ports/ISubscriptionRepository";
|
|
3
|
+
import type { SubscriptionStatus } from "../../domains/subscription/core/SubscriptionStatus";
|
|
4
|
+
import { SubscriptionRepositoryError } from "../utils/SubscriptionError";
|
|
5
5
|
|
|
6
6
|
export interface ActivationHandlerConfig {
|
|
7
7
|
repository: ISubscriptionRepository;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ISubscriptionRepository Interface
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { SubscriptionStatus } from '
|
|
5
|
+
import { SubscriptionStatus } from '../../../domains/subscription/core/SubscriptionStatus';
|
|
6
6
|
|
|
7
7
|
export interface ISubscriptionRepository {
|
|
8
8
|
getSubscriptionStatus(userId: string): Promise<SubscriptionStatus | null>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Defines the contract for subscription service operations
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { SubscriptionStatus } from '
|
|
6
|
+
import type { SubscriptionStatus } from '../../../domains/subscription/core/SubscriptionStatus';
|
|
7
7
|
|
|
8
8
|
export interface ISubscriptionService {
|
|
9
9
|
/**
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Subscription Config Value Object
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { ISubscriptionRepository } from "
|
|
6
|
-
import { SubscriptionStatus } from "
|
|
5
|
+
import { ISubscriptionRepository } from "../application/ports/ISubscriptionRepository";
|
|
6
|
+
import { SubscriptionStatus } from "../../domains/subscription/core/SubscriptionStatus";
|
|
7
7
|
|
|
8
8
|
export interface SubscriptionConfig {
|
|
9
9
|
repository: ISubscriptionRepository;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* });
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import type { CreditsRepository } from "../infrastructure/
|
|
17
|
+
import type { CreditsRepository } from "../domains/credits/infrastructure/CreditsRepository";
|
|
18
18
|
import { createCreditChecker } from "./creditChecker";
|
|
19
19
|
|
|
20
20
|
export interface AICreditHelpersConfig {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Generic - works with any generation type mapping.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { CreditsRepository } from "../infrastructure/
|
|
8
|
+
import type { CreditsRepository } from "../domains/credits/infrastructure/CreditsRepository";
|
|
9
9
|
|
|
10
10
|
export interface CreditCheckResult {
|
|
11
11
|
success: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { detectPackageType, type SubscriptionPackageType } from "./packageTypeDetector";
|
|
2
|
-
import type { PackageAllocationMap } from "../
|
|
2
|
+
import type { PackageAllocationMap } from "../domains/credits/core/Credits";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Get credit allocation for a package type from provided allocations map
|