@umituz/react-native-subscription 2.43.3 → 2.43.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-subscription",
3
- "version": "2.43.3",
3
+ "version": "2.43.4",
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",
@@ -6,8 +6,10 @@ import {
6
6
  selectUserId,
7
7
  } from "@umituz/react-native-auth";
8
8
  import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
9
+ import { subscriptionStatusQueryKeys } from "../../presentation/useSubscriptionStatus";
10
+ import { creditsQueryKeys } from "../../../credits/presentation/creditsQueryKeys";
11
+ import { SUBSCRIPTION_QUERY_KEYS } from "./subscriptionQueryKeys";
9
12
  import { getErrorMessage } from "../../../revenuecat/core/errors/RevenueCatErrorHandler";
10
- import { invalidateSubscriptionCaches } from "../../../../shared/infrastructure/react-query/utils";
11
13
 
12
14
  interface PurchaseMutationResult {
13
15
  success: boolean;
@@ -37,7 +39,13 @@ export const usePurchasePackage = () => {
37
39
  onSuccess: (result) => {
38
40
  if (result.success) {
39
41
  showSuccess("Purchase Successful", "Your subscription is now active!");
40
- invalidateSubscriptionCaches(queryClient, userId);
42
+
43
+ // Invalidate caches after successful purchase
44
+ queryClient.invalidateQueries({ queryKey: SUBSCRIPTION_QUERY_KEYS.packages });
45
+ if (userId) {
46
+ queryClient.invalidateQueries({ queryKey: subscriptionStatusQueryKeys.user(userId) });
47
+ queryClient.invalidateQueries({ queryKey: creditsQueryKeys.user(userId) });
48
+ }
41
49
  } else {
42
50
  showError("Purchase Failed", "Unable to complete purchase. Please try again.");
43
51
  }
@@ -5,8 +5,10 @@ import {
5
5
  selectUserId,
6
6
  } from "@umituz/react-native-auth";
7
7
  import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
8
+ import { subscriptionStatusQueryKeys } from "../../presentation/useSubscriptionStatus";
9
+ import { creditsQueryKeys } from "../../../credits/presentation/creditsQueryKeys";
10
+ import { SUBSCRIPTION_QUERY_KEYS } from "./subscriptionQueryKeys";
8
11
  import { getErrorMessage } from "../../../revenuecat/core/errors/RevenueCatErrorHandler";
9
- import { invalidateSubscriptionCaches } from "../../../../shared/infrastructure/react-query/utils";
10
12
 
11
13
  interface RestoreResult {
12
14
  success: boolean;
@@ -29,7 +31,12 @@ export const useRestorePurchase = () => {
29
31
  },
30
32
  onSuccess: (result) => {
31
33
  if (result.success) {
32
- invalidateSubscriptionCaches(queryClient, userId);
34
+ // Invalidate caches after successful restore
35
+ queryClient.invalidateQueries({ queryKey: SUBSCRIPTION_QUERY_KEYS.packages });
36
+ if (userId) {
37
+ queryClient.invalidateQueries({ queryKey: subscriptionStatusQueryKeys.user(userId) });
38
+ queryClient.invalidateQueries({ queryKey: creditsQueryKeys.user(userId) });
39
+ }
33
40
 
34
41
  if (result.productId) {
35
42
  showSuccess("Restore Successful", "Your subscription has been restored!");
package/src/index.ts CHANGED
@@ -51,14 +51,6 @@ export {
51
51
  } from "./shared/utils/Result";
52
52
  export type { Result, Success, Failure } from "./shared/utils/Result";
53
53
 
54
- // Cache Invalidation Utilities
55
- export {
56
- invalidateSubscriptionCaches,
57
- invalidateSubscriptionStatus,
58
- invalidateCredits,
59
- invalidateAllUserData,
60
- } from "./shared/infrastructure/react-query/utils";
61
-
62
54
  // Infrastructure Layer (Services & Repositories)
63
55
  export { initializeSubscription } from "./domains/subscription/application/initializer/SubscriptionInitializer";
64
56
  export type { SubscriptionInitConfig, CreditPackageConfig } from "./domains/subscription/application/SubscriptionInitializerTypes";
@@ -1,97 +0,0 @@
1
- import type { QueryClient } from "@tanstack/react-query";
2
- import { SUBSCRIPTION_QUERY_KEYS } from "../../../../domains/subscription/infrastructure/hooks/subscriptionQueryKeys";
3
- import { subscriptionStatusQueryKeys } from "../../../../domains/subscription/presentation/useSubscriptionStatus";
4
- import { creditsQueryKeys } from "../../../../domains/credits/presentation/creditsQueryKeys";
5
-
6
- /**
7
- * Centralized cache invalidation utilities for subscription-related queries.
8
- * This ensures consistent cache invalidation across all mutations and removes code duplication.
9
- */
10
-
11
- /**
12
- * Invalidate all subscription-related caches for a specific user.
13
- * This includes:
14
- * - Subscription packages
15
- * - Subscription status
16
- * - Credits
17
- *
18
- * @param queryClient - TanStack Query client instance
19
- * @param userId - User ID to invalidate caches for
20
- */
21
- export function invalidateSubscriptionCaches(
22
- queryClient: QueryClient,
23
- userId: string | null | undefined
24
- ): void {
25
- if (!userId) {
26
- return;
27
- }
28
-
29
- // Invalidate packages (global, not user-specific)
30
- queryClient.invalidateQueries({
31
- queryKey: SUBSCRIPTION_QUERY_KEYS.packages,
32
- });
33
-
34
- // Invalidate subscription status (user-specific)
35
- queryClient.invalidateQueries({
36
- queryKey: subscriptionStatusQueryKeys.user(userId),
37
- });
38
-
39
- // Invalidate credits (user-specific)
40
- queryClient.invalidateQueries({
41
- queryKey: creditsQueryKeys.user(userId),
42
- });
43
- }
44
-
45
- /**
46
- * Invalidate only subscription status cache.
47
- * Use this when only subscription status changes, not credits.
48
- *
49
- * @param queryClient - TanStack Query client instance
50
- * @param userId - User ID to invalidate cache for
51
- */
52
- export function invalidateSubscriptionStatus(
53
- queryClient: QueryClient,
54
- userId: string | null | undefined
55
- ): void {
56
- if (!userId) {
57
- return;
58
- }
59
-
60
- queryClient.invalidateQueries({
61
- queryKey: subscriptionStatusQueryKeys.user(userId),
62
- });
63
- }
64
-
65
- /**
66
- * Invalidate only credits cache.
67
- * Use this when only credits change, not subscription status.
68
- *
69
- * @param queryClient - TanStack Query client instance
70
- * @param userId - User ID to invalidate cache for
71
- */
72
- export function invalidateCredits(
73
- queryClient: QueryClient,
74
- userId: string | null | undefined
75
- ): void {
76
- if (!userId) {
77
- return;
78
- }
79
-
80
- queryClient.invalidateQueries({
81
- queryKey: creditsQueryKeys.user(userId),
82
- });
83
- }
84
-
85
- /**
86
- * Invalidate all caches for a user (subscription + credits).
87
- * Alias for invalidateSubscriptionCaches for better semantic clarity.
88
- *
89
- * @param queryClient - TanStack Query client instance
90
- * @param userId - User ID to invalidate caches for
91
- */
92
- export function invalidateAllUserData(
93
- queryClient: QueryClient,
94
- userId: string | null | undefined
95
- ): void {
96
- invalidateSubscriptionCaches(queryClient, userId);
97
- }
@@ -1,6 +0,0 @@
1
- export {
2
- invalidateSubscriptionCaches,
3
- invalidateSubscriptionStatus,
4
- invalidateCredits,
5
- invalidateAllUserData,
6
- } from "./cacheInvalidation";