@blackcode_sa/metaestetics-api 1.12.40 → 1.12.42

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.
@@ -452,9 +452,10 @@ interface FilledDocumentFileValue {
452
452
  *
453
453
  * @property id - Unique identifier of the product
454
454
  * @property name - Name of the product
455
- * @property description - Detailed description of the product and its purpose
456
455
  * @property brandId - ID of the brand that manufactures this product
457
- * @property technologyId - ID of the technology this product is used with
456
+ * @property brandName - Name of the brand (denormalized for display)
457
+ * @property assignedTechnologyIds - Array of technology IDs this product is assigned to
458
+ * @property description - Detailed description of the product and its purpose
458
459
  * @property technicalDetails - Technical details and specifications
459
460
  * @property warnings - List of warnings related to product use
460
461
  * @property dosage - Dosage information (if applicable)
@@ -470,10 +471,7 @@ interface Product {
470
471
  name: string;
471
472
  brandId: string;
472
473
  brandName: string;
473
- technologyId: string;
474
- technologyName: string;
475
- categoryId: string;
476
- subcategoryId: string;
474
+ assignedTechnologyIds?: string[];
477
475
  createdAt: Date;
478
476
  updatedAt: Date;
479
477
  isActive: boolean;
@@ -484,6 +482,14 @@ interface Product {
484
482
  composition?: string;
485
483
  indications?: string[];
486
484
  contraindications?: ContraindicationDynamic[];
485
+ /** Present only in subcollections - synced from technology metadata */
486
+ technologyId?: string;
487
+ /** Present only in subcollections - synced from technology name */
488
+ technologyName?: string;
489
+ /** Present only in subcollections - synced from technology categoryId */
490
+ categoryId?: string;
491
+ /** Present only in subcollections - synced from technology subcategoryId */
492
+ subcategoryId?: string;
487
493
  }
488
494
 
489
495
  /**
@@ -452,9 +452,10 @@ interface FilledDocumentFileValue {
452
452
  *
453
453
  * @property id - Unique identifier of the product
454
454
  * @property name - Name of the product
455
- * @property description - Detailed description of the product and its purpose
456
455
  * @property brandId - ID of the brand that manufactures this product
457
- * @property technologyId - ID of the technology this product is used with
456
+ * @property brandName - Name of the brand (denormalized for display)
457
+ * @property assignedTechnologyIds - Array of technology IDs this product is assigned to
458
+ * @property description - Detailed description of the product and its purpose
458
459
  * @property technicalDetails - Technical details and specifications
459
460
  * @property warnings - List of warnings related to product use
460
461
  * @property dosage - Dosage information (if applicable)
@@ -470,10 +471,7 @@ interface Product {
470
471
  name: string;
471
472
  brandId: string;
472
473
  brandName: string;
473
- technologyId: string;
474
- technologyName: string;
475
- categoryId: string;
476
- subcategoryId: string;
474
+ assignedTechnologyIds?: string[];
477
475
  createdAt: Date;
478
476
  updatedAt: Date;
479
477
  isActive: boolean;
@@ -484,6 +482,14 @@ interface Product {
484
482
  composition?: string;
485
483
  indications?: string[];
486
484
  contraindications?: ContraindicationDynamic[];
485
+ /** Present only in subcollections - synced from technology metadata */
486
+ technologyId?: string;
487
+ /** Present only in subcollections - synced from technology name */
488
+ technologyName?: string;
489
+ /** Present only in subcollections - synced from technology categoryId */
490
+ categoryId?: string;
491
+ /** Present only in subcollections - synced from technology subcategoryId */
492
+ subcategoryId?: string;
487
493
  }
488
494
 
489
495
  /**
@@ -581,9 +581,10 @@ interface UpdateDocumentTemplateData {
581
581
  *
582
582
  * @property id - Unique identifier of the product
583
583
  * @property name - Name of the product
584
- * @property description - Detailed description of the product and its purpose
585
584
  * @property brandId - ID of the brand that manufactures this product
586
- * @property technologyId - ID of the technology this product is used with
585
+ * @property brandName - Name of the brand (denormalized for display)
586
+ * @property assignedTechnologyIds - Array of technology IDs this product is assigned to
587
+ * @property description - Detailed description of the product and its purpose
587
588
  * @property technicalDetails - Technical details and specifications
588
589
  * @property warnings - List of warnings related to product use
589
590
  * @property dosage - Dosage information (if applicable)
@@ -599,10 +600,7 @@ interface Product {
599
600
  name: string;
600
601
  brandId: string;
601
602
  brandName: string;
602
- technologyId: string;
603
- technologyName: string;
604
- categoryId: string;
605
- subcategoryId: string;
603
+ assignedTechnologyIds?: string[];
606
604
  createdAt: Date;
607
605
  updatedAt: Date;
608
606
  isActive: boolean;
@@ -613,6 +611,14 @@ interface Product {
613
611
  composition?: string;
614
612
  indications?: string[];
615
613
  contraindications?: ContraindicationDynamic[];
614
+ /** Present only in subcollections - synced from technology metadata */
615
+ technologyId?: string;
616
+ /** Present only in subcollections - synced from technology name */
617
+ technologyName?: string;
618
+ /** Present only in subcollections - synced from technology categoryId */
619
+ categoryId?: string;
620
+ /** Present only in subcollections - synced from technology subcategoryId */
621
+ subcategoryId?: string;
616
622
  }
