@umituz/web-firebase 1.0.4 → 2.0.1

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 (75) hide show
  1. package/README.md +555 -0
  2. package/dist/application/index.d.mts +273 -0
  3. package/dist/application/index.d.ts +273 -0
  4. package/dist/application/index.js +490 -0
  5. package/dist/application/index.mjs +19 -0
  6. package/dist/chunk-34DL2QWQ.mjs +87 -0
  7. package/dist/chunk-4FP2ELQ5.mjs +96 -0
  8. package/dist/chunk-7TX3OU3O.mjs +721 -0
  9. package/dist/chunk-I6WGBPFB.mjs +439 -0
  10. package/dist/chunk-RZ4QR6TB.mjs +96 -0
  11. package/dist/chunk-U2XI4MGO.mjs +397 -0
  12. package/dist/domain/index.d.mts +325 -0
  13. package/dist/domain/index.d.ts +325 -0
  14. package/dist/domain/index.js +662 -0
  15. package/dist/domain/index.mjs +36 -0
  16. package/dist/file.repository.interface-v5vHgVsZ.d.mts +241 -0
  17. package/dist/file.repository.interface-v5vHgVsZ.d.ts +241 -0
  18. package/dist/firebase.entity-xvfEPjXZ.d.mts +15 -0
  19. package/dist/firebase.entity-xvfEPjXZ.d.ts +15 -0
  20. package/dist/index.d.mts +14 -96
  21. package/dist/index.d.ts +14 -96
  22. package/dist/index.js +1717 -78
  23. package/dist/index.mjs +88 -175
  24. package/dist/infrastructure/index.d.mts +170 -0
  25. package/dist/infrastructure/index.d.ts +170 -0
  26. package/dist/infrastructure/index.js +856 -0
  27. package/dist/infrastructure/index.mjs +46 -0
  28. package/dist/presentation/index.d.mts +25 -0
  29. package/dist/presentation/index.d.ts +25 -0
  30. package/dist/presentation/index.js +105 -0
  31. package/dist/presentation/index.mjs +6 -0
  32. package/dist/user.repository.interface-DS74TsJ5.d.mts +298 -0
  33. package/dist/user.repository.interface-DS74TsJ5.d.ts +298 -0
  34. package/package.json +39 -12
  35. package/src/application/dto/auth.dto.ts +69 -0
  36. package/src/application/dto/index.ts +7 -0
  37. package/src/application/dto/user.dto.ts +64 -0
  38. package/src/application/index.ts +7 -0
  39. package/src/application/use-cases/auth/reset-password.use-case.ts +66 -0
  40. package/src/application/use-cases/auth/sign-in-with-google.use-case.ts +86 -0
  41. package/src/application/use-cases/auth/sign-in.use-case.ts +77 -0
  42. package/src/application/use-cases/auth/sign-out.use-case.ts +22 -0
  43. package/src/application/use-cases/auth/sign-up.use-case.ts +99 -0
  44. package/src/application/use-cases/index.ts +12 -0
  45. package/src/application/use-cases/user/delete-account.use-case.ts +77 -0
  46. package/src/application/use-cases/user/update-profile.use-case.ts +98 -0
  47. package/src/domain/entities/file.entity.ts +151 -0
  48. package/src/domain/entities/firebase.entity.ts +13 -0
  49. package/src/domain/entities/timestamp.entity.ts +116 -0
  50. package/src/domain/entities/user.entity.ts +193 -0
  51. package/src/domain/errors/auth.errors.ts +115 -0
  52. package/src/domain/errors/repository.errors.ts +121 -0
  53. package/src/domain/index.ts +30 -0
  54. package/src/domain/interfaces/auth.repository.interface.ts +83 -0
  55. package/src/domain/interfaces/file.repository.interface.ts +143 -0
  56. package/src/domain/interfaces/repository.interface.ts +11 -0
  57. package/src/domain/interfaces/user.repository.interface.ts +75 -0
  58. package/src/domain/value-objects/email.vo.ts +105 -0
  59. package/src/domain/value-objects/file-path.vo.ts +184 -0
  60. package/src/domain/value-objects/user-id.vo.ts +87 -0
  61. package/src/index.ts +23 -0
  62. package/src/infrastructure/firebase/auth.adapter.ts +220 -0
  63. package/src/infrastructure/firebase/client.ts +141 -0
  64. package/src/infrastructure/firebase/firestore.adapter.ts +190 -0
  65. package/src/infrastructure/firebase/storage.adapter.ts +323 -0
  66. package/src/infrastructure/index.ts +13 -0
  67. package/src/infrastructure/services/firebase.service.ts +30 -0
  68. package/src/infrastructure/services/firestore.repository.ts +66 -0
  69. package/src/infrastructure/utils/storage.util.ts +46 -0
  70. package/src/presentation/hooks/useAuth.ts +153 -0
  71. package/src/presentation/hooks/useFirebaseAuth.ts +122 -0
  72. package/src/presentation/hooks/useFirestore.ts +125 -0
  73. package/src/presentation/hooks/useStorage.ts +141 -0
  74. package/src/presentation/index.ts +6 -0
  75. package/src/presentation/providers/FirebaseProvider.tsx +40 -0
