@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.
Files changed (69) 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 +37 -11
  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/timestamp.entity.ts +116 -0
  49. package/src/domain/entities/user.entity.ts +193 -0
  50. package/src/domain/errors/auth.errors.ts +115 -0
  51. package/src/domain/errors/repository.errors.ts +121 -0
  52. package/src/domain/index.ts +25 -2
  53. package/src/domain/interfaces/auth.repository.interface.ts +83 -0
  54. package/src/domain/interfaces/file.repository.interface.ts +143 -0
  55. package/src/domain/interfaces/user.repository.interface.ts +75 -0
  56. package/src/domain/value-objects/email.vo.ts +105 -0
  57. package/src/domain/value-objects/file-path.vo.ts +184 -0
  58. package/src/domain/value-objects/user-id.vo.ts +87 -0
  59. package/src/index.ts +19 -4
  60. package/src/infrastructure/firebase/auth.adapter.ts +220 -0
  61. package/src/infrastructure/firebase/client.ts +141 -0
  62. package/src/infrastructure/firebase/firestore.adapter.ts +190 -0
  63. package/src/infrastructure/firebase/storage.adapter.ts +323 -0
  64. package/src/infrastructure/index.ts +10 -5
  65. package/src/infrastructure/utils/storage.util.ts +3 -3
  66. package/src/presentation/hooks/useAuth.ts +153 -0
  67. package/src/presentation/hooks/useFirestore.ts +125 -0
  68. package/src/presentation/hooks/useStorage.ts +141 -0
  69. package/src/presentation/providers/FirebaseProvider.tsx +40 -0