617
623
  /**
618
624
  * Collection in Firestore database where products are stored
@@ -620,9 +626,75 @@ interface Product {
620
626
  declare const PRODUCTS_COLLECTION = "products";
621
627
  /**
622
628
  * Interface for the ProductService class
629
+ *
630
+ * NOTE: This interface maintains backward compatibility while adding new top-level collection methods.
631
+ * Old methods using technologyId are kept for existing code, new methods work with top-level collection.
623
632
  */
624
633
  interface IProductService {
625
634
  /**
635
+ * Creates a new product in the top-level collection
636
+ * @param brandId - ID of the brand that manufactures this product
637
+ * @param product - Product data
638
+ * @param technologyIds - Optional array of technology IDs to assign this product to
639
+ */
640
+ createTopLevel(brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'assignedTechnologyIds'>, technologyIds?: string[]): Promise<Product>;
641
+ /**
642
+ * Gets all products from the top-level collection
643
+ * @param options - Query options
644
+ */
645
+ getAllTopLevel(options: {
646
+ rowsPerPage: number;
647
+ lastVisible?: any;
648
+ brandId?: string;
649
+ }): Promise<{
650
+ products: Product[];
651
+ lastVisible: any;
652
+ }>;
653
+ /**
654
+ * Gets a product by ID from the top-level collection
655
+ * @param productId - ID of the product
656
+ */
657
+ getByIdTopLevel(productId: string): Promise<Product | null>;
658
+ /**
659
+ * Updates a product in the top-level collection
660
+ * @param productId - ID of the product to update
661
+ * @param product - Updated product data
662
+ */
663
+ updateTopLevel(productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId'>>): Promise<Product | null>;
664
+ /**
665
+ * Deletes a product from the top-level collection (soft delete)
666
+ * @param productId - ID of the product to delete
667
+ */
668
+ deleteTopLevel(productId: string): Promise<void>;
669
+ /**
670
+ * Assigns a product to a technology
671
+ * @param productId - ID of the product
672
+ * @param technologyId - ID of the technology
673
+ */
674
+ assignToTechnology(productId: string, technologyId: string): Promise<void>;
675
+ /**
676
+ * Unassigns a product from a technology
677
+ * @param productId - ID of the product
678
+ * @param technologyId - ID of the technology
679
+ */
680
+ unassignFromTechnology(productId: string, technologyId: string): Promise<void>;
681
+ /**
682
+ * Gets products assigned to a specific technology
683
+ * @param technologyId - ID of the technology
684
+ */
685
+ getAssignedProducts(technologyId: string): Promise<Product[]>;
686
+ /**
687
+ * Gets products NOT assigned to a specific technology
688
+ * @param technologyId - ID of the technology
689
+ */
690
+ getUnassignedProducts(technologyId: string): Promise<Product[]>;
691
+ /**
692
+ * Gets all products for a brand
693
+ * @param brandId - ID of the brand
694
+ */
695
+ getByBrand(brandId: string): Promise<Product[]>;
696
+ /**
697
+ * @deprecated Use createTopLevel instead
626
698
  * Creates a new product
627
699
  * @param technologyId - ID of the technology this product is used with
628
700
  * @param brandId - ID of the brand that manufactures this product
@@ -630,6 +702,7 @@ interface IProductService {
630
702
  */
631
703
  create(technologyId: string, brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'technologyId'>): Promise<Product>;
632
704
  /**
705
+ * @deprecated Use getAllTopLevel instead
633
706
  * Gets a paginated list of all products, with optional filters.
634
707
  */
635
708
  getAll(options: {
@@ -643,6 +716,7 @@ interface IProductService {
643
716
  lastVisible: any;
644
717
  }>;
645
718
  /**
719
+ * @deprecated Use alternative counting methods
646
720
  * Gets the total count of active products, with optional filters.
647
721
  */
648
722
  getProductsCount(options: {
@@ -651,6 +725,7 @@ interface IProductService {
651
725
  technologyId?: string;
652
726
  }): Promise<number>;
653
727
  /**
728
+ * @deprecated Use alternative counting methods
654
729
  * Gets counts of active products grouped by category, subcategory, and technology.
655
730
  */
656
731
  getProductCounts(): Promise<{
@@ -659,16 +734,19 @@ interface IProductService {
659
734
  byTechnology: Record<string, number>;
660
735
  }>;
661
736
  /**
737
+ * @deprecated Use getAssignedProducts instead
662
738
  * Gets all products for a specific technology (non-paginated, for filters/dropdowns)
663
739
  * @param technologyId - ID of the technology
664
740
  */
665
741
  getAllByTechnology(technologyId: string): Promise<Product[]>;
666
742
  /**
743
+ * @deprecated Use getByBrand instead
667
744
  * Gets all products for a brand
668
745
  * @param brandId - ID of the brand
669
746
  */
670
747
  getAllByBrand(brandId: string): Promise<Product[]>;
671
748
  /**
749
+ * @deprecated Use updateTopLevel instead
672
750
  * Updates a product
673
751
  * @param technologyId - ID of the technology
674
752
  * @param productId - ID of the product to update
@@ -676,12 +754,14 @@ interface IProductService {
676
754
  */
677
755
  update(technologyId: string, productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId' | 'technologyId'>>): Promise<Product | null>;
678
756
  /**
757
+ * @deprecated Use deleteTopLevel instead
679
758
  * Deletes a product (soft delete)
680
759
  * @param technologyId - ID of the technology
681
760
  * @param productId - ID of the product to delete
682
761
  */
683
762
  delete(technologyId: string, productId: string): Promise<void>;
684
763
  /**
764
+ * @deprecated Use getByIdTopLevel instead
685
765
  * Gets a product by ID
686
766
  * @param technologyId - ID of the technology
687
767
  * @param productId - ID of the product
@@ -1468,7 +1548,12 @@ declare class DocumentationTemplateServiceBackoffice {
1468
1548
 
1469
1549
  declare class ProductService extends BaseService implements IProductService {
1470
1550
  /**
1471
- * Gets reference to products collection under a technology
1551
+ * Gets reference to top-level products collection (source of truth)
1552
+ * @returns Firestore collection reference
1553
+ */
1554
+ private getTopLevelProductsRef;
1555
+ /**
1556
+ * Gets reference to products collection under a technology (backward compatibility)
1472
1557
  * @param technologyId - ID of the technology
1473
1558
  * @returns Firestore collection reference
1474
1559
  */
@@ -1501,7 +1586,7 @@ declare class ProductService extends BaseService implements IProductService {
1501
1586
  }): Promise<number>;
1502
1587
  /**
1503
1588
  * Gets counts of active products grouped by category, subcategory, and technology.
1504
- * This uses a single collectionGroup query for efficiency.
1589
+ * Queries technology subcollections which have the legacy fields synced by Cloud Functions.
1505
1590
  */
1506
1591
  getProductCounts(): Promise<{
1507
1592
  byCategory: Record<string, number>;
@@ -1528,6 +1613,53 @@ declare class ProductService extends BaseService implements IProductService {
1528
1613
  * Gets a product by ID
1529
1614
  */
1530
1615
  getById(technologyId: string, productId: string): Promise<Product | null>;
1616
+ /**
1617
+ * Creates a new product in the top-level collection
1618
+ */
1619
+ createTopLevel(brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'assignedTechnologyIds'>, technologyIds?: string[]): Promise<Product>;
1620
+ /**
1621
+ * Gets all products from the top-level collection
1622
+ */
1623
+ getAllTopLevel(options: {
1624
+ rowsPerPage: number;
1625
+ lastVisible?: any;
1626
+ brandId?: string;
1627
+ }): Promise<{
1628
+ products: Product[];
1629
+ lastVisible: any;
1630
+ }>;
1631
+ /**
1632
+ * Gets a product by ID from the top-level collection
1633
+ */
1634
+ getByIdTopLevel(productId: string): Promise<Product | null>;
1635
+ /**
1636
+ * Updates a product in the top-level collection
1637
+ */
1638
+ updateTopLevel(productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId'>>): Promise<Product | null>;
1639
+ /**
1640
+ * Deletes a product from the top-level collection (soft delete)
1641
+ */
1642
+ deleteTopLevel(productId: string): Promise<void>;
1643
+ /**
1644
+ * Assigns a product to a technology
1645
+ */
1646
+ assignToTechnology(productId: string, technologyId: string): Promise<void>;
1647
+ /**
1648
+ * Unassigns a product from a technology
1649
+ */
1650
+ unassignFromTechnology(productId: string, technologyId: string): Promise<void>;
1651
+ /**
1652
+ * Gets products assigned to a specific technology
1653
+ */
1654
+ getAssignedProducts(technologyId: string): Promise<Product[]>;
1655
+ /**
1656
+ * Gets products NOT assigned to a specific technology
1657
+ */
1658
+ getUnassignedProducts(technologyId: string): Promise<Product[]>;
1659
+ /**
1660
+ * Gets all products for a brand (from top-level collection)
1661
+ */
1662
+ getByBrand(brandId: string): Promise<Product[]>;
1531
1663
  }
1532
1664
 
1533
1665
  /**
@@ -1740,10 +1872,10 @@ declare class TechnologyService extends BaseService implements ITechnologyServic
1740
1872
  isActive: boolean;
1741
1873
  description: string;
1742
1874
  family: ProcedureFamily;
1743
- categoryId: string;
1744
- subcategoryId: string;
1745
1875
  technicalDetails?: string | undefined;
1746
1876
  contraindications: ContraindicationDynamic[];
1877
+ categoryId: string;
1878
+ subcategoryId: string;
1747
1879
  requirements: {
1748
1880
  pre: Requirement[];
1749
1881
  post: Requirement[];
@@ -2012,6 +2144,38 @@ declare class TechnologyService extends BaseService implements ITechnologyServic
2012
2144
  * Gets all active technologies for filter dropdowns.
2013
2145
  */
2014
2146
  getAllForFilter(): Promise<Technology[]>;
2147
+ /**
2148
+ * Assigns multiple products to a technology
2149
+ * Updates each product's assignedTechnologyIds array
2150
+ */
2151
+ assignProducts(technologyId: string, productIds: string[]): Promise<void>;
2152
+ /**
2153
+ * Unassigns multiple products from a technology
2154
+ * Updates each product's assignedTechnologyIds array
2155
+ */
2156
+ unassignProducts(technologyId: string, productIds: string[]): Promise<void>;
2157
+ /**
2158
+ * Gets products assigned to a specific technology
2159
+ * Reads from top-level collection for immediate consistency (Cloud Functions may lag)
2160
+ */
2161
+ getAssignedProducts(technologyId: string): Promise<Product[]>;
2162
+ /**
2163
+ * Gets products NOT assigned to a specific technology
2164
+ */
2165
+ getUnassignedProducts(technologyId: string): Promise<Product[]>;
2166
+ /**
2167
+ * Gets product assignment statistics for a technology
2168
+ */
2169
+ getProductStats(technologyId: string): Promise<{
2170
+ totalAssigned: number;
2171
+ byBrand: Record<string, number>;
2172
+ }>;
2173
+ /**
2174
+ * Updates products in technology subcollection when technology metadata changes
2175
+ * @param technologyId - ID of the technology
2176
+ * @param updates - Fields to update (categoryId, subcategoryId, technologyName)
2177
+ */
2178
+ private updateProductsInSubcollection;
2015
2179
  }
2016
2180
 
2017
2181
  /**
@@ -4825,13 +4989,13 @@ declare const technologySchema: z.ZodObject<{
4825
4989
  name: string;
4826
4990
  isActive: boolean;
4827
4991
  family: ProcedureFamily;
4828
- categoryId: string;
4829
- subcategoryId: string;
4830
4992
  contraindications: {
4831
4993
  id: string;
4832
4994
  name: string;
4833
4995
  description?: string | undefined;
4834
4996
  }[];
4997
+ categoryId: string;
4998
+ subcategoryId: string;
4835
4999
  requirements: {
4836
5000
  pre: {
4837
5001
  name: string;
@@ -4970,13 +5134,13 @@ declare const technologySchema: z.ZodObject<{
4970
5134
  }, {
4971
5135
  name: string;
4972
5136
  family: ProcedureFamily;
4973
- categoryId: string;
4974
- subcategoryId: string;
4975
5137
  contraindications: {
4976
5138
  id: string;
4977
5139
  name: string;
4978
5140
  description?: string | undefined;
4979
5141
  }[];
5142
+ categoryId: string;
5143
+ subcategoryId: string;
4980
5144
  blockingConditions: BlockingCondition[];
4981
5145
  benefits: {
4982
5146
  id: string;
@@ -5839,14 +6003,14 @@ declare const technologyUpdateSchema: z.ZodObject<{
5839
6003
  isActive?: boolean | undefined;
5840
6004
  description?: string | undefined;
5841
6005
  family?: ProcedureFamily | undefined;
5842
- categoryId?: string | undefined;
5843
- subcategoryId?: string | undefined;
5844
6006
  technicalDetails?: string | undefined;
5845
6007
  contraindications?: {
5846
6008
  id: string;
5847
6009
  name: string;
5848
6010
  description?: string | undefined;
5849
6011
  }[] | undefined;
6012
+ categoryId?: string | undefined;
6013
+ subcategoryId?: string | undefined;
5850
6014
  requirements?: {
5851
6015
  pre: {
5852
6016
  name: string;
@@ -5985,14 +6149,14 @@ declare const technologyUpdateSchema: z.ZodObject<{
5985
6149
  isActive?: boolean | undefined;
5986
6150
  description?: string | undefined;
5987
6151
  family?: ProcedureFamily | undefined;
5988
- categoryId?: string | undefined;
5989
- subcategoryId?: string | undefined;
5990
6152
  technicalDetails?: string | undefined;
5991
6153
  contraindications?: {
5992
6154
  id: string;
5993
6155
  name: string;
5994
6156
  description?: string | undefined;
5995
6157
  }[] | undefined;
6158
+ categoryId?: string | undefined;
6159
+ subcategoryId?: string | undefined;
5996
6160
  requirements?: {
5997
6161
  pre: {
5998
6162
  name: string;