@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/backoffice/index.js +2 -6
- package/dist/backoffice/index.mjs +2 -6
- package/dist/index.d.mts +398 -4
- package/dist/index.d.ts +398 -4
- package/dist/index.js +853 -91
- package/dist/index.mjs +896 -91
- package/package.json +1 -1
- package/src/index.ts +79 -59
- package/src/types/index.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
AllergyType: () => AllergyType,
|
|
26
26
|
AuthService: () => AuthService,
|
|
27
27
|
BlockingCondition: () => BlockingCondition,
|
|
28
|
+
BrandService: () => BrandService,
|
|
28
29
|
CALENDAR_COLLECTION: () => CALENDAR_COLLECTION,
|
|
29
30
|
CLINICS_COLLECTION: () => CLINICS_COLLECTION,
|
|
30
31
|
CLINIC_ADMINS_COLLECTION: () => CLINIC_ADMINS_COLLECTION,
|
|
@@ -33,6 +34,7 @@ __export(index_exports, {
|
|
|
33
34
|
CalendarEventType: () => CalendarEventType,
|
|
34
35
|
CalendarServiceV2: () => CalendarServiceV2,
|
|
35
36
|
CalendarSyncStatus: () => CalendarSyncStatus,
|
|
37
|
+
CategoryService: () => CategoryService,
|
|
36
38
|
CertificationLevel: () => CertificationLevel,
|
|
37
39
|
CertificationSpecialty: () => CertificationSpecialty,
|
|
38
40
|
ClinicAdminService: () => ClinicAdminService,
|
|
@@ -76,11 +78,14 @@ __export(index_exports, {
|
|
|
76
78
|
PricingMeasure: () => PricingMeasure,
|
|
77
79
|
ProcedureFamily: () => ProcedureFamily,
|
|
78
80
|
ProcedureService: () => ProcedureService,
|
|
81
|
+
ProductService: () => ProductService,
|
|
79
82
|
REGISTER_TOKENS_COLLECTION: () => REGISTER_TOKENS_COLLECTION,
|
|
80
83
|
SYNCED_CALENDARS_COLLECTION: () => SYNCED_CALENDARS_COLLECTION,
|
|
84
|
+
SubcategoryService: () => SubcategoryService,
|
|
81
85
|
SubscriptionModel: () => SubscriptionModel,
|
|
82
86
|
SyncedCalendarProvider: () => SyncedCalendarProvider,
|
|
83
87
|
SyncedCalendarsService: () => SyncedCalendarsService,
|
|
88
|
+
TechnologyService: () => TechnologyService,
|
|
84
89
|
TreatmentBenefit: () => TreatmentBenefit,
|
|
85
90
|
USER_ERRORS: () => USER_ERRORS,
|
|
86
91
|
UserService: () => UserService,
|
|
@@ -236,6 +241,8 @@ var import_auth5 = require("firebase/auth");
|
|
|
236
241
|
var import_firestore19 = require("firebase/firestore");
|
|
237
242
|
|
|
238
243
|
// src/types/documentation-templates/index.ts
|
|
244
|
+
var DOCUMENTATION_TEMPLATES_COLLECTION = "documentation-templates";
|
|
245
|
+
var FILLED_DOCUMENTS_COLLECTION = "filled-documents";
|
|
239
246
|
var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
|
|
240
247
|
DocumentElementType2["HEADING"] = "heading";
|
|
241
248
|
DocumentElementType2["PARAGRAPH"] = "paragraph";
|
|
@@ -315,8 +322,6 @@ var UserRole = /* @__PURE__ */ ((UserRole2) => {
|
|
|
315
322
|
return UserRole2;
|
|
316
323
|
})(UserRole || {});
|
|
317
324
|
var USERS_COLLECTION = "users";
|
|
318
|
-
var DOCUMENTATION_TEMPLATES_COLLECTION = "documentation-templates";
|
|
319
|
-
var FILLED_DOCUMENTS_COLLECTION = "filled-documents";
|
|
320
325
|
|
|
321
326
|
// src/services/auth.service.ts
|
|
322
327
|
var import_zod15 = require("zod");
|
|
@@ -1434,9 +1439,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
1434
1439
|
var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
1435
1440
|
const validatedData = updateAllergySchema.parse(data);
|
|
1436
1441
|
const { allergyIndex, ...updateData } = validatedData;
|
|
1437
|
-
const
|
|
1438
|
-
if (!
|
|
1439
|
-
const medicalInfo =
|
|
1442
|
+
const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1443
|
+
if (!doc26.exists()) throw new Error("Medical info not found");
|
|
1444
|
+
const medicalInfo = doc26.data();
|
|
1440
1445
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
1441
1446
|
throw new Error("Invalid allergy index");
|
|
1442
1447
|
}
|
|
@@ -1452,9 +1457,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
1452
1457
|
});
|
|
1453
1458
|
};
|
|
1454
1459
|
var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
|
|
1455
|
-
const
|
|
1456
|
-
if (!
|
|
1457
|
-
const medicalInfo =
|
|
1460
|
+
const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1461
|
+
if (!doc26.exists()) throw new Error("Medical info not found");
|
|
1462
|
+
const medicalInfo = doc26.data();
|
|
1458
1463
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
1459
1464
|
throw new Error("Invalid allergy index");
|
|
1460
1465
|
}
|
|
@@ -1479,9 +1484,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
1479
1484
|
var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
1480
1485
|
const validatedData = updateBlockingConditionSchema.parse(data);
|
|
1481
1486
|
const { conditionIndex, ...updateData } = validatedData;
|
|
1482
|
-
const
|
|
1483
|
-
if (!
|
|
1484
|
-
const medicalInfo =
|
|
1487
|
+
const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1488
|
+
if (!doc26.exists()) throw new Error("Medical info not found");
|
|
1489
|
+
const medicalInfo = doc26.data();
|
|
1485
1490
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
1486
1491
|
throw new Error("Invalid blocking condition index");
|
|
1487
1492
|
}
|
|
@@ -1497,9 +1502,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
1497
1502
|
});
|
|
1498
1503
|
};
|
|
1499
1504
|
var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
|
|
1500
|
-
const
|
|
1501
|
-
if (!
|
|
1502
|
-
const medicalInfo =
|
|
1505
|
+
const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1506
|
+
if (!doc26.exists()) throw new Error("Medical info not found");
|
|
1507
|
+
const medicalInfo = doc26.data();
|
|
1503
1508
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
1504
1509
|
throw new Error("Invalid blocking condition index");
|
|
1505
1510
|
}
|
|
@@ -1524,9 +1529,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1524
1529
|
var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
1525
1530
|
const validatedData = updateContraindicationSchema.parse(data);
|
|
1526
1531
|
const { contraindicationIndex, ...updateData } = validatedData;
|
|
1527
|
-
const
|
|
1528
|
-
if (!
|
|
1529
|
-
const medicalInfo =
|
|
1532
|
+
const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1533
|
+
if (!doc26.exists()) throw new Error("Medical info not found");
|
|
1534
|
+
const medicalInfo = doc26.data();
|
|
1530
1535
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
1531
1536
|
throw new Error("Invalid contraindication index");
|
|
1532
1537
|
}
|
|
@@ -1542,9 +1547,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1542
1547
|
});
|
|
1543
1548
|
};
|
|
1544
1549
|
var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
|
|
1545
|
-
const
|
|
1546
|
-
if (!
|
|
1547
|
-
const medicalInfo =
|
|
1550
|
+
const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1551
|
+
if (!doc26.exists()) throw new Error("Medical info not found");
|
|
1552
|
+
const medicalInfo = doc26.data();
|
|
1548
1553
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
1549
1554
|
throw new Error("Invalid contraindication index");
|
|
1550
1555
|
}
|
|
@@ -1569,9 +1574,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1569
1574
|
var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
1570
1575
|
const validatedData = updateMedicationSchema.parse(data);
|
|
1571
1576
|
const { medicationIndex, ...updateData } = validatedData;
|
|
1572
|
-
const
|
|
1573
|
-
if (!
|
|
1574
|
-
const medicalInfo =
|
|
1577
|
+
const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1578
|
+
if (!doc26.exists()) throw new Error("Medical info not found");
|
|
1579
|
+
const medicalInfo = doc26.data();
|
|
1575
1580
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
1576
1581
|
throw new Error("Invalid medication index");
|
|
1577
1582
|
}
|
|
@@ -1587,9 +1592,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1587
1592
|
});
|
|
1588
1593
|
};
|
|
1589
1594
|
var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
|
|
1590
|
-
const
|
|
1591
|
-
if (!
|
|
1592
|
-
const medicalInfo =
|
|
1595
|
+
const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1596
|
+
if (!doc26.exists()) throw new Error("Medical info not found");
|
|
1597
|
+
const medicalInfo = doc26.data();
|
|
1593
1598
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
1594
1599
|
throw new Error("Invalid medication index");
|
|
1595
1600
|
}
|
|
@@ -2883,7 +2888,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
|
|
|
2883
2888
|
(0, import_firestore11.where)("clinicGroupId", "==", clinicGroupId)
|
|
2884
2889
|
);
|
|
2885
2890
|
const querySnapshot = await (0, import_firestore11.getDocs)(q);
|
|
2886
|
-
return querySnapshot.docs.map((
|
|
2891
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
2887
2892
|
}
|
|
2888
2893
|
async function updateClinicAdmin(db, adminId, data) {
|
|
2889
2894
|
const admin = await getClinicAdmin(db, adminId);
|
|
@@ -3181,16 +3186,16 @@ var CertificationLevel = /* @__PURE__ */ ((CertificationLevel2) => {
|
|
|
3181
3186
|
CertificationLevel2["PLASTIC_SURGEON"] = "plastic_surgeon";
|
|
3182
3187
|
return CertificationLevel2;
|
|
3183
3188
|
})(CertificationLevel || {});
|
|
3184
|
-
var CertificationSpecialty = /* @__PURE__ */ ((
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
return
|
|
3189
|
+
var CertificationSpecialty = /* @__PURE__ */ ((CertificationSpecialty3) => {
|
|
3190
|
+
CertificationSpecialty3["LASER"] = "laser";
|
|
3191
|
+
CertificationSpecialty3["INJECTABLES"] = "injectables";
|
|
3192
|
+
CertificationSpecialty3["CHEMICAL_PEELS"] = "chemical_peels";
|
|
3193
|
+
CertificationSpecialty3["MICRODERMABRASION"] = "microdermabrasion";
|
|
3194
|
+
CertificationSpecialty3["BODY_CONTOURING"] = "body_contouring";
|
|
3195
|
+
CertificationSpecialty3["SKIN_CARE"] = "skin_care";
|
|
3196
|
+
CertificationSpecialty3["WOUND_CARE"] = "wound_care";
|
|
3197
|
+
CertificationSpecialty3["ANESTHESIA"] = "anesthesia";
|
|
3198
|
+
return CertificationSpecialty3;
|
|
3194
3199
|
})(CertificationSpecialty || {});
|
|
3195
3200
|
|
|
3196
3201
|
// src/validations/practitioner.schema.ts
|
|
@@ -3538,7 +3543,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3538
3543
|
(0, import_firestore13.where)("expiresAt", ">", import_firestore13.Timestamp.now())
|
|
3539
3544
|
);
|
|
3540
3545
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3541
|
-
return querySnapshot.docs.map((
|
|
3546
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
3542
3547
|
}
|
|
3543
3548
|
/**
|
|
3544
3549
|
* Gets a token by its string value and validates it
|
|
@@ -3621,7 +3626,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3621
3626
|
(0, import_firestore13.where)("status", "==", "active" /* ACTIVE */)
|
|
3622
3627
|
);
|
|
3623
3628
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3624
|
-
return querySnapshot.docs.map((
|
|
3629
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
3625
3630
|
}
|
|
3626
3631
|
/**
|
|
3627
3632
|
* Dohvata sve draft zdravstvene radnike za određenu kliniku
|
|
@@ -3633,7 +3638,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3633
3638
|
(0, import_firestore13.where)("status", "==", "draft" /* DRAFT */)
|
|
3634
3639
|
);
|
|
3635
3640
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3636
|
-
return querySnapshot.docs.map((
|
|
3641
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
3637
3642
|
}
|
|
3638
3643
|
/**
|
|
3639
3644
|
* Ažurira profil zdravstvenog radnika
|
|
@@ -3942,7 +3947,7 @@ var UserService = class extends BaseService {
|
|
|
3942
3947
|
];
|
|
3943
3948
|
const q = (0, import_firestore14.query)((0, import_firestore14.collection)(this.db, USERS_COLLECTION), ...constraints);
|
|
3944
3949
|
const querySnapshot = await (0, import_firestore14.getDocs)(q);
|
|
3945
|
-
const users = querySnapshot.docs.map((
|
|
3950
|
+
const users = querySnapshot.docs.map((doc26) => doc26.data());
|
|
3946
3951
|
return Promise.all(users.map((userData) => userSchema.parse(userData)));
|
|
3947
3952
|
}
|
|
3948
3953
|
/**
|
|
@@ -4306,7 +4311,7 @@ async function getAllActiveGroups(db) {
|
|
|
4306
4311
|
(0, import_firestore15.where)("isActive", "==", true)
|
|
4307
4312
|
);
|
|
4308
4313
|
const querySnapshot = await (0, import_firestore15.getDocs)(q);
|
|
4309
|
-
return querySnapshot.docs.map((
|
|
4314
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
4310
4315
|
}
|
|
4311
4316
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
4312
4317
|
console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
|
|
@@ -4966,7 +4971,7 @@ async function getClinicsByGroup(db, groupId) {
|
|
|
4966
4971
|
(0, import_firestore16.where)("isActive", "==", true)
|
|
4967
4972
|
);
|
|
4968
4973
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
4969
|
-
return querySnapshot.docs.map((
|
|
4974
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
4970
4975
|
}
|
|
4971
4976
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
4972
4977
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -5178,7 +5183,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
5178
5183
|
}
|
|
5179
5184
|
const q = (0, import_firestore16.query)((0, import_firestore16.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5180
5185
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
5181
|
-
return querySnapshot.docs.map((
|
|
5186
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
5182
5187
|
}
|
|
5183
5188
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
5184
5189
|
return getClinicsByAdmin(
|
|
@@ -5320,8 +5325,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
5320
5325
|
}
|
|
5321
5326
|
const q = (0, import_firestore18.query)((0, import_firestore18.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5322
5327
|
const querySnapshot = await (0, import_firestore18.getDocs)(q);
|
|
5323
|
-
for (const
|
|
5324
|
-
const clinic =
|
|
5328
|
+
for (const doc26 of querySnapshot.docs) {
|
|
5329
|
+
const clinic = doc26.data();
|
|
5325
5330
|
const distance = (0, import_geofire_common4.distanceBetween)(
|
|
5326
5331
|
[center.latitude, center.longitude],
|
|
5327
5332
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -6253,9 +6258,9 @@ var NotificationService = class extends BaseService {
|
|
|
6253
6258
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6254
6259
|
);
|
|
6255
6260
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6256
|
-
return querySnapshot.docs.map((
|
|
6257
|
-
id:
|
|
6258
|
-
...
|
|
6261
|
+
return querySnapshot.docs.map((doc26) => ({
|
|
6262
|
+
id: doc26.id,
|
|
6263
|
+
...doc26.data()
|
|
6259
6264
|
}));
|
|
6260
6265
|
}
|
|
6261
6266
|
/**
|
|
@@ -6269,9 +6274,9 @@ var NotificationService = class extends BaseService {
|
|
|
6269
6274
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6270
6275
|
);
|
|
6271
6276
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6272
|
-
return querySnapshot.docs.map((
|
|
6273
|
-
id:
|
|
6274
|
-
...
|
|
6277
|
+
return querySnapshot.docs.map((doc26) => ({
|
|
6278
|
+
id: doc26.id,
|
|
6279
|
+
...doc26.data()
|
|
6275
6280
|
}));
|
|
6276
6281
|
}
|
|
6277
6282
|
/**
|
|
@@ -6343,9 +6348,9 @@ var NotificationService = class extends BaseService {
|
|
|
6343
6348
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6344
6349
|
);
|
|
6345
6350
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6346
|
-
return querySnapshot.docs.map((
|
|
6347
|
-
id:
|
|
6348
|
-
...
|
|
6351
|
+
return querySnapshot.docs.map((doc26) => ({
|
|
6352
|
+
id: doc26.id,
|
|
6353
|
+
...doc26.data()
|
|
6349
6354
|
}));
|
|
6350
6355
|
}
|
|
6351
6356
|
/**
|
|
@@ -6358,9 +6363,9 @@ var NotificationService = class extends BaseService {
|
|
|
6358
6363
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6359
6364
|
);
|
|
6360
6365
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6361
|
-
return querySnapshot.docs.map((
|
|
6362
|
-
id:
|
|
6363
|
-
...
|
|
6366
|
+
return querySnapshot.docs.map((doc26) => ({
|
|
6367
|
+
id: doc26.id,
|
|
6368
|
+
...doc26.data()
|
|
6364
6369
|
}));
|
|
6365
6370
|
}
|
|
6366
6371
|
};
|
|
@@ -6510,7 +6515,7 @@ var ProcedureService = class extends BaseService {
|
|
|
6510
6515
|
(0, import_firestore21.where)("isActive", "==", true)
|
|
6511
6516
|
);
|
|
6512
6517
|
const snapshot = await (0, import_firestore21.getDocs)(q);
|
|
6513
|
-
return snapshot.docs.map((
|
|
6518
|
+
return snapshot.docs.map((doc26) => doc26.data());
|
|
6514
6519
|
}
|
|
6515
6520
|
/**
|
|
6516
6521
|
* Gets all procedures for a practitioner
|
|
@@ -6524,7 +6529,7 @@ var ProcedureService = class extends BaseService {
|
|
|
6524
6529
|
(0, import_firestore21.where)("isActive", "==", true)
|
|
6525
6530
|
);
|
|
6526
6531
|
const snapshot = await (0, import_firestore21.getDocs)(q);
|
|
6527
|
-
return snapshot.docs.map((
|
|
6532
|
+
return snapshot.docs.map((doc26) => doc26.data());
|
|
6528
6533
|
}
|
|
6529
6534
|
/**
|
|
6530
6535
|
* Updates a procedure
|
|
@@ -6710,9 +6715,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6710
6715
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6711
6716
|
const templates = [];
|
|
6712
6717
|
let lastVisible = null;
|
|
6713
|
-
querySnapshot.forEach((
|
|
6714
|
-
templates.push(
|
|
6715
|
-
lastVisible =
|
|
6718
|
+
querySnapshot.forEach((doc26) => {
|
|
6719
|
+
templates.push(doc26.data());
|
|
6720
|
+
lastVisible = doc26;
|
|
6716
6721
|
});
|
|
6717
6722
|
return {
|
|
6718
6723
|
templates,
|
|
@@ -6740,9 +6745,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6740
6745
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6741
6746
|
const templates = [];
|
|
6742
6747
|
let lastVisible = null;
|
|
6743
|
-
querySnapshot.forEach((
|
|
6744
|
-
templates.push(
|
|
6745
|
-
lastVisible =
|
|
6748
|
+
querySnapshot.forEach((doc26) => {
|
|
6749
|
+
templates.push(doc26.data());
|
|
6750
|
+
lastVisible = doc26;
|
|
6746
6751
|
});
|
|
6747
6752
|
return {
|
|
6748
6753
|
templates,
|
|
@@ -6769,9 +6774,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6769
6774
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6770
6775
|
const templates = [];
|
|
6771
6776
|
let lastVisible = null;
|
|
6772
|
-
querySnapshot.forEach((
|
|
6773
|
-
templates.push(
|
|
6774
|
-
lastVisible =
|
|
6777
|
+
querySnapshot.forEach((doc26) => {
|
|
6778
|
+
templates.push(doc26.data());
|
|
6779
|
+
lastVisible = doc26;
|
|
6775
6780
|
});
|
|
6776
6781
|
return {
|
|
6777
6782
|
templates,
|
|
@@ -6884,9 +6889,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
6884
6889
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6885
6890
|
const documents = [];
|
|
6886
6891
|
let lastVisible = null;
|
|
6887
|
-
querySnapshot.forEach((
|
|
6888
|
-
documents.push(
|
|
6889
|
-
lastVisible =
|
|
6892
|
+
querySnapshot.forEach((doc26) => {
|
|
6893
|
+
documents.push(doc26.data());
|
|
6894
|
+
lastVisible = doc26;
|
|
6890
6895
|
});
|
|
6891
6896
|
return {
|
|
6892
6897
|
documents,
|
|
@@ -6913,9 +6918,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
6913
6918
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6914
6919
|
const documents = [];
|
|
6915
6920
|
let lastVisible = null;
|
|
6916
|
-
querySnapshot.forEach((
|
|
6917
|
-
documents.push(
|
|
6918
|
-
lastVisible =
|
|
6921
|
+
querySnapshot.forEach((doc26) => {
|
|
6922
|
+
documents.push(doc26.data());
|
|
6923
|
+
lastVisible = doc26;
|
|
6919
6924
|
});
|
|
6920
6925
|
return {
|
|
6921
6926
|
documents,
|
|
@@ -6942,9 +6947,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
6942
6947
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6943
6948
|
const documents = [];
|
|
6944
6949
|
let lastVisible = null;
|
|
6945
|
-
querySnapshot.forEach((
|
|
6946
|
-
documents.push(
|
|
6947
|
-
lastVisible =
|
|
6950
|
+
querySnapshot.forEach((doc26) => {
|
|
6951
|
+
documents.push(doc26.data());
|
|
6952
|
+
lastVisible = doc26;
|
|
6948
6953
|
});
|
|
6949
6954
|
return {
|
|
6950
6955
|
documents,
|
|
@@ -6971,9 +6976,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
6971
6976
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6972
6977
|
const documents = [];
|
|
6973
6978
|
let lastVisible = null;
|
|
6974
|
-
querySnapshot.forEach((
|
|
6975
|
-
documents.push(
|
|
6976
|
-
lastVisible =
|
|
6979
|
+
querySnapshot.forEach((doc26) => {
|
|
6980
|
+
documents.push(doc26.data());
|
|
6981
|
+
lastVisible = doc26;
|
|
6977
6982
|
});
|
|
6978
6983
|
return {
|
|
6979
6984
|
documents,
|
|
@@ -7000,9 +7005,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7000
7005
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7001
7006
|
const documents = [];
|
|
7002
7007
|
let lastVisible = null;
|
|
7003
|
-
querySnapshot.forEach((
|
|
7004
|
-
documents.push(
|
|
7005
|
-
lastVisible =
|
|
7008
|
+
querySnapshot.forEach((doc26) => {
|
|
7009
|
+
documents.push(doc26.data());
|
|
7010
|
+
lastVisible = doc26;
|
|
7006
7011
|
});
|
|
7007
7012
|
return {
|
|
7008
7013
|
documents,
|
|
@@ -7505,7 +7510,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
7505
7510
|
);
|
|
7506
7511
|
const q = (0, import_firestore30.query)(calendarsRef, (0, import_firestore30.orderBy)("createdAt", "desc"));
|
|
7507
7512
|
const querySnapshot = await (0, import_firestore30.getDocs)(q);
|
|
7508
|
-
return querySnapshot.docs.map((
|
|
7513
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
7509
7514
|
}
|
|
7510
7515
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
7511
7516
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
@@ -7522,7 +7527,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
7522
7527
|
);
|
|
7523
7528
|
const q = (0, import_firestore30.query)(calendarsRef, (0, import_firestore30.orderBy)("createdAt", "desc"));
|
|
7524
7529
|
const querySnapshot = await (0, import_firestore30.getDocs)(q);
|
|
7525
|
-
return querySnapshot.docs.map((
|
|
7530
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
7526
7531
|
}
|
|
7527
7532
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
7528
7533
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
@@ -7539,7 +7544,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
7539
7544
|
);
|
|
7540
7545
|
const q = (0, import_firestore30.query)(calendarsRef, (0, import_firestore30.orderBy)("createdAt", "desc"));
|
|
7541
7546
|
const querySnapshot = await (0, import_firestore30.getDocs)(q);
|
|
7542
|
-
return querySnapshot.docs.map((
|
|
7547
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
7543
7548
|
}
|
|
7544
7549
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
7545
7550
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -8894,9 +8899,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
8894
8899
|
(0, import_firestore33.where)("eventTime.start", "<=", import_firestore32.Timestamp.fromDate(endDate))
|
|
8895
8900
|
);
|
|
8896
8901
|
const eventsSnapshot = await (0, import_firestore33.getDocs)(q);
|
|
8897
|
-
const events = eventsSnapshot.docs.map((
|
|
8898
|
-
id:
|
|
8899
|
-
...
|
|
8902
|
+
const events = eventsSnapshot.docs.map((doc26) => ({
|
|
8903
|
+
id: doc26.id,
|
|
8904
|
+
...doc26.data()
|
|
8900
8905
|
}));
|
|
8901
8906
|
const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
|
|
8902
8907
|
doctorId
|
|
@@ -9429,7 +9434,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9429
9434
|
])
|
|
9430
9435
|
);
|
|
9431
9436
|
const querySnapshot = await (0, import_firestore33.getDocs)(q);
|
|
9432
|
-
return querySnapshot.docs.map((
|
|
9437
|
+
return querySnapshot.docs.map((doc26) => doc26.data());
|
|
9433
9438
|
}
|
|
9434
9439
|
/**
|
|
9435
9440
|
* Calculates available time slots based on working hours, schedule and existing appointments
|
|
@@ -9553,6 +9558,758 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9553
9558
|
// #endregion
|
|
9554
9559
|
};
|
|
9555
9560
|
|
|
9561
|
+
// src/backoffice/services/brand.service.ts
|
|
9562
|
+
var import_firestore34 = require("firebase/firestore");
|
|
9563
|
+
|
|
9564
|
+
// src/backoffice/types/brand.types.ts
|
|
9565
|
+
var BRANDS_COLLECTION = "brands";
|
|
9566
|
+
|
|
9567
|
+
// src/backoffice/services/brand.service.ts
|
|
9568
|
+
var BrandService = class extends BaseService {
|
|
9569
|
+
get brandsRef() {
|
|
9570
|
+
return (0, import_firestore34.collection)(this.db, BRANDS_COLLECTION);
|
|
9571
|
+
}
|
|
9572
|
+
async create(brand) {
|
|
9573
|
+
const now = /* @__PURE__ */ new Date();
|
|
9574
|
+
const newBrand = {
|
|
9575
|
+
...brand,
|
|
9576
|
+
createdAt: now,
|
|
9577
|
+
updatedAt: now,
|
|
9578
|
+
isActive: true
|
|
9579
|
+
};
|
|
9580
|
+
const docRef = await (0, import_firestore34.addDoc)(this.brandsRef, newBrand);
|
|
9581
|
+
return { id: docRef.id, ...newBrand };
|
|
9582
|
+
}
|
|
9583
|
+
async getAll() {
|
|
9584
|
+
const q = (0, import_firestore34.query)(this.brandsRef, (0, import_firestore34.where)("isActive", "==", true));
|
|
9585
|
+
const snapshot = await (0, import_firestore34.getDocs)(q);
|
|
9586
|
+
return snapshot.docs.map(
|
|
9587
|
+
(doc26) => ({
|
|
9588
|
+
id: doc26.id,
|
|
9589
|
+
...doc26.data()
|
|
9590
|
+
})
|
|
9591
|
+
);
|
|
9592
|
+
}
|
|
9593
|
+
async update(id, brand) {
|
|
9594
|
+
const updateData = {
|
|
9595
|
+
...brand,
|
|
9596
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
9597
|
+
};
|
|
9598
|
+
const docRef = (0, import_firestore34.doc)(this.brandsRef, id);
|
|
9599
|
+
await (0, import_firestore34.updateDoc)(docRef, updateData);
|
|
9600
|
+
return this.getById(id);
|
|
9601
|
+
}
|
|
9602
|
+
async delete(id) {
|
|
9603
|
+
await this.update(id, { isActive: false });
|
|
9604
|
+
}
|
|
9605
|
+
async getById(id) {
|
|
9606
|
+
const docRef = (0, import_firestore34.doc)(this.brandsRef, id);
|
|
9607
|
+
const docSnap = await (0, import_firestore34.getDoc)(docRef);
|
|
9608
|
+
if (!docSnap.exists()) return null;
|
|
9609
|
+
return {
|
|
9610
|
+
id: docSnap.id,
|
|
9611
|
+
...docSnap.data()
|
|
9612
|
+
};
|
|
9613
|
+
}
|
|
9614
|
+
};
|
|
9615
|
+
|
|
9616
|
+
// src/backoffice/services/category.service.ts
|
|
9617
|
+
var import_firestore35 = require("firebase/firestore");
|
|
9618
|
+
var CategoryService = class extends BaseService {
|
|
9619
|
+
/**
|
|
9620
|
+
* Referenca na Firestore kolekciju kategorija
|
|
9621
|
+
*/
|
|
9622
|
+
get categoriesRef() {
|
|
9623
|
+
return (0, import_firestore35.collection)(this.db, CATEGORIES_COLLECTION);
|
|
9624
|
+
}
|
|
9625
|
+
/**
|
|
9626
|
+
* Kreira novu kategoriju u sistemu
|
|
9627
|
+
* @param category - Podaci za novu kategoriju
|
|
9628
|
+
* @returns Kreirana kategorija sa generisanim ID-em
|
|
9629
|
+
*/
|
|
9630
|
+
async create(category) {
|
|
9631
|
+
const now = /* @__PURE__ */ new Date();
|
|
9632
|
+
const newCategory = {
|
|
9633
|
+
...category,
|
|
9634
|
+
createdAt: now,
|
|
9635
|
+
updatedAt: now,
|
|
9636
|
+
isActive: true
|
|
9637
|
+
};
|
|
9638
|
+
const docRef = await (0, import_firestore35.addDoc)(this.categoriesRef, newCategory);
|
|
9639
|
+
return { id: docRef.id, ...newCategory };
|
|
9640
|
+
}
|
|
9641
|
+
/**
|
|
9642
|
+
* Vraća sve aktivne kategorije
|
|
9643
|
+
* @returns Lista aktivnih kategorija
|
|
9644
|
+
*/
|
|
9645
|
+
async getAll() {
|
|
9646
|
+
const q = (0, import_firestore35.query)(this.categoriesRef, (0, import_firestore35.where)("isActive", "==", true));
|
|
9647
|
+
const snapshot = await (0, import_firestore35.getDocs)(q);
|
|
9648
|
+
return snapshot.docs.map(
|
|
9649
|
+
(doc26) => ({
|
|
9650
|
+
id: doc26.id,
|
|
9651
|
+
...doc26.data()
|
|
9652
|
+
})
|
|
9653
|
+
);
|
|
9654
|
+
}
|
|
9655
|
+
/**
|
|
9656
|
+
* Vraća sve aktivne kategorije za određenu familiju procedura
|
|
9657
|
+
* @param family - Familija procedura (aesthetics/surgery)
|
|
9658
|
+
* @returns Lista kategorija koje pripadaju traženoj familiji
|
|
9659
|
+
*/
|
|
9660
|
+
async getAllByFamily(family) {
|
|
9661
|
+
const q = (0, import_firestore35.query)(
|
|
9662
|
+
this.categoriesRef,
|
|
9663
|
+
(0, import_firestore35.where)("family", "==", family),
|
|
9664
|
+
(0, import_firestore35.where)("isActive", "==", true)
|
|
9665
|
+
);
|
|
9666
|
+
const snapshot = await (0, import_firestore35.getDocs)(q);
|
|
9667
|
+
return snapshot.docs.map(
|
|
9668
|
+
(doc26) => ({
|
|
9669
|
+
id: doc26.id,
|
|
9670
|
+
...doc26.data()
|
|
9671
|
+
})
|
|
9672
|
+
);
|
|
9673
|
+
}
|
|
9674
|
+
/**
|
|
9675
|
+
* Ažurira postojeću kategoriju
|
|
9676
|
+
* @param id - ID kategorije koja se ažurira
|
|
9677
|
+
* @param category - Novi podaci za kategoriju
|
|
9678
|
+
* @returns Ažurirana kategorija
|
|
9679
|
+
*/
|
|
9680
|
+
async update(id, category) {
|
|
9681
|
+
const updateData = {
|
|
9682
|
+
...category,
|
|
9683
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
9684
|
+
};
|
|
9685
|
+
const docRef = (0, import_firestore35.doc)(this.categoriesRef, id);
|
|
9686
|
+
await (0, import_firestore35.updateDoc)(docRef, updateData);
|
|
9687
|
+
return this.getById(id);
|
|
9688
|
+
}
|
|
9689
|
+
/**
|
|
9690
|
+
* Soft delete kategorije (postavlja isActive na false)
|
|
9691
|
+
* @param id - ID kategorije koja se briše
|
|
9692
|
+
*/
|
|
9693
|
+
async delete(id) {
|
|
9694
|
+
await this.update(id, { isActive: false });
|
|
9695
|
+
}
|
|
9696
|
+
/**
|
|
9697
|
+
* Vraća kategoriju po ID-u
|
|
9698
|
+
* @param id - ID tražene kategorije
|
|
9699
|
+
* @returns Kategorija ili null ako ne postoji
|
|
9700
|
+
*/
|
|
9701
|
+
async getById(id) {
|
|
9702
|
+
const docRef = (0, import_firestore35.doc)(this.categoriesRef, id);
|
|
9703
|
+
const docSnap = await (0, import_firestore35.getDoc)(docRef);
|
|
9704
|
+
if (!docSnap.exists()) return null;
|
|
9705
|
+
return {
|
|
9706
|
+
id: docSnap.id,
|
|
9707
|
+
...docSnap.data()
|
|
9708
|
+
};
|
|
9709
|
+
}
|
|
9710
|
+
};
|
|
9711
|
+
|
|
9712
|
+
// src/backoffice/services/subcategory.service.ts
|
|
9713
|
+
var import_firestore36 = require("firebase/firestore");
|
|
9714
|
+
var SubcategoryService = class extends BaseService {
|
|
9715
|
+
/**
|
|
9716
|
+
* Vraća referencu na Firestore kolekciju podkategorija za određenu kategoriju
|
|
9717
|
+
* @param categoryId - ID roditeljske kategorije
|
|
9718
|
+
*/
|
|
9719
|
+
getSubcategoriesRef(categoryId) {
|
|
9720
|
+
return (0, import_firestore36.collection)(
|
|
9721
|
+
this.db,
|
|
9722
|
+
CATEGORIES_COLLECTION,
|
|
9723
|
+
categoryId,
|
|
9724
|
+
SUBCATEGORIES_COLLECTION
|
|
9725
|
+
);
|
|
9726
|
+
}
|
|
9727
|
+
/**
|
|
9728
|
+
* Kreira novu podkategoriju u okviru kategorije
|
|
9729
|
+
* @param categoryId - ID kategorije kojoj će pripadati nova podkategorija
|
|
9730
|
+
* @param subcategory - Podaci za novu podkategoriju
|
|
9731
|
+
* @returns Kreirana podkategorija sa generisanim ID-em
|
|
9732
|
+
*/
|
|
9733
|
+
async create(categoryId, subcategory) {
|
|
9734
|
+
const now = /* @__PURE__ */ new Date();
|
|
9735
|
+
const newSubcategory = {
|
|
9736
|
+
...subcategory,
|
|
9737
|
+
categoryId,
|
|
9738
|
+
createdAt: now,
|
|
9739
|
+
updatedAt: now,
|
|
9740
|
+
isActive: true
|
|
9741
|
+
};
|
|
9742
|
+
const docRef = await (0, import_firestore36.addDoc)(
|
|
9743
|
+
this.getSubcategoriesRef(categoryId),
|
|
9744
|
+
newSubcategory
|
|
9745
|
+
);
|
|
9746
|
+
return { id: docRef.id, ...newSubcategory };
|
|
9747
|
+
}
|
|
9748
|
+
/**
|
|
9749
|
+
* Vraća sve aktivne podkategorije za određenu kategoriju
|
|
9750
|
+
* @param categoryId - ID kategorije čije podkategorije tražimo
|
|
9751
|
+
* @returns Lista aktivnih podkategorija
|
|
9752
|
+
*/
|
|
9753
|
+
async getAllByCategoryId(categoryId) {
|
|
9754
|
+
const q = (0, import_firestore36.query)(
|
|
9755
|
+
this.getSubcategoriesRef(categoryId),
|
|
9756
|
+
(0, import_firestore36.where)("isActive", "==", true)
|
|
9757
|
+
);
|
|
9758
|
+
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
9759
|
+
return snapshot.docs.map(
|
|
9760
|
+
(doc26) => ({
|
|
9761
|
+
id: doc26.id,
|
|
9762
|
+
...doc26.data()
|
|
9763
|
+
})
|
|
9764
|
+
);
|
|
9765
|
+
}
|
|
9766
|
+
/**
|
|
9767
|
+
* Ažurira postojeću podkategoriju
|
|
9768
|
+
* @param categoryId - ID kategorije kojoj pripada podkategorija
|
|
9769
|
+
* @param subcategoryId - ID podkategorije koja se ažurira
|
|
9770
|
+
* @param subcategory - Novi podaci za podkategoriju
|
|
9771
|
+
* @returns Ažurirana podkategorija
|
|
9772
|
+
*/
|
|
9773
|
+
async update(categoryId, subcategoryId, subcategory) {
|
|
9774
|
+
const updateData = {
|
|
9775
|
+
...subcategory,
|
|
9776
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
9777
|
+
};
|
|
9778
|
+
const docRef = (0, import_firestore36.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
9779
|
+
await (0, import_firestore36.updateDoc)(docRef, updateData);
|
|
9780
|
+
return this.getById(categoryId, subcategoryId);
|
|
9781
|
+
}
|
|
9782
|
+
/**
|
|
9783
|
+
* Soft delete podkategorije (postavlja isActive na false)
|
|
9784
|
+
* @param categoryId - ID kategorije kojoj pripada podkategorija
|
|
9785
|
+
* @param subcategoryId - ID podkategorije koja se briše
|
|
9786
|
+
*/
|
|
9787
|
+
async delete(categoryId, subcategoryId) {
|
|
9788
|
+
await this.update(categoryId, subcategoryId, { isActive: false });
|
|
9789
|
+
}
|
|
9790
|
+
/**
|
|
9791
|
+
* Vraća podkategoriju po ID-u
|
|
9792
|
+
* @param categoryId - ID kategorije kojoj pripada podkategorija
|
|
9793
|
+
* @param subcategoryId - ID tražene podkategorije
|
|
9794
|
+
* @returns Podkategorija ili null ako ne postoji
|
|
9795
|
+
*/
|
|
9796
|
+
async getById(categoryId, subcategoryId) {
|
|
9797
|
+
const docRef = (0, import_firestore36.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
9798
|
+
const docSnap = await (0, import_firestore36.getDoc)(docRef);
|
|
9799
|
+
if (!docSnap.exists()) return null;
|
|
9800
|
+
return {
|
|
9801
|
+
id: docSnap.id,
|
|
9802
|
+
...docSnap.data()
|
|
9803
|
+
};
|
|
9804
|
+
}
|
|
9805
|
+
};
|
|
9806
|
+
|
|
9807
|
+
// src/backoffice/services/technology.service.ts
|
|
9808
|
+
var import_firestore37 = require("firebase/firestore");
|
|
9809
|
+
var DEFAULT_CERTIFICATION_REQUIREMENT = {
|
|
9810
|
+
minimumLevel: "aesthetician" /* AESTHETICIAN */,
|
|
9811
|
+
requiredSpecialties: []
|
|
9812
|
+
};
|
|
9813
|
+
var TechnologyService = class extends BaseService {
|
|
9814
|
+
/**
|
|
9815
|
+
* Vraća referencu na Firestore kolekciju tehnologija za određenu podkategoriju
|
|
9816
|
+
* @param categoryId - ID kategorije
|
|
9817
|
+
* @param subcategoryId - ID podkategorije
|
|
9818
|
+
*/
|
|
9819
|
+
getTechnologiesRef(categoryId, subcategoryId) {
|
|
9820
|
+
return (0, import_firestore37.collection)(
|
|
9821
|
+
this.db,
|
|
9822
|
+
CATEGORIES_COLLECTION,
|
|
9823
|
+
categoryId,
|
|
9824
|
+
SUBCATEGORIES_COLLECTION,
|
|
9825
|
+
subcategoryId,
|
|
9826
|
+
TECHNOLOGIES_COLLECTION
|
|
9827
|
+
);
|
|
9828
|
+
}
|
|
9829
|
+
/**
|
|
9830
|
+
* Kreira novu tehnologiju u okviru podkategorije
|
|
9831
|
+
* @param categoryId - ID kategorije
|
|
9832
|
+
* @param subcategoryId - ID podkategorije
|
|
9833
|
+
* @param technology - Podaci za novu tehnologiju
|
|
9834
|
+
* @returns Kreirana tehnologija sa generisanim ID-em
|
|
9835
|
+
*/
|
|
9836
|
+
async create(categoryId, subcategoryId, technology) {
|
|
9837
|
+
const now = /* @__PURE__ */ new Date();
|
|
9838
|
+
const newTechnology = {
|
|
9839
|
+
...technology,
|
|
9840
|
+
subcategoryId,
|
|
9841
|
+
createdAt: now,
|
|
9842
|
+
updatedAt: now,
|
|
9843
|
+
isActive: true,
|
|
9844
|
+
requirements: {
|
|
9845
|
+
pre: [],
|
|
9846
|
+
post: []
|
|
9847
|
+
},
|
|
9848
|
+
blockingConditions: [],
|
|
9849
|
+
contraindications: [],
|
|
9850
|
+
benefits: [],
|
|
9851
|
+
certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
|
|
9852
|
+
};
|
|
9853
|
+
const docRef = await (0, import_firestore37.addDoc)(
|
|
9854
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9855
|
+
newTechnology
|
|
9856
|
+
);
|
|
9857
|
+
return { id: docRef.id, ...newTechnology };
|
|
9858
|
+
}
|
|
9859
|
+
/**
|
|
9860
|
+
* Vraća sve aktivne tehnologije za određenu podkategoriju
|
|
9861
|
+
* @param categoryId - ID kategorije
|
|
9862
|
+
* @param subcategoryId - ID podkategorije
|
|
9863
|
+
* @returns Lista aktivnih tehnologija
|
|
9864
|
+
*/
|
|
9865
|
+
async getAllBySubcategoryId(categoryId, subcategoryId) {
|
|
9866
|
+
const q = (0, import_firestore37.query)(
|
|
9867
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9868
|
+
(0, import_firestore37.where)("isActive", "==", true)
|
|
9869
|
+
);
|
|
9870
|
+
const snapshot = await (0, import_firestore37.getDocs)(q);
|
|
9871
|
+
return snapshot.docs.map(
|
|
9872
|
+
(doc26) => ({
|
|
9873
|
+
id: doc26.id,
|
|
9874
|
+
...doc26.data()
|
|
9875
|
+
})
|
|
9876
|
+
);
|
|
9877
|
+
}
|
|
9878
|
+
/**
|
|
9879
|
+
* Ažurira postojeću tehnologiju
|
|
9880
|
+
* @param categoryId - ID kategorije
|
|
9881
|
+
* @param subcategoryId - ID podkategorije
|
|
9882
|
+
* @param technologyId - ID tehnologije
|
|
9883
|
+
* @param technology - Novi podaci za tehnologiju
|
|
9884
|
+
* @returns Ažurirana tehnologija
|
|
9885
|
+
*/
|
|
9886
|
+
async update(categoryId, subcategoryId, technologyId, technology) {
|
|
9887
|
+
const updateData = {
|
|
9888
|
+
...technology,
|
|
9889
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
9890
|
+
};
|
|
9891
|
+
const docRef = (0, import_firestore37.doc)(
|
|
9892
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9893
|
+
technologyId
|
|
9894
|
+
);
|
|
9895
|
+
await (0, import_firestore37.updateDoc)(docRef, updateData);
|
|
9896
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
9897
|
+
}
|
|
9898
|
+
/**
|
|
9899
|
+
* Soft delete tehnologije (postavlja isActive na false)
|
|
9900
|
+
* @param categoryId - ID kategorije
|
|
9901
|
+
* @param subcategoryId - ID podkategorije
|
|
9902
|
+
* @param technologyId - ID tehnologije koja se briše
|
|
9903
|
+
*/
|
|
9904
|
+
async delete(categoryId, subcategoryId, technologyId) {
|
|
9905
|
+
await this.update(categoryId, subcategoryId, technologyId, {
|
|
9906
|
+
isActive: false
|
|
9907
|
+
});
|
|
9908
|
+
}
|
|
9909
|
+
/**
|
|
9910
|
+
* Vraća tehnologiju po ID-u
|
|
9911
|
+
* @param categoryId - ID kategorije
|
|
9912
|
+
* @param subcategoryId - ID podkategorije
|
|
9913
|
+
* @param technologyId - ID tražene tehnologije
|
|
9914
|
+
* @returns Tehnologija ili null ako ne postoji
|
|
9915
|
+
*/
|
|
9916
|
+
async getById(categoryId, subcategoryId, technologyId) {
|
|
9917
|
+
const docRef = (0, import_firestore37.doc)(
|
|
9918
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9919
|
+
technologyId
|
|
9920
|
+
);
|
|
9921
|
+
const docSnap = await (0, import_firestore37.getDoc)(docRef);
|
|
9922
|
+
if (!docSnap.exists()) return null;
|
|
9923
|
+
return {
|
|
9924
|
+
id: docSnap.id,
|
|
9925
|
+
...docSnap.data()
|
|
9926
|
+
};
|
|
9927
|
+
}
|
|
9928
|
+
/**
|
|
9929
|
+
* Dodaje novi zahtev tehnologiji
|
|
9930
|
+
* @param categoryId - ID kategorije
|
|
9931
|
+
* @param subcategoryId - ID podkategorije
|
|
9932
|
+
* @param technologyId - ID tehnologije
|
|
9933
|
+
* @param requirement - Zahtev koji se dodaje
|
|
9934
|
+
* @returns Ažurirana tehnologija sa novim zahtevom
|
|
9935
|
+
*/
|
|
9936
|
+
async addRequirement(categoryId, subcategoryId, technologyId, requirement) {
|
|
9937
|
+
const docRef = (0, import_firestore37.doc)(
|
|
9938
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9939
|
+
technologyId
|
|
9940
|
+
);
|
|
9941
|
+
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
9942
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
9943
|
+
[requirementType]: (0, import_firestore37.arrayUnion)(requirement),
|
|
9944
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
9945
|
+
});
|
|
9946
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
9947
|
+
}
|
|
9948
|
+
/**
|
|
9949
|
+
* Uklanja zahtev iz tehnologije
|
|
9950
|
+
* @param categoryId - ID kategorije
|
|
9951
|
+
* @param subcategoryId - ID podkategorije
|
|
9952
|
+
* @param technologyId - ID tehnologije
|
|
9953
|
+
* @param requirement - Zahtev koji se uklanja
|
|
9954
|
+
* @returns Ažurirana tehnologija bez uklonjenog zahteva
|
|
9955
|
+
*/
|
|
9956
|
+
async removeRequirement(categoryId, subcategoryId, technologyId, requirement) {
|
|
9957
|
+
const docRef = (0, import_firestore37.doc)(
|
|
9958
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9959
|
+
technologyId
|
|
9960
|
+
);
|
|
9961
|
+
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
9962
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
9963
|
+
[requirementType]: (0, import_firestore37.arrayRemove)(requirement),
|
|
9964
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
9965
|
+
});
|
|
9966
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
9967
|
+
}
|
|
9968
|
+
/**
|
|
9969
|
+
* Vraća sve zahteve za tehnologiju
|
|
9970
|
+
* @param categoryId - ID kategorije
|
|
9971
|
+
* @param subcategoryId - ID podkategorije
|
|
9972
|
+
* @param technologyId - ID tehnologije
|
|
9973
|
+
* @param type - Opcioni filter za tip zahteva (pre/post)
|
|
9974
|
+
* @returns Lista zahteva
|
|
9975
|
+
*/
|
|
9976
|
+
async getRequirements(categoryId, subcategoryId, technologyId, type) {
|
|
9977
|
+
const technology = await this.getById(
|
|
9978
|
+
categoryId,
|
|
9979
|
+
subcategoryId,
|
|
9980
|
+
technologyId
|
|
9981
|
+
);
|
|
9982
|
+
if (!technology || !technology.requirements) return [];
|
|
9983
|
+
if (type) {
|
|
9984
|
+
return technology.requirements[type];
|
|
9985
|
+
}
|
|
9986
|
+
return [...technology.requirements.pre, ...technology.requirements.post];
|
|
9987
|
+
}
|
|
9988
|
+
/**
|
|
9989
|
+
* Ažurira postojeći zahtev
|
|
9990
|
+
* @param categoryId - ID kategorije
|
|
9991
|
+
* @param subcategoryId - ID podkategorije
|
|
9992
|
+
* @param technologyId - ID tehnologije
|
|
9993
|
+
* @param oldRequirement - Stari zahtev koji se menja
|
|
9994
|
+
* @param newRequirement - Novi zahtev koji zamenjuje stari
|
|
9995
|
+
* @returns Ažurirana tehnologija
|
|
9996
|
+
*/
|
|
9997
|
+
async updateRequirement(categoryId, subcategoryId, technologyId, oldRequirement, newRequirement) {
|
|
9998
|
+
await this.removeRequirement(
|
|
9999
|
+
categoryId,
|
|
10000
|
+
subcategoryId,
|
|
10001
|
+
technologyId,
|
|
10002
|
+
oldRequirement
|
|
10003
|
+
);
|
|
10004
|
+
return this.addRequirement(
|
|
10005
|
+
categoryId,
|
|
10006
|
+
subcategoryId,
|
|
10007
|
+
technologyId,
|
|
10008
|
+
newRequirement
|
|
10009
|
+
);
|
|
10010
|
+
}
|
|
10011
|
+
/**
|
|
10012
|
+
* Dodaje blokirajući uslov tehnologiji
|
|
10013
|
+
* @param categoryId - ID kategorije
|
|
10014
|
+
* @param subcategoryId - ID podkategorije
|
|
10015
|
+
* @param technologyId - ID tehnologije
|
|
10016
|
+
* @param condition - Blokirajući uslov koji se dodaje
|
|
10017
|
+
* @returns Ažurirana tehnologija
|
|
10018
|
+
*/
|
|
10019
|
+
async addBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
|
|
10020
|
+
const docRef = (0, import_firestore37.doc)(
|
|
10021
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10022
|
+
technologyId
|
|
10023
|
+
);
|
|
10024
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10025
|
+
blockingConditions: (0, import_firestore37.arrayUnion)(condition),
|
|
10026
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
10027
|
+
});
|
|
10028
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
10029
|
+
}
|
|
10030
|
+
/**
|
|
10031
|
+
* Uklanja blokirajući uslov iz tehnologije
|
|
10032
|
+
* @param categoryId - ID kategorije
|
|
10033
|
+
* @param subcategoryId - ID podkategorije
|
|
10034
|
+
* @param technologyId - ID tehnologije
|
|
10035
|
+
* @param condition - Blokirajući uslov koji se uklanja
|
|
10036
|
+
* @returns Ažurirana tehnologija
|
|
10037
|
+
*/
|
|
10038
|
+
async removeBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
|
|
10039
|
+
const docRef = (0, import_firestore37.doc)(
|
|
10040
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10041
|
+
technologyId
|
|
10042
|
+
);
|
|
10043
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10044
|
+
blockingConditions: (0, import_firestore37.arrayRemove)(condition),
|
|
10045
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
10046
|
+
});
|
|
10047
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
10048
|
+
}
|
|
10049
|
+
/**
|
|
10050
|
+
* Dodaje kontraindikaciju tehnologiji
|
|
10051
|
+
* @param categoryId - ID kategorije
|
|
10052
|
+
* @param subcategoryId - ID podkategorije
|
|
10053
|
+
* @param technologyId - ID tehnologije
|
|
10054
|
+
* @param contraindication - Kontraindikacija koja se dodaje
|
|
10055
|
+
* @returns Ažurirana tehnologija
|
|
10056
|
+
*/
|
|
10057
|
+
async addContraindication(categoryId, subcategoryId, technologyId, contraindication) {
|
|
10058
|
+
const docRef = (0, import_firestore37.doc)(
|
|
10059
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10060
|
+
technologyId
|
|
10061
|
+
);
|
|
10062
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10063
|
+
contraindications: (0, import_firestore37.arrayUnion)(contraindication),
|
|
10064
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
10065
|
+
});
|
|
10066
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
10067
|
+
}
|
|
10068
|
+
/**
|
|
10069
|
+
* Uklanja kontraindikaciju iz tehnologije
|
|
10070
|
+
* @param categoryId - ID kategorije
|
|
10071
|
+
* @param subcategoryId - ID podkategorije
|
|
10072
|
+
* @param technologyId - ID tehnologije
|
|
10073
|
+
* @param contraindication - Kontraindikacija koja se uklanja
|
|
10074
|
+
* @returns Ažurirana tehnologija
|
|
10075
|
+
*/
|
|
10076
|
+
async removeContraindication(categoryId, subcategoryId, technologyId, contraindication) {
|
|
10077
|
+
const docRef = (0, import_firestore37.doc)(
|
|
10078
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10079
|
+
technologyId
|
|
10080
|
+
);
|
|
10081
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10082
|
+
contraindications: (0, import_firestore37.arrayRemove)(contraindication),
|
|
10083
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
10084
|
+
});
|
|
10085
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
10086
|
+
}
|
|
10087
|
+
/**
|
|
10088
|
+
* Dodaje benefit tehnologiji
|
|
10089
|
+
* @param categoryId - ID kategorije
|
|
10090
|
+
* @param subcategoryId - ID podkategorije
|
|
10091
|
+
* @param technologyId - ID tehnologije
|
|
10092
|
+
* @param benefit - Benefit koji se dodaje
|
|
10093
|
+
* @returns Ažurirana tehnologija
|
|
10094
|
+
*/
|
|
10095
|
+
async addBenefit(categoryId, subcategoryId, technologyId, benefit) {
|
|
10096
|
+
const docRef = (0, import_firestore37.doc)(
|
|
10097
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10098
|
+
technologyId
|
|
10099
|
+
);
|
|
10100
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10101
|
+
benefits: (0, import_firestore37.arrayUnion)(benefit),
|
|
10102
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
10103
|
+
});
|
|
10104
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
10105
|
+
}
|
|
10106
|
+
/**
|
|
10107
|
+
* Uklanja benefit iz tehnologije
|
|
10108
|
+
* @param categoryId - ID kategorije
|
|
10109
|
+
* @param subcategoryId - ID podkategorije
|
|
10110
|
+
* @param technologyId - ID tehnologije
|
|
10111
|
+
* @param benefit - Benefit koji se uklanja
|
|
10112
|
+
* @returns Ažurirana tehnologija
|
|
10113
|
+
*/
|
|
10114
|
+
async removeBenefit(categoryId, subcategoryId, technologyId, benefit) {
|
|
10115
|
+
const docRef = (0, import_firestore37.doc)(
|
|
10116
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10117
|
+
technologyId
|
|
10118
|
+
);
|
|
10119
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10120
|
+
benefits: (0, import_firestore37.arrayRemove)(benefit),
|
|
10121
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
10122
|
+
});
|
|
10123
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
10124
|
+
}
|
|
10125
|
+
/**
|
|
10126
|
+
* Vraća sve blokirajuće uslove za tehnologiju
|
|
10127
|
+
* @param categoryId - ID kategorije
|
|
10128
|
+
* @param subcategoryId - ID podkategorije
|
|
10129
|
+
* @param technologyId - ID tehnologije
|
|
10130
|
+
* @returns Lista blokirajućih uslova
|
|
10131
|
+
*/
|
|
10132
|
+
async getBlockingConditions(categoryId, subcategoryId, technologyId) {
|
|
10133
|
+
const technology = await this.getById(
|
|
10134
|
+
categoryId,
|
|
10135
|
+
subcategoryId,
|
|
10136
|
+
technologyId
|
|
10137
|
+
);
|
|
10138
|
+
return (technology == null ? void 0 : technology.blockingConditions) || [];
|
|
10139
|
+
}
|
|
10140
|
+
/**
|
|
10141
|
+
* Vraća sve kontraindikacije za tehnologiju
|
|
10142
|
+
* @param categoryId - ID kategorije
|
|
10143
|
+
* @param subcategoryId - ID podkategorije
|
|
10144
|
+
* @param technologyId - ID tehnologije
|
|
10145
|
+
* @returns Lista kontraindikacija
|
|
10146
|
+
*/
|
|
10147
|
+
async getContraindications(categoryId, subcategoryId, technologyId) {
|
|
10148
|
+
const technology = await this.getById(
|
|
10149
|
+
categoryId,
|
|
10150
|
+
subcategoryId,
|
|
10151
|
+
technologyId
|
|
10152
|
+
);
|
|
10153
|
+
return (technology == null ? void 0 : technology.contraindications) || [];
|
|
10154
|
+
}
|
|
10155
|
+
/**
|
|
10156
|
+
* Vraća sve benefite za tehnologiju
|
|
10157
|
+
* @param categoryId - ID kategorije
|
|
10158
|
+
* @param subcategoryId - ID podkategorije
|
|
10159
|
+
* @param technologyId - ID tehnologije
|
|
10160
|
+
* @returns Lista benefita
|
|
10161
|
+
*/
|
|
10162
|
+
async getBenefits(categoryId, subcategoryId, technologyId) {
|
|
10163
|
+
const technology = await this.getById(
|
|
10164
|
+
categoryId,
|
|
10165
|
+
subcategoryId,
|
|
10166
|
+
technologyId
|
|
10167
|
+
);
|
|
10168
|
+
return (technology == null ? void 0 : technology.benefits) || [];
|
|
10169
|
+
}
|
|
10170
|
+
/**
|
|
10171
|
+
* Ažurira zahteve sertifikacije za tehnologiju
|
|
10172
|
+
* @param categoryId - ID kategorije
|
|
10173
|
+
* @param subcategoryId - ID podkategorije
|
|
10174
|
+
* @param technologyId - ID tehnologije
|
|
10175
|
+
* @param certificationRequirement - Novi zahtevi sertifikacije
|
|
10176
|
+
* @returns Ažurirana tehnologija
|
|
10177
|
+
*/
|
|
10178
|
+
async updateCertificationRequirement(categoryId, subcategoryId, technologyId, certificationRequirement) {
|
|
10179
|
+
const docRef = (0, import_firestore37.doc)(
|
|
10180
|
+
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10181
|
+
technologyId
|
|
10182
|
+
);
|
|
10183
|
+
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10184
|
+
certificationRequirement,
|
|
10185
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
10186
|
+
});
|
|
10187
|
+
return this.getById(categoryId, subcategoryId, technologyId);
|
|
10188
|
+
}
|
|
10189
|
+
/**
|
|
10190
|
+
* Vraća zahteve sertifikacije za tehnologiju
|
|
10191
|
+
* @param categoryId - ID kategorije
|
|
10192
|
+
* @param subcategoryId - ID podkategorije
|
|
10193
|
+
* @param technologyId - ID tehnologije
|
|
10194
|
+
* @returns Zahtevi sertifikacije ili null ako tehnologija ne postoji
|
|
10195
|
+
*/
|
|
10196
|
+
async getCertificationRequirement(categoryId, subcategoryId, technologyId) {
|
|
10197
|
+
const technology = await this.getById(
|
|
10198
|
+
categoryId,
|
|
10199
|
+
subcategoryId,
|
|
10200
|
+
technologyId
|
|
10201
|
+
);
|
|
10202
|
+
return (technology == null ? void 0 : technology.certificationRequirement) || null;
|
|
10203
|
+
}
|
|
10204
|
+
};
|
|
10205
|
+
|
|
10206
|
+
// src/backoffice/services/product.service.ts
|
|
10207
|
+
var import_firestore38 = require("firebase/firestore");
|
|
10208
|
+
var ProductService = class extends BaseService {
|
|
10209
|
+
getProductsRefByTechnology(categoryId, subcategoryId, technologyId) {
|
|
10210
|
+
return (0, import_firestore38.collection)(
|
|
10211
|
+
this.db,
|
|
10212
|
+
CATEGORIES_COLLECTION,
|
|
10213
|
+
categoryId,
|
|
10214
|
+
SUBCATEGORIES_COLLECTION,
|
|
10215
|
+
subcategoryId,
|
|
10216
|
+
TECHNOLOGIES_COLLECTION,
|
|
10217
|
+
technologyId,
|
|
10218
|
+
PRODUCTS_COLLECTION
|
|
10219
|
+
);
|
|
10220
|
+
}
|
|
10221
|
+
getProductsRefByBrand(brandId) {
|
|
10222
|
+
return (0, import_firestore38.collection)(this.db, BRANDS_COLLECTION, brandId, PRODUCTS_COLLECTION);
|
|
10223
|
+
}
|
|
10224
|
+
async create(categoryId, subcategoryId, technologyId, brandId, product) {
|
|
10225
|
+
const now = /* @__PURE__ */ new Date();
|
|
10226
|
+
const newProduct = {
|
|
10227
|
+
...product,
|
|
10228
|
+
brandId,
|
|
10229
|
+
technologyId,
|
|
10230
|
+
createdAt: now,
|
|
10231
|
+
updatedAt: now,
|
|
10232
|
+
isActive: true
|
|
10233
|
+
};
|
|
10234
|
+
const techProductRef = await (0, import_firestore38.addDoc)(
|
|
10235
|
+
this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
|
|
10236
|
+
newProduct
|
|
10237
|
+
);
|
|
10238
|
+
await (0, import_firestore38.addDoc)(this.getProductsRefByBrand(brandId), {
|
|
10239
|
+
...newProduct,
|
|
10240
|
+
id: techProductRef.id,
|
|
10241
|
+
// Store the original ID for reference
|
|
10242
|
+
categoryId,
|
|
10243
|
+
subcategoryId,
|
|
10244
|
+
technologyId
|
|
10245
|
+
});
|
|
10246
|
+
return { id: techProductRef.id, ...newProduct };
|
|
10247
|
+
}
|
|
10248
|
+
async getAllByTechnology(categoryId, subcategoryId, technologyId) {
|
|
10249
|
+
const q = (0, import_firestore38.query)(
|
|
10250
|
+
this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
|
|
10251
|
+
(0, import_firestore38.where)("isActive", "==", true)
|
|
10252
|
+
);
|
|
10253
|
+
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
10254
|
+
return snapshot.docs.map(
|
|
10255
|
+
(doc26) => ({
|
|
10256
|
+
id: doc26.id,
|
|
10257
|
+
...doc26.data()
|
|
10258
|
+
})
|
|
10259
|
+
);
|
|
10260
|
+
}
|
|
10261
|
+
async getAllByBrand(brandId) {
|
|
10262
|
+
const q = (0, import_firestore38.query)(
|
|
10263
|
+
this.getProductsRefByBrand(brandId),
|
|
10264
|
+
(0, import_firestore38.where)("isActive", "==", true)
|
|
10265
|
+
);
|
|
10266
|
+
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
10267
|
+
return snapshot.docs.map(
|
|
10268
|
+
(doc26) => ({
|
|
10269
|
+
id: doc26.id,
|
|
10270
|
+
...doc26.data()
|
|
10271
|
+
})
|
|
10272
|
+
);
|
|
10273
|
+
}
|
|
10274
|
+
async update(categoryId, subcategoryId, technologyId, productId, product) {
|
|
10275
|
+
const updateData = {
|
|
10276
|
+
...product,
|
|
10277
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
10278
|
+
};
|
|
10279
|
+
const techDocRef = (0, import_firestore38.doc)(
|
|
10280
|
+
this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
|
|
10281
|
+
productId
|
|
10282
|
+
);
|
|
10283
|
+
await (0, import_firestore38.updateDoc)(techDocRef, updateData);
|
|
10284
|
+
const brandProductsQuery = (0, import_firestore38.query)(
|
|
10285
|
+
(0, import_firestore38.collectionGroup)(this.db, PRODUCTS_COLLECTION),
|
|
10286
|
+
(0, import_firestore38.where)("id", "==", productId)
|
|
10287
|
+
);
|
|
10288
|
+
const brandProductsSnapshot = await (0, import_firestore38.getDocs)(brandProductsQuery);
|
|
10289
|
+
for (const doc26 of brandProductsSnapshot.docs) {
|
|
10290
|
+
await (0, import_firestore38.updateDoc)(doc26.ref, updateData);
|
|
10291
|
+
}
|
|
10292
|
+
return this.getById(categoryId, subcategoryId, technologyId, productId);
|
|
10293
|
+
}
|
|
10294
|
+
async delete(categoryId, subcategoryId, technologyId, productId) {
|
|
10295
|
+
await this.update(categoryId, subcategoryId, technologyId, productId, {
|
|
10296
|
+
isActive: false
|
|
10297
|
+
});
|
|
10298
|
+
}
|
|
10299
|
+
async getById(categoryId, subcategoryId, technologyId, productId) {
|
|
10300
|
+
const docRef = (0, import_firestore38.doc)(
|
|
10301
|
+
this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
|
|
10302
|
+
productId
|
|
10303
|
+
);
|
|
10304
|
+
const docSnap = await (0, import_firestore38.getDoc)(docRef);
|
|
10305
|
+
if (!docSnap.exists()) return null;
|
|
10306
|
+
return {
|
|
10307
|
+
id: docSnap.id,
|
|
10308
|
+
...docSnap.data()
|
|
10309
|
+
};
|
|
10310
|
+
}
|
|
10311
|
+
};
|
|
10312
|
+
|
|
9556
10313
|
// src/validations/notification.schema.ts
|
|
9557
10314
|
var import_zod19 = require("zod");
|
|
9558
10315
|
var baseNotificationSchema = import_zod19.z.object({
|
|
@@ -9614,6 +10371,7 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
|
|
|
9614
10371
|
AllergyType,
|
|
9615
10372
|
AuthService,
|
|
9616
10373
|
BlockingCondition,
|
|
10374
|
+
BrandService,
|
|
9617
10375
|
CALENDAR_COLLECTION,
|
|
9618
10376
|
CLINICS_COLLECTION,
|
|
9619
10377
|
CLINIC_ADMINS_COLLECTION,
|
|
@@ -9622,6 +10380,7 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
|
|
|
9622
10380
|
CalendarEventType,
|
|
9623
10381
|
CalendarServiceV2,
|
|
9624
10382
|
CalendarSyncStatus,
|
|
10383
|
+
CategoryService,
|
|
9625
10384
|
CertificationLevel,
|
|
9626
10385
|
CertificationSpecialty,
|
|
9627
10386
|
ClinicAdminService,
|
|
@@ -9665,11 +10424,14 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
|
|
|
9665
10424
|
PricingMeasure,
|
|
9666
10425
|
ProcedureFamily,
|
|
9667
10426
|
ProcedureService,
|
|
10427
|
+
ProductService,
|
|
9668
10428
|
REGISTER_TOKENS_COLLECTION,
|
|
9669
10429
|
SYNCED_CALENDARS_COLLECTION,
|
|
10430
|
+
SubcategoryService,
|
|
9670
10431
|
SubscriptionModel,
|
|
9671
10432
|
SyncedCalendarProvider,
|
|
9672
10433
|
SyncedCalendarsService,
|
|
10434
|
+
TechnologyService,
|
|
9673
10435
|
TreatmentBenefit,
|
|
9674
10436
|
USER_ERRORS,
|
|
9675
10437
|
UserService,
|