@umituz/react-native-firebase 3.0.3 → 3.0.5
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 +7 -1
- package/src/domains/account-deletion/index.ts +15 -10
- package/src/domains/account-deletion/infrastructure/services/account-deletion.service.ts +226 -26
- package/src/domains/account-deletion/infrastructure/services/reauthentication.service.ts +160 -0
- package/src/domains/auth/domain/value-objects/FirebaseAuthConfig.ts +1 -1
- package/src/domains/auth/index.ts +156 -6
- package/src/domains/auth/infrastructure/config/FirebaseAuthClient.ts +60 -48
- package/src/domains/auth/infrastructure/config/initializers/FirebaseAuthInitializer.ts +41 -5
- package/src/domains/auth/presentation/hooks/useGoogleOAuth.ts +115 -20
- package/src/domains/firestore/domain/constants/QuotaLimits.ts +101 -0
- package/src/domains/firestore/domain/entities/QuotaMetrics.ts +26 -0
- package/src/domains/firestore/domain/entities/RequestLog.ts +28 -0
- package/src/domains/firestore/domain/services/QuotaCalculator.ts +71 -0
- package/src/domains/firestore/index.ts +86 -31
- package/src/domains/firestore/infrastructure/config/FirestoreClient.ts +82 -45
- package/src/domains/firestore/infrastructure/config/initializers/FirebaseFirestoreInitializer.ts +249 -4
- package/src/domains/firestore/infrastructure/middleware/QueryDeduplicationMiddleware.ts +312 -0
- package/src/domains/firestore/infrastructure/middleware/QuotaTrackingMiddleware.ts +95 -0
- package/src/domains/firestore/infrastructure/repositories/BasePaginatedRepository.ts +7 -1
- package/src/domains/firestore/infrastructure/repositories/BaseQueryRepository.ts +34 -8
- package/src/domains/firestore/infrastructure/repositories/BaseRepository.ts +48 -9
- package/src/domains/firestore/infrastructure/services/RequestLoggerService.ts +165 -0
- package/src/domains/firestore/presentation/hooks/index.ts +10 -0
- package/src/domains/firestore/presentation/hooks/useFirestoreMutation.ts +1 -1
- package/src/domains/firestore/presentation/hooks/useFirestoreQuery.ts +1 -1
- package/src/domains/firestore/presentation/hooks/useSmartFirestoreSnapshot.ts +361 -0
- package/src/domains/firestore/presentation/query-keys/createFirestoreKeys.ts +32 -0
- package/src/domains/firestore/presentation/query-keys/index.ts +1 -0
- package/src/domains/firestore/utils/deduplication/pending-query-manager.util.ts +119 -0
- package/src/domains/firestore/utils/deduplication/query-key-generator.util.ts +34 -0
- package/src/domains/firestore/utils/deduplication/timer-manager.util.ts +83 -0
- package/src/index.ts +2 -30
- package/src/shared/domain/utils/calculation.util.ts +305 -17
- package/src/shared/domain/utils/error-handlers/error-messages.ts +0 -11
- package/src/shared/domain/utils/index.ts +5 -0
- package/src/shared/infrastructure/config/base/ClientStateManager.ts +82 -0
- package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts +136 -20
- package/src/shared/infrastructure/config/clients/FirebaseClientSingleton.ts +1 -1
- package/src/shared/infrastructure/config/initializers/FirebaseAppInitializer.ts +9 -0
- package/src/shared/infrastructure/config/services/FirebaseInitializationService.ts +1 -1
- package/src/shared/infrastructure/config/state/FirebaseClientState.ts +14 -36
- package/src/application/auth/index.ts +0 -10
- package/src/application/auth/use-cases/index.ts +0 -6
- package/src/domains/account-deletion/domain/index.ts +0 -8
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts +0 -79
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionTypes.ts +0 -32
- package/src/domains/auth/domain.ts +0 -16
- package/src/domains/auth/infrastructure/config/index.ts +0 -2
- package/src/domains/auth/infrastructure/config/initializers/index.ts +0 -1
- package/src/domains/auth/infrastructure/services/index.ts +0 -16
- package/src/domains/auth/infrastructure/services/utils/index.ts +0 -1
- package/src/domains/auth/infrastructure/stores/index.ts +0 -1
- package/src/domains/auth/infrastructure/utils/index.ts +0 -1
- package/src/domains/auth/infrastructure.ts +0 -11
- package/src/domains/auth/presentation/hooks/useAppleAuth.ts +0 -82
- package/src/domains/auth/presentation.ts +0 -31
- package/src/domains/firestore/domain/entities/Collection.ts +0 -122
- package/src/domains/firestore/domain/entities/CollectionFactory.ts +0 -55
- package/src/domains/firestore/domain/entities/CollectionHelpers.ts +0 -143
- package/src/domains/firestore/domain/entities/CollectionUtils.ts +0 -72
- package/src/domains/firestore/domain/entities/CollectionValidation.ts +0 -138
- package/src/domains/firestore/domain/index.ts +0 -61
- package/src/domains/firestore/domain/value-objects/QueryOptions.ts +0 -143
- package/src/domains/firestore/domain/value-objects/QueryOptionsFactory.ts +0 -95
- package/src/domains/firestore/domain/value-objects/QueryOptionsHelpers.ts +0 -110
- package/src/domains/firestore/domain/value-objects/WhereClause.ts +0 -114
- package/src/domains/firestore/domain/value-objects/WhereClauseFactory.ts +0 -101
- package/src/domains/firestore/domain/value-objects/WhereClauseHelpers.ts +0 -123
- package/src/domains/firestore/domain/value-objects/WhereClauseValidation.ts +0 -83
- package/src/shared/infrastructure/base/ErrorHandler.ts +0 -81
- package/src/shared/infrastructure/base/ServiceBase.ts +0 -62
- package/src/shared/infrastructure/base/TypedGuard.ts +0 -131
- package/src/shared/infrastructure/base/index.ts +0 -34
- package/src/shared/types/firebase.types.ts +0 -274
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where Clause Validation Utilities
|
|
3
|
-
* Single Responsibility: Validate where clauses
|
|
4
|
-
*
|
|
5
|
-
* Max lines: 150 (enforced for maintainability)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { WhereFilterOp } from 'firebase/firestore';
|
|
9
|
-
import type { WhereClause } from './WhereClause';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Validate where clause
|
|
13
|
-
*/
|
|
14
|
-
export function validateWhereClause(clause: WhereClause): {
|
|
15
|
-
valid: boolean;
|
|
16
|
-
errors: string[];
|
|
17
|
-
} {
|
|
18
|
-
const errors: string[] = [];
|
|
19
|
-
|
|
20
|
-
// Field validation
|
|
21
|
-
if (!clause.field || clause.field.trim() === '') {
|
|
22
|
-
errors.push('Field cannot be empty');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Value validation
|
|
26
|
-
if (clause.value === undefined) {
|
|
27
|
-
errors.push('Value cannot be undefined');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Operator-specific validation
|
|
31
|
-
if (requiresArrayValue(clause.operator)) {
|
|
32
|
-
if (!Array.isArray(clause.value)) {
|
|
33
|
-
errors.push(`Operator '${clause.operator}' requires an array value`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
valid: errors.length === 0,
|
|
39
|
-
errors,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Check if operator requires array value
|
|
45
|
-
*/
|
|
46
|
-
export function requiresArrayValue(operator: WhereFilterOp): boolean {
|
|
47
|
-
return operator === 'in' || operator === 'not-in' || operator === 'array-contains-any';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Check if operator is equality type
|
|
52
|
-
*/
|
|
53
|
-
export function isEqualityOperator(operator: WhereFilterOp): boolean {
|
|
54
|
-
return operator === '==';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Check if operator is inequality type
|
|
59
|
-
*/
|
|
60
|
-
export function isInequalityOperator(operator: WhereFilterOp): boolean {
|
|
61
|
-
return operator === '!=';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Check if operator is comparison type
|
|
66
|
-
*/
|
|
67
|
-
export function isComparisonOperator(operator: WhereFilterOp): boolean {
|
|
68
|
-
return ['<', '<=', '>', '>='].includes(operator);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Check if operator is array type
|
|
73
|
-
*/
|
|
74
|
-
export function isArrayOperator(operator: WhereFilterOp): boolean {
|
|
75
|
-
return operator === 'array-contains' || operator === 'array-contains-any';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Check if operator is membership type
|
|
80
|
-
*/
|
|
81
|
-
export function isMembershipOperator(operator: WhereFilterOp): boolean {
|
|
82
|
-
return operator === 'in' || operator === 'not-in';
|
|
83
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Handler
|
|
3
|
-
* Centralized error handling for services
|
|
4
|
-
*
|
|
5
|
-
* Max lines: 150 (enforced for maintainability)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { Result } from '../../domain/utils';
|
|
9
|
-
|
|
10
|
-
export interface ErrorHandlerOptions {
|
|
11
|
-
readonly serviceName?: string;
|
|
12
|
-
readonly defaultErrorCode?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ErrorInfo {
|
|
16
|
-
readonly code: string;
|
|
17
|
-
readonly message: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class ErrorHandler {
|
|
21
|
-
readonly serviceName: string;
|
|
22
|
-
readonly defaultErrorCode: string;
|
|
23
|
-
|
|
24
|
-
constructor(options: ErrorHandlerOptions = {}) {
|
|
25
|
-
this.serviceName = options.serviceName || 'Service';
|
|
26
|
-
this.defaultErrorCode = options.defaultErrorCode || 'ERROR';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async handleAsync<T>(
|
|
30
|
-
operation: () => Promise<T>,
|
|
31
|
-
errorCode?: string
|
|
32
|
-
): Promise<Result<T>> {
|
|
33
|
-
try {
|
|
34
|
-
const result = await operation();
|
|
35
|
-
return {
|
|
36
|
-
success: true,
|
|
37
|
-
data: result,
|
|
38
|
-
};
|
|
39
|
-
} catch (error) {
|
|
40
|
-
return {
|
|
41
|
-
success: false,
|
|
42
|
-
error: this.toErrorInfo(error, errorCode),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
handle<T>(operation: () => T, errorCode?: string): Result<T> {
|
|
48
|
-
try {
|
|
49
|
-
const result = operation();
|
|
50
|
-
return {
|
|
51
|
-
success: true,
|
|
52
|
-
data: result,
|
|
53
|
-
};
|
|
54
|
-
} catch (error) {
|
|
55
|
-
return {
|
|
56
|
-
success: false,
|
|
57
|
-
error: this.toErrorInfo(error, errorCode),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
toErrorInfo(error: unknown, code?: string): ErrorInfo {
|
|
63
|
-
if (error instanceof Error) {
|
|
64
|
-
return {
|
|
65
|
-
code: code || this.defaultErrorCode,
|
|
66
|
-
message: error.message,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
code: code || this.defaultErrorCode,
|
|
72
|
-
message: String(error),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
getUserMessage(error: ErrorInfo): string {
|
|
77
|
-
return error.message;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const defaultErrorHandler = new ErrorHandler();
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service Base
|
|
3
|
-
* Base class for all services with common functionality
|
|
4
|
-
*
|
|
5
|
-
* Max lines: 150 (enforced for maintainability)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { Result } from '../../domain/utils';
|
|
9
|
-
|
|
10
|
-
export interface ServiceBaseOptions {
|
|
11
|
-
readonly serviceName?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class ServiceBase {
|
|
15
|
-
readonly serviceName: string;
|
|
16
|
-
|
|
17
|
-
constructor(options: ServiceBaseOptions = {}) {
|
|
18
|
-
this.serviceName = options.serviceName || 'Service';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
protected async execute<T>(
|
|
22
|
-
operation: () => Promise<T>,
|
|
23
|
-
errorCode?: string
|
|
24
|
-
): Promise<Result<T>> {
|
|
25
|
-
try {
|
|
26
|
-
const result = await operation();
|
|
27
|
-
return {
|
|
28
|
-
success: true,
|
|
29
|
-
data: result,
|
|
30
|
-
};
|
|
31
|
-
} catch (error) {
|
|
32
|
-
return {
|
|
33
|
-
success: false,
|
|
34
|
-
error: {
|
|
35
|
-
code: errorCode || `${this.serviceName}_ERROR`,
|
|
36
|
-
message: error instanceof Error ? error.message : 'Unknown error',
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected executeSync<T>(
|
|
43
|
-
operation: () => T,
|
|
44
|
-
errorCode?: string
|
|
45
|
-
): Result<T> {
|
|
46
|
-
try {
|
|
47
|
-
const result = operation();
|
|
48
|
-
return {
|
|
49
|
-
success: true,
|
|
50
|
-
data: result,
|
|
51
|
-
};
|
|
52
|
-
} catch (error) {
|
|
53
|
-
return {
|
|
54
|
-
success: false,
|
|
55
|
-
error: {
|
|
56
|
-
code: errorCode || `${this.serviceName}_ERROR`,
|
|
57
|
-
message: error instanceof Error ? error.message : 'Unknown error',
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed Guard Utilities
|
|
3
|
-
* Single Responsibility: Provide type-safe guard utilities
|
|
4
|
-
*
|
|
5
|
-
* Consolidates all type guards to eliminate duplication across 6+ files.
|
|
6
|
-
* Provides type-safe checking without using 'as' assertions.
|
|
7
|
-
* Optimized for performance with minimal type assertions.
|
|
8
|
-
*
|
|
9
|
-
* Max lines: 150 (enforced for maintainability)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Type guard for non-null objects
|
|
14
|
-
* Inline function for better performance
|
|
15
|
-
*/
|
|
16
|
-
function isObject(value: unknown): value is Record<string, unknown> {
|
|
17
|
-
return typeof value === 'object' && value !== null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Type guard for objects with a 'code' property of type string
|
|
22
|
-
* Commonly used for Firebase errors and other error objects
|
|
23
|
-
* Optimized: Reduced type assertions by using 'in' operator check first
|
|
24
|
-
*/
|
|
25
|
-
export function hasCodeProperty(error: unknown): error is { code: string } {
|
|
26
|
-
return isObject(error) && 'code' in error && typeof error.code === 'string';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Type guard for objects with a 'message' property of type string
|
|
31
|
-
* Commonly used for Error objects
|
|
32
|
-
* Optimized: Reduced type assertions by using 'in' operator check first
|
|
33
|
-
*/
|
|
34
|
-
export function hasMessageProperty(error: unknown): error is { message: string } {
|
|
35
|
-
return isObject(error) && 'message' in error && typeof error.message === 'string';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Type guard for objects with both 'code' and 'message' properties
|
|
40
|
-
* Commonly used for Firebase errors
|
|
41
|
-
*/
|
|
42
|
-
export function isFirebaseErrorLike(error: unknown): error is { code: string; message: string } {
|
|
43
|
-
return hasCodeProperty(error) && hasMessageProperty(error);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Type guard for objects with a 'name' property of type string
|
|
48
|
-
* Commonly used for Error objects
|
|
49
|
-
*/
|
|
50
|
-
export function hasNameProperty(error: unknown): error is { name: string } {
|
|
51
|
-
return isObject(error) && 'name' in error && typeof error.name === 'string';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Type guard for Error instances
|
|
56
|
-
* More reliable than instanceof for cross-realm errors
|
|
57
|
-
*/
|
|
58
|
-
export function isErrorLike(value: unknown): value is Error {
|
|
59
|
-
return (
|
|
60
|
-
isObject(value) &&
|
|
61
|
-
'message' in value &&
|
|
62
|
-
typeof value.message === 'string' &&
|
|
63
|
-
'stack' in value &&
|
|
64
|
-
(typeof value.stack === 'string' || value.stack === undefined)
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Type guard for objects with a 'uid' property of type string
|
|
70
|
-
* Commonly used for Firebase user objects
|
|
71
|
-
*/
|
|
72
|
-
export function hasUidProperty(obj: unknown): obj is { uid: string } {
|
|
73
|
-
return isObject(obj) && 'uid' in obj && typeof obj.uid === 'string';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Type guard for objects with a 'email' property of type string
|
|
78
|
-
* Commonly used for Firebase user objects
|
|
79
|
-
*/
|
|
80
|
-
export function hasEmailProperty(obj: unknown): obj is { email: string | null } {
|
|
81
|
-
return isObject(obj) && 'email' in obj && (typeof obj.email === 'string' || obj.email === null);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Type guard for objects with a 'providerId' property
|
|
86
|
-
* Commonly used for Firebase user info objects
|
|
87
|
-
*/
|
|
88
|
-
export function hasProviderIdProperty(obj: unknown): obj is { providerId: string } {
|
|
89
|
-
return isObject(obj) && 'providerId' in obj && typeof obj.providerId === 'string';
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Type guard for arrays
|
|
94
|
-
*/
|
|
95
|
-
export function isArray(value: unknown): value is unknown[] {
|
|
96
|
-
return Array.isArray(value);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Type guard for strings
|
|
101
|
-
*/
|
|
102
|
-
export function isString(value: unknown): value is string {
|
|
103
|
-
return typeof value === 'string';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Type guard for functions
|
|
108
|
-
*/
|
|
109
|
-
export function isFunction(value: unknown): value is (...args: unknown[]) => unknown {
|
|
110
|
-
return typeof value === 'function';
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Check if object has a specific property
|
|
115
|
-
*/
|
|
116
|
-
export function hasProperty<T extends string>(
|
|
117
|
-
obj: unknown,
|
|
118
|
-
prop: T
|
|
119
|
-
): obj is Record<T, unknown> {
|
|
120
|
-
return isObject(obj) && prop in obj;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Check if object has multiple properties
|
|
125
|
-
*/
|
|
126
|
-
export function hasProperties<T extends string>(
|
|
127
|
-
obj: unknown,
|
|
128
|
-
props: T[]
|
|
129
|
-
): obj is Record<T, unknown> {
|
|
130
|
-
return isObject(obj) && props.every(prop => prop in obj);
|
|
131
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared Infrastructure Base Classes
|
|
3
|
-
*
|
|
4
|
-
* Eliminates code duplication across the codebase.
|
|
5
|
-
* Provides common functionality for services, error handling, and type guards.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { ServiceBase, ErrorHandler, hasCodeProperty } from '@umituz/react-native-firebase/base';
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// ServiceBase - Base class for all services
|
|
14
|
-
export { ServiceBase, type ServiceBaseOptions } from './ServiceBase';
|
|
15
|
-
|
|
16
|
-
// ErrorHandler - Centralized error handling
|
|
17
|
-
export { ErrorHandler, defaultErrorHandler, type ErrorHandlerOptions } from './ErrorHandler';
|
|
18
|
-
|
|
19
|
-
// TypedGuard - Type-safe guard utilities
|
|
20
|
-
export {
|
|
21
|
-
hasCodeProperty,
|
|
22
|
-
hasMessageProperty,
|
|
23
|
-
isFirebaseErrorLike,
|
|
24
|
-
hasNameProperty,
|
|
25
|
-
isErrorLike,
|
|
26
|
-
hasUidProperty,
|
|
27
|
-
hasEmailProperty,
|
|
28
|
-
hasProviderIdProperty,
|
|
29
|
-
isArray,
|
|
30
|
-
isString,
|
|
31
|
-
isFunction,
|
|
32
|
-
hasProperty,
|
|
33
|
-
hasProperties,
|
|
34
|
-
} from './TypedGuard';
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Firebase Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* These types mirror Firebase SDK types but don't import from the firebase package.
|
|
5
|
-
* This prevents the 'idb' dependency that causes bundling errors in React Native.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// =============================================================================
|
|
9
|
-
// Firebase App Types
|
|
10
|
-
// =============================================================================
|
|
11
|
-
|
|
12
|
-
export interface FirebaseApp {
|
|
13
|
-
name: string;
|
|
14
|
-
options?: FirebaseAppOptions;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface FirebaseAppOptions {
|
|
18
|
-
apiKey?: string;
|
|
19
|
-
authDomain?: string;
|
|
20
|
-
databaseURL?: string;
|
|
21
|
-
projectId?: string;
|
|
22
|
-
storageBucket?: string;
|
|
23
|
-
messagingSenderId?: string;
|
|
24
|
-
appId?: string;
|
|
25
|
-
measurementId?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// =============================================================================
|
|
29
|
-
// Firestore Types
|
|
30
|
-
// =============================================================================
|
|
31
|
-
|
|
32
|
-
// Firestore type - use 'any' to avoid type conflicts with Firebase SDK
|
|
33
|
-
// In your app, import the actual type: import type { Firestore } from 'firebase/firestore'
|
|
34
|
-
export type Firestore = any;
|
|
35
|
-
|
|
36
|
-
export interface DocumentSnapshot<T = unknown> {
|
|
37
|
-
id: string;
|
|
38
|
-
ref: DocumentReference<T>;
|
|
39
|
-
data: T | null;
|
|
40
|
-
metadata: SnapshotMetadata;
|
|
41
|
-
exists(): boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface SnapshotMetadata {
|
|
45
|
-
hasPendingWrites: boolean;
|
|
46
|
-
fromCache: boolean;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface QuerySnapshot<T = unknown> {
|
|
50
|
-
docs: QueryDocumentSnapshot<T>[];
|
|
51
|
-
metadata: SnapshotMetadata;
|
|
52
|
-
size: number;
|
|
53
|
-
empty: boolean;
|
|
54
|
-
docChanges: DocumentChange<T>[];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface QueryDocumentSnapshot<T = unknown> extends DocumentSnapshot<T> {}
|
|
58
|
-
|
|
59
|
-
export interface DocumentReference<T = unknown> {
|
|
60
|
-
id: string;
|
|
61
|
-
firestore: Firestore;
|
|
62
|
-
path: string;
|
|
63
|
-
parent: CollectionReference<T> | null;
|
|
64
|
-
get(): Promise<DocumentSnapshot<T>>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface CollectionReference<T = unknown> {
|
|
68
|
-
id: string;
|
|
69
|
-
firestore: Firestore;
|
|
70
|
-
path: string;
|
|
71
|
-
parent: CollectionReference<unknown> | DocumentReference<unknown> | null;
|
|
72
|
-
doc(documentPath?: string): DocumentReference<T>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface Query<T = unknown> {
|
|
76
|
-
firestore: Firestore;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// =============================================================================
|
|
80
|
-
// Firestore Types - Field Values
|
|
81
|
-
// =============================================================================
|
|
82
|
-
|
|
83
|
-
export type FieldPath = string | readonly string[];
|
|
84
|
-
|
|
85
|
-
export interface FieldValue {
|
|
86
|
-
isEqual(other: unknown): boolean;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface Bytes {
|
|
90
|
-
toUint8Array(): Uint8Array;
|
|
91
|
-
toBase64(): string;
|
|
92
|
-
toString(format?: 'base64' | 'base64url'): string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// =============================================================================
|
|
96
|
-
// Firestore Types - Timestamp
|
|
97
|
-
// =============================================================================
|
|
98
|
-
|
|
99
|
-
export class Timestamp {
|
|
100
|
-
readonly seconds: number;
|
|
101
|
-
readonly nanoseconds: number;
|
|
102
|
-
|
|
103
|
-
constructor(seconds: number, nanoseconds: number);
|
|
104
|
-
|
|
105
|
-
static now(): Timestamp;
|
|
106
|
-
static fromDate(date: Date): Timestamp;
|
|
107
|
-
static fromMillis(milliseconds: number): Timestamp;
|
|
108
|
-
|
|
109
|
-
toDate(): Date;
|
|
110
|
-
toMillis(): number;
|
|
111
|
-
toString(): string;
|
|
112
|
-
isEqual(other: Timestamp): boolean;
|
|
113
|
-
|
|
114
|
-
valueOf(): number {
|
|
115
|
-
return this.toMillis();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// =============================================================================
|
|
120
|
-
// Firestore Types - GeoPoint
|
|
121
|
-
// =============================================================================
|
|
122
|
-
|
|
123
|
-
export class GeoPoint {
|
|
124
|
-
readonly latitude: number;
|
|
125
|
-
readonly longitude: number;
|
|
126
|
-
|
|
127
|
-
constructor(latitude: number, longitude: number);
|
|
128
|
-
|
|
129
|
-
toString(): string;
|
|
130
|
-
isEqual(other: GeoPoint): boolean;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// =============================================================================
|
|
134
|
-
// Firestore Types - Transaction
|
|
135
|
-
// =============================================================================
|
|
136
|
-
|
|
137
|
-
export interface Transaction {
|
|
138
|
-
get(documentRef: DocumentReference): Promise<DocumentSnapshot>;
|
|
139
|
-
set(documentRef: DocumentReference, data: unknown): Promise<void>;
|
|
140
|
-
update(documentRef: DocumentReference, data: Partial<unknown>): Promise<void>;
|
|
141
|
-
delete(documentRef: DocumentReference): Promise<void>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// =============================================================================
|
|
145
|
-
// Firestore Types - Query
|
|
146
|
-
// =============================================================================
|
|
147
|
-
|
|
148
|
-
export type WhereFilterOp =
|
|
149
|
-
| '<'
|
|
150
|
-
| '<='
|
|
151
|
-
| '=='
|
|
152
|
-
| '!='
|
|
153
|
-
| '>='
|
|
154
|
-
| '>'
|
|
155
|
-
| 'array-contains'
|
|
156
|
-
| 'in'
|
|
157
|
-
| 'array-contains-any'
|
|
158
|
-
| 'not-in';
|
|
159
|
-
|
|
160
|
-
export type OrderByDirection = 'asc' | 'desc';
|
|
161
|
-
|
|
162
|
-
export type QueryConstraint = QueryFilterConstraint | QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint;
|
|
163
|
-
|
|
164
|
-
export interface QueryFilterConstraint {
|
|
165
|
-
type: 'where';
|
|
166
|
-
fieldPath: FieldPath;
|
|
167
|
-
op: WhereFilterOp;
|
|
168
|
-
value: unknown;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export interface QueryOrderByConstraint {
|
|
172
|
-
type: 'orderBy';
|
|
173
|
-
fieldPath: FieldPath;
|
|
174
|
-
direction?: OrderByDirection;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface QueryLimitConstraint {
|
|
178
|
-
type: 'limit';
|
|
179
|
-
limit: number;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export interface QueryStartAtConstraint {
|
|
183
|
-
type: 'startAt';
|
|
184
|
-
cursor: unknown;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export interface QueryEndAtConstraint {
|
|
188
|
-
type: 'endAt';
|
|
189
|
-
cursor: unknown;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// =============================================================================
|
|
193
|
-
// Auth Types
|
|
194
|
-
// =============================================================================
|
|
195
|
-
|
|
196
|
-
export interface Auth {
|
|
197
|
-
app: FirebaseApp;
|
|
198
|
-
currentUser: User | null;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export interface User {
|
|
202
|
-
uid: string;
|
|
203
|
-
email: string | null;
|
|
204
|
-
emailVerified: boolean;
|
|
205
|
-
displayName: string | null;
|
|
206
|
-
photoURL: string | null;
|
|
207
|
-
phoneNumber: string | null;
|
|
208
|
-
tenantId: string | null;
|
|
209
|
-
providerId: string;
|
|
210
|
-
metadata: UserMetadata;
|
|
211
|
-
isAnonymous: boolean;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export interface UserMetadata {
|
|
215
|
-
creationTime?: string;
|
|
216
|
-
lastSignInTime?: string | null;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export interface UserCredential {
|
|
220
|
-
user: User;
|
|
221
|
-
providerId: string | null;
|
|
222
|
-
operationType?: string;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export interface AuthCredential {
|
|
226
|
-
providerId: string;
|
|
227
|
-
signInMethod: string;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// =============================================================================
|
|
231
|
-
// Error Types
|
|
232
|
-
// =============================================================================
|
|
233
|
-
|
|
234
|
-
export interface FirestoreError {
|
|
235
|
-
code: string;
|
|
236
|
-
message: string;
|
|
237
|
-
name: string;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export interface AuthError {
|
|
241
|
-
code: string;
|
|
242
|
-
message: string;
|
|
243
|
-
name: string;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export interface FirebaseError extends Error {
|
|
247
|
-
code: string;
|
|
248
|
-
name: string;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// =============================================================================
|
|
252
|
-
// Change Type
|
|
253
|
-
// =============================================================================
|
|
254
|
-
|
|
255
|
-
export type DocumentChangeType = 'added' | 'removed' | 'modified';
|
|
256
|
-
|
|
257
|
-
export interface DocumentChange<T = unknown> {
|
|
258
|
-
type: DocumentChangeType;
|
|
259
|
-
doc: QueryDocumentSnapshot<T>;
|
|
260
|
-
oldIndex?: number;
|
|
261
|
-
newIndex?: number;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// =============================================================================
|
|
265
|
-
// Blob Types
|
|
266
|
-
// =============================================================================
|
|
267
|
-
|
|
268
|
-
export interface Blob {
|
|
269
|
-
bytes: Uint8Array;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export function blob(bytes: Uint8Array): Blob {
|
|
273
|
-
return { bytes };
|
|
274
|
-
}
|