@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.
@@ -1420,6 +1420,7 @@ interface AdminToken {
1420
1420
  email?: string | null;
1421
1421
  status: AdminTokenStatus;
1422
1422
  usedByUserRef?: string;
1423
+ clinicGroupId: string;
1423
1424
  createdAt: Timestamp;
1424
1425
  expiresAt: Timestamp;
1425
1426
  }
@@ -1558,7 +1559,8 @@ interface ClinicGroup {
1558
1559
  clinicsInfo: ClinicInfo[];
1559
1560
  admins: string[];
1560
1561
  adminsInfo: AdminInfo[];
1561
- adminTokens: AdminToken[];
1562
+ /** @deprecated Tokens now stored in subcollection clinic_groups/{id}/adminTokens */
1563
+ adminTokens?: AdminToken[];
1562
1564
  ownerId: string | null;
1563
1565
  createdAt: Timestamp;
1564
1566
  updatedAt: Timestamp;
@@ -1420,6 +1420,7 @@ interface AdminToken {
1420
1420
  email?: string | null;
1421
1421
  status: AdminTokenStatus;
1422
1422
  usedByUserRef?: string;
1423
+ clinicGroupId: string;
1423
1424
  createdAt: Timestamp;
1424
1425
  expiresAt: Timestamp;
1425
1426
  }
@@ -1558,7 +1559,8 @@ interface ClinicGroup {
1558
1559
  clinicsInfo: ClinicInfo[];
1559
1560
  admins: string[];
1560
1561
  adminsInfo: AdminInfo[];
1561
- adminTokens: AdminToken[];
1562
+ /** @deprecated Tokens now stored in subcollection clinic_groups/{id}/adminTokens */
1563
+ adminTokens?: AdminToken[];
1562
1564
  ownerId: string | null;
1563
1565
  createdAt: Timestamp;
1564
1566
  updatedAt: Timestamp;
@@ -4961,7 +4961,7 @@ var ClinicAggregationService = class {
4961
4961
  try {
4962
4962
  await groupRef.update({
4963
4963
  clinicsInfo: admin8.firestore.FieldValue.arrayUnion(clinicInfo),
4964
- clinicIds: admin8.firestore.FieldValue.arrayUnion(clinicId),
4964
+ clinics: admin8.firestore.FieldValue.arrayUnion(clinicId),
4965
4965
  updatedAt: admin8.firestore.FieldValue.serverTimestamp()
4966
4966
  });
4967
4967
  console.log(
@@ -4883,7 +4883,7 @@ var ClinicAggregationService = class {
4883
4883
  try {
4884
4884
  await groupRef.update({
4885
4885
  clinicsInfo: admin8.firestore.FieldValue.arrayUnion(clinicInfo),
4886
- clinicIds: admin8.firestore.FieldValue.arrayUnion(clinicId),
4886
+ clinics: admin8.firestore.FieldValue.arrayUnion(clinicId),
4887
4887
  updatedAt: admin8.firestore.FieldValue.serverTimestamp()
4888
4888
  });
4889
4889
  console.log(
package/dist/index.d.mts CHANGED
@@ -5865,6 +5865,7 @@ interface AdminToken {
5865
5865
  email?: string | null;
5866
5866
  status: AdminTokenStatus;
5867
5867
  usedByUserRef?: string;
5868
+ clinicGroupId: string;
5868
5869
  createdAt: Timestamp;
5869
5870
  expiresAt: Timestamp;
5870
5871
  }
@@ -6003,7 +6004,8 @@ interface ClinicGroup {
6003
6004
  clinicsInfo: ClinicInfo[];
6004
6005
  admins: string[];
6005
6006
  adminsInfo: AdminInfo[];
6006
- adminTokens: AdminToken[];
6007
+ /** @deprecated Tokens now stored in subcollection clinic_groups/{id}/adminTokens */
6008
+ adminTokens?: AdminToken[];
6007
6009
  ownerId: string | null;
6008
6010
  createdAt: Timestamp;
6009
6011
  updatedAt: Timestamp;
@@ -7305,6 +7307,18 @@ declare class ClinicGroupService extends BaseService {
7305
7307
  * Dohvata aktivne admin tokene
7306
7308
  */
7307
7309
  getActiveAdminTokens(groupId: string, adminId: string): Promise<AdminToken[]>;
7310
+ /**
7311
+ * Gets ALL admin tokens for a clinic group (all statuses)
7312
+ */
7313
+ getAllAdminTokens(groupId: string, adminId: string): Promise<AdminToken[]>;
7314
+ /**
7315
+ * Finds an admin token by its value across all clinic groups.
7316
+ * Uses a collection group query for O(1) lookup.
7317
+ */
7318
+ findAdminTokenByValue(tokenValue: string): Promise<{
7319
+ token: AdminToken;
7320
+ clinicGroupId: string;
7321
+ } | null>;
7308
7322
  /**
7309
7323
  * Updates the onboarding status for a clinic group
7310
7324
  *
package/dist/index.d.ts CHANGED
@@ -5865,6 +5865,7 @@ interface AdminToken {
5865
5865
  email?: string | null;
5866
5866
  status: AdminTokenStatus;
5867
5867
  usedByUserRef?: string;
5868
+ clinicGroupId: string;
5868
5869
  createdAt: Timestamp;
5869
5870
  expiresAt: Timestamp;
5870
5871
  }
@@ -6003,7 +6004,8 @@ interface ClinicGroup {
6003
6004
  clinicsInfo: ClinicInfo[];
6004
6005
  admins: string[];
6005
6006
  adminsInfo: AdminInfo[];
6006
- adminTokens: AdminToken[];
6007
+ /** @deprecated Tokens now stored in subcollection clinic_groups/{id}/adminTokens */
6008
+ adminTokens?: AdminToken[];
6007
6009
  ownerId: string | null;
6008
6010
  createdAt: Timestamp;
6009
6011
  updatedAt: Timestamp;
@@ -7305,6 +7307,18 @@ declare class ClinicGroupService extends BaseService {
7305
7307
  * Dohvata aktivne admin tokene
7306
7308
  */
7307
7309
  getActiveAdminTokens(groupId: string, adminId: string): Promise<AdminToken[]>;
7310
+ /**
7311
+ * Gets ALL admin tokens for a clinic group (all statuses)
7312
+ */
7313
+ getAllAdminTokens(groupId: string, adminId: string): Promise<AdminToken[]>;
7314
+ /**
7315
+ * Finds an admin token by its value across all clinic groups.
7316
+ * Uses a collection group query for O(1) lookup.
7317
+ */
7318
+ findAdminTokenByValue(tokenValue: string): Promise<{
7319
+ token: AdminToken;
7320
+ clinicGroupId: string;
7321
+ } | null>;
7308
7322
  /**
7309
7323
  * Updates the onboarding status for a clinic group
7310
7324
  *
package/dist/index.js CHANGED
@@ -667,11 +667,11 @@ var StaffInviteStatus = /* @__PURE__ */ ((StaffInviteStatus2) => {
667
667
  var CLINIC_GROUPS_COLLECTION = "clinic_groups";
668
668
  var CLINIC_ADMINS_COLLECTION = "clinic_admins";
669
669
  var CLINICS_COLLECTION = "clinics";
670
- var AdminTokenStatus = /* @__PURE__ */ ((AdminTokenStatus2) => {
671
- AdminTokenStatus2["ACTIVE"] = "active";
672
- AdminTokenStatus2["USED"] = "used";
673
- AdminTokenStatus2["EXPIRED"] = "expired";
674
- return AdminTokenStatus2;
670
+ var AdminTokenStatus = /* @__PURE__ */ ((AdminTokenStatus3) => {
671
+ AdminTokenStatus3["ACTIVE"] = "active";
672
+ AdminTokenStatus3["USED"] = "used";
673
+ AdminTokenStatus3["EXPIRED"] = "expired";
674
+ return AdminTokenStatus3;
675
675
  })(AdminTokenStatus || {});
676
676
  var SubscriptionModel = /* @__PURE__ */ ((SubscriptionModel2) => {
677
677
  SubscriptionModel2["NO_SUBSCRIPTION"] = "no_subscription";
@@ -2189,7 +2189,7 @@ var AnalyticsService = class extends BaseService {
2189
2189
  * @param limit - Number of top procedures to return
2190
2190
  * @returns Array of procedure popularity metrics
2191
2191
  */
2192
- async getProcedurePopularity(dateRange, limit22 = 10) {
2192
+ async getProcedurePopularity(dateRange, limit23 = 10) {
2193
2193
  const appointments = await this.fetchAppointments(void 0, dateRange);
2194
2194
  const completed = getCompletedAppointments(appointments);
2195
2195
  const procedureMap = /* @__PURE__ */ new Map();
@@ -2218,7 +2218,7 @@ var AnalyticsService = class extends BaseService {
2218
2218
  completedCount: data.count,
2219
2219
  rank: 0
2220
2220
  // Will be set after sorting
2221
- })).sort((a, b) => b.appointmentCount - a.appointmentCount).slice(0, limit22).map((item, index) => ({ ...item, rank: index + 1 }));
2221
+ })).sort((a, b) => b.appointmentCount - a.appointmentCount).slice(0, limit23).map((item, index) => ({ ...item, rank: index + 1 }));
2222
2222
  }
2223
2223
  /**
2224
2224
  * Get procedure profitability metrics
@@ -2227,7 +2227,7 @@ var AnalyticsService = class extends BaseService {
2227
2227
  * @param limit - Number of top procedures to return
2228
2228
  * @returns Array of procedure profitability metrics
2229
2229
  */
2230
- async getProcedureProfitability(dateRange, limit22 = 10) {
2230
+ async getProcedureProfitability(dateRange, limit23 = 10) {
2231
2231
  const appointments = await this.fetchAppointments(void 0, dateRange);
2232
2232
  const completed = getCompletedAppointments(appointments);
2233
2233
  const procedureMap = /* @__PURE__ */ new Map();
@@ -2261,7 +2261,7 @@ var AnalyticsService = class extends BaseService {
2261
2261
  appointmentCount: data.count,
2262
2262
  rank: 0
2263
2263
  // Will be set after sorting
2264
- })).sort((a, b) => b.totalRevenue - a.totalRevenue).slice(0, limit22).map((item, index) => ({ ...item, rank: index + 1 }));
2264
+ })).sort((a, b) => b.totalRevenue - a.totalRevenue).slice(0, limit23).map((item, index) => ({ ...item, rank: index + 1 }));
2265
2265
  }
2266
2266
  // ==========================================
2267
2267
  // Time Efficiency Analytics
@@ -5727,10 +5727,9 @@ var adminTokenSchema = import_zod9.z.object({
5727
5727
  email: import_zod9.z.string().email().optional().nullable(),
5728
5728
  status: import_zod9.z.nativeEnum(AdminTokenStatus),
5729
5729
  usedByUserRef: import_zod9.z.string().optional(),
5730
+ clinicGroupId: import_zod9.z.string(),
5730
5731
  createdAt: import_zod9.z.instanceof(Date).or(import_zod9.z.instanceof(import_firestore9.Timestamp)),
5731
- // Timestamp
5732
5732
  expiresAt: import_zod9.z.instanceof(Date).or(import_zod9.z.instanceof(import_firestore9.Timestamp))
5733
- // Timestamp
5734
5733
  });
5735
5734
  var stripeTransactionDataSchema = import_zod9.z.object({
5736
5735
  sessionId: import_zod9.z.string().optional(),
@@ -5791,7 +5790,7 @@ var clinicGroupSchema = import_zod9.z.object({
5791
5790
  clinicsInfo: import_zod9.z.array(clinicInfoSchema),
5792
5791
  admins: import_zod9.z.array(import_zod9.z.string()),
5793
5792
  adminsInfo: import_zod9.z.array(adminInfoSchema),
5794
- adminTokens: import_zod9.z.array(adminTokenSchema),
5793
+ adminTokens: import_zod9.z.array(adminTokenSchema).optional(),
5795
5794
  ownerId: import_zod9.z.string().nullable(),
5796
5795
  createdAt: import_zod9.z.instanceof(Date).or(import_zod9.z.instanceof(import_firestore9.Timestamp)),
5797
5796
  // Timestamp
@@ -15730,6 +15729,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
15730
15729
  admins: [ownerId],
15731
15730
  adminsInfo: [],
15732
15731
  adminTokens: [],
15732
+ // @deprecated — tokens now in subcollection, kept for backward compat
15733
15733
  ownerId,
15734
15734
  createdAt: now,
15735
15735
  updatedAt: now,
@@ -15914,6 +15914,10 @@ async function deactivateClinicGroup(db, groupId, app) {
15914
15914
  app
15915
15915
  );
15916
15916
  }
15917
+ var ADMIN_TOKENS_SUBCOLLECTION = "adminTokens";
15918
+ function adminTokensRef(db, groupId) {
15919
+ return (0, import_firestore41.collection)(db, CLINIC_GROUPS_COLLECTION, groupId, ADMIN_TOKENS_SUBCOLLECTION);
15920
+ }
15917
15921
  async function createAdminToken(db, groupId, creatorAdminId, app, data) {
15918
15922
  const group = await getClinicGroup(db, groupId);
15919
15923
  if (!group) {
@@ -15929,68 +15933,60 @@ async function createAdminToken(db, groupId, creatorAdminId, app, data) {
15929
15933
  now.seconds + expiresInDays * 24 * 60 * 60,
15930
15934
  now.nanoseconds
15931
15935
  );
15936
+ const tokenRef = (0, import_firestore41.doc)(adminTokensRef(db, groupId));
15932
15937
  const token = {
15933
- id: generateId(),
15938
+ id: tokenRef.id,
15934
15939
  token: generateId(),
15935
15940
  status: "active" /* ACTIVE */,
15936
15941
  email,
15942
+ clinicGroupId: groupId,
15937
15943
  createdAt: now,
15938
15944
  expiresAt
15939
15945
  };
15940
- await updateClinicGroup(
15941
- db,
15942
- groupId,
15943
- {
15944
- adminTokens: [...group.adminTokens, token]
15945
- },
15946
- app
15947
- );
15946
+ await (0, import_firestore41.setDoc)(tokenRef, token);
15948
15947
  return token;
15949
15948
  }
15950
- async function verifyAndUseAdminToken(db, groupId, token, userRef, app) {
15951
- const group = await getClinicGroup(db, groupId);
15952
- if (!group) {
15953
- throw new Error("Clinic group not found");
15954
- }
15955
- const adminToken = group.adminTokens.find((t) => t.token === token);
15956
- if (!adminToken) {
15949
+ async function verifyAndUseAdminToken(db, groupId, tokenValue, userRef, app) {
15950
+ const tokensQuery = (0, import_firestore41.query)(
15951
+ adminTokensRef(db, groupId),
15952
+ (0, import_firestore41.where)("token", "==", tokenValue),
15953
+ (0, import_firestore41.limit)(1)
15954
+ );
15955
+ const snapshot = await (0, import_firestore41.getDocs)(tokensQuery);
15956
+ if (snapshot.empty) {
15957
15957
  throw new Error("Admin token not found");
15958
15958
  }
15959
+ const tokenDoc = snapshot.docs[0];
15960
+ const adminToken = tokenDoc.data();
15959
15961
  if (adminToken.status !== "active" /* ACTIVE */) {
15960
15962
  throw new Error("Admin token is not active");
15961
15963
  }
15962
15964
  const now = import_firestore41.Timestamp.now();
15963
15965
  if (adminToken.expiresAt.seconds < now.seconds) {
15964
- const updatedTokens2 = group.adminTokens.map(
15965
- (t) => t.id === adminToken.id ? { ...t, status: "expired" /* EXPIRED */ } : t
15966
- );
15967
- await updateClinicGroup(
15968
- db,
15969
- groupId,
15970
- {
15971
- adminTokens: updatedTokens2
15972
- },
15973
- app
15974
- );
15966
+ await (0, import_firestore41.updateDoc)(tokenDoc.ref, { status: "expired" /* EXPIRED */ });
15975
15967
  throw new Error("Admin token has expired");
15976
15968
  }
15977
- const updatedTokens = group.adminTokens.map(
15978
- (t) => t.id === adminToken.id ? {
15979
- ...t,
15980
- status: "used" /* USED */,
15981
- usedByUserRef: userRef
15982
- } : t
15983
- );
15984
- await updateClinicGroup(
15985
- db,
15986
- groupId,
15987
- {
15988
- adminTokens: updatedTokens
15989
- },
15990
- app
15991
- );
15969
+ await (0, import_firestore41.updateDoc)(tokenDoc.ref, {
15970
+ status: "used" /* USED */,
15971
+ usedByUserRef: userRef
15972
+ });
15992
15973
  return true;
15993
15974
  }
15975
+ async function findAdminTokenByValue(db, tokenValue) {
15976
+ const tokensQuery = (0, import_firestore41.query)(
15977
+ (0, import_firestore41.collectionGroup)(db, ADMIN_TOKENS_SUBCOLLECTION),
15978
+ (0, import_firestore41.where)("token", "==", tokenValue),
15979
+ (0, import_firestore41.where)("status", "==", "active" /* ACTIVE */),
15980
+ (0, import_firestore41.limit)(1)
15981
+ );
15982
+ const snapshot = await (0, import_firestore41.getDocs)(tokensQuery);
15983
+ if (snapshot.empty) return null;
15984
+ const tokenData = snapshot.docs[0].data();
15985
+ return {
15986
+ token: tokenData,
15987
+ clinicGroupId: tokenData.clinicGroupId
15988
+ };
15989
+ }
15994
15990
  async function deleteAdminToken(db, groupId, tokenId, adminId, app) {
15995
15991
  const group = await getClinicGroup(db, groupId);
15996
15992
  if (!group) {
@@ -15999,15 +15995,7 @@ async function deleteAdminToken(db, groupId, tokenId, adminId, app) {
15999
15995
  if (!group.admins.includes(adminId)) {
16000
15996
  throw new Error("Admin does not belong to this clinic group");
16001
15997
  }
16002
- const updatedTokens = group.adminTokens.filter((t) => t.id !== tokenId);
16003
- await updateClinicGroup(
16004
- db,
16005
- groupId,
16006
- {
16007
- adminTokens: updatedTokens
16008
- },
16009
- app
16010
- );
15998
+ await (0, import_firestore41.deleteDoc)((0, import_firestore41.doc)(adminTokensRef(db, groupId), tokenId));
16011
15999
  }
16012
16000
  async function getActiveAdminTokens(db, groupId, adminId, app) {
16013
16001
  const group = await getClinicGroup(db, groupId);
@@ -16017,7 +16005,23 @@ async function getActiveAdminTokens(db, groupId, adminId, app) {
16017
16005
  if (!group.admins.includes(adminId)) {
16018
16006
  throw new Error("Admin does not belong to this clinic group");
16019
16007
  }
16020
- return group.adminTokens.filter((t) => t.status === "active" /* ACTIVE */);
16008
+ const tokensQuery = (0, import_firestore41.query)(
16009
+ adminTokensRef(db, groupId),
16010
+ (0, import_firestore41.where)("status", "==", "active" /* ACTIVE */)
16011
+ );
16012
+ const snapshot = await (0, import_firestore41.getDocs)(tokensQuery);
16013
+ return snapshot.docs.map((d) => d.data());
16014
+ }
16015
+ async function getAllAdminTokens(db, groupId, adminId, app) {
16016
+ const group = await getClinicGroup(db, groupId);
16017
+ if (!group) {
16018
+ throw new Error("Clinic group not found");
16019
+ }
16020
+ if (!group.admins.includes(adminId)) {
16021
+ throw new Error("Admin does not belong to this clinic group");
16022
+ }
16023
+ const snapshot = await (0, import_firestore41.getDocs)(adminTokensRef(db, groupId));
16024
+ return snapshot.docs.map((d) => d.data());
16021
16025
  }
16022
16026
 
16023
16027
  // src/services/clinic/clinic-group.service.ts
@@ -16147,11 +16151,19 @@ var ClinicGroupService = class extends BaseService {
16147
16151
  async getActiveAdminTokens(groupId, adminId) {
16148
16152
  return getActiveAdminTokens(this.db, groupId, adminId, this.app);
16149
16153
  }
16150
- // TODO: Add a method to get all admin tokens for a clinic group (not just active ones)
16151
- // TODO: Refactor admin token methods not to add tokens to the clinicGroup document,
16152
- // but to add them to a subcollection called adminTokens that belongs to a specific clinicGroup document
16153
- // TODO: Add granular control over admin permissions, e.g. only allow admins to manage certain clinics to tokens directly
16154
- // TODO: Generally refactor admin tokens and invites, also create cloud function to send invites and send updates when sombody uses the token
16154
+ /**
16155
+ * Gets ALL admin tokens for a clinic group (all statuses)
16156
+ */
16157
+ async getAllAdminTokens(groupId, adminId) {
16158
+ return getAllAdminTokens(this.db, groupId, adminId, this.app);
16159
+ }
16160
+ /**
16161
+ * Finds an admin token by its value across all clinic groups.
16162
+ * Uses a collection group query for O(1) lookup.
16163
+ */
16164
+ async findAdminTokenByValue(tokenValue) {
16165
+ return findAdminTokenByValue(this.db, tokenValue);
16166
+ }
16155
16167
  /**
16156
16168
  * Updates the onboarding status for a clinic group
16157
16169
  *
@@ -17787,7 +17799,6 @@ var AuthService = class extends BaseService {
17787
17799
  });
17788
17800
  console.log("[AUTH] Updating admin with clinic group ID");
17789
17801
  await clinicAdminService.updateClinicAdmin(adminProfile.id, {
17790
- // Use admin profile ID, not user UID
17791
17802
  clinicGroupId: clinicGroup.id
17792
17803
  });
17793
17804
  console.log("[AUTH] Admin updated with clinic group ID successfully");
@@ -17805,46 +17816,20 @@ var AuthService = class extends BaseService {
17805
17816
  console.log("[AUTH] Invite token provided", {
17806
17817
  token: data.inviteToken
17807
17818
  });
17808
- console.log("[AUTH] Searching for token in clinic groups");
17809
- const groupsRef = (0, import_firestore46.collection)(this.db, CLINIC_GROUPS_COLLECTION);
17810
- const q = (0, import_firestore46.query)(groupsRef);
17811
- const querySnapshot = await (0, import_firestore46.getDocs)(q);
17812
- let foundGroup = null;
17813
- let foundToken = null;
17814
- console.log("[AUTH] Found", querySnapshot.size, "clinic groups to check");
17815
- for (const docSnapshot of querySnapshot.docs) {
17816
- const group = docSnapshot.data();
17817
- console.log("[AUTH] Checking group", {
17818
- groupId: group.id,
17819
- groupName: group.name
17820
- });
17821
- const token = group.adminTokens.find((t) => {
17822
- const isMatch = t.token === data.inviteToken && t.status === "active" /* ACTIVE */ && new Date(t.expiresAt.toDate()) > /* @__PURE__ */ new Date();
17823
- console.log("[AUTH] Checking token", {
17824
- tokenId: t.id,
17825
- tokenMatch: t.token === data.inviteToken,
17826
- tokenStatus: t.status,
17827
- tokenActive: t.status === "active" /* ACTIVE */,
17828
- tokenExpiry: new Date(t.expiresAt.toDate()),
17829
- tokenExpired: new Date(t.expiresAt.toDate()) <= /* @__PURE__ */ new Date(),
17830
- isMatch
17831
- });
17832
- return isMatch;
17833
- });
17834
- if (token) {
17835
- foundGroup = group;
17836
- foundToken = token;
17837
- console.log("[AUTH] Found matching token in group", {
17838
- groupId: group.id,
17839
- tokenId: token.id
17840
- });
17841
- break;
17842
- }
17843
- }
17844
- if (!foundGroup || !foundToken) {
17845
- console.error("[AUTH] No valid token found in any clinic group");
17819
+ console.log("[AUTH] Searching for token via collection group query");
17820
+ const tokenResult = await clinicGroupService.findAdminTokenByValue(data.inviteToken);
17821
+ if (!tokenResult) {
17822
+ console.error("[AUTH] No valid active token found");
17846
17823
  throw new Error("Invalid or expired invite token");
17847
17824
  }
17825
+ console.log("[AUTH] Found matching token", {
17826
+ tokenId: tokenResult.token.id,
17827
+ clinicGroupId: tokenResult.clinicGroupId
17828
+ });
17829
+ const foundGroup = await clinicGroupService.getClinicGroup(tokenResult.clinicGroupId);
17830
+ if (!foundGroup) {
17831
+ throw new Error("Clinic group not found for token");
17832
+ }
17848
17833
  clinicGroup = foundGroup;
17849
17834
  console.log("[AUTH] Creating clinic admin");
17850
17835
  const createClinicAdminData = {
@@ -24202,17 +24187,17 @@ var ProcedureService = class extends BaseService {
24202
24187
  const proceduresCollection = (0, import_firestore64.collection)(this.db, PROCEDURES_COLLECTION);
24203
24188
  let proceduresQuery = (0, import_firestore64.query)(proceduresCollection);
24204
24189
  if (pagination && pagination > 0) {
24205
- const { limit: limit22, startAfter: startAfter20 } = await import("firebase/firestore");
24190
+ const { limit: limit23, startAfter: startAfter20 } = await import("firebase/firestore");
24206
24191
  if (lastDoc) {
24207
24192
  proceduresQuery = (0, import_firestore64.query)(
24208
24193
  proceduresCollection,
24209
24194
  (0, import_firestore64.orderBy)("name"),
24210
24195
  // Use imported orderBy
24211
24196
  startAfter20(lastDoc),
24212
- limit22(pagination)
24197
+ limit23(pagination)
24213
24198
  );
24214
24199
  } else {
24215
- proceduresQuery = (0, import_firestore64.query)(proceduresCollection, (0, import_firestore64.orderBy)("name"), limit22(pagination));
24200
+ proceduresQuery = (0, import_firestore64.query)(proceduresCollection, (0, import_firestore64.orderBy)("name"), limit23(pagination));
24216
24201
  }
24217
24202
  } else {
24218
24203
  proceduresQuery = (0, import_firestore64.query)(proceduresCollection, (0, import_firestore64.orderBy)("name"));
@@ -28252,9 +28237,9 @@ var ConstantsService = class extends BaseService {
28252
28237
  */
28253
28238
  async getAllBenefits(options) {
28254
28239
  const allBenefits = await this.getAllBenefitsForFilter();
28255
- const { page, limit: limit22 } = options;
28256
- const startIndex = page * limit22;
28257
- const endIndex = startIndex + limit22;
28240
+ const { page, limit: limit23 } = options;
28241
+ const startIndex = page * limit23;
28242
+ const endIndex = startIndex + limit23;
28258
28243
  const paginatedBenefits = allBenefits.slice(startIndex, endIndex);
28259
28244
  return { benefits: paginatedBenefits, total: allBenefits.length };
28260
28245
  }
@@ -28351,9 +28336,9 @@ var ConstantsService = class extends BaseService {
28351
28336
  */
28352
28337
  async getAllContraindications(options) {
28353
28338
  const allContraindications = await this.getAllContraindicationsForFilter();
28354
- const { page, limit: limit22 } = options;
28355
- const startIndex = page * limit22;
28356
- const endIndex = startIndex + limit22;
28339
+ const { page, limit: limit23 } = options;
28340
+ const startIndex = page * limit23;
28341
+ const endIndex = startIndex + limit23;
28357
28342
  const paginatedContraindications = allContraindications.slice(
28358
28343
  startIndex,
28359
28344
  endIndex