@umituz/react-native-subscription 2.2.40 → 2.2.42

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.2.40",
3
+ "version": "2.2.42",
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",
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Subscription Service Interface
3
+ * Defines the contract for subscription service operations
4
+ */
5
+
6
+ import type { SubscriptionStatus } from '../../domain/entities/SubscriptionStatus';
7
+
8
+ export interface ISubscriptionService {
9
+ /**
10
+ * Get current subscription status
11
+ */
12
+ getStatus(userId: string): Promise<SubscriptionStatus | null>;
13
+
14
+ /**
15
+ * Activate a subscription
16
+ */
17
+ activateSubscription(
18
+ userId: string,
19
+ productId: string,
20
+ expiresAt: string | null
21
+ ): Promise<void>;
22
+
23
+ /**
24
+ * Deactivate a subscription
25
+ */
26
+ deactivateSubscription(userId: string): Promise<void>;
27
+
28
+ /**
29
+ * Check if user has premium access
30
+ */
31
+ isPremium(userId: string): Promise<boolean>;
32
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Subscription Error
3
+ * Custom error class for subscription-related errors
4
+ */
5
+
6
+ export class SubscriptionError extends Error {
7
+ public readonly code: string;
8
+
9
+ constructor(message: string, code: string = 'SUBSCRIPTION_ERROR') {
10
+ super(message);
11
+ this.name = 'SubscriptionError';
12
+ this.code = code;
13
+ }
14
+
15
+ static notFound(message: string = 'Subscription not found'): SubscriptionError {
16
+ return new SubscriptionError(message, 'SUBSCRIPTION_NOT_FOUND');
17
+ }
18
+
19
+ static expired(message: string = 'Subscription has expired'): SubscriptionError {
20
+ return new SubscriptionError(message, 'SUBSCRIPTION_EXPIRED');
21
+ }
22
+
23
+ static purchaseFailed(message: string = 'Purchase failed'): SubscriptionError {
24
+ return new SubscriptionError(message, 'PURCHASE_FAILED');
25
+ }
26
+
27
+ static restoreFailed(message: string = 'Restore failed'): SubscriptionError {
28
+ return new SubscriptionError(message, 'RESTORE_FAILED');
29
+ }
30
+
31
+ static networkError(message: string = 'Network error'): SubscriptionError {
32
+ return new SubscriptionError(message, 'NETWORK_ERROR');
33
+ }
34
+ }
@@ -7,6 +7,7 @@ import React from "react";
7
7
  import { View, Text, StyleSheet } from "react-native";
8
8
  import { useAppDesignTokens } from "@umituz/react-native-design-system";
9
9
  import { SubscriptionStatusType } from "../../../domain/entities/SubscriptionStatus";
10
+ export type { SubscriptionStatusType };
10
11
 
11
12
  export interface PremiumStatusBadgeProps {
12
13
  status: SubscriptionStatusType;
@@ -90,8 +90,8 @@ export function useSubscriptionDetails(
90
90
  isExpired,
91
91
  isLifetime,
92
92
  daysRemaining,
93
- formattedExpirationDate: formatDate(status.expiresAt, locale),
94
- formattedPurchaseDate: formatDate(status.purchasedAt, locale),
93
+ formattedExpirationDate: formatDate(status.expiresAt ?? null, locale),
94
+ formattedPurchaseDate: formatDate(status.purchasedAt ?? null, locale),
95
95
  statusKey,
96
96
  };
97
97
  }, [status, locale]);