@umituz/react-native-subscription 2.33.3 → 2.33.5

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.33.3",
3
+ "version": "2.33.5",
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",
@@ -1,11 +1,11 @@
1
1
  import type { QueryClient } from "@umituz/react-native-design-system";
2
2
  import { timezoneService } from "@umituz/react-native-design-system";
3
- import type { UserCredits } from "../../core/Credits";
3
+ import type { UserCredits, DeductCreditsResult } from "../../core/Credits";
4
4
  import type { CreditsRepository } from "../../infrastructure/CreditsRepository";
5
5
  import { creditsQueryKeys } from "../creditsQueryKeys";
6
6
  import { calculateRemaining } from "../../../../shared/utils/numberUtils";
7
7
 
8
- interface MutationContext {
8
+ export interface MutationContext {
9
9
  previousCredits: UserCredits | null;
10
10
  skippedOptimistic: boolean;
11
11
  wasInsufficient?: boolean;
@@ -18,7 +18,7 @@ export function createDeductCreditMutationConfig(
18
18
  queryClient: QueryClient
19
19
  ) {
20
20
  return {
21
- mutationFn: async (cost: number) => {
21
+ mutationFn: async (cost: number): Promise<DeductCreditsResult> => {
22
22
  if (!userId) throw new Error("User not authenticated");
23
23
  return repository.deductCredit(userId, cost);
24
24
  },
@@ -2,7 +2,8 @@ import { useCallback } from "react";
2
2
  import { useMutation, useQueryClient } from "@umituz/react-native-design-system";
3
3
  import { getCreditsRepository } from "../../infrastructure/CreditsRepositoryManager";
4
4
  import type { UseDeductCreditParams, UseDeductCreditResult } from "./types";
5
- import { createDeductCreditMutationConfig } from "./mutationConfig";
5
+ import type { DeductCreditsResult } from "../../core/Credits";
6
+ import { createDeductCreditMutationConfig, type MutationContext } from "./mutationConfig";
6
7
 
7
8
  export const useDeductCredit = ({
8
9
  userId,
@@ -11,7 +12,9 @@ export const useDeductCredit = ({
11
12
  const repository = getCreditsRepository();
12
13
  const queryClient = useQueryClient();
13
14
 
14
- const mutation = useMutation(createDeductCreditMutationConfig(userId, repository, queryClient));
15
+ const mutation = useMutation<DeductCreditsResult, Error, number, MutationContext>(
16
+ createDeductCreditMutationConfig(userId, repository, queryClient)
17
+ );
15
18
 
16
19
  const deductCredit = useCallback(async (cost: number = 1): Promise<boolean> => {
17
20
  try {