@umituz/react-native-subscription 2.37.13 → 2.37.15

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.
Files changed (133) hide show
  1. package/package.json +1 -1
  2. package/src/domains/credits/application/PurchaseMetadataGenerator.ts +1 -1
  3. package/src/domains/credits/application/credit-strategies/CreditAllocationOrchestrator.ts +1 -1
  4. package/src/domains/credits/application/creditDocumentHelpers.ts +0 -14
  5. package/src/domains/credits/presentation/deduct-credit/index.ts +0 -1
  6. package/src/domains/credits/presentation/useCredits.ts +1 -6
  7. package/src/domains/credits/utils/creditValidation.ts +3 -3
  8. package/src/domains/paywall/components/PaywallFeatures.tsx +1 -1
  9. package/src/domains/paywall/hooks/usePaywallActions.ts +1 -1
  10. package/src/domains/revenuecat/core/errors/RevenueCatError.ts +1 -14
  11. package/src/domains/revenuecat/core/errors/RevenueCatErrorHandler.ts +1 -1
  12. package/src/domains/revenuecat/core/types/RevenueCatTypes.ts +3 -3
  13. package/src/domains/revenuecat/infrastructure/services/ConfigurationStateManager.ts +8 -2
  14. package/src/domains/revenuecat/infrastructure/services/RevenueCatInitializer.ts +0 -2
  15. package/src/domains/subscription/application/initializer/BackgroundInitializer.ts +45 -16
  16. package/src/domains/subscription/application/initializer/index.ts +1 -1
  17. package/src/domains/subscription/core/SubscriptionStatus.ts +4 -10
  18. package/src/domains/subscription/core/SubscriptionStatusHandlers.ts +1 -1
  19. package/src/domains/subscription/infrastructure/handlers/PackageHandler.ts +0 -2
  20. package/src/domains/subscription/infrastructure/hooks/usePurchasePackage.ts +1 -1
  21. package/src/domains/subscription/infrastructure/hooks/useRevenueCatTrialEligibility.ts +1 -2
  22. package/src/domains/subscription/infrastructure/hooks/useSubscriptionQueries.ts +0 -4
  23. package/src/domains/subscription/infrastructure/services/OfferingsFetcher.ts +50 -22
  24. package/src/domains/subscription/infrastructure/services/RestoreHandler.ts +1 -1
  25. package/src/domains/subscription/infrastructure/services/RevenueCatService.ts +1 -2
  26. package/src/domains/subscription/infrastructure/services/revenueCatServiceInstance.ts +0 -4
  27. package/src/domains/subscription/infrastructure/utils/renewal/index.ts +1 -1
  28. package/src/domains/subscription/presentation/components/details/CreditRow.tsx +1 -1
  29. package/src/domains/subscription/presentation/components/details/DetailRow.tsx +1 -1
  30. package/src/domains/subscription/presentation/components/feedback/FeedbackOption.tsx +0 -2
  31. package/src/domains/subscription/presentation/components/feedback/FeedbackTextInput.tsx +1 -1
  32. package/src/domains/subscription/presentation/featureGateRefs.ts +1 -1
  33. package/src/domains/subscription/presentation/screens/components/CreditsList.tsx +2 -2
  34. package/src/domains/subscription/presentation/screens/components/SubscriptionHeader.tsx +0 -2
  35. package/src/domains/subscription/presentation/stores/index.ts +0 -5
  36. package/src/domains/subscription/presentation/stores/purchaseLoadingStore.ts +3 -7
  37. package/src/domains/subscription/presentation/useAuthAwarePurchase.ts +2 -8
  38. package/src/domains/subscription/presentation/useFeatureGate.ts +0 -2
  39. package/src/domains/subscription/presentation/usePaywallVisibility.ts +1 -1
  40. package/src/domains/subscription/utils/authGuards.ts +0 -23
  41. package/src/domains/subscription/utils/syncStatus.ts +1 -1
  42. package/src/domains/wallet/index.ts +0 -112
  43. package/src/domains/wallet/infrastructure/config/walletConfig.ts +1 -23
  44. package/src/domains/wallet/infrastructure/repositories/transaction/CollectionBuilder.ts +1 -1
  45. package/src/domains/wallet/infrastructure/repositories/transaction/index.ts +0 -9
  46. package/src/domains/wallet/presentation/components/BalanceCard.tsx +1 -1
  47. package/src/domains/wallet/presentation/components/TransactionItem.tsx +0 -2
  48. package/src/domains/wallet/presentation/components/TransactionList.tsx +3 -2
  49. package/src/domains/wallet/presentation/hooks/useTransactionHistory.ts +2 -2
  50. package/src/domains/wallet/presentation/hooks/useWallet.ts +2 -2
  51. package/src/shared/application/FeedbackService.ts +2 -2
  52. package/src/shared/infrastructure/SubscriptionEventBus.ts +1 -1
  53. package/src/shared/infrastructure/firestore/collectionUtils.ts +0 -7
  54. package/src/shared/infrastructure/firestore/resultUtils.ts +3 -39
  55. package/src/shared/presentation/layouts/ScreenLayout.tsx +1 -1
  56. package/src/shared/utils/numberUtils.core.ts +0 -27
  57. package/src/shared/utils/numberUtils.ts +1 -9
  58. package/src/shared/utils/validators.ts +0 -58
  59. package/src/domains/config/domain/entities/Plan.ts +0 -44
  60. package/src/domains/config/domain/index.ts +0 -2
  61. package/src/domains/config/domain/value-objects/Config.ts +0 -49
  62. package/src/domains/config/index.ts +0 -6
  63. package/src/domains/config/utils/planSelectors.ts +0 -56
  64. package/src/domains/paywall/components/FeatureItem.tsx +0 -50
  65. package/src/domains/paywall/components/FeatureList.tsx +0 -34
  66. package/src/domains/paywall/components/PaywallHeader.tsx +0 -112
  67. package/src/domains/paywall/hooks/usePaywallTranslations.ts +0 -78
  68. package/src/domains/paywall/hooks/useSubscriptionModal.ts +0 -45
  69. package/src/domains/paywall/index.ts +0 -13
  70. package/src/domains/revenuecat/core/constants/RevenueCatConstants.ts +0 -201
  71. package/src/domains/revenuecat/core/constants/index.ts +0 -5
  72. package/src/domains/revenuecat/core/customerInfoHelpers.ts +0 -21
  73. package/src/domains/revenuecat/core/index.ts +0 -7
  74. package/src/domains/revenuecat/index.ts +0 -7
  75. package/src/domains/revenuecat/infrastructure/index.ts +0 -5
  76. package/src/domains/revenuecat/infrastructure/services/index.ts +0 -7
  77. package/src/domains/subscription/infrastructure/hooks/customer-info/index.ts +0 -2
  78. package/src/domains/subscription/infrastructure/hooks/customer-info/types.ts +0 -9
  79. package/src/domains/subscription/infrastructure/hooks/customer-info/useCustomerInfo.ts +0 -52
  80. package/src/domains/subscription/infrastructure/hooks/useInitializeSubscription.ts +0 -30
  81. package/src/domains/subscription/infrastructure/hooks/usePaywallFlow.ts +0 -78
  82. package/src/domains/subscription/infrastructure/hooks/useRevenueCat.ts +0 -119
  83. package/src/domains/subscription/presentation/components/feedback/FeedbackConstants.ts +0 -6
  84. package/src/domains/subscription/presentation/screens/components/SubscriptionActions.tsx +0 -56
  85. package/src/domains/subscription/utils/dateFormatters.ts +0 -28
  86. package/src/domains/wallet/domain/entities/CreditCost.ts +0 -45
  87. package/src/domains/wallet/domain/entities/README.md +0 -41
  88. package/src/domains/wallet/domain/errors/README.md +0 -40
  89. package/src/domains/wallet/domain/errors/WalletError.ts +0 -17
  90. package/src/domains/wallet/domain/errors/WalletError.types.ts +0 -30
  91. package/src/domains/wallet/domain/errors/WalletErrorClasses.ts +0 -82
  92. package/src/domains/wallet/domain/errors/WalletErrorFactory.ts +0 -24
  93. package/src/domains/wallet/domain/errors/WalletErrorMessages.ts +0 -17
  94. package/src/domains/wallet/domain/types/credit-cost.types.ts +0 -86
  95. package/src/domains/wallet/domain/types/index.ts +0 -33
  96. package/src/domains/wallet/domain/types/wallet.types.ts +0 -50
  97. package/src/domains/wallet/infrastructure/services/product-metadata/CacheManager.ts +0 -30
  98. package/src/domains/wallet/infrastructure/services/product-metadata/FirebaseFetcher.ts +0 -17
  99. package/src/domains/wallet/infrastructure/services/product-metadata/ProductMetadataService.ts +0 -57
  100. package/src/domains/wallet/infrastructure/services/product-metadata/ServiceManager.ts +0 -29
  101. package/src/domains/wallet/infrastructure/services/product-metadata/index.ts +0 -7
  102. package/src/domains/wallet/presentation/hooks/index.ts +0 -8
  103. package/src/domains/wallet/presentation/hooks/useProductMetadata.ts +0 -72
  104. package/src/domains/wallet/utils/index.ts +0 -1
  105. package/src/shared/application/ActivationHandler.ts +0 -108
  106. package/src/shared/application/ports/ISubscriptionService.ts +0 -27
  107. package/src/shared/infrastructure/index.ts +0 -6
  108. package/src/shared/infrastructure/react-query/queryInvalidation.ts +0 -46
  109. package/src/shared/presentation/hooks/index.ts +0 -6
  110. package/src/shared/presentation/hooks/useAsyncState.ts +0 -72
  111. package/src/shared/presentation/hooks/useServiceCall.ts +0 -77
  112. package/src/shared/types/ReactTypes.ts +0 -80
  113. package/src/shared/utils/InsufficientCreditsError.ts +0 -32
  114. package/src/shared/utils/Logger.ts +0 -81
  115. package/src/shared/utils/SubscriptionConfig.ts +0 -15
  116. package/src/shared/utils/SubscriptionError.ts +0 -47
  117. package/src/shared/utils/appValidators.ts +0 -38
  118. package/src/shared/utils/arrayUtils.core.ts +0 -81
  119. package/src/shared/utils/arrayUtils.query.ts +0 -118
  120. package/src/shared/utils/arrayUtils.transforms.ts +0 -116
  121. package/src/shared/utils/arrayUtils.ts +0 -19
  122. package/src/shared/utils/errorUtils.ts +0 -32
  123. package/src/shared/utils/index.ts +0 -14
  124. package/src/shared/utils/numberUtils.aggregate.ts +0 -35
  125. package/src/shared/utils/numberUtils.format.ts +0 -42
  126. package/src/shared/utils/numberUtils.math.ts +0 -48
  127. package/src/shared/utils/queryKeyFactory.ts +0 -9
  128. package/src/shared/utils/stringUtils.case.ts +0 -64
  129. package/src/shared/utils/stringUtils.check.ts +0 -65
  130. package/src/shared/utils/stringUtils.format.ts +0 -84
  131. package/src/shared/utils/stringUtils.generate.ts +0 -47
  132. package/src/shared/utils/stringUtils.modify.ts +0 -67
  133. package/src/shared/utils/stringUtils.ts +0 -10
