@blackcode_sa/metaestetics-api 1.12.43 → 1.12.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -565,10 +565,9 @@ interface FilledDocumentFileValue {
565
565
  *
566
566
  * @property id - Unique identifier of the product
567
567
  * @property name - Name of the product
568
- * @property brandId - ID of the brand that manufactures this product
569
- * @property brandName - Name of the brand (denormalized for display)
570
- * @property assignedTechnologyIds - Array of technology IDs this product is assigned to
571
568
  * @property description - Detailed description of the product and its purpose
569
+ * @property brandId - ID of the brand that manufactures this product
570
+ * @property technologyId - ID of the technology this product is used with
572
571
  * @property technicalDetails - Technical details and specifications
573
572
  * @property warnings - List of warnings related to product use
574
573
  * @property dosage - Dosage information (if applicable)
@@ -584,7 +583,10 @@ interface Product {
584
583
  name: string;
585
584
  brandId: string;
586
585
  brandName: string;
587
- assignedTechnologyIds?: string[];
586
+ technologyId: string;
587
+ technologyName: string;
588
+ categoryId: string;
589
+ subcategoryId: string;
588
590
  createdAt: Date;
589
591
  updatedAt: Date;
590
592
  isActive: boolean;
@@ -595,86 +597,12 @@ interface Product {
595
597
  composition?: string;
596
598
  indications?: string[];
597
599
  contraindications?: ContraindicationDynamic[];
598
- /** Present only in subcollections - synced from technology metadata */
599
- technologyId?: string;
600
- /** Present only in subcollections - synced from technology name */
601
- technologyName?: string;
602
- /** Present only in subcollections - synced from technology categoryId */
603
- categoryId?: string;
604
- /** Present only in subcollections - synced from technology subcategoryId */
605
- subcategoryId?: string;
606
600
  }
607
601
  /**
608
602
  * Interface for the ProductService class
609
- *
610
- * NOTE: This interface maintains backward compatibility while adding new top-level collection methods.
611
- * Old methods using technologyId are kept for existing code, new methods work with top-level collection.
612
603
  */
613
604
  interface IProductService {
614
605
  /**
615
- * Creates a new product in the top-level collection
616
- * @param brandId - ID of the brand that manufactures this product
617
- * @param product - Product data
618
- * @param technologyIds - Optional array of technology IDs to assign this product to
619
- */
620
- createTopLevel(brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'assignedTechnologyIds'>, technologyIds?: string[]): Promise<Product>;
621
- /**
622
- * Gets all products from the top-level collection
623
- * @param options - Query options
624
- */
625
- getAllTopLevel(options: {
626
- rowsPerPage: number;
627
- lastVisible?: any;
628
- brandId?: string;
629
- }): Promise<{
630
- products: Product[];
631
- lastVisible: any;
632
- }>;
633
- /**
634
- * Gets a product by ID from the top-level collection
635
- * @param productId - ID of the product
636
- */
637
- getByIdTopLevel(productId: string): Promise<Product | null>;
638
- /**
639
- * Updates a product in the top-level collection
640
- * @param productId - ID of the product to update
641
- * @param product - Updated product data
642
- */
643
- updateTopLevel(productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId'>>): Promise<Product | null>;
644
- /**
645
- * Deletes a product from the top-level collection (soft delete)
646
- * @param productId - ID of the product to delete
647
- */
648
- deleteTopLevel(productId: string): Promise<void>;
649
- /**
650
- * Assigns a product to a technology
651
- * @param productId - ID of the product
652
- * @param technologyId - ID of the technology
653
- */
654
- assignToTechnology(productId: string, technologyId: string): Promise<void>;
655
- /**
656
- * Unassigns a product from a technology
657
- * @param productId - ID of the product
658
- * @param technologyId - ID of the technology
659
- */
660
- unassignFromTechnology(productId: string, technologyId: string): Promise<void>;
661
- /**
662
- * Gets products assigned to a specific technology
663
- * @param technologyId - ID of the technology
664
- */
665
- getAssignedProducts(technologyId: string): Promise<Product[]>;
666
- /**
667
- * Gets products NOT assigned to a specific technology
668
- * @param technologyId - ID of the technology
669
- */
670
- getUnassignedProducts(technologyId: string): Promise<Product[]>;
671
- /**
672
- * Gets all products for a brand
673
- * @param brandId - ID of the brand
674
- */
675
- getByBrand(brandId: string): Promise<Product[]>;
676
- /**
677
- * @deprecated Use createTopLevel instead
678
606
  * Creates a new product
679
607
  * @param technologyId - ID of the technology this product is used with
680
608
  * @param brandId - ID of the brand that manufactures this product
@@ -682,7 +610,6 @@ interface IProductService {
682
610
  */
683
611
  create(technologyId: string, brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'technologyId'>): Promise<Product>;
684
612
  /**
685
- * @deprecated Use getAllTopLevel instead
686
613
  * Gets a paginated list of all products, with optional filters.
687
614
  */
688
615
  getAll(options: {
@@ -696,7 +623,6 @@ interface IProductService {
696
623
  lastVisible: any;
697
624
  }>;
698
625
  /**
699
- * @deprecated Use alternative counting methods
700
626
  * Gets the total count of active products, with optional filters.
701
627
  */
702
628
  getProductsCount(options: {
@@ -705,7 +631,6 @@ interface IProductService {
705
631
  technologyId?: string;
706
632
  }): Promise<number>;
707
633
  /**
708
- * @deprecated Use alternative counting methods
709
634
  * Gets counts of active products grouped by category, subcategory, and technology.
710
635
  */
711
636
  getProductCounts(): Promise<{
@@ -714,19 +639,16 @@ interface IProductService {
714
639
  byTechnology: Record<string, number>;
715
640
  }>;
716
641
  /**
717
- * @deprecated Use getAssignedProducts instead
718
642
  * Gets all products for a specific technology (non-paginated, for filters/dropdowns)
719
643
  * @param technologyId - ID of the technology
720
644
  */
721
645
  getAllByTechnology(technologyId: string): Promise<Product[]>;
722
646
  /**
723
- * @deprecated Use getByBrand instead
724
647
  * Gets all products for a brand
725
648
  * @param brandId - ID of the brand
726
649
  */
727
650
  getAllByBrand(brandId: string): Promise<Product[]>;
728
651
  /**
729
- * @deprecated Use updateTopLevel instead
730
652
  * Updates a product
731
653
  * @param technologyId - ID of the technology
732
654
  * @param productId - ID of the product to update
@@ -734,14 +656,12 @@ interface IProductService {
734
656
  */
735
657
  update(technologyId: string, productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId' | 'technologyId'>>): Promise<Product | null>;
736
658
  /**
737
- * @deprecated Use deleteTopLevel instead
738
659
  * Deletes a product (soft delete)
739
660
  * @param technologyId - ID of the technology
740
661
  * @param productId - ID of the product to delete
741
662
  */
742
663
  delete(technologyId: string, productId: string): Promise<void>;
743
664
  /**
744
- * @deprecated Use getByIdTopLevel instead
745
665
  * Gets a product by ID
746
666
  * @param technologyId - ID of the technology
747
667
  * @param productId - ID of the product
@@ -1183,18 +1103,6 @@ declare class BrandService extends BaseService {
1183
1103
  * Gets a brand by ID
1184
1104
  */
1185
1105
  getById(brandId: string): Promise<Brand | null>;
1186
- /**
1187
- * Exports brands to CSV string, suitable for Excel/Sheets.
1188
- * Includes headers and optional UTF-8 BOM.
1189
- * By default exports only active brands (set includeInactive to true to export all).
1190
- */
1191
- exportToCsv(options?: {
1192
- includeInactive?: boolean;
1193
- includeBom?: boolean;
1194
- }): Promise<string>;
1195
- private brandToCsvRow;
1196
- private formatDateIso;
1197
- private formatCsvValue;
1198
1106
  }
1199
1107
 
1200
1108
  /**
@@ -1296,18 +1204,6 @@ declare class CategoryService extends BaseService implements ICategoryService {
1296
1204
  * @returns Kategorija ili null ako ne postoji
1297
1205
  */
1298
1206
  getById(id: string): Promise<Category | null>;
1299
- /**
1300
- * Exports categories to CSV string, suitable for Excel/Sheets.
1301
- * Includes headers and optional UTF-8 BOM.
1302
- * By default exports only active categories (set includeInactive to true to export all).
1303
- */
1304
- exportToCsv(options?: {
1305
- includeInactive?: boolean;
1306
- includeBom?: boolean;
1307
- }): Promise<string>;
1308
- private categoryToCsvRow;
1309
- private formatDateIso;
1310
- private formatCsvValue;
1311
1207
  }
1312
1208
 
1313
1209
  /**
@@ -1584,12 +1480,7 @@ declare class FilledDocumentService extends BaseService {
1584
1480
 
1585
1481
  declare class ProductService extends BaseService implements IProductService {
1586
1482
  /**
1587
- * Gets reference to top-level products collection (source of truth)
1588
- * @returns Firestore collection reference
1589
- */
1590
- private getTopLevelProductsRef;
1591
- /**
1592
- * Gets reference to products collection under a technology (backward compatibility)
1483
+ * Gets reference to products collection under a technology
1593
1484
  * @param technologyId - ID of the technology
1594
1485
  * @returns Firestore collection reference
1595
1486
  */
@@ -1622,7 +1513,7 @@ declare class ProductService extends BaseService implements IProductService {
1622
1513
  }): Promise<number>;
1623
1514
  /**
1624
1515
  * Gets counts of active products grouped by category, subcategory, and technology.
1625
- * Queries technology subcollections which have the legacy fields synced by Cloud Functions.
1516
+ * This uses a single collectionGroup query for efficiency.
1626
1517
  */
1627
1518
  getProductCounts(): Promise<{
1628
1519
  byCategory: Record<string, number>;
@@ -1649,65 +1540,6 @@ declare class ProductService extends BaseService implements IProductService {
1649
1540
  * Gets a product by ID
1650
1541
  */
1651
1542
  getById(technologyId: string, productId: string): Promise<Product | null>;
1652
- /**
1653
- * Creates a new product in the top-level collection
1654
- */
1655
- createTopLevel(brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'assignedTechnologyIds'>, technologyIds?: string[]): Promise<Product>;
1656
- /**
1657
- * Gets all products from the top-level collection
1658
- */
1659
- getAllTopLevel(options: {
1660
- rowsPerPage: number;
1661
- lastVisible?: any;
1662
- brandId?: string;
1663
- }): Promise<{
1664
- products: Product[];
1665
- lastVisible: any;
1666
- }>;
1667
- /**
1668
- * Gets a product by ID from the top-level collection
1669
- */
1670
- getByIdTopLevel(productId: string): Promise<Product | null>;
1671
- /**
1672
- * Updates a product in the top-level collection
1673
- */
1674
- updateTopLevel(productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId'>>): Promise<Product | null>;
1675
- /**
1676
- * Deletes a product from the top-level collection (soft delete)
1677
- */
1678
- deleteTopLevel(productId: string): Promise<void>;
1679
- /**
1680
- * Assigns a product to a technology
1681
- */
1682
- assignToTechnology(productId: string, technologyId: string): Promise<void>;
1683
- /**
1684
- * Unassigns a product from a technology
1685
- */
1686
- unassignFromTechnology(productId: string, technologyId: string): Promise<void>;
1687
- /**
1688
- * Gets products assigned to a specific technology
1689
- */
1690
- getAssignedProducts(technologyId: string): Promise<Product[]>;
1691
- /**
1692
- * Gets products NOT assigned to a specific technology
1693
- */
1694
- getUnassignedProducts(technologyId: string): Promise<Product[]>;
1695
- /**
1696
- * Gets all products for a brand (from top-level collection)
1697
- */
1698
- getByBrand(brandId: string): Promise<Product[]>;
1699
- /**
1700
- * Exports products to CSV string, suitable for Excel/Sheets.
1701
- * Includes headers and optional UTF-8 BOM.
1702
- * By default exports only active products (set includeInactive to true to export all).
1703
- */
1704
- exportToCsv(options?: {
1705
- includeInactive?: boolean;
1706
- includeBom?: boolean;
1707
- }): Promise<string>;
1708
- private productToCsvRow;
1709
- private formatDateIso;
1710
- private formatCsvValue;
1711
1543
  }
1712
1544
 
1713
1545
  /**
@@ -1818,18 +1650,6 @@ declare class SubcategoryService extends BaseService {
1818
1650
  * @returns Podkategorija ili null ako ne postoji
1819
1651
  */
1820
1652
  getById(categoryId: string, subcategoryId: string): Promise<Subcategory | null>;
1821
- /**
1822
- * Exports subcategories to CSV string, suitable for Excel/Sheets.
1823
- * Includes headers and optional UTF-8 BOM.
1824
- * By default exports only active subcategories (set includeInactive to true to export all).
1825
- */
1826
- exportToCsv(options?: {
1827
- includeInactive?: boolean;
1828
- includeBom?: boolean;
1829
- }): Promise<string>;
1830
- private subcategoryToCsvRow;
1831
- private formatDateIso;
1832
- private formatCsvValue;
1833
1653
  }
1834
1654
 
1835
1655
  /**
@@ -2153,10 +1973,10 @@ declare class TechnologyService extends BaseService implements ITechnologyServic
2153
1973
  description: string;
2154
1974
  family: ProcedureFamily;
2155
1975
  isActive: boolean;
2156
- technicalDetails?: string | undefined;
2157
- contraindications: ContraindicationDynamic[];
2158
1976
  categoryId: string;
2159
1977
  subcategoryId: string;
1978
+ technicalDetails?: string | undefined;
1979
+ contraindications: ContraindicationDynamic[];
2160
1980
  requirements: {
2161
1981
  pre: Requirement[];
2162
1982
  post: Requirement[];
@@ -2425,54 +2245,6 @@ declare class TechnologyService extends BaseService implements ITechnologyServic
2425
2245
  * Gets all active technologies for filter dropdowns.
2426
2246
  */
2427
2247
  getAllForFilter(): Promise<Technology[]>;
2428
- /**
2429
- * Assigns multiple products to a technology
2430
- * Updates each product's assignedTechnologyIds array
2431
- */
2432
- assignProducts(technologyId: string, productIds: string[]): Promise<void>;
2433
- /**
2434
- * Unassigns multiple products from a technology
2435
- * Updates each product's assignedTechnologyIds array
2436
- */
2437
- unassignProducts(technologyId: string, productIds: string[]): Promise<void>;
2438
- /**
2439
- * Gets products assigned to a specific technology
2440
- * Reads from top-level collection for immediate consistency (Cloud Functions may lag)
2441
- */
2442
- getAssignedProducts(technologyId: string): Promise<Product[]>;
2443
- /**
2444
- * Gets products NOT assigned to a specific technology
2445
- */
2446
- getUnassignedProducts(technologyId: string): Promise<Product[]>;
2447
- /**
2448
- * Gets product assignment statistics for a technology
2449
- */
2450
- getProductStats(technologyId: string): Promise<{
2451
- totalAssigned: number;
2452
- byBrand: Record<string, number>;
2453
- }>;
2454
- /**
2455
- * Updates products in technology subcollection when technology metadata changes
2456
- * @param technologyId - ID of the technology
2457
- * @param updates - Fields to update (categoryId, subcategoryId, technologyName)
2458
- */
2459
- private updateProductsInSubcollection;
2460
- /**
2461
- * Exports technologies to CSV string, suitable for Excel/Sheets.
2462
- * Includes headers and optional UTF-8 BOM.
2463
- * By default exports only active technologies (set includeInactive to true to export all).
2464
- * Includes product names from subcollections.
2465
- */
2466
- exportToCsv(options?: {
2467
- includeInactive?: boolean;
2468
- includeBom?: boolean;
2469
- }): Promise<string>;
2470
- /**
2471
- * Gets product names from the technology's product subcollection
2472
- */
2473
- private getProductNamesForTechnology;
2474
- private technologyToCsvRow;
2475
- private formatCsvValue;
2476
2248
  }
2477
2249
 
2478
2250
  /**
@@ -2592,23 +2364,6 @@ declare class ConstantsService extends BaseService {
2592
2364
  * @returns {Promise<void>}
2593
2365
  */
2594
2366
  deleteContraindication(contraindicationId: string): Promise<void>;
2595
- /**
2596
- * Exports treatment benefits to CSV string, suitable for Excel/Sheets.
2597
- * Includes headers and optional UTF-8 BOM.
2598
- */
2599
- exportBenefitsToCsv(options?: {
2600
- includeBom?: boolean;
2601
- }): Promise<string>;
2602
- /**
2603
- * Exports contraindications to CSV string, suitable for Excel/Sheets.
2604
- * Includes headers and optional UTF-8 BOM.
2605
- */
2606
- exportContraindicationsToCsv(options?: {
2607
- includeBom?: boolean;
2608
- }): Promise<string>;
2609
- private benefitToCsvRow;
2610
- private contraindicationToCsvRow;
2611
- private formatCsvValue;
2612
2367
  }
2613
2368
 
2614
2369
  /**