@blackcode_sa/metaestetics-api 1.5.6 → 1.5.8

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.mjs CHANGED
@@ -63,6 +63,8 @@ import {
63
63
  } from "firebase/firestore";
64
64
 
65
65
  // src/types/documentation-templates/index.ts
66
+ var DOCUMENTATION_TEMPLATES_COLLECTION = "documentation-templates";
67
+ var FILLED_DOCUMENTS_COLLECTION = "filled-documents";
66
68
  var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
67
69
  DocumentElementType2["HEADING"] = "heading";
68
70
  DocumentElementType2["PARAGRAPH"] = "paragraph";
@@ -142,8 +144,6 @@ var UserRole = /* @__PURE__ */ ((UserRole2) => {
142
144
  return UserRole2;
143
145
  })(UserRole || {});
144
146
  var USERS_COLLECTION = "users";
145
- var DOCUMENTATION_TEMPLATES_COLLECTION = "documentation-templates";
146
- var FILLED_DOCUMENTS_COLLECTION = "filled-documents";
147
147
 
148
148
  // src/services/auth.service.ts
149
149
  import { z as z15 } from "zod";
@@ -1310,9 +1310,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
1310
1310
  var updateAllergyUtil = async (db, patientId, data, userRef) => {
1311
1311
  const validatedData = updateAllergySchema.parse(data);
1312
1312
  const { allergyIndex, ...updateData } = validatedData;
1313
- const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1314
- if (!doc21.exists()) throw new Error("Medical info not found");
1315
- const medicalInfo = doc21.data();
1313
+ const doc26 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1314
+ if (!doc26.exists()) throw new Error("Medical info not found");
1315
+ const medicalInfo = doc26.data();
1316
1316
  if (allergyIndex >= medicalInfo.allergies.length) {
1317
1317
  throw new Error("Invalid allergy index");
1318
1318
  }
@@ -1328,9 +1328,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
1328
1328
  });
1329
1329
  };
1330
1330
  var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
1331
- const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1332
- if (!doc21.exists()) throw new Error("Medical info not found");
1333
- const medicalInfo = doc21.data();
1331
+ const doc26 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1332
+ if (!doc26.exists()) throw new Error("Medical info not found");
1333
+ const medicalInfo = doc26.data();
1334
1334
  if (allergyIndex >= medicalInfo.allergies.length) {
1335
1335
  throw new Error("Invalid allergy index");
1336
1336
  }
@@ -1355,9 +1355,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
1355
1355
  var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1356
1356
  const validatedData = updateBlockingConditionSchema.parse(data);
1357
1357
  const { conditionIndex, ...updateData } = validatedData;
1358
- const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1359
- if (!doc21.exists()) throw new Error("Medical info not found");
1360
- const medicalInfo = doc21.data();
1358
+ const doc26 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1359
+ if (!doc26.exists()) throw new Error("Medical info not found");
1360
+ const medicalInfo = doc26.data();
1361
1361
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1362
1362
  throw new Error("Invalid blocking condition index");
1363
1363
  }
@@ -1373,9 +1373,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1373
1373
  });
1374
1374
  };
1375
1375
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
1376
- const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1377
- if (!doc21.exists()) throw new Error("Medical info not found");
1378
- const medicalInfo = doc21.data();
1376
+ const doc26 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1377
+ if (!doc26.exists()) throw new Error("Medical info not found");
1378
+ const medicalInfo = doc26.data();
1379
1379
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1380
1380
  throw new Error("Invalid blocking condition index");
1381
1381
  }
@@ -1400,9 +1400,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
1400
1400
  var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1401
1401
  const validatedData = updateContraindicationSchema.parse(data);
1402
1402
  const { contraindicationIndex, ...updateData } = validatedData;
1403
- const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1404
- if (!doc21.exists()) throw new Error("Medical info not found");
1405
- const medicalInfo = doc21.data();
1403
+ const doc26 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1404
+ if (!doc26.exists()) throw new Error("Medical info not found");
1405
+ const medicalInfo = doc26.data();
1406
1406
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1407
1407
  throw new Error("Invalid contraindication index");
1408
1408
  }
@@ -1418,9 +1418,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1418
1418
  });
1419
1419
  };
1420
1420
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
1421
- const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1422
- if (!doc21.exists()) throw new Error("Medical info not found");
1423
- const medicalInfo = doc21.data();
1421
+ const doc26 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1422
+ if (!doc26.exists()) throw new Error("Medical info not found");
1423
+ const medicalInfo = doc26.data();
1424
1424
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1425
1425
  throw new Error("Invalid contraindication index");
1426
1426
  }
@@ -1445,9 +1445,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
1445
1445
  var updateMedicationUtil = async (db, patientId, data, userRef) => {
1446
1446
  const validatedData = updateMedicationSchema.parse(data);
1447
1447
  const { medicationIndex, ...updateData } = validatedData;
1448
- const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1449
- if (!doc21.exists()) throw new Error("Medical info not found");
1450
- const medicalInfo = doc21.data();
1448
+ const doc26 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1449
+ if (!doc26.exists()) throw new Error("Medical info not found");
1450
+ const medicalInfo = doc26.data();
1451
1451
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1452
1452
  throw new Error("Invalid medication index");
1453
1453
  }
@@ -1463,9 +1463,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
1463
1463
  });
1464
1464
  };
1465
1465
  var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
1466
- const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1467
- if (!doc21.exists()) throw new Error("Medical info not found");
1468
- const medicalInfo = doc21.data();
1466
+ const doc26 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1467
+ if (!doc26.exists()) throw new Error("Medical info not found");
1468
+ const medicalInfo = doc26.data();
1469
1469
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1470
1470
  throw new Error("Invalid medication index");
1471
1471
  }
@@ -2782,7 +2782,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
2782
2782
  where2("clinicGroupId", "==", clinicGroupId)
2783
2783
  );
2784
2784
  const querySnapshot = await getDocs2(q);
2785
- return querySnapshot.docs.map((doc21) => doc21.data());
2785
+ return querySnapshot.docs.map((doc26) => doc26.data());
2786
2786
  }
