@blackcode_sa/metaestetics-api 1.5.2 → 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 (32) 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 +30 -16
  6. package/dist/index.d.ts +30 -16
  7. package/dist/index.js +81 -1
  8. package/dist/index.mjs +81 -1
  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/index.ts +3 -3
  30. package/src/types/procedure/index.ts +104 -0
  31. package/src/validations/procedure.schema.ts +58 -0
  32. package/src/validations/schemas.ts +9 -3
@@ -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 */
@@ -3658,9 +3658,9 @@ interface User {
3658
3658
  email: string | null;
3659
3659
  roles: UserRole[];
3660
3660
  isAnonymous: boolean;
3661
- createdAt: Timestamp;
3662
- updatedAt: Timestamp;
3663
- lastLoginAt: Timestamp;
3661
+ createdAt: Timestamp | FieldValue;
3662
+ updatedAt: Timestamp | FieldValue;
3663
+ lastLoginAt: Timestamp | FieldValue;
3664
3664
  patientProfile?: string;
3665
3665
  practitionerProfile?: string;
3666
3666
  adminProfile?: string;
@@ -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;
@@ -5012,7 +5026,7 @@ declare const emailSchema: z.ZodString;
5012
5026
  declare const passwordSchema: z.ZodString;
5013
5027
  declare const userRoleSchema: z.ZodNativeEnum<typeof UserRole>;
5014
5028
  declare const userRolesSchema: z.ZodArray<z.ZodNativeEnum<typeof UserRole>, "many">;
5015
- declare const timestampSchema: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
5029
+ declare const timestampSchema: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
5016
5030
  /**
5017
5031
  * Validaciona šema za clinic admin opcije pri kreiranju
5018
5032
  */
@@ -5080,31 +5094,31 @@ declare const userSchema: z.ZodObject<{
5080
5094
  email: z.ZodNullable<z.ZodString>;
5081
5095
  roles: z.ZodArray<z.ZodNativeEnum<typeof UserRole>, "many">;
5082
5096
  isAnonymous: z.ZodBoolean;
5083
- createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
5084
- updatedAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
5085
- lastLoginAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
5097
+ createdAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
5098
+ updatedAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
5099
+ lastLoginAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
5086
5100
  patientProfile: z.ZodOptional<z.ZodString>;
5087
5101
  practitionerProfile: z.ZodOptional<z.ZodString>;
5088
5102
  adminProfile: z.ZodOptional<z.ZodString>;
5089
5103
  }, "strip", z.ZodTypeAny, {
5090
- updatedAt: Timestamp;
5104
+ updatedAt: Timestamp | FieldValue;
5091
5105
  email: string | null;
5092
- createdAt: Timestamp;
5106
+ createdAt: Timestamp | FieldValue;
5093
5107
  uid: string;
5094
5108
  roles: UserRole[];
5095
5109
  isAnonymous: boolean;
5096
- lastLoginAt: Timestamp;
5110
+ lastLoginAt: Timestamp | FieldValue;
5097
5111
  patientProfile?: string | undefined;
5098
5112
  practitionerProfile?: string | undefined;
5099
5113
  adminProfile?: string | undefined;
5100
5114
  }, {
5101
- updatedAt: Timestamp;
5115
+ updatedAt: Timestamp | FieldValue;
5102
5116
  email: string | null;
5103
- createdAt: Timestamp;
5117
+ createdAt: Timestamp | FieldValue;
5104
5118
  uid: string;
5105
5119
  roles: UserRole[];
5106
5120
  isAnonymous: boolean;
5107
- lastLoginAt: Timestamp;
5121
+ lastLoginAt: Timestamp | FieldValue;
5108
5122
  patientProfile?: string | undefined;
5109
5123
  practitionerProfile?: string | undefined;
5110
5124
  adminProfile?: string | undefined;
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 */
@@ -3658,9 +3658,9 @@ interface User {
3658
3658
  email: string | null;
3659
3659
  roles: UserRole[];
3660
3660
  isAnonymous: boolean;
3661
- createdAt: Timestamp;
3662
- updatedAt: Timestamp;
3663
- lastLoginAt: Timestamp;
3661
+ createdAt: Timestamp | FieldValue;
3662
+ updatedAt: Timestamp | FieldValue;
3663
+ lastLoginAt: Timestamp | FieldValue;
3664
3664
  patientProfile?: string;
3665
3665
  practitionerProfile?: string;
3666
3666
  adminProfile?: string;
@@ -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;
@@ -5012,7 +5026,7 @@ declare const emailSchema: z.ZodString;
5012
5026
  declare const passwordSchema: z.ZodString;
5013
5027
  declare const userRoleSchema: z.ZodNativeEnum<typeof UserRole>;
5014
5028
  declare const userRolesSchema: z.ZodArray<z.ZodNativeEnum<typeof UserRole>, "many">;
5015
- declare const timestampSchema: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
5029
+ declare const timestampSchema: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
5016
5030
  /**
5017
5031
  * Validaciona šema za clinic admin opcije pri kreiranju
5018
5032
  */
@@ -5080,31 +5094,31 @@ declare const userSchema: z.ZodObject<{
5080
5094
  email: z.ZodNullable<z.ZodString>;
5081
5095
  roles: z.ZodArray<z.ZodNativeEnum<typeof UserRole>, "many">;
5082
5096
  isAnonymous: z.ZodBoolean;
5083
- createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
5084
- updatedAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
5085
- lastLoginAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
5097
+ createdAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
5098
+ updatedAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
5099
+ lastLoginAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
5086
5100
  patientProfile: z.ZodOptional<z.ZodString>;
5087
5101
  practitionerProfile: z.ZodOptional<z.ZodString>;
5088
5102
  adminProfile: z.ZodOptional<z.ZodString>;
5089
5103
  }, "strip", z.ZodTypeAny, {
5090
- updatedAt: Timestamp;
5104
+ updatedAt: Timestamp | FieldValue;
5091
5105
  email: string | null;
5092
- createdAt: Timestamp;
5106
+ createdAt: Timestamp | FieldValue;
5093
5107
  uid: string;
5094
5108
  roles: UserRole[];
5095
5109
  isAnonymous: boolean;
5096
- lastLoginAt: Timestamp;
5110
+ lastLoginAt: Timestamp | FieldValue;
5097
5111
  patientProfile?: string | undefined;
5098
5112
  practitionerProfile?: string | undefined;
5099
5113
  adminProfile?: string | undefined;
5100
5114
  }, {
5101
- updatedAt: Timestamp;
5115
+ updatedAt: Timestamp | FieldValue;
5102
5116
  email: string | null;
5103
- createdAt: Timestamp;
5117
+ createdAt: Timestamp | FieldValue;
5104
5118
  uid: string;
5105
5119
  roles: UserRole[];
5106
5120
  isAnonymous: boolean;
5107
- lastLoginAt: Timestamp;
5121
+ lastLoginAt: Timestamp | FieldValue;
5108
5122
  patientProfile?: string | undefined;
5109
5123
  practitionerProfile?: string | undefined;
5110
5124
  adminProfile?: string | undefined;
package/dist/index.js CHANGED
@@ -460,8 +460,11 @@ var passwordSchema = import_zod2.z.string().min(8, "Password must be at least 8
460
460
  var userRoleSchema = import_zod2.z.nativeEnum(UserRole);
461
461
  var userRolesSchema = import_zod2.z.array(userRoleSchema).min(1, "User must have at least one role").max(3, "User cannot have more than 3 roles");
462
462
  var timestampSchema = import_zod2.z.custom((data) => {
463
+ if (data && typeof data === "object" && "isEqual" in data) {
464
+ return true;
465
+ }
463
466
  return data && typeof data === "object" && "toDate" in data && "seconds" in data && "nanoseconds" in data;
464
- }, "Must be a Timestamp object");
467
+ }, "Must be a Timestamp object or serverTimestamp");
465
468
  var clinicAdminOptionsSchema = import_zod2.z.object({
466
469
  isGroupOwner: import_zod2.z.boolean(),
467
470
  groupToken: import_zod2.z.string().optional(),
@@ -623,6 +626,12 @@ var AUTH_ERRORS = {
623
626
  "AUTH/INVALID_CREDENTIAL",
624
627
  401
625
628
  ),
629
+ // Resource not found
630
+ NOT_FOUND: new AuthError(
631
+ "The requested resource was not found",
632
+ "AUTH/NOT_FOUND",
633
+ 404
634
+ ),
626
635
  // Detailed password validation errors
627
636
  PASSWORD_LENGTH_ERROR: new AuthError(
628
637
  "Password must be at least 8 characters long",
@@ -5848,6 +5857,77 @@ var AuthService = class extends BaseService {
5848
5857
  );
5849
5858
  return this.userService.getOrCreateUser(firebaseUser);
5850
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
+ }
5851
5931
  /**
5852
5932
  * Prijavljuje korisnika sa Facebook-om
5853
5933
  */