@umituz/web-firebase 2.1.1 → 3.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 (58) hide show
  1. package/package.json +12 -39
  2. package/src/domain/interfaces/auth.repository.interface.ts +4 -19
  3. package/src/domain/interfaces/file.repository.interface.ts +5 -102
  4. package/src/domain/interfaces/index.ts +7 -0
  5. package/src/domain/interfaces/user.repository.interface.ts +17 -44
  6. package/src/domains/auth/entities/index.ts +60 -0
  7. package/src/domains/auth/index.ts +13 -0
  8. package/src/domains/auth/services/auth.service.ts +245 -0
  9. package/src/domains/auth/services/index.ts +7 -0
  10. package/src/domains/auth/types/auth-service.interface.ts +72 -0
  11. package/src/domains/auth/types/index.ts +5 -0
  12. package/src/domains/firestore/entities/index.ts +82 -0
  13. package/src/domains/firestore/index.ts +13 -0
  14. package/src/domains/firestore/services/firestore.service.ts +191 -0
  15. package/src/domains/firestore/services/index.ts +7 -0
  16. package/src/domains/firestore/types/firestore-service.interface.ts +64 -0
  17. package/src/domains/firestore/types/index.ts +5 -0
  18. package/src/domains/storage/entities/index.ts +94 -0
  19. package/src/domains/storage/index.ts +13 -0
  20. package/src/domains/storage/services/index.ts +7 -0
  21. package/src/domains/storage/services/storage.service.ts +223 -0
  22. package/src/domains/storage/types/index.ts +5 -0
  23. package/src/domains/storage/types/storage-service.interface.ts +120 -0
  24. package/src/index.ts +12 -16
  25. package/src/presentation/hooks/useAuth.ts +69 -26
  26. package/src/presentation/providers/FirebaseProvider.tsx +9 -14
  27. package/dist/application/index.d.mts +0 -273
  28. package/dist/application/index.d.ts +0 -273
  29. package/dist/application/index.js +0 -490
  30. package/dist/application/index.mjs +0 -19
  31. package/dist/chunk-34DL2QWQ.mjs +0 -87
  32. package/dist/chunk-4FP2ELQ5.mjs +0 -96
  33. package/dist/chunk-7TX3OU3O.mjs +0 -721
  34. package/dist/chunk-I6WGBPFB.mjs +0 -439
  35. package/dist/chunk-RZ4QR6TB.mjs +0 -96
  36. package/dist/chunk-U2XI4MGO.mjs +0 -397
  37. package/dist/domain/index.d.mts +0 -325
  38. package/dist/domain/index.d.ts +0 -325
  39. package/dist/domain/index.js +0 -662
  40. package/dist/domain/index.mjs +0 -36
  41. package/dist/file.repository.interface-v5vHgVsZ.d.mts +0 -241
  42. package/dist/file.repository.interface-v5vHgVsZ.d.ts +0 -241
  43. package/dist/firebase.entity-xvfEPjXZ.d.mts +0 -15
  44. package/dist/firebase.entity-xvfEPjXZ.d.ts +0 -15
  45. package/dist/index.d.mts +0 -14
  46. package/dist/index.d.ts +0 -14
  47. package/dist/index.js +0 -1833
  48. package/dist/index.mjs +0 -98
  49. package/dist/infrastructure/index.d.mts +0 -170
  50. package/dist/infrastructure/index.d.ts +0 -170
  51. package/dist/infrastructure/index.js +0 -856
  52. package/dist/infrastructure/index.mjs +0 -46
  53. package/dist/presentation/index.d.mts +0 -25
  54. package/dist/presentation/index.d.ts +0 -25
  55. package/dist/presentation/index.js +0 -105
  56. package/dist/presentation/index.mjs +0 -6
  57. package/dist/user.repository.interface-DS74TsJ5.d.mts +0 -298
  58. package/dist/user.repository.interface-DS74TsJ5.d.ts +0 -298