2787
2787
  async function updateClinicAdmin(db, adminId, data) {
2788
2788
  const admin = await getClinicAdmin(db, adminId);
@@ -3092,16 +3092,16 @@ var CertificationLevel = /* @__PURE__ */ ((CertificationLevel2) => {
3092
3092
  CertificationLevel2["PLASTIC_SURGEON"] = "plastic_surgeon";
3093
3093
  return CertificationLevel2;
3094
3094
  })(CertificationLevel || {});
3095
- var CertificationSpecialty = /* @__PURE__ */ ((CertificationSpecialty2) => {
3096
- CertificationSpecialty2["LASER"] = "laser";
3097
- CertificationSpecialty2["INJECTABLES"] = "injectables";
3098
- CertificationSpecialty2["CHEMICAL_PEELS"] = "chemical_peels";
3099
- CertificationSpecialty2["MICRODERMABRASION"] = "microdermabrasion";
3100
- CertificationSpecialty2["BODY_CONTOURING"] = "body_contouring";
3101
- CertificationSpecialty2["SKIN_CARE"] = "skin_care";
3102
- CertificationSpecialty2["WOUND_CARE"] = "wound_care";
3103
- CertificationSpecialty2["ANESTHESIA"] = "anesthesia";
3104
- return CertificationSpecialty2;
3095
+ var CertificationSpecialty = /* @__PURE__ */ ((CertificationSpecialty3) => {
3096
+ CertificationSpecialty3["LASER"] = "laser";
3097
+ CertificationSpecialty3["INJECTABLES"] = "injectables";
3098
+ CertificationSpecialty3["CHEMICAL_PEELS"] = "chemical_peels";
3099
+ CertificationSpecialty3["MICRODERMABRASION"] = "microdermabrasion";
3100
+ CertificationSpecialty3["BODY_CONTOURING"] = "body_contouring";
3101
+ CertificationSpecialty3["SKIN_CARE"] = "skin_care";
3102
+ CertificationSpecialty3["WOUND_CARE"] = "wound_care";
3103
+ CertificationSpecialty3["ANESTHESIA"] = "anesthesia";
3104
+ return CertificationSpecialty3;
3105
3105
  })(CertificationSpecialty || {});
3106
3106
 
3107
3107
  // src/validations/practitioner.schema.ts
@@ -3449,7 +3449,7 @@ var PractitionerService = class extends BaseService {
3449
3449
  where3("expiresAt", ">", Timestamp8.now())
3450
3450
  );
3451
3451
  const querySnapshot = await getDocs3(q);
3452
- return querySnapshot.docs.map((doc21) => doc21.data());
3452
+ return querySnapshot.docs.map((doc26) => doc26.data());
3453
3453
  }
3454
3454
  /**
3455
3455
  * Gets a token by its string value and validates it
@@ -3532,7 +3532,7 @@ var PractitionerService = class extends BaseService {
3532
3532
  where3("status", "==", "active" /* ACTIVE */)
3533
3533
  );
3534
3534
  const querySnapshot = await getDocs3(q);
3535
- return querySnapshot.docs.map((doc21) => doc21.data());
3535
+ return querySnapshot.docs.map((doc26) => doc26.data());
3536
3536
  }
3537
3537
  /**
3538
3538
  * Dohvata sve draft zdravstvene radnike za određenu kliniku
@@ -3544,7 +3544,7 @@ var PractitionerService = class extends BaseService {
3544
3544
  where3("status", "==", "draft" /* DRAFT */)
3545
3545
  );
3546
3546
  const querySnapshot = await getDocs3(q);
3547
- return querySnapshot.docs.map((doc21) => doc21.data());
3547
+ return querySnapshot.docs.map((doc26) => doc26.data());
3548
3548
  }
