@umituz/react-native-firebase 1.13.17 → 1.13.19
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.
|
|
3
|
+
"version": "1.13.19",
|
|
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",
|
package/src/firestore/index.ts
CHANGED
|
@@ -108,6 +108,12 @@ export {
|
|
|
108
108
|
getQuotaErrorMessage,
|
|
109
109
|
} from './utils/quota-error-detector.util';
|
|
110
110
|
|
|
111
|
+
// =============================================================================
|
|
112
|
+
// UTILS - Path Resolver
|
|
113
|
+
// =============================================================================
|
|
114
|
+
|
|
115
|
+
export { FirestorePathResolver } from './utils/path-resolver';
|
|
116
|
+
|
|
111
117
|
// =============================================================================
|
|
112
118
|
// DOMAIN LAYER - Constants
|
|
113
119
|
// =============================================================================
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Firestore } from "firebase/firestore";
|
|
2
|
+
import { collection, doc } from "firebase/firestore";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolves Firestore paths for user collections
|
|
6
|
+
* Standard pattern: users/{userId}/{collectionName}
|
|
7
|
+
*
|
|
8
|
+
* This class is designed to be used across hundreds of apps.
|
|
9
|
+
* All user data MUST be under users/{userId}/ for consistency.
|
|
10
|
+
*/
|
|
11
|
+
export class FirestorePathResolver {
|
|
12
|
+
constructor(
|
|
13
|
+
private readonly collectionName: string,
|
|
14
|
+
private readonly db: Firestore | null,
|
|
15
|
+
) { }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get collection reference for a user
|
|
19
|
+
* Pattern: users/{userId}/{collectionName}
|
|
20
|
+
*
|
|
21
|
+
* @param userId User identifier
|
|
22
|
+
* @returns CollectionReference or null if db not initialized
|
|
23
|
+
*/
|
|
24
|
+
getUserCollection(userId: string) {
|
|
25
|
+
if (!this.db) return null;
|
|
26
|
+
return collection(this.db, "users", userId, this.collectionName);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get document reference for a specific item
|
|
31
|
+
* Pattern: users/{userId}/{collectionName}/{documentId}
|
|
32
|
+
*
|
|
33
|
+
* @param userId User identifier
|
|
34
|
+
* @param documentId Document identifier
|
|
35
|
+
* @returns DocumentReference or null if db not initialized
|
|
36
|
+
*/
|
|
37
|
+
getDocRef(userId: string, documentId: string) {
|
|
38
|
+
if (!this.db) return null;
|
|
39
|
+
return doc(this.db, "users", userId, this.collectionName, documentId);
|
|
40
|
+
}
|
|
41
|
+
}
|