@blackcode_sa/metaestetics-api 1.14.5 → 1.14.6

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/dist/index.js CHANGED
@@ -12906,6 +12906,23 @@ var UserService = class extends BaseService {
12906
12906
  * Kreira novog korisnika na osnovu Firebase korisnika
12907
12907
  */
12908
12908
  async createUser(firebaseUser, roles = ["patient" /* PATIENT */], options) {
12909
+ var _a, _b, _c, _d, _e, _f, _g, _h;
12910
+ console.log("[USER_SERVICE] ====== CREATE USER DEBUG ======");
12911
+ console.log("[USER_SERVICE] Current auth state:", {
12912
+ currentUser: ((_b = (_a = this.auth) == null ? void 0 : _a.currentUser) == null ? void 0 : _b.uid) || "NULL",
12913
+ currentUserEmail: ((_d = (_c = this.auth) == null ? void 0 : _c.currentUser) == null ? void 0 : _d.email) || "NULL",
12914
+ currentUserProvider: ((_f = (_e = this.auth) == null ? void 0 : _e.currentUser) == null ? void 0 : _f.providerId) || "NULL"
12915
+ });
12916
+ console.log("[USER_SERVICE] Firebase user passed to createUser:", {
12917
+ uid: (firebaseUser == null ? void 0 : firebaseUser.uid) || "NULL",
12918
+ email: (firebaseUser == null ? void 0 : firebaseUser.email) || "NULL",
12919
+ providerId: (firebaseUser == null ? void 0 : firebaseUser.providerId) || "NULL",
12920
+ isAnonymous: firebaseUser == null ? void 0 : firebaseUser.isAnonymous
12921
+ });
12922
+ console.log("[USER_SERVICE] Auth instances match:", ((_h = (_g = this.auth) == null ? void 0 : _g.currentUser) == null ? void 0 : _h.uid) === (firebaseUser == null ? void 0 : firebaseUser.uid));
12923
+ console.log("[USER_SERVICE] Document path:", `${USERS_COLLECTION}/${firebaseUser == null ? void 0 : firebaseUser.uid}`);
12924
+ console.log("[USER_SERVICE] Roles:", roles);
12925
+ console.log("[USER_SERVICE] ================================");
12909
12926
  const userData = {
12910
12927
  uid: firebaseUser.uid,
12911
12928
  email: firebaseUser.email,
@@ -12915,7 +12932,22 @@ var UserService = class extends BaseService {
12915
12932
  updatedAt: (0, import_firestore33.serverTimestamp)(),
12916
12933
  lastLoginAt: (0, import_firestore33.serverTimestamp)()
12917
12934
  };
12918
- await (0, import_firestore33.setDoc)((0, import_firestore33.doc)(this.db, USERS_COLLECTION, userData.uid), userData);
12935
+ console.log("[USER_SERVICE] Attempting setDoc with userData:", {
12936
+ uid: userData.uid,
12937
+ email: userData.email,
12938
+ roles: userData.roles
12939
+ });
12940
+ try {
12941
+ await (0, import_firestore33.setDoc)((0, import_firestore33.doc)(this.db, USERS_COLLECTION, userData.uid), userData);
12942
+ console.log("[USER_SERVICE] \u2705 setDoc SUCCEEDED for:", userData.uid);
12943
+ } catch (error) {
12944
+ console.error("[USER_SERVICE] \u274C setDoc FAILED:", {
12945
+ errorCode: error == null ? void 0 : error.code,
12946
+ errorMessage: error == null ? void 0 : error.message,
12947
+ uid: userData.uid
12948
+ });
12949
+ throw error;
12950
+ }
12919
12951
  if (options == null ? void 0 : options.skipProfileCreation) {
12920
12952
  return this.getUserById(userData.uid);
12921
12953
  }
package/dist/index.mjs CHANGED
@@ -12929,6 +12929,23 @@ var UserService = class extends BaseService {
12929
12929
  * Kreira novog korisnika na osnovu Firebase korisnika
12930
12930
  */
12931
12931
  async createUser(firebaseUser, roles = ["patient" /* PATIENT */], options) {
12932
+ var _a, _b, _c, _d, _e, _f, _g, _h;
12933
+ console.log("[USER_SERVICE] ====== CREATE USER DEBUG ======");
12934
+ console.log("[USER_SERVICE] Current auth state:", {
12935
+ currentUser: ((_b = (_a = this.auth) == null ? void 0 : _a.currentUser) == null ? void 0 : _b.uid) || "NULL",
12936
+ currentUserEmail: ((_d = (_c = this.auth) == null ? void 0 : _c.currentUser) == null ? void 0 : _d.email) || "NULL",
12937
+ currentUserProvider: ((_f = (_e = this.auth) == null ? void 0 : _e.currentUser) == null ? void 0 : _f.providerId) || "NULL"
12938
+ });
12939
+ console.log("[USER_SERVICE] Firebase user passed to createUser:", {
12940
+ uid: (firebaseUser == null ? void 0 : firebaseUser.uid) || "NULL",
12941
+ email: (firebaseUser == null ? void 0 : firebaseUser.email) || "NULL",
12942
+ providerId: (firebaseUser == null ? void 0 : firebaseUser.providerId) || "NULL",
12943
+ isAnonymous: firebaseUser == null ? void 0 : firebaseUser.isAnonymous
12944
+ });
12945
+ console.log("[USER_SERVICE] Auth instances match:", ((_h = (_g = this.auth) == null ? void 0 : _g.currentUser) == null ? void 0 : _h.uid) === (firebaseUser == null ? void 0 : firebaseUser.uid));
12946
+ console.log("[USER_SERVICE] Document path:", `${USERS_COLLECTION}/${firebaseUser == null ? void 0 : firebaseUser.uid}`);
12947
+ console.log("[USER_SERVICE] Roles:", roles);
12948
+ console.log("[USER_SERVICE] ================================");
12932
12949
  const userData = {
12933
12950
  uid: firebaseUser.uid,
12934
12951
  email: firebaseUser.email,
@@ -12938,7 +12955,22 @@ var UserService = class extends BaseService {
12938
12955
  updatedAt: serverTimestamp18(),
12939
12956
  lastLoginAt: serverTimestamp18()
12940
12957
  };
12941
- await setDoc12(doc21(this.db, USERS_COLLECTION, userData.uid), userData);
12958
+ console.log("[USER_SERVICE] Attempting setDoc with userData:", {
12959
+ uid: userData.uid,
12960
+ email: userData.email,
12961
+ roles: userData.roles
12962
+ });
12963
+ try {
12964
+ await setDoc12(doc21(this.db, USERS_COLLECTION, userData.uid), userData);
12965
+ console.log("[USER_SERVICE] \u2705 setDoc SUCCEEDED for:", userData.uid);
12966
+ } catch (error) {
12967
+ console.error("[USER_SERVICE] \u274C setDoc FAILED:", {
12968
+ errorCode: error == null ? void 0 : error.code,
12969
+ errorMessage: error == null ? void 0 : error.message,
12970
+ uid: userData.uid
12971
+ });
12972
+ throw error;
12973
+ }
12942
12974
  if (options == null ? void 0 : options.skipProfileCreation) {
12943
12975
  return this.getUserById(userData.uid);
12944
12976
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.14.5",
4
+ "version": "1.14.6",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -11,7 +11,6 @@ import {
11
11
  Timestamp,
12
12
  setDoc,
13
13
  serverTimestamp,
14
- FieldValue,
15
14
  } from 'firebase/firestore';
16
15
  import { initializeFirebase } from '../../config/firebase';
17
16
  import { User, UserRole, USERS_COLLECTION, CreateUserData } from '../../types';
@@ -90,6 +89,24 @@ export class UserService extends BaseService {
90
89
  skipProfileCreation?: boolean;
91
90
  },
92
91
  ): Promise<User> {
92
+ // DEBUG LOGGING - Check auth state before creating user document
93
+ console.log('[USER_SERVICE] ====== CREATE USER DEBUG ======');
94
+ console.log('[USER_SERVICE] Current auth state:', {
95
+ currentUser: this.auth?.currentUser?.uid || 'NULL',
96
+ currentUserEmail: this.auth?.currentUser?.email || 'NULL',
97
+ currentUserProvider: this.auth?.currentUser?.providerId || 'NULL',
98
+ });
99
+ console.log('[USER_SERVICE] Firebase user passed to createUser:', {
100
+ uid: firebaseUser?.uid || 'NULL',
101
+ email: firebaseUser?.email || 'NULL',
102
+ providerId: firebaseUser?.providerId || 'NULL',
103
+ isAnonymous: firebaseUser?.isAnonymous,
104
+ });
105
+ console.log('[USER_SERVICE] Auth instances match:', this.auth?.currentUser?.uid === firebaseUser?.uid);
106
+ console.log('[USER_SERVICE] Document path:', `${USERS_COLLECTION}/${firebaseUser?.uid}`);
107
+ console.log('[USER_SERVICE] Roles:', roles);
108
+ console.log('[USER_SERVICE] ================================');
109
+
93
110
  const userData: CreateUserData = {
94
111
  uid: firebaseUser.uid,
95
112
  email: firebaseUser.email,
@@ -100,8 +117,24 @@ export class UserService extends BaseService {
100
117
  lastLoginAt: serverTimestamp(),
101
118
  };
102
119
 
120
+ console.log('[USER_SERVICE] Attempting setDoc with userData:', {
121
+ uid: userData.uid,
122
+ email: userData.email,
123
+ roles: userData.roles,
124
+ });
125
+
103
126
  // Kreiramo osnovnog korisnika
104
- await setDoc(doc(this.db, USERS_COLLECTION, userData.uid), userData);
127
+ try {
128
+ await setDoc(doc(this.db, USERS_COLLECTION, userData.uid), userData);
129
+ console.log('[USER_SERVICE] ✅ setDoc SUCCEEDED for:', userData.uid);
130
+ } catch (error: any) {
131
+ console.error('[USER_SERVICE] ❌ setDoc FAILED:', {
132
+ errorCode: error?.code,
133
+ errorMessage: error?.message,
134
+ uid: userData.uid,
135
+ });
136
+ throw error;
137
+ }
105
138
 
106
139
  // Kreiramo odgovarajuće profile na osnovu rola
107
140
  if (options?.skipProfileCreation) {