3549
3549
  /**
3550
3550
  * Ažurira profil zdravstvenog radnika
@@ -3853,7 +3853,7 @@ var UserService = class extends BaseService {
3853
3853
  ];
3854
3854
  const q = query4(collection4(this.db, USERS_COLLECTION), ...constraints);
3855
3855
  const querySnapshot = await getDocs4(q);
3856
- const users = querySnapshot.docs.map((doc21) => doc21.data());
3856
+ const users = querySnapshot.docs.map((doc26) => doc26.data());
3857
3857
  return Promise.all(users.map((userData) => userSchema.parse(userData)));
3858
3858
  }
3859
3859
  /**
@@ -4233,7 +4233,7 @@ async function getAllActiveGroups(db) {
4233
4233
  where5("isActive", "==", true)
4234
4234
  );
4235
4235
  const querySnapshot = await getDocs5(q);
4236
- return querySnapshot.docs.map((doc21) => doc21.data());
4236
+ return querySnapshot.docs.map((doc26) => doc26.data());
4237
4237
  }
4238
4238
  async function updateClinicGroup(db, groupId, data, app) {
4239
4239
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -4903,7 +4903,7 @@ async function getClinicsByGroup(db, groupId) {
4903
4903
  where6("isActive", "==", true)
4904
4904
  );
4905
4905
  const querySnapshot = await getDocs6(q);
4906
- return querySnapshot.docs.map((doc21) => doc21.data());
4906
+ return querySnapshot.docs.map((doc26) => doc26.data());
4907
4907
  }
4908
4908
  async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
4909
4909
  console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
@@ -5115,7 +5115,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
5115
5115
  }
5116
5116
  const q = query6(collection6(db, CLINICS_COLLECTION), ...constraints);
5117
5117
  const querySnapshot = await getDocs6(q);
5118
- return querySnapshot.docs.map((doc21) => doc21.data());
5118
+ return querySnapshot.docs.map((doc26) => doc26.data());
5119
5119
  }
5120
5120
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
5121
5121
  return getClinicsByAdmin(
@@ -5268,8 +5268,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
5268
5268
  }
5269
5269
  const q = query7(collection8(db, CLINICS_COLLECTION), ...constraints);
5270
5270
  const querySnapshot = await getDocs7(q);
5271
- for (const doc21 of querySnapshot.docs) {
5272
- const clinic = doc21.data();
5271
+ for (const doc26 of querySnapshot.docs) {
5272
+ const clinic = doc26.data();
5273
5273
  const distance = distanceBetween(
5274
5274
  [center.latitude, center.longitude],
5275
5275
  [clinic.location.latitude, clinic.location.longitude]
@@ -6214,9 +6214,9 @@ var NotificationService = class extends BaseService {
6214
6214
  orderBy("notificationTime", "desc")
6215
6215
  );
6216
6216
  const querySnapshot = await getDocs9(q);
6217
- return querySnapshot.docs.map((doc21) => ({
6218
- id: doc21.id,
6219
- ...doc21.data()
6217
+ return querySnapshot.docs.map((doc26) => ({
6218
+ id: doc26.id,
6219
+ ...doc26.data()
6220
6220
  }));
6221
6221
  }
6222
6222
  /**
@@ -6230,9 +6230,9 @@ var NotificationService = class extends BaseService {
6230
6230
  orderBy("notificationTime", "desc")
6231
6231
  );
6232
6232
  const querySnapshot = await getDocs9(q);
6233
- return querySnapshot.docs.map((doc21) => ({
6234
- id: doc21.id,
6235
- ...doc21.data()
6233
+ return querySnapshot.docs.map((doc26) => ({
6234
+ id: doc26.id,
6235
+ ...doc26.data()
6236
6236
  }));
6237
6237
  }
6238
6238
  /**
@@ -6304,9 +6304,9 @@ var NotificationService = class extends BaseService {
6304
6304
  orderBy("notificationTime", "desc")
6305
6305
  );
6306
6306
  const querySnapshot = await getDocs9(q);
6307
- return querySnapshot.docs.map((doc21) => ({
6308
- id: doc21.id,
6309
- ...doc21.data()
6307
+ return querySnapshot.docs.map((doc26) => ({
6308
+ id: doc26.id,
6309
+ ...doc26.data()
6310
6310
  }));
6311
6311
  }
6312
6312
  /**
@@ -6319,9 +6319,9 @@ var NotificationService = class extends BaseService {
6319
6319
  orderBy("notificationTime", "desc")
6320
6320
  );
6321
6321
  const querySnapshot = await getDocs9(q);
6322
- return querySnapshot.docs.map((doc21) => ({
6323
- id: doc21.id,
6324
- ...doc21.data()
6322
+ return querySnapshot.docs.map((doc26) => ({
6323
+ id: doc26.id,
6324
+ ...doc26.data()
6325
6325
  }));
6326
6326
  }
6327
6327
  };
@@ -6481,7 +6481,7 @@ var ProcedureService = class extends BaseService {
6481
6481
  where10("isActive", "==", true)
6482
6482
  );
6483
6483
  const snapshot = await getDocs10(q);
6484
- return snapshot.docs.map((doc21) => doc21.data());
6484
+ return snapshot.docs.map((doc26) => doc26.data());
6485
6485
  }
6486
6486
  /**
6487
6487
  * Gets all procedures for a practitioner
@@ -6495,7 +6495,7 @@ var ProcedureService = class extends BaseService {
6495
6495
  where10("isActive", "==", true)
6496
6496
  );
6497
6497
  const snapshot = await getDocs10(q);
6498
- return snapshot.docs.map((doc21) => doc21.data());
6498
+ return snapshot.docs.map((doc26) => doc26.data());
6499
6499
  }
6500
6500
  /**
6501
6501
  * Updates a procedure
@@ -6694,9 +6694,9 @@ var DocumentationTemplateService = class extends BaseService {
6694
6694
  const querySnapshot = await getDocs11(q);
6695
6695
  const templates = [];
6696
6696
  let lastVisible = null;
6697
- querySnapshot.forEach((doc21) => {
6698
- templates.push(doc21.data());
6699
- lastVisible = doc21;
6697
+ querySnapshot.forEach((doc26) => {
6698
+ templates.push(doc26.data());
6699
+ lastVisible = doc26;
6700
6700
  });
6701
6701
  return {
6702
6702
  templates,
@@ -6724,9 +6724,9 @@ var DocumentationTemplateService = class extends BaseService {
6724
6724
  const querySnapshot = await getDocs11(q);
6725
6725
  const templates = [];
6726
6726
  let lastVisible = null;
6727
- querySnapshot.forEach((doc21) => {
6728
- templates.push(doc21.data());
6729
- lastVisible = doc21;
6727
+ querySnapshot.forEach((doc26) => {
6728
+ templates.push(doc26.data());
6729
+ lastVisible = doc26;
6730
6730
  });
6731
6731
  return {
6732
6732
  templates,
@@ -6753,9 +6753,9 @@ var DocumentationTemplateService = class extends BaseService {
6753
6753
  const querySnapshot = await getDocs11(q);
6754
6754
  const templates = [];
6755
6755
  let lastVisible = null;
6756
- querySnapshot.forEach((doc21) => {
6757
- templates.push(doc21.data());
6758
- lastVisible = doc21;
6756
+ querySnapshot.forEach((doc26) => {
6757
+ templates.push(doc26.data());
6758
+ lastVisible = doc26;
6759
6759
  });
6760
6760
  return {
6761
6761
  templates,
@@ -6880,9 +6880,9 @@ var FilledDocumentService = class extends BaseService {
6880
6880
  const querySnapshot = await getDocs12(q);
6881
6881
  const documents = [];
6882
6882
  let lastVisible = null;
6883
- querySnapshot.forEach((doc21) => {
6884
- documents.push(doc21.data());
6885
- lastVisible = doc21;
6883
+ querySnapshot.forEach((doc26) => {
6884
+ documents.push(doc26.data());
6885
+ lastVisible = doc26;
6886
6886
  });
6887
6887
  return {
6888
6888
  documents,
@@ -6909,9 +6909,9 @@ var FilledDocumentService = class extends BaseService {
6909
6909
  const querySnapshot = await getDocs12(q);
6910
6910
  const documents = [];
6911
6911
  let lastVisible = null;
6912
- querySnapshot.forEach((doc21) => {
6913
- documents.push(doc21.data());
6914
- lastVisible = doc21;
6912
+ querySnapshot.forEach((doc26) => {
6913
+ documents.push(doc26.data());
6914
+ lastVisible = doc26;
6915
6915
  });
6916
6916
  return {
6917
6917
  documents,
@@ -6938,9 +6938,9 @@ var FilledDocumentService = class extends BaseService {
6938
6938
  const querySnapshot = await getDocs12(q);
6939
6939
  const documents = [];
6940
6940
  let lastVisible = null;
6941
- querySnapshot.forEach((doc21) => {
6942
- documents.push(doc21.data());
6943
- lastVisible = doc21;
6941
+ querySnapshot.forEach((doc26) => {
6942
+ documents.push(doc26.data());
6943
+ lastVisible = doc26;
6944
6944
  });
6945
6945
  return {
6946
6946
  documents,
@@ -6967,9 +6967,9 @@ var FilledDocumentService = class extends BaseService {
6967
6967
  const querySnapshot = await getDocs12(q);
6968
6968
  const documents = [];
6969
6969
  let lastVisible = null;
6970
- querySnapshot.forEach((doc21) => {
6971
- documents.push(doc21.data());
6972
- lastVisible = doc21;
6970
+ querySnapshot.forEach((doc26) => {
6971
+ documents.push(doc26.data());
6972
+ lastVisible = doc26;
6973
6973
  });
6974
6974
  return {
6975
6975
  documents,
@@ -6996,9 +6996,9 @@ var FilledDocumentService = class extends BaseService {
6996
6996
  const querySnapshot = await getDocs12(q);
6997
6997
  const documents = [];
6998
6998
  let lastVisible = null;
6999
- querySnapshot.forEach((doc21) => {
7000
- documents.push(doc21.data());
7001
- lastVisible = doc21;
6999
+ querySnapshot.forEach((doc26) => {
7000
+ documents.push(doc26.data());
7001
+ lastVisible = doc26;
7002
7002
  });
7003
7003
  return {
7004
7004
  documents,
@@ -7558,7 +7558,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
7558
7558
  );
7559
7559
  const q = query16(calendarsRef, orderBy7("createdAt", "desc"));
7560
7560
  const querySnapshot = await getDocs16(q);
7561
- return querySnapshot.docs.map((doc21) => doc21.data());
7561
+ return querySnapshot.docs.map((doc26) => doc26.data());
7562
7562
  }
7563
7563
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
7564
7564
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
@@ -7575,7 +7575,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
7575
7575
  );
7576
7576
  const q = query16(calendarsRef, orderBy7("createdAt", "desc"));
7577
7577
  const querySnapshot = await getDocs16(q);
7578
- return querySnapshot.docs.map((doc21) => doc21.data());
7578
+ return querySnapshot.docs.map((doc26) => doc26.data());
7579
7579
  }
7580
7580
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
7581
7581
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
@@ -7592,7 +7592,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
7592
7592
  );
7593
7593
  const q = query16(calendarsRef, orderBy7("createdAt", "desc"));
7594
7594
  const querySnapshot = await getDocs16(q);
7595
- return querySnapshot.docs.map((doc21) => doc21.data());
7595
+ return querySnapshot.docs.map((doc26) => doc26.data());
7596
7596
  }
7597
7597
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
7598
7598
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -8947,9 +8947,9 @@ var CalendarServiceV2 = class extends BaseService {
8947
8947
  where17("eventTime.start", "<=", Timestamp24.fromDate(endDate))
8948
8948
  );
8949
8949
  const eventsSnapshot = await getDocs17(q);
8950
- const events = eventsSnapshot.docs.map((doc21) => ({
8951
- id: doc21.id,
8952
- ...doc21.data()
8950
+ const events = eventsSnapshot.docs.map((doc26) => ({
8951
+ id: doc26.id,
8952
+ ...doc26.data()
8953
8953
  }));
8954
8954
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
8955
8955
  doctorId
@@ -9482,7 +9482,7 @@ var CalendarServiceV2 = class extends BaseService {
9482
9482
  ])
9483
9483
  );
9484
9484
  const querySnapshot = await getDocs17(q);
9485
- return querySnapshot.docs.map((doc21) => doc21.data());
9485
+ return querySnapshot.docs.map((doc26) => doc26.data());
9486
9486
  }
9487
9487
  /**
9488
9488
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -9606,6 +9606,806 @@ var CalendarServiceV2 = class extends BaseService {
9606
9606
  // #endregion
9607
9607
  };
9608
9608
 
9609
+ // src/backoffice/services/brand.service.ts
9610
+ import {
9611
+ addDoc as addDoc4,
9612
+ collection as collection19,
9613
+ doc as doc21,
9614
+ getDoc as getDoc24,
9615
+ getDocs as getDocs18,
9616
+ query as query18,
9617
+ updateDoc as updateDoc22,
9618
+ where as where18
9619
+ } from "firebase/firestore";
9620
+
9621
+ // src/backoffice/types/brand.types.ts
9622
+ var BRANDS_COLLECTION = "brands";
9623
+
9624
+ // src/backoffice/services/brand.service.ts
9625
+ var BrandService = class extends BaseService {
9626
+ get brandsRef() {
9627
+ return collection19(this.db, BRANDS_COLLECTION);
9628
+ }
9629
+ async create(brand) {
9630
+ const now = /* @__PURE__ */ new Date();
9631
+ const newBrand = {
9632
+ ...brand,
9633
+ createdAt: now,
9634
+ updatedAt: now,
9635
+ isActive: true
9636
+ };
9637
+ const docRef = await addDoc4(this.brandsRef, newBrand);
9638
+ return { id: docRef.id, ...newBrand };
9639
+ }
9640
+ async getAll() {
9641
+ const q = query18(this.brandsRef, where18("isActive", "==", true));
9642
+ const snapshot = await getDocs18(q);
9643
+ return snapshot.docs.map(
9644
+ (doc26) => ({
9645
+ id: doc26.id,
9646
+ ...doc26.data()
9647
+ })
9648
+ );
9649
+ }
9650
+ async update(id, brand) {
9651
+ const updateData = {
9652
+ ...brand,
9653
+ updatedAt: /* @__PURE__ */ new Date()
9654
+ };
9655
+ const docRef = doc21(this.brandsRef, id);
9656
+ await updateDoc22(docRef, updateData);
9657
+ return this.getById(id);
9658
+ }
9659
+ async delete(id) {
9660
+ await this.update(id, { isActive: false });
9661
+ }
9662
+ async getById(id) {
9663
+ const docRef = doc21(this.brandsRef, id);
9664
+ const docSnap = await getDoc24(docRef);
9665
+ if (!docSnap.exists()) return null;
9666
+ return {
9667
+ id: docSnap.id,
9668
+ ...docSnap.data()
9669
+ };
9670
+ }
9671
+ };
9672
+
9673
+ // src/backoffice/services/category.service.ts
9674
+ import {
9675
+ addDoc as addDoc5,
9676
+ collection as collection20,
9677
+ doc as doc22,
9678
+ getDoc as getDoc25,
9679
+ getDocs as getDocs19,
9680
+ query as query19,
9681
+ updateDoc as updateDoc23,
9682
+ where as where19
9683
+ } from "firebase/firestore";
9684
+ var CategoryService = class extends BaseService {
9685
+ /**
9686
+ * Referenca na Firestore kolekciju kategorija
9687
+ */
9688
+ get categoriesRef() {
9689
+ return collection20(this.db, CATEGORIES_COLLECTION);
9690
+ }
9691
+ /**
9692
+ * Kreira novu kategoriju u sistemu
9693
+ * @param category - Podaci za novu kategoriju
9694
+ * @returns Kreirana kategorija sa generisanim ID-em
9695
+ */
9696
+ async create(category) {
9697
+ const now = /* @__PURE__ */ new Date();
9698
+ const newCategory = {
9699
+ ...category,
9700
+ createdAt: now,
9701
+ updatedAt: now,
9702
+ isActive: true
9703
+ };
9704
+ const docRef = await addDoc5(this.categoriesRef, newCategory);
9705
+ return { id: docRef.id, ...newCategory };
9706
+ }
9707
+ /**
9708
+ * Vraća sve aktivne kategorije
9709
+ * @returns Lista aktivnih kategorija
9710
+ */
9711
+ async getAll() {
9712
+ const q = query19(this.categoriesRef, where19("isActive", "==", true));
9713
+ const snapshot = await getDocs19(q);
9714
+ return snapshot.docs.map(
9715
+ (doc26) => ({
9716
+ id: doc26.id,
9717
+ ...doc26.data()
9718
+ })
9719
+ );
9720
+ }
9721
+ /**
9722
+ * Vraća sve aktivne kategorije za određenu familiju procedura
9723
+ * @param family - Familija procedura (aesthetics/surgery)
9724
+ * @returns Lista kategorija koje pripadaju traženoj familiji
9725
+ */
9726
+ async getAllByFamily(family) {
9727
+ const q = query19(
9728
+ this.categoriesRef,
9729
+ where19("family", "==", family),
9730
+ where19("isActive", "==", true)
9731
+ );
9732
+ const snapshot = await getDocs19(q);
9733
+ return snapshot.docs.map(
9734
+ (doc26) => ({
9735
+ id: doc26.id,
9736
+ ...doc26.data()
9737
+ })
9738
+ );
9739
+ }
9740
+ /**
9741
+ * Ažurira postojeću kategoriju
9742
+ * @param id - ID kategorije koja se ažurira
9743
+ * @param category - Novi podaci za kategoriju
9744
+ * @returns Ažurirana kategorija
9745
+ */
9746
+ async update(id, category) {
9747
+ const updateData = {
9748
+ ...category,
9749
+ updatedAt: /* @__PURE__ */ new Date()
9750
+ };
9751
+ const docRef = doc22(this.categoriesRef, id);
9752
+ await updateDoc23(docRef, updateData);
9753
+ return this.getById(id);
9754
+ }
9755
+ /**
9756
+ * Soft delete kategorije (postavlja isActive na false)
9757
+ * @param id - ID kategorije koja se briše
9758
+ */
9759
+ async delete(id) {
9760
+ await this.update(id, { isActive: false });
9761
+ }
9762
+ /**
9763
+ * Vraća kategoriju po ID-u
9764
+ * @param id - ID tražene kategorije
9765
+ * @returns Kategorija ili null ako ne postoji
9766
+ */
9767
+ async getById(id) {
9768
+ const docRef = doc22(this.categoriesRef, id);
9769
+ const docSnap = await getDoc25(docRef);
9770
+ if (!docSnap.exists()) return null;
9771
+ return {
9772
+ id: docSnap.id,
9773
+ ...docSnap.data()
9774
+ };
9775
+ }
9776
+ };
9777
+
9778
+ // src/backoffice/services/subcategory.service.ts
9779
+ import {
9780
+ addDoc as addDoc6,
9781
+ collection as collection21,
9782
+ doc as doc23,
9783
+ getDoc as getDoc26,
9784
+ getDocs as getDocs20,
9785
+ query as query20,
9786
+ updateDoc as updateDoc24,
9787
+ where as where20
9788
+ } from "firebase/firestore";
9789
+ var SubcategoryService = class extends BaseService {
9790
+ /**
9791
+ * Vraća referencu na Firestore kolekciju podkategorija za određenu kategoriju
9792
+ * @param categoryId - ID roditeljske kategorije
9793
+ */
9794
+ getSubcategoriesRef(categoryId) {
9795
+ return collection21(
9796
+ this.db,
9797
+ CATEGORIES_COLLECTION,
9798
+ categoryId,
9799
+ SUBCATEGORIES_COLLECTION
9800
+ );
9801
+ }
9802
+ /**
9803
+ * Kreira novu podkategoriju u okviru kategorije
9804
+ * @param categoryId - ID kategorije kojoj će pripadati nova podkategorija
9805
+ * @param subcategory - Podaci za novu podkategoriju
9806
+ * @returns Kreirana podkategorija sa generisanim ID-em
9807
+ */
9808
+ async create(categoryId, subcategory) {
9809
+ const now = /* @__PURE__ */ new Date();
9810
+ const newSubcategory = {
9811
+ ...subcategory,
9812
+ categoryId,
9813
+ createdAt: now,
9814
+ updatedAt: now,
9815
+ isActive: true
9816
+ };
9817
+ const docRef = await addDoc6(
9818
+ this.getSubcategoriesRef(categoryId),
9819
+ newSubcategory
9820
+ );
9821
+ return { id: docRef.id, ...newSubcategory };
9822
+ }
9823
+ /**
9824
+ * Vraća sve aktivne podkategorije za određenu kategoriju
9825
+ * @param categoryId - ID kategorije čije podkategorije tražimo
9826
+ * @returns Lista aktivnih podkategorija
9827
+ */
9828
+ async getAllByCategoryId(categoryId) {
9829
+ const q = query20(
9830
+ this.getSubcategoriesRef(categoryId),
9831
+ where20("isActive", "==", true)
9832
+ );
9833
+ const snapshot = await getDocs20(q);
9834
+ return snapshot.docs.map(
9835
+ (doc26) => ({
9836
+ id: doc26.id,
9837
+ ...doc26.data()
9838
+ })
9839
+ );
9840
+ }
9841
+ /**
9842
+ * Ažurira postojeću podkategoriju
9843
+ * @param categoryId - ID kategorije kojoj pripada podkategorija
9844
+ * @param subcategoryId - ID podkategorije koja se ažurira
9845
+ * @param subcategory - Novi podaci za podkategoriju
9846
+ * @returns Ažurirana podkategorija
9847
+ */
9848
+ async update(categoryId, subcategoryId, subcategory) {
9849
+ const updateData = {
9850
+ ...subcategory,
9851
+ updatedAt: /* @__PURE__ */ new Date()
9852
+ };
9853
+ const docRef = doc23(this.getSubcategoriesRef(categoryId), subcategoryId);
9854
+ await updateDoc24(docRef, updateData);
9855
+ return this.getById(categoryId, subcategoryId);
9856
+ }
9857
+ /**
9858
+ * Soft delete podkategorije (postavlja isActive na false)
9859
+ * @param categoryId - ID kategorije kojoj pripada podkategorija
9860
+ * @param subcategoryId - ID podkategorije koja se briše
9861
+ */
9862
+ async delete(categoryId, subcategoryId) {
9863
+ await this.update(categoryId, subcategoryId, { isActive: false });
9864
+ }
9865
+ /**
9866
+ * Vraća podkategoriju po ID-u
9867
+ * @param categoryId - ID kategorije kojoj pripada podkategorija
9868
+ * @param subcategoryId - ID tražene podkategorije
9869
+ * @returns Podkategorija ili null ako ne postoji
9870
+ */
9871
+ async getById(categoryId, subcategoryId) {
9872
+ const docRef = doc23(this.getSubcategoriesRef(categoryId), subcategoryId);
9873
+ const docSnap = await getDoc26(docRef);
9874
+ if (!docSnap.exists()) return null;
9875
+ return {
9876
+ id: docSnap.id,
9877
+ ...docSnap.data()
9878
+ };
9879
+ }
9880
+ };
9881
+
9882
+ // src/backoffice/services/technology.service.ts
9883
+ import {
9884
+ addDoc as addDoc7,
9885
+ collection as collection22,
9886
+ doc as doc24,
9887
+ getDoc as getDoc27,
9888
+ getDocs as getDocs21,
9889
+ query as query21,
9890
+ updateDoc as updateDoc25,
9891
+ where as where21,
9892
+ arrayUnion as arrayUnion5,
9893
+ arrayRemove as arrayRemove3
9894
+ } from "firebase/firestore";
9895
+ var DEFAULT_CERTIFICATION_REQUIREMENT = {
9896
+ minimumLevel: "aesthetician" /* AESTHETICIAN */,
9897
+ requiredSpecialties: []
9898
+ };
9899
+ var TechnologyService = class extends BaseService {
9900
+ /**
9901
+ * Vraća referencu na Firestore kolekciju tehnologija za određenu podkategoriju
9902
+ * @param categoryId - ID kategorije
9903
+ * @param subcategoryId - ID podkategorije
9904
+ */
9905
+ getTechnologiesRef(categoryId, subcategoryId) {
9906
+ return collection22(
9907
+ this.db,
9908
+ CATEGORIES_COLLECTION,
9909
+ categoryId,
9910
+ SUBCATEGORIES_COLLECTION,
9911
+ subcategoryId,
9912
+ TECHNOLOGIES_COLLECTION
9913
+ );
9914
+ }
9915
+ /**
9916
+ * Kreira novu tehnologiju u okviru podkategorije
9917
+ * @param categoryId - ID kategorije
9918
+ * @param subcategoryId - ID podkategorije
9919
+ * @param technology - Podaci za novu tehnologiju
9920
+ * @returns Kreirana tehnologija sa generisanim ID-em
9921
+ */
9922
+ async create(categoryId, subcategoryId, technology) {
9923
+ const now = /* @__PURE__ */ new Date();
9924
+ const newTechnology = {
9925
+ ...technology,
9926
+ subcategoryId,
9927
+ createdAt: now,
9928
+ updatedAt: now,
9929
+ isActive: true,
9930
+ requirements: {
9931
+ pre: [],
9932
+ post: []
9933
+ },
9934
+ blockingConditions: [],
9935
+ contraindications: [],
9936
+ benefits: [],
9937
+ certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
9938
+ };
9939
+ const docRef = await addDoc7(
9940
+ this.getTechnologiesRef(categoryId, subcategoryId),
9941
+ newTechnology
9942
+ );
9943
+ return { id: docRef.id, ...newTechnology };
9944
+ }
9945
+ /**
9946
+ * Vraća sve aktivne tehnologije za određenu podkategoriju
9947
+ * @param categoryId - ID kategorije
9948
+ * @param subcategoryId - ID podkategorije
9949
+ * @returns Lista aktivnih tehnologija
9950
+ */
9951
+ async getAllBySubcategoryId(categoryId, subcategoryId) {
9952
+ const q = query21(
9953
+ this.getTechnologiesRef(categoryId, subcategoryId),
9954
+ where21("isActive", "==", true)
9955
+ );
9956
+ const snapshot = await getDocs21(q);
9957
+ return snapshot.docs.map(
9958
+ (doc26) => ({
9959
+ id: doc26.id,
9960
+ ...doc26.data()
9961
+ })
9962
+ );
9963
+ }
9964
+ /**
9965
+ * Ažurira postojeću tehnologiju
9966
+ * @param categoryId - ID kategorije
9967
+ * @param subcategoryId - ID podkategorije
9968
+ * @param technologyId - ID tehnologije
9969
+ * @param technology - Novi podaci za tehnologiju
9970
+ * @returns Ažurirana tehnologija
9971
+ */
9972
+ async update(categoryId, subcategoryId, technologyId, technology) {
9973
+ const updateData = {
9974
+ ...technology,
9975
+ updatedAt: /* @__PURE__ */ new Date()
9976
+ };
9977
+ const docRef = doc24(
9978
+ this.getTechnologiesRef(categoryId, subcategoryId),
9979
+ technologyId
9980
+ );
9981
+ await updateDoc25(docRef, updateData);
9982
+ return this.getById(categoryId, subcategoryId, technologyId);
9983
+ }
9984
+ /**
9985
+ * Soft delete tehnologije (postavlja isActive na false)
9986
+ * @param categoryId - ID kategorije
9987
+ * @param subcategoryId - ID podkategorije
9988
+ * @param technologyId - ID tehnologije koja se briše
9989
+ */
9990
+ async delete(categoryId, subcategoryId, technologyId) {
9991
+ await this.update(categoryId, subcategoryId, technologyId, {
9992
+ isActive: false
9993
+ });
9994
+ }
9995
+ /**
9996
+ * Vraća tehnologiju po ID-u
9997
+ * @param categoryId - ID kategorije
9998
+ * @param subcategoryId - ID podkategorije
9999
+ * @param technologyId - ID tražene tehnologije
10000
+ * @returns Tehnologija ili null ako ne postoji
10001
+ */
10002
+ async getById(categoryId, subcategoryId, technologyId) {
10003
+ const docRef = doc24(
10004
+ this.getTechnologiesRef(categoryId, subcategoryId),
10005
+ technologyId
10006
+ );
10007
+ const docSnap = await getDoc27(docRef);
10008
+ if (!docSnap.exists()) return null;
10009
+ return {
10010
+ id: docSnap.id,
10011
+ ...docSnap.data()
10012
+ };
10013
+ }
10014
+ /**
10015
+ * Dodaje novi zahtev tehnologiji
10016
+ * @param categoryId - ID kategorije
10017
+ * @param subcategoryId - ID podkategorije
10018
+ * @param technologyId - ID tehnologije
10019
+ * @param requirement - Zahtev koji se dodaje
10020
+ * @returns Ažurirana tehnologija sa novim zahtevom
10021
+ */
10022
+ async addRequirement(categoryId, subcategoryId, technologyId, requirement) {
10023
+ const docRef = doc24(
10024
+ this.getTechnologiesRef(categoryId, subcategoryId),
10025
+ technologyId
10026
+ );
10027
+ const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
10028
+ await updateDoc25(docRef, {
10029
+ [requirementType]: arrayUnion5(requirement),
10030
+ updatedAt: /* @__PURE__ */ new Date()
10031
+ });
10032
+ return this.getById(categoryId, subcategoryId, technologyId);
10033
+ }
10034
+ /**
10035
+ * Uklanja zahtev iz tehnologije
10036
+ * @param categoryId - ID kategorije
10037
+ * @param subcategoryId - ID podkategorije
10038
+ * @param technologyId - ID tehnologije
10039
+ * @param requirement - Zahtev koji se uklanja
10040
+ * @returns Ažurirana tehnologija bez uklonjenog zahteva
10041
+ */
10042
+ async removeRequirement(categoryId, subcategoryId, technologyId, requirement) {
10043
+ const docRef = doc24(
10044
+ this.getTechnologiesRef(categoryId, subcategoryId),
10045
+ technologyId
10046
+ );
10047
+ const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
10048
+ await updateDoc25(docRef, {
10049
+ [requirementType]: arrayRemove3(requirement),
10050
+ updatedAt: /* @__PURE__ */ new Date()
10051
+ });
10052
+ return this.getById(categoryId, subcategoryId, technologyId);
10053
+ }
10054
+ /**
10055
+ * Vraća sve zahteve za tehnologiju
10056
+ * @param categoryId - ID kategorije
10057
+ * @param subcategoryId - ID podkategorije
10058
+ * @param technologyId - ID tehnologije
10059
+ * @param type - Opcioni filter za tip zahteva (pre/post)
10060
+ * @returns Lista zahteva
10061
+ */
10062
+ async getRequirements(categoryId, subcategoryId, technologyId, type) {
10063
+ const technology = await this.getById(
10064
+ categoryId,
10065
+ subcategoryId,
10066
+ technologyId
10067
+ );
10068
+ if (!technology || !technology.requirements) return [];
10069
+ if (type) {
10070
+ return technology.requirements[type];
10071
+ }
10072
+ return [...technology.requirements.pre, ...technology.requirements.post];
10073
+ }
10074
+ /**
10075
+ * Ažurira postojeći zahtev
10076
+ * @param categoryId - ID kategorije
10077
+ * @param subcategoryId - ID podkategorije
10078
+ * @param technologyId - ID tehnologije
10079
+ * @param oldRequirement - Stari zahtev koji se menja
10080
+ * @param newRequirement - Novi zahtev koji zamenjuje stari
10081
+ * @returns Ažurirana tehnologija
10082
+ */
10083
+ async updateRequirement(categoryId, subcategoryId, technologyId, oldRequirement, newRequirement) {
10084
+ await this.removeRequirement(
10085
+ categoryId,
10086
+ subcategoryId,
10087
+ technologyId,
10088
+ oldRequirement
10089
+ );
10090
+ return this.addRequirement(
10091
+ categoryId,
10092
+ subcategoryId,
10093
+ technologyId,
10094
+ newRequirement
10095
+ );
10096
+ }
10097
+ /**
10098
+ * Dodaje blokirajući uslov tehnologiji
10099
+ * @param categoryId - ID kategorije
10100
+ * @param subcategoryId - ID podkategorije
10101
+ * @param technologyId - ID tehnologije
10102
+ * @param condition - Blokirajući uslov koji se dodaje
10103
+ * @returns Ažurirana tehnologija
10104
+ */
10105
+ async addBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
10106
+ const docRef = doc24(
10107
+ this.getTechnologiesRef(categoryId, subcategoryId),
10108
+ technologyId
10109
+ );
10110
+ await updateDoc25(docRef, {
10111
+ blockingConditions: arrayUnion5(condition),
10112
+ updatedAt: /* @__PURE__ */ new Date()
10113
+ });
10114
+ return this.getById(categoryId, subcategoryId, technologyId);
10115
+ }
10116
+ /**
10117
+ * Uklanja blokirajući uslov iz tehnologije
10118
+ * @param categoryId - ID kategorije
10119
+ * @param subcategoryId - ID podkategorije
10120
+ * @param technologyId - ID tehnologije
10121
+ * @param condition - Blokirajući uslov koji se uklanja
10122
+ * @returns Ažurirana tehnologija
10123
+ */
10124
+ async removeBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
10125
+ const docRef = doc24(
10126
+ this.getTechnologiesRef(categoryId, subcategoryId),
10127
+ technologyId
10128
+ );
10129
+ await updateDoc25(docRef, {
10130
+ blockingConditions: arrayRemove3(condition),
10131
+ updatedAt: /* @__PURE__ */ new Date()
10132
+ });
10133
+ return this.getById(categoryId, subcategoryId, technologyId);
10134
+ }
10135
+ /**
10136
+ * Dodaje kontraindikaciju tehnologiji
10137
+ * @param categoryId - ID kategorije
10138
+ * @param subcategoryId - ID podkategorije
10139
+ * @param technologyId - ID tehnologije
10140
+ * @param contraindication - Kontraindikacija koja se dodaje
10141
+ * @returns Ažurirana tehnologija
10142
+ */
10143
+ async addContraindication(categoryId, subcategoryId, technologyId, contraindication) {
10144
+ const docRef = doc24(
10145
+ this.getTechnologiesRef(categoryId, subcategoryId),
10146
+ technologyId
10147
+ );
10148
+ await updateDoc25(docRef, {
10149
+ contraindications: arrayUnion5(contraindication),
10150
+ updatedAt: /* @__PURE__ */ new Date()
10151
+ });
10152
+ return this.getById(categoryId, subcategoryId, technologyId);
10153
+ }
10154
+ /**
10155
+ * Uklanja kontraindikaciju iz tehnologije
10156
+ * @param categoryId - ID kategorije
10157
+ * @param subcategoryId - ID podkategorije
10158
+ * @param technologyId - ID tehnologije
10159
+ * @param contraindication - Kontraindikacija koja se uklanja
10160
+ * @returns Ažurirana tehnologija
10161
+ */
10162
+ async removeContraindication(categoryId, subcategoryId, technologyId, contraindication) {
10163
+ const docRef = doc24(
10164
+ this.getTechnologiesRef(categoryId, subcategoryId),
10165
+ technologyId
10166
+ );
10167
+ await updateDoc25(docRef, {
10168
+ contraindications: arrayRemove3(contraindication),
10169
+ updatedAt: /* @__PURE__ */ new Date()
10170
+ });
10171
+ return this.getById(categoryId, subcategoryId, technologyId);
10172
+ }
10173
+ /**
10174
+ * Dodaje benefit tehnologiji
10175
+ * @param categoryId - ID kategorije
10176
+ * @param subcategoryId - ID podkategorije
10177
+ * @param technologyId - ID tehnologije
10178
+ * @param benefit - Benefit koji se dodaje
10179
+ * @returns Ažurirana tehnologija
10180
+ */
10181
+ async addBenefit(categoryId, subcategoryId, technologyId, benefit) {
10182
+ const docRef = doc24(
10183
+ this.getTechnologiesRef(categoryId, subcategoryId),
10184
+ technologyId
10185
+ );
10186
+ await updateDoc25(docRef, {
10187
+ benefits: arrayUnion5(benefit),
10188
+ updatedAt: /* @__PURE__ */ new Date()
10189
+ });
10190
+ return this.getById(categoryId, subcategoryId, technologyId);
10191
+ }
10192
+ /**
10193
+ * Uklanja benefit iz tehnologije
10194
+ * @param categoryId - ID kategorije
10195
+ * @param subcategoryId - ID podkategorije
10196
+ * @param technologyId - ID tehnologije
10197
+ * @param benefit - Benefit koji se uklanja
10198
+ * @returns Ažurirana tehnologija
10199
+ */
10200
+ async removeBenefit(categoryId, subcategoryId, technologyId, benefit) {
10201
+ const docRef = doc24(
10202
+ this.getTechnologiesRef(categoryId, subcategoryId),
10203
+ technologyId
10204
+ );
10205
+ await updateDoc25(docRef, {
10206
+ benefits: arrayRemove3(benefit),
10207
+ updatedAt: /* @__PURE__ */ new Date()
10208
+ });
10209
+ return this.getById(categoryId, subcategoryId, technologyId);
10210
+ }
10211
+ /**
10212
+ * Vraća sve blokirajuće uslove za tehnologiju
10213
+ * @param categoryId - ID kategorije
10214
+ * @param subcategoryId - ID podkategorije
10215
+ * @param technologyId - ID tehnologije
10216
+ * @returns Lista blokirajućih uslova
10217
+ */
10218
+ async getBlockingConditions(categoryId, subcategoryId, technologyId) {
10219
+ const technology = await this.getById(
10220
+ categoryId,
10221
+ subcategoryId,
10222
+ technologyId
10223
+ );
10224
+ return (technology == null ? void 0 : technology.blockingConditions) || [];
10225
+ }
10226
+ /**
10227
+ * Vraća sve kontraindikacije za tehnologiju
10228
+ * @param categoryId - ID kategorije
10229
+ * @param subcategoryId - ID podkategorije
10230
+ * @param technologyId - ID tehnologije
10231
+ * @returns Lista kontraindikacija
10232
+ */
10233
+ async getContraindications(categoryId, subcategoryId, technologyId) {
10234
+ const technology = await this.getById(
10235
+ categoryId,
10236
+ subcategoryId,
10237
+ technologyId
10238
+ );
10239
+ return (technology == null ? void 0 : technology.contraindications) || [];
10240
+ }
10241
+ /**
10242
+ * Vraća sve benefite za tehnologiju
10243
+ * @param categoryId - ID kategorije
10244
+ * @param subcategoryId - ID podkategorije
10245
+ * @param technologyId - ID tehnologije
10246
+ * @returns Lista benefita
10247
+ */
10248
+ async getBenefits(categoryId, subcategoryId, technologyId) {
10249
+ const technology = await this.getById(
10250
+ categoryId,
10251
+ subcategoryId,
10252
+ technologyId
10253
+ );
10254
+ return (technology == null ? void 0 : technology.benefits) || [];
10255
+ }
10256
+ /**
10257
+ * Ažurira zahteve sertifikacije za tehnologiju
10258
+ * @param categoryId - ID kategorije
10259
+ * @param subcategoryId - ID podkategorije
10260
+ * @param technologyId - ID tehnologije
10261
+ * @param certificationRequirement - Novi zahtevi sertifikacije
10262
+ * @returns Ažurirana tehnologija
10263
+ */
10264
+ async updateCertificationRequirement(categoryId, subcategoryId, technologyId, certificationRequirement) {
10265
+ const docRef = doc24(
10266
+ this.getTechnologiesRef(categoryId, subcategoryId),
10267
+ technologyId
10268
+ );
10269
+ await updateDoc25(docRef, {
10270
+ certificationRequirement,
10271
+ updatedAt: /* @__PURE__ */ new Date()
10272
+ });
10273
+ return this.getById(categoryId, subcategoryId, technologyId);
10274
+ }
10275
+ /**
10276
+ * Vraća zahteve sertifikacije za tehnologiju
10277
+ * @param categoryId - ID kategorije
10278
+ * @param subcategoryId - ID podkategorije
10279
+ * @param technologyId - ID tehnologije
10280
+ * @returns Zahtevi sertifikacije ili null ako tehnologija ne postoji
10281
+ */
10282
+ async getCertificationRequirement(categoryId, subcategoryId, technologyId) {
10283
+ const technology = await this.getById(
10284
+ categoryId,
10285
+ subcategoryId,
10286
+ technologyId
10287
+ );
10288
+ return (technology == null ? void 0 : technology.certificationRequirement) || null;
10289
+ }
10290
+ };
10291
+
10292
+ // src/backoffice/services/product.service.ts
10293
+ import {
10294
+ addDoc as addDoc8,
10295
+ collection as collection23,
10296
+ collectionGroup,
10297
+ doc as doc25,
10298
+ getDoc as getDoc28,
10299
+ getDocs as getDocs22,
10300
+ query as query22,
10301
+ updateDoc as updateDoc26,
10302
+ where as where22
10303
+ } from "firebase/firestore";
10304
+ var ProductService = class extends BaseService {
10305
+ getProductsRefByTechnology(categoryId, subcategoryId, technologyId) {
10306
+ return collection23(
10307
+ this.db,
10308
+ CATEGORIES_COLLECTION,
10309
+ categoryId,
10310
+ SUBCATEGORIES_COLLECTION,
10311
+ subcategoryId,
10312
+ TECHNOLOGIES_COLLECTION,
10313
+ technologyId,
10314
+ PRODUCTS_COLLECTION
10315
+ );
10316
+ }
10317
+ getProductsRefByBrand(brandId) {
10318
+ return collection23(this.db, BRANDS_COLLECTION, brandId, PRODUCTS_COLLECTION);
10319
+ }
10320
+ async create(categoryId, subcategoryId, technologyId, brandId, product) {
10321
+ const now = /* @__PURE__ */ new Date();
10322
+ const newProduct = {
10323
+ ...product,
10324
+ brandId,
10325
+ technologyId,
10326
+ createdAt: now,
10327
+ updatedAt: now,
10328
+ isActive: true
10329
+ };
10330
+ const techProductRef = await addDoc8(
10331
+ this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
10332
+ newProduct
10333
+ );
10334
+ await addDoc8(this.getProductsRefByBrand(brandId), {
10335
+ ...newProduct,
10336
+ id: techProductRef.id,
10337
+ // Store the original ID for reference
10338
+ categoryId,
10339
+ subcategoryId,
10340
+ technologyId
10341
+ });
10342
+ return { id: techProductRef.id, ...newProduct };
10343
+ }
10344
+ async getAllByTechnology(categoryId, subcategoryId, technologyId) {
10345
+ const q = query22(
10346
+ this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
10347
+ where22("isActive", "==", true)
10348
+ );
10349
+ const snapshot = await getDocs22(q);
10350
+ return snapshot.docs.map(
10351
+ (doc26) => ({
10352
+ id: doc26.id,
10353
+ ...doc26.data()
10354
+ })
10355
+ );
10356
+ }
10357
+ async getAllByBrand(brandId) {
10358
+ const q = query22(
10359
+ this.getProductsRefByBrand(brandId),
10360
+ where22("isActive", "==", true)
10361
+ );
10362
+ const snapshot = await getDocs22(q);
10363
+ return snapshot.docs.map(
10364
+ (doc26) => ({
10365
+ id: doc26.id,
10366
+ ...doc26.data()
10367
+ })
10368
+ );
10369
+ }
10370
+ async update(categoryId, subcategoryId, technologyId, productId, product) {
10371
+ const updateData = {
10372
+ ...product,
10373
+ updatedAt: /* @__PURE__ */ new Date()
10374
+ };
10375
+ const techDocRef = doc25(
10376
+ this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
10377
+ productId
10378
+ );
10379
+ await updateDoc26(techDocRef, updateData);
10380
+ const brandProductsQuery = query22(
10381
+ collectionGroup(this.db, PRODUCTS_COLLECTION),
10382
+ where22("id", "==", productId)
10383
+ );
10384
+ const brandProductsSnapshot = await getDocs22(brandProductsQuery);
10385
+ for (const doc26 of brandProductsSnapshot.docs) {
10386
+ await updateDoc26(doc26.ref, updateData);
10387
+ }
10388
+ return this.getById(categoryId, subcategoryId, technologyId, productId);
10389
+ }
10390
+ async delete(categoryId, subcategoryId, technologyId, productId) {
10391
+ await this.update(categoryId, subcategoryId, technologyId, productId, {
10392
+ isActive: false
10393
+ });
10394
+ }
10395
+ async getById(categoryId, subcategoryId, technologyId, productId) {
10396
+ const docRef = doc25(
10397
+ this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
10398
+ productId
10399
+ );
10400
+ const docSnap = await getDoc28(docRef);
10401
+ if (!docSnap.exists()) return null;
10402
+ return {
10403
+ id: docSnap.id,
10404
+ ...docSnap.data()
10405
+ };
10406
+ }
10407
+ };
10408
+
9609
10409
  // src/validations/notification.schema.ts
