@umituz/react-native-firebase 1.13.16 → 1.13.18

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-firebase",
3
- "version": "1.13.16",
3
+ "version": "1.13.18",
4
4
  "description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -32,6 +32,7 @@
32
32
  "peerDependencies": {
33
33
  "@umituz/react-native-sentry": "latest",
34
34
  "expo-apple-authentication": ">=6.0.0",
35
+ "expo-crypto": ">=13.0.0",
35
36
  "firebase": ">=10.0.0",
36
37
  "react": ">=18.2.0",
37
38
  "react-native": ">=0.74.0"
@@ -15,7 +15,6 @@
15
15
 
16
16
  import type { Auth } from 'firebase/auth';
17
17
  import { getFirebaseApp } from '../../../infrastructure/config/FirebaseClient';
18
- import { FirebaseAuthInitializationError } from '../../domain/errors/FirebaseAuthError';
19
18
  import { FirebaseAuthInitializer } from './initializers/FirebaseAuthInitializer';
20
19
  import type { FirebaseAuthConfig } from '../../domain/value-objects/FirebaseAuthConfig';
21
20
 
@@ -10,7 +10,6 @@ import { getFirebaseAuth } from "../config/FirebaseAuthClient";
10
10
  import {
11
11
  getUserAuthProvider,
12
12
  reauthenticateWithApple,
13
- type AuthProviderType,
14
13
  } from "./reauthentication.service";
15
14
 
16
15
  export interface AccountDeletionResult {
@@ -108,6 +108,17 @@ export {
108
108
  getQuotaErrorMessage,
109
109
  } from './utils/quota-error-detector.util';
110
110
 
111
+ // =============================================================================
112
+ // UTILS - Path Resolver
113
+ // =============================================================================
114
+
115
+ export {
116
+ FirestorePathResolver,
117
+ createDefaultPathBuilder,
118
+ } from './utils/path-resolver';
119
+
120
+ export type { PathBuilder } from './utils/path-resolver';
121
+
111
122
  // =============================================================================
112
123
  // DOMAIN LAYER - Constants
113
124
  // =============================================================================
@@ -0,0 +1,67 @@
1
+ import type { Firestore } from "firebase/firestore";
2
+ import { collection, doc } from "firebase/firestore";
3
+
4
+ /**
5
+ * Path builder function type
6
+ * Allows apps to define custom Firestore path structures
7
+ *
8
+ * @example
9
+ * // Default: users/{userId}/creations
10
+ * (userId) => ["users", userId, "creations"]
11
+ *
12
+ * @example
13
+ * // Alternative: creations/{userId}/items
14
+ * (userId) => ["creations", userId, "items"]
15
+ */
16
+ export type PathBuilder = (userId: string) => string[];
17
+
18
+ /**
19
+ * Resolves Firestore paths dynamically
20
+ * Single Responsibility: Path resolution and reference creation
21
+ *
22
+ * This class is designed to be used across hundreds of apps.
23
+ * It provides a consistent way to build Firestore paths and references.
24
+ */
25
+ export class FirestorePathResolver {
26
+ constructor(
27
+ private readonly pathBuilder: PathBuilder,
28
+ private readonly db: Firestore | null,
29
+ ) { }
30
+
31
+ /**
32
+ * Get collection reference for a user
33
+ * @param userId User identifier
34
+ * @returns CollectionReference or null if db not initialized
35
+ */
36
+ getUserCollection(userId: string) {
37
+ if (!this.db) return null;
38
+ const pathSegments = this.pathBuilder(userId);
39
+ const [first, ...rest] = pathSegments;
40
+ if (!first) return null;
41
+ return collection(this.db, first, ...rest);
42
+ }
43
+
44
+ /**
45
+ * Get document reference for a specific item
46
+ * @param userId User identifier
47
+ * @param documentId Document identifier
48
+ * @returns DocumentReference or null if db not initialized
49
+ */
50
+ getDocRef(userId: string, documentId: string) {
51
+ if (!this.db) return null;
52
+ const pathSegments = this.pathBuilder(userId);
53
+ const [first, ...rest] = pathSegments;
54
+ if (!first) return null;
55
+ return doc(this.db, first, ...rest, documentId);
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Creates a default path builder for standard user collections
61
+ * Pattern: users/{userId}/{collectionName}
62
+ *
63
+ * @param collectionName Name of the collection
64
+ * @returns PathBuilder function
65
+ */
66
+ export const createDefaultPathBuilder = (collectionName: string): PathBuilder =>
67
+ (userId: string) => ["users", userId, collectionName];