@@ -1,46 +0,0 @@
1
- import {
2
- AuthAdapter,
3
- FirestoreAdapter,
4
- StorageAdapter,
5
- analytics,
6
- app,
7
- auth,
8
- db,
9
- deleteFile,
10
- functions,
11
- getFirebaseAnalytics,
12
- getFirebaseApp,
13
- getFirebaseAuth,
14
- getFirebaseDB,
15
- getFirebaseFunctions,
16
- getFirebaseInstances,
17
- getFirebaseStorage,
18
- initializeFirebase,
19
- storage,
20
- uploadBase64,
21
- uploadFile
22
- } from "../chunk-7TX3OU3O.mjs";
23
- import "../chunk-4FP2ELQ5.mjs";
24
- import "../chunk-RZ4QR6TB.mjs";
25
- export {
26
- AuthAdapter,
27
- FirestoreAdapter,
28
- StorageAdapter,
29
- analytics,
30
- app,
31
- auth,
32
- db,
33
- deleteFile,
34
- functions,
35
- getFirebaseAnalytics,
36
- getFirebaseApp,
37
- getFirebaseAuth,
38
- getFirebaseDB,
39
- getFirebaseFunctions,
40
- getFirebaseInstances,
41
- getFirebaseStorage,
42
- initializeFirebase,
43
- storage,
44
- uploadBase64,
45
- uploadFile
46
- };
@@ -1,25 +0,0 @@
1
- import { UserCredential, Auth } from 'firebase/auth';
2
- import { a as FirebaseUser } from '../firebase.entity-xvfEPjXZ.mjs';
3
-
4
- /**
5
- * useFirebaseAuth Hook
6
- * @description Hook to manage Firebase authentication state and operations
7
- */
8
- interface UseFirebaseAuthOptions {
9
- onUserChange?: (user: FirebaseUser | null) => void;
10
- }
11
- interface UseFirebaseAuthReturn {
12
- user: FirebaseUser | null;
13
- loading: boolean;
14
- isAuthenticated: boolean;
15
- signIn(email: string, password: string): Promise<UserCredential>;
16
- signUp(email: string, password: string, name?: string): Promise<UserCredential>;
17
- signOut(): Promise<void>;
18
- updateUserProfile(name: string, photoURL?: string): Promise<void>;
19
- updateUserPassword(newPassword: string): Promise<void>;
20
- resetPassword(email: string): Promise<void>;
21
- getIdToken(): Promise<string>;
22
- }
23
- declare function useFirebaseAuth(auth: Auth, options?: UseFirebaseAuthOptions): UseFirebaseAuthReturn;
24
-
25
- export { type UseFirebaseAuthOptions, type UseFirebaseAuthReturn, useFirebaseAuth };
@@ -1,25 +0,0 @@
1
- import { UserCredential, Auth } from 'firebase/auth';
2
- import { a as FirebaseUser } from '../firebase.entity-xvfEPjXZ.js';
3
-
4
- /**
5
- * useFirebaseAuth Hook
6
- * @description Hook to manage Firebase authentication state and operations
7
- */
8
- interface UseFirebaseAuthOptions {
9
- onUserChange?: (user: FirebaseUser | null) => void;
10
- }
11
- interface UseFirebaseAuthReturn {
12
- user: FirebaseUser | null;
13
- loading: boolean;
14
- isAuthenticated: boolean;
15
- signIn(email: string, password: string): Promise<UserCredential>;
16
- signUp(email: string, password: string, name?: string): Promise<UserCredential>;
17
- signOut(): Promise<void>;
18
- updateUserProfile(name: string, photoURL?: string): Promise<void>;
19
- updateUserPassword(newPassword: string): Promise<void>;
20
- resetPassword(email: string): Promise<void>;
21
- getIdToken(): Promise<string>;
22
- }
23
- declare function useFirebaseAuth(auth: Auth, options?: UseFirebaseAuthOptions): UseFirebaseAuthReturn;
24
-
25
- export { type UseFirebaseAuthOptions, type UseFirebaseAuthReturn, useFirebaseAuth };
@@ -1,105 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/presentation/index.ts
21
- var presentation_exports = {};
22
- __export(presentation_exports, {
23
- useFirebaseAuth: () => useFirebaseAuth
24
- });
25
- module.exports = __toCommonJS(presentation_exports);
26
-
27
- // src/presentation/hooks/useFirebaseAuth.ts
28
- var import_react = require("react");
29
- var import_auth = require("firebase/auth");
30
- function mapUser(u) {
31
- return {
32
- uid: u.uid,
33
- email: u.email,
34
- displayName: u.displayName,
35
- photoURL: u.photoURL,
36
- emailVerified: u.emailVerified
37
- };
38
- }
39
- function useFirebaseAuth(auth, options) {
40
- const [user, setUser] = (0, import_react.useState)(null);
41
- const [loading, setLoading] = (0, import_react.useState)(true);
42
- (0, import_react.useEffect)(() => {
43
- const unsub = (0, import_auth.onAuthStateChanged)(auth, (firebaseUser) => {
44
- const mapped = firebaseUser ? mapUser(firebaseUser) : null;
45
- setUser(mapped);
46
- setLoading(false);
47
- options?.onUserChange?.(mapped);
48
- });
49
- return unsub;
50
- }, [auth, options]);
51
- const signIn = (0, import_react.useCallback)(
52
- (email, password) => (0, import_auth.signInWithEmailAndPassword)(auth, email, password),
53
- [auth]
54
- );
55
- const signUp = (0, import_react.useCallback)(
56
- async (email, password, name) => {
57
- const cred = await (0, import_auth.createUserWithEmailAndPassword)(auth, email, password);
58
- if (name && cred.user) await (0, import_auth.updateProfile)(cred.user, { displayName: name });
59
- return cred;
60
- },
61
- [auth]
62
- );
63
- const signOut = (0, import_react.useCallback)(() => (0, import_auth.signOut)(auth), [auth]);
64
- const updateUserProfile = (0, import_react.useCallback)(
65
- async (name, photoURL) => {
66
- if (!auth.currentUser) throw new Error("No authenticated user");
67
- await (0, import_auth.updateProfile)(auth.currentUser, {
68
- displayName: name,
69
- ...photoURL !== void 0 && { photoURL }
70
- });
71
- },
72
- [auth]
73
- );
74
- const updateUserPassword = (0, import_react.useCallback)(
75
- async (newPassword) => {
76
- if (!auth.currentUser) throw new Error("No authenticated user");
77
- await (0, import_auth.updatePassword)(auth.currentUser, newPassword);
78
- },
79
- [auth]
80
- );
81
- const resetPassword = (0, import_react.useCallback)(
82
- (email) => (0, import_auth.sendPasswordResetEmail)(auth, email),
83
- [auth]
84
- );
85
- const getIdToken = (0, import_react.useCallback)(async () => {
86
- if (!auth.currentUser) throw new Error("No authenticated user");
87
- return auth.currentUser.getIdToken();
88
- }, [auth]);
89
- return {
90
- user,
91
- loading,
92
- isAuthenticated: !!user,
93
- signIn,
94
- signUp,
95
- signOut,
96
- updateUserProfile,
97
- updateUserPassword,
98
- resetPassword,
99
- getIdToken
100
- };
101
- }
102
- // Annotate the CommonJS export names for ESM import in node:
103
- 0 && (module.exports = {
104
- useFirebaseAuth
105
- });
@@ -1,6 +0,0 @@
1
- import {
2
- useFirebaseAuth
3
- } from "../chunk-34DL2QWQ.mjs";
4
- export {
5
- useFirebaseAuth
6
- };
@@ -1,298 +0,0 @@
1
- import { UserCredential, User as User$1 } from 'firebase/auth';
2
- import { QueryConstraint } from 'firebase/firestore';
3
-
4
- /**
5
- * User Domain Entities
6
- * @description Core user-related entities following DDD principles
7
- * Migrated from: /Users/umituz/Desktop/github/umituz/apps/web/app-growth-factory/src/domains/firebase/types/index.ts
8
- */
9
- /**
10
- * User Profile Value Object
11
- * Immutable user profile data
12
- */
13
- interface UserProfile {
14
- readonly id: string;
15
- readonly email: string;
16
- readonly displayName: string;
17
- readonly photoURL?: string;
18
- readonly phoneNumber?: string;
19
- readonly createdAt: number;
20
- readonly updatedAt: number;
21
- readonly lastLoginAt: number;
22
- readonly emailVerified: boolean;
23
- }
24
- /**
25
- * User Notifications Settings
26
- */
27
- interface UserNotifications {
28
- email: boolean;
29
- push: boolean;
30
- marketing: boolean;
31
- security: boolean;
32
- weeklyDigest: boolean;
33
- }
34
- /**
35
- * User Privacy Settings
36
- */
37
- interface UserPrivacy {
38
- profileVisibility: 'public' | 'private';
39
- showEmail: boolean;
40
- showPhone: boolean;
41
- dataSharing: boolean;
42
- }
43
- /**
44
- * User Settings Value Object
45
- */
46
- interface UserSettings {
47
- theme: 'light' | 'dark' | 'system';
48
- language: string;
49
- timezone: string;
50
- currency: string;
51
- notifications: UserNotifications;
52
- privacy: UserPrivacy;
53
- }
54
- /**
55
- * User Subscription Value Object
56
- */
57
- interface UserSubscription {
58
- plan: 'free' | 'standard' | 'professional' | 'business';
59
- status: 'active' | 'inactive' | 'canceled' | 'past_due';
60
- polarCustomerId?: string;
61
- polarSubscriptionId?: string;
62
- currentPeriodStart?: number;
63
- currentPeriodEnd?: number;
64
- cancelAtPeriodEnd: boolean;
65
- readonly createdAt: number;
66
- readonly updatedAt: number;
67
- }
68
- /**
69
- * Account Metrics Value Object
70
- */
71
- interface AccountMetrics {
72
- followers: number;
73
- following: number;
74
- posts: number;
75
- engagement: number;
76
- lastSyncedAt: number;
77
- }
78
- /**
79
- * User Connected Account Entity
80
- */
81
- interface UserConnectedAccount {
82
- platform: 'twitter' | 'facebook' | 'instagram' | 'linkedin' | 'tiktok' | 'youtube' | 'pinterest' | 'reddit' | 'threads' | 'discord' | 'telegram' | 'mastodon' | 'medium';
83
- connected: boolean;
84
- readonly connectedAt: number;
85
- username?: string;
86
- profileId?: string;
87
- accessToken?: string;
88
- refreshToken?: string;
89
- tokenExpiresAt?: number;
90
- metrics?: AccountMetrics;
91
- }
92
- /**
93
- * User Content Entity
94
- */
95
- interface UserContent {
96
- readonly id: string;
97
- type: 'post' | 'article' | 'video' | 'image' | 'story' | 'reel';
98
- title: string;
99
- content: string;
100
- platforms: string[];
101
- status: 'draft' | 'scheduled' | 'published' | 'failed';
102
- scheduledFor?: number;
103
- publishedAt?: number;
104
- readonly createdAt: number;
105
- readonly updatedAt: number;
106
- mediaUrls?: string[];
107
- metadata?: Record<string, unknown>;
108
- }
109
- /**
110
- * Platform Breakdown for Analytics
111
- */
112
- interface PlatformBreakdown {
113
- [platform: string]: {
114
- posts: number;
115
- engagement: number;
116
- reach: number;
117
- };
118
- }
119
- /**
120
- * User Analytics Value Object
121
- */
122
- interface UserAnalytics {
123
- totalPosts: number;
124
- totalEngagement: number;
125
- totalReach: number;
126
- topPerformingPosts: string[];
127
- platformBreakdown: PlatformBreakdown;
128
- lastCalculatedAt: number;
129
- }
130
- /**
131
- * User Credits Value Object
132
- */
133
- interface UserCredits {
134
- standard: number;
135
- professional: number;
136
- total: number;
137
- resetAt: number;
138
- lastResetAt: number;
139
- }
140
- /**
141
- * User Aggregate Root
142
- * Main user document containing all user-related data
143
- * This is the aggregate root for the User domain
144
- */
145
- interface User {
146
- readonly profile: UserProfile;
147
- settings: UserSettings;
148
- subscription: UserSubscription;
149
- connectedAccounts: UserConnectedAccount[];
150
- content: UserContent[];
151
- analytics: UserAnalytics;
152
- credits: UserCredits;
153
- }
154
- /**
155
- * Collection Constants
156
- */
157
- declare const USER_COLLECTIONS: {
158
- readonly USERS: "users";
159
- readonly CONTENT: "content";
160
- readonly ANALYTICS: "analytics";
161
- readonly CONNECTED_ACCOUNTS: "connectedAccounts";
162
- };
163
- declare const USER_SUBCOLLECTIONS: {
164
- readonly CONTENT: "content";
165
- readonly ANALYTICS: "analytics";
166
- readonly SCHEDULED: "scheduled";
167
- readonly PUBLISHED: "published";
168
- readonly DRAFTS: "drafts";
169
- };
170
-
171
- /**
172
- * Authentication Repository Interface
173
- * @description Defines contract for authentication operations
174
- */
175
-
176
- /**
177
- * Authentication Repository Interface
178
- * Defines operations for user authentication and management
179
- */
180
- interface IAuthRepository {
181
- /**
182
- * Sign in with email and password
183
- */
184
- signIn(email: string, password: string): Promise<UserCredential>;
185
- /**
186
- * Sign up with email, password, and display name
187
- */
188
- signUp(email: string, password: string, displayName: string): Promise<UserCredential>;
189
- /**
190
- * Sign in with Google OAuth
191
- */
192
- signInWithGoogle(): Promise<UserCredential>;
193
- /**
194
- * Sign out current user
195
- */
196
- signOut(): Promise<void>;
197
- /**
198
- * Send password reset email
199
- */
200
- sendPasswordReset(email: string): Promise<void>;
201
- /**
202
- * Resend email verification
203
- */
204
- resendEmailVerification(): Promise<void>;
205
- /**
206
- * Update user profile (displayName, photoURL)
207
- */
208
- updateProfile(updates: Partial<Pick<User['profile'], 'displayName' | 'photoURL'>>): Promise<void>;
209
- /**
210
- * Update user email (requires password)
211
- */
212
- updateEmail(newEmail: string, password: string): Promise<void>;
213
- /**
214
- * Update user password (requires current password)
215
- */
216
- updatePassword(currentPassword: string, newPassword: string): Promise<void>;
217
- /**
218
- * Delete user account (requires password)
219
- */
220
- deleteAccount(password: string): Promise<void>;
221
- /**
222
- * Get current authenticated user
223
- */
224
- getCurrentUser(): User$1 | null;
225
- /**
226
- * Subscribe to auth state changes
227
- */
228
- onAuthStateChanged(callback: (user: User$1 | null) => void): () => void;
229
- /**
230
- * Create user document in Firestore
231
- */
232
- createUserDocument(userId: string, data: Partial<Omit<User, 'profile'>> & {
233
- email: string;
234
- displayName: string;
235
- }): Promise<void>;
236
- /**
237
- * Update last login timestamp
238
- */
239
- updateLastLogin(userId: string): Promise<void>;
240
- }
241
-
242
- /**
243
- * User Repository Interface
244
- * @description Defines contract for user data operations
245
- */
246
-
247
- /**
248
- * User Repository Interface
249
- * Defines operations for user data management
250
- */
251
- interface IUserRepository {
252
- /**
253
- * Get user by ID
254
- */
255
- getUser(userId: string): Promise<User | null>;
256
- /**
257
- * Get user by email
258
- */
259
- getUserByEmail(email: string): Promise<User | null>;
260
- /**
261
- * Create user
262
- */
263
- createUser(userId: string, data: Partial<User>): Promise<void>;
264
- /**
265
- * Update user
266
- */
267
- updateUser(userId: string, data: Partial<User>): Promise<void>;
268
- /**
269
- * Delete user
270
- */
271
- deleteUser(userId: string): Promise<void>;
272
- /**
273
- * Update user profile
274
- */
275
- updateProfile(userId: string, updates: Partial<Pick<User['profile'], 'displayName' | 'photoURL' | 'phoneNumber'>>): Promise<void>;
276
- /**
277
- * Update user settings
278
- */
279
- updateSettings(userId: string, settings: Partial<User['settings']>): Promise<void>;
280
- /**
281
- * Update user subscription
282
- */
283
- updateSubscription(userId: string, subscription: Partial<User['subscription']>): Promise<void>;
284
- /**
285
- * Update last login timestamp
286
- */
287
- updateLastLogin(userId: string): Promise<void>;
288
- /**
289
- * Query users with constraints
290
- */
291
- queryUsers(constraints: QueryConstraint[]): Promise<User[]>;
292
- /**
293
- * Subscribe to user document changes
294
- */
295
- subscribeToUser(userId: string, callback: (user: User | null) => void, onError?: (error: Error) => void): () => void;
296
- }
297
-
298
- export { type AccountMetrics as A, type IAuthRepository as I, type PlatformBreakdown as P, USER_COLLECTIONS as U, type IUserRepository as a, USER_SUBCOLLECTIONS as b, type User as c, type UserAnalytics as d, type UserConnectedAccount as e, type UserContent as f, type UserCredits as g, type UserNotifications as h, type UserPrivacy as i, type UserProfile as j, type UserSettings as k, type UserSubscription as l };