@umituz/react-native-design-system 2.8.9 → 2.8.11

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 (26) hide show
  1. package/package.json +8 -1
  2. package/src/exports/tanstack.ts +1 -0
  3. package/src/index.ts +5 -0
  4. package/src/media/presentation/hooks/useCardMediaUpload.ts +1 -1
  5. package/src/media/presentation/hooks/useCardMultimediaFlashcard.ts +3 -3
  6. package/src/media/presentation/hooks/useMediaUpload.ts +1 -1
  7. package/src/media/presentation/hooks/useMultimediaFlashcard.ts +3 -3
  8. package/src/tanstack/domain/constants/CacheDefaults.ts +63 -0
  9. package/src/tanstack/domain/repositories/BaseRepository.ts +280 -0
  10. package/src/tanstack/domain/repositories/RepositoryFactory.ts +135 -0
  11. package/src/tanstack/domain/types/CacheStrategy.ts +115 -0
  12. package/src/tanstack/domain/utils/ErrorHelpers.ts +154 -0
  13. package/src/tanstack/domain/utils/QueryKeyFactory.ts +134 -0
  14. package/src/tanstack/domain/utils/TypeUtilities.ts +153 -0
  15. package/src/tanstack/index.ts +161 -0
  16. package/src/tanstack/infrastructure/config/PersisterConfig.ts +162 -0
  17. package/src/tanstack/infrastructure/config/QueryClientConfig.ts +154 -0
  18. package/src/tanstack/infrastructure/config/QueryClientSingleton.ts +69 -0
  19. package/src/tanstack/infrastructure/monitoring/DevMonitor.ts +274 -0
  20. package/src/tanstack/infrastructure/providers/TanstackProvider.tsx +105 -0
  21. package/src/tanstack/presentation/hooks/useInvalidateQueries.ts +128 -0
  22. package/src/tanstack/presentation/hooks/useOptimisticUpdate.ts +88 -0
  23. package/src/tanstack/presentation/hooks/usePaginatedQuery.ts +129 -0
  24. package/src/tanstack/presentation/hooks/usePrefetch.ts +237 -0
  25. package/src/tanstack/presentation/utils/RetryHelpers.ts +67 -0
  26. package/src/tanstack/types/global.d.ts +1 -0
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Retry Helpers
3
+ * Presentation layer - Utility functions for retry logic
4
+ *
5
+ * General-purpose retry helpers for any React Native app
6
+ */
7
+
8
+ /**
9
+ * Retry function type for TanStack Query
10
+ */
11
+ export type RetryFunction = (failureCount: number, error: Error) => boolean;
12
+
13
+ /**
14
+ * Error checker function type
15
+ */
16
+ export type ErrorChecker = (error: unknown) => boolean;
17
+
18
+ /**
19
+ * Creates a retry function that stops retrying on specific errors
20
+ *
21
+ * @param shouldNotRetry - Function to check if error should NOT be retried
22
+ * @param maxRetries - Maximum number of retries (default: 1)
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const isQuotaError = (error: unknown) => {
27
+ * return error instanceof Error && error.message.includes('quota');
28
+ * };
29
+ *
30
+ * const retryFn = createConditionalRetry(isQuotaError, 1);
31
+ * ```
32
+ */
33
+ export function createConditionalRetry(
34
+ shouldNotRetry: ErrorChecker,
35
+ maxRetries = 1,
36
+ ): RetryFunction {
37
+ return (failureCount: number, error: Error) => {
38
+ // Don't retry if error matches condition
39
+ if (shouldNotRetry(error)) {
40
+ return false;
41
+ }
42
+
43
+ // Retry up to maxRetries times
44
+ return failureCount < maxRetries;
45
+ };
46
+ }
47
+
48
+ /**
49
+ * Creates a quota-aware retry function
50
+ * Stops retrying on quota errors, retries other errors
51
+ *
52
+ * @param isQuotaError - Function to check if error is quota-related
53
+ * @param maxRetries - Maximum number of retries (default: 1)
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * import { isQuotaError } from '@umituz/react-native-firestore';
58
+ *
59
+ * const retryFn = createQuotaAwareRetry(isQuotaError);
60
+ * ```
61
+ */
62
+ export function createQuotaAwareRetry(
63
+ isQuotaError: ErrorChecker,
64
+ maxRetries = 1,
65
+ ): RetryFunction {
66
+ return createConditionalRetry(isQuotaError, maxRetries);
67
+ }
@@ -0,0 +1 @@
1
+ declare var __DEV__: boolean;