@umituz/react-native-firebase 1.13.163 → 1.14.0
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.
|
|
3
|
+
"version": "1.14.0",
|
|
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
|
@@ -23,6 +23,7 @@ export type { Firestore } from './infrastructure/config/FirestoreClient';
|
|
|
23
23
|
|
|
24
24
|
// Repositories
|
|
25
25
|
export { BaseRepository } from './infrastructure/repositories/BaseRepository';
|
|
26
|
+
export type { IPathResolver } from './infrastructure/repositories/BaseRepository';
|
|
26
27
|
export { BaseQueryRepository } from './infrastructure/repositories/BaseQueryRepository';
|
|
27
28
|
export { BasePaginatedRepository } from './infrastructure/repositories/BasePaginatedRepository';
|
|
28
29
|
|
|
@@ -12,19 +12,17 @@ import type { Firestore, CollectionReference, DocumentReference, DocumentData }
|
|
|
12
12
|
import { getFirestore, collection, doc } from 'firebase/firestore';
|
|
13
13
|
import { isQuotaError as checkQuotaError } from '../../utils/quota-error-detector.util';
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* Repository destruction state
|
|
17
|
-
*/
|
|
18
15
|
export enum RepositoryState {
|
|
19
16
|
ACTIVE = 'active',
|
|
20
17
|
DESTROYED = 'destroyed',
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
export interface IPathResolver {
|
|
21
|
+
getUserCollection(userId: string): CollectionReference<DocumentData> | null;
|
|
22
|
+
getDocRef(userId: string, documentId: string): DocumentReference<DocumentData> | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export abstract class BaseRepository implements IPathResolver {
|
|
28
26
|
protected state: RepositoryState = RepositoryState.ACTIVE;
|
|
29
27
|
protected readonly collectionName: string;
|
|
30
28
|
|
|
@@ -43,32 +41,17 @@ export abstract class BaseRepository {
|
|
|
43
41
|
return getFirestore();
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
* Get user collection reference
|
|
48
|
-
* Pattern: users/{userId}/{collectionName}
|
|
49
|
-
*
|
|
50
|
-
* @param userId User identifier
|
|
51
|
-
* @returns CollectionReference or null if db not initialized
|
|
52
|
-
*/
|
|
53
|
-
protected getUserCollection = (userId: string): CollectionReference<DocumentData> | null => {
|
|
44
|
+
getUserCollection(userId: string): CollectionReference<DocumentData> | null {
|
|
54
45
|
const db = this.getDb();
|
|
55
46
|
if (!db) return null;
|
|
56
47
|
return collection(db, 'users', userId, this.collectionName);
|
|
57
|
-
}
|
|
48
|
+
}
|
|
58
49
|
|
|
59
|
-
|
|
60
|
-
* Get document reference
|
|
61
|
-
* Pattern: users/{userId}/{collectionName}/{documentId}
|
|
62
|
-
*
|
|
63
|
-
* @param userId User identifier
|
|
64
|
-
* @param documentId Document identifier
|
|
65
|
-
* @returns DocumentReference or null if db not initialized
|
|
66
|
-
*/
|
|
67
|
-
protected getDocRef = (userId: string, documentId: string): DocumentReference<DocumentData> | null => {
|
|
50
|
+
getDocRef(userId: string, documentId: string): DocumentReference<DocumentData> | null {
|
|
68
51
|
const db = this.getDb();
|
|
69
52
|
if (!db) return null;
|
|
70
53
|
return doc(db, 'users', userId, this.collectionName, documentId);
|
|
71
|
-
}
|
|
54
|
+
}
|
|
72
55
|
|
|
73
56
|
/**
|
|
74
57
|
* Check if Firestore is initialized
|