@umituz/react-native-firebase 2.6.3 → 2.6.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.
Files changed (108) hide show
  1. package/package.json +1 -1
  2. package/src/application/auth/index.ts +2 -34
  3. package/src/application/auth/use-cases/index.ts +1 -21
  4. package/src/domains/account-deletion/domain/index.ts +1 -8
  5. package/src/domains/account-deletion/index.ts +0 -42
  6. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts +79 -0
  7. package/src/domains/account-deletion/infrastructure/services/AccountDeletionTypes.ts +0 -1
  8. package/src/domains/account-deletion/infrastructure/services/account-deletion.service.ts +2 -14
  9. package/src/domains/auth/index.ts +3 -12
  10. package/src/domains/auth/infrastructure/config/FirebaseAuthClient.ts +48 -60
  11. package/src/domains/auth/infrastructure/config/index.ts +2 -0
  12. package/src/domains/auth/infrastructure/config/initializers/index.ts +1 -0
  13. package/src/domains/auth/infrastructure/services/index.ts +16 -0
  14. package/src/domains/auth/infrastructure/services/utils/index.ts +1 -0
  15. package/src/domains/auth/infrastructure/stores/index.ts +1 -0
  16. package/src/domains/auth/infrastructure/utils/index.ts +1 -0
  17. package/src/domains/auth/infrastructure.ts +11 -0
  18. package/src/domains/auth/presentation/hooks/useGoogleOAuth.ts +18 -59
  19. package/src/domains/firestore/domain/entities/Collection.ts +0 -2
  20. package/src/domains/firestore/domain/index.ts +6 -2
  21. package/src/domains/firestore/domain/value-objects/WhereClause.ts +0 -14
  22. package/src/domains/firestore/index.ts +0 -1
  23. package/src/domains/firestore/infrastructure/config/FirestoreClient.ts +42 -60
  24. package/src/domains/firestore/presentation/hooks/useFirestoreMutation.ts +1 -1
  25. package/src/domains/firestore/presentation/hooks/useFirestoreQuery.ts +1 -1
  26. package/src/shared/infrastructure/base/ErrorHandler.ts +81 -0
  27. package/src/shared/infrastructure/base/ServiceBase.ts +62 -0
  28. package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts +39 -0
  29. package/src/application/auth/ports/AuthPort.ts.bak +0 -164
  30. package/src/application/auth/ports/AuthPort_part_aa +0 -150
  31. package/src/application/auth/ports/AuthPort_part_ab +0 -14
  32. package/src/application/auth/use-cases/SignInUseCase.ts.bak +0 -253
  33. package/src/application/auth/use-cases/SignInUseCaseHelpers.ts +0 -0
  34. package/src/application/auth/use-cases/SignInUseCaseMain.ts +0 -0
  35. package/src/application/auth/use-cases/SignInUseCase_part_aa +0 -150
  36. package/src/application/auth/use-cases/SignInUseCase_part_ab +0 -103
  37. package/src/application/auth/use-cases/SignOutUseCase.ts.bak +0 -288
  38. package/src/application/auth/use-cases/SignOutUseCaseCleanup.ts +0 -0
  39. package/src/application/auth/use-cases/SignOutUseCaseMain.ts +0 -0
  40. package/src/application/auth/use-cases/SignOutUseCase_part_aa +0 -150
  41. package/src/application/auth/use-cases/SignOutUseCase_part_ab +0 -138
  42. package/src/domains/account-deletion/domain/services/UserValidationHelpers.ts.bak +0 -181
  43. package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_aa +0 -150
  44. package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_ab +0 -31
  45. package/src/domains/account-deletion/domain/services/UserValidationService.ts.bak +0 -286
  46. package/src/domains/account-deletion/domain/services/UserValidationService_part_aa +0 -150
  47. package/src/domains/account-deletion/domain/services/UserValidationService_part_ab +0 -136
  48. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts.bak +0 -230
  49. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_aa +0 -150
  50. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_ab +0 -80
  51. package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler.ts.bak +0 -174
  52. package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_aa +0 -150
  53. package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_ab +0 -24
  54. package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository.ts.bak +0 -266
  55. package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_aa +0 -150
  56. package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_ab +0 -116
  57. package/src/domains/account-deletion/infrastructure/services/reauthentication.service.ts.bak +0 -160
  58. package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_aa +0 -150
  59. package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_ab +0 -10
  60. package/src/domains/auth/infrastructure.ts.bak +0 -156
  61. package/src/domains/auth/infrastructure_part_aa +0 -150
  62. package/src/domains/auth/infrastructure_part_ab +0 -6
  63. package/src/domains/auth/presentation/hooks/GoogleOAuthHelpers.ts +0 -0
  64. package/src/domains/auth/presentation/hooks/GoogleOAuthHookService.ts.bak +0 -247
  65. package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_aa +0 -150
  66. package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_ab +0 -97
  67. package/src/domains/auth/presentation/hooks/GoogleOAuthService.ts +0 -0
  68. package/src/domains/firestore/domain/entities/Collection.ts.bak +0 -288
  69. package/src/domains/firestore/domain/entities/Collection_part_aa +0 -150
  70. package/src/domains/firestore/domain/entities/Collection_part_ab +0 -138
  71. package/src/domains/firestore/domain/entities/Document.ts.bak +0 -233
  72. package/src/domains/firestore/domain/entities/DocumentHelpers.ts +0 -0
  73. package/src/domains/firestore/domain/entities/DocumentMain.ts +0 -0
  74. package/src/domains/firestore/domain/entities/Document_part_aa +0 -150
  75. package/src/domains/firestore/domain/entities/Document_part_ab +0 -83
  76. package/src/domains/firestore/domain/services/QueryService.ts.bak +0 -182
  77. package/src/domains/firestore/domain/services/QueryServiceAnalysis.ts.bak +0 -169
  78. package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_aa +0 -150
  79. package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_ab +0 -19
  80. package/src/domains/firestore/domain/services/QueryServiceHelpers.ts.bak +0 -151
  81. package/src/domains/firestore/domain/services/QueryServiceHelpers_part_aa +0 -150
  82. package/src/domains/firestore/domain/services/QueryServiceHelpers_part_ab +0 -1
  83. package/src/domains/firestore/domain/services/QueryService_part_aa +0 -150
  84. package/src/domains/firestore/domain/services/QueryService_part_ab +0 -32
  85. package/src/domains/firestore/domain/value-objects/QueryOptions.ts.bak +0 -191
  86. package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization.ts.bak +0 -207
  87. package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_aa +0 -150
  88. package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_ab +0 -57
  89. package/src/domains/firestore/domain/value-objects/QueryOptionsValidation.ts.bak +0 -182
  90. package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_aa +0 -150
  91. package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_ab +0 -32
  92. package/src/domains/firestore/domain/value-objects/QueryOptions_part_aa +0 -150
  93. package/src/domains/firestore/domain/value-objects/QueryOptions_part_ab +0 -41
  94. package/src/domains/firestore/domain/value-objects/WhereClause.ts.bak +0 -299
  95. package/src/domains/firestore/domain/value-objects/WhereClauseFactory.ts.bak +0 -207
  96. package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_aa +0 -150
  97. package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_ab +0 -57
  98. package/src/domains/firestore/domain/value-objects/WhereClause_part_aa +0 -150
  99. package/src/domains/firestore/domain/value-objects/WhereClause_part_ab +0 -149
  100. package/src/shared/infrastructure/base/ErrorHandler.ts.bak +0 -189
  101. package/src/shared/infrastructure/base/ErrorHandler_part_aa +0 -150
  102. package/src/shared/infrastructure/base/ErrorHandler_part_ab +0 -39
  103. package/src/shared/infrastructure/base/ServiceBase.ts.bak +0 -220
  104. package/src/shared/infrastructure/base/ServiceBase_part_aa +0 -150
  105. package/src/shared/infrastructure/base/ServiceBase_part_ab +0 -70
  106. package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts.bak +0 -155
  107. package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_aa +0 -150
  108. package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_ab +0 -5
