@blackcode_sa/metaestetics-api 1.11.1 → 1.11.2

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 (36) hide show
  1. package/dist/admin/index.d.mts +324 -330
  2. package/dist/admin/index.d.ts +324 -330
  3. package/dist/backoffice/index.d.mts +67 -283
  4. package/dist/backoffice/index.d.ts +67 -283
  5. package/dist/backoffice/index.js +6 -114
  6. package/dist/backoffice/index.mjs +6 -112
  7. package/dist/index.d.mts +3037 -3100
  8. package/dist/index.d.ts +3037 -3100
  9. package/dist/index.js +129 -379
  10. package/dist/index.mjs +130 -379
  11. package/package.json +1 -1
  12. package/src/backoffice/expo-safe/index.ts +0 -2
  13. package/src/backoffice/services/__tests__/brand.service.test.ts +196 -0
  14. package/src/backoffice/services/__tests__/category.service.test.ts +201 -0
  15. package/src/backoffice/services/__tests__/product.service.test.ts +358 -0
  16. package/src/backoffice/services/__tests__/requirement.service.test.ts +226 -0
  17. package/src/backoffice/services/__tests__/subcategory.service.test.ts +181 -0
  18. package/src/backoffice/services/__tests__/technology.service.test.ts +1097 -0
  19. package/src/backoffice/services/technology.service.ts +10 -122
  20. package/src/backoffice/types/index.ts +0 -1
  21. package/src/backoffice/types/product.types.ts +1 -3
  22. package/src/backoffice/types/technology.types.ts +4 -4
  23. package/src/backoffice/validations/schemas.ts +9 -35
  24. package/src/services/appointment/appointment.service.ts +5 -0
  25. package/src/services/appointment/utils/appointment.utils.ts +113 -124
  26. package/src/services/procedure/procedure.service.ts +234 -434
  27. package/src/types/appointment/index.ts +37 -43
  28. package/src/types/clinic/index.ts +6 -1
  29. package/src/types/patient/medical-info.types.ts +3 -3
  30. package/src/types/procedure/index.ts +17 -20
  31. package/src/validations/appointment.schema.ts +118 -170
  32. package/src/validations/clinic.schema.ts +6 -1
  33. package/src/validations/patient/medical-info.schema.ts +2 -7
  34. package/src/backoffice/services/README.md +0 -40
  35. package/src/backoffice/services/constants.service.ts +0 -268
  36. package/src/backoffice/types/admin-constants.types.ts +0 -69
