@umituz/web-firebase 1.0.5 → 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.
- package/README.md +555 -0
- package/dist/application/index.d.mts +273 -0
- package/dist/application/index.d.ts +273 -0
- package/dist/application/index.js +490 -0
- package/dist/application/index.mjs +19 -0
- package/dist/chunk-34DL2QWQ.mjs +87 -0
- package/dist/chunk-4FP2ELQ5.mjs +96 -0
- package/dist/chunk-7TX3OU3O.mjs +721 -0
- package/dist/chunk-I6WGBPFB.mjs +439 -0
- package/dist/chunk-RZ4QR6TB.mjs +96 -0
- package/dist/chunk-U2XI4MGO.mjs +397 -0
- package/dist/domain/index.d.mts +325 -0
- package/dist/domain/index.d.ts +325 -0
- package/dist/domain/index.js +662 -0
- package/dist/domain/index.mjs +36 -0
- package/dist/file.repository.interface-v5vHgVsZ.d.mts +241 -0
- package/dist/file.repository.interface-v5vHgVsZ.d.ts +241 -0
- package/dist/firebase.entity-xvfEPjXZ.d.mts +15 -0
- package/dist/firebase.entity-xvfEPjXZ.d.ts +15 -0
- package/dist/index.d.mts +14 -96
- package/dist/index.d.ts +14 -96
- package/dist/index.js +1717 -78
- package/dist/index.mjs +88 -175
- package/dist/infrastructure/index.d.mts +170 -0
- package/dist/infrastructure/index.d.ts +170 -0
- package/dist/infrastructure/index.js +856 -0
- package/dist/infrastructure/index.mjs +46 -0
- package/dist/presentation/index.d.mts +25 -0
- package/dist/presentation/index.d.ts +25 -0
- package/dist/presentation/index.js +105 -0
- package/dist/presentation/index.mjs +6 -0
- package/dist/user.repository.interface-DS74TsJ5.d.mts +298 -0
- package/dist/user.repository.interface-DS74TsJ5.d.ts +298 -0
- package/package.json +37 -11
- package/src/application/dto/auth.dto.ts +69 -0
- package/src/application/dto/index.ts +7 -0
- package/src/application/dto/user.dto.ts +64 -0
- package/src/application/index.ts +7 -0
- package/src/application/use-cases/auth/reset-password.use-case.ts +66 -0
- package/src/application/use-cases/auth/sign-in-with-google.use-case.ts +86 -0
- package/src/application/use-cases/auth/sign-in.use-case.ts +77 -0
- package/src/application/use-cases/auth/sign-out.use-case.ts +22 -0
- package/src/application/use-cases/auth/sign-up.use-case.ts +99 -0
- package/src/application/use-cases/index.ts +12 -0
- package/src/application/use-cases/user/delete-account.use-case.ts +77 -0
- package/src/application/use-cases/user/update-profile.use-case.ts +98 -0
- package/src/domain/entities/file.entity.ts +151 -0
- package/src/domain/entities/timestamp.entity.ts +116 -0
- package/src/domain/entities/user.entity.ts +193 -0
- package/src/domain/errors/auth.errors.ts +115 -0
- package/src/domain/errors/repository.errors.ts +121 -0
- package/src/domain/index.ts +25 -2
- package/src/domain/interfaces/auth.repository.interface.ts +83 -0
- package/src/domain/interfaces/file.repository.interface.ts +143 -0
- package/src/domain/interfaces/user.repository.interface.ts +75 -0
- package/src/domain/value-objects/email.vo.ts +105 -0
- package/src/domain/value-objects/file-path.vo.ts +184 -0
- package/src/domain/value-objects/user-id.vo.ts +87 -0
- package/src/index.ts +19 -4
- package/src/infrastructure/firebase/auth.adapter.ts +220 -0
- package/src/infrastructure/firebase/client.ts +141 -0
- package/src/infrastructure/firebase/firestore.adapter.ts +190 -0
- package/src/infrastructure/firebase/storage.adapter.ts +323 -0
- package/src/infrastructure/index.ts +10 -5
- package/src/infrastructure/utils/storage.util.ts +3 -3
- package/src/presentation/hooks/useAuth.ts +153 -0
- package/src/presentation/hooks/useFirestore.ts +125 -0
- package/src/presentation/hooks/useStorage.ts +141 -0
- 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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
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 };
|