@umituz/react-native-subscription 1.0.5 → 1.0.6

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": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Subscription management system for React Native apps - Database-first approach with secure validation",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -31,10 +31,13 @@ export function getPeriodText(
31
31
  input:
32
32
  | {
33
33
  product?: {
34
- subscriptionPeriod?: {
35
- unit: string;
36
- numberOfUnits: number;
37
- } | null;
34
+ subscriptionPeriod?:
35
+ | {
36
+ unit: string;
37
+ numberOfUnits: number;
38
+ }
39
+ | string
40
+ | null;
38
41
  };
39
42
  }
40
43
  | {
@@ -59,8 +62,10 @@ export function getPeriodText(
59
62
  if ('product' in input && input.product?.subscriptionPeriod) {
60
63
  const period = input.product.subscriptionPeriod;
61
64
  // Type guard: check if period is an object with unit and numberOfUnits
65
+ // RevenueCat's subscriptionPeriod can be string | null | object
62
66
  if (
63
67
  typeof period === 'object' &&
68
+ period !== null &&
64
69
  'unit' in period &&
65
70
  'numberOfUnits' in period
66
71
  ) {
@@ -69,6 +74,7 @@ export function getPeriodText(
69
74
  numberOfUnits: period.numberOfUnits as number,
70
75
  };
71
76
  }
77
+ // If period is string, we can't extract unit/numberOfUnits, return empty
72
78
  } else if ('unit' in input && 'numberOfUnits' in input) {
73
79
  // Input is already a subscription period object
74
80
  subscriptionPeriod = {