@blackcode_sa/metaestetics-api 1.14.11 → 1.14.13
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 +35 -5
- package/dist/index.mjs +93 -59
- package/package.json +1 -1
- package/src/services/auth/auth.service.ts +41 -5
package/dist/index.js
CHANGED
|
@@ -15996,7 +15996,7 @@ var AuthService = class extends BaseService {
|
|
|
15996
15996
|
* @returns Object containing user and claimed practitioner
|
|
15997
15997
|
*/
|
|
15998
15998
|
async claimDraftProfilesWithGoogle(idToken, practitionerIds) {
|
|
15999
|
-
var _a, _b;
|
|
15999
|
+
var _a, _b, _c, _d;
|
|
16000
16000
|
try {
|
|
16001
16001
|
console.log("[AUTH] Starting claim draft profiles with Google", {
|
|
16002
16002
|
practitionerIdsCount: practitionerIds.length,
|
|
@@ -16013,6 +16013,7 @@ var AuthService = class extends BaseService {
|
|
|
16013
16013
|
console.log("[AUTH] currentUser IMMEDIATELY AFTER sign-in:", ((_b = this.auth.currentUser) == null ? void 0 : _b.uid) || "NULL");
|
|
16014
16014
|
console.log("[AUTH] User returned from signInWithCredential:", firebaseUser.uid);
|
|
16015
16015
|
const practitionerService = new PractitionerService(this.db, this.auth, this.app);
|
|
16016
|
+
console.log("[AUTH] currentUser after intializing practitionerService:", ((_c = this.auth.currentUser) == null ? void 0 : _c.uid) || "NULL");
|
|
16016
16017
|
let user = null;
|
|
16017
16018
|
try {
|
|
16018
16019
|
user = await this.userService.getUserById(firebaseUser.uid);
|
|
@@ -16021,11 +16022,40 @@ var AuthService = class extends BaseService {
|
|
|
16021
16022
|
console.log("[AUTH] User document does not exist, creating it...");
|
|
16022
16023
|
}
|
|
16023
16024
|
if (!user) {
|
|
16024
|
-
console.log("[AUTH] Creating user document for:", firebaseUser.uid);
|
|
16025
|
-
|
|
16026
|
-
|
|
16025
|
+
console.log("[AUTH] Creating user document DIRECTLY for:", firebaseUser.uid);
|
|
16026
|
+
console.log("[AUTH] Using THIS.auth.currentUser:", ((_d = this.auth.currentUser) == null ? void 0 : _d.uid) || "NULL");
|
|
16027
|
+
console.log("[AUTH] Using THIS.db:", this.db ? "EXISTS" : "NULL");
|
|
16028
|
+
const userData = {
|
|
16029
|
+
uid: firebaseUser.uid,
|
|
16030
|
+
email: firebaseUser.email,
|
|
16031
|
+
roles: ["practitioner" /* PRACTITIONER */],
|
|
16032
|
+
isAnonymous: firebaseUser.isAnonymous || false,
|
|
16033
|
+
createdAt: (0, import_firestore40.serverTimestamp)(),
|
|
16034
|
+
updatedAt: (0, import_firestore40.serverTimestamp)(),
|
|
16035
|
+
lastLoginAt: (0, import_firestore40.serverTimestamp)()
|
|
16036
|
+
};
|
|
16037
|
+
console.log("[AUTH] Attempting setDoc directly with userData:", {
|
|
16038
|
+
uid: userData.uid,
|
|
16039
|
+
email: userData.email,
|
|
16040
|
+
roles: userData.roles
|
|
16027
16041
|
});
|
|
16028
|
-
|
|
16042
|
+
try {
|
|
16043
|
+
await (0, import_firestore40.setDoc)((0, import_firestore40.doc)(this.db, USERS_COLLECTION, firebaseUser.uid), userData);
|
|
16044
|
+
console.log("[AUTH] \u2705 setDoc SUCCEEDED directly!");
|
|
16045
|
+
const userDoc = await (0, import_firestore40.getDoc)((0, import_firestore40.doc)(this.db, USERS_COLLECTION, firebaseUser.uid));
|
|
16046
|
+
if (!userDoc.exists()) {
|
|
16047
|
+
throw new Error("User document was not created");
|
|
16048
|
+
}
|
|
16049
|
+
user = userDoc.data();
|
|
16050
|
+
console.log("[AUTH] User document created successfully:", user.uid);
|
|
16051
|
+
} catch (error) {
|
|
16052
|
+
console.error("[AUTH] \u274C setDoc FAILED directly:", {
|
|
16053
|
+
errorCode: error == null ? void 0 : error.code,
|
|
16054
|
+
errorMessage: error == null ? void 0 : error.message,
|
|
16055
|
+
uid: firebaseUser.uid
|
|
16056
|
+
});
|
|
16057
|
+
throw error;
|
|
16058
|
+
}
|
|
16029
16059
|
}
|
|
16030
16060
|
let practitioner;
|
|
16031
16061
|
if (practitionerIds.length === 1) {
|
package/dist/index.mjs
CHANGED
|
@@ -7122,9 +7122,13 @@ import {
|
|
|
7122
7122
|
} from "firebase/auth";
|
|
7123
7123
|
import {
|
|
7124
7124
|
collection as collection21,
|
|
7125
|
+
doc as doc25,
|
|
7126
|
+
getDoc as getDoc27,
|
|
7127
|
+
setDoc as setDoc16,
|
|
7125
7128
|
query as query21,
|
|
7126
7129
|
getDocs as getDocs21,
|
|
7127
|
-
runTransaction
|
|
7130
|
+
runTransaction,
|
|
7131
|
+
serverTimestamp as serverTimestamp21
|
|
7128
7132
|
} from "firebase/firestore";
|
|
7129
7133
|
|
|
7130
7134
|
// src/types/user/index.ts
|
|
@@ -16083,7 +16087,7 @@ var AuthService = class extends BaseService {
|
|
|
16083
16087
|
* @returns Object containing user and claimed practitioner
|
|
16084
16088
|
*/
|
|
16085
16089
|
async claimDraftProfilesWithGoogle(idToken, practitionerIds) {
|
|
16086
|
-
var _a, _b;
|
|
16090
|
+
var _a, _b, _c, _d;
|
|
16087
16091
|
try {
|
|
16088
16092
|
console.log("[AUTH] Starting claim draft profiles with Google", {
|
|
16089
16093
|
practitionerIdsCount: practitionerIds.length,
|
|
@@ -16100,6 +16104,7 @@ var AuthService = class extends BaseService {
|
|
|
16100
16104
|
console.log("[AUTH] currentUser IMMEDIATELY AFTER sign-in:", ((_b = this.auth.currentUser) == null ? void 0 : _b.uid) || "NULL");
|
|
16101
16105
|
console.log("[AUTH] User returned from signInWithCredential:", firebaseUser.uid);
|
|
16102
16106
|
const practitionerService = new PractitionerService(this.db, this.auth, this.app);
|
|
16107
|
+
console.log("[AUTH] currentUser after intializing practitionerService:", ((_c = this.auth.currentUser) == null ? void 0 : _c.uid) || "NULL");
|
|
16103
16108
|
let user = null;
|
|
16104
16109
|
try {
|
|
16105
16110
|
user = await this.userService.getUserById(firebaseUser.uid);
|
|
@@ -16108,11 +16113,40 @@ var AuthService = class extends BaseService {
|
|
|
16108
16113
|
console.log("[AUTH] User document does not exist, creating it...");
|
|
16109
16114
|
}
|
|
16110
16115
|
if (!user) {
|
|
16111
|
-
console.log("[AUTH] Creating user document for:", firebaseUser.uid);
|
|
16112
|
-
|
|
16113
|
-
|
|
16116
|
+
console.log("[AUTH] Creating user document DIRECTLY for:", firebaseUser.uid);
|
|
16117
|
+
console.log("[AUTH] Using THIS.auth.currentUser:", ((_d = this.auth.currentUser) == null ? void 0 : _d.uid) || "NULL");
|
|
16118
|
+
console.log("[AUTH] Using THIS.db:", this.db ? "EXISTS" : "NULL");
|
|
16119
|
+
const userData = {
|
|
16120
|
+
uid: firebaseUser.uid,
|
|
16121
|
+
email: firebaseUser.email,
|
|
16122
|
+
roles: ["practitioner" /* PRACTITIONER */],
|
|
16123
|
+
isAnonymous: firebaseUser.isAnonymous || false,
|
|
16124
|
+
createdAt: serverTimestamp21(),
|
|
16125
|
+
updatedAt: serverTimestamp21(),
|
|
16126
|
+
lastLoginAt: serverTimestamp21()
|
|
16127
|
+
};
|
|
16128
|
+
console.log("[AUTH] Attempting setDoc directly with userData:", {
|
|
16129
|
+
uid: userData.uid,
|
|
16130
|
+
email: userData.email,
|
|
16131
|
+
roles: userData.roles
|
|
16114
16132
|
});
|
|
16115
|
-
|
|
16133
|
+
try {
|
|
16134
|
+
await setDoc16(doc25(this.db, USERS_COLLECTION, firebaseUser.uid), userData);
|
|
16135
|
+
console.log("[AUTH] \u2705 setDoc SUCCEEDED directly!");
|
|
16136
|
+
const userDoc = await getDoc27(doc25(this.db, USERS_COLLECTION, firebaseUser.uid));
|
|
16137
|
+
if (!userDoc.exists()) {
|
|
16138
|
+
throw new Error("User document was not created");
|
|
16139
|
+
}
|
|
16140
|
+
user = userDoc.data();
|
|
16141
|
+
console.log("[AUTH] User document created successfully:", user.uid);
|
|
16142
|
+
} catch (error) {
|
|
16143
|
+
console.error("[AUTH] \u274C setDoc FAILED directly:", {
|
|
16144
|
+
errorCode: error == null ? void 0 : error.code,
|
|
16145
|
+
errorMessage: error == null ? void 0 : error.message,
|
|
16146
|
+
uid: firebaseUser.uid
|
|
16147
|
+
});
|
|
16148
|
+
throw error;
|
|
16149
|
+
}
|
|
16116
16150
|
}
|
|
16117
16151
|
let practitioner;
|
|
16118
16152
|
if (practitionerIds.length === 1) {
|
|
@@ -16544,7 +16578,7 @@ var AuthService = class extends BaseService {
|
|
|
16544
16578
|
};
|
|
16545
16579
|
|
|
16546
16580
|
// src/services/calendar/calendar.v2.service.ts
|
|
16547
|
-
import { Timestamp as Timestamp29, serverTimestamp as
|
|
16581
|
+
import { Timestamp as Timestamp29, serverTimestamp as serverTimestamp27 } from "firebase/firestore";
|
|
16548
16582
|
import {
|
|
16549
16583
|
doc as doc32,
|
|
16550
16584
|
getDoc as getDoc33,
|
|
@@ -16569,7 +16603,7 @@ import {
|
|
|
16569
16603
|
where as where22,
|
|
16570
16604
|
orderBy as orderBy8,
|
|
16571
16605
|
Timestamp as Timestamp23,
|
|
16572
|
-
serverTimestamp as
|
|
16606
|
+
serverTimestamp as serverTimestamp22
|
|
16573
16607
|
} from "firebase/firestore";
|
|
16574
16608
|
|
|
16575
16609
|
// src/services/calendar/utils/docs.utils.ts
|
|
@@ -16618,8 +16652,8 @@ async function createClinicCalendarEventUtil(db, clinicId, eventData, generateId
|
|
|
16618
16652
|
const newEvent = {
|
|
16619
16653
|
id: eventId,
|
|
16620
16654
|
...eventData,
|
|
16621
|
-
createdAt:
|
|
16622
|
-
updatedAt:
|
|
16655
|
+
createdAt: serverTimestamp22(),
|
|
16656
|
+
updatedAt: serverTimestamp22()
|
|
16623
16657
|
};
|
|
16624
16658
|
await setDoc17(eventRef, newEvent);
|
|
16625
16659
|
return {
|
|
@@ -16632,7 +16666,7 @@ async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData)
|
|
|
16632
16666
|
const eventRef = getClinicCalendarEventDocRef(db, clinicId, eventId);
|
|
16633
16667
|
const updates = {
|
|
16634
16668
|
...updateData,
|
|
16635
|
-
updatedAt:
|
|
16669
|
+
updatedAt: serverTimestamp22()
|
|
16636
16670
|
};
|
|
16637
16671
|
await updateDoc22(eventRef, updates);
|
|
16638
16672
|
const updatedDoc = await getDoc28(eventRef);
|
|
@@ -16673,7 +16707,7 @@ import {
|
|
|
16673
16707
|
where as where23,
|
|
16674
16708
|
orderBy as orderBy9,
|
|
16675
16709
|
Timestamp as Timestamp24,
|
|
16676
|
-
serverTimestamp as
|
|
16710
|
+
serverTimestamp as serverTimestamp23
|
|
16677
16711
|
} from "firebase/firestore";
|
|
16678
16712
|
async function createPatientCalendarEventUtil(db, patientId, eventData, generateId2) {
|
|
16679
16713
|
const eventId = generateId2();
|
|
@@ -16681,8 +16715,8 @@ async function createPatientCalendarEventUtil(db, patientId, eventData, generate
|
|
|
16681
16715
|
const newEvent = {
|
|
16682
16716
|
id: eventId,
|
|
16683
16717
|
...eventData,
|
|
16684
|
-
createdAt:
|
|
16685
|
-
updatedAt:
|
|
16718
|
+
createdAt: serverTimestamp23(),
|
|
16719
|
+
updatedAt: serverTimestamp23()
|
|
16686
16720
|
};
|
|
16687
16721
|
await setDoc18(eventRef, newEvent);
|
|
16688
16722
|
return {
|
|
@@ -16695,7 +16729,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
|
|
|
16695
16729
|
const eventRef = getPatientCalendarEventDocRef(db, patientId, eventId);
|
|
16696
16730
|
const updates = {
|
|
16697
16731
|
...updateData,
|
|
16698
|
-
updatedAt:
|
|
16732
|
+
updatedAt: serverTimestamp23()
|
|
16699
16733
|
};
|
|
16700
16734
|
await updateDoc23(eventRef, updates);
|
|
16701
16735
|
const updatedDoc = await getDoc29(eventRef);
|
|
@@ -16717,7 +16751,7 @@ import {
|
|
|
16717
16751
|
where as where24,
|
|
16718
16752
|
orderBy as orderBy10,
|
|
16719
16753
|
Timestamp as Timestamp25,
|
|
16720
|
-
serverTimestamp as
|
|
16754
|
+
serverTimestamp as serverTimestamp24
|
|
16721
16755
|
} from "firebase/firestore";
|
|
16722
16756
|
async function createPractitionerCalendarEventUtil(db, practitionerId, eventData, generateId2) {
|
|
16723
16757
|
const eventId = generateId2();
|
|
@@ -16729,8 +16763,8 @@ async function createPractitionerCalendarEventUtil(db, practitionerId, eventData
|
|
|
16729
16763
|
const newEvent = {
|
|
16730
16764
|
id: eventId,
|
|
16731
16765
|
...eventData,
|
|
16732
|
-
createdAt:
|
|
16733
|
-
updatedAt:
|
|
16766
|
+
createdAt: serverTimestamp24(),
|
|
16767
|
+
updatedAt: serverTimestamp24()
|
|
16734
16768
|
};
|
|
16735
16769
|
await setDoc19(eventRef, newEvent);
|
|
16736
16770
|
return {
|
|
@@ -16747,7 +16781,7 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
|
|
|
16747
16781
|
);
|
|
16748
16782
|
const updates = {
|
|
16749
16783
|
...updateData,
|
|
16750
|
-
updatedAt:
|
|
16784
|
+
updatedAt: serverTimestamp24()
|
|
16751
16785
|
};
|
|
16752
16786
|
await updateDoc24(eventRef, updates);
|
|
16753
16787
|
const updatedDoc = await getDoc30(eventRef);
|
|
@@ -16820,7 +16854,7 @@ import {
|
|
|
16820
16854
|
where as where25,
|
|
16821
16855
|
orderBy as orderBy11,
|
|
16822
16856
|
Timestamp as Timestamp26,
|
|
16823
|
-
serverTimestamp as
|
|
16857
|
+
serverTimestamp as serverTimestamp25
|
|
16824
16858
|
} from "firebase/firestore";
|
|
16825
16859
|
async function searchCalendarEventsUtil(db, params) {
|
|
16826
16860
|
const { searchLocation, entityId, ...filters } = params;
|
|
@@ -16925,7 +16959,7 @@ import {
|
|
|
16925
16959
|
query as query26,
|
|
16926
16960
|
orderBy as orderBy12,
|
|
16927
16961
|
Timestamp as Timestamp27,
|
|
16928
|
-
serverTimestamp as
|
|
16962
|
+
serverTimestamp as serverTimestamp26
|
|
16929
16963
|
} from "firebase/firestore";
|
|
16930
16964
|
async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendarData, generateId2) {
|
|
16931
16965
|
const calendarId = generateId2();
|
|
@@ -16937,8 +16971,8 @@ async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
16937
16971
|
const newCalendar = {
|
|
16938
16972
|
id: calendarId,
|
|
16939
16973
|
...calendarData,
|
|
16940
|
-
createdAt:
|
|
16941
|
-
updatedAt:
|
|
16974
|
+
createdAt: serverTimestamp26(),
|
|
16975
|
+
updatedAt: serverTimestamp26()
|
|
16942
16976
|
};
|
|
16943
16977
|
await setDoc21(calendarRef, newCalendar);
|
|
16944
16978
|
return {
|
|
@@ -16953,8 +16987,8 @@ async function createPatientSyncedCalendarUtil(db, patientId, calendarData, gene
|
|
|
16953
16987
|
const newCalendar = {
|
|
16954
16988
|
id: calendarId,
|
|
16955
16989
|
...calendarData,
|
|
16956
|
-
createdAt:
|
|
16957
|
-
updatedAt:
|
|
16990
|
+
createdAt: serverTimestamp26(),
|
|
16991
|
+
updatedAt: serverTimestamp26()
|
|
16958
16992
|
};
|
|
16959
16993
|
await setDoc21(calendarRef, newCalendar);
|
|
16960
16994
|
return {
|
|
@@ -16969,8 +17003,8 @@ async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, genera
|
|
|
16969
17003
|
const newCalendar = {
|
|
16970
17004
|
id: calendarId,
|
|
16971
17005
|
...calendarData,
|
|
16972
|
-
createdAt:
|
|
16973
|
-
updatedAt:
|
|
17006
|
+
createdAt: serverTimestamp26(),
|
|
17007
|
+
updatedAt: serverTimestamp26()
|
|
16974
17008
|
};
|
|
16975
17009
|
await setDoc21(calendarRef, newCalendar);
|
|
16976
17010
|
return {
|
|
@@ -17042,7 +17076,7 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
17042
17076
|
);
|
|
17043
17077
|
const updates = {
|
|
17044
17078
|
...updateData,
|
|
17045
|
-
updatedAt:
|
|
17079
|
+
updatedAt: serverTimestamp26()
|
|
17046
17080
|
};
|
|
17047
17081
|
await updateDoc26(calendarRef, updates);
|
|
17048
17082
|
const updatedDoc = await getDoc32(calendarRef);
|
|
@@ -17055,7 +17089,7 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
|
|
|
17055
17089
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
17056
17090
|
const updates = {
|
|
17057
17091
|
...updateData,
|
|
17058
|
-
updatedAt:
|
|
17092
|
+
updatedAt: serverTimestamp26()
|
|
17059
17093
|
};
|
|
17060
17094
|
await updateDoc26(calendarRef, updates);
|
|
17061
17095
|
const updatedDoc = await getDoc32(calendarRef);
|
|
@@ -17068,7 +17102,7 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
|
|
|
17068
17102
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
17069
17103
|
const updates = {
|
|
17070
17104
|
...updateData,
|
|
17071
|
-
updatedAt:
|
|
17105
|
+
updatedAt: serverTimestamp26()
|
|
17072
17106
|
};
|
|
17073
17107
|
await updateDoc26(calendarRef, updates);
|
|
17074
17108
|
const updatedDoc = await getDoc32(calendarRef);
|
|
@@ -18290,8 +18324,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18290
18324
|
const newEvent = {
|
|
18291
18325
|
id: eventId,
|
|
18292
18326
|
...eventData,
|
|
18293
|
-
createdAt:
|
|
18294
|
-
updatedAt:
|
|
18327
|
+
createdAt: serverTimestamp27(),
|
|
18328
|
+
updatedAt: serverTimestamp27()
|
|
18295
18329
|
};
|
|
18296
18330
|
await setDoc22(eventRef, newEvent);
|
|
18297
18331
|
return {
|
|
@@ -18507,7 +18541,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18507
18541
|
end: Timestamp29.fromDate(endTime)
|
|
18508
18542
|
},
|
|
18509
18543
|
description: externalEvent.description || "",
|
|
18510
|
-
updatedAt:
|
|
18544
|
+
updatedAt: serverTimestamp27()
|
|
18511
18545
|
});
|
|
18512
18546
|
console.log(`Updated local event ${eventId} from external event`);
|
|
18513
18547
|
} catch (error) {
|
|
@@ -18534,7 +18568,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18534
18568
|
);
|
|
18535
18569
|
await updateDoc27(eventRef, {
|
|
18536
18570
|
status,
|
|
18537
|
-
updatedAt:
|
|
18571
|
+
updatedAt: serverTimestamp27()
|
|
18538
18572
|
});
|
|
18539
18573
|
console.log(`Updated event ${eventId} status to ${status}`);
|
|
18540
18574
|
} catch (error) {
|
|
@@ -18935,7 +18969,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18935
18969
|
}
|
|
18936
18970
|
await updateDoc27(eventRef, {
|
|
18937
18971
|
syncedCalendarEventId: syncIds,
|
|
18938
|
-
updatedAt:
|
|
18972
|
+
updatedAt: serverTimestamp27()
|
|
18939
18973
|
});
|
|
18940
18974
|
console.log(
|
|
18941
18975
|
`Updated event ${eventId} with sync ID ${syncEvent.eventId}`
|
|
@@ -19158,7 +19192,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19158
19192
|
};
|
|
19159
19193
|
|
|
19160
19194
|
// src/services/calendar/calendar.v3.service.ts
|
|
19161
|
-
import { Timestamp as Timestamp30, serverTimestamp as
|
|
19195
|
+
import { Timestamp as Timestamp30, serverTimestamp as serverTimestamp28 } from "firebase/firestore";
|
|
19162
19196
|
import { doc as doc33, getDoc as getDoc34, setDoc as setDoc23, updateDoc as updateDoc28, deleteDoc as deleteDoc15 } from "firebase/firestore";
|
|
19163
19197
|
var CalendarServiceV3 = class extends BaseService {
|
|
19164
19198
|
/**
|
|
@@ -19193,8 +19227,8 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
19193
19227
|
status: "confirmed" /* CONFIRMED */,
|
|
19194
19228
|
// Blocking events are always confirmed
|
|
19195
19229
|
syncStatus: "internal" /* INTERNAL */,
|
|
19196
|
-
createdAt:
|
|
19197
|
-
updatedAt:
|
|
19230
|
+
createdAt: serverTimestamp28(),
|
|
19231
|
+
updatedAt: serverTimestamp28()
|
|
19198
19232
|
};
|
|
19199
19233
|
if (params.entityType === "practitioner") {
|
|
19200
19234
|
eventData.practitionerProfileId = params.entityId;
|
|
@@ -19224,7 +19258,7 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
19224
19258
|
throw new Error(`Blocking event with ID ${params.eventId} not found`);
|
|
19225
19259
|
}
|
|
19226
19260
|
const updateData = {
|
|
19227
|
-
updatedAt:
|
|
19261
|
+
updatedAt: serverTimestamp28()
|
|
19228
19262
|
};
|
|
19229
19263
|
if (params.eventName !== void 0) {
|
|
19230
19264
|
updateData.eventName = params.eventName;
|
|
@@ -19471,7 +19505,7 @@ import {
|
|
|
19471
19505
|
setDoc as setDoc24,
|
|
19472
19506
|
deleteDoc as deleteDoc16,
|
|
19473
19507
|
Timestamp as Timestamp31,
|
|
19474
|
-
serverTimestamp as
|
|
19508
|
+
serverTimestamp as serverTimestamp29,
|
|
19475
19509
|
orderBy as orderBy13,
|
|
19476
19510
|
limit as limit12
|
|
19477
19511
|
} from "firebase/firestore";
|
|
@@ -19633,7 +19667,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19633
19667
|
const updateData = {
|
|
19634
19668
|
status: "accepted" /* ACCEPTED */,
|
|
19635
19669
|
acceptedAt: Timestamp31.now(),
|
|
19636
|
-
updatedAt:
|
|
19670
|
+
updatedAt: serverTimestamp29()
|
|
19637
19671
|
};
|
|
19638
19672
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
19639
19673
|
await updateDoc29(docRef, updateData);
|
|
@@ -19665,7 +19699,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19665
19699
|
status: "rejected" /* REJECTED */,
|
|
19666
19700
|
rejectionReason: rejectionReason || null,
|
|
19667
19701
|
rejectedAt: Timestamp31.now(),
|
|
19668
|
-
updatedAt:
|
|
19702
|
+
updatedAt: serverTimestamp29()
|
|
19669
19703
|
};
|
|
19670
19704
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
19671
19705
|
await updateDoc29(docRef, updateData);
|
|
@@ -19697,7 +19731,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19697
19731
|
status: "cancelled" /* CANCELLED */,
|
|
19698
19732
|
cancelReason: cancelReason || null,
|
|
19699
19733
|
cancelledAt: Timestamp31.now(),
|
|
19700
|
-
updatedAt:
|
|
19734
|
+
updatedAt: serverTimestamp29()
|
|
19701
19735
|
};
|
|
19702
19736
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
19703
19737
|
await updateDoc29(docRef, updateData);
|
|
@@ -20971,7 +21005,7 @@ import {
|
|
|
20971
21005
|
updateDoc as updateDoc34,
|
|
20972
21006
|
setDoc as setDoc27,
|
|
20973
21007
|
deleteDoc as deleteDoc19,
|
|
20974
|
-
serverTimestamp as
|
|
21008
|
+
serverTimestamp as serverTimestamp32,
|
|
20975
21009
|
writeBatch as writeBatch6,
|
|
20976
21010
|
orderBy as orderBy18,
|
|
20977
21011
|
limit as limit16,
|
|
@@ -21457,8 +21491,8 @@ var ProcedureService = class extends BaseService {
|
|
|
21457
21491
|
const procedureRef = doc39(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
21458
21492
|
await setDoc27(procedureRef, {
|
|
21459
21493
|
...newProcedure,
|
|
21460
|
-
createdAt:
|
|
21461
|
-
updatedAt:
|
|
21494
|
+
createdAt: serverTimestamp32(),
|
|
21495
|
+
updatedAt: serverTimestamp32()
|
|
21462
21496
|
});
|
|
21463
21497
|
const savedDoc = await getDoc40(procedureRef);
|
|
21464
21498
|
return savedDoc.data();
|
|
@@ -21585,8 +21619,8 @@ var ProcedureService = class extends BaseService {
|
|
|
21585
21619
|
const procedureRef = doc39(this.db, PROCEDURES_COLLECTION, newProcedureId);
|
|
21586
21620
|
await setDoc27(procedureRef, {
|
|
21587
21621
|
...newProcedure,
|
|
21588
|
-
createdAt:
|
|
21589
|
-
updatedAt:
|
|
21622
|
+
createdAt: serverTimestamp32(),
|
|
21623
|
+
updatedAt: serverTimestamp32()
|
|
21590
21624
|
});
|
|
21591
21625
|
const savedDoc = await getDoc40(procedureRef);
|
|
21592
21626
|
return savedDoc.data();
|
|
@@ -21687,8 +21721,8 @@ var ProcedureService = class extends BaseService {
|
|
|
21687
21721
|
const procedureRef = doc39(this.db, PROCEDURES_COLLECTION, newProcedureId);
|
|
21688
21722
|
batch.set(procedureRef, {
|
|
21689
21723
|
...newProcedure,
|
|
21690
|
-
createdAt:
|
|
21691
|
-
updatedAt:
|
|
21724
|
+
createdAt: serverTimestamp32(),
|
|
21725
|
+
updatedAt: serverTimestamp32()
|
|
21692
21726
|
});
|
|
21693
21727
|
}
|
|
21694
21728
|
await batch.commit();
|
|
@@ -21892,8 +21926,8 @@ var ProcedureService = class extends BaseService {
|
|
|
21892
21926
|
console.log("\u{1F525}\u{1F525}\u{1F525} NO UNDEFINED FIELDS - Proceeding with batch.set");
|
|
21893
21927
|
batch.set(procedureRef, {
|
|
21894
21928
|
...newProcedure,
|
|
21895
|
-
createdAt:
|
|
21896
|
-
updatedAt:
|
|
21929
|
+
createdAt: serverTimestamp32(),
|
|
21930
|
+
updatedAt: serverTimestamp32()
|
|
21897
21931
|
});
|
|
21898
21932
|
}
|
|
21899
21933
|
await batch.commit();
|
|
@@ -22127,7 +22161,7 @@ var ProcedureService = class extends BaseService {
|
|
|
22127
22161
|
}
|
|
22128
22162
|
await updateDoc34(procedureRef, {
|
|
22129
22163
|
...updatedProcedureData,
|
|
22130
|
-
updatedAt:
|
|
22164
|
+
updatedAt: serverTimestamp32()
|
|
22131
22165
|
});
|
|
22132
22166
|
const updatedSnapshot = await getDoc40(procedureRef);
|
|
22133
22167
|
return updatedSnapshot.data();
|
|
@@ -22145,7 +22179,7 @@ var ProcedureService = class extends BaseService {
|
|
|
22145
22179
|
}
|
|
22146
22180
|
await updateDoc34(procedureRef, {
|
|
22147
22181
|
isActive: false,
|
|
22148
|
-
updatedAt:
|
|
22182
|
+
updatedAt: serverTimestamp32()
|
|
22149
22183
|
});
|
|
22150
22184
|
}
|
|
22151
22185
|
/**
|
|
@@ -22822,8 +22856,8 @@ var ProcedureService = class extends BaseService {
|
|
|
22822
22856
|
const procedureRef = doc39(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
22823
22857
|
await setDoc27(procedureRef, {
|
|
22824
22858
|
...newProcedure,
|
|
22825
|
-
createdAt:
|
|
22826
|
-
updatedAt:
|
|
22859
|
+
createdAt: serverTimestamp32(),
|
|
22860
|
+
updatedAt: serverTimestamp32()
|
|
22827
22861
|
});
|
|
22828
22862
|
const savedDoc = await getDoc40(procedureRef);
|
|
22829
22863
|
return savedDoc.data();
|
|
@@ -22906,7 +22940,7 @@ import {
|
|
|
22906
22940
|
where as where34,
|
|
22907
22941
|
setDoc as setDoc28,
|
|
22908
22942
|
deleteDoc as deleteDoc20,
|
|
22909
|
-
serverTimestamp as
|
|
22943
|
+
serverTimestamp as serverTimestamp33
|
|
22910
22944
|
} from "firebase/firestore";
|
|
22911
22945
|
import { z as z27 } from "zod";
|
|
22912
22946
|
var ReviewService = class extends BaseService {
|
|
@@ -23060,8 +23094,8 @@ var ReviewService = class extends BaseService {
|
|
|
23060
23094
|
reviewSchema.parse(review);
|
|
23061
23095
|
const firestoreData = {
|
|
23062
23096
|
...review,
|
|
23063
|
-
createdAt:
|
|
23064
|
-
updatedAt:
|
|
23097
|
+
createdAt: serverTimestamp33(),
|
|
23098
|
+
updatedAt: serverTimestamp33()
|
|
23065
23099
|
};
|
|
23066
23100
|
Object.keys(firestoreData).forEach((key) => {
|
|
23067
23101
|
if (firestoreData[key] === void 0) {
|
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
Timestamp,
|
|
36
36
|
runTransaction,
|
|
37
37
|
Firestore,
|
|
38
|
+
serverTimestamp,
|
|
38
39
|
} from 'firebase/firestore';
|
|
39
40
|
import { FirebaseApp } from 'firebase/app';
|
|
40
41
|
import { User, UserRole, USERS_COLLECTION } from '../../types';
|
|
@@ -899,6 +900,7 @@ export class AuthService extends BaseService {
|
|
|
899
900
|
console.log('[AUTH] User returned from signInWithCredential:', firebaseUser.uid);
|
|
900
901
|
|
|
901
902
|
const practitionerService = new PractitionerService(this.db, this.auth, this.app);
|
|
903
|
+
console.log('[AUTH] currentUser after intializing practitionerService:', this.auth.currentUser?.uid || 'NULL');
|
|
902
904
|
|
|
903
905
|
// Step 1: Check if User document already exists
|
|
904
906
|
let user: User | null = null;
|
|
@@ -909,13 +911,47 @@ export class AuthService extends BaseService {
|
|
|
909
911
|
console.log('[AUTH] User document does not exist, creating it...');
|
|
910
912
|
}
|
|
911
913
|
|
|
912
|
-
// Step 2: Create User document
|
|
914
|
+
// Step 2: Create User document directly (bypassing UserService to test auth instance issue)
|
|
913
915
|
if (!user) {
|
|
914
|
-
console.log('[AUTH] Creating user document for:', firebaseUser.uid);
|
|
915
|
-
|
|
916
|
-
|
|
916
|
+
console.log('[AUTH] Creating user document DIRECTLY for:', firebaseUser.uid);
|
|
917
|
+
console.log('[AUTH] Using THIS.auth.currentUser:', this.auth.currentUser?.uid || 'NULL');
|
|
918
|
+
console.log('[AUTH] Using THIS.db:', this.db ? 'EXISTS' : 'NULL');
|
|
919
|
+
|
|
920
|
+
const userData = {
|
|
921
|
+
uid: firebaseUser.uid,
|
|
922
|
+
email: firebaseUser.email,
|
|
923
|
+
roles: [UserRole.PRACTITIONER],
|
|
924
|
+
isAnonymous: firebaseUser.isAnonymous || false,
|
|
925
|
+
createdAt: serverTimestamp(),
|
|
926
|
+
updatedAt: serverTimestamp(),
|
|
927
|
+
lastLoginAt: serverTimestamp(),
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
console.log('[AUTH] Attempting setDoc directly with userData:', {
|
|
931
|
+
uid: userData.uid,
|
|
932
|
+
email: userData.email,
|
|
933
|
+
roles: userData.roles,
|
|
917
934
|
});
|
|
918
|
-
|
|
935
|
+
|
|
936
|
+
try {
|
|
937
|
+
await setDoc(doc(this.db, USERS_COLLECTION, firebaseUser.uid), userData);
|
|
938
|
+
console.log('[AUTH] ✅ setDoc SUCCEEDED directly!');
|
|
939
|
+
|
|
940
|
+
// Fetch the created user
|
|
941
|
+
const userDoc = await getDoc(doc(this.db, USERS_COLLECTION, firebaseUser.uid));
|
|
942
|
+
if (!userDoc.exists()) {
|
|
943
|
+
throw new Error('User document was not created');
|
|
944
|
+
}
|
|
945
|
+
user = userDoc.data() as User;
|
|
946
|
+
console.log('[AUTH] User document created successfully:', user.uid);
|
|
947
|
+
} catch (error: any) {
|
|
948
|
+
console.error('[AUTH] ❌ setDoc FAILED directly:', {
|
|
949
|
+
errorCode: error?.code,
|
|
950
|
+
errorMessage: error?.message,
|
|
951
|
+
uid: firebaseUser.uid,
|
|
952
|
+
});
|
|
953
|
+
throw error;
|
|
954
|
+
}
|
|
919
955
|
}
|
|
920
956
|
|
|
921
957
|
// Step 3: Claim the draft profiles
|