@blackcode_sa/metaestetics-api 1.15.17-staging.4 → 1.15.17-staging.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/admin/index.d.mts +3 -1
- package/dist/admin/index.d.ts +3 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +102 -117
- package/dist/index.mjs +242 -257
- package/package.json +1 -1
- package/src/admin/aggregation/clinic/clinic.aggregation.service.ts +1 -1
- package/src/services/auth/auth.service.ts +16 -49
- package/src/services/clinic/clinic-group.service.ts +13 -6
- package/src/services/clinic/utils/clinic-group.utils.ts +97 -88
- package/src/types/clinic/index.ts +3 -1
- package/src/validations/clinic.schema.ts +4 -3
package/dist/index.mjs
CHANGED
|
@@ -482,11 +482,11 @@ var StaffInviteStatus = /* @__PURE__ */ ((StaffInviteStatus2) => {
|
|
|
482
482
|
var CLINIC_GROUPS_COLLECTION = "clinic_groups";
|
|
483
483
|
var CLINIC_ADMINS_COLLECTION = "clinic_admins";
|
|
484
484
|
var CLINICS_COLLECTION = "clinics";
|
|
485
|
-
var AdminTokenStatus = /* @__PURE__ */ ((
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
return
|
|
485
|
+
var AdminTokenStatus = /* @__PURE__ */ ((AdminTokenStatus3) => {
|
|
486
|
+
AdminTokenStatus3["ACTIVE"] = "active";
|
|
487
|
+
AdminTokenStatus3["USED"] = "used";
|
|
488
|
+
AdminTokenStatus3["EXPIRED"] = "expired";
|
|
489
|
+
return AdminTokenStatus3;
|
|
490
490
|
})(AdminTokenStatus || {});
|
|
491
491
|
var SubscriptionModel = /* @__PURE__ */ ((SubscriptionModel2) => {
|
|
492
492
|
SubscriptionModel2["NO_SUBSCRIPTION"] = "no_subscription";
|
|
@@ -2004,7 +2004,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2004
2004
|
* @param limit - Number of top procedures to return
|
|
2005
2005
|
* @returns Array of procedure popularity metrics
|
|
2006
2006
|
*/
|
|
2007
|
-
async getProcedurePopularity(dateRange,
|
|
2007
|
+
async getProcedurePopularity(dateRange, limit23 = 10) {
|
|
2008
2008
|
const appointments = await this.fetchAppointments(void 0, dateRange);
|
|
2009
2009
|
const completed = getCompletedAppointments(appointments);
|
|
2010
2010
|
const procedureMap = /* @__PURE__ */ new Map();
|
|
@@ -2033,7 +2033,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2033
2033
|
completedCount: data.count,
|
|
2034
2034
|
rank: 0
|
|
2035
2035
|
// Will be set after sorting
|
|
2036
|
-
})).sort((a, b) => b.appointmentCount - a.appointmentCount).slice(0,
|
|
2036
|
+
})).sort((a, b) => b.appointmentCount - a.appointmentCount).slice(0, limit23).map((item, index) => ({ ...item, rank: index + 1 }));
|
|
2037
2037
|
}
|
|
2038
2038
|
/**
|
|
2039
2039
|
* Get procedure profitability metrics
|
|
@@ -2042,7 +2042,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2042
2042
|
* @param limit - Number of top procedures to return
|
|
2043
2043
|
* @returns Array of procedure profitability metrics
|
|
2044
2044
|
*/
|
|
2045
|
-
async getProcedureProfitability(dateRange,
|
|
2045
|
+
async getProcedureProfitability(dateRange, limit23 = 10) {
|
|
2046
2046
|
const appointments = await this.fetchAppointments(void 0, dateRange);
|
|
2047
2047
|
const completed = getCompletedAppointments(appointments);
|
|
2048
2048
|
const procedureMap = /* @__PURE__ */ new Map();
|
|
@@ -2076,7 +2076,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2076
2076
|
appointmentCount: data.count,
|
|
2077
2077
|
rank: 0
|
|
2078
2078
|
// Will be set after sorting
|
|
2079
|
-
})).sort((a, b) => b.totalRevenue - a.totalRevenue).slice(0,
|
|
2079
|
+
})).sort((a, b) => b.totalRevenue - a.totalRevenue).slice(0, limit23).map((item, index) => ({ ...item, rank: index + 1 }));
|
|
2080
2080
|
}
|
|
2081
2081
|
// ==========================================
|
|
2082
2082
|
// Time Efficiency Analytics
|
|
@@ -5616,10 +5616,9 @@ var adminTokenSchema = z9.object({
|
|
|
5616
5616
|
email: z9.string().email().optional().nullable(),
|
|
5617
5617
|
status: z9.nativeEnum(AdminTokenStatus),
|
|
5618
5618
|
usedByUserRef: z9.string().optional(),
|
|
5619
|
+
clinicGroupId: z9.string(),
|
|
5619
5620
|
createdAt: z9.instanceof(Date).or(z9.instanceof(Timestamp7)),
|
|
5620
|
-
// Timestamp
|
|
5621
5621
|
expiresAt: z9.instanceof(Date).or(z9.instanceof(Timestamp7))
|
|
5622
|
-
// Timestamp
|
|
5623
5622
|
});
|
|
5624
5623
|
var stripeTransactionDataSchema = z9.object({
|
|
5625
5624
|
sessionId: z9.string().optional(),
|
|
@@ -5680,7 +5679,7 @@ var clinicGroupSchema = z9.object({
|
|
|
5680
5679
|
clinicsInfo: z9.array(clinicInfoSchema),
|
|
5681
5680
|
admins: z9.array(z9.string()),
|
|
5682
5681
|
adminsInfo: z9.array(adminInfoSchema),
|
|
5683
|
-
adminTokens: z9.array(adminTokenSchema),
|
|
5682
|
+
adminTokens: z9.array(adminTokenSchema).optional(),
|
|
5684
5683
|
ownerId: z9.string().nullable(),
|
|
5685
5684
|
createdAt: z9.instanceof(Date).or(z9.instanceof(Timestamp7)),
|
|
5686
5685
|
// Timestamp
|
|
@@ -9749,9 +9748,6 @@ import {
|
|
|
9749
9748
|
OAuthProvider
|
|
9750
9749
|
} from "firebase/auth";
|
|
9751
9750
|
import {
|
|
9752
|
-
collection as collection22,
|
|
9753
|
-
query as query22,
|
|
9754
|
-
getDocs as getDocs22,
|
|
9755
9751
|
runTransaction
|
|
9756
9752
|
} from "firebase/firestore";
|
|
9757
9753
|
import { z as z28 } from "zod";
|
|
@@ -15597,13 +15593,16 @@ var BillingTransactionsService = class extends BaseService {
|
|
|
15597
15593
|
// src/services/clinic/utils/clinic-group.utils.ts
|
|
15598
15594
|
import {
|
|
15599
15595
|
collection as collection17,
|
|
15596
|
+
collectionGroup as collectionGroup2,
|
|
15600
15597
|
doc as doc28,
|
|
15601
15598
|
getDoc as getDoc30,
|
|
15602
15599
|
getDocs as getDocs17,
|
|
15603
15600
|
query as query17,
|
|
15604
15601
|
where as where17,
|
|
15602
|
+
limit as limit9,
|
|
15605
15603
|
updateDoc as updateDoc24,
|
|
15606
15604
|
setDoc as setDoc17,
|
|
15605
|
+
deleteDoc as deleteDoc6,
|
|
15607
15606
|
Timestamp as Timestamp20
|
|
15608
15607
|
} from "firebase/firestore";
|
|
15609
15608
|
import { geohashForLocation as geohashForLocation2 } from "geofire-common";
|
|
@@ -15759,6 +15758,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
|
|
|
15759
15758
|
admins: [ownerId],
|
|
15760
15759
|
adminsInfo: [],
|
|
15761
15760
|
adminTokens: [],
|
|
15761
|
+
// @deprecated — tokens now in subcollection, kept for backward compat
|
|
15762
15762
|
ownerId,
|
|
15763
15763
|
createdAt: now,
|
|
15764
15764
|
updatedAt: now,
|
|
@@ -15943,6 +15943,10 @@ async function deactivateClinicGroup(db, groupId, app) {
|
|
|
15943
15943
|
app
|
|
15944
15944
|
);
|
|
15945
15945
|
}
|
|
15946
|
+
var ADMIN_TOKENS_SUBCOLLECTION = "adminTokens";
|
|
15947
|
+
function adminTokensRef(db, groupId) {
|
|
15948
|
+
return collection17(db, CLINIC_GROUPS_COLLECTION, groupId, ADMIN_TOKENS_SUBCOLLECTION);
|
|
15949
|
+
}
|
|
15946
15950
|
async function createAdminToken(db, groupId, creatorAdminId, app, data) {
|
|
15947
15951
|
const group = await getClinicGroup(db, groupId);
|
|
15948
15952
|
if (!group) {
|
|
@@ -15958,68 +15962,60 @@ async function createAdminToken(db, groupId, creatorAdminId, app, data) {
|
|
|
15958
15962
|
now.seconds + expiresInDays * 24 * 60 * 60,
|
|
15959
15963
|
now.nanoseconds
|
|
15960
15964
|
);
|
|
15965
|
+
const tokenRef = doc28(adminTokensRef(db, groupId));
|
|
15961
15966
|
const token = {
|
|
15962
|
-
id:
|
|
15967
|
+
id: tokenRef.id,
|
|
15963
15968
|
token: generateId(),
|
|
15964
15969
|
status: "active" /* ACTIVE */,
|
|
15965
15970
|
email,
|
|
15971
|
+
clinicGroupId: groupId,
|
|
15966
15972
|
createdAt: now,
|
|
15967
15973
|
expiresAt
|
|
15968
15974
|
};
|
|
15969
|
-
await
|
|
15970
|
-
db,
|
|
15971
|
-
groupId,
|
|
15972
|
-
{
|
|
15973
|
-
adminTokens: [...group.adminTokens, token]
|
|
15974
|
-
},
|
|
15975
|
-
app
|
|
15976
|
-
);
|
|
15975
|
+
await setDoc17(tokenRef, token);
|
|
15977
15976
|
return token;
|
|
15978
15977
|
}
|
|
15979
|
-
async function verifyAndUseAdminToken(db, groupId,
|
|
15980
|
-
const
|
|
15981
|
-
|
|
15982
|
-
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15978
|
+
async function verifyAndUseAdminToken(db, groupId, tokenValue, userRef, app) {
|
|
15979
|
+
const tokensQuery = query17(
|
|
15980
|
+
adminTokensRef(db, groupId),
|
|
15981
|
+
where17("token", "==", tokenValue),
|
|
15982
|
+
limit9(1)
|
|
15983
|
+
);
|
|
15984
|
+
const snapshot = await getDocs17(tokensQuery);
|
|
15985
|
+
if (snapshot.empty) {
|
|
15986
15986
|
throw new Error("Admin token not found");
|
|
15987
15987
|
}
|
|
15988
|
+
const tokenDoc = snapshot.docs[0];
|
|
15989
|
+
const adminToken = tokenDoc.data();
|
|
15988
15990
|
if (adminToken.status !== "active" /* ACTIVE */) {
|
|
15989
15991
|
throw new Error("Admin token is not active");
|
|
15990
15992
|
}
|
|
15991
15993
|
const now = Timestamp20.now();
|
|
15992
15994
|
if (adminToken.expiresAt.seconds < now.seconds) {
|
|
15993
|
-
|
|
15994
|
-
(t) => t.id === adminToken.id ? { ...t, status: "expired" /* EXPIRED */ } : t
|
|
15995
|
-
);
|
|
15996
|
-
await updateClinicGroup(
|
|
15997
|
-
db,
|
|
15998
|
-
groupId,
|
|
15999
|
-
{
|
|
16000
|
-
adminTokens: updatedTokens2
|
|
16001
|
-
},
|
|
16002
|
-
app
|
|
16003
|
-
);
|
|
15995
|
+
await updateDoc24(tokenDoc.ref, { status: "expired" /* EXPIRED */ });
|
|
16004
15996
|
throw new Error("Admin token has expired");
|
|
16005
15997
|
}
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
usedByUserRef: userRef
|
|
16011
|
-
} : t
|
|
16012
|
-
);
|
|
16013
|
-
await updateClinicGroup(
|
|
16014
|
-
db,
|
|
16015
|
-
groupId,
|
|
16016
|
-
{
|
|
16017
|
-
adminTokens: updatedTokens
|
|
16018
|
-
},
|
|
16019
|
-
app
|
|
16020
|
-
);
|
|
15998
|
+
await updateDoc24(tokenDoc.ref, {
|
|
15999
|
+
status: "used" /* USED */,
|
|
16000
|
+
usedByUserRef: userRef
|
|
16001
|
+
});
|
|
16021
16002
|
return true;
|
|
16022
16003
|
}
|
|
16004
|
+
async function findAdminTokenByValue(db, tokenValue) {
|
|
16005
|
+
const tokensQuery = query17(
|
|
16006
|
+
collectionGroup2(db, ADMIN_TOKENS_SUBCOLLECTION),
|
|
16007
|
+
where17("token", "==", tokenValue),
|
|
16008
|
+
where17("status", "==", "active" /* ACTIVE */),
|
|
16009
|
+
limit9(1)
|
|
16010
|
+
);
|
|
16011
|
+
const snapshot = await getDocs17(tokensQuery);
|
|
16012
|
+
if (snapshot.empty) return null;
|
|
16013
|
+
const tokenData = snapshot.docs[0].data();
|
|
16014
|
+
return {
|
|
16015
|
+
token: tokenData,
|
|
16016
|
+
clinicGroupId: tokenData.clinicGroupId
|
|
16017
|
+
};
|
|
16018
|
+
}
|
|
16023
16019
|
async function deleteAdminToken(db, groupId, tokenId, adminId, app) {
|
|
16024
16020
|
const group = await getClinicGroup(db, groupId);
|
|
16025
16021
|
if (!group) {
|
|
@@ -16028,15 +16024,7 @@ async function deleteAdminToken(db, groupId, tokenId, adminId, app) {
|
|
|
16028
16024
|
if (!group.admins.includes(adminId)) {
|
|
16029
16025
|
throw new Error("Admin does not belong to this clinic group");
|
|
16030
16026
|
}
|
|
16031
|
-
|
|
16032
|
-
await updateClinicGroup(
|
|
16033
|
-
db,
|
|
16034
|
-
groupId,
|
|
16035
|
-
{
|
|
16036
|
-
adminTokens: updatedTokens
|
|
16037
|
-
},
|
|
16038
|
-
app
|
|
16039
|
-
);
|
|
16027
|
+
await deleteDoc6(doc28(adminTokensRef(db, groupId), tokenId));
|
|
16040
16028
|
}
|
|
16041
16029
|
async function getActiveAdminTokens(db, groupId, adminId, app) {
|
|
16042
16030
|
const group = await getClinicGroup(db, groupId);
|
|
@@ -16046,7 +16034,23 @@ async function getActiveAdminTokens(db, groupId, adminId, app) {
|
|
|
16046
16034
|
if (!group.admins.includes(adminId)) {
|
|
16047
16035
|
throw new Error("Admin does not belong to this clinic group");
|
|
16048
16036
|
}
|
|
16049
|
-
|
|
16037
|
+
const tokensQuery = query17(
|
|
16038
|
+
adminTokensRef(db, groupId),
|
|
16039
|
+
where17("status", "==", "active" /* ACTIVE */)
|
|
16040
|
+
);
|
|
16041
|
+
const snapshot = await getDocs17(tokensQuery);
|
|
16042
|
+
return snapshot.docs.map((d) => d.data());
|
|
16043
|
+
}
|
|
16044
|
+
async function getAllAdminTokens(db, groupId, adminId, app) {
|
|
16045
|
+
const group = await getClinicGroup(db, groupId);
|
|
16046
|
+
if (!group) {
|
|
16047
|
+
throw new Error("Clinic group not found");
|
|
16048
|
+
}
|
|
16049
|
+
if (!group.admins.includes(adminId)) {
|
|
16050
|
+
throw new Error("Admin does not belong to this clinic group");
|
|
16051
|
+
}
|
|
16052
|
+
const snapshot = await getDocs17(adminTokensRef(db, groupId));
|
|
16053
|
+
return snapshot.docs.map((d) => d.data());
|
|
16050
16054
|
}
|
|
16051
16055
|
|
|
16052
16056
|
// src/services/clinic/clinic-group.service.ts
|
|
@@ -16176,11 +16180,19 @@ var ClinicGroupService = class extends BaseService {
|
|
|
16176
16180
|
async getActiveAdminTokens(groupId, adminId) {
|
|
16177
16181
|
return getActiveAdminTokens(this.db, groupId, adminId, this.app);
|
|
16178
16182
|
}
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16183
|
+
/**
|
|
16184
|
+
* Gets ALL admin tokens for a clinic group (all statuses)
|
|
16185
|
+
*/
|
|
16186
|
+
async getAllAdminTokens(groupId, adminId) {
|
|
16187
|
+
return getAllAdminTokens(this.db, groupId, adminId, this.app);
|
|
16188
|
+
}
|
|
16189
|
+
/**
|
|
16190
|
+
* Finds an admin token by its value across all clinic groups.
|
|
16191
|
+
* Uses a collection group query for O(1) lookup.
|
|
16192
|
+
*/
|
|
16193
|
+
async findAdminTokenByValue(tokenValue) {
|
|
16194
|
+
return findAdminTokenByValue(this.db, tokenValue);
|
|
16195
|
+
}
|
|
16184
16196
|
/**
|
|
16185
16197
|
* Updates the onboarding status for a clinic group
|
|
16186
16198
|
*
|
|
@@ -16278,7 +16290,7 @@ import {
|
|
|
16278
16290
|
updateDoc as updateDoc25,
|
|
16279
16291
|
setDoc as setDoc18,
|
|
16280
16292
|
Timestamp as Timestamp21,
|
|
16281
|
-
limit as
|
|
16293
|
+
limit as limit10,
|
|
16282
16294
|
startAfter as startAfter8
|
|
16283
16295
|
} from "firebase/firestore";
|
|
16284
16296
|
import {
|
|
@@ -16567,10 +16579,10 @@ async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners
|
|
|
16567
16579
|
clinicsQuery = query18(
|
|
16568
16580
|
clinicsCollection,
|
|
16569
16581
|
startAfter8(lastDoc),
|
|
16570
|
-
|
|
16582
|
+
limit10(pagination)
|
|
16571
16583
|
);
|
|
16572
16584
|
} else {
|
|
16573
|
-
clinicsQuery = query18(clinicsCollection,
|
|
16585
|
+
clinicsQuery = query18(clinicsCollection, limit10(pagination));
|
|
16574
16586
|
}
|
|
16575
16587
|
}
|
|
16576
16588
|
const clinicsSnapshot = await getDocs18(clinicsQuery);
|
|
@@ -16763,8 +16775,8 @@ import {
|
|
|
16763
16775
|
where as where20,
|
|
16764
16776
|
getDocs as getDocs20,
|
|
16765
16777
|
startAfter as startAfter9,
|
|
16766
|
-
limit as
|
|
16767
|
-
orderBy as
|
|
16778
|
+
limit as limit11,
|
|
16779
|
+
orderBy as orderBy7
|
|
16768
16780
|
} from "firebase/firestore";
|
|
16769
16781
|
import { geohashQueryBounds as geohashQueryBounds3, distanceBetween as distanceBetween4 } from "geofire-common";
|
|
16770
16782
|
async function getClinicsByFilters(db, filters) {
|
|
@@ -16851,7 +16863,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16851
16863
|
const constraints = getBaseConstraints();
|
|
16852
16864
|
constraints.push(where20("nameLower", ">=", searchTerm));
|
|
16853
16865
|
constraints.push(where20("nameLower", "<=", searchTerm + "\uF8FF"));
|
|
16854
|
-
constraints.push(
|
|
16866
|
+
constraints.push(orderBy7("nameLower"));
|
|
16855
16867
|
if (filters.lastDoc) {
|
|
16856
16868
|
if (typeof filters.lastDoc.data === "function") {
|
|
16857
16869
|
constraints.push(startAfter9(filters.lastDoc));
|
|
@@ -16861,7 +16873,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16861
16873
|
constraints.push(startAfter9(filters.lastDoc));
|
|
16862
16874
|
}
|
|
16863
16875
|
}
|
|
16864
|
-
constraints.push(
|
|
16876
|
+
constraints.push(limit11(filters.pagination || 5));
|
|
16865
16877
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16866
16878
|
const querySnapshot = await getDocs20(q);
|
|
16867
16879
|
let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
|
|
@@ -16886,7 +16898,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16886
16898
|
const constraints = getBaseConstraints();
|
|
16887
16899
|
constraints.push(where20("name", ">=", searchTerm));
|
|
16888
16900
|
constraints.push(where20("name", "<=", searchTerm + "\uF8FF"));
|
|
16889
|
-
constraints.push(
|
|
16901
|
+
constraints.push(orderBy7("name"));
|
|
16890
16902
|
if (filters.lastDoc) {
|
|
16891
16903
|
if (typeof filters.lastDoc.data === "function") {
|
|
16892
16904
|
constraints.push(startAfter9(filters.lastDoc));
|
|
@@ -16896,7 +16908,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16896
16908
|
constraints.push(startAfter9(filters.lastDoc));
|
|
16897
16909
|
}
|
|
16898
16910
|
}
|
|
16899
|
-
constraints.push(
|
|
16911
|
+
constraints.push(limit11(filters.pagination || 5));
|
|
16900
16912
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16901
16913
|
const querySnapshot = await getDocs20(q);
|
|
16902
16914
|
let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
|
|
@@ -16919,7 +16931,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16919
16931
|
"[CLINIC_SERVICE] Strategy 3: Using createdAt ordering with client-side filtering"
|
|
16920
16932
|
);
|
|
16921
16933
|
const constraints = getBaseConstraints();
|
|
16922
|
-
constraints.push(
|
|
16934
|
+
constraints.push(orderBy7("createdAt", "desc"));
|
|
16923
16935
|
if (filters.lastDoc) {
|
|
16924
16936
|
if (typeof filters.lastDoc.data === "function") {
|
|
16925
16937
|
constraints.push(startAfter9(filters.lastDoc));
|
|
@@ -16929,7 +16941,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16929
16941
|
constraints.push(startAfter9(filters.lastDoc));
|
|
16930
16942
|
}
|
|
16931
16943
|
}
|
|
16932
|
-
constraints.push(
|
|
16944
|
+
constraints.push(limit11(filters.pagination || 5));
|
|
16933
16945
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16934
16946
|
const querySnapshot = await getDocs20(q);
|
|
16935
16947
|
let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
|
|
@@ -16947,8 +16959,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16947
16959
|
console.log("[CLINIC_SERVICE] Strategy 4: Minimal fallback");
|
|
16948
16960
|
const constraints = [
|
|
16949
16961
|
where20("isActive", "==", true),
|
|
16950
|
-
|
|
16951
|
-
|
|
16962
|
+
orderBy7("createdAt", "desc"),
|
|
16963
|
+
limit11(filters.pagination || 5)
|
|
16952
16964
|
];
|
|
16953
16965
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16954
16966
|
const querySnapshot = await getDocs20(q);
|
|
@@ -17856,7 +17868,6 @@ var AuthService = class extends BaseService {
|
|
|
17856
17868
|
});
|
|
17857
17869
|
console.log("[AUTH] Updating admin with clinic group ID");
|
|
17858
17870
|
await clinicAdminService.updateClinicAdmin(adminProfile.id, {
|
|
17859
|
-
// Use admin profile ID, not user UID
|
|
17860
17871
|
clinicGroupId: clinicGroup.id
|
|
17861
17872
|
});
|
|
17862
17873
|
console.log("[AUTH] Admin updated with clinic group ID successfully");
|
|
@@ -17874,46 +17885,20 @@ var AuthService = class extends BaseService {
|
|
|
17874
17885
|
console.log("[AUTH] Invite token provided", {
|
|
17875
17886
|
token: data.inviteToken
|
|
17876
17887
|
});
|
|
17877
|
-
console.log("[AUTH] Searching for token
|
|
17878
|
-
const
|
|
17879
|
-
|
|
17880
|
-
|
|
17881
|
-
let foundGroup = null;
|
|
17882
|
-
let foundToken = null;
|
|
17883
|
-
console.log("[AUTH] Found", querySnapshot.size, "clinic groups to check");
|
|
17884
|
-
for (const docSnapshot of querySnapshot.docs) {
|
|
17885
|
-
const group = docSnapshot.data();
|
|
17886
|
-
console.log("[AUTH] Checking group", {
|
|
17887
|
-
groupId: group.id,
|
|
17888
|
-
groupName: group.name
|
|
17889
|
-
});
|
|
17890
|
-
const token = group.adminTokens.find((t) => {
|
|
17891
|
-
const isMatch = t.token === data.inviteToken && t.status === "active" /* ACTIVE */ && new Date(t.expiresAt.toDate()) > /* @__PURE__ */ new Date();
|
|
17892
|
-
console.log("[AUTH] Checking token", {
|
|
17893
|
-
tokenId: t.id,
|
|
17894
|
-
tokenMatch: t.token === data.inviteToken,
|
|
17895
|
-
tokenStatus: t.status,
|
|
17896
|
-
tokenActive: t.status === "active" /* ACTIVE */,
|
|
17897
|
-
tokenExpiry: new Date(t.expiresAt.toDate()),
|
|
17898
|
-
tokenExpired: new Date(t.expiresAt.toDate()) <= /* @__PURE__ */ new Date(),
|
|
17899
|
-
isMatch
|
|
17900
|
-
});
|
|
17901
|
-
return isMatch;
|
|
17902
|
-
});
|
|
17903
|
-
if (token) {
|
|
17904
|
-
foundGroup = group;
|
|
17905
|
-
foundToken = token;
|
|
17906
|
-
console.log("[AUTH] Found matching token in group", {
|
|
17907
|
-
groupId: group.id,
|
|
17908
|
-
tokenId: token.id
|
|
17909
|
-
});
|
|
17910
|
-
break;
|
|
17911
|
-
}
|
|
17912
|
-
}
|
|
17913
|
-
if (!foundGroup || !foundToken) {
|
|
17914
|
-
console.error("[AUTH] No valid token found in any clinic group");
|
|
17888
|
+
console.log("[AUTH] Searching for token via collection group query");
|
|
17889
|
+
const tokenResult = await clinicGroupService.findAdminTokenByValue(data.inviteToken);
|
|
17890
|
+
if (!tokenResult) {
|
|
17891
|
+
console.error("[AUTH] No valid active token found");
|
|
17915
17892
|
throw new Error("Invalid or expired invite token");
|
|
17916
17893
|
}
|
|
17894
|
+
console.log("[AUTH] Found matching token", {
|
|
17895
|
+
tokenId: tokenResult.token.id,
|
|
17896
|
+
clinicGroupId: tokenResult.clinicGroupId
|
|
17897
|
+
});
|
|
17898
|
+
const foundGroup = await clinicGroupService.getClinicGroup(tokenResult.clinicGroupId);
|
|
17899
|
+
if (!foundGroup) {
|
|
17900
|
+
throw new Error("Clinic group not found for token");
|
|
17901
|
+
}
|
|
17917
17902
|
clinicGroup = foundGroup;
|
|
17918
17903
|
console.log("[AUTH] Creating clinic admin");
|
|
17919
17904
|
const createClinicAdminData = {
|
|
@@ -18743,7 +18728,7 @@ import {
|
|
|
18743
18728
|
deleteDoc as deleteDoc10,
|
|
18744
18729
|
query as query23,
|
|
18745
18730
|
where as where23,
|
|
18746
|
-
orderBy as
|
|
18731
|
+
orderBy as orderBy9,
|
|
18747
18732
|
Timestamp as Timestamp24,
|
|
18748
18733
|
serverTimestamp as serverTimestamp25
|
|
18749
18734
|
} from "firebase/firestore";
|
|
@@ -18847,7 +18832,7 @@ import {
|
|
|
18847
18832
|
deleteDoc as deleteDoc11,
|
|
18848
18833
|
query as query24,
|
|
18849
18834
|
where as where24,
|
|
18850
|
-
orderBy as
|
|
18835
|
+
orderBy as orderBy10,
|
|
18851
18836
|
Timestamp as Timestamp25,
|
|
18852
18837
|
serverTimestamp as serverTimestamp26
|
|
18853
18838
|
} from "firebase/firestore";
|
|
@@ -18891,7 +18876,7 @@ import {
|
|
|
18891
18876
|
deleteDoc as deleteDoc12,
|
|
18892
18877
|
query as query25,
|
|
18893
18878
|
where as where25,
|
|
18894
|
-
orderBy as
|
|
18879
|
+
orderBy as orderBy11,
|
|
18895
18880
|
Timestamp as Timestamp26,
|
|
18896
18881
|
serverTimestamp as serverTimestamp27
|
|
18897
18882
|
} from "firebase/firestore";
|
|
@@ -18994,7 +18979,7 @@ import {
|
|
|
18994
18979
|
deleteDoc as deleteDoc13,
|
|
18995
18980
|
query as query26,
|
|
18996
18981
|
where as where26,
|
|
18997
|
-
orderBy as
|
|
18982
|
+
orderBy as orderBy12,
|
|
18998
18983
|
Timestamp as Timestamp27,
|
|
18999
18984
|
serverTimestamp as serverTimestamp28
|
|
19000
18985
|
} from "firebase/firestore";
|
|
@@ -19121,7 +19106,7 @@ import {
|
|
|
19121
19106
|
updateDoc as updateDoc32,
|
|
19122
19107
|
deleteDoc as deleteDoc14,
|
|
19123
19108
|
query as query27,
|
|
19124
|
-
orderBy as
|
|
19109
|
+
orderBy as orderBy13,
|
|
19125
19110
|
Timestamp as Timestamp28,
|
|
19126
19111
|
serverTimestamp as serverTimestamp29
|
|
19127
19112
|
} from "firebase/firestore";
|
|
@@ -19194,7 +19179,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
19194
19179
|
db,
|
|
19195
19180
|
`practitioners/${practitionerId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
19196
19181
|
);
|
|
19197
|
-
const q = query27(calendarsRef,
|
|
19182
|
+
const q = query27(calendarsRef, orderBy13("createdAt", "desc"));
|
|
19198
19183
|
const querySnapshot = await getDocs27(q);
|
|
19199
19184
|
return querySnapshot.docs.map((doc54) => doc54.data());
|
|
19200
19185
|
}
|
|
@@ -19211,7 +19196,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
19211
19196
|
db,
|
|
19212
19197
|
`patients/${patientId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
19213
19198
|
);
|
|
19214
|
-
const q = query27(calendarsRef,
|
|
19199
|
+
const q = query27(calendarsRef, orderBy13("createdAt", "desc"));
|
|
19215
19200
|
const querySnapshot = await getDocs27(q);
|
|
19216
19201
|
return querySnapshot.docs.map((doc54) => doc54.data());
|
|
19217
19202
|
}
|
|
@@ -19228,7 +19213,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
19228
19213
|
db,
|
|
19229
19214
|
`clinics/${clinicId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
19230
19215
|
);
|
|
19231
|
-
const q = query27(calendarsRef,
|
|
19216
|
+
const q = query27(calendarsRef, orderBy13("createdAt", "desc"));
|
|
19232
19217
|
const querySnapshot = await getDocs27(q);
|
|
19233
19218
|
return querySnapshot.docs.map((doc54) => doc54.data());
|
|
19234
19219
|
}
|
|
@@ -21670,8 +21655,8 @@ import {
|
|
|
21670
21655
|
deleteDoc as deleteDoc16,
|
|
21671
21656
|
Timestamp as Timestamp32,
|
|
21672
21657
|
serverTimestamp as serverTimestamp32,
|
|
21673
|
-
orderBy as
|
|
21674
|
-
limit as
|
|
21658
|
+
orderBy as orderBy14,
|
|
21659
|
+
limit as limit13
|
|
21675
21660
|
} from "firebase/firestore";
|
|
21676
21661
|
var PractitionerInviteService = class extends BaseService {
|
|
21677
21662
|
constructor(db, auth, app) {
|
|
@@ -21766,7 +21751,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21766
21751
|
try {
|
|
21767
21752
|
const constraints = [
|
|
21768
21753
|
where29("practitionerId", "==", practitionerId),
|
|
21769
|
-
|
|
21754
|
+
orderBy14("createdAt", "desc")
|
|
21770
21755
|
];
|
|
21771
21756
|
if (statusFilter && statusFilter.length > 0) {
|
|
21772
21757
|
constraints.push(where29("status", "in", statusFilter));
|
|
@@ -21795,7 +21780,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21795
21780
|
try {
|
|
21796
21781
|
const constraints = [
|
|
21797
21782
|
where29("clinicId", "==", clinicId),
|
|
21798
|
-
|
|
21783
|
+
orderBy14("createdAt", "desc")
|
|
21799
21784
|
];
|
|
21800
21785
|
if (statusFilter && statusFilter.length > 0) {
|
|
21801
21786
|
constraints.push(where29("status", "in", statusFilter));
|
|
@@ -21951,9 +21936,9 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21951
21936
|
}
|
|
21952
21937
|
const orderField = filters.orderBy || "createdAt";
|
|
21953
21938
|
const orderDirection = filters.orderDirection || "desc";
|
|
21954
|
-
constraints.push(
|
|
21939
|
+
constraints.push(orderBy14(orderField, orderDirection));
|
|
21955
21940
|
if (filters.limit) {
|
|
21956
|
-
constraints.push(
|
|
21941
|
+
constraints.push(limit13(filters.limit));
|
|
21957
21942
|
}
|
|
21958
21943
|
const q = query29(
|
|
21959
21944
|
collection29(this.db, PRACTITIONER_INVITES_COLLECTION),
|
|
@@ -22044,8 +22029,8 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
22044
22029
|
collection29(this.db, PRACTITIONER_INVITES_COLLECTION),
|
|
22045
22030
|
where29("practitionerId", "==", practitionerId),
|
|
22046
22031
|
where29("clinicId", "==", clinicId),
|
|
22047
|
-
|
|
22048
|
-
|
|
22032
|
+
orderBy14("createdAt", "desc"),
|
|
22033
|
+
limit13(1)
|
|
22049
22034
|
);
|
|
22050
22035
|
const querySnapshot = await getDocs29(q);
|
|
22051
22036
|
if (querySnapshot.empty) {
|
|
@@ -22073,8 +22058,8 @@ import {
|
|
|
22073
22058
|
deleteDoc as deleteDoc17,
|
|
22074
22059
|
query as query30,
|
|
22075
22060
|
where as where30,
|
|
22076
|
-
orderBy as
|
|
22077
|
-
limit as
|
|
22061
|
+
orderBy as orderBy15,
|
|
22062
|
+
limit as limit14,
|
|
22078
22063
|
startAfter as startAfter11
|
|
22079
22064
|
} from "firebase/firestore";
|
|
22080
22065
|
import { getCountFromServer as getCountFromServer2 } from "firebase/firestore";
|
|
@@ -22229,7 +22214,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22229
22214
|
this.db,
|
|
22230
22215
|
`${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions`
|
|
22231
22216
|
);
|
|
22232
|
-
const q = query30(versionsCollectionRef,
|
|
22217
|
+
const q = query30(versionsCollectionRef, orderBy15("version", "desc"));
|
|
22233
22218
|
const querySnapshot = await getDocs30(q);
|
|
22234
22219
|
const versions = [];
|
|
22235
22220
|
querySnapshot.forEach((doc54) => {
|
|
@@ -22255,8 +22240,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22255
22240
|
let q = query30(
|
|
22256
22241
|
this.collectionRef,
|
|
22257
22242
|
where30("isActive", "==", true),
|
|
22258
|
-
|
|
22259
|
-
|
|
22243
|
+
orderBy15("updatedAt", "desc"),
|
|
22244
|
+
limit14(pageSize)
|
|
22260
22245
|
);
|
|
22261
22246
|
if (lastDoc) {
|
|
22262
22247
|
q = query30(q, startAfter11(lastDoc));
|
|
@@ -22288,9 +22273,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22288
22273
|
} = options;
|
|
22289
22274
|
const constraints = [
|
|
22290
22275
|
where30("isActive", "==", true),
|
|
22291
|
-
|
|
22292
|
-
|
|
22293
|
-
|
|
22276
|
+
orderBy15("sortingOrder", "asc"),
|
|
22277
|
+
orderBy15("title", "asc"),
|
|
22278
|
+
limit14(pageSize)
|
|
22294
22279
|
];
|
|
22295
22280
|
if (isUserForm !== void 0) {
|
|
22296
22281
|
constraints.push(where30("isUserForm", "==", isUserForm));
|
|
@@ -22346,7 +22331,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22346
22331
|
const q = query30(
|
|
22347
22332
|
this.collectionRef,
|
|
22348
22333
|
where30("isActive", "==", true),
|
|
22349
|
-
|
|
22334
|
+
orderBy15("title", "asc")
|
|
22350
22335
|
);
|
|
22351
22336
|
const querySnapshot = await getDocs30(q);
|
|
22352
22337
|
const templates = [];
|
|
@@ -22367,8 +22352,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22367
22352
|
this.collectionRef,
|
|
22368
22353
|
where30("isActive", "==", true),
|
|
22369
22354
|
where30("tags", "array-contains-any", tags),
|
|
22370
|
-
|
|
22371
|
-
|
|
22355
|
+
orderBy15("updatedAt", "desc"),
|
|
22356
|
+
limit14(pageSize)
|
|
22372
22357
|
);
|
|
22373
22358
|
if (lastDoc) {
|
|
22374
22359
|
q = query30(q, startAfter11(lastDoc));
|
|
@@ -22396,8 +22381,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22396
22381
|
let q = query30(
|
|
22397
22382
|
this.collectionRef,
|
|
22398
22383
|
where30("createdBy", "==", userId),
|
|
22399
|
-
|
|
22400
|
-
|
|
22384
|
+
orderBy15("updatedAt", "desc"),
|
|
22385
|
+
limit14(pageSize)
|
|
22401
22386
|
);
|
|
22402
22387
|
if (lastDoc) {
|
|
22403
22388
|
q = query30(q, startAfter11(lastDoc));
|
|
@@ -22423,7 +22408,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22423
22408
|
let q = query30(
|
|
22424
22409
|
this.collectionRef,
|
|
22425
22410
|
where30("isActive", "==", true),
|
|
22426
|
-
|
|
22411
|
+
orderBy15("updatedAt", "desc")
|
|
22427
22412
|
);
|
|
22428
22413
|
if ((options == null ? void 0 : options.isUserForm) !== void 0) {
|
|
22429
22414
|
q = query30(q, where30("isUserForm", "==", options.isUserForm));
|
|
@@ -22449,8 +22434,8 @@ import {
|
|
|
22449
22434
|
setDoc as setDoc30,
|
|
22450
22435
|
updateDoc as updateDoc37,
|
|
22451
22436
|
query as query31,
|
|
22452
|
-
orderBy as
|
|
22453
|
-
limit as
|
|
22437
|
+
orderBy as orderBy16,
|
|
22438
|
+
limit as limit15,
|
|
22454
22439
|
startAfter as startAfter12
|
|
22455
22440
|
} from "firebase/firestore";
|
|
22456
22441
|
var FilledDocumentService = class extends BaseService {
|
|
@@ -22607,8 +22592,8 @@ var FilledDocumentService = class extends BaseService {
|
|
|
22607
22592
|
);
|
|
22608
22593
|
let q = query31(
|
|
22609
22594
|
subcollectionRef,
|
|
22610
|
-
|
|
22611
|
-
|
|
22595
|
+
orderBy16("updatedAt", "desc"),
|
|
22596
|
+
limit15(pageSize)
|
|
22612
22597
|
);
|
|
22613
22598
|
if (lastDoc) {
|
|
22614
22599
|
q = query31(q, startAfter12(lastDoc));
|
|
@@ -22631,8 +22616,8 @@ var FilledDocumentService = class extends BaseService {
|
|
|
22631
22616
|
);
|
|
22632
22617
|
let q = query31(
|
|
22633
22618
|
subcollectionRef,
|
|
22634
|
-
|
|
22635
|
-
|
|
22619
|
+
orderBy16("updatedAt", "desc"),
|
|
22620
|
+
limit15(pageSize)
|
|
22636
22621
|
);
|
|
22637
22622
|
if (lastDoc) {
|
|
22638
22623
|
q = query31(q, startAfter12(lastDoc));
|
|
@@ -22818,7 +22803,7 @@ import {
|
|
|
22818
22803
|
where as where32,
|
|
22819
22804
|
updateDoc as updateDoc38,
|
|
22820
22805
|
deleteDoc as deleteDoc18,
|
|
22821
|
-
orderBy as
|
|
22806
|
+
orderBy as orderBy17,
|
|
22822
22807
|
Timestamp as Timestamp34,
|
|
22823
22808
|
addDoc as addDoc3,
|
|
22824
22809
|
writeBatch as writeBatch5
|
|
@@ -22869,7 +22854,7 @@ var NotificationService = class extends BaseService {
|
|
|
22869
22854
|
const q = query32(
|
|
22870
22855
|
collection32(this.db, NOTIFICATIONS_COLLECTION),
|
|
22871
22856
|
where32("userId", "==", userId),
|
|
22872
|
-
|
|
22857
|
+
orderBy17("notificationTime", "desc")
|
|
22873
22858
|
);
|
|
22874
22859
|
const querySnapshot = await getDocs32(q);
|
|
22875
22860
|
return querySnapshot.docs.map((doc54) => ({
|
|
@@ -22885,7 +22870,7 @@ var NotificationService = class extends BaseService {
|
|
|
22885
22870
|
collection32(this.db, NOTIFICATIONS_COLLECTION),
|
|
22886
22871
|
where32("userId", "==", userId),
|
|
22887
22872
|
where32("isRead", "==", false),
|
|
22888
|
-
|
|
22873
|
+
orderBy17("notificationTime", "desc")
|
|
22889
22874
|
);
|
|
22890
22875
|
const querySnapshot = await getDocs32(q);
|
|
22891
22876
|
return querySnapshot.docs.map((doc54) => ({
|
|
@@ -22959,7 +22944,7 @@ var NotificationService = class extends BaseService {
|
|
|
22959
22944
|
collection32(this.db, NOTIFICATIONS_COLLECTION),
|
|
22960
22945
|
where32("userId", "==", userId),
|
|
22961
22946
|
where32("notificationType", "==", type),
|
|
22962
|
-
|
|
22947
|
+
orderBy17("notificationTime", "desc")
|
|
22963
22948
|
);
|
|
22964
22949
|
const querySnapshot = await getDocs32(q);
|
|
22965
22950
|
return querySnapshot.docs.map((doc54) => ({
|
|
@@ -22974,7 +22959,7 @@ var NotificationService = class extends BaseService {
|
|
|
22974
22959
|
const q = query32(
|
|
22975
22960
|
collection32(this.db, NOTIFICATIONS_COLLECTION),
|
|
22976
22961
|
where32("appointmentId", "==", appointmentId),
|
|
22977
|
-
|
|
22962
|
+
orderBy17("notificationTime", "desc")
|
|
22978
22963
|
);
|
|
22979
22964
|
const querySnapshot = await getDocs32(q);
|
|
22980
22965
|
return querySnapshot.docs.map((doc54) => ({
|
|
@@ -22993,8 +22978,8 @@ import {
|
|
|
22993
22978
|
doc as doc44,
|
|
22994
22979
|
updateDoc as updateDoc39,
|
|
22995
22980
|
Timestamp as Timestamp35,
|
|
22996
|
-
orderBy as
|
|
22997
|
-
limit as
|
|
22981
|
+
orderBy as orderBy18,
|
|
22982
|
+
limit as limit16,
|
|
22998
22983
|
startAfter as startAfter13,
|
|
22999
22984
|
getDoc as getDoc45
|
|
23000
22985
|
} from "firebase/firestore";
|
|
@@ -23041,7 +23026,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
23041
23026
|
*/
|
|
23042
23027
|
async getAllPatientRequirementInstances(patientId, filters, pageLimit = 20, lastVisible) {
|
|
23043
23028
|
const collRef = this.getPatientRequirementsCollectionRef(patientId);
|
|
23044
|
-
let q = query33(collRef,
|
|
23029
|
+
let q = query33(collRef, orderBy18("createdAt", "desc"));
|
|
23045
23030
|
const queryConstraints = [];
|
|
23046
23031
|
if ((filters == null ? void 0 : filters.appointmentId) && filters.appointmentId !== "all") {
|
|
23047
23032
|
queryConstraints.push(
|
|
@@ -23054,7 +23039,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
23054
23039
|
if (lastVisible) {
|
|
23055
23040
|
queryConstraints.push(startAfter13(lastVisible));
|
|
23056
23041
|
}
|
|
23057
|
-
queryConstraints.push(
|
|
23042
|
+
queryConstraints.push(limit16(pageLimit));
|
|
23058
23043
|
q = query33(collRef, ...queryConstraints);
|
|
23059
23044
|
const snapshot = await getDocs33(q);
|
|
23060
23045
|
let requirements = snapshot.docs.map((docSnap) => {
|
|
@@ -23194,8 +23179,8 @@ import {
|
|
|
23194
23179
|
Timestamp as Timestamp36,
|
|
23195
23180
|
serverTimestamp as serverTimestamp35,
|
|
23196
23181
|
writeBatch as writeBatch6,
|
|
23197
|
-
orderBy as
|
|
23198
|
-
limit as
|
|
23182
|
+
orderBy as orderBy19,
|
|
23183
|
+
limit as limit17,
|
|
23199
23184
|
startAfter as startAfter14,
|
|
23200
23185
|
documentId as documentId2
|
|
23201
23186
|
} from "firebase/firestore";
|
|
@@ -24421,20 +24406,20 @@ var ProcedureService = class extends BaseService {
|
|
|
24421
24406
|
const proceduresCollection = collection34(this.db, PROCEDURES_COLLECTION);
|
|
24422
24407
|
let proceduresQuery = query34(proceduresCollection);
|
|
24423
24408
|
if (pagination && pagination > 0) {
|
|
24424
|
-
const { limit:
|
|
24409
|
+
const { limit: limit23, startAfter: startAfter20 } = await import("firebase/firestore");
|
|
24425
24410
|
if (lastDoc) {
|
|
24426
24411
|
proceduresQuery = query34(
|
|
24427
24412
|
proceduresCollection,
|
|
24428
|
-
|
|
24413
|
+
orderBy19("name"),
|
|
24429
24414
|
// Use imported orderBy
|
|
24430
24415
|
startAfter20(lastDoc),
|
|
24431
|
-
|
|
24416
|
+
limit23(pagination)
|
|
24432
24417
|
);
|
|
24433
24418
|
} else {
|
|
24434
|
-
proceduresQuery = query34(proceduresCollection,
|
|
24419
|
+
proceduresQuery = query34(proceduresCollection, orderBy19("name"), limit23(pagination));
|
|
24435
24420
|
}
|
|
24436
24421
|
} else {
|
|
24437
|
-
proceduresQuery = query34(proceduresCollection,
|
|
24422
|
+
proceduresQuery = query34(proceduresCollection, orderBy19("name"));
|
|
24438
24423
|
}
|
|
24439
24424
|
const proceduresSnapshot = await getDocs34(proceduresQuery);
|
|
24440
24425
|
let procedures = proceduresSnapshot.docs.map((doc54) => {
|
|
@@ -24617,7 +24602,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24617
24602
|
}
|
|
24618
24603
|
constraints.push(where34("nameLower", ">=", searchTerm));
|
|
24619
24604
|
constraints.push(where34("nameLower", "<=", searchTerm + "\uF8FF"));
|
|
24620
|
-
constraints.push(
|
|
24605
|
+
constraints.push(orderBy19("nameLower"));
|
|
24621
24606
|
if (filters.lastDoc) {
|
|
24622
24607
|
const cursorValues = this.getCursorValuesForStartAfter(filters.lastDoc, "nameLower");
|
|
24623
24608
|
if (cursorValues) {
|
|
@@ -24625,7 +24610,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24625
24610
|
console.log("[PROCEDURE_SERVICE] Strategy 1: Using cursor for pagination");
|
|
24626
24611
|
}
|
|
24627
24612
|
}
|
|
24628
|
-
constraints.push(
|
|
24613
|
+
constraints.push(limit17(filters.pagination || 10));
|
|
24629
24614
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24630
24615
|
const querySnapshot = await getDocs34(q);
|
|
24631
24616
|
let procedures = querySnapshot.docs.map(
|
|
@@ -24659,7 +24644,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24659
24644
|
}
|
|
24660
24645
|
constraints.push(where34("name", ">=", searchTerm));
|
|
24661
24646
|
constraints.push(where34("name", "<=", searchTerm + "\uF8FF"));
|
|
24662
|
-
constraints.push(
|
|
24647
|
+
constraints.push(orderBy19("name"));
|
|
24663
24648
|
if (filters.lastDoc) {
|
|
24664
24649
|
const cursorValues = this.getCursorValuesForStartAfter(filters.lastDoc, "name");
|
|
24665
24650
|
if (cursorValues) {
|
|
@@ -24667,7 +24652,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24667
24652
|
console.log("[PROCEDURE_SERVICE] Strategy 2: Using cursor for pagination");
|
|
24668
24653
|
}
|
|
24669
24654
|
}
|
|
24670
|
-
constraints.push(
|
|
24655
|
+
constraints.push(limit17(filters.pagination || 10));
|
|
24671
24656
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24672
24657
|
const querySnapshot = await getDocs34(q);
|
|
24673
24658
|
let procedures = querySnapshot.docs.map(
|
|
@@ -24733,7 +24718,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24733
24718
|
"[PROCEDURE_SERVICE] Strategy 3 Firestore constraints (nested filters excluded):",
|
|
24734
24719
|
constraints.map((c) => c.fieldPath || "unknown")
|
|
24735
24720
|
);
|
|
24736
|
-
constraints.push(
|
|
24721
|
+
constraints.push(orderBy19("createdAt", "desc"));
|
|
24737
24722
|
if (filters.lastDoc) {
|
|
24738
24723
|
const cursorValues = this.getCursorValuesForStartAfter(filters.lastDoc, "createdAt");
|
|
24739
24724
|
if (cursorValues) {
|
|
@@ -24741,7 +24726,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24741
24726
|
console.log("[PROCEDURE_SERVICE] Strategy 3: Using cursor for pagination");
|
|
24742
24727
|
}
|
|
24743
24728
|
}
|
|
24744
|
-
constraints.push(
|
|
24729
|
+
constraints.push(limit17(filters.pagination || 10));
|
|
24745
24730
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24746
24731
|
const querySnapshot = await getDocs34(q);
|
|
24747
24732
|
let procedures = querySnapshot.docs.map(
|
|
@@ -24779,7 +24764,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24779
24764
|
console.log("[PROCEDURE_SERVICE] Strategy 4: Minimal query fallback");
|
|
24780
24765
|
const constraints = [
|
|
24781
24766
|
where34("isActive", "==", filters.isActive !== void 0 ? filters.isActive : true),
|
|
24782
|
-
|
|
24767
|
+
orderBy19("createdAt", "desc")
|
|
24783
24768
|
];
|
|
24784
24769
|
if (filters.practitionerId) {
|
|
24785
24770
|
constraints.push(where34("practitionerId", "==", filters.practitionerId));
|
|
@@ -24794,7 +24779,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24794
24779
|
console.log("[PROCEDURE_SERVICE] Strategy 4: Using cursor for pagination");
|
|
24795
24780
|
}
|
|
24796
24781
|
}
|
|
24797
|
-
constraints.push(
|
|
24782
|
+
constraints.push(limit17(filters.pagination || 10));
|
|
24798
24783
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24799
24784
|
const querySnapshot = await getDocs34(q);
|
|
24800
24785
|
let procedures = querySnapshot.docs.map(
|
|
@@ -25183,7 +25168,7 @@ var ProcedureService = class extends BaseService {
|
|
|
25183
25168
|
const proceduresQuery = query34(
|
|
25184
25169
|
collection34(this.db, PROCEDURES_COLLECTION),
|
|
25185
25170
|
...constraints,
|
|
25186
|
-
|
|
25171
|
+
orderBy19("name", "asc")
|
|
25187
25172
|
);
|
|
25188
25173
|
const querySnapshot = await getDocs34(proceduresQuery);
|
|
25189
25174
|
let procedures = querySnapshot.docs.map((doc54) => ({
|
|
@@ -25205,7 +25190,7 @@ import {
|
|
|
25205
25190
|
deleteDoc as deleteDoc20,
|
|
25206
25191
|
query as query35,
|
|
25207
25192
|
where as where35,
|
|
25208
|
-
orderBy as
|
|
25193
|
+
orderBy as orderBy20,
|
|
25209
25194
|
writeBatch as writeBatch7,
|
|
25210
25195
|
updateDoc as updateDoc41,
|
|
25211
25196
|
serverTimestamp as serverTimestamp36,
|
|
@@ -25359,7 +25344,7 @@ var ResourceService = class extends BaseService {
|
|
|
25359
25344
|
async getResourcesByClinic(clinicBranchId) {
|
|
25360
25345
|
const q = query35(
|
|
25361
25346
|
this.getResourcesRef(clinicBranchId),
|
|
25362
|
-
|
|
25347
|
+
orderBy20("nameLower")
|
|
25363
25348
|
);
|
|
25364
25349
|
const snapshot = await getDocs35(q);
|
|
25365
25350
|
return snapshot.docs.map(
|
|
@@ -25373,7 +25358,7 @@ var ResourceService = class extends BaseService {
|
|
|
25373
25358
|
const q = query35(
|
|
25374
25359
|
this.getResourcesRef(clinicBranchId),
|
|
25375
25360
|
where35("status", "==", "active" /* ACTIVE */),
|
|
25376
|
-
|
|
25361
|
+
orderBy20("nameLower")
|
|
25377
25362
|
);
|
|
25378
25363
|
const snapshot = await getDocs35(q);
|
|
25379
25364
|
return snapshot.docs.map(
|
|
@@ -25491,7 +25476,7 @@ var ResourceService = class extends BaseService {
|
|
|
25491
25476
|
async getResourceInstances(clinicBranchId, resourceId) {
|
|
25492
25477
|
const q = query35(
|
|
25493
25478
|
this.getInstancesRef(clinicBranchId, resourceId),
|
|
25494
|
-
|
|
25479
|
+
orderBy20("index")
|
|
25495
25480
|
);
|
|
25496
25481
|
const snapshot = await getDocs35(q);
|
|
25497
25482
|
return snapshot.docs.map(
|
|
@@ -25505,7 +25490,7 @@ var ResourceService = class extends BaseService {
|
|
|
25505
25490
|
const q = query35(
|
|
25506
25491
|
this.getInstancesRef(clinicBranchId, resourceId),
|
|
25507
25492
|
where35("status", "==", "active" /* ACTIVE */),
|
|
25508
|
-
|
|
25493
|
+
orderBy20("index")
|
|
25509
25494
|
);
|
|
25510
25495
|
const snapshot = await getDocs35(q);
|
|
25511
25496
|
return snapshot.docs.map(
|
|
@@ -25525,7 +25510,7 @@ var ResourceService = class extends BaseService {
|
|
|
25525
25510
|
calendarRef,
|
|
25526
25511
|
where35("eventTime.start", ">=", start),
|
|
25527
25512
|
where35("eventTime.start", "<=", end),
|
|
25528
|
-
|
|
25513
|
+
orderBy20("eventTime.start")
|
|
25529
25514
|
);
|
|
25530
25515
|
const snapshot = await getDocs35(q);
|
|
25531
25516
|
return snapshot.docs.map(
|
|
@@ -25644,7 +25629,7 @@ var ResourceService = class extends BaseService {
|
|
|
25644
25629
|
const q = query35(
|
|
25645
25630
|
calendarRef,
|
|
25646
25631
|
where35("eventType", "==", "blocking" /* BLOCKING */),
|
|
25647
|
-
|
|
25632
|
+
orderBy20("eventTime.start")
|
|
25648
25633
|
);
|
|
25649
25634
|
const snapshot = await getDocs35(q);
|
|
25650
25635
|
return snapshot.docs.map(
|
|
@@ -26290,8 +26275,8 @@ import {
|
|
|
26290
26275
|
query as query37,
|
|
26291
26276
|
updateDoc as updateDoc42,
|
|
26292
26277
|
where as where37,
|
|
26293
|
-
limit as
|
|
26294
|
-
orderBy as
|
|
26278
|
+
limit as limit18,
|
|
26279
|
+
orderBy as orderBy21,
|
|
26295
26280
|
startAfter as startAfter15,
|
|
26296
26281
|
getCountFromServer as getCountFromServer3
|
|
26297
26282
|
} from "firebase/firestore";
|
|
@@ -26331,7 +26316,7 @@ var BrandService = class extends BaseService {
|
|
|
26331
26316
|
async getAll(rowsPerPage, searchTerm, lastVisible) {
|
|
26332
26317
|
const constraints = [
|
|
26333
26318
|
where37("isActive", "==", true),
|
|
26334
|
-
|
|
26319
|
+
orderBy21("name_lowercase")
|
|
26335
26320
|
];
|
|
26336
26321
|
if (searchTerm) {
|
|
26337
26322
|
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
@@ -26343,7 +26328,7 @@ var BrandService = class extends BaseService {
|
|
|
26343
26328
|
if (lastVisible) {
|
|
26344
26329
|
constraints.push(startAfter15(lastVisible));
|
|
26345
26330
|
}
|
|
26346
|
-
constraints.push(
|
|
26331
|
+
constraints.push(limit18(rowsPerPage));
|
|
26347
26332
|
const q = query37(this.getBrandsRef(), ...constraints);
|
|
26348
26333
|
const snapshot = await getDocs37(q);
|
|
26349
26334
|
const brands = snapshot.docs.map(
|
|
@@ -26379,7 +26364,7 @@ var BrandService = class extends BaseService {
|
|
|
26379
26364
|
const q = query37(
|
|
26380
26365
|
this.getBrandsRef(),
|
|
26381
26366
|
where37("isActive", "==", true),
|
|
26382
|
-
|
|
26367
|
+
orderBy21("name")
|
|
26383
26368
|
);
|
|
26384
26369
|
const snapshot = await getDocs37(q);
|
|
26385
26370
|
return snapshot.docs.map(
|
|
@@ -26449,9 +26434,9 @@ var BrandService = class extends BaseService {
|
|
|
26449
26434
|
if (!includeInactive) {
|
|
26450
26435
|
baseConstraints.push(where37("isActive", "==", true));
|
|
26451
26436
|
}
|
|
26452
|
-
baseConstraints.push(
|
|
26437
|
+
baseConstraints.push(orderBy21("name_lowercase"));
|
|
26453
26438
|
while (true) {
|
|
26454
|
-
const constraints = [...baseConstraints,
|
|
26439
|
+
const constraints = [...baseConstraints, limit18(PAGE_SIZE)];
|
|
26455
26440
|
if (cursor) constraints.push(startAfter15(cursor));
|
|
26456
26441
|
const q = query37(this.getBrandsRef(), ...constraints);
|
|
26457
26442
|
const snapshot = await getDocs37(q);
|
|
@@ -26500,8 +26485,8 @@ import {
|
|
|
26500
26485
|
doc as doc49,
|
|
26501
26486
|
getDoc as getDoc50,
|
|
26502
26487
|
getDocs as getDocs38,
|
|
26503
|
-
limit as
|
|
26504
|
-
orderBy as
|
|
26488
|
+
limit as limit19,
|
|
26489
|
+
orderBy as orderBy22,
|
|
26505
26490
|
query as query38,
|
|
26506
26491
|
startAfter as startAfter16,
|
|
26507
26492
|
updateDoc as updateDoc43,
|
|
@@ -26589,7 +26574,7 @@ var CategoryService = class extends BaseService {
|
|
|
26589
26574
|
this.categoriesRef,
|
|
26590
26575
|
where38("family", "==", family),
|
|
26591
26576
|
where38("isActive", "==", true),
|
|
26592
|
-
|
|
26577
|
+
orderBy22("name")
|
|
26593
26578
|
);
|
|
26594
26579
|
const snapshot = await getDocs38(q);
|
|
26595
26580
|
const categories = snapshot.docs.map(
|
|
@@ -26609,8 +26594,8 @@ var CategoryService = class extends BaseService {
|
|
|
26609
26594
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26610
26595
|
const constraints = [
|
|
26611
26596
|
where38("isActive", "==", active),
|
|
26612
|
-
|
|
26613
|
-
queryLimit ?
|
|
26597
|
+
orderBy22("name"),
|
|
26598
|
+
queryLimit ? limit19(queryLimit) : void 0,
|
|
26614
26599
|
lastVisible ? startAfter16(lastVisible) : void 0
|
|
26615
26600
|
].filter((c) => !!c);
|
|
26616
26601
|
const q = query38(this.categoriesRef, ...constraints);
|
|
@@ -26636,8 +26621,8 @@ var CategoryService = class extends BaseService {
|
|
|
26636
26621
|
const constraints = [
|
|
26637
26622
|
where38("family", "==", family),
|
|
26638
26623
|
where38("isActive", "==", active),
|
|
26639
|
-
|
|
26640
|
-
queryLimit ?
|
|
26624
|
+
orderBy22("name"),
|
|
26625
|
+
queryLimit ? limit19(queryLimit) : void 0,
|
|
26641
26626
|
lastVisible ? startAfter16(lastVisible) : void 0
|
|
26642
26627
|
].filter((c) => !!c);
|
|
26643
26628
|
const q = query38(this.categoriesRef, ...constraints);
|
|
@@ -26758,9 +26743,9 @@ var CategoryService = class extends BaseService {
|
|
|
26758
26743
|
if (!includeInactive) {
|
|
26759
26744
|
constraints.push(where38("isActive", "==", true));
|
|
26760
26745
|
}
|
|
26761
|
-
constraints.push(
|
|
26746
|
+
constraints.push(orderBy22("name"));
|
|
26762
26747
|
while (true) {
|
|
26763
|
-
const queryConstraints = [...constraints,
|
|
26748
|
+
const queryConstraints = [...constraints, limit19(PAGE_SIZE)];
|
|
26764
26749
|
if (cursor) queryConstraints.push(startAfter16(cursor));
|
|
26765
26750
|
const q = query38(this.categoriesRef, ...queryConstraints);
|
|
26766
26751
|
const snapshot = await getDocs38(q);
|
|
@@ -26806,13 +26791,13 @@ var CategoryService = class extends BaseService {
|
|
|
26806
26791
|
import {
|
|
26807
26792
|
addDoc as addDoc6,
|
|
26808
26793
|
collection as collection39,
|
|
26809
|
-
collectionGroup as
|
|
26794
|
+
collectionGroup as collectionGroup3,
|
|
26810
26795
|
deleteDoc as deleteDoc22,
|
|
26811
26796
|
doc as doc50,
|
|
26812
26797
|
getDoc as getDoc51,
|
|
26813
26798
|
getDocs as getDocs39,
|
|
26814
|
-
limit as
|
|
26815
|
-
orderBy as
|
|
26799
|
+
limit as limit20,
|
|
26800
|
+
orderBy as orderBy23,
|
|
26816
26801
|
query as query39,
|
|
26817
26802
|
setDoc as setDoc34,
|
|
26818
26803
|
startAfter as startAfter17,
|
|
@@ -26896,8 +26881,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
26896
26881
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26897
26882
|
const constraints = [
|
|
26898
26883
|
where39("isActive", "==", active),
|
|
26899
|
-
|
|
26900
|
-
queryLimit ?
|
|
26884
|
+
orderBy23("name"),
|
|
26885
|
+
queryLimit ? limit20(queryLimit) : void 0,
|
|
26901
26886
|
lastVisible ? startAfter17(lastVisible) : void 0
|
|
26902
26887
|
].filter((c) => !!c);
|
|
26903
26888
|
const q = query39(this.getSubcategoriesRef(categoryId), ...constraints);
|
|
@@ -26924,12 +26909,12 @@ var SubcategoryService = class extends BaseService {
|
|
|
26924
26909
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26925
26910
|
const constraints = [
|
|
26926
26911
|
where39("isActive", "==", active),
|
|
26927
|
-
|
|
26928
|
-
queryLimit ?
|
|
26912
|
+
orderBy23("name"),
|
|
26913
|
+
queryLimit ? limit20(queryLimit) : void 0,
|
|
26929
26914
|
lastVisible ? startAfter17(lastVisible) : void 0
|
|
26930
26915
|
].filter((c) => !!c);
|
|
26931
26916
|
const q = query39(
|
|
26932
|
-
|
|
26917
|
+
collectionGroup3(this.db, SUBCATEGORIES_COLLECTION),
|
|
26933
26918
|
...constraints
|
|
26934
26919
|
);
|
|
26935
26920
|
const querySnapshot = await getDocs39(q);
|
|
@@ -26968,7 +26953,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
26968
26953
|
*/
|
|
26969
26954
|
async getAllForFilter() {
|
|
26970
26955
|
const q = query39(
|
|
26971
|
-
|
|
26956
|
+
collectionGroup3(this.db, SUBCATEGORIES_COLLECTION),
|
|
26972
26957
|
where39("isActive", "==", true)
|
|
26973
26958
|
);
|
|
26974
26959
|
const querySnapshot = await getDocs39(q);
|
|
@@ -27119,12 +27104,12 @@ var SubcategoryService = class extends BaseService {
|
|
|
27119
27104
|
if (!includeInactive) {
|
|
27120
27105
|
constraints.push(where39("isActive", "==", true));
|
|
27121
27106
|
}
|
|
27122
|
-
constraints.push(
|
|
27107
|
+
constraints.push(orderBy23("name"));
|
|
27123
27108
|
while (true) {
|
|
27124
|
-
const queryConstraints = [...constraints,
|
|
27109
|
+
const queryConstraints = [...constraints, limit20(PAGE_SIZE)];
|
|
27125
27110
|
if (cursor) queryConstraints.push(startAfter17(cursor));
|
|
27126
27111
|
const q = query39(
|
|
27127
|
-
|
|
27112
|
+
collectionGroup3(this.db, SUBCATEGORIES_COLLECTION),
|
|
27128
27113
|
...queryConstraints
|
|
27129
27114
|
);
|
|
27130
27115
|
const snapshot = await getDocs39(q);
|
|
@@ -27173,8 +27158,8 @@ import {
|
|
|
27173
27158
|
doc as doc51,
|
|
27174
27159
|
getDoc as getDoc52,
|
|
27175
27160
|
getDocs as getDocs40,
|
|
27176
|
-
limit as
|
|
27177
|
-
orderBy as
|
|
27161
|
+
limit as limit21,
|
|
27162
|
+
orderBy as orderBy24,
|
|
27178
27163
|
query as query40,
|
|
27179
27164
|
startAfter as startAfter18,
|
|
27180
27165
|
updateDoc as updateDoc45,
|
|
@@ -27281,8 +27266,8 @@ var TechnologyService = class extends BaseService {
|
|
|
27281
27266
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
27282
27267
|
const constraints = [
|
|
27283
27268
|
where40("isActive", "==", active),
|
|
27284
|
-
|
|
27285
|
-
queryLimit ?
|
|
27269
|
+
orderBy24("name"),
|
|
27270
|
+
queryLimit ? limit21(queryLimit) : void 0,
|
|
27286
27271
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
27287
27272
|
].filter((c) => !!c);
|
|
27288
27273
|
const q = query40(this.technologiesRef, ...constraints);
|
|
@@ -27308,8 +27293,8 @@ var TechnologyService = class extends BaseService {
|
|
|
27308
27293
|
const constraints = [
|
|
27309
27294
|
where40("categoryId", "==", categoryId),
|
|
27310
27295
|
where40("isActive", "==", active),
|
|
27311
|
-
|
|
27312
|
-
queryLimit ?
|
|
27296
|
+
orderBy24("name"),
|
|
27297
|
+
queryLimit ? limit21(queryLimit) : void 0,
|
|
27313
27298
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
27314
27299
|
].filter((c) => !!c);
|
|
27315
27300
|
const q = query40(this.technologiesRef, ...constraints);
|
|
@@ -27335,8 +27320,8 @@ var TechnologyService = class extends BaseService {
|
|
|
27335
27320
|
const constraints = [
|
|
27336
27321
|
where40("subcategoryId", "==", subcategoryId),
|
|
27337
27322
|
where40("isActive", "==", active),
|
|
27338
|
-
|
|
27339
|
-
queryLimit ?
|
|
27323
|
+
orderBy24("name"),
|
|
27324
|
+
queryLimit ? limit21(queryLimit) : void 0,
|
|
27340
27325
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
27341
27326
|
].filter((c) => !!c);
|
|
27342
27327
|
const q = query40(this.technologiesRef, ...constraints);
|
|
@@ -27809,7 +27794,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27809
27794
|
collection40(this.db, TECHNOLOGIES_COLLECTION),
|
|
27810
27795
|
where40("isActive", "==", true),
|
|
27811
27796
|
where40("subcategoryId", "==", subcategoryId),
|
|
27812
|
-
|
|
27797
|
+
orderBy24("name")
|
|
27813
27798
|
);
|
|
27814
27799
|
const snapshot = await getDocs40(q);
|
|
27815
27800
|
const technologies = snapshot.docs.map(
|
|
@@ -27831,7 +27816,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27831
27816
|
where40("isActive", "==", true),
|
|
27832
27817
|
where40("categoryId", "==", categoryId),
|
|
27833
27818
|
where40("subcategoryId", "==", subcategoryId),
|
|
27834
|
-
|
|
27819
|
+
orderBy24("name")
|
|
27835
27820
|
);
|
|
27836
27821
|
const snapshot = await getDocs40(q);
|
|
27837
27822
|
const technologies = snapshot.docs.map(
|
|
@@ -27849,7 +27834,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27849
27834
|
const q = query40(
|
|
27850
27835
|
collection40(this.db, TECHNOLOGIES_COLLECTION),
|
|
27851
27836
|
where40("isActive", "==", true),
|
|
27852
|
-
|
|
27837
|
+
orderBy24("name")
|
|
27853
27838
|
);
|
|
27854
27839
|
const snapshot = await getDocs40(q);
|
|
27855
27840
|
const technologies = snapshot.docs.map(
|
|
@@ -27902,7 +27887,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27902
27887
|
collection40(this.db, PRODUCTS_COLLECTION),
|
|
27903
27888
|
where40("assignedTechnologyIds", "array-contains", technologyId),
|
|
27904
27889
|
where40("isActive", "==", true),
|
|
27905
|
-
|
|
27890
|
+
orderBy24("name")
|
|
27906
27891
|
);
|
|
27907
27892
|
const snapshot = await getDocs40(q);
|
|
27908
27893
|
return snapshot.docs.map(
|
|
@@ -27919,7 +27904,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27919
27904
|
const q = query40(
|
|
27920
27905
|
collection40(this.db, PRODUCTS_COLLECTION),
|
|
27921
27906
|
where40("isActive", "==", true),
|
|
27922
|
-
|
|
27907
|
+
orderBy24("name")
|
|
27923
27908
|
);
|
|
27924
27909
|
const snapshot = await getDocs40(q);
|
|
27925
27910
|
const allProducts = snapshot.docs.map(
|
|
@@ -28017,9 +28002,9 @@ var TechnologyService = class extends BaseService {
|
|
|
28017
28002
|
if (!includeInactive) {
|
|
28018
28003
|
constraints.push(where40("isActive", "==", true));
|
|
28019
28004
|
}
|
|
28020
|
-
constraints.push(
|
|
28005
|
+
constraints.push(orderBy24("name"));
|
|
28021
28006
|
while (true) {
|
|
28022
|
-
const queryConstraints = [...constraints,
|
|
28007
|
+
const queryConstraints = [...constraints, limit21(PAGE_SIZE)];
|
|
28023
28008
|
if (cursor) queryConstraints.push(startAfter18(cursor));
|
|
28024
28009
|
const q = query40(this.technologiesRef, ...queryConstraints);
|
|
28025
28010
|
const snapshot = await getDocs40(q);
|
|
@@ -28087,15 +28072,15 @@ var TechnologyService = class extends BaseService {
|
|
|
28087
28072
|
import {
|
|
28088
28073
|
addDoc as addDoc8,
|
|
28089
28074
|
collection as collection41,
|
|
28090
|
-
collectionGroup as
|
|
28075
|
+
collectionGroup as collectionGroup4,
|
|
28091
28076
|
doc as doc52,
|
|
28092
28077
|
getDoc as getDoc53,
|
|
28093
28078
|
getDocs as getDocs41,
|
|
28094
28079
|
query as query41,
|
|
28095
28080
|
updateDoc as updateDoc46,
|
|
28096
28081
|
where as where41,
|
|
28097
|
-
limit as
|
|
28098
|
-
orderBy as
|
|
28082
|
+
limit as limit22,
|
|
28083
|
+
orderBy as orderBy25,
|
|
28099
28084
|
startAfter as startAfter19,
|
|
28100
28085
|
getCountFromServer as getCountFromServer7,
|
|
28101
28086
|
arrayUnion as arrayUnion10,
|
|
@@ -28140,7 +28125,7 @@ var ProductService = class extends BaseService {
|
|
|
28140
28125
|
*/
|
|
28141
28126
|
async getAll(options) {
|
|
28142
28127
|
const { rowsPerPage, lastVisible, categoryId, subcategoryId, technologyId } = options;
|
|
28143
|
-
const constraints = [where41("isActive", "==", true),
|
|
28128
|
+
const constraints = [where41("isActive", "==", true), orderBy25("name")];
|
|
28144
28129
|
if (categoryId) {
|
|
28145
28130
|
constraints.push(where41("categoryId", "==", categoryId));
|
|
28146
28131
|
}
|
|
@@ -28153,8 +28138,8 @@ var ProductService = class extends BaseService {
|
|
|
28153
28138
|
if (lastVisible) {
|
|
28154
28139
|
constraints.push(startAfter19(lastVisible));
|
|
28155
28140
|
}
|
|
28156
|
-
constraints.push(
|
|
28157
|
-
const q = query41(
|
|
28141
|
+
constraints.push(limit22(rowsPerPage));
|
|
28142
|
+
const q = query41(collectionGroup4(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
28158
28143
|
const snapshot = await getDocs41(q);
|
|
28159
28144
|
const products = snapshot.docs.map(
|
|
28160
28145
|
(doc54) => ({
|
|
@@ -28180,7 +28165,7 @@ var ProductService = class extends BaseService {
|
|
|
28180
28165
|
if (technologyId) {
|
|
28181
28166
|
constraints.push(where41("technologyId", "==", technologyId));
|
|
28182
28167
|
}
|
|
28183
|
-
const q = query41(
|
|
28168
|
+
const q = query41(collectionGroup4(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
28184
28169
|
const snapshot = await getCountFromServer7(q);
|
|
28185
28170
|
return snapshot.data().count;
|
|
28186
28171
|
}
|
|
@@ -28194,7 +28179,7 @@ var ProductService = class extends BaseService {
|
|
|
28194
28179
|
bySubcategory: {},
|
|
28195
28180
|
byTechnology: {}
|
|
28196
28181
|
};
|
|
28197
|
-
const q = query41(
|
|
28182
|
+
const q = query41(collectionGroup4(this.db, PRODUCTS_COLLECTION), where41("isActive", "==", true));
|
|
28198
28183
|
const snapshot = await getDocs41(q);
|
|
28199
28184
|
snapshot.docs.forEach((doc54) => {
|
|
28200
28185
|
const product = doc54.data();
|
|
@@ -28217,7 +28202,7 @@ var ProductService = class extends BaseService {
|
|
|
28217
28202
|
const q = query41(
|
|
28218
28203
|
this.getProductsRef(technologyId),
|
|
28219
28204
|
where41("isActive", "==", true),
|
|
28220
|
-
|
|
28205
|
+
orderBy25("name")
|
|
28221
28206
|
);
|
|
28222
28207
|
const snapshot = await getDocs41(q);
|
|
28223
28208
|
return snapshot.docs.map(
|
|
@@ -28313,7 +28298,7 @@ var ProductService = class extends BaseService {
|
|
|
28313
28298
|
brandId: brandId || "none",
|
|
28314
28299
|
category: category || "none"
|
|
28315
28300
|
});
|
|
28316
|
-
const constraints = [where41("isActive", "==", true),
|
|
28301
|
+
const constraints = [where41("isActive", "==", true), orderBy25("name")];
|
|
28317
28302
|
if (brandId) {
|
|
28318
28303
|
console.log("[ProductService.getAllTopLevel] Adding brandId filter:", brandId);
|
|
28319
28304
|
constraints.push(where41("brandId", "==", brandId));
|
|
@@ -28325,7 +28310,7 @@ var ProductService = class extends BaseService {
|
|
|
28325
28310
|
if (lastVisible) {
|
|
28326
28311
|
constraints.push(startAfter19(lastVisible));
|
|
28327
28312
|
}
|
|
28328
|
-
constraints.push(
|
|
28313
|
+
constraints.push(limit22(rowsPerPage));
|
|
28329
28314
|
const q = query41(this.getTopLevelProductsRef(), ...constraints);
|
|
28330
28315
|
const snapshot = await getDocs41(q);
|
|
28331
28316
|
const products = snapshot.docs.map(
|
|
@@ -28397,7 +28382,7 @@ var ProductService = class extends BaseService {
|
|
|
28397
28382
|
this.getTopLevelProductsRef(),
|
|
28398
28383
|
where41("assignedTechnologyIds", "array-contains", technologyId),
|
|
28399
28384
|
where41("isActive", "==", true),
|
|
28400
|
-
|
|
28385
|
+
orderBy25("name")
|
|
28401
28386
|
);
|
|
28402
28387
|
const snapshot = await getDocs41(q);
|
|
28403
28388
|
return snapshot.docs.map(
|
|
@@ -28414,7 +28399,7 @@ var ProductService = class extends BaseService {
|
|
|
28414
28399
|
const q = query41(
|
|
28415
28400
|
this.getTopLevelProductsRef(),
|
|
28416
28401
|
where41("isActive", "==", true),
|
|
28417
|
-
|
|
28402
|
+
orderBy25("name")
|
|
28418
28403
|
);
|
|
28419
28404
|
const snapshot = await getDocs41(q);
|
|
28420
28405
|
const allProducts = snapshot.docs.map(
|
|
@@ -28438,7 +28423,7 @@ var ProductService = class extends BaseService {
|
|
|
28438
28423
|
this.getTopLevelProductsRef(),
|
|
28439
28424
|
where41("brandId", "==", brandId),
|
|
28440
28425
|
where41("isActive", "==", true),
|
|
28441
|
-
|
|
28426
|
+
orderBy25("name")
|
|
28442
28427
|
);
|
|
28443
28428
|
const snapshot = await getDocs41(q);
|
|
28444
28429
|
return snapshot.docs.map(
|
|
@@ -28476,9 +28461,9 @@ var ProductService = class extends BaseService {
|
|
|
28476
28461
|
if (!includeInactive) {
|
|
28477
28462
|
constraints.push(where41("isActive", "==", true));
|
|
28478
28463
|
}
|
|
28479
|
-
constraints.push(
|
|
28464
|
+
constraints.push(orderBy25("name"));
|
|
28480
28465
|
while (true) {
|
|
28481
|
-
const queryConstraints = [...constraints,
|
|
28466
|
+
const queryConstraints = [...constraints, limit22(PAGE_SIZE)];
|
|
28482
28467
|
if (cursor) queryConstraints.push(startAfter19(cursor));
|
|
28483
28468
|
const q = query41(this.getTopLevelProductsRef(), ...queryConstraints);
|
|
28484
28469
|
const snapshot = await getDocs41(q);
|
|
@@ -28573,9 +28558,9 @@ var ConstantsService = class extends BaseService {
|
|
|
28573
28558
|
*/
|
|
28574
28559
|
async getAllBenefits(options) {
|
|
28575
28560
|
const allBenefits = await this.getAllBenefitsForFilter();
|
|
28576
|
-
const { page, limit:
|
|
28577
|
-
const startIndex = page *
|
|
28578
|
-
const endIndex = startIndex +
|
|
28561
|
+
const { page, limit: limit23 } = options;
|
|
28562
|
+
const startIndex = page * limit23;
|
|
28563
|
+
const endIndex = startIndex + limit23;
|
|
28579
28564
|
const paginatedBenefits = allBenefits.slice(startIndex, endIndex);
|
|
28580
28565
|
return { benefits: paginatedBenefits, total: allBenefits.length };
|
|
28581
28566
|
}
|
|
@@ -28672,9 +28657,9 @@ var ConstantsService = class extends BaseService {
|
|
|
28672
28657
|
*/
|
|
28673
28658
|
async getAllContraindications(options) {
|
|
28674
28659
|
const allContraindications = await this.getAllContraindicationsForFilter();
|
|
28675
|
-
const { page, limit:
|
|
28676
|
-
const startIndex = page *
|
|
28677
|
-
const endIndex = startIndex +
|
|
28660
|
+
const { page, limit: limit23 } = options;
|
|
28661
|
+
const startIndex = page * limit23;
|
|
28662
|
+
const endIndex = startIndex + limit23;
|
|
28678
28663
|
const paginatedContraindications = allContraindications.slice(
|
|
28679
28664
|
startIndex,
|
|
28680
28665
|
endIndex
|