@blackcode_sa/metaestetics-api 1.5.3 → 1.5.4

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.
Files changed (30) hide show
  1. package/dist/backoffice/index.d.mts +1306 -63
  2. package/dist/backoffice/index.d.ts +1306 -63
  3. package/dist/backoffice/index.js +35 -26
  4. package/dist/backoffice/index.mjs +35 -26
  5. package/dist/index.d.mts +17 -3
  6. package/dist/index.d.ts +17 -3
  7. package/dist/index.js +77 -0
  8. package/dist/index.mjs +77 -0
  9. package/package.json +1 -1
  10. package/src/backoffice/services/brand.service.ts +2 -4
  11. package/src/backoffice/services/category.service.ts +2 -7
  12. package/src/backoffice/services/product.service.ts +5 -7
  13. package/src/backoffice/services/requirement.service.ts +6 -7
  14. package/src/backoffice/services/subcategory.service.ts +11 -8
  15. package/src/backoffice/services/technology.service.ts +6 -11
  16. package/src/backoffice/types/brand.types.ts +5 -0
  17. package/src/backoffice/types/category.types.ts +5 -0
  18. package/src/backoffice/types/documentation-templates.types.ts +4 -0
  19. package/src/backoffice/types/product.types.ts +5 -0
  20. package/src/backoffice/types/requirement.types.ts +5 -0
  21. package/src/backoffice/types/subcategory.types.ts +5 -0
  22. package/src/backoffice/types/technology.types.ts +10 -0
  23. package/src/backoffice/validations/schemas.ts +2 -0
  24. package/src/errors/auth.errors.ts +7 -0
  25. package/src/services/auth.service.ts +94 -0
  26. package/src/services/documentation-templates/documentation-template.service.ts +4 -1
  27. package/src/services/procedure/procedure.service.ts +238 -0
  28. package/src/types/documentation-templates/index.ts +5 -0
  29. package/src/types/procedure/index.ts +104 -0
  30. package/src/validations/procedure.schema.ts +58 -0
@@ -90,17 +90,33 @@ __export(index_exports, {
90
90
  });
91
91
  module.exports = __toCommonJS(index_exports);
92
92
 
93
+ // src/backoffice/types/brand.types.ts
94
+ var BRANDS_COLLECTION = "brands";
95
+
96
+ // src/backoffice/types/category.types.ts
97
+ var CATEGORIES_COLLECTION = "backoffice_categories";
98
+
99
+ // src/backoffice/types/product.types.ts
100
+ var PRODUCTS_COLLECTION = "products";
101
+
93
102
  // src/backoffice/types/requirement.types.ts
94
103
  var TimeUnit = /* @__PURE__ */ ((TimeUnit2) => {
95
104
  TimeUnit2["HOURS"] = "hours";
96
105
  TimeUnit2["DAYS"] = "days";
97
106
  return TimeUnit2;
98
107
  })(TimeUnit || {});
99
- var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
100
- RequirementType2["PRE"] = "pre";
101
- RequirementType2["POST"] = "post";
102
- return RequirementType2;
108
+ var RequirementType = /* @__PURE__ */ ((RequirementType3) => {
109
+ RequirementType3["PRE"] = "pre";
110
+ RequirementType3["POST"] = "post";
111
+ return RequirementType3;
103
112
  })(RequirementType || {});
113
+ var REQUIREMENTS_COLLECTION = "backoffice_requirements";
114
+
115
+ // src/backoffice/types/subcategory.types.ts
116
+ var SUBCATEGORIES_COLLECTION = "subcategories";
117
+
118
+ // src/backoffice/types/technology.types.ts
119
+ var TECHNOLOGIES_COLLECTION = "technologies";
104
120
 
105
121
  // src/backoffice/types/static/blocking-condition.types.ts