@@ -3,14 +3,11 @@
3
3
  *
4
4
  * Domain-Driven Design: Infrastructure implementation of Firestore client
5
5
  * Singleton pattern for managing Firestore instance
6
- *
7
- * IMPORTANT: This package requires Firebase App to be initialized first.
8
- * Use @umituz/react-native-firebase to initialize Firebase App.
9
6
  */
10
7
 
11
8
  import type { Firestore } from 'firebase/firestore';
9
+ import { getFirestore as getFirestoreFromFirebase } from 'firebase/firestore';
12
10
  import { getFirebaseApp } from '../../../../shared/infrastructure/config/services/FirebaseInitializationService';
13
- import { FirebaseFirestoreInitializer } from './initializers/FirebaseFirestoreInitializer';
14
11
  import { ServiceClientSingleton } from '../../../../shared/infrastructure/config/base/ServiceClientSingleton';
15
12
 
16
13
  /**
@@ -19,79 +16,64 @@ import { ServiceClientSingleton } from '../../../../shared/infrastructure/config
19
16
  */
20
17
  class FirestoreClientSingleton extends ServiceClientSingleton<Firestore> {
21
18
  private constructor() {
22
- super({
23
- serviceName: 'Firestore',
24
- initializer: () => {
25
- const app = getFirebaseApp();
26
- if (!app) {
27
- this.setError('Firebase App is not initialized');
28
- return null;
29
- }
30
- return FirebaseFirestoreInitializer.initialize(app);
31
- },
32
- autoInitializer: () => {
33
- const app = getFirebaseApp();
34
- if (!app) return null;
35
- return FirebaseFirestoreInitializer.initialize(app);
36
- },
37
- });
19
+ super();
38
20
  }
39
21
 
40
- private static instance: FirestoreClientSingleton | null = null;
22
+ initialize(): Firestore {
23
+ try {
24
+ const app = getFirebaseApp();
25
+ if (!app) {
26
+ this.setError('Firebase App is not initialized');
27
+ throw new Error('Firebase App is not initialized');
28
+ }
41
29
 
42
- static getInstance(): FirestoreClientSingleton {
43
- if (!this.instance) {
44
- this.instance = new FirestoreClientSingleton();
30
+ const firestore = getFirestoreFromFirebase(app);
31
+ this.instance = firestore;
32
+ return firestore;
33
+ } catch (error) {
34
+ const errorMessage = error instanceof Error ? error.message : 'Firestore initialization failed';
35
+ this.setError(errorMessage);
36
+ throw error;
45
37
  }
46
- return this.instance;
47
38
  }
48
39
 
49
- /**
50
- * Initialize Firestore
51
- */
52
- override initialize(): Firestore | null {
53
- return super.initialize();
40
+ getFirestore(): Firestore {
41
+ if (!this.isInitialized()) {
42
+ return this.initialize();
43
+ }
44
+ return this.getInstance();
54
45
  }
55
46
 
56
- /**
57
- * Get Firestore instance with auto-initialization
58
- */
59
- getFirestore(): Firestore | null {
60
- return this.getInstance(true);
61
- }
62
- }
47
+ private static instance: FirestoreClientSingleton | null = null;
63
48
 
64
- function getFirestoreClientSafe(): FirestoreClientSingleton | null {
65
- try {
66
- return FirestoreClientSingleton.getInstance();
67
- } catch (error) {
68
- if (__DEV__) {
69
- console.error('[Firestore] Could not create Firestore client singleton:', error);
49
+ static getInstance(): FirestoreClientSingleton {
50
+ if (!this.instance) {
51
+ this.instance = new FirestoreClientSingleton();
70
52
  }
71
- return null;
53
+ return this.instance;
72
54
  }
73
55
  }
74
56
 
75
- export const firestoreClient = getFirestoreClientSafe();
57
+ const firestoreClientSingleton = FirestoreClientSingleton.getInstance();
76
58
 
77
- export function initializeFirestore(): Firestore | null {
78
- return firestoreClient?.initialize() ?? null;
79
- }
59
+ export const initializeFirestore = (): Firestore => {
60
+ return firestoreClientSingleton.initialize();
61
+ };
80
62
 
81
- export function getFirestore(): Firestore | null {
82
- return firestoreClient?.getFirestore() ?? null;
83
- }
63
+ export const getFirestore = (): Firestore => {
64
+ return firestoreClientSingleton.getFirestore();
65
+ };
84
66
 
85
- export function isFirestoreInitialized(): boolean {
86
- return firestoreClient?.isInitialized() ?? false;
87
- }
67
+ export const isFirestoreInitialized = (): boolean => {
68
+ return firestoreClientSingleton.isInitialized();
69
+ };
88
70
 
89
- export function getFirestoreInitializationError(): string | null {
90
- return firestoreClient?.getInitializationError() ?? null;
91
- }
71
+ export const getFirestoreInitializationError = (): Error | null => {
72
+ return firestoreClientSingleton.getInitializationError();
73
+ };
92
74
 
93
- export function resetFirestoreClient(): void {
94
- firestoreClient?.reset();
95
- }
75
+ export const resetFirestoreClient = (): void => {
76
+ firestoreClientSingleton.reset();
77
+ };
96
78
 
97
79
  export type { Firestore } from 'firebase/firestore';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * useFirestoreMutation
3
3
  *
4
- * TanStack Mutation wrapper for Firestore write operations.
4
+ * TanStack Mutation integration for Firestore write operations.
5
5
  * Automatically invalidates specified query keys on success.
6
6
  *
7
7
  * @example
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * useFirestoreQuery
3
3
  *
4
- * TanStack Query wrapper optimized for Firestore data fetching.
4
+ * TanStack Query integration for Firestore data fetching.
5
5
  * Provides Firestore-aware defaults, retry logic, and error handling.
6
6
  *
7
7
  * @example
@@ -0,0 +1,81 @@
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();
@@ -0,0 +1,62 @@
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
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Service Client Singleton Base
3
+ * Base singleton pattern for service clients
4
+ *
5
+ * Max lines: 150 (enforced for maintainability)
6
+ */
7
+
8
+ export abstract class ServiceClientSingleton<TInstance, TConfig = unknown> {
9
+ protected instance: TInstance | null = null;
10
+ protected initializationError: Error | null = null;
11
+
12
+ protected constructor() {}
13
+
14
+ abstract initialize(config?: TConfig): Promise<TInstance> | TInstance;
15
+
16
+ getInstance(): TInstance {
17
+ if (!this.instance) {
18
+ throw new Error('Service not initialized. Call initialize() first.');
19
+ }
20
+ return this.instance;
21
+ }
22
+
23
+ isInitialized(): boolean {
24
+ return this.instance !== null;
25
+ }
26
+
27
+ getInitializationError(): Error | null {
28
+ return this.initializationError;
29
+ }
30
+
31
+ setError(message: string): void {
32
+ this.initializationError = new Error(message);
33
+ }
34
+
35
+ reset(): void {
36
+ this.instance = null;
37
+ this.initializationError = null;
38
+ }
39
+ }
@@ -1,164 +0,0 @@
1
- /**
2
- * Auth Port
3
- * Single Responsibility: Define authentication contract
4
- *
5
- * Port interface for authentication operations.
6
- * Defines the contract that infrastructure must implement.
7
- *
8
- * Max lines: 150 (enforced for maintainability)
9
- */
10
-
11
- import type { User, Auth } from 'firebase/auth';
12
- import type { Result } from '../../../shared/domain/utils';
13
-
14
- /**
15
- * Email credentials
16
- */
17
- export interface EmailCredentials {
18
- readonly email: string;
19
- readonly password: string;
20
- }
21
-
22
- /**
23
- * Sign in result
24
- */
25
- export interface SignInResult {
26
- readonly user: User;
27
- readonly isNewUser: boolean;
28
- }
29
-
30
- /**
31
- * Sign up result
32
- */
33
- export interface SignUpResult {
34
- readonly user: User;
35
- readonly userId: string;
36
- }
37
-
38
- /**
39
- * Auth port interface
40
- * Defines contract for authentication operations
41
- */
42
- export interface IAuthPort {
43
- /**
44
- * Sign in with email and password
45
- */
46
- signInWithEmail(credentials: EmailCredentials): Promise<Result<SignInResult>>;
47
-
48
- /**
49
- * Sign up with email and password
50
- */
51
- signUpWithEmail(credentials: EmailCredentials): Promise<Result<SignUpResult>>;
52
-
53
- /**
54
- * Sign out current user
55
- */
56
- signOut(): Promise<Result<void>>;
57
-
58
- /**
59
- * Get current authenticated user
60
- */
61
- getCurrentUser(): User | null;
62
-
63
- /**
64
- * Get current user ID
65
- */
66
- getCurrentUserId(): string | null;
67
-
68
- /**
69
- * Check if user is authenticated
70
- */
71
- isAuthenticated(): boolean;
72
-
73
- /**
74
- * Check if user is anonymous
75
- */
76
- isAnonymous(): boolean;
77
-
78
- /**
79
- * Delete user account
80
- */
81
- deleteAccount(): Promise<Result<void>>;
82
-
83
- /**
84
- * Update user password
85
- */
86
- updatePassword(newPassword: string): Promise<Result<void>>;
87
-
88
- /**
89
- * Send password reset email
90
- */
91
- sendPasswordResetEmail(email: string): Promise<Result<void>>;
92
-
93
- /**
94
- * Get auth instance
95
- */
96
- getAuth(): Auth | null;
97
- }
98
-
99
- /**
100
- * Auth port options
101
- */
102
- export interface AuthPortOptions {
103
- /** Auto-initialize auth on first access */
104
- autoInitialize?: boolean;
105
- /** Enable detailed logging */
106
- enableLogging?: boolean;
107
- }
108
-
109
- /**
110
- * Auth port configuration
111
- */
112
- export interface AuthPortConfig {
113
- readonly port: IAuthPort;
114
- readonly options: AuthPortOptions;
115
- }
116
-
117
- /**
118
- * Create auth port configuration
119
- */
120
- export function createAuthPortConfig(
121
- port: IAuthPort,
122
- options: AuthPortOptions = {}
123
- ): AuthPortConfig {
124
- return {
125
- port,
126
- options: {
127
- autoInitialize: true,
128
- enableLogging: __DEV__,
129
- ...options,
130
- },
131
- };
132
- }
133
-
134
- /**
135
- * Auth port factory
136
- * Creates auth port instances
137
- */
138
- export interface IAuthPortFactory {
139
- createPort(options?: AuthPortOptions): IAuthPort;
140
- }
141
-
142
- /**
143
- * Default auth port factory
144
- * Implements factory pattern for auth ports
145
- */
146
- export class AuthPortFactory implements IAuthPortFactory {
147
- createPort(options?: AuthPortOptions): IAuthPort {
148
- // Import and create actual implementation
149
- const { FirebaseAuthPort } = require('../implementations/FirebaseAuthPort');
150
- return new FirebaseAuthPort(options);
151
- }
152
- }
153
-
154
- /**
155
- * Default auth port factory instance
156
- */
157
- export const authPortFactory = new AuthPortFactory();
158
-
159
- /**
160
- * Create auth port with default factory
161
- */
162
- export function createAuthPort(options?: AuthPortOptions): IAuthPort {
163
- return authPortFactory.createPort(options);
164
- }
@@ -1,150 +0,0 @@
1
- /**
2
- * Auth Port
3
- * Single Responsibility: Define authentication contract
4
- *
5
- * Port interface for authentication operations.
6
- * Defines the contract that infrastructure must implement.
7
- *
8
- * Max lines: 150 (enforced for maintainability)
9
- */
10
-
11
- import type { User, Auth } from 'firebase/auth';
12
- import type { Result } from '../../../shared/domain/utils';
13
-
14
- /**
15
- * Email credentials
16
- */
17
- export interface EmailCredentials {
18
- readonly email: string;
19
- readonly password: string;
20
- }
21
-
22
- /**
23
- * Sign in result
24
- */
25
- export interface SignInResult {
26
- readonly user: User;
27
- readonly isNewUser: boolean;
28
- }
29
-
30
- /**
31
- * Sign up result
32
- */
33
- export interface SignUpResult {
34
- readonly user: User;
35
- readonly userId: string;
36
- }
37
-
38
- /**
39
- * Auth port interface
40
- * Defines contract for authentication operations
41
- */
42
- export interface IAuthPort {
43
- /**
44
- * Sign in with email and password
45
- */
46
- signInWithEmail(credentials: EmailCredentials): Promise<Result<SignInResult>>;
47
-
48
- /**
49
- * Sign up with email and password
50
- */
51
- signUpWithEmail(credentials: EmailCredentials): Promise<Result<SignUpResult>>;
52
-
53
- /**
54
- * Sign out current user
55
- */
56
- signOut(): Promise<Result<void>>;
57
-
58
- /**
59
- * Get current authenticated user
60
- */
61
- getCurrentUser(): User | null;
62
-
63
- /**
64
- * Get current user ID
65
- */
66
- getCurrentUserId(): string | null;
67
-
68
- /**
69
- * Check if user is authenticated
70
- */
71
- isAuthenticated(): boolean;
72
-
73
- /**
74
- * Check if user is anonymous
75
- */
76
- isAnonymous(): boolean;
77
-
78
- /**
79
- * Delete user account
80
- */
81
- deleteAccount(): Promise<Result<void>>;
82
-
83
- /**
84
- * Update user password
85
- */
86
- updatePassword(newPassword: string): Promise<Result<void>>;
87
-
88
- /**
89
- * Send password reset email
90
- */
91
- sendPasswordResetEmail(email: string): Promise<Result<void>>;
92
-
93
- /**
94
- * Get auth instance
95
- */
96
- getAuth(): Auth | null;
97
- }
98
-
99
- /**
100
- * Auth port options
101
- */
102
- export interface AuthPortOptions {
103
- /** Auto-initialize auth on first access */
104
- autoInitialize?: boolean;
105
- /** Enable detailed logging */
106
- enableLogging?: boolean;
107
- }
108
-
109
- /**
110
- * Auth port configuration
111
- */
112
- export interface AuthPortConfig {
113
- readonly port: IAuthPort;
114
- readonly options: AuthPortOptions;
115
- }
116
-
117
- /**
118
- * Create auth port configuration
119
- */
120
- export function createAuthPortConfig(
121
- port: IAuthPort,
122
- options: AuthPortOptions = {}
123
- ): AuthPortConfig {
124
- return {
125
- port,
126
- options: {
127
- autoInitialize: true,
128
- enableLogging: __DEV__,
129
- ...options,
130
- },
131
- };
132
- }
133
-
134
- /**
135
- * Auth port factory
136
- * Creates auth port instances
137
- */
138
- export interface IAuthPortFactory {
139
- createPort(options?: AuthPortOptions): IAuthPort;
140
- }
141
-
142
- /**
143
- * Default auth port factory
144
- * Implements factory pattern for auth ports
145
- */
146
- export class AuthPortFactory implements IAuthPortFactory {
147
- createPort(options?: AuthPortOptions): IAuthPort {
148
- // Import and create actual implementation
149
- const { FirebaseAuthPort } = require('../implementations/FirebaseAuthPort');
150
- return new FirebaseAuthPort(options);
@@ -1,14 +0,0 @@
1
- }
2
- }
3
-
4
- /**
5
- * Default auth port factory instance
6
- */
7
- export const authPortFactory = new AuthPortFactory();
8
-
9
- /**
10
- * Create auth port with default factory
11
- */
12
- export function createAuthPort(options?: AuthPortOptions): IAuthPort {
13
- return authPortFactory.createPort(options);
14
- }