package/dist/index.mjs CHANGED
@@ -1,184 +1,97 @@
1
- // src/infrastructure/services/firebase.service.ts
2
- import { initializeApp, getApps } from "firebase/app";
3
- import { getAuth } from "firebase/auth";
4
- import { getFirestore } from "firebase/firestore";
5
- import { getStorage } from "firebase/storage";
6
- import { getFunctions } from "firebase/functions";
7
- function initializeFirebase(config, appName) {
8
- const existing = getApps().find((a) => a.name === (appName ?? "[DEFAULT]"));
9
- const app = existing ?? initializeApp(config, appName);
10
- return {
11
- app,
12
- auth: getAuth(app),
13
- db: getFirestore(app),
14
- storage: getStorage(app),
15
- functions: getFunctions(app)
16
- };
17
- }
18
-
19
- // src/infrastructure/services/firestore.repository.ts
20
1
  import {
21
- collection,
22
- doc,
23
- getDoc,
24
- getDocs,
25
- setDoc,
26
- updateDoc,
27
- deleteDoc,
28
- query
29
- } from "firebase/firestore";
30
- var FirestoreRepository = class {
31
- constructor(db, collectionName) {
32
- this.db = db;
33
- this.collectionName = collectionName;
34
- }
35
- getCollection(parentPath) {
36
- const fullPath = parentPath ? `${parentPath}/${this.collectionName}` : this.collectionName;
37
- return collection(this.db, fullPath);
38
- }
39
- getDocRef(id, parentPath) {
40
- const fullPath = parentPath ? `${parentPath}/${this.collectionName}` : this.collectionName;
41
- return doc(this.db, fullPath, id);
42
- }
43
- async getById(id, parentPath) {
44
- const snap = await getDoc(this.getDocRef(id, parentPath));
45
- return snap.exists() ? { id: snap.id, ...snap.data() } : null;
46
- }
47
- async getAll(constraints = [], parentPath) {
48
- const q = query(this.getCollection(parentPath), ...constraints);
49
- const snap = await getDocs(q);
50
- return snap.docs.map((d) => ({ id: d.id, ...d.data() }));
51
- }
52
- async create(id, data, parentPath) {
53
- await setDoc(this.getDocRef(id, parentPath), {
54
- ...data,
55
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
56
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
57
- });
58
- }
59
- async update(id, data, parentPath) {
60
- await updateDoc(this.getDocRef(id, parentPath), {
61
- ...data,
62
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
63
- });
64
- }
65
- async delete(id, parentPath) {
66
- await deleteDoc(this.getDocRef(id, parentPath));
67
- }
68
- };
69
-
70
- // src/infrastructure/utils/storage.util.ts
2
+ DeleteAccountUseCase,
3
+ ResetPasswordUseCase,
4
+ SignInUseCase,
5
+ SignInWithGoogleUseCase,
6
+ SignOutUseCase,
7
+ SignUpUseCase,
8
+ UpdateProfileUseCase
9
+ } from "./chunk-U2XI4MGO.mjs";
10
+ import {
11
+ Email,
12
+ FileErrorCode,
13
+ FilePath,
14
+ Timestamp,
15
+ USER_COLLECTIONS,
16
+ USER_SUBCOLLECTIONS,
17
+ UserId,
18
+ serverTimestamp
19
+ } from "./chunk-I6WGBPFB.mjs";
20
+ import {
21
+ AuthAdapter,
22
+ FirestoreAdapter,
23
+ StorageAdapter,
24
+ analytics,
25
+ app,
26
+ auth,
27
+ db,
28
+ deleteFile,
29
+ functions,
30
+ getFirebaseAnalytics,
31
+ getFirebaseApp,
32
+ getFirebaseAuth,
33
+ getFirebaseDB,
34
+ getFirebaseFunctions,
35
+ getFirebaseInstances,
36
+ getFirebaseStorage,
37
+ initializeFirebase,
38
+ storage,
39
+ uploadBase64,
40
+ uploadFile
41
+ } from "./chunk-7TX3OU3O.mjs";
71
42
  import {
72
- ref,
73
- uploadBytes,
74
- uploadString,
75
- getDownloadURL,
76
- deleteObject
77
- } from "firebase/storage";
78
- async function uploadFile(storage, path, file) {
79
- const storageRef = ref(storage, path);
80
- await uploadBytes(storageRef, file);
81
- const url = await getDownloadURL(storageRef);
82
- return { url, path };
83
- }
84
- async function uploadBase64(storage, path, base64, mimeType = "image/jpeg") {
85
- const storageRef = ref(storage, path);
86
- const dataUrl = base64.startsWith("data:") ? base64 : `data:${mimeType};base64,${base64}`;
87
- await uploadString(storageRef, dataUrl, "data_url");
88
- const url = await getDownloadURL(storageRef);
89
- return { url, path };
90
- }
91
- async function deleteFile(storage, path) {
92
- await deleteObject(ref(storage, path));
93
- }
94
-
95
- // src/presentation/hooks/useFirebaseAuth.ts
96
- import { useState, useEffect, useCallback } from "react";
43
+ RepositoryError,
44
+ RepositoryErrorCode,
45
+ createRepositoryError
46
+ } from "./chunk-4FP2ELQ5.mjs";
97
47
  import {
98
- onAuthStateChanged,
99
- signInWithEmailAndPassword,
100
- createUserWithEmailAndPassword,
101
- signOut as firebaseSignOut,
102
- updateProfile,
103
- updatePassword,
104
- sendPasswordResetEmail
105
- } from "firebase/auth";
106
- function mapUser(u) {
107
- return {
108
- uid: u.uid,
109
- email: u.email,
110
- displayName: u.displayName,
111
- photoURL: u.photoURL,
112
- emailVerified: u.emailVerified
113
- };
114
- }
115
- function useFirebaseAuth(auth, options) {
116
- const [user, setUser] = useState(null);
117
- const [loading, setLoading] = useState(true);
118
- useEffect(() => {
119
- const unsub = onAuthStateChanged(auth, (firebaseUser) => {
120
- const mapped = firebaseUser ? mapUser(firebaseUser) : null;
121
- setUser(mapped);
122
- setLoading(false);
123
- options?.onUserChange?.(mapped);
124
- });
125
- return unsub;
126
- }, [auth, options]);
127
- const signIn = useCallback(
128
- (email, password) => signInWithEmailAndPassword(auth, email, password),
129
- [auth]
130
- );
131
- const signUp = useCallback(
132
- async (email, password, name) => {
133
- const cred = await createUserWithEmailAndPassword(auth, email, password);
134
- if (name && cred.user) await updateProfile(cred.user, { displayName: name });
135
- return cred;
136
- },
137
- [auth]
138
- );
139
- const signOut = useCallback(() => firebaseSignOut(auth), [auth]);
140
- const updateUserProfile = useCallback(
141
- async (name, photoURL) => {
142
- if (!auth.currentUser) throw new Error("No authenticated user");
143
- await updateProfile(auth.currentUser, {
144
- displayName: name,
145
- ...photoURL !== void 0 && { photoURL }
146
- });
147
- },
148
- [auth]
149
- );
150
- const updateUserPassword = useCallback(
151
- async (newPassword) => {
152
- if (!auth.currentUser) throw new Error("No authenticated user");
153
- await updatePassword(auth.currentUser, newPassword);
154
- },
155
- [auth]
156
- );
157
- const resetPassword = useCallback(
158
- (email) => sendPasswordResetEmail(auth, email),
159
- [auth]
160
- );
161
- const getIdToken = useCallback(async () => {
162
- if (!auth.currentUser) throw new Error("No authenticated user");
163
- return auth.currentUser.getIdToken();
164
- }, [auth]);
165
- return {
166
- user,
167
- loading,
168
- isAuthenticated: !!user,
169
- signIn,
170
- signUp,
171
- signOut,
172
- updateUserProfile,
173
- updateUserPassword,
174
- resetPassword,
175
- getIdToken
176
- };
177
- }
48
+ AuthError,
49
+ AuthErrorCode,
50
+ createAuthError
51
+ } from "./chunk-RZ4QR6TB.mjs";
52
+ import {
53
+ useFirebaseAuth
54
+ } from "./chunk-34DL2QWQ.mjs";
178
55
  export {
179
- FirestoreRepository,
56
+ AuthAdapter,
57
+ AuthError,
58
+ AuthErrorCode,
59
+ DeleteAccountUseCase,
60
+ Email,
61
+ FileErrorCode,
62
+ FilePath,
63
+ FirestoreAdapter,
64
+ RepositoryError,
65
+ RepositoryErrorCode,
66
+ ResetPasswordUseCase,
67
+ SignInUseCase,
68
+ SignInWithGoogleUseCase,
69
+ SignOutUseCase,
70
+ SignUpUseCase,
71
+ StorageAdapter,
72
+ Timestamp,
73
+ USER_COLLECTIONS,
74
+ USER_SUBCOLLECTIONS,
75
+ UpdateProfileUseCase,
76
+ UserId,
77
+ analytics,
78
+ app,
79
+ auth,
80
+ createAuthError,
81
+ createRepositoryError,
82
+ db,
180
83
  deleteFile,
84
+ functions,
85
+ getFirebaseAnalytics,
86
+ getFirebaseApp,
87
+ getFirebaseAuth,
88
+ getFirebaseDB,
89
+ getFirebaseFunctions,
90
+ getFirebaseInstances,
91
+ getFirebaseStorage,
181
92
  initializeFirebase,
93
+ serverTimestamp,
94
+ storage,
182
95
  uploadBase64,
183
96
  uploadFile,
184
97
  useFirebaseAuth
@@ -0,0 +1,170 @@
1
+ import { FirebaseApp } from 'firebase/app';
2
+ import { Auth, UserCredential, User as User$1 } from 'firebase/auth';
3
+ import { Firestore } from 'firebase/firestore';
4
+ import { FirebaseStorage } from 'firebase/storage';
5
+ import { Analytics } from 'firebase/analytics';
6
+ import { Functions } from 'firebase/functions';
7
+ import * as _firebase_util from '@firebase/util';
8
+ import { I as IAuthRepository, c as User, a as IUserRepository } from '../user.repository.interface-DS74TsJ5.mjs';
9
+ import { I as IFileRepository, U as UploadOptions, i as UploadResult, c as FileMetadata, S as StorageStats } from '../file.repository.interface-v5vHgVsZ.mjs';
10
+
11
+ /**
12
+ * Firebase Client
13
+ * @description Firebase initialization and singleton instances
14
+ * Migrated from: /Users/umituz/Desktop/github/umituz/apps/web/app-growth-factory/src/domains/firebase/services/client.ts
15
+ */
16
+
17
+ declare let app: FirebaseApp;
18
+ declare let auth: Auth;
19
+ declare let db: Firestore;
20
+ declare let storage: FirebaseStorage;
21
+ declare let functions: Functions;
22
+ declare let analytics: Analytics | null;
23
+ /**
24
+ * Initialize Firebase App
25
+ */
26
+ declare function initializeFirebase(): FirebaseApp;
27
+ /**
28
+ * Get Firebase App instance
29
+ */
30
+ declare function getFirebaseApp(): FirebaseApp;
31
+ /**
32
+ * Get Firebase Auth instance
33
+ */
34
+ declare function getFirebaseAuth(): Auth;
35
+ /**
36
+ * Get Firestore instance
37
+ */
38
+ declare function getFirebaseDB(): Firestore;
39
+ /**
40
+ * Get Firebase Storage instance
41
+ */
42
+ declare function getFirebaseStorage(): FirebaseStorage;
43
+ /**
44
+ * Get Firebase Functions instance
45
+ */
46
+ declare function getFirebaseFunctions(): Functions;
47
+ /**
48
+ * Get Firebase Analytics instance
49
+ */
50
+ declare function getFirebaseAnalytics(): Analytics | null;
51
+ /**
52
+ * Firebase Instances
53
+ * All Firebase service instances
54
+ */
55
+ interface FirebaseInstances {
56
+ app: FirebaseApp;
57
+ auth: Auth;
58
+ db: Firestore;
59
+ storage: FirebaseStorage;
60
+ functions: Functions;
61
+ analytics: Analytics | null;
62
+ }
63
+ /**
64
+ * Get all Firebase instances
65
+ */
66
+ declare function getFirebaseInstances(): FirebaseInstances;
67
+
68
+ declare class AuthAdapter implements IAuthRepository {
69
+ private get auth();
70
+ signIn(email: string, password: string): Promise<UserCredential>;
71
+ signUp(email: string, password: string, displayName: string): Promise<UserCredential>;
72
+ signInWithGoogle(): Promise<UserCredential>;
73
+ signOut(): Promise<void>;
74
+ sendPasswordReset(email: string): Promise<void>;
75
+ resendEmailVerification(): Promise<void>;
76
+ updateProfile(updates: Partial<Pick<User['profile'], 'displayName' | 'photoURL'>>): Promise<void>;
77
+ updateEmail(newEmail: string, password: string): Promise<void>;
78
+ updatePassword(currentPassword: string, newPassword: string): Promise<void>;
79
+ deleteAccount(password: string): Promise<void>;
80
+ getCurrentUser(): User$1 | null;
81
+ onAuthStateChanged(callback: (user: User$1 | null) => void): _firebase_util.Unsubscribe;
82
+ createUserDocument(_userId: string, _data: Partial<Omit<User, 'profile'>> & {
83
+ email: string;
84
+ displayName: string;
85
+ }): Promise<void>;
86
+ updateLastLogin(_userId: string): Promise<void>;
87
+ /**
88
+ * Handle Firebase Auth errors
89
+ */
90
+ private handleAuthError;
91
+ }
92
+
93
+ /**
94
+ * Firestore Adapter
95
+ * @description Firebase Firestore implementation of IUserRepository
96
+ * Migrated from: /Users/umituz/Desktop/github/umituz/apps/web/app-growth-factory/src/domains/firebase/services/firestore.ts
97
+ */
98
+
99
+ declare class FirestoreAdapter implements IUserRepository {
100
+ private get db();
101
+ private readonly USERS_COLLECTION;
102
+ getUser(userId: string): Promise<User | null>;
103
+ getUserByEmail(email: string): Promise<User | null>;
104
+ createUser(userId: string, data: Partial<User>): Promise<void>;
105
+ updateUser(userId: string, data: Partial<User>): Promise<void>;
106
+ deleteUser(userId: string): Promise<void>;
107
+ updateProfile(userId: string, updates: Partial<Pick<User['profile'], 'displayName' | 'photoURL' | 'phoneNumber'>>): Promise<void>;
108
+ updateSettings(userId: string, settings: Partial<User['settings']>): Promise<void>;
109
+ updateSubscription(userId: string, subscription: Partial<User['subscription']>): Promise<void>;
110
+ updateLastLogin(userId: string): Promise<void>;
111
+ queryUsers(constraints: any[]): Promise<User[]>;
112
+ subscribeToUser(userId: string, callback: (user: User | null) => void, onError?: (error: Error) => void): () => void;
113
+ }
114
+
115
+ /**
116
+ * Storage Adapter
117
+ * @description Firebase Storage implementation of IFileRepository
118
+ * Migrated from: /Users/umituz/Desktop/github/umituz/apps/web/app-growth-factory/src/domains/firebase/services/storage.ts
119
+ */
120
+
121
+ declare class StorageAdapter implements IFileRepository {
122
+ private get storage();
123
+ uploadFile(userId: string, path: string, file: File | Blob, options?: UploadOptions): Promise<UploadResult>;
124
+ uploadImage(userId: string, file: File, filename?: string): Promise<UploadResult>;
125
+ uploadVideo(userId: string, file: File, filename?: string): Promise<UploadResult>;
126
+ uploadDocument(userId: string, file: File, filename?: string): Promise<UploadResult>;
127
+ uploadProfilePicture(userId: string, file: File): Promise<UploadResult>;
128
+ getDownloadURL(path: string): Promise<string>;
129
+ deleteFile(path: string): Promise<void>;
130
+ deleteUserFiles(userId: string): Promise<void>;
131
+ deleteImage(userId: string, filename: string): Promise<void>;
132
+ deleteVideo(userId: string, filename: string): Promise<void>;
133
+ deleteProfilePicture(userId: string, filename: string): Promise<void>;
134
+ listUserFiles(userId: string, path?: string): Promise<string[]>;
135
+ listUserImages(userId: string): Promise<string[]>;
136
+ listUserVideos(userId: string): Promise<string[]>;
137
+ getFileMetadata(path: string): Promise<FileMetadata>;
138
+ queryFiles(userId: string, _filters?: any): Promise<{
139
+ files: FileMetadata[];
140
+ totalCount: number;
141
+ hasMore: boolean;
142
+ }>;
143
+ getStorageStats(userId: string): Promise<StorageStats>;
144
+ validateFile(file: File, options?: {
145
+ maxSizeBytes?: number;
146
+ maxSizeMB?: number;
147
+ allowedTypes?: string[];
148
+ }): boolean;
149
+ isImageFile(file: File): boolean;
150
+ isVideoFile(file: File): boolean;
151
+ isDocumentFile(file: File): boolean;
152
+ generateUniqueFilename(originalName: string): string;
153
+ getFileExtension(filename: string): string;
154
+ private extractUserId;
155
+ private extractFileType;
156
+ }
157
+
158
+ /**
159
+ * Firebase Storage Utils
160
+ * @description Upload and delete helpers for Firebase Storage
161
+ */
162
+ interface StorageUploadResult {
163
+ url: string;
164
+ path: string;
165
+ }
166
+ declare function uploadFile(storage: FirebaseStorage, path: string, file: File | Blob): Promise<StorageUploadResult>;
167
+ declare function uploadBase64(storage: FirebaseStorage, path: string, base64: string, mimeType?: string): Promise<StorageUploadResult>;
168
+ declare function deleteFile(storage: FirebaseStorage, path: string): Promise<void>;
169
+
170
+ export { AuthAdapter, type FirebaseInstances, FirestoreAdapter, StorageAdapter, type StorageUploadResult, analytics, app, auth, db, deleteFile, functions, getFirebaseAnalytics, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstances, getFirebaseStorage, initializeFirebase, storage, uploadBase64, uploadFile };
@@ -0,0 +1,170 @@
1
+ import { FirebaseApp } from 'firebase/app';
2
+ import { Auth, UserCredential, User as User$1 } from 'firebase/auth';
3
+ import { Firestore } from 'firebase/firestore';
4
+ import { FirebaseStorage } from 'firebase/storage';
5
+ import { Analytics } from 'firebase/analytics';
6
+ import { Functions } from 'firebase/functions';
7
+ import * as _firebase_util from '@firebase/util';
8
+ import { I as IAuthRepository, c as User, a as IUserRepository } from '../user.repository.interface-DS74TsJ5.js';
9
+ import { I as IFileRepository, U as UploadOptions, i as UploadResult, c as FileMetadata, S as StorageStats } from '../file.repository.interface-v5vHgVsZ.js';
10
+
11
+ /**
12
+ * Firebase Client
13
+ * @description Firebase initialization and singleton instances
14
+ * Migrated from: /Users/umituz/Desktop/github/umituz/apps/web/app-growth-factory/src/domains/firebase/services/client.ts
15
+ */
16
+
17
+ declare let app: FirebaseApp;
18
+ declare let auth: Auth;
19
+ declare let db: Firestore;
20
+ declare let storage: FirebaseStorage;
21
+ declare let functions: Functions;
22
+ declare let analytics: Analytics | null;
23
+ /**
24
+ * Initialize Firebase App
25
+ */
26
+ declare function initializeFirebase(): FirebaseApp;
27
+ /**
28
+ * Get Firebase App instance
29
+ */
30
+ declare function getFirebaseApp(): FirebaseApp;
31
+ /**
32
+ * Get Firebase Auth instance
33
+ */
34
+ declare function getFirebaseAuth(): Auth;
35
+ /**
36
+ * Get Firestore instance
37
+ */
38
+ declare function getFirebaseDB(): Firestore;
39
+ /**
40
+ * Get Firebase Storage instance
41
+ */
42
+ declare function getFirebaseStorage(): FirebaseStorage;
43
+ /**
44
+ * Get Firebase Functions instance
45
+ */
46
+ declare function getFirebaseFunctions(): Functions;
47
+ /**
48
+ * Get Firebase Analytics instance
49
+ */
50
+ declare function getFirebaseAnalytics(): Analytics | null;
51
+ /**
52
+ * Firebase Instances
53
+ * All Firebase service instances
54
+ */
55
+ interface FirebaseInstances {
56
+ app: FirebaseApp;
57
+ auth: Auth;
58
+ db: Firestore;
59
+ storage: FirebaseStorage;
60
+ functions: Functions;
61
+ analytics: Analytics | null;
62
+ }
63
+ /**
64
+ * Get all Firebase instances
65
+ */
66
+ declare function getFirebaseInstances(): FirebaseInstances;
67
+
68
+ declare class AuthAdapter implements IAuthRepository {
69
+ private get auth();
70
+ signIn(email: string, password: string): Promise<UserCredential>;
71
+ signUp(email: string, password: string, displayName: string): Promise<UserCredential>;
72
+ signInWithGoogle(): Promise<UserCredential>;
73
+ signOut(): Promise<void>;
74
+ sendPasswordReset(email: string): Promise<void>;
75
+ resendEmailVerification(): Promise<void>;
76
+ updateProfile(updates: Partial<Pick<User['profile'], 'displayName' | 'photoURL'>>): Promise<void>;
77
+ updateEmail(newEmail: string, password: string): Promise<void>;
78
+ updatePassword(currentPassword: string, newPassword: string): Promise<void>;
79
+ deleteAccount(password: string): Promise<void>;
80
+ getCurrentUser(): User$1 | null;
81
+ onAuthStateChanged(callback: (user: User$1 | null) => void): _firebase_util.Unsubscribe;
82
+ createUserDocument(_userId: string, _data: Partial<Omit<User, 'profile'>> & {
83
+ email: string;
84
+ displayName: string;
85
+ }): Promise<void>;
86
+ updateLastLogin(_userId: string): Promise<void>;
87
+ /**
88
+ * Handle Firebase Auth errors
89
+ */
90
+ private handleAuthError;
91
+ }
92
+
93
+ /**
94
+ * Firestore Adapter
95
+ * @description Firebase Firestore implementation of IUserRepository
96
+ * Migrated from: /Users/umituz/Desktop/github/umituz/apps/web/app-growth-factory/src/domains/firebase/services/firestore.ts
97
+ */
98
+
99
+ declare class FirestoreAdapter implements IUserRepository {
100
+ private get db();
101
+ private readonly USERS_COLLECTION;
102
+ getUser(userId: string): Promise<User | null>;
103
+ getUserByEmail(email: string): Promise<User | null>;
104
+ createUser(userId: string, data: Partial<User>): Promise<void>;
105
+ updateUser(userId: string, data: Partial<User>): Promise<void>;
106
+ deleteUser(userId: string): Promise<void>;
107
+ updateProfile(userId: string, updates: Partial<Pick<User['profile'], 'displayName' | 'photoURL' | 'phoneNumber'>>): Promise<void>;
108
+ updateSettings(userId: string, settings: Partial<User['settings']>): Promise<void>;
109
+ updateSubscription(userId: string, subscription: Partial<User['subscription']>): Promise<void>;
110
+ updateLastLogin(userId: string): Promise<void>;
111
+ queryUsers(constraints: any[]): Promise<User[]>;
112
+ subscribeToUser(userId: string, callback: (user: User | null) => void, onError?: (error: Error) => void): () => void;
113
+ }
114
+
115
+ /**
116
+ * Storage Adapter
117
+ * @description Firebase Storage implementation of IFileRepository
118
+ * Migrated from: /Users/umituz/Desktop/github/umituz/apps/web/app-growth-factory/src/domains/firebase/services/storage.ts
119
+ */
120
+
121
+ declare class StorageAdapter implements IFileRepository {
122
+ private get storage();
123
+ uploadFile(userId: string, path: string, file: File | Blob, options?: UploadOptions): Promise<UploadResult>;
124
+ uploadImage(userId: string, file: File, filename?: string): Promise<UploadResult>;
125
+ uploadVideo(userId: string, file: File, filename?: string): Promise<UploadResult>;
126
+ uploadDocument(userId: string, file: File, filename?: string): Promise<UploadResult>;
127
+ uploadProfilePicture(userId: string, file: File): Promise<UploadResult>;
128
+ getDownloadURL(path: string): Promise<string>;
129
+ deleteFile(path: string): Promise<void>;
130
+ deleteUserFiles(userId: string): Promise<void>;
131
+ deleteImage(userId: string, filename: string): Promise<void>;
132
+ deleteVideo(userId: string, filename: string): Promise<void>;
133
+ deleteProfilePicture(userId: string, filename: string): Promise<void>;
134
+ listUserFiles(userId: string, path?: string): Promise<string[]>;
135
+ listUserImages(userId: string): Promise<string[]>;
136
+ listUserVideos(userId: string): Promise<string[]>;
137
+ getFileMetadata(path: string): Promise<FileMetadata>;
138
+ queryFiles(userId: string, _filters?: any): Promise<{
139
+ files: FileMetadata[];
140
+ totalCount: number;
141
+ hasMore: boolean;
142
+ }>;
143
+ getStorageStats(userId: string): Promise<StorageStats>;
144
+ validateFile(file: File, options?: {
145
+ maxSizeBytes?: number;
146
+ maxSizeMB?: number;
147
+ allowedTypes?: string[];
148
+ }): boolean;
149
+ isImageFile(file: File): boolean;
150
+ isVideoFile(file: File): boolean;
151
+ isDocumentFile(file: File): boolean;
152
+ generateUniqueFilename(originalName: string): string;
153
+ getFileExtension(filename: string): string;
154
+ private extractUserId;
155
+ private extractFileType;
156
+ }
157
+
158
+ /**
159
+ * Firebase Storage Utils
160
+ * @description Upload and delete helpers for Firebase Storage
161
+ */
162
+ interface StorageUploadResult {
163
+ url: string;
164
+ path: string;
165
+ }
166
+ declare function uploadFile(storage: FirebaseStorage, path: string, file: File | Blob): Promise<StorageUploadResult>;
167
+ declare function uploadBase64(storage: FirebaseStorage, path: string, base64: string, mimeType?: string): Promise<StorageUploadResult>;
168
+ declare function deleteFile(storage: FirebaseStorage, path: string): Promise<void>;
169
+
170
+ export { AuthAdapter, type FirebaseInstances, FirestoreAdapter, StorageAdapter, type StorageUploadResult, analytics, app, auth, db, deleteFile, functions, getFirebaseAnalytics, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstances, getFirebaseStorage, initializeFirebase, storage, uploadBase64, uploadFile };