@umituz/react-native-subscription 2.12.20 → 2.12.23
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/application/ports/ISubscriptionRepository.ts +1 -1
- package/src/application/ports/ISubscriptionService.ts +1 -1
- package/src/domain/value-objects/SubscriptionConfig.ts +1 -1
- package/src/domains/paywall/components/CreditCard.tsx +2 -2
- package/src/domains/paywall/components/FeatureList.tsx +1 -1
- package/src/domains/paywall/components/PaywallModal.tsx +1 -1
- package/src/domains/paywall/components/PaywallTabBar.tsx +1 -1
- package/src/domains/paywall/components/PlanCard.tsx +1 -1
- package/src/index.ts +54 -54
- package/src/infrastructure/repositories/CreditsRepository.ts +3 -3
- package/src/infrastructure/repositories/CreditsRepositoryProvider.ts +2 -2
- package/src/infrastructure/services/ActivationHandler.ts +3 -3
- package/src/infrastructure/services/CreditsInitializer.ts +1 -1
- package/src/infrastructure/services/SubscriptionService.ts +6 -6
- package/src/presentation/components/details/PremiumStatusBadge.tsx +1 -1
- package/src/presentation/hooks/useCreditChecker.ts +3 -3
- package/src/presentation/hooks/useCredits.ts +2 -2
- package/src/presentation/hooks/useDeductCredit.ts +2 -2
- package/src/presentation/hooks/useDevTestCallbacks.ts +2 -2
- package/src/presentation/hooks/usePremiumWithConfig.ts +2 -2
- package/src/presentation/hooks/useSubscriptionDetails.ts +2 -2
- package/src/revenuecat/infrastructure/handlers/PackageHandler.ts +2 -2
- package/src/revenuecat/infrastructure/managers/SubscriptionManager.ts +7 -7
- package/src/revenuecat/infrastructure/services/CustomerInfoListenerManager.ts +2 -2
- package/src/revenuecat/infrastructure/services/PurchaseHandler.ts +5 -5
- package/src/revenuecat/infrastructure/services/RestoreHandler.ts +5 -5
- package/src/revenuecat/infrastructure/services/RevenueCatInitializer.ts +4 -4
- package/src/revenuecat/infrastructure/services/RevenueCatService.ts +3 -3
- package/src/revenuecat/infrastructure/services/ServiceStateManager.ts +2 -2
- package/src/revenuecat/infrastructure/utils/ApiKeyResolver.ts +1 -1
- package/src/revenuecat/infrastructure/utils/ExpirationDateCalculator.ts +1 -1
- package/src/revenuecat/infrastructure/utils/PremiumStatusSyncer.ts +2 -2
- package/src/revenuecat/presentation/hooks/useInitializeSubscription.ts +1 -1
- package/src/revenuecat/presentation/hooks/usePurchasePackage.ts +1 -1
- package/src/revenuecat/presentation/hooks/useRestorePurchase.ts +1 -1
- package/src/revenuecat/presentation/hooks/useRevenueCat.ts +2 -2
- package/src/revenuecat/presentation/hooks/useSubscriptionPackages.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.23",
|
|
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",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ISubscriptionRepository Interface
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { SubscriptionStatus } from '
|
|
5
|
+
import { SubscriptionStatus } from '../../domain/entities/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 '../../domain/entities/SubscriptionStatus';
|
|
7
7
|
|
|
8
8
|
export interface ISubscriptionService {
|
|
9
9
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Subscription Config Value Object
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { ISubscriptionRepository } from "
|
|
5
|
+
import { ISubscriptionRepository } from "../../application/ports/ISubscriptionRepository";
|
|
6
6
|
import { SubscriptionStatus } from "../entities/SubscriptionStatus";
|
|
7
7
|
|
|
8
8
|
export interface SubscriptionConfig {
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, TouchableOpacity, StyleSheet } from "react-native";
|
|
8
8
|
import { AtomicText, AtomicIcon, AtomicBadge, useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
|
-
import type { CreditsPackage } from "
|
|
9
|
+
import type { CreditsPackage } from "../paywall/entities";
|
|
10
10
|
|
|
11
|
-
import { formatPrice } from "
|
|
11
|
+
import { formatPrice } from "../../utils/priceUtils";
|
|
12
12
|
|
|
13
13
|
interface CreditCardProps {
|
|
14
14
|
pkg: CreditsPackage;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, StyleSheet } from "react-native";
|
|
8
8
|
import { FeatureItem } from "./FeatureItem";
|
|
9
|
-
import type { SubscriptionFeature } from "
|
|
9
|
+
import type { SubscriptionFeature } from "../paywall/entities";
|
|
10
10
|
|
|
11
11
|
interface FeatureListProps {
|
|
12
12
|
features: SubscriptionFeature[];
|
|
@@ -9,7 +9,7 @@ import { BaseModal, useAppDesignTokens, AtomicText, AtomicIcon } from "@umituz/r
|
|
|
9
9
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
10
10
|
import { PlanCard } from "./PlanCard";
|
|
11
11
|
import { CreditCard } from "./CreditCard";
|
|
12
|
-
import type { PaywallMode, CreditsPackage, SubscriptionFeature, PaywallTranslations, PaywallLegalUrls } from "
|
|
12
|
+
import type { PaywallMode, CreditsPackage, SubscriptionFeature, PaywallTranslations, PaywallLegalUrls } from "../paywall/entities";
|
|
13
13
|
|
|
14
14
|
export interface PaywallModalProps {
|
|
15
15
|
visible: boolean;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, TouchableOpacity, StyleSheet, Animated } from "react-native";
|
|
8
8
|
import { AtomicText, useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
|
-
import type { PaywallTabType } from "
|
|
9
|
+
import type { PaywallTabType } from "../paywall/entities";
|
|
10
10
|
|
|
11
11
|
interface PaywallTabBarProps {
|
|
12
12
|
activeTab: PaywallTabType;
|
|
@@ -8,7 +8,7 @@ import { View, TouchableOpacity, StyleSheet } from "react-native";
|
|
|
8
8
|
import { AtomicText, AtomicIcon, AtomicBadge, useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
9
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
10
10
|
|
|
11
|
-
import { formatPrice } from "
|
|
11
|
+
import { formatPrice } from "../../utils/priceUtils";
|
|
12
12
|
|
|
13
13
|
interface PlanCardProps {
|
|
14
14
|
pkg: PurchasesPackage;
|
package/src/index.ts
CHANGED
|
@@ -16,48 +16,48 @@
|
|
|
16
16
|
export {
|
|
17
17
|
createDefaultSubscriptionStatus,
|
|
18
18
|
isSubscriptionValid,
|
|
19
|
-
} from "
|
|
20
|
-
export type { SubscriptionStatus, SubscriptionStatusType } from "
|
|
19
|
+
} from "./domain/entities/SubscriptionStatus";
|
|
20
|
+
export type { SubscriptionStatus, SubscriptionStatusType } from "./domain/entities/SubscriptionStatus";
|
|
21
21
|
|
|
22
|
-
export type { SubscriptionConfig } from "
|
|
22
|
+
export type { SubscriptionConfig } from "./domain/value-objects/SubscriptionConfig";
|
|
23
23
|
|
|
24
|
-
export type { ISubscriptionRepository } from "
|
|
24
|
+
export type { ISubscriptionRepository } from "./application/ports/ISubscriptionRepository";
|
|
25
25
|
|
|
26
26
|
export {
|
|
27
27
|
SubscriptionService,
|
|
28
28
|
initializeSubscriptionService,
|
|
29
|
-
} from "
|
|
29
|
+
} from "./infrastructure/services/SubscriptionService";
|
|
30
30
|
|
|
31
|
-
export { useSubscription } from "
|
|
32
|
-
export type { UseSubscriptionResult } from "
|
|
31
|
+
export { useSubscription } from "./presentation/hooks/useSubscription";
|
|
32
|
+
export type { UseSubscriptionResult } from "./presentation/hooks/useSubscription";
|
|
33
33
|
|
|
34
34
|
export {
|
|
35
35
|
useSubscriptionDetails,
|
|
36
36
|
type SubscriptionDetails,
|
|
37
|
-
} from "
|
|
37
|
+
} from "./presentation/hooks/useSubscriptionDetails";
|
|
38
38
|
|
|
39
39
|
// Feedback
|
|
40
|
-
export * from "
|
|
41
|
-
export * from "
|
|
40
|
+
export * from "./presentation/components/feedback/PaywallFeedbackModal";
|
|
41
|
+
export * from "./presentation/hooks/feedback/usePaywallFeedback";
|
|
42
42
|
|
|
43
43
|
export {
|
|
44
44
|
usePremiumGate,
|
|
45
45
|
type UsePremiumGateParams,
|
|
46
46
|
type UsePremiumGateResult,
|
|
47
|
-
} from "
|
|
47
|
+
} from "./presentation/hooks/usePremiumGate";
|
|
48
48
|
|
|
49
49
|
export {
|
|
50
50
|
useFeatureGate,
|
|
51
51
|
type UseFeatureGateParams,
|
|
52
52
|
type UseFeatureGateResult,
|
|
53
|
-
} from "
|
|
53
|
+
} from "./presentation/hooks/useFeatureGate";
|
|
54
54
|
|
|
55
55
|
export {
|
|
56
56
|
useUserTierWithRepository,
|
|
57
57
|
type UseUserTierWithRepositoryParams,
|
|
58
58
|
type UseUserTierWithRepositoryResult,
|
|
59
59
|
type AuthProvider,
|
|
60
|
-
} from "
|
|
60
|
+
} from "./presentation/hooks/useUserTierWithRepository";
|
|
61
61
|
|
|
62
62
|
// =============================================================================
|
|
63
63
|
// PAYWALL DOMAIN
|
|
@@ -81,7 +81,7 @@ export {
|
|
|
81
81
|
type SubscriptionFeature,
|
|
82
82
|
type PaywallTranslations,
|
|
83
83
|
type PaywallLegalUrls,
|
|
84
|
-
} from "
|
|
84
|
+
} from "./domains/paywall";
|
|
85
85
|
|
|
86
86
|
// =============================================================================
|
|
87
87
|
// PRESENTATION LAYER - Premium Details Components
|
|
@@ -92,12 +92,12 @@ export {
|
|
|
92
92
|
type PremiumDetailsCardProps,
|
|
93
93
|
type PremiumDetailsTranslations,
|
|
94
94
|
type CreditInfo,
|
|
95
|
-
} from "
|
|
95
|
+
} from "./presentation/components/details/PremiumDetailsCard";
|
|
96
96
|
|
|
97
97
|
export {
|
|
98
98
|
PremiumStatusBadge,
|
|
99
99
|
type PremiumStatusBadgeProps,
|
|
100
|
-
} from "
|
|
100
|
+
} from "./presentation/components/details/PremiumStatusBadge";
|
|
101
101
|
|
|
102
102
|
// =============================================================================
|
|
103
103
|
// PRESENTATION LAYER - Settings Section Component
|
|
@@ -107,7 +107,7 @@ export {
|
|
|
107
107
|
SubscriptionSection,
|
|
108
108
|
type SubscriptionSectionProps,
|
|
109
109
|
type SubscriptionSectionConfig,
|
|
110
|
-
} from "
|
|
110
|
+
} from "./presentation/components/sections/SubscriptionSection";
|
|
111
111
|
|
|
112
112
|
// =============================================================================
|
|
113
113
|
// PRESENTATION LAYER - Subscription Detail Screen
|
|
@@ -118,16 +118,16 @@ export {
|
|
|
118
118
|
type SubscriptionDetailScreenProps,
|
|
119
119
|
type SubscriptionDetailConfig,
|
|
120
120
|
type SubscriptionDetailTranslations,
|
|
121
|
-
} from "
|
|
121
|
+
} from "./presentation/screens/SubscriptionDetailScreen";
|
|
122
122
|
|
|
123
|
-
export { type DevTestActions } from "
|
|
123
|
+
export { type DevTestActions } from "./presentation/screens/components/DevTestSection";
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
// =============================================================================
|
|
127
127
|
// UTILS - Date & Price
|
|
128
128
|
// =============================================================================
|
|
129
129
|
|
|
130
|
-
export { formatPrice } from "
|
|
130
|
+
export { formatPrice } from "./utils/priceUtils";
|
|
131
131
|
|
|
132
132
|
// =============================================================================
|
|
133
133
|
// UTILS - User Tier
|
|
@@ -137,24 +137,24 @@ export type {
|
|
|
137
137
|
UserTier,
|
|
138
138
|
UserTierInfo,
|
|
139
139
|
PremiumStatusFetcher,
|
|
140
|
-
} from "
|
|
140
|
+
} from "./utils/types";
|
|
141
141
|
|
|
142
142
|
export {
|
|
143
143
|
getUserTierInfo,
|
|
144
144
|
checkPremiumAccess,
|
|
145
|
-
} from "
|
|
145
|
+
} from "./utils/tierUtils";
|
|
146
146
|
|
|
147
147
|
export {
|
|
148
148
|
hasTierAccess,
|
|
149
149
|
isTierPremium,
|
|
150
150
|
isTierFreemium,
|
|
151
151
|
isTierGuest,
|
|
152
|
-
} from "
|
|
152
|
+
} from "./utils/userTierUtils";
|
|
153
153
|
|
|
154
154
|
export {
|
|
155
155
|
isAuthenticated,
|
|
156
156
|
isGuest,
|
|
157
|
-
} from "
|
|
157
|
+
} from "./utils/authUtils";
|
|
158
158
|
|
|
159
159
|
export {
|
|
160
160
|
isValidUserTier,
|
|
@@ -163,7 +163,7 @@ export {
|
|
|
163
163
|
validateIsGuest,
|
|
164
164
|
validateIsPremium,
|
|
165
165
|
validateFetcher,
|
|
166
|
-
} from "
|
|
166
|
+
} from "./utils/validation";
|
|
167
167
|
|
|
168
168
|
// =============================================================================
|
|
169
169
|
// CREDITS SYSTEM - Domain Entities
|
|
@@ -175,9 +175,9 @@ export type {
|
|
|
175
175
|
CreditsConfig,
|
|
176
176
|
CreditsResult,
|
|
177
177
|
DeductCreditsResult,
|
|
178
|
-
} from "
|
|
178
|
+
} from "./domain/entities/Credits";
|
|
179
179
|
|
|
180
|
-
export { DEFAULT_CREDITS_CONFIG } from "
|
|
180
|
+
export { DEFAULT_CREDITS_CONFIG } from "./domain/entities/Credits";
|
|
181
181
|
|
|
182
182
|
// =============================================================================
|
|
183
183
|
// CREDITS SYSTEM - Repository
|
|
@@ -186,7 +186,7 @@ export { DEFAULT_CREDITS_CONFIG } from "@domain/entities/Credits";
|
|
|
186
186
|
export {
|
|
187
187
|
CreditsRepository,
|
|
188
188
|
createCreditsRepository,
|
|
189
|
-
} from "
|
|
189
|
+
} from "./infrastructure/repositories/CreditsRepository";
|
|
190
190
|
|
|
191
191
|
// =============================================================================
|
|
192
192
|
// CREDITS SYSTEM - Configuration (Module-Level Provider)
|
|
@@ -197,7 +197,7 @@ export {
|
|
|
197
197
|
getCreditsRepository,
|
|
198
198
|
getCreditsConfig,
|
|
199
199
|
resetCreditsRepository,
|
|
200
|
-
} from "
|
|
200
|
+
} from "./infrastructure/repositories/CreditsRepositoryProvider";
|
|
201
201
|
|
|
202
202
|
// =============================================================================
|
|
203
203
|
// CREDITS SYSTEM - Hooks
|
|
@@ -209,7 +209,7 @@ export {
|
|
|
209
209
|
creditsQueryKeys,
|
|
210
210
|
type UseCreditsParams,
|
|
211
211
|
type UseCreditsResult,
|
|
212
|
-
} from "
|
|
212
|
+
} from "./presentation/hooks/useCredits";
|
|
213
213
|
|
|
214
214
|
export {
|
|
215
215
|
useDeductCredit,
|
|
@@ -219,37 +219,37 @@ export {
|
|
|
219
219
|
type UseInitializeCreditsParams,
|
|
220
220
|
type UseInitializeCreditsResult,
|
|
221
221
|
type InitializeCreditsOptions,
|
|
222
|
-
} from "
|
|
222
|
+
} from "./presentation/hooks/useDeductCredit";
|
|
223
223
|
|
|
224
224
|
export {
|
|
225
225
|
usePremiumWithCredits,
|
|
226
226
|
type UsePremiumWithCreditsParams,
|
|
227
227
|
type UsePremiumWithCreditsResult,
|
|
228
|
-
} from "
|
|
228
|
+
} from "./presentation/hooks/usePremiumWithCredits";
|
|
229
229
|
|
|
230
230
|
export {
|
|
231
231
|
useCreditChecker,
|
|
232
232
|
type UseCreditCheckerParams,
|
|
233
233
|
type UseCreditCheckerResult,
|
|
234
|
-
} from "
|
|
234
|
+
} from "./presentation/hooks/useCreditChecker";
|
|
235
235
|
|
|
236
236
|
export {
|
|
237
237
|
usePaywallVisibility,
|
|
238
238
|
type UsePaywallVisibilityResult,
|
|
239
|
-
} from "
|
|
239
|
+
} from "./presentation/hooks/usePaywallVisibility";
|
|
240
240
|
|
|
241
241
|
export {
|
|
242
242
|
usePremiumWithConfig,
|
|
243
243
|
type UsePremiumWithConfigParams,
|
|
244
244
|
type UsePremiumWithConfigResult,
|
|
245
|
-
} from "
|
|
245
|
+
} from "./presentation/hooks/usePremiumWithConfig";
|
|
246
246
|
|
|
247
247
|
export {
|
|
248
248
|
useAuthSubscriptionSync,
|
|
249
249
|
type AuthSubscriptionSyncConfig,
|
|
250
|
-
} from "
|
|
250
|
+
} from "./presentation/hooks/useAuthSubscriptionSync";
|
|
251
251
|
|
|
252
|
-
export { useDevTestCallbacks } from "
|
|
252
|
+
export { useDevTestCallbacks } from "./presentation/hooks/useDevTestCallbacks";
|
|
253
253
|
|
|
254
254
|
// =============================================================================
|
|
255
255
|
// CREDITS SYSTEM - Utilities
|
|
@@ -260,18 +260,18 @@ export {
|
|
|
260
260
|
type CreditCheckResult,
|
|
261
261
|
type CreditCheckerConfig,
|
|
262
262
|
type CreditChecker,
|
|
263
|
-
} from "
|
|
263
|
+
} from "./utils/creditChecker";
|
|
264
264
|
|
|
265
265
|
export {
|
|
266
266
|
createAICreditHelpers,
|
|
267
267
|
type AICreditHelpersConfig,
|
|
268
268
|
type AICreditHelpers,
|
|
269
|
-
} from "
|
|
269
|
+
} from "./utils/aiCreditHelpers";
|
|
270
270
|
|
|
271
271
|
export {
|
|
272
272
|
detectPackageType,
|
|
273
273
|
type SubscriptionPackageType,
|
|
274
|
-
} from "
|
|
274
|
+
} from "./utils/packageTypeDetector";
|
|
275
275
|
|
|
276
276
|
export {
|
|
277
277
|
getCreditAllocation,
|
|
@@ -279,7 +279,7 @@ export {
|
|
|
279
279
|
getTextCreditsForPackage,
|
|
280
280
|
CREDIT_ALLOCATIONS,
|
|
281
281
|
type CreditAllocation,
|
|
282
|
-
} from "
|
|
282
|
+
} from "./utils/creditMapper";
|
|
283
283
|
|
|
284
284
|
// =============================================================================
|
|
285
285
|
// REVENUECAT - Errors
|
|
@@ -293,26 +293,26 @@ export {
|
|
|
293
293
|
RevenueCatRestoreError,
|
|
294
294
|
RevenueCatNetworkError,
|
|
295
295
|
RevenueCatExpoGoError,
|
|
296
|
-
} from "
|
|
296
|
+
} from "./revenuecat/domain/errors/RevenueCatError";
|
|
297
297
|
|
|
298
298
|
// =============================================================================
|
|
299
299
|
// REVENUECAT - Types & Config
|
|
300
300
|
// =============================================================================
|
|
301
301
|
|
|
302
|
-
export type { RevenueCatConfig } from "
|
|
302
|
+
export type { RevenueCatConfig } from "./revenuecat/domain/value-objects/RevenueCatConfig";
|
|
303
303
|
|
|
304
304
|
export type {
|
|
305
305
|
RevenueCatEntitlement,
|
|
306
306
|
RevenueCatPurchaseErrorInfo,
|
|
307
|
-
} from "
|
|
307
|
+
} from "./revenuecat/domain/types/RevenueCatTypes";
|
|
308
308
|
|
|
309
|
-
export { REVENUECAT_LOG_PREFIX } from "
|
|
309
|
+
export { REVENUECAT_LOG_PREFIX } from "./revenuecat/domain/constants/RevenueCatConstants";
|
|
310
310
|
|
|
311
311
|
export {
|
|
312
312
|
getPremiumEntitlement,
|
|
313
313
|
isUserCancelledError,
|
|
314
314
|
getErrorMessage,
|
|
315
|
-
} from "
|
|
315
|
+
} from "./revenuecat/domain/types/RevenueCatTypes";
|
|
316
316
|
|
|
317
317
|
// =============================================================================
|
|
318
318
|
// REVENUECAT - Ports
|
|
@@ -323,7 +323,7 @@ export type {
|
|
|
323
323
|
InitializeResult,
|
|
324
324
|
PurchaseResult,
|
|
325
325
|
RestoreResult,
|
|
326
|
-
} from "
|
|
326
|
+
} from "./revenuecat/application/ports/IRevenueCatService";
|
|
327
327
|
|
|
328
328
|
// =============================================================================
|
|
329
329
|
// REVENUECAT - Service
|
|
@@ -334,23 +334,23 @@ export {
|
|
|
334
334
|
initializeRevenueCatService,
|
|
335
335
|
getRevenueCatService,
|
|
336
336
|
resetRevenueCatService,
|
|
337
|
-
} from "
|
|
337
|
+
} from "./revenuecat/infrastructure/services/RevenueCatService";
|
|
338
338
|
|
|
339
339
|
export {
|
|
340
340
|
SubscriptionManager,
|
|
341
341
|
type SubscriptionManagerConfig,
|
|
342
342
|
type PremiumStatus,
|
|
343
|
-
} from "
|
|
343
|
+
} from "./revenuecat/infrastructure/managers/SubscriptionManager";
|
|
344
344
|
|
|
345
345
|
// =============================================================================
|
|
346
346
|
// REVENUECAT - Hooks
|
|
347
347
|
// =============================================================================
|
|
348
348
|
|
|
349
|
-
export { useRevenueCat } from "
|
|
350
|
-
export type { UseRevenueCatResult } from "
|
|
349
|
+
export { useRevenueCat } from "./revenuecat/presentation/hooks/useRevenueCat";
|
|
350
|
+
export type { UseRevenueCatResult } from "./revenuecat/presentation/hooks/useRevenueCat";
|
|
351
351
|
|
|
352
|
-
export { useCustomerInfo } from "
|
|
353
|
-
export type { UseCustomerInfoResult } from "
|
|
352
|
+
export { useCustomerInfo } from "./revenuecat/presentation/hooks/useCustomerInfo";
|
|
353
|
+
export type { UseCustomerInfoResult } from "./revenuecat/presentation/hooks/useCustomerInfo";
|
|
354
354
|
|
|
355
355
|
export {
|
|
356
356
|
useInitializeSubscription,
|
|
@@ -358,4 +358,4 @@ export {
|
|
|
358
358
|
usePurchasePackage,
|
|
359
359
|
useRestorePurchase,
|
|
360
360
|
SUBSCRIPTION_QUERY_KEYS,
|
|
361
|
-
} from "
|
|
361
|
+
} from "./revenuecat/presentation/hooks/useSubscriptionQueries";
|
|
@@ -20,11 +20,11 @@ import type {
|
|
|
20
20
|
CreditsConfig,
|
|
21
21
|
CreditsResult,
|
|
22
22
|
DeductCreditsResult,
|
|
23
|
-
} from "
|
|
23
|
+
} from "../../domain/entities/Credits";
|
|
24
24
|
import type { UserCreditsDocumentRead } from "../models/UserCreditsDocument";
|
|
25
25
|
import { initializeCreditsTransaction } from "../services/CreditsInitializer";
|
|
26
|
-
import { detectPackageType } from "
|
|
27
|
-
import { getCreditAllocation } from "
|
|
26
|
+
import { detectPackageType } from "../../utils/packageTypeDetector";
|
|
27
|
+
import { getCreditAllocation } from "../../utils/creditMapper";
|
|
28
28
|
|
|
29
29
|
export class CreditsRepository extends BaseRepository {
|
|
30
30
|
private config: CreditsConfig;
|
|
@@ -4,8 +4,8 @@
|
|
|
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 "
|
|
7
|
+
import type { CreditsConfig } from "../../domain/entities/Credits";
|
|
8
|
+
import { DEFAULT_CREDITS_CONFIG } from "../../domain/entities/Credits";
|
|
9
9
|
import type { CreditsRepository } from "./CreditsRepository";
|
|
10
10
|
import { createCreditsRepository } from "./CreditsRepository";
|
|
11
11
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Handles subscription activation and deactivation
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ISubscriptionRepository } from "
|
|
7
|
-
import type { SubscriptionStatus } from "
|
|
8
|
-
import { SubscriptionRepositoryError } from "
|
|
6
|
+
import type { ISubscriptionRepository } from "../../application/ports/ISubscriptionRepository";
|
|
7
|
+
import type { SubscriptionStatus } from "../../domain/entities/SubscriptionStatus";
|
|
8
|
+
import { SubscriptionRepositoryError } from "../../domain/errors/SubscriptionError";
|
|
9
9
|
|
|
10
10
|
export interface ActivationHandlerConfig {
|
|
11
11
|
repository: ISubscriptionRepository;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type Transaction,
|
|
8
8
|
type DocumentReference,
|
|
9
9
|
} from "firebase/firestore";
|
|
10
|
-
import type { CreditsConfig } from "
|
|
10
|
+
import type { CreditsConfig } from "../../domain/entities/Credits";
|
|
11
11
|
import type { UserCreditsDocumentRead } from "../models/UserCreditsDocument";
|
|
12
12
|
|
|
13
13
|
interface InitializationResult {
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* Database-first subscription management
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ISubscriptionService } from "
|
|
7
|
-
import type { ISubscriptionRepository } from "
|
|
8
|
-
import type { SubscriptionStatus } from "
|
|
9
|
-
import { createDefaultSubscriptionStatus } from "
|
|
6
|
+
import type { ISubscriptionService } from "../../application/ports/ISubscriptionService";
|
|
7
|
+
import type { ISubscriptionRepository } from "../../application/ports/ISubscriptionRepository";
|
|
8
|
+
import type { SubscriptionStatus } from "../../domain/entities/SubscriptionStatus";
|
|
9
|
+
import { createDefaultSubscriptionStatus } from "../../domain/entities/SubscriptionStatus";
|
|
10
10
|
import {
|
|
11
11
|
SubscriptionRepositoryError,
|
|
12
12
|
SubscriptionValidationError,
|
|
13
|
-
} from "
|
|
14
|
-
import type { SubscriptionConfig } from "
|
|
13
|
+
} from "../../domain/errors/SubscriptionError";
|
|
14
|
+
import type { SubscriptionConfig } from "../../domain/value-objects/SubscriptionConfig";
|
|
15
15
|
import {
|
|
16
16
|
activateSubscription,
|
|
17
17
|
deactivateSubscription,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, StyleSheet } from "react-native";
|
|
8
8
|
import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
|
|
9
|
-
import { SubscriptionStatusType } from "
|
|
9
|
+
import { SubscriptionStatusType } from "../../domain/entities/SubscriptionStatus";
|
|
10
10
|
export type { SubscriptionStatusType };
|
|
11
11
|
|
|
12
12
|
export interface PremiumStatusBadgeProps {
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { useMemo } from "react";
|
|
8
|
-
import type { CreditType } from "
|
|
9
|
-
import { getCreditsRepository } from "
|
|
8
|
+
import type { CreditType } from "../../domain/entities/Credits";
|
|
9
|
+
import { getCreditsRepository } from "../../infrastructure/repositories/CreditsRepositoryProvider";
|
|
10
10
|
import {
|
|
11
11
|
createCreditChecker,
|
|
12
12
|
type CreditCheckResult,
|
|
13
|
-
} from "
|
|
13
|
+
} from "../../utils/creditChecker";
|
|
14
14
|
|
|
15
15
|
export interface UseCreditCheckerParams {
|
|
16
16
|
getCreditType: (operationType: string) => CreditType;
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { useQuery } from "@tanstack/react-query";
|
|
9
|
-
import type { UserCredits, CreditType } from "
|
|
9
|
+
import type { UserCredits, CreditType } from "../../domain/entities/Credits";
|
|
10
10
|
import {
|
|
11
11
|
getCreditsRepository,
|
|
12
12
|
getCreditsConfig,
|
|
13
|
-
} from "
|
|
13
|
+
} from "../../infrastructure/repositories/CreditsRepositoryProvider";
|
|
14
14
|
|
|
15
15
|
const CACHE_CONFIG = {
|
|
16
16
|
staleTime: 30 * 1000,
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import { useCallback } from "react";
|
|
9
9
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
10
|
-
import type { CreditType, UserCredits } from "
|
|
11
|
-
import { getCreditsRepository } from "
|
|
10
|
+
import type { CreditType, UserCredits } from "../../domain/entities/Credits";
|
|
11
|
+
import { getCreditsRepository } from "../../infrastructure/repositories/CreditsRepositoryProvider";
|
|
12
12
|
import { creditsQueryKeys } from "./useCredits";
|
|
13
13
|
|
|
14
14
|
export interface UseDeductCreditParams {
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import { useCallback } from "react";
|
|
8
8
|
import { Alert } from "react-native";
|
|
9
9
|
import { useAuth } from "@umituz/react-native-auth";
|
|
10
|
-
import { getCreditsRepository } from "
|
|
10
|
+
import { getCreditsRepository } from "../../infrastructure/repositories/CreditsRepositoryProvider";
|
|
11
11
|
import { useCredits } from "./useCredits";
|
|
12
|
-
import type { DevTestActions } from "
|
|
12
|
+
import type { DevTestActions } from "../screens/components/DevTestSection";
|
|
13
13
|
|
|
14
14
|
export const useDevTestCallbacks = (): DevTestActions | undefined => {
|
|
15
15
|
const { user } = useAuth();
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
import { useCallback } from "react";
|
|
13
13
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
14
|
-
import type { UserCredits } from "
|
|
14
|
+
import type { UserCredits } from "../../domain/entities/Credits";
|
|
15
15
|
import { useCredits } from "./useCredits";
|
|
16
16
|
import {
|
|
17
17
|
useSubscriptionPackages,
|
|
18
18
|
usePurchasePackage,
|
|
19
19
|
useRestorePurchase,
|
|
20
|
-
} from "
|
|
20
|
+
} from "../../revenuecat/presentation/hooks/useSubscriptionQueries";
|
|
21
21
|
import { usePaywallVisibility } from "./usePaywallVisibility";
|
|
22
22
|
|
|
23
23
|
export interface UsePremiumWithConfigParams {
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useMemo } from "react";
|
|
7
|
-
import type { SubscriptionStatus } from "
|
|
7
|
+
import type { SubscriptionStatus } from "../../domain/entities/SubscriptionStatus";
|
|
8
8
|
import {
|
|
9
9
|
getDaysUntilExpiration,
|
|
10
10
|
isSubscriptionExpired,
|
|
11
|
-
} from "
|
|
11
|
+
} from "../../utils/dateValidationUtils";
|
|
12
12
|
|
|
13
13
|
export interface SubscriptionDetails {
|
|
14
14
|
/** Raw subscription status */
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
7
|
-
import type { IRevenueCatService } from "
|
|
8
|
-
import { getPremiumEntitlement } from "
|
|
7
|
+
import type { IRevenueCatService } from "../application/ports/IRevenueCatService";
|
|
8
|
+
import { getPremiumEntitlement } from "../domain/types/RevenueCatTypes";
|
|
9
9
|
import {
|
|
10
10
|
trackPackageError,
|
|
11
11
|
addPackageBreadcrumb,
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
8
|
-
import type { RevenueCatConfig } from "
|
|
9
|
-
import type { IRevenueCatService } from "
|
|
10
|
-
import { initializeRevenueCatService, getRevenueCatService } from "
|
|
11
|
-
import { UserIdProvider } from "
|
|
12
|
-
import { InitializationCache } from "
|
|
13
|
-
import { PackageHandler } from "
|
|
14
|
-
import type { PremiumStatus } from "
|
|
8
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
9
|
+
import type { IRevenueCatService } from "../application/ports/IRevenueCatService";
|
|
10
|
+
import { initializeRevenueCatService, getRevenueCatService } from "../infrastructure/services/RevenueCatService";
|
|
11
|
+
import { UserIdProvider } from "../infrastructure/utils/UserIdProvider";
|
|
12
|
+
import { InitializationCache } from "../infrastructure/utils/InitializationCache";
|
|
13
|
+
import { PackageHandler } from "../infrastructure/handlers/PackageHandler";
|
|
14
|
+
import type { PremiumStatus } from "../infrastructure/handlers/PackageHandler";
|
|
15
15
|
import {
|
|
16
16
|
trackPackageError,
|
|
17
17
|
addPackageBreadcrumb,
|
|
@@ -7,8 +7,8 @@ import Purchases, {
|
|
|
7
7
|
type CustomerInfo,
|
|
8
8
|
type CustomerInfoUpdateListener,
|
|
9
9
|
} from "react-native-purchases";
|
|
10
|
-
import type { RevenueCatConfig } from "
|
|
11
|
-
import { syncPremiumStatus } from "
|
|
10
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
11
|
+
import { syncPremiumStatus } from "../infrastructure/utils/PremiumStatusSyncer";
|
|
12
12
|
import { addPackageBreadcrumb } from "@umituz/react-native-sentry";
|
|
13
13
|
|
|
14
14
|
export class CustomerInfoListenerManager {
|
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import Purchases, { type PurchasesPackage } from "react-native-purchases";
|
|
7
|
-
import type { PurchaseResult } from "
|
|
7
|
+
import type { PurchaseResult } from "../application/ports/IRevenueCatService";
|
|
8
8
|
import {
|
|
9
9
|
RevenueCatPurchaseError,
|
|
10
10
|
RevenueCatInitializationError,
|
|
11
|
-
} from "
|
|
12
|
-
import type { RevenueCatConfig } from "
|
|
11
|
+
} from "../domain/errors/RevenueCatError";
|
|
12
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
13
13
|
import {
|
|
14
14
|
isUserCancelledError,
|
|
15
15
|
getErrorMessage,
|
|
16
|
-
} from "
|
|
16
|
+
} from "../domain/types/RevenueCatTypes";
|
|
17
17
|
import {
|
|
18
18
|
syncPremiumStatus,
|
|
19
19
|
notifyPurchaseCompleted,
|
|
20
|
-
} from "
|
|
20
|
+
} from "../infrastructure/utils/PremiumStatusSyncer";
|
|
21
21
|
import {
|
|
22
22
|
trackPackageError,
|
|
23
23
|
addPackageBreadcrumb,
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import Purchases from "react-native-purchases";
|
|
7
|
-
import type { RestoreResult } from "
|
|
7
|
+
import type { RestoreResult } from "../application/ports/IRevenueCatService";
|
|
8
8
|
import {
|
|
9
9
|
RevenueCatRestoreError,
|
|
10
10
|
RevenueCatInitializationError,
|
|
11
|
-
} from "
|
|
12
|
-
import type { RevenueCatConfig } from "
|
|
13
|
-
import { getErrorMessage } from "
|
|
11
|
+
} from "../domain/errors/RevenueCatError";
|
|
12
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
13
|
+
import { getErrorMessage } from "../domain/types/RevenueCatTypes";
|
|
14
14
|
import {
|
|
15
15
|
syncPremiumStatus,
|
|
16
16
|
notifyRestoreCompleted,
|
|
17
|
-
} from "
|
|
17
|
+
} from "../infrastructure/utils/PremiumStatusSyncer";
|
|
18
18
|
import {
|
|
19
19
|
trackPackageError,
|
|
20
20
|
addPackageBreadcrumb,
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import Purchases from "react-native-purchases";
|
|
7
|
-
import type { InitializeResult } from "
|
|
8
|
-
import type { RevenueCatConfig } from "
|
|
9
|
-
import { getErrorMessage } from "
|
|
10
|
-
import { resolveApiKey } from "
|
|
7
|
+
import type { InitializeResult } from "../application/ports/IRevenueCatService";
|
|
8
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
9
|
+
import { getErrorMessage } from "../domain/types/RevenueCatTypes";
|
|
10
|
+
import { resolveApiKey } from "../infrastructure/utils/ApiKeyResolver";
|
|
11
11
|
import {
|
|
12
12
|
trackPackageError,
|
|
13
13
|
addPackageBreadcrumb,
|
|
@@ -10,9 +10,9 @@ import type {
|
|
|
10
10
|
InitializeResult,
|
|
11
11
|
PurchaseResult,
|
|
12
12
|
RestoreResult,
|
|
13
|
-
} from "
|
|
14
|
-
import type { RevenueCatConfig } from "
|
|
15
|
-
import { resolveApiKey } from "
|
|
13
|
+
} from "../application/ports/IRevenueCatService";
|
|
14
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
15
|
+
import { resolveApiKey } from "../infrastructure/utils/ApiKeyResolver";
|
|
16
16
|
import { initializeSDK } from "./RevenueCatInitializer";
|
|
17
17
|
import { fetchOfferings } from "./OfferingsFetcher";
|
|
18
18
|
import { handlePurchase } from "./PurchaseHandler";
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Manages RevenueCat service state
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { RevenueCatConfig } from "
|
|
7
|
-
import { isExpoGo, isDevelopment } from "
|
|
6
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
7
|
+
import { isExpoGo, isDevelopment } from "../infrastructure/utils/ExpoGoDetector";
|
|
8
8
|
|
|
9
9
|
export class ServiceStateManager {
|
|
10
10
|
private isInitializedFlag: boolean = false;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* NOTE: Main app is responsible for resolving platform-specific keys
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { RevenueCatConfig } from "
|
|
7
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
8
8
|
import { isTestStoreEnvironment } from "./ExpoGoDetector";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Handles RevenueCat expiration date extraction
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { RevenueCatEntitlement } from "
|
|
6
|
+
import type { RevenueCatEntitlement } from "../domain/types/RevenueCatTypes";
|
|
7
7
|
|
|
8
8
|
export function getExpirationDate(
|
|
9
9
|
entitlement: RevenueCatEntitlement | null
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { CustomerInfo } from "react-native-purchases";
|
|
7
|
-
import type { RevenueCatConfig } from "
|
|
8
|
-
import { getPremiumEntitlement } from "
|
|
7
|
+
import type { RevenueCatConfig } from "../domain/value-objects/RevenueCatConfig";
|
|
8
|
+
import { getPremiumEntitlement } from "../domain/types/RevenueCatTypes";
|
|
9
9
|
import { getExpirationDate } from "./ExpirationDateCalculator";
|
|
10
10
|
import {
|
|
11
11
|
trackPackageError,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
7
|
-
import { SubscriptionManager } from "
|
|
7
|
+
import { SubscriptionManager } from "../infrastructure/managers/SubscriptionManager";
|
|
8
8
|
import {
|
|
9
9
|
trackPackageError,
|
|
10
10
|
addPackageBreadcrumb,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
7
7
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
8
|
-
import { SubscriptionManager } from "
|
|
8
|
+
import { SubscriptionManager } from "../infrastructure/managers/SubscriptionManager";
|
|
9
9
|
import {
|
|
10
10
|
trackPackageError,
|
|
11
11
|
addPackageBreadcrumb,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
7
|
-
import { SubscriptionManager } from "
|
|
7
|
+
import { SubscriptionManager } from "../infrastructure/managers/SubscriptionManager";
|
|
8
8
|
import {
|
|
9
9
|
trackPackageError,
|
|
10
10
|
addPackageBreadcrumb,
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import { useState, useCallback } from "react";
|
|
7
7
|
import type { PurchasesOffering, PurchasesPackage } from "react-native-purchases";
|
|
8
|
-
import { getRevenueCatService } from "
|
|
9
|
-
import type { PurchaseResult, RestoreResult } from "
|
|
8
|
+
import { getRevenueCatService } from "../infrastructure/services/RevenueCatService";
|
|
9
|
+
import type { PurchaseResult, RestoreResult } from "../application/ports/IRevenueCatService";
|
|
10
10
|
|
|
11
11
|
export interface UseRevenueCatResult {
|
|
12
12
|
/** Current offering */
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useQuery } from "@tanstack/react-query";
|
|
7
|
-
import { SubscriptionManager } from "
|
|
7
|
+
import { SubscriptionManager } from "../infrastructure/managers/SubscriptionManager";
|
|
8
8
|
import { addPackageBreadcrumb } from "@umituz/react-native-sentry";
|
|
9
9
|
import {
|
|
10
10
|
SUBSCRIPTION_QUERY_KEYS,
|