@@ -1,32 +0,0 @@
1
- /**
2
- * Error Utilities
3
- * Common error handling and normalization functions
4
- */
5
-
6
- /**
7
- * Normalizes unknown error types to Error objects
8
- * Useful for catch blocks where error type is unknown
9
- *
10
- * @param error - The error to normalize (unknown type)
11
- * @param fallbackMessage - Message to use if error is not an Error object
12
- * @returns Always returns an Error object
13
- *
14
- * @example
15
- * try {
16
- * await someOperation();
17
- * } catch (error) {
18
- * const err = normalizeError(error, "Operation failed");
19
- * console.error(err.message);
20
- * }
21
- */
22
- export function normalizeError(
23
- error: unknown,
24
- fallbackMessage = "Unknown error"
25
- ): Error {
26
- if (error instanceof Error) {
27
- return error;
28
- }
29
-
30
- const message = typeof error === "string" ? error : String(error);
31
- return new Error(message || fallbackMessage);
32
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Shared Utilities
3
- */
4
-
5
- export * from "./arrayUtils";
6
- export * from "./BaseError";
7
- export * from "./InsufficientCreditsError";
8
- export * from "./Logger";
9
- export * from "./numberUtils";
10
- export * from "./Result";
11
- export * from "./stringUtils";
12
- export * from "./SubscriptionConfig";
13
- export * from "./SubscriptionError";
14
- export * from "./validators";
@@ -1,35 +0,0 @@
1
- /**
2
- * Number Utilities - Aggregation
3
- * Array aggregation functions for numbers
4
- */
5
-
6
- /**
7
- * Calculate the sum of an array of numbers
8
- */
9
- export function sum(values: number[]): number {
10
- return values.reduce((acc, val) => acc + val, 0);
11
- }
12
-
13
- /**
14
- * Calculate the average of an array of numbers
15
- */
16
- export function average(values: number[]): number {
17
- if (values.length === 0) return 0;
18
- return sum(values) / values.length;
19
- }
20
-
21
- /**
22
- * Find the minimum value in an array
23
- */
24
- export function min(values: number[]): number | null {
25
- if (values.length === 0) return null;
26
- return Math.min(...values);
27
- }
28
-
29
- /**
30
- * Find the maximum value in an array
31
- */
32
- export function max(values: number[]): number | null {
33
- if (values.length === 0) return null;
34
- return Math.max(...values);
35
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Number Utilities - Formatting
3
- * Number formatting and display functions
4
- */
5
-
6
- /**
7
- * Format number with thousands separator
8
- */
9
- export function formatNumber(value: number, locale: string = "en-US"): string {
10
- return new Intl.NumberFormat(locale).format(value);
11
- }
12
-
13
- /**
14
- * Format number as compact string (e.g., 1K, 1M, 1B)
15
- */
16
- export function formatCompactNumber(value: number, locale: string = "en-US"): string {
17
- return new Intl.NumberFormat(locale, {
18
- notation: "compact",
19
- compactDisplay: "short",
20
- }).format(value);
21
- }
22
-
23
- /**
24
- * Round to nearest multiple (e.g., round to nearest 0.99)
25
- */
26
- export function roundToNearest(value: number, multiple: number): number {
27
- return Math.round(value / multiple) * multiple;
28
- }
29
-
30
- /**
31
- * Floor to nearest multiple
32
- */
33
- export function floorToNearest(value: number, multiple: number): number {
34
- return Math.floor(value / multiple) * multiple;
35
- }
36
-
37
- /**
38
- * Ceiling to nearest multiple
39
- */
40
- export function ceilToNearest(value: number, multiple: number): number {
41
- return Math.ceil(value / multiple) * multiple;
42
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * Number Utilities - Math Operations
3
- * Advanced mathematical operations
4
- */
5
-
6
- import { clamp } from "./numberUtils.core";
7
-
8
- /**
9
- * Linear interpolation between two values
10
- */
11
- export function lerp(start: number, end: number, progress: number): number {
12
- return start + (end - start) * clamp(progress, 0, 1);
13
- }
14
-
15
- /**
16
- * Map a value from one range to another
17
- */
18
- export function mapRange(
19
- value: number,
20
- inMin: number,
21
- inMax: number,
22
- outMin: number,
23
- outMax: number
24
- ): number {
25
- const progress = (value - inMin) / (inMax - inMin);
26
- return lerp(outMin, outMax, progress);
27
- }
28
-
29
- /**
30
- * Check if a number is within range (inclusive)
31
- */
32
- export function isInRange(value: number, min: number, max: number): boolean {
33
- return value >= min && value <= max;
34
- }
35
-
36
- /**
37
- * Calculate tax amount
38
- */
39
- export function calculateTax(subtotal: number, taxRate: number): number {
40
- return subtotal * (taxRate / 100);
41
- }
42
-
43
- /**
44
- * Calculate total with tax
45
- */
46
- export function calculateTotalWithTax(subtotal: number, taxRate: number): number {
47
- return subtotal + calculateTax(subtotal, taxRate);
48
- }
@@ -1,9 +0,0 @@
1
- import { isAuthenticated } from "../../domains/subscription/utils/authGuards";
2
-
3
- export const createUserQueryKey = <T extends readonly unknown[]>(
4
- baseKey: T,
5
- userId: string | null | undefined,
6
- userSpecificKey: (userId: string) => readonly unknown[]
7
- ): readonly unknown[] => {
8
- return isAuthenticated(userId) ? userSpecificKey(userId) : baseKey;
9
- };
@@ -1,64 +0,0 @@
1
- /**
2
- * String Utilities - Case Conversion
3
- * String case transformation functions
4
- */
5
-
6
- /**
7
- * Capitalize first letter of a string
8
- */
9
- export function capitalize(str: string): string {
10
- if (!str) return "";
11
- return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
12
- }
13
-
14
- /**
15
- * Capitalize first letter of each word
16
- */
17
- export function titleCase(str: string): string {
18
- if (!str) return "";
19
- return str
20
- .toLowerCase()
21
- .split(" ")
22
- .map((word) => capitalize(word))
23
- .join(" ");
24
- }
25
-
26
- /**
27
- * Convert string to kebab-case
28
- */
29
- export function kebabCase(str: string): string {
30
- if (!str) return "";
31
- return str
32
- .replace(/([a-z])([A-Z])/g, "$1-$2")
33
- .replace(/[\s_]+/g, "-")
34
- .toLowerCase();
35
- }
36
-
37
- /**
38
- * Convert string to snake_case
39
- */
40
- export function snakeCase(str: string): string {
41
- if (!str) return "";
42
- return str
43
- .replace(/([a-z])([A-Z])/g, "$1_$2")
44
- .replace(/[\s-]+/g, "_")
45
- .toLowerCase();
46
- }
47
-
48
- /**
49
- * Convert string to camelCase
50
- */
51
- export function camelCase(str: string): string {
52
- if (!str) return "";
53
- return str
54
- .replace(/[-_\s]+(.)?/g, (_, char) => (char ? char.toUpperCase() : ""))
55
- .replace(/^[A-Z]/, (char) => char.toLowerCase());
56
- }
57
-
58
- /**
59
- * Convert string to PascalCase
60
- */
61
- export function pascalCase(str: string): string {
62
- if (!str) return "";
63
- return capitalize(camelCase(str));
64
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * String Utilities - Check Operations
3
- * String validation and comparison functions
4
- */
5
-
6
- /**
7
- * Check if value is a non-empty string
8
- */
9
- function isNonEmptyString(value: unknown): value is string {
10
- return typeof value === "string" && value.trim().length > 0;
11
- }
12
-
13
- /**
14
- * Check if string contains a substring (case insensitive)
15
- */
16
- export function containsIgnoreCase(str: string, search: string): boolean {
17
- return str.toLowerCase().includes(search.toLowerCase());
18
- }
19
-
20
- /**
21
- * Check if string starts with a prefix (case insensitive)
22
- */
23
- export function startsWithIgnoreCase(str: string, prefix: string): boolean {
24
- return str.toLowerCase().startsWith(prefix.toLowerCase());
25
- }
26
-
27
- /**
28
- * Check if string ends with a suffix (case insensitive)
29
- */
30
- export function endsWithIgnoreCase(str: string, suffix: string): boolean {
31
- return str.toLowerCase().endsWith(suffix.toLowerCase());
32
- }
33
-
34
- /**
35
- * Check if a string is a valid email (basic validation)
36
- */
37
- export function isValidEmailString(value: unknown): value is string {
38
- if (!isNonEmptyString(value)) {
39
- return false;
40
- }
41
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
42
- return emailRegex.test(value);
43
- }
44
-
45
- /**
46
- * Check if value is a valid URL (basic validation)
47
- */
48
- export function isValidUrlString(value: unknown): value is string {
49
- if (!isNonEmptyString(value)) {
50
- return false;
51
- }
52
- try {
53
- new URL(value as string);
54
- return true;
55
- } catch {
56
- return false;
57
- }
58
- }
59
-
60
- /**
61
- * Check if a string is a valid product identifier
62
- */
63
- export function isValidProductIdString(value: unknown): value is string {
64
- return isNonEmptyString(value) && /^[a-zA-Z0-9._-]+$/.test(value as string);
65
- }
@@ -1,84 +0,0 @@
1
- /**
2
- * String Utilities - Formatting
3
- * String formatting and display functions
4
- */
5
-
6
- /**
7
- * Truncate string to specified length and add ellipsis
8
- */
9
- export function truncate(str: string, maxLength: number, suffix: string = "..."): string {
10
- if (!str || str.length <= maxLength) return str;
11
- return str.slice(0, maxLength - suffix.length) + suffix;
12
- }
13
-
14
- /**
15
- * Format bytes as human readable string
16
- */
17
- export function formatBytes(bytes: number, decimals: number = 2): string {
18
- if (bytes === 0) return "0 Bytes";
19
-
20
- const k = 1024;
21
- const dm = decimals < 0 ? 0 : decimals;
22
- const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
23
-
24
- const i = Math.floor(Math.log(bytes) / Math.log(k));
25
-
26
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
27
- }
28
-
29
- /**
30
- * Format a list of items as a comma-separated string with "and" for the last item
31
- */
32
- export function formatList(items: string[], conjunction: string = "and"): string {
33
- if (items.length === 0) return "";
34
- if (items.length === 1) return items[0] ?? "";
35
- if (items.length === 2) return items.join(` ${conjunction} `);
36
-
37
- const lastItem = items[items.length - 1];
38
- return `${items.slice(0, -1).join(", ")} ${conjunction} ${lastItem ?? ""}`;
39
- }
40
-
41
- /**
42
- * Pluralize a word based on count
43
- */
44
- export function pluralize(count: number, singular: string, plural?: string): string {
45
- if (count === 1) return singular;
46
- return plural || singular + "s";
47
- }
48
-
49
- /**
50
- * Format number as ordinal (1st, 2nd, 3rd, etc.)
51
- */
52
- export function formatOrdinal(num: number): string {
53
- const suffixes = ["th", "st", "nd", "rd"];
54
- const value = num % 100;
55
- const suffix = suffixes[(value - 20) % 10] || suffixes[value] || suffixes[0];
56
- return `${num}${suffix}`;
57
- }
58
-
59
- /**
60
- * Mask sensitive data (e.g., credit card, email)
61
- */
62
- export function maskString(str: string, visibleChars: number = 4, maskChar: string = "*"): string {
63
- if (!str) return "";
64
- if (str.length <= visibleChars * 2) return maskChar.repeat(str.length);
65
-
66
- const start = str.substring(0, visibleChars);
67
- const end = str.substring(str.length - visibleChars);
68
- const middleLength = str.length - visibleChars * 2;
69
-
70
- return `${start}${maskChar.repeat(middleLength)}${end}`;
71
- }
72
-
73
- /**
74
- * Extract initials from a name
75
- */
76
- export function getInitials(name: string, maxInitials: number = 2): string {
77
- if (!name) return "";
78
- return name
79
- .split(" ")
80
- .filter((word) => word.length > 0)
81
- .map((word) => word.charAt(0).toUpperCase())
82
- .slice(0, maxInitials)
83
- .join("");
84
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * String Utilities - Generate Functions
3
- * String generation and encoding functions
4
- */
5
-
6
- /**
7
- * Generate a random string of specified length
8
- */
9
- export function randomString(
10
- length: number,
11
- charset: string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
12
- ): string {
13
- let result = "";
14
- for (let i = 0; i < length; i++) {
15
- result += charset.charAt(Math.floor(Math.random() * charset.length));
16
- }
17
- return result;
18
- }
19
-
20
- /**
21
- * Generate a random ID
22
- */
23
- export function randomId(prefix: string = ""): string {
24
- const timestamp = Date.now().toString(36);
25
- const random = Math.random().toString(36).substring(2, 9);
26
- return prefix ? `${prefix}_${timestamp}${random}` : `${timestamp}${random}`;
27
- }
28
-
29
- /**
30
- * Convert a string to base64
31
- */
32
- export function toBase64(str: string): string {
33
- if (typeof btoa !== "undefined") {
34
- return btoa(str);
35
- }
36
- return Buffer.from(str).toString("base64");
37
- }
38
-
39
- /**
40
- * Decode a base64 string
41
- */
42
- export function fromBase64(base64: string): string {
43
- if (typeof atob !== "undefined") {
44
- return atob(base64);
45
- }
46
- return Buffer.from(base64, "base64").toString();
47
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * String Utilities - Modify Operations
3
- * String manipulation and transformation functions
4
- */
5
-
6
- /**
7
- * Remove all whitespace from string
8
- */
9
- export function removeWhitespace(str: string): string {
10
- return str.replace(/\s+/g, "");
11
- }
12
-
13
- /**
14
- * Normalize whitespace (replace multiple spaces with single space)
15
- */
16
- export function normalizeWhitespace(str: string): string {
17
- return str.trim().replace(/\s+/g, " ");
18
- }
19
-
20
- /**
21
- * Count words in a string
22
- */
23
- export function countWords(str: string): number {
24
- if (!str.trim()) return 0;
25
- return str.trim().split(/\s+/).length;
26
- }
27
-
28
- /**
29
- * Count characters in a string (excluding whitespace)
30
- */
31
- export function countChars(str: string, excludeWhitespace: boolean = true): number {
32
- return excludeWhitespace ? removeWhitespace(str).length : str.length;
33
- }
34
-
35
- /**
36
- * Replace all occurrences of a substring
37
- */
38
- export function replaceAll(str: string, search: string, replacement: string): string {
39
- return str.split(search).join(replacement);
40
- }
41
-
42
- /**
43
- * Escape special regex characters in a string
44
- */
45
- export function escapeRegex(str: string): string {
46
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47
- }
48
-
49
- /**
50
- * Strip HTML tags from a string
51
- */
52
- export function stripHtml(html: string): string {
53
- return html.replace(/<[^>]*>/g, "");
54
- }
55
-
56
- /**
57
- * Sanitize string input (trim and remove extra whitespace)
58
- */
59
- export function sanitizeStringValue(value: unknown): string | null {
60
- if (value === null || value === undefined) {
61
- return null;
62
- }
63
- if (typeof value === "string") {
64
- return value.trim().replace(/\s+/g, " ");
65
- }
66
- return String(value).trim().replace(/\s+/g, " ");
67
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * String Utilities
3
- * Re-exports all string utility modules
4
- */
5
-
6
- export * from "./stringUtils.case";
7
- export * from "./stringUtils.check";
8
- export * from "./stringUtils.format";
9
- export * from "./stringUtils.generate";
10
- export * from "./stringUtils.modify";