9610
10410
  import { z as z19 } from "zod";
9611
10411
  var baseNotificationSchema = z19.object({
@@ -9666,6 +10466,7 @@ export {
9666
10466
  AllergyType,
9667
10467
  AuthService,
9668
10468
  BlockingCondition,
10469
+ BrandService,
9669
10470
  CALENDAR_COLLECTION,
9670
10471
  CLINICS_COLLECTION,
9671
10472
  CLINIC_ADMINS_COLLECTION,
@@ -9674,6 +10475,7 @@ export {
9674
10475
  CalendarEventType,
9675
10476
  CalendarServiceV2,
9676
10477
  CalendarSyncStatus,
10478
+ CategoryService,
9677
10479
  CertificationLevel,
9678
10480
  CertificationSpecialty,
9679
10481
  ClinicAdminService,
@@ -9717,11 +10519,14 @@ export {
9717
10519
  PricingMeasure,
9718
10520
  ProcedureFamily,
9719
10521
  ProcedureService,
10522
+ ProductService,
9720
10523
  REGISTER_TOKENS_COLLECTION,
9721
10524
  SYNCED_CALENDARS_COLLECTION,
10525
+ SubcategoryService,
9722
10526
  SubscriptionModel,
9723
10527
  SyncedCalendarProvider,
9724
10528
  SyncedCalendarsService,
10529
+ TechnologyService,
9725
10530
  TreatmentBenefit,
9726
10531
  USER_ERRORS,
9727
10532
  UserService,