106
122
  var BlockingCondition = /* @__PURE__ */ ((BlockingCondition2) => {
@@ -550,6 +566,7 @@ var technologySchema = import_zod2.z.object({
550
566
  }),
551
567
  blockingConditions: import_zod2.z.array(blockingConditionSchema),
552
568
  contraindications: import_zod2.z.array(contraindicationSchema),
569
+ documentationTemplates: import_zod2.z.array(documentTemplateSchema),
553
570
  benefits: import_zod2.z.array(treatmentBenefitSchema),
554
571
  certificationRequirement: certificationRequirementSchema,
555
572
  isActive: import_zod2.z.boolean().default(true)
@@ -600,13 +617,12 @@ var BaseService = class {
600
617
  };
601
618
 
602
619
  // src/backoffice/services/category.service.ts
603
- var COLLECTION = "backoffice_categories";
604
620
  var CategoryService = class extends BaseService {
605
621
  /**
606
622
  * Referenca na Firestore kolekciju kategorija
607
623
  */
608
624
  get categoriesRef() {
609
- return (0, import_firestore.collection)(this.db, COLLECTION);
625
+ return (0, import_firestore.collection)(this.db, CATEGORIES_COLLECTION);
610
626
  }
611
627
  /**
612
628
  * Kreira novu kategoriju u sistemu
@@ -697,15 +713,18 @@ var CategoryService = class extends BaseService {
697
713
 
698
714
  // src/backoffice/services/subcategory.service.ts
699
715
  var import_firestore2 = require("firebase/firestore");
700
- var COLLECTION2 = "backoffice_categories";
701
- var SUB_COLLECTION = "subcategories";
702
716
  var SubcategoryService = class extends BaseService {
703
717
  /**
704
718
  * Vraća referencu na Firestore kolekciju podkategorija za određenu kategoriju
705
719
  * @param categoryId - ID roditeljske kategorije
706
720
  */
707
721
  getSubcategoriesRef(categoryId) {
708
- return (0, import_firestore2.collection)(this.db, COLLECTION2, categoryId, SUB_COLLECTION);
722
+ return (0, import_firestore2.collection)(
723
+ this.db,
724
+ CATEGORIES_COLLECTION,
725
+ categoryId,
726
+ SUBCATEGORIES_COLLECTION
727
+ );
709
728
  }
710
729
  /**
711
730
  * Kreira novu podkategoriju u okviru kategorije
@@ -789,9 +808,6 @@ var SubcategoryService = class extends BaseService {
789
808
 
790
809
  // src/backoffice/services/technology.service.ts
791
810
  var import_firestore3 = require("firebase/firestore");
792
- var COLLECTION3 = "backoffice_categories";
793
- var SUB_COLLECTION_SUBCATEGORIES = "subcategories";
794
- var SUB_COLLECTION_TECHNOLOGIES = "technologies";
795
811
  var DEFAULT_CERTIFICATION_REQUIREMENT2 = {
796
812
  minimumLevel: "aesthetician" /* AESTHETICIAN */,
797
813
  requiredSpecialties: []
@@ -805,11 +821,11 @@ var TechnologyService = class extends BaseService {
805
821
  getTechnologiesRef(categoryId, subcategoryId) {
806
822
  return (0, import_firestore3.collection)(
807
823
  this.db,
808
- COLLECTION3,
824
+ CATEGORIES_COLLECTION,
809
825
  categoryId,
810
- SUB_COLLECTION_SUBCATEGORIES,
826
+ SUBCATEGORIES_COLLECTION,
811
827
  subcategoryId,
812
- SUB_COLLECTION_TECHNOLOGIES
828
+ TECHNOLOGIES_COLLECTION
813
829
  );
814
830
  }
815
831
  /**
@@ -1191,13 +1207,12 @@ var TechnologyService = class extends BaseService {
1191
1207
 
1192
1208
  // src/backoffice/services/requirement.service.ts
1193
1209
  var import_firestore4 = require("firebase/firestore");
1194
- var COLLECTION4 = "backoffice_requirements";
1195
1210
  var RequirementService = class extends BaseService {
1196
1211
  /**
1197
1212
  * Referenca na Firestore kolekciju zahteva
1198
1213
  */
1199
1214
  get requirementsRef() {
1200
- return (0, import_firestore4.collection)(this.db, COLLECTION4);
1215
+ return (0, import_firestore4.collection)(this.db, REQUIREMENTS_COLLECTION);
1201
1216
  }
1202
1217
  /**
1203
1218
  * Kreira novi globalni zahtev
@@ -1288,10 +1303,9 @@ var RequirementService = class extends BaseService {
1288
1303
 
1289
1304
  // src/backoffice/services/brand.service.ts
1290
1305
  var import_firestore5 = require("firebase/firestore");
1291
- var COLLECTION5 = "backoffice_brands";
1292
1306
  var BrandService = class extends BaseService {
1293
1307
  get brandsRef() {
1294
- return (0, import_firestore5.collection)(this.db, COLLECTION5);
1308
+ return (0, import_firestore5.collection)(this.db, BRANDS_COLLECTION);
1295
1309
  }
1296
1310
  async create(brand) {
1297
1311
  const now = /* @__PURE__ */ new Date();
@@ -1339,11 +1353,6 @@ var BrandService = class extends BaseService {
1339
1353
 
1340
1354
  // src/backoffice/services/product.service.ts
1341
1355
  var import_firestore6 = require("firebase/firestore");
1342
- var CATEGORIES_COLLECTION = "backoffice_categories";
1343
- var SUBCATEGORIES_COLLECTION = "subcategories";
1344
- var TECHNOLOGIES_COLLECTION = "technologies";
1345
- var PRODUCTS_COLLECTION = "products";
1346
- var BRANDS_COLLECTION = "backoffice_brands";
1347
1356
  var ProductService = class extends BaseService {
1348
1357
  getProductsRefByTechnology(categoryId, subcategoryId, technologyId) {
1349
1358
  return (0, import_firestore6.collection)(
@@ -1453,7 +1462,7 @@ var ProductService = class extends BaseService {
1453
1462
  var import_firestore7 = require("firebase/firestore");
1454
1463
 
1455
1464
  // src/types/index.ts
1456
- var DOCUMENTATION_TEMPLATES_COLLECTION = "documentation-templates";
1465
+ var DOCUMENTATION_TEMPLATES_COLLECTION2 = "documentation-templates";
1457
1466
 
1458
1467
  // src/services/documentation-templates/documentation-template.service.ts
1459
1468
  var DocumentationTemplateService = class extends BaseService {
@@ -1461,7 +1470,7 @@ var DocumentationTemplateService = class extends BaseService {
1461
1470
  super(...arguments);
1462
1471
  this.collectionRef = (0, import_firestore7.collection)(
1463
1472
  this.db,
1464
- DOCUMENTATION_TEMPLATES_COLLECTION
1473
+ DOCUMENTATION_TEMPLATES_COLLECTION2
1465
1474
  );
1466
1475
  }
1467
1476
  /**
@@ -1,14 +1,30 @@
1
+ // src/backoffice/types/brand.types.ts
2
+ var BRANDS_COLLECTION = "brands";
3
+
4
+ // src/backoffice/types/category.types.ts
5
+ var CATEGORIES_COLLECTION = "backoffice_categories";
6
+
7
+ // src/backoffice/types/product.types.ts
8
+ var PRODUCTS_COLLECTION = "products";
9
+
1
10
  // src/backoffice/types/requirement.types.ts
2
11
  var TimeUnit = /* @__PURE__ */ ((TimeUnit2) => {
3
12
  TimeUnit2["HOURS"] = "hours";
4
13
  TimeUnit2["DAYS"] = "days";
5
14
  return TimeUnit2;
6
15
  })(TimeUnit || {});
7
- var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
8
- RequirementType2["PRE"] = "pre";
9
- RequirementType2["POST"] = "post";
10
- return RequirementType2;
16
+ var RequirementType = /* @__PURE__ */ ((RequirementType3) => {
17
+ RequirementType3["PRE"] = "pre";
18
+ RequirementType3["POST"] = "post";
19
+ return RequirementType3;
11
20
  })(RequirementType || {});
21
+ var REQUIREMENTS_COLLECTION = "backoffice_requirements";
22
+
23
+ // src/backoffice/types/subcategory.types.ts
24
+ var SUBCATEGORIES_COLLECTION = "subcategories";
25
+
26
+ // src/backoffice/types/technology.types.ts
27
+ var TECHNOLOGIES_COLLECTION = "technologies";
12
28
 
13
29
  // src/backoffice/types/static/blocking-condition.types.ts
14
30
  var BlockingCondition = /* @__PURE__ */ ((BlockingCondition2) => {
@@ -458,6 +474,7 @@ var technologySchema = z2.object({
458
474
  }),
459
475
  blockingConditions: z2.array(blockingConditionSchema),
460
476
  contraindications: z2.array(contraindicationSchema),
477
+ documentationTemplates: z2.array(documentTemplateSchema),
461
478
  benefits: z2.array(treatmentBenefitSchema),
462
479
  certificationRequirement: certificationRequirementSchema,
463
480
  isActive: z2.boolean().default(true)
@@ -517,13 +534,12 @@ var BaseService = class {
517
534
  };
518
535
 
519
536
  // src/backoffice/services/category.service.ts
520
- var COLLECTION = "backoffice_categories";
521
537
  var CategoryService = class extends BaseService {
522
538
  /**
523
539
  * Referenca na Firestore kolekciju kategorija
524
540
  */
525
541
  get categoriesRef() {
526
- return collection(this.db, COLLECTION);
542
+ return collection(this.db, CATEGORIES_COLLECTION);
527
543
  }
528
544
  /**
529
545
  * Kreira novu kategoriju u sistemu
@@ -623,15 +639,18 @@ import {
623
639
  updateDoc as updateDoc2,
624
640
  where as where2
625
641
  } from "firebase/firestore";
626
- var COLLECTION2 = "backoffice_categories";
627
- var SUB_COLLECTION = "subcategories";
628
642
  var SubcategoryService = class extends BaseService {
629
643
  /**
630
644
  * Vraća referencu na Firestore kolekciju podkategorija za određenu kategoriju
631
645
  * @param categoryId - ID roditeljske kategorije
632
646
  */
633
647
  getSubcategoriesRef(categoryId) {
634
- return collection2(this.db, COLLECTION2, categoryId, SUB_COLLECTION);
648
+ return collection2(
649
+ this.db,
650
+ CATEGORIES_COLLECTION,
651
+ categoryId,
652
+ SUBCATEGORIES_COLLECTION
653
+ );
635
654
  }
636
655
  /**
637
656
  * Kreira novu podkategoriju u okviru kategorije
@@ -726,9 +745,6 @@ import {
726
745
  arrayUnion,
727
746
  arrayRemove
728
747
  } from "firebase/firestore";
729
- var COLLECTION3 = "backoffice_categories";
730
- var SUB_COLLECTION_SUBCATEGORIES = "subcategories";
731
- var SUB_COLLECTION_TECHNOLOGIES = "technologies";
732
748
  var DEFAULT_CERTIFICATION_REQUIREMENT2 = {
733
749
  minimumLevel: "aesthetician" /* AESTHETICIAN */,
734
750
  requiredSpecialties: []
@@ -742,11 +758,11 @@ var TechnologyService = class extends BaseService {
742
758
  getTechnologiesRef(categoryId, subcategoryId) {
743
759
  return collection3(
744
760
  this.db,
745
- COLLECTION3,
761
+ CATEGORIES_COLLECTION,
746
762
  categoryId,
747
- SUB_COLLECTION_SUBCATEGORIES,
763
+ SUBCATEGORIES_COLLECTION,
748
764
  subcategoryId,
749
- SUB_COLLECTION_TECHNOLOGIES
765
+ TECHNOLOGIES_COLLECTION
750
766
  );
751
767
  }
752
768
  /**
@@ -1137,13 +1153,12 @@ import {
1137
1153
  updateDoc as updateDoc4,
1138
1154
  where as where4
1139
1155
  } from "firebase/firestore";
1140
- var COLLECTION4 = "backoffice_requirements";
1141
1156
  var RequirementService = class extends BaseService {
1142
1157
  /**
1143
1158
  * Referenca na Firestore kolekciju zahteva
1144
1159
  */
1145
1160
  get requirementsRef() {
1146
- return collection4(this.db, COLLECTION4);
1161
+ return collection4(this.db, REQUIREMENTS_COLLECTION);
1147
1162
  }
1148
1163
  /**
1149
1164
  * Kreira novi globalni zahtev
@@ -1243,10 +1258,9 @@ import {
1243
1258
  updateDoc as updateDoc5,
1244
1259
  where as where5
1245
1260
  } from "firebase/firestore";
1246
- var COLLECTION5 = "backoffice_brands";
1247
1261
  var BrandService = class extends BaseService {
1248
1262
  get brandsRef() {
1249
- return collection5(this.db, COLLECTION5);
1263
+ return collection5(this.db, BRANDS_COLLECTION);
1250
1264
  }
1251
1265
  async create(brand) {
1252
1266
  const now = /* @__PURE__ */ new Date();
@@ -1304,11 +1318,6 @@ import {
1304
1318
  updateDoc as updateDoc6,
1305
1319
  where as where6
1306
1320
  } from "firebase/firestore";
1307
- var CATEGORIES_COLLECTION = "backoffice_categories";
1308
- var SUBCATEGORIES_COLLECTION = "subcategories";
1309
- var TECHNOLOGIES_COLLECTION = "technologies";
1310
- var PRODUCTS_COLLECTION = "products";
1311
- var BRANDS_COLLECTION = "backoffice_brands";
1312
1321
  var ProductService = class extends BaseService {
1313
1322
  getProductsRefByTechnology(categoryId, subcategoryId, technologyId) {
1314
1323
  return collection6(
@@ -1431,7 +1440,7 @@ import {
1431
1440
  } from "firebase/firestore";
1432
1441
 
1433
1442
  // src/types/index.ts
1434
- var DOCUMENTATION_TEMPLATES_COLLECTION = "documentation-templates";
1443
+ var DOCUMENTATION_TEMPLATES_COLLECTION2 = "documentation-templates";
1435
1444
 
1436
1445
  // src/services/documentation-templates/documentation-template.service.ts
1437
1446
  var DocumentationTemplateService = class extends BaseService {
@@ -1439,7 +1448,7 @@ var DocumentationTemplateService = class extends BaseService {
1439
1448
  super(...arguments);
1440
1449
  this.collectionRef = collection7(
1441
1450
  this.db,
1442
- DOCUMENTATION_TEMPLATES_COLLECTION
1451
+ DOCUMENTATION_TEMPLATES_COLLECTION2
1443
1452
  );
1444
1453
  }
1445
1454
  /**
package/dist/index.d.mts CHANGED
@@ -26,9 +26,6 @@ declare const getFirebaseAuth: () => Promise<Auth>;
26
26
  declare const getFirebaseDB: () => Promise<Firestore>;
27
27
  declare const getFirebaseApp: () => Promise<FirebaseApp>;
28
28
 
29
- /**
30
- * Types for the Medical Documentation Templating System
31
- */
32
29
  /**
33
30
  * Enum for element types in documentation templates
34
31
  */
@@ -1692,6 +1689,7 @@ interface Subcategory {
1692
1689
  * @property contraindications - List of conditions requiring special attention
1693
1690
  * @property benefits - List of expected benefits from the procedure
1694
1691
  * @property certificationRequirement - Required certification level and specialties
1692
+ * @property documentationTemplates - List of documentation templates required for this technology
1695
1693
  * @property isActive - Whether the technology is active in the system
1696
1694
  * @property createdAt - Creation date
1697
1695
  * @property updatedAt - Last update date
@@ -1720,6 +1718,8 @@ interface Technology {
1720
1718
  benefits: TreatmentBenefit[];
1721
1719
  /** Potrebna sertifikacija za korišćenje tehnologije */
1722
1720
  certificationRequirement: CertificationRequirement;
1721
+ /** Dokumentacioni šabloni potrebni za ovu tehnologiju */
1722
+ documentationTemplates?: DocumentTemplate[];
1723
1723
  /** Da li je tehnologija trenutno aktivna */
1724
1724
  isActive: boolean;
1725
1725
  /** Datum kreiranja */
@@ -4108,6 +4108,19 @@ declare class AuthService extends BaseService {
4108
4108
  * Prijavljuje korisnika sa email-om i lozinkom
4109
4109
  */
4110
4110
  signIn(email: string, password: string): Promise<User>;
4111
+ /**
4112
+ * Prijavljuje korisnika sa email-om i lozinkom samo za clinic_admin role
4113
+ * @param email - Email korisnika
4114
+ * @param password - Lozinka korisnika
4115
+ * @returns Objekat koji sadrži korisnika, admin profil i grupu klinika
4116
+ * @throws {AUTH_ERRORS.INVALID_ROLE} Ako korisnik nema clinic_admin rolu
4117
+ * @throws {AUTH_ERRORS.NOT_FOUND} Ako admin profil nije pronađen
4118
+ */
4119
+ signInClinicAdmin(email: string, password: string): Promise<{
4120
+ user: User;
4121
+ clinicAdmin: ClinicAdmin;
4122
+ clinicGroup: ClinicGroup;
4123
+ }>;
4111
4124
  /**
4112
4125
  * Prijavljuje korisnika sa Facebook-om
4113
4126
  */
@@ -4978,6 +4991,7 @@ declare const AUTH_ERRORS: {
4978
4991
  readonly REQUIRES_RECENT_LOGIN: AuthError;
4979
4992
  readonly INVALID_PROVIDER: AuthError;
4980
4993
  readonly INVALID_CREDENTIAL: AuthError;
4994
+ readonly NOT_FOUND: AuthError;
4981
4995
  readonly PASSWORD_LENGTH_ERROR: AuthError;
4982
4996
  readonly PASSWORD_UPPERCASE_ERROR: AuthError;
4983
4997
  readonly PASSWORD_NUMBER_ERROR: AuthError;
package/dist/index.d.ts CHANGED
@@ -26,9 +26,6 @@ declare const getFirebaseAuth: () => Promise<Auth>;
26
26
  declare const getFirebaseDB: () => Promise<Firestore>;
27
27
  declare const getFirebaseApp: () => Promise<FirebaseApp>;
28
28
 
29
- /**
30
- * Types for the Medical Documentation Templating System
31
- */
32
29
  /**
33
30
  * Enum for element types in documentation templates
34
31
  */
@@ -1692,6 +1689,7 @@ interface Subcategory {
1692
1689
  * @property contraindications - List of conditions requiring special attention
1693
1690
  * @property benefits - List of expected benefits from the procedure
1694
1691
  * @property certificationRequirement - Required certification level and specialties
1692
+ * @property documentationTemplates - List of documentation templates required for this technology
1695
1693
  * @property isActive - Whether the technology is active in the system
1696
1694
  * @property createdAt - Creation date
1697
1695
  * @property updatedAt - Last update date
@@ -1720,6 +1718,8 @@ interface Technology {
1720
1718
  benefits: TreatmentBenefit[];
1721
1719
  /** Potrebna sertifikacija za korišćenje tehnologije */
1722
1720
  certificationRequirement: CertificationRequirement;
1721
+ /** Dokumentacioni šabloni potrebni za ovu tehnologiju */
1722
+ documentationTemplates?: DocumentTemplate[];
1723
1723
  /** Da li je tehnologija trenutno aktivna */
1724
1724
  isActive: boolean;
1725
1725
  /** Datum kreiranja */
@@ -4108,6 +4108,19 @@ declare class AuthService extends BaseService {
4108
4108
  * Prijavljuje korisnika sa email-om i lozinkom
4109
4109
  */
4110
4110
  signIn(email: string, password: string): Promise<User>;
4111
+ /**
4112
+ * Prijavljuje korisnika sa email-om i lozinkom samo za clinic_admin role
4113
+ * @param email - Email korisnika
4114
+ * @param password - Lozinka korisnika
4115
+ * @returns Objekat koji sadrži korisnika, admin profil i grupu klinika
4116
+ * @throws {AUTH_ERRORS.INVALID_ROLE} Ako korisnik nema clinic_admin rolu
4117
+ * @throws {AUTH_ERRORS.NOT_FOUND} Ako admin profil nije pronađen
4118
+ */
4119
+ signInClinicAdmin(email: string, password: string): Promise<{
4120
+ user: User;
4121
+ clinicAdmin: ClinicAdmin;
4122
+ clinicGroup: ClinicGroup;
4123
+ }>;
4111
4124
  /**
4112
4125
  * Prijavljuje korisnika sa Facebook-om
4113
4126
  */
@@ -4978,6 +4991,7 @@ declare const AUTH_ERRORS: {
4978
4991
  readonly REQUIRES_RECENT_LOGIN: AuthError;
4979
4992
  readonly INVALID_PROVIDER: AuthError;
4980
4993
  readonly INVALID_CREDENTIAL: AuthError;
4994
+ readonly NOT_FOUND: AuthError;
4981
4995
  readonly PASSWORD_LENGTH_ERROR: AuthError;
4982
4996
  readonly PASSWORD_UPPERCASE_ERROR: AuthError;
4983
4997
  readonly PASSWORD_NUMBER_ERROR: AuthError;
package/dist/index.js CHANGED
@@ -626,6 +626,12 @@ var AUTH_ERRORS = {
626
626
  "AUTH/INVALID_CREDENTIAL",
627
627
  401
628
628
  ),
629
+ // Resource not found
630
+ NOT_FOUND: new AuthError(
631
+ "The requested resource was not found",
632
+ "AUTH/NOT_FOUND",
633
+ 404
634
+ ),
629
635
  // Detailed password validation errors
630
636
  PASSWORD_LENGTH_ERROR: new AuthError(
631
637
  "Password must be at least 8 characters long",
@@ -5851,6 +5857,77 @@ var AuthService = class extends BaseService {
5851
5857
  );
5852
5858
  return this.userService.getOrCreateUser(firebaseUser);
5853
5859
  }
5860
+ /**
5861
+ * Prijavljuje korisnika sa email-om i lozinkom samo za clinic_admin role
5862
+ * @param email - Email korisnika
5863
+ * @param password - Lozinka korisnika
5864
+ * @returns Objekat koji sadrži korisnika, admin profil i grupu klinika
5865
+ * @throws {AUTH_ERRORS.INVALID_ROLE} Ako korisnik nema clinic_admin rolu
5866
+ * @throws {AUTH_ERRORS.NOT_FOUND} Ako admin profil nije pronađen
5867
+ */
5868
+ async signInClinicAdmin(email, password) {
5869
+ var _a;
5870
+ try {
5871
+ const clinicAdminService = new ClinicAdminService(
5872
+ this.db,
5873
+ this.auth,
5874
+ this.app
5875
+ );
5876
+ const clinicGroupService = new ClinicGroupService(
5877
+ this.db,
5878
+ this.auth,
5879
+ this.app,
5880
+ clinicAdminService
5881
+ );
5882
+ const clinicService = new ClinicService(
5883
+ this.db,
5884
+ this.auth,
5885
+ this.app,
5886
+ clinicGroupService,
5887
+ clinicAdminService
5888
+ );
5889
+ clinicAdminService.setServices(clinicGroupService, clinicService);
5890
+ const { user: firebaseUser } = await (0, import_auth5.signInWithEmailAndPassword)(
5891
+ this.auth,
5892
+ email,
5893
+ password
5894
+ );
5895
+ const user = await this.userService.getOrCreateUser(firebaseUser);
5896
+ if (!((_a = user.roles) == null ? void 0 : _a.includes("clinic_admin" /* CLINIC_ADMIN */))) {
5897
+ console.error("[AUTH] User is not a clinic admin:", user.uid);
5898
+ throw AUTH_ERRORS.INVALID_ROLE;
5899
+ }
5900
+ if (!user.adminProfile) {
5901
+ console.error("[AUTH] User has no admin profile:", user.uid);
5902
+ throw AUTH_ERRORS.NOT_FOUND;
5903
+ }
5904
+ const adminProfile = await clinicAdminService.getClinicAdmin(
5905
+ user.adminProfile
5906
+ );
5907
+ if (!adminProfile) {
5908
+ console.error("[AUTH] Admin profile not found:", user.adminProfile);
5909
+ throw AUTH_ERRORS.NOT_FOUND;
5910
+ }
5911
+ const clinicGroup = await clinicGroupService.getClinicGroup(
5912
+ adminProfile.clinicGroupId
5913
+ );
5914
+ if (!clinicGroup) {
5915
+ console.error(
5916
+ "[AUTH] Clinic group not found:",
5917
+ adminProfile.clinicGroupId
5918
+ );
5919
+ throw AUTH_ERRORS.NOT_FOUND;
5920
+ }
5921
+ return {
5922
+ user,
5923
+ clinicAdmin: adminProfile,
5924
+ clinicGroup
5925
+ };
5926
+ } catch (error) {
5927
+ console.error("[AUTH] Error in signInClinicAdmin:", error);
5928
+ throw error;
5929
+ }
5930
+ }
5854
5931
  /**
5855
5932
  * Prijavljuje korisnika sa Facebook-om
5856
5933
  */
package/dist/index.mjs CHANGED
@@ -454,6 +454,12 @@ var AUTH_ERRORS = {
454
454
  "AUTH/INVALID_CREDENTIAL",
455
455
  401
456
456
  ),
457
+ // Resource not found
458
+ NOT_FOUND: new AuthError(
459
+ "The requested resource was not found",
460
+ "AUTH/NOT_FOUND",
461
+ 404
462
+ ),
457
463
  // Detailed password validation errors
458
464
  PASSWORD_LENGTH_ERROR: new AuthError(
459
465
  "Password must be at least 8 characters long",
@@ -5800,6 +5806,77 @@ var AuthService = class extends BaseService {
5800
5806
  );
5801
5807
  return this.userService.getOrCreateUser(firebaseUser);
5802
5808
  }
5809
+ /**
5810
+ * Prijavljuje korisnika sa email-om i lozinkom samo za clinic_admin role
5811
+ * @param email - Email korisnika
5812
+ * @param password - Lozinka korisnika
5813
+ * @returns Objekat koji sadrži korisnika, admin profil i grupu klinika
5814
+ * @throws {AUTH_ERRORS.INVALID_ROLE} Ako korisnik nema clinic_admin rolu
5815
+ * @throws {AUTH_ERRORS.NOT_FOUND} Ako admin profil nije pronađen
5816
+ */
5817
+ async signInClinicAdmin(email, password) {
5818
+ var _a;
5819
+ try {
5820
+ const clinicAdminService = new ClinicAdminService(
5821
+ this.db,
5822
+ this.auth,
5823
+ this.app
5824
+ );
5825
+ const clinicGroupService = new ClinicGroupService(
5826
+ this.db,
5827
+ this.auth,
5828
+ this.app,
5829
+ clinicAdminService
5830
+ );
5831
+ const clinicService = new ClinicService(
5832
+ this.db,
5833
+ this.auth,
5834
+ this.app,
5835
+ clinicGroupService,
5836
+ clinicAdminService
5837
+ );
5838
+ clinicAdminService.setServices(clinicGroupService, clinicService);
5839
+ const { user: firebaseUser } = await signInWithEmailAndPassword(
5840
+ this.auth,
5841
+ email,
5842
+ password
5843
+ );
5844
+ const user = await this.userService.getOrCreateUser(firebaseUser);
5845
+ if (!((_a = user.roles) == null ? void 0 : _a.includes("clinic_admin" /* CLINIC_ADMIN */))) {
5846
+ console.error("[AUTH] User is not a clinic admin:", user.uid);
5847
+ throw AUTH_ERRORS.INVALID_ROLE;
5848
+ }
5849
+ if (!user.adminProfile) {
5850
+ console.error("[AUTH] User has no admin profile:", user.uid);
5851
+ throw AUTH_ERRORS.NOT_FOUND;
5852
+ }
5853
+ const adminProfile = await clinicAdminService.getClinicAdmin(
5854
+ user.adminProfile
5855
+ );
5856
+ if (!adminProfile) {
5857
+ console.error("[AUTH] Admin profile not found:", user.adminProfile);
5858
+ throw AUTH_ERRORS.NOT_FOUND;
5859
+ }
5860
+ const clinicGroup = await clinicGroupService.getClinicGroup(
5861
+ adminProfile.clinicGroupId
5862
+ );
5863
+ if (!clinicGroup) {
5864
+ console.error(
5865
+ "[AUTH] Clinic group not found:",
5866
+ adminProfile.clinicGroupId
5867
+ );
5868
+ throw AUTH_ERRORS.NOT_FOUND;
5869
+ }
5870
+ return {
5871
+ user,
5872
+ clinicAdmin: adminProfile,
5873
+ clinicGroup
5874
+ };
5875
+ } catch (error) {
5876
+ console.error("[AUTH] Error in signInClinicAdmin:", error);
5877
+ throw error;
5878
+ }
5879
+ }
5803
5880
  /**
5804
5881
  * Prijavljuje korisnika sa Facebook-om
5805
5882
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.5.3",
4
+ "version": "1.5.4",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -8,14 +8,12 @@ import {
8
8
  updateDoc,
9
9
  where,
10
10
  } from "firebase/firestore";
11
- import { Brand } from "../types/brand.types";
11
+ import { Brand, BRANDS_COLLECTION } from "../types/brand.types";
12
12
  import { BaseService } from "../../services/base.service";
13
13
 
14
- const COLLECTION = "backoffice_brands";
15
-
16
14
  export class BrandService extends BaseService {
17
15
  private get brandsRef() {
18
- return collection(this.db, COLLECTION);
16
+ return collection(this.db, BRANDS_COLLECTION);
19
17
  }
20
18
 
21
19
  async create(brand: Omit<Brand, "id" | "createdAt" | "updatedAt">) {
@@ -8,15 +8,10 @@ import {
8
8
  updateDoc,
9
9
  where,
10
10
  } from "firebase/firestore";
11
- import { Category } from "../types/category.types";
11
+ import { Category, CATEGORIES_COLLECTION } from "../types/category.types";
12
12
  import { BaseService } from "../../services/base.service";
13
13
  import { ProcedureFamily } from "../types/static/procedure-family.types";
14
14
 
15
- /**
16
- * Kolekcija u Firestore bazi gde se čuvaju kategorije
17
- */
18
- const COLLECTION = "backoffice_categories";
19
-
20
15
  /**
21
16
  * Servis za upravljanje kategorijama procedura.
22
17
  * Kategorije su prvi nivo organizacije nakon procedure family (aesthetics/surgery).
@@ -35,7 +30,7 @@ export class CategoryService extends BaseService {
35
30
  * Referenca na Firestore kolekciju kategorija
36
31
  */
37
32
  private get categoriesRef() {
38
- return collection(this.db, COLLECTION);
33
+ return collection(this.db, CATEGORIES_COLLECTION);
39
34
  }
40
35
 
41
36
  /**
@@ -9,14 +9,12 @@ import {
9
9
  updateDoc,
10
10
  where,
11
11
  } from "firebase/firestore";
12
- import { Product } from "../types/product.types";
12
+ import { Product, PRODUCTS_COLLECTION } from "../types/product.types";
13
13
  import { BaseService } from "../../services/base.service";
14
-
15
- const CATEGORIES_COLLECTION = "backoffice_categories";
16
- const SUBCATEGORIES_COLLECTION = "subcategories";
17
- const TECHNOLOGIES_COLLECTION = "technologies";
18
- const PRODUCTS_COLLECTION = "products";
19
- const BRANDS_COLLECTION = "backoffice_brands";
14
+ import { CATEGORIES_COLLECTION } from "../types/category.types";
15
+ import { BRANDS_COLLECTION } from "../types/brand.types";
16
+ import { SUBCATEGORIES_COLLECTION } from "../types/subcategory.types";
17
+ import { TECHNOLOGIES_COLLECTION } from "../types/technology.types";
20
18
 
21
19
  export class ProductService extends BaseService {
22
20
  private getProductsRefByTechnology(