@umituz/web-firebase 2.1.0 → 3.0.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.
Files changed (54) hide show
  1. package/package.json +12 -39
  2. package/src/domains/auth/entities/index.ts +60 -0
  3. package/src/domains/auth/index.ts +13 -0
  4. package/src/domains/auth/services/auth.service.ts +245 -0
  5. package/src/domains/auth/services/index.ts +7 -0
  6. package/src/domains/auth/types/auth-service.interface.ts +72 -0
  7. package/src/domains/auth/types/index.ts +5 -0
  8. package/src/domains/firestore/entities/index.ts +82 -0
  9. package/src/domains/firestore/index.ts +13 -0
  10. package/src/domains/firestore/services/firestore.service.ts +191 -0
  11. package/src/domains/firestore/services/index.ts +7 -0
  12. package/src/domains/firestore/types/firestore-service.interface.ts +64 -0
  13. package/src/domains/firestore/types/index.ts +5 -0
  14. package/src/domains/storage/entities/index.ts +94 -0
  15. package/src/domains/storage/index.ts +13 -0
  16. package/src/domains/storage/services/index.ts +7 -0
  17. package/src/domains/storage/services/storage.service.ts +223 -0
  18. package/src/domains/storage/types/index.ts +5 -0
  19. package/src/domains/storage/types/storage-service.interface.ts +120 -0
  20. package/src/index.ts +12 -16
  21. package/src/presentation/hooks/useAuth.ts +69 -26
  22. package/src/presentation/providers/FirebaseProvider.tsx +9 -14
  23. package/dist/application/index.d.mts +0 -273
  24. package/dist/application/index.d.ts +0 -273
  25. package/dist/application/index.js +0 -490
  26. package/dist/application/index.mjs +0 -19
  27. package/dist/chunk-34DL2QWQ.mjs +0 -87
  28. package/dist/chunk-4FP2ELQ5.mjs +0 -96
  29. package/dist/chunk-7TX3OU3O.mjs +0 -721
  30. package/dist/chunk-I6WGBPFB.mjs +0 -439
  31. package/dist/chunk-RZ4QR6TB.mjs +0 -96
  32. package/dist/chunk-U2XI4MGO.mjs +0 -397
  33. package/dist/domain/index.d.mts +0 -325
  34. package/dist/domain/index.d.ts +0 -325
  35. package/dist/domain/index.js +0 -662
  36. package/dist/domain/index.mjs +0 -36
  37. package/dist/file.repository.interface-v5vHgVsZ.d.mts +0 -241
  38. package/dist/file.repository.interface-v5vHgVsZ.d.ts +0 -241
  39. package/dist/firebase.entity-xvfEPjXZ.d.mts +0 -15
  40. package/dist/firebase.entity-xvfEPjXZ.d.ts +0 -15
  41. package/dist/index.d.mts +0 -14
  42. package/dist/index.d.ts +0 -14
  43. package/dist/index.js +0 -1833
  44. package/dist/index.mjs +0 -98
  45. package/dist/infrastructure/index.d.mts +0 -170
  46. package/dist/infrastructure/index.d.ts +0 -170
  47. package/dist/infrastructure/index.js +0 -856
  48. package/dist/infrastructure/index.mjs +0 -46
  49. package/dist/presentation/index.d.mts +0 -25
  50. package/dist/presentation/index.d.ts +0 -25
  51. package/dist/presentation/index.js +0 -105
  52. package/dist/presentation/index.mjs +0 -6
  53. package/dist/user.repository.interface-DS74TsJ5.d.mts +0 -298
  54. package/dist/user.repository.interface-DS74TsJ5.d.ts +0 -298
package/dist/index.mjs DELETED
@@ -1,98 +0,0 @@
1
- import {
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";
42
- import {
43
- RepositoryError,
44
- RepositoryErrorCode,
45
- createRepositoryError
46
- } from "./chunk-4FP2ELQ5.mjs";
47
- import {
48
- AuthError,
49
- AuthErrorCode,
50
- createAuthError
51
- } from "./chunk-RZ4QR6TB.mjs";
52
- import {
53
- useFirebaseAuth
54
- } from "./chunk-34DL2QWQ.mjs";
55
- export {
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,
83
- deleteFile,
84
- functions,
85
- getFirebaseAnalytics,
86
- getFirebaseApp,
87
- getFirebaseAuth,
88
- getFirebaseDB,
89
- getFirebaseFunctions,
90
- getFirebaseInstances,
91
- getFirebaseStorage,
92
- initializeFirebase,
93
- serverTimestamp,
94
- storage,
95
- uploadBase64,
96
- uploadFile,
97
- useFirebaseAuth
98
- };
@@ -1,170 +0,0 @@
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 };
@@ -1,170 +0,0 @@
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 };