@@ -79,7 +79,6 @@ __export(index_exports, {
79
79
  certificationLevelSchema: () => certificationLevelSchema,
80
80
  certificationRequirementSchema: () => certificationRequirementSchema,
81
81
  certificationSpecialtySchema: () => certificationSpecialtySchema,
82
- contraindicationDynamicSchema: () => contraindicationDynamicSchema,
83
82
  contraindicationSchemaBackoffice: () => contraindicationSchemaBackoffice,
84
83
  createDocumentTemplateSchema: () => createDocumentTemplateSchema,
85
84
  documentElementSchema: () => documentElementSchema,
@@ -96,7 +95,6 @@ __export(index_exports, {
96
95
  technologyUpdateSchema: () => technologyUpdateSchema,
97
96
  timeUnitSchemaBackoffice: () => timeUnitSchemaBackoffice,
98
97
  timeframeSchema: () => timeframeSchema,
99
- treatmentBenefitDynamicSchema: () => treatmentBenefitDynamicSchema,
100
98
  treatmentBenefitSchemaBackoffice: () => treatmentBenefitSchemaBackoffice,
101
99
  updateDocumentTemplateSchema: () => updateDocumentTemplateSchema
102
100
  });
@@ -1511,16 +1509,8 @@ var TechnologyService = class extends BaseService {
1511
1509
  */
1512
1510
  async addContraindication(technologyId, contraindication) {
1513
1511
  const docRef = (0, import_firestore10.doc)(this.getTechnologiesRef(), technologyId);
1514
- const technology = await this.getById(technologyId);
1515
- if (!technology) {
1516
- throw new Error(`Technology with id ${technologyId} not found`);
1517
- }
1518
- const existingContraindications = technology.contraindications || [];
1519
- if (existingContraindications.some((c) => c.id === contraindication.id)) {
1520
- return technology;
1521
- }
1522
1512
  await (0, import_firestore10.updateDoc)(docRef, {
1523
- contraindications: [...existingContraindications, contraindication],
1513
+ contraindications: (0, import_firestore10.arrayUnion)(contraindication),
1524
1514
  updatedAt: /* @__PURE__ */ new Date()
1525
1515
  });
1526
1516
  return this.getById(technologyId);
@@ -1533,44 +1523,8 @@ var TechnologyService = class extends BaseService {
1533
1523
  */
1534
1524
  async removeContraindication(technologyId, contraindication) {
1535
1525
  const docRef = (0, import_firestore10.doc)(this.getTechnologiesRef(), technologyId);
1536
- const technology = await this.getById(technologyId);
1537
- if (!technology) {
1538
- throw new Error(`Technology with id ${technologyId} not found`);
1539
- }
1540
- const updatedContraindications = (technology.contraindications || []).filter((c) => c.id !== contraindication.id);
1541
- await (0, import_firestore10.updateDoc)(docRef, {
1542
- contraindications: updatedContraindications,
1543
- updatedAt: /* @__PURE__ */ new Date()
1544
- });
1545
- return this.getById(technologyId);
1546
- }
1547
- /**
1548
- * Updates an existing contraindication in a technology's list.
1549
- * If the contraindication does not exist, it will not be added.
1550
- * @param technologyId - ID of the technology
1551
- * @param contraindication - The updated contraindication object
1552
- * @returns The updated technology
1553
- */
1554
- async updateContraindication(technologyId, contraindication) {
1555
- const docRef = (0, import_firestore10.doc)(this.getTechnologiesRef(), technologyId);
1556
- const technology = await this.getById(technologyId);
1557
- if (!technology) {
1558
- throw new Error(`Technology with id ${technologyId} not found`);
1559
- }
1560
- const contraindications = technology.contraindications || [];
1561
- const index = contraindications.findIndex(
1562
- (c) => c.id === contraindication.id
1563
- );
1564
- if (index === -1) {
1565
- console.warn(
1566
- `Contraindication with id ${contraindication.id} not found for technology ${technologyId}. No update performed.`
1567
- );
1568
- return technology;
1569
- }
1570
- const updatedContraindications = [...contraindications];
1571
- updatedContraindications[index] = contraindication;
1572
1526
  await (0, import_firestore10.updateDoc)(docRef, {
1573
- contraindications: updatedContraindications,
1527
+ contraindications: (0, import_firestore10.arrayRemove)(contraindication),
1574
1528
  updatedAt: /* @__PURE__ */ new Date()
1575
1529
  });
1576
1530
  return this.getById(technologyId);
@@ -1583,16 +1537,8 @@ var TechnologyService = class extends BaseService {
1583
1537
  */
1584
1538
  async addBenefit(technologyId, benefit) {
1585
1539
  const docRef = (0, import_firestore10.doc)(this.getTechnologiesRef(), technologyId);
1586
- const technology = await this.getById(technologyId);
1587
- if (!technology) {
1588
- throw new Error(`Technology with id ${technologyId} not found`);
1589
- }
1590
- const existingBenefits = technology.benefits || [];
1591
- if (existingBenefits.some((b) => b.id === benefit.id)) {
1592
- return technology;
1593
- }
1594
1540
  await (0, import_firestore10.updateDoc)(docRef, {
1595
- benefits: [...existingBenefits, benefit],
1541
+ benefits: (0, import_firestore10.arrayUnion)(benefit),
1596
1542
  updatedAt: /* @__PURE__ */ new Date()
1597
1543
  });
1598
1544
  return this.getById(technologyId);
@@ -1605,44 +1551,8 @@ var TechnologyService = class extends BaseService {
1605
1551
  */
1606
1552
  async removeBenefit(technologyId, benefit) {
1607
1553
  const docRef = (0, import_firestore10.doc)(this.getTechnologiesRef(), technologyId);
1608
- const technology = await this.getById(technologyId);
1609
- if (!technology) {
1610
- throw new Error(`Technology with id ${technologyId} not found`);
1611
- }
1612
- const updatedBenefits = (technology.benefits || []).filter(
1613
- (b) => b.id !== benefit.id
1614
- );
1615
- await (0, import_firestore10.updateDoc)(docRef, {
1616
- benefits: updatedBenefits,
1617
- updatedAt: /* @__PURE__ */ new Date()
1618
- });
1619
- return this.getById(technologyId);
1620
- }
1621
- /**
1622
- * Updates an existing benefit in a technology's list.
1623
- * If the benefit does not exist, it will not be added.
1624
- * @param technologyId - ID of the technology
1625
- * @param benefit - The updated benefit object
1626
- * @returns The updated technology
1627
- */
1628
- async updateBenefit(technologyId, benefit) {
1629
- const docRef = (0, import_firestore10.doc)(this.getTechnologiesRef(), technologyId);
1630
- const technology = await this.getById(technologyId);
1631
- if (!technology) {
1632
- throw new Error(`Technology with id ${technologyId} not found`);
1633
- }
1634
- const benefits = technology.benefits || [];
1635
- const index = benefits.findIndex((b) => b.id === benefit.id);
1636
- if (index === -1) {
1637
- console.warn(
1638
- `Benefit with id ${benefit.id} not found for technology ${technologyId}. No update performed.`
1639
- );
1640
- return technology;
1641
- }
1642
- const updatedBenefits = [...benefits];
1643
- updatedBenefits[index] = benefit;
1644
1554
  await (0, import_firestore10.updateDoc)(docRef, {
1645
- benefits: updatedBenefits,
1555
+ benefits: (0, import_firestore10.arrayRemove)(benefit),
1646
1556
  updatedAt: /* @__PURE__ */ new Date()
1647
1557
  });
1648
1558
  return this.getById(technologyId);
@@ -1866,25 +1776,9 @@ var TreatmentBenefit = /* @__PURE__ */ ((TreatmentBenefit2) => {
1866
1776
 
1867
1777
  // src/backoffice/validations/schemas.ts
1868
1778
  var import_zod2 = require("zod");
1869
- var contraindicationDynamicSchema = import_zod2.z.object({
1870
- id: import_zod2.z.string().min(1, "Contraindication ID is required").regex(
1871
- /^[a-z0-9_]+$/,
1872
- "ID must be in snake_case (lowercase, numbers, and underscores only)"
1873
- ),
1874
- name: import_zod2.z.string().min(1, "Contraindication name is required"),
1875
- description: import_zod2.z.string().optional()
1876
- });
1877
- var treatmentBenefitDynamicSchema = import_zod2.z.object({
1878
- id: import_zod2.z.string().min(1, "Benefit ID is required").regex(
1879
- /^[a-z0-9_]+$/,
1880
- "ID must be in snake_case (lowercase, numbers, and underscores only)"
1881
- ),
1882
- name: import_zod2.z.string().min(1, "Benefit name is required"),
1883
- description: import_zod2.z.string().optional()
1884
- });
1885
1779
  var blockingConditionSchemaBackoffice = import_zod2.z.nativeEnum(BlockingCondition);
1886
- var contraindicationSchemaBackoffice = contraindicationDynamicSchema;
1887
- var treatmentBenefitSchemaBackoffice = treatmentBenefitDynamicSchema;
1780
+ var contraindicationSchemaBackoffice = import_zod2.z.nativeEnum(Contraindication);
1781
+ var treatmentBenefitSchemaBackoffice = import_zod2.z.nativeEnum(TreatmentBenefit);
1888
1782
  var procedureFamilySchemaBackoffice = import_zod2.z.nativeEnum(ProcedureFamily);
1889
1783
  var timeUnitSchemaBackoffice = import_zod2.z.nativeEnum(TimeUnit);
1890
1784
  var requirementTypeSchema = import_zod2.z.nativeEnum(RequirementType);
@@ -2154,7 +2048,6 @@ var InvalidTreatmentBenefitError = class extends TreatmentBenefitError {
2154
2048
  certificationLevelSchema,
2155
2049
  certificationRequirementSchema,
2156
2050
  certificationSpecialtySchema,
2157
- contraindicationDynamicSchema,
2158
2051
  contraindicationSchemaBackoffice,
2159
2052
  createDocumentTemplateSchema,
2160
2053
  documentElementSchema,
@@ -2171,7 +2064,6 @@ var InvalidTreatmentBenefitError = class extends TreatmentBenefitError {
2171
2064
  technologyUpdateSchema,
2172
2065
  timeUnitSchemaBackoffice,
2173
2066
  timeframeSchema,
2174
- treatmentBenefitDynamicSchema,
2175
2067
  treatmentBenefitSchemaBackoffice,
2176
2068
  updateDocumentTemplateSchema
2177
2069
  });
@@ -1505,16 +1505,8 @@ var TechnologyService = class extends BaseService {
1505
1505
  */
1506
1506
  async addContraindication(technologyId, contraindication) {
1507
1507
  const docRef = doc9(this.getTechnologiesRef(), technologyId);
1508
- const technology = await this.getById(technologyId);
1509
- if (!technology) {
1510
- throw new Error(`Technology with id ${technologyId} not found`);
1511
- }
1512
- const existingContraindications = technology.contraindications || [];
1513
- if (existingContraindications.some((c) => c.id === contraindication.id)) {
1514
- return technology;
1515
- }
1516
1508
  await updateDoc9(docRef, {
1517
- contraindications: [...existingContraindications, contraindication],
1509
+ contraindications: arrayUnion(contraindication),
1518
1510
  updatedAt: /* @__PURE__ */ new Date()
1519
1511
  });
1520
1512
  return this.getById(technologyId);
@@ -1527,44 +1519,8 @@ var TechnologyService = class extends BaseService {
1527
1519
  */
1528
1520
  async removeContraindication(technologyId, contraindication) {
1529
1521
  const docRef = doc9(this.getTechnologiesRef(), technologyId);
1530
- const technology = await this.getById(technologyId);
1531
- if (!technology) {
1532
- throw new Error(`Technology with id ${technologyId} not found`);
1533
- }
1534
- const updatedContraindications = (technology.contraindications || []).filter((c) => c.id !== contraindication.id);
1535
- await updateDoc9(docRef, {
1536
- contraindications: updatedContraindications,
1537
- updatedAt: /* @__PURE__ */ new Date()
1538
- });
1539
- return this.getById(technologyId);
1540
- }
1541
- /**
1542
- * Updates an existing contraindication in a technology's list.
1543
- * If the contraindication does not exist, it will not be added.
1544
- * @param technologyId - ID of the technology
1545
- * @param contraindication - The updated contraindication object
1546
- * @returns The updated technology
1547
- */
1548
- async updateContraindication(technologyId, contraindication) {
1549
- const docRef = doc9(this.getTechnologiesRef(), technologyId);
1550
- const technology = await this.getById(technologyId);
1551
- if (!technology) {
1552
- throw new Error(`Technology with id ${technologyId} not found`);
1553
- }
1554
- const contraindications = technology.contraindications || [];
1555
- const index = contraindications.findIndex(
1556
- (c) => c.id === contraindication.id
1557
- );
1558
- if (index === -1) {
1559
- console.warn(
1560
- `Contraindication with id ${contraindication.id} not found for technology ${technologyId}. No update performed.`
1561
- );
1562
- return technology;
1563
- }
1564
- const updatedContraindications = [...contraindications];
1565
- updatedContraindications[index] = contraindication;
1566
1522
  await updateDoc9(docRef, {
1567
- contraindications: updatedContraindications,
1523
+ contraindications: arrayRemove(contraindication),
1568
1524
  updatedAt: /* @__PURE__ */ new Date()
1569
1525
  });
1570
1526
  return this.getById(technologyId);
@@ -1577,16 +1533,8 @@ var TechnologyService = class extends BaseService {
1577
1533
  */
1578
1534
  async addBenefit(technologyId, benefit) {
1579
1535
  const docRef = doc9(this.getTechnologiesRef(), technologyId);
1580
- const technology = await this.getById(technologyId);
1581
- if (!technology) {
1582
- throw new Error(`Technology with id ${technologyId} not found`);
1583
- }
1584
- const existingBenefits = technology.benefits || [];
1585
- if (existingBenefits.some((b) => b.id === benefit.id)) {
1586
- return technology;
1587
- }
1588
1536
  await updateDoc9(docRef, {
1589
- benefits: [...existingBenefits, benefit],
1537
+ benefits: arrayUnion(benefit),
1590
1538
  updatedAt: /* @__PURE__ */ new Date()
1591
1539
  });
1592
1540
  return this.getById(technologyId);
@@ -1599,44 +1547,8 @@ var TechnologyService = class extends BaseService {
1599
1547
  */
1600
1548
  async removeBenefit(technologyId, benefit) {
1601
1549
  const docRef = doc9(this.getTechnologiesRef(), technologyId);
1602
- const technology = await this.getById(technologyId);
1603
- if (!technology) {
1604
- throw new Error(`Technology with id ${technologyId} not found`);
1605
- }
1606
- const updatedBenefits = (technology.benefits || []).filter(
1607
- (b) => b.id !== benefit.id
1608
- );
1609
- await updateDoc9(docRef, {
1610
- benefits: updatedBenefits,
1611
- updatedAt: /* @__PURE__ */ new Date()
1612
- });
1613
- return this.getById(technologyId);
1614
- }
1615
- /**
1616
- * Updates an existing benefit in a technology's list.
1617
- * If the benefit does not exist, it will not be added.
1618
- * @param technologyId - ID of the technology
1619
- * @param benefit - The updated benefit object
1620
- * @returns The updated technology
1621
- */
1622
- async updateBenefit(technologyId, benefit) {
1623
- const docRef = doc9(this.getTechnologiesRef(), technologyId);
1624
- const technology = await this.getById(technologyId);
1625
- if (!technology) {
1626
- throw new Error(`Technology with id ${technologyId} not found`);
1627
- }
1628
- const benefits = technology.benefits || [];
1629
- const index = benefits.findIndex((b) => b.id === benefit.id);
1630
- if (index === -1) {
1631
- console.warn(
1632
- `Benefit with id ${benefit.id} not found for technology ${technologyId}. No update performed.`
1633
- );
1634
- return technology;
1635
- }
1636
- const updatedBenefits = [...benefits];
1637
- updatedBenefits[index] = benefit;
1638
1550
  await updateDoc9(docRef, {
1639
- benefits: updatedBenefits,
1551
+ benefits: arrayRemove(benefit),
1640
1552
  updatedAt: /* @__PURE__ */ new Date()
1641
1553
  });
1642
1554
  return this.getById(technologyId);
@@ -1860,25 +1772,9 @@ var TreatmentBenefit = /* @__PURE__ */ ((TreatmentBenefit2) => {
1860
1772
 
1861
1773
  // src/backoffice/validations/schemas.ts
1862
1774
  import { z as z2 } from "zod";
1863
- var contraindicationDynamicSchema = z2.object({
1864
- id: z2.string().min(1, "Contraindication ID is required").regex(
1865
- /^[a-z0-9_]+$/,
1866
- "ID must be in snake_case (lowercase, numbers, and underscores only)"
1867
- ),
1868
- name: z2.string().min(1, "Contraindication name is required"),
1869
- description: z2.string().optional()
1870
- });
1871
- var treatmentBenefitDynamicSchema = z2.object({
1872
- id: z2.string().min(1, "Benefit ID is required").regex(
1873
- /^[a-z0-9_]+$/,
1874
- "ID must be in snake_case (lowercase, numbers, and underscores only)"
1875
- ),
1876
- name: z2.string().min(1, "Benefit name is required"),
1877
- description: z2.string().optional()
1878
- });
1879
1775
  var blockingConditionSchemaBackoffice = z2.nativeEnum(BlockingCondition);
1880
- var contraindicationSchemaBackoffice = contraindicationDynamicSchema;
1881
- var treatmentBenefitSchemaBackoffice = treatmentBenefitDynamicSchema;
1776
+ var contraindicationSchemaBackoffice = z2.nativeEnum(Contraindication);
1777
+ var treatmentBenefitSchemaBackoffice = z2.nativeEnum(TreatmentBenefit);
1882
1778
  var procedureFamilySchemaBackoffice = z2.nativeEnum(ProcedureFamily);
1883
1779
  var timeUnitSchemaBackoffice = z2.nativeEnum(TimeUnit);
1884
1780
  var requirementTypeSchema = z2.nativeEnum(RequirementType);
@@ -2147,7 +2043,6 @@ export {
2147
2043
  certificationLevelSchema,
2148
2044
  certificationRequirementSchema,
2149
2045
  certificationSpecialtySchema,
2150
- contraindicationDynamicSchema,
2151
2046
  contraindicationSchemaBackoffice,
2152
2047
  createDocumentTemplateSchema,
2153
2048
  documentElementSchema,
@@ -2164,7 +2059,6 @@ export {
2164
2059
  technologyUpdateSchema,
2165
2060
  timeUnitSchemaBackoffice,
2166
2061
  timeframeSchema,
2167
- treatmentBenefitDynamicSchema,
2168
2062
  treatmentBenefitSchemaBackoffice,
2169
2063
  updateDocumentTemplateSchema
2170
2064
  };