@@ -0,0 +1,273 @@
1
+ import { UserCredential } from 'firebase/auth';
2
+ import { c as User, I as IAuthRepository, a as IUserRepository } from '../user.repository.interface-DS74TsJ5.mjs';
3
+ import 'firebase/firestore';
4
+
5
+ /**
6
+ * Authentication DTOs
7
+ * @description Data Transfer Objects for authentication operations
8
+ */
9
+
10
+ /**
11
+ * Sign In DTO
12
+ */
13
+ interface SignInDTO {
14
+ email: string;
15
+ password: string;
16
+ }
17
+ /**
18
+ * Sign Up DTO
19
+ */
20
+ interface SignUpDTO {
21
+ email: string;
22
+ password: string;
23
+ displayName: string;
24
+ }
25
+ /**
26
+ * Sign Up Result
27
+ */
28
+ interface SignUpResult extends UserCredential {
29
+ userId: string;
30
+ emailVerified: boolean;
31
+ }
32
+ /**
33
+ * Reset Password DTO
34
+ */
35
+ interface ResetPasswordDTO {
36
+ email: string;
37
+ }
38
+ /**
39
+ * Update Profile DTO
40
+ */
41
+ interface UpdateProfileDTO {
42
+ displayName?: string;
43
+ photoURL?: string;
44
+ }
45
+ /**
46
+ * Update Email DTO
47
+ */
48
+ interface UpdateEmailDTO {
49
+ newEmail: string;
50
+ currentPassword: string;
51
+ }
52
+ /**
53
+ * Update Password DTO
54
+ */
55
+ interface UpdatePasswordDTO {
56
+ currentPassword: string;
57
+ newPassword: string;
58
+ }
59
+ /**
60
+ * Delete Account DTO
61
+ */
62
+ interface DeleteAccountDTO {
63
+ password: string;
64
+ }
65
+
66
+ /**
67
+ * User DTOs
68
+ * @description Data Transfer Objects for user operations
69
+ */
70
+
71
+ /**
72
+ * Create User DTO
73
+ */
74
+ interface CreateUserDTO {
75
+ id: string;
76
+ email: string;
77
+ displayName: string;
78
+ photoURL?: string;
79
+ phoneNumber?: string;
80
+ emailVerified: boolean;
81
+ }
82
+ /**
83
+ * Update User DTO
84
+ */
85
+ interface UpdateUserDTO {
86
+ displayName?: string;
87
+ photoURL?: string;
88
+ phoneNumber?: string;
89
+ theme?: 'light' | 'dark' | 'system';
90
+ language?: string;
91
+ timezone?: string;
92
+ }
93
+ /**
94
+ * Update User Settings DTO
95
+ */
96
+ interface UpdateUserSettingsDTO {
97
+ theme?: 'light' | 'dark' | 'system';
98
+ language?: string;
99
+ timezone?: string;
100
+ currency?: string;
101
+ notifications?: Partial<User['settings']['notifications']>;
102
+ privacy?: Partial<User['settings']['privacy']>;
103
+ }
104
+ /**
105
+ * Update User Subscription DTO
106
+ */
107
+ interface UpdateUserSubscriptionDTO {
108
+ plan?: User['subscription']['plan'];
109
+ status?: User['subscription']['status'];
110
+ polarCustomerId?: string;
111
+ polarSubscriptionId?: string;
112
+ currentPeriodStart?: number;
113
+ currentPeriodEnd?: number;
114
+ cancelAtPeriodEnd?: boolean;
115
+ }
116
+ /**
117
+ * User Query Result
118
+ */
119
+ interface UserQueryResult {
120
+ user: User | null;
121
+ lastLoginAt?: number;
122
+ createdAt?: number;
123
+ }
124
+
125
+ /**
126
+ * Sign In Use Case
127
+ * @description Handles user sign in with email/password
128
+ */
129
+
130
+ declare class SignInUseCase {
131
+ private readonly authRepository;
132
+ constructor(authRepository: IAuthRepository);
133
+ /**
134
+ * Execute sign in use case
135
+ */
136
+ execute(dto: SignInDTO): Promise<UserCredential>;
137
+ /**
138
+ * Validate DTO
139
+ */
140
+ private validateDTO;
141
+ /**
142
+ * Handle errors
143
+ */
144
+ private handleError;
145
+ }
146
+
147
+ /**
148
+ * Sign Up Use Case
149
+ * @description Handles user registration with email/password
150
+ */
151
+
152
+ declare class SignUpUseCase {
153
+ private readonly authRepository;
154
+ private readonly userRepository;
155
+ constructor(authRepository: IAuthRepository, userRepository: IUserRepository);
156
+ /**
157
+ * Execute sign up use case
158
+ */
159
+ execute(dto: SignUpDTO): Promise<SignUpResult>;
160
+ /**
161
+ * Validate DTO
162
+ */
163
+ private validateDTO;
164
+ /**
165
+ * Handle errors
166
+ */
167
+ private handleError;
168
+ }
169
+
170
+ /**
171
+ * Sign In With Google Use Case
172
+ * @description Handles Google OAuth sign in/sign up
173
+ */
174
+
175
+ declare class SignInWithGoogleUseCase {
176
+ private readonly authRepository;
177
+ private readonly userRepository;
178
+ constructor(authRepository: IAuthRepository, userRepository: IUserRepository);
179
+ /**
180
+ * Execute Google sign in use case
181
+ */
182
+ execute(): Promise<UserCredential>;
183
+ /**
184
+ * Handle errors
185
+ */
186
+ private handleError;
187
+ }
188
+
189
+ /**
190
+ * Reset Password Use Case
191
+ * @description Handles password reset flow
192
+ */
193
+
194
+ declare class ResetPasswordUseCase {
195
+ private readonly authRepository;
196
+ constructor(authRepository: IAuthRepository);
197
+ /**
198
+ * Execute password reset use case
199
+ */
200
+ execute(dto: ResetPasswordDTO): Promise<void>;
201
+ /**
202
+ * Validate DTO
203
+ */
204
+ private validateDTO;
205
+ /**
206
+ * Handle errors
207
+ */
208
+ private handleError;
209
+ }
210
+
211
+ /**
212
+ * Sign Out Use Case
213
+ * @description Handles user sign out
214
+ */
215
+
216
+ declare class SignOutUseCase {
217
+ private readonly authRepository;
218
+ constructor(authRepository: IAuthRepository);
219
+ /**
220
+ * Execute sign out use case
221
+ */
222
+ execute(): Promise<void>;
223
+ }
224
+
225
+ /**
226
+ * Update Profile Use Case
227
+ * @description Handles user profile updates
228
+ */
229
+
230
+ declare class UpdateProfileUseCase {
231
+ private readonly authRepository;
232
+ constructor(authRepository: IAuthRepository);
233
+ /**
234
+ * Execute profile update use case
235
+ */
236
+ execute(dto: UpdateProfileDTO): Promise<void>;
237
+ /**
238
+ * Validate DTO
239
+ */
240
+ private validateDTO;
241
+ /**
242
+ * Validate URL format
243
+ */
244
+ private isValidURL;
245
+ /**
246
+ * Handle errors
247
+ */
248
+ private handleError;
249
+ }
250
+
251
+ /**
252
+ * Delete Account Use Case
253
+ * @description Handles user account deletion
254
+ */
255
+
256
+ declare class DeleteAccountUseCase {
257
+ private readonly authRepository;
258
+ constructor(authRepository: IAuthRepository);
259
+ /**
260
+ * Execute account deletion use case
261
+ */
262
+ execute(dto: DeleteAccountDTO): Promise<void>;
263
+ /**
264
+ * Validate DTO
265
+ */
266
+ private validateDTO;
267
+ /**
268
+ * Handle errors
269
+ */
270
+ private handleError;
271
+ }
272
+
273
+ export { type CreateUserDTO, type DeleteAccountDTO, DeleteAccountUseCase, type ResetPasswordDTO, ResetPasswordUseCase, type SignInDTO, SignInUseCase, SignInWithGoogleUseCase, SignOutUseCase, type SignUpDTO, type SignUpResult, SignUpUseCase, type UpdateEmailDTO, type UpdatePasswordDTO, type UpdateProfileDTO, UpdateProfileUseCase, type UpdateUserDTO, type UpdateUserSettingsDTO, type UpdateUserSubscriptionDTO, type UserQueryResult };
@@ -0,0 +1,273 @@
1
+ import { UserCredential } from 'firebase/auth';
2
+ import { c as User, I as IAuthRepository, a as IUserRepository } from '../user.repository.interface-DS74TsJ5.js';
3
+ import 'firebase/firestore';
4
+
5
+ /**
6
+ * Authentication DTOs
7
+ * @description Data Transfer Objects for authentication operations
8
+ */
9
+
10
+ /**
11
+ * Sign In DTO
12
+ */
13
+ interface SignInDTO {
14
+ email: string;
15
+ password: string;
16
+ }
17
+ /**
18
+ * Sign Up DTO
19
+ */
20
+ interface SignUpDTO {
21
+ email: string;
22
+ password: string;
23
+ displayName: string;
24
+ }
25
+ /**
26
+ * Sign Up Result
27
+ */
28
+ interface SignUpResult extends UserCredential {
29
+ userId: string;
30
+ emailVerified: boolean;
31
+ }
32
+ /**
33
+ * Reset Password DTO
34
+ */
35
+ interface ResetPasswordDTO {
36
+ email: string;
37
+ }
38
+ /**
39
+ * Update Profile DTO
40
+ */
41
+ interface UpdateProfileDTO {
42
+ displayName?: string;
43
+ photoURL?: string;
44
+ }
45
+ /**
46
+ * Update Email DTO
47
+ */
48
+ interface UpdateEmailDTO {
49
+ newEmail: string;
50
+ currentPassword: string;
51
+ }
52
+ /**
53
+ * Update Password DTO
54
+ */
55
+ interface UpdatePasswordDTO {
56
+ currentPassword: string;
57
+ newPassword: string;
58
+ }
59
+ /**
60
+ * Delete Account DTO
61
+ */
62
+ interface DeleteAccountDTO {
63
+ password: string;
64
+ }
65
+
66
+ /**
67
+ * User DTOs
68
+ * @description Data Transfer Objects for user operations
69
+ */
70
+
71
+ /**
72
+ * Create User DTO
73
+ */
74
+ interface CreateUserDTO {
75
+ id: string;
76
+ email: string;
77
+ displayName: string;
78
+ photoURL?: string;
79
+ phoneNumber?: string;
80
+ emailVerified: boolean;
81
+ }
82
+ /**
83
+ * Update User DTO
84
+ */
85
+ interface UpdateUserDTO {
86
+ displayName?: string;
87
+ photoURL?: string;
88
+ phoneNumber?: string;
89
+ theme?: 'light' | 'dark' | 'system';
90
+ language?: string;
91
+ timezone?: string;
92
+ }
93
+ /**
94
+ * Update User Settings DTO
95
+ */
96
+ interface UpdateUserSettingsDTO {
97
+ theme?: 'light' | 'dark' | 'system';
98
+ language?: string;
99
+ timezone?: string;
100
+ currency?: string;
101
+ notifications?: Partial<User['settings']['notifications']>;
102
+ privacy?: Partial<User['settings']['privacy']>;
103
+ }
104
+ /**
105
+ * Update User Subscription DTO
106
+ */
107
+ interface UpdateUserSubscriptionDTO {
108
+ plan?: User['subscription']['plan'];
109
+ status?: User['subscription']['status'];
110
+ polarCustomerId?: string;
111
+ polarSubscriptionId?: string;
112
+ currentPeriodStart?: number;
113
+ currentPeriodEnd?: number;
114
+ cancelAtPeriodEnd?: boolean;
115
+ }
116
+ /**
117
+ * User Query Result
118
+ */
119
+ interface UserQueryResult {
120
+ user: User | null;
121
+ lastLoginAt?: number;
122
+ createdAt?: number;
123
+ }
124
+
125
+ /**
126
+ * Sign In Use Case
127
+ * @description Handles user sign in with email/password
128
+ */
129
+
130
+ declare class SignInUseCase {
131
+ private readonly authRepository;
132
+ constructor(authRepository: IAuthRepository);
133
+ /**
134
+ * Execute sign in use case
135
+ */
136
+ execute(dto: SignInDTO): Promise<UserCredential>;
137
+ /**
138
+ * Validate DTO
139
+ */
140
+ private validateDTO;
141
+ /**
142
+ * Handle errors
143
+ */
144
+ private handleError;
145
+ }
146
+
147
+ /**
148
+ * Sign Up Use Case
149
+ * @description Handles user registration with email/password
150
+ */
151
+
152
+ declare class SignUpUseCase {
153
+ private readonly authRepository;
154
+ private readonly userRepository;
155
+ constructor(authRepository: IAuthRepository, userRepository: IUserRepository);
156
+ /**
157
+ * Execute sign up use case
158
+ */
159
+ execute(dto: SignUpDTO): Promise<SignUpResult>;
160
+ /**
161
+ * Validate DTO
162
+ */
163
+ private validateDTO;
164
+ /**
165
+ * Handle errors
166
+ */
167
+ private handleError;
168
+ }
169
+
170
+ /**
171
+ * Sign In With Google Use Case
172
+ * @description Handles Google OAuth sign in/sign up
173
+ */
174
+
175
+ declare class SignInWithGoogleUseCase {
176
+ private readonly authRepository;
177
+ private readonly userRepository;
178
+ constructor(authRepository: IAuthRepository, userRepository: IUserRepository);
179
+ /**
180
+ * Execute Google sign in use case
181
+ */
182
+ execute(): Promise<UserCredential>;
183
+ /**
184
+ * Handle errors
185
+ */
186
+ private handleError;
187
+ }
188
+
189
+ /**
190
+ * Reset Password Use Case
191
+ * @description Handles password reset flow
192
+ */
193
+
194
+ declare class ResetPasswordUseCase {
195
+ private readonly authRepository;
196
+ constructor(authRepository: IAuthRepository);
197
+ /**
198
+ * Execute password reset use case
199
+ */
200
+ execute(dto: ResetPasswordDTO): Promise<void>;
201
+ /**
202
+ * Validate DTO
203
+ */
204
+ private validateDTO;
205
+ /**
206
+ * Handle errors
207
+ */
208
+ private handleError;
209
+ }
210
+
211
+ /**
212
+ * Sign Out Use Case
213
+ * @description Handles user sign out
214
+ */
215
+
216
+ declare class SignOutUseCase {
217
+ private readonly authRepository;
218
+ constructor(authRepository: IAuthRepository);
219
+ /**
220
+ * Execute sign out use case
221
+ */
222
+ execute(): Promise<void>;
223
+ }
224
+
225
+ /**
226
+ * Update Profile Use Case
227
+ * @description Handles user profile updates
228
+ */
229
+
230
+ declare class UpdateProfileUseCase {
231
+ private readonly authRepository;
232
+ constructor(authRepository: IAuthRepository);
233
+ /**
234
+ * Execute profile update use case
235
+ */
236
+ execute(dto: UpdateProfileDTO): Promise<void>;
237
+ /**
238
+ * Validate DTO
239
+ */
240
+ private validateDTO;
241
+ /**
242
+ * Validate URL format
243
+ */
244
+ private isValidURL;
245
+ /**
246
+ * Handle errors
247
+ */
248
+ private handleError;
249
+ }
250
+
251
+ /**
252
+ * Delete Account Use Case
253
+ * @description Handles user account deletion
254
+ */
255
+
256
+ declare class DeleteAccountUseCase {
257
+ private readonly authRepository;
258
+ constructor(authRepository: IAuthRepository);
259
+ /**
260
+ * Execute account deletion use case
261
+ */
262
+ execute(dto: DeleteAccountDTO): Promise<void>;
263
+ /**
264
+ * Validate DTO
265
+ */
266
+ private validateDTO;
267
+ /**
268
+ * Handle errors
269
+ */
270
+ private handleError;
271
+ }
272
+
273
+ export { type CreateUserDTO, type DeleteAccountDTO, DeleteAccountUseCase, type ResetPasswordDTO, ResetPasswordUseCase, type SignInDTO, SignInUseCase, SignInWithGoogleUseCase, SignOutUseCase, type SignUpDTO, type SignUpResult, SignUpUseCase, type UpdateEmailDTO, type UpdatePasswordDTO, type UpdateProfileDTO, UpdateProfileUseCase, type UpdateUserDTO, type UpdateUserSettingsDTO, type UpdateUserSubscriptionDTO, type UserQueryResult };