@blackcode_sa/metaestetics-api 1.12.2 → 1.12.3
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/backoffice/index.d.mts +64 -14
- package/dist/backoffice/index.d.ts +64 -14
- package/dist/backoffice/index.js +72 -53
- package/dist/backoffice/index.mjs +72 -53
- package/dist/index.d.mts +129 -17
- package/dist/index.d.ts +129 -17
- package/dist/index.js +72 -53
- package/dist/index.mjs +72 -53
- package/package.json +1 -1
- package/src/backoffice/services/FIXES_README.md +102 -0
- package/src/backoffice/services/category.service.ts +46 -27
- package/src/backoffice/services/product.service.ts +52 -74
- package/src/backoffice/services/technology.service.ts +99 -116
- package/src/backoffice/types/category.types.ts +28 -2
- package/src/backoffice/types/product.types.ts +10 -9
- package/src/backoffice/types/technology.types.ts +31 -59
package/dist/index.d.ts
CHANGED
|
@@ -254,6 +254,35 @@ interface Category {
|
|
|
254
254
|
/** Flag koji označava da li je kategorija aktivna */
|
|
255
255
|
isActive: boolean;
|
|
256
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Interface for the CategoryService class
|
|
259
|
+
*/
|
|
260
|
+
interface ICategoryService {
|
|
261
|
+
create(category: Omit<Category, 'id' | 'createdAt' | 'updatedAt'>): Promise<Category>;
|
|
262
|
+
getCategoryCounts(active?: boolean): Promise<Record<string, number>>;
|
|
263
|
+
getAllForFilter(): Promise<Category[]>;
|
|
264
|
+
getAllForFilterByFamily(family: ProcedureFamily): Promise<Category[]>;
|
|
265
|
+
getAll(options?: {
|
|
266
|
+
active?: boolean;
|
|
267
|
+
limit?: number;
|
|
268
|
+
lastVisible?: any;
|
|
269
|
+
}): Promise<{
|
|
270
|
+
categories: Category[];
|
|
271
|
+
lastVisible: any;
|
|
272
|
+
}>;
|
|
273
|
+
getAllByFamily(family: ProcedureFamily, options?: {
|
|
274
|
+
active?: boolean;
|
|
275
|
+
limit?: number;
|
|
276
|
+
lastVisible?: any;
|
|
277
|
+
}): Promise<{
|
|
278
|
+
categories: Category[];
|
|
279
|
+
lastVisible: any;
|
|
280
|
+
}>;
|
|
281
|
+
update(id: string, category: Partial<Omit<Category, 'id' | 'createdAt'>>): Promise<Category | null>;
|
|
282
|
+
delete(id: string): Promise<void>;
|
|
283
|
+
reactivate(id: string): Promise<void>;
|
|
284
|
+
getById(id: string): Promise<Category | null>;
|
|
285
|
+
}
|
|
257
286
|
|
|
258
287
|
/**
|
|
259
288
|
* Types for the Medical Documentation Templating System
|
|
@@ -575,7 +604,7 @@ interface IProductService {
|
|
|
575
604
|
* @param brandId - ID of the brand that manufactures this product
|
|
576
605
|
* @param product - Product data
|
|
577
606
|
*/
|
|
578
|
-
create(technologyId: string, brandId: string, product: Omit<Product,
|
|
607
|
+
create(technologyId: string, brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'technologyId'>): Promise<Product>;
|
|
579
608
|
/**
|
|
580
609
|
* Gets a paginated list of all products, with optional filters.
|
|
581
610
|
*/
|
|
@@ -605,6 +634,11 @@ interface IProductService {
|
|
|
605
634
|
bySubcategory: Record<string, number>;
|
|
606
635
|
byTechnology: Record<string, number>;
|
|
607
636
|
}>;
|
|
637
|
+
/**
|
|
638
|
+
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
639
|
+
* @param technologyId - ID of the technology
|
|
640
|
+
*/
|
|
641
|
+
getAllByTechnology(technologyId: string): Promise<Product[]>;
|
|
608
642
|
/**
|
|
609
643
|
* Gets all products for a brand
|
|
610
644
|
* @param brandId - ID of the brand
|
|
@@ -616,7 +650,7 @@ interface IProductService {
|
|
|
616
650
|
* @param productId - ID of the product to update
|
|
617
651
|
* @param product - Updated product data
|
|
618
652
|
*/
|
|
619
|
-
update(technologyId: string, productId: string, product: Partial<Omit<Product,
|
|
653
|
+
update(technologyId: string, productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId' | 'technologyId'>>): Promise<Product | null>;
|
|
620
654
|
/**
|
|
621
655
|
* Deletes a product (soft delete)
|
|
622
656
|
* @param technologyId - ID of the technology
|
|
@@ -830,6 +864,69 @@ interface Technology {
|
|
|
830
864
|
createdAt: Date;
|
|
831
865
|
updatedAt: Date;
|
|
832
866
|
}
|
|
867
|
+
/**
|
|
868
|
+
* Interface for the TechnologyService class
|
|
869
|
+
*/
|
|
870
|
+
interface ITechnologyService {
|
|
871
|
+
create(technology: Omit<Technology, 'id' | 'createdAt' | 'updatedAt'>): Promise<Technology>;
|
|
872
|
+
getTechnologyCounts(active?: boolean): Promise<Record<string, number>>;
|
|
873
|
+
getTechnologyCountsByCategory(active?: boolean): Promise<Record<string, number>>;
|
|
874
|
+
getAll(options?: {
|
|
875
|
+
active?: boolean;
|
|
876
|
+
limit?: number;
|
|
877
|
+
lastVisible?: any;
|
|
878
|
+
}): Promise<{
|
|
879
|
+
technologies: Technology[];
|
|
880
|
+
lastVisible: any;
|
|
881
|
+
}>;
|
|
882
|
+
getAllByCategoryId(categoryId: string, options?: {
|
|
883
|
+
active?: boolean;
|
|
884
|
+
limit?: number;
|
|
885
|
+
lastVisible?: any;
|
|
886
|
+
}): Promise<{
|
|
887
|
+
technologies: Technology[];
|
|
888
|
+
lastVisible: any;
|
|
889
|
+
}>;
|
|
890
|
+
getAllBySubcategoryId(subcategoryId: string, options?: {
|
|
891
|
+
active?: boolean;
|
|
892
|
+
limit?: number;
|
|
893
|
+
lastVisible?: any;
|
|
894
|
+
}): Promise<{
|
|
895
|
+
technologies: Technology[];
|
|
896
|
+
lastVisible: any;
|
|
897
|
+
}>;
|
|
898
|
+
update(id: string, technology: Partial<Omit<Technology, 'id' | 'createdAt'>>): Promise<Technology | null>;
|
|
899
|
+
delete(id: string): Promise<void>;
|
|
900
|
+
reactivate(id: string): Promise<void>;
|
|
901
|
+
getById(id: string): Promise<Technology | null>;
|
|
902
|
+
addRequirement(technologyId: string, requirement: Requirement): Promise<Technology | null>;
|
|
903
|
+
removeRequirement(technologyId: string, requirement: Requirement): Promise<Technology | null>;
|
|
904
|
+
getRequirements(technologyId: string, type?: 'pre' | 'post'): Promise<Requirement[]>;
|
|
905
|
+
updateRequirement(technologyId: string, oldRequirement: Requirement, newRequirement: Requirement): Promise<Technology | null>;
|
|
906
|
+
addBlockingCondition(technologyId: string, condition: BlockingCondition): Promise<Technology | null>;
|
|
907
|
+
removeBlockingCondition(technologyId: string, condition: BlockingCondition): Promise<Technology | null>;
|
|
908
|
+
addContraindication(technologyId: string, contraindication: ContraindicationDynamic): Promise<Technology | null>;
|
|
909
|
+
removeContraindication(technologyId: string, contraindication: ContraindicationDynamic): Promise<Technology | null>;
|
|
910
|
+
updateContraindication(technologyId: string, contraindication: ContraindicationDynamic): Promise<Technology | null>;
|
|
911
|
+
addBenefit(technologyId: string, benefit: TreatmentBenefitDynamic): Promise<Technology | null>;
|
|
912
|
+
removeBenefit(technologyId: string, benefit: TreatmentBenefitDynamic): Promise<Technology | null>;
|
|
913
|
+
updateBenefit(technologyId: string, benefit: TreatmentBenefitDynamic): Promise<Technology | null>;
|
|
914
|
+
getBlockingConditions(technologyId: string): Promise<BlockingCondition[]>;
|
|
915
|
+
getContraindications(technologyId: string): Promise<ContraindicationDynamic[]>;
|
|
916
|
+
getBenefits(technologyId: string): Promise<TreatmentBenefitDynamic[]>;
|
|
917
|
+
updateCertificationRequirement(technologyId: string, certificationRequirement: CertificationRequirement): Promise<Technology | null>;
|
|
918
|
+
getCertificationRequirement(technologyId: string): Promise<CertificationRequirement | null>;
|
|
919
|
+
validateCertification(requiredCertification: CertificationRequirement, practitionerCertification: any): boolean;
|
|
920
|
+
getAllowedTechnologies(practitioner: any): Promise<{
|
|
921
|
+
technologies: Technology[];
|
|
922
|
+
families: ProcedureFamily[];
|
|
923
|
+
categories: string[];
|
|
924
|
+
subcategories: string[];
|
|
925
|
+
}>;
|
|
926
|
+
getAllForFilterBySubcategory(subcategoryId: string): Promise<Technology[]>;
|
|
927
|
+
getAllForFilterBySubcategoryId(categoryId: string, subcategoryId: string): Promise<Technology[]>;
|
|
928
|
+
getAllForFilter(): Promise<Technology[]>;
|
|
929
|
+
}
|
|
833
930
|
|
|
834
931
|
/**
|
|
835
932
|
* @deprecated
|
|
@@ -964,8 +1061,8 @@ declare class BrandService extends BaseService {
|
|
|
964
1061
|
createdAt: Date;
|
|
965
1062
|
updatedAt: Date;
|
|
966
1063
|
name: string;
|
|
967
|
-
isActive: boolean;
|
|
968
1064
|
description?: string | undefined;
|
|
1065
|
+
isActive: boolean;
|
|
969
1066
|
name_lowercase: string;
|
|
970
1067
|
manufacturer: string;
|
|
971
1068
|
website?: string | undefined;
|
|
@@ -1017,7 +1114,7 @@ declare class BrandService extends BaseService {
|
|
|
1017
1114
|
* family: ProcedureFamily.AESTHETICS
|
|
1018
1115
|
* });
|
|
1019
1116
|
*/
|
|
1020
|
-
declare class CategoryService extends BaseService {
|
|
1117
|
+
declare class CategoryService extends BaseService implements ICategoryService {
|
|
1021
1118
|
/**
|
|
1022
1119
|
* Referenca na Firestore kolekciju kategorija
|
|
1023
1120
|
*/
|
|
@@ -1027,13 +1124,13 @@ declare class CategoryService extends BaseService {
|
|
|
1027
1124
|
* @param category - Podaci za novu kategoriju
|
|
1028
1125
|
* @returns Kreirana kategorija sa generisanim ID-em
|
|
1029
1126
|
*/
|
|
1030
|
-
create(category: Omit<Category,
|
|
1127
|
+
create(category: Omit<Category, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
1031
1128
|
createdAt: Date;
|
|
1032
1129
|
updatedAt: Date;
|
|
1033
1130
|
name: string;
|
|
1034
|
-
isActive: boolean;
|
|
1035
1131
|
description: string;
|
|
1036
1132
|
family: ProcedureFamily;
|
|
1133
|
+
isActive: boolean;
|
|
1037
1134
|
id: string;
|
|
1038
1135
|
}>;
|
|
1039
1136
|
/**
|
|
@@ -1047,6 +1144,12 @@ declare class CategoryService extends BaseService {
|
|
|
1047
1144
|
* @returns Lista svih aktivnih kategorija
|
|
1048
1145
|
*/
|
|
1049
1146
|
getAllForFilter(): Promise<Category[]>;
|
|
1147
|
+
/**
|
|
1148
|
+
* Vraća sve kategorije za određenu familiju za potrebe filtera (bez paginacije)
|
|
1149
|
+
* @param family - Familija procedura (aesthetics/surgery)
|
|
1150
|
+
* @returns Lista aktivnih kategorija koje pripadaju traženoj familiji
|
|
1151
|
+
*/
|
|
1152
|
+
getAllForFilterByFamily(family: ProcedureFamily): Promise<Category[]>;
|
|
1050
1153
|
/**
|
|
1051
1154
|
* Vraća sve kategorije sa paginacijom
|
|
1052
1155
|
* @param options - Pagination and filter options
|
|
@@ -1080,7 +1183,7 @@ declare class CategoryService extends BaseService {
|
|
|
1080
1183
|
* @param category - Novi podaci za kategoriju
|
|
1081
1184
|
* @returns Ažurirana kategorija
|
|
1082
1185
|
*/
|
|
1083
|
-
update(id: string, category: Partial<Omit<Category,
|
|
1186
|
+
update(id: string, category: Partial<Omit<Category, 'id' | 'createdAt'>>): Promise<Category | null>;
|
|
1084
1187
|
/**
|
|
1085
1188
|
* Soft delete kategorije (postavlja isActive na false)
|
|
1086
1189
|
* @param id - ID kategorije koja se briše
|
|
@@ -1381,7 +1484,7 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1381
1484
|
/**
|
|
1382
1485
|
* Creates a new product under technology
|
|
1383
1486
|
*/
|
|
1384
|
-
create(technologyId: string, brandId: string, product: Omit<Product,
|
|
1487
|
+
create(technologyId: string, brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'technologyId'>): Promise<Product>;
|
|
1385
1488
|
/**
|
|
1386
1489
|
* Gets a paginated list of all products, with optional filters.
|
|
1387
1490
|
* This uses a collectionGroup query to search across all technologies.
|
|
@@ -1413,6 +1516,10 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1413
1516
|
bySubcategory: Record<string, number>;
|
|
1414
1517
|
byTechnology: Record<string, number>;
|
|
1415
1518
|
}>;
|
|
1519
|
+
/**
|
|
1520
|
+
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
1521
|
+
*/
|
|
1522
|
+
getAllByTechnology(technologyId: string): Promise<Product[]>;
|
|
1416
1523
|
/**
|
|
1417
1524
|
* Gets all products for a brand by filtering through all technologies
|
|
1418
1525
|
*/
|
|
@@ -1420,7 +1527,7 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1420
1527
|
/**
|
|
1421
1528
|
* Updates a product
|
|
1422
1529
|
*/
|
|
1423
|
-
update(technologyId: string, productId: string, product: Partial<Omit<Product,
|
|
1530
|
+
update(technologyId: string, productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId' | 'technologyId'>>): Promise<Product | null>;
|
|
1424
1531
|
/**
|
|
1425
1532
|
* Soft deletes a product
|
|
1426
1533
|
*/
|
|
@@ -1460,9 +1567,9 @@ declare class SubcategoryService extends BaseService {
|
|
|
1460
1567
|
createdAt: Date;
|
|
1461
1568
|
updatedAt: Date;
|
|
1462
1569
|
name: string;
|
|
1463
|
-
categoryId: string;
|
|
1464
|
-
isActive: boolean;
|
|
1465
1570
|
description?: string | undefined;
|
|
1571
|
+
isActive: boolean;
|
|
1572
|
+
categoryId: string;
|
|
1466
1573
|
id: string;
|
|
1467
1574
|
}>;
|
|
1468
1575
|
/**
|
|
@@ -1845,7 +1952,7 @@ interface CreatePractitionerTokenData {
|
|
|
1845
1952
|
/**
|
|
1846
1953
|
* Service for managing technologies.
|
|
1847
1954
|
*/
|
|
1848
|
-
declare class TechnologyService extends BaseService {
|
|
1955
|
+
declare class TechnologyService extends BaseService implements ITechnologyService {
|
|
1849
1956
|
/**
|
|
1850
1957
|
* Reference to the Firestore collection of technologies.
|
|
1851
1958
|
*/
|
|
@@ -1855,17 +1962,17 @@ declare class TechnologyService extends BaseService {
|
|
|
1855
1962
|
* @param technology - Data for the new technology.
|
|
1856
1963
|
* @returns The created technology with its generated ID.
|
|
1857
1964
|
*/
|
|
1858
|
-
create(technology: Omit<Technology,
|
|
1965
|
+
create(technology: Omit<Technology, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
1859
1966
|
createdAt: Date;
|
|
1860
1967
|
updatedAt: Date;
|
|
1861
1968
|
name: string;
|
|
1969
|
+
description: string;
|
|
1970
|
+
family: ProcedureFamily;
|
|
1971
|
+
isActive: boolean;
|
|
1862
1972
|
categoryId: string;
|
|
1863
1973
|
subcategoryId: string;
|
|
1864
|
-
isActive: boolean;
|
|
1865
|
-
description: string;
|
|
1866
1974
|
technicalDetails?: string | undefined;
|
|
1867
1975
|
contraindications: ContraindicationDynamic[];
|
|
1868
|
-
family: ProcedureFamily;
|
|
1869
1976
|
requirements: {
|
|
1870
1977
|
pre: Requirement[];
|
|
1871
1978
|
post: Requirement[];
|
|
@@ -1935,7 +2042,7 @@ declare class TechnologyService extends BaseService {
|
|
|
1935
2042
|
* @param technology - New data for the technology.
|
|
1936
2043
|
* @returns The updated technology.
|
|
1937
2044
|
*/
|
|
1938
|
-
update(id: string, technology: Partial<Omit<Technology,
|
|
2045
|
+
update(id: string, technology: Partial<Omit<Technology, 'id' | 'createdAt'>>): Promise<Technology | null>;
|
|
1939
2046
|
/**
|
|
1940
2047
|
* Soft deletes a technology.
|
|
1941
2048
|
* @param id - The ID of the technology to delete.
|
|
@@ -2119,6 +2226,11 @@ declare class TechnologyService extends BaseService {
|
|
|
2119
2226
|
categories: string[];
|
|
2120
2227
|
subcategories: string[];
|
|
2121
2228
|
}>;
|
|
2229
|
+
/**
|
|
2230
|
+
* Gets all active technologies for a subcategory for filter dropdowns (by subcategory only).
|
|
2231
|
+
* @param subcategoryId - The ID of the subcategory.
|
|
2232
|
+
*/
|
|
2233
|
+
getAllForFilterBySubcategory(subcategoryId: string): Promise<Technology[]>;
|
|
2122
2234
|
/**
|
|
2123
2235
|
* Gets all active technologies for a subcategory for filter dropdowns.
|
|
2124
2236
|
* @param categoryId - The ID of the parent category.
|
package/dist/index.js
CHANGED
|
@@ -16544,6 +16544,26 @@ var CategoryService = class extends BaseService {
|
|
|
16544
16544
|
})
|
|
16545
16545
|
);
|
|
16546
16546
|
}
|
|
16547
|
+
/**
|
|
16548
|
+
* Vraća sve kategorije za određenu familiju za potrebe filtera (bez paginacije)
|
|
16549
|
+
* @param family - Familija procedura (aesthetics/surgery)
|
|
16550
|
+
* @returns Lista aktivnih kategorija koje pripadaju traženoj familiji
|
|
16551
|
+
*/
|
|
16552
|
+
async getAllForFilterByFamily(family) {
|
|
16553
|
+
const q = (0, import_firestore50.query)(
|
|
16554
|
+
this.categoriesRef,
|
|
16555
|
+
(0, import_firestore50.where)("family", "==", family),
|
|
16556
|
+
(0, import_firestore50.where)("isActive", "==", true),
|
|
16557
|
+
(0, import_firestore50.orderBy)("name")
|
|
16558
|
+
);
|
|
16559
|
+
const snapshot = await (0, import_firestore50.getDocs)(q);
|
|
16560
|
+
return snapshot.docs.map(
|
|
16561
|
+
(doc38) => ({
|
|
16562
|
+
id: doc38.id,
|
|
16563
|
+
...doc38.data()
|
|
16564
|
+
})
|
|
16565
|
+
);
|
|
16566
|
+
}
|
|
16547
16567
|
/**
|
|
16548
16568
|
* Vraća sve kategorije sa paginacijom
|
|
16549
16569
|
* @param options - Pagination and filter options
|
|
@@ -17177,7 +17197,9 @@ var TechnologyService = class extends BaseService {
|
|
|
17177
17197
|
if (!technology) {
|
|
17178
17198
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
17179
17199
|
}
|
|
17180
|
-
const updatedContraindications = (technology.contraindications || []).filter(
|
|
17200
|
+
const updatedContraindications = (technology.contraindications || []).filter(
|
|
17201
|
+
(c) => c.id !== contraindication.id
|
|
17202
|
+
);
|
|
17181
17203
|
await (0, import_firestore52.updateDoc)(docRef, {
|
|
17182
17204
|
contraindications: updatedContraindications,
|
|
17183
17205
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -17198,9 +17220,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17198
17220
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
17199
17221
|
}
|
|
17200
17222
|
const contraindications = technology.contraindications || [];
|
|
17201
|
-
const index = contraindications.findIndex(
|
|
17202
|
-
(c) => c.id === contraindication.id
|
|
17203
|
-
);
|
|
17223
|
+
const index = contraindications.findIndex((c) => c.id === contraindication.id);
|
|
17204
17224
|
if (index === -1) {
|
|
17205
17225
|
console.warn(
|
|
17206
17226
|
`Contraindication with id ${contraindication.id} not found for technology ${technologyId}. No update performed.`
|
|
@@ -17249,9 +17269,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17249
17269
|
if (!technology) {
|
|
17250
17270
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
17251
17271
|
}
|
|
17252
|
-
const updatedBenefits = (technology.benefits || []).filter(
|
|
17253
|
-
(b) => b.id !== benefit.id
|
|
17254
|
-
);
|
|
17272
|
+
const updatedBenefits = (technology.benefits || []).filter((b) => b.id !== benefit.id);
|
|
17255
17273
|
await (0, import_firestore52.updateDoc)(docRef, {
|
|
17256
17274
|
benefits: updatedBenefits,
|
|
17257
17275
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -17357,9 +17375,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17357
17375
|
* );
|
|
17358
17376
|
*/
|
|
17359
17377
|
validateCertification(requiredCertification, practitionerCertification) {
|
|
17360
|
-
const doctorLevel = Object.values(CertificationLevel).indexOf(
|
|
17361
|
-
practitionerCertification.level
|
|
17362
|
-
);
|
|
17378
|
+
const doctorLevel = Object.values(CertificationLevel).indexOf(practitionerCertification.level);
|
|
17363
17379
|
const requiredLevel = Object.values(CertificationLevel).indexOf(
|
|
17364
17380
|
requiredCertification.minimumLevel
|
|
17365
17381
|
);
|
|
@@ -17400,18 +17416,11 @@ var TechnologyService = class extends BaseService {
|
|
|
17400
17416
|
async getAllowedTechnologies(practitioner) {
|
|
17401
17417
|
const allTechnologies = await this.getAll();
|
|
17402
17418
|
const allowedTechnologies = allTechnologies.technologies.filter(
|
|
17403
|
-
(technology) => this.validateCertification(
|
|
17404
|
-
technology.certificationRequirement,
|
|
17405
|
-
practitioner.certification
|
|
17406
|
-
)
|
|
17419
|
+
(technology) => this.validateCertification(technology.certificationRequirement, practitioner.certification)
|
|
17407
17420
|
);
|
|
17408
17421
|
const families = [...new Set(allowedTechnologies.map((t) => t.family))];
|
|
17409
|
-
const categories = [
|
|
17410
|
-
|
|
17411
|
-
];
|
|
17412
|
-
const subcategories = [
|
|
17413
|
-
...new Set(allowedTechnologies.map((t) => t.subcategoryId))
|
|
17414
|
-
];
|
|
17422
|
+
const categories = [...new Set(allowedTechnologies.map((t) => t.categoryId))];
|
|
17423
|
+
const subcategories = [...new Set(allowedTechnologies.map((t) => t.subcategoryId))];
|
|
17415
17424
|
return {
|
|
17416
17425
|
technologies: allowedTechnologies,
|
|
17417
17426
|
families,
|
|
@@ -17419,6 +17428,25 @@ var TechnologyService = class extends BaseService {
|
|
|
17419
17428
|
subcategories
|
|
17420
17429
|
};
|
|
17421
17430
|
}
|
|
17431
|
+
/**
|
|
17432
|
+
* Gets all active technologies for a subcategory for filter dropdowns (by subcategory only).
|
|
17433
|
+
* @param subcategoryId - The ID of the subcategory.
|
|
17434
|
+
*/
|
|
17435
|
+
async getAllForFilterBySubcategory(subcategoryId) {
|
|
17436
|
+
const q = (0, import_firestore52.query)(
|
|
17437
|
+
(0, import_firestore52.collection)(this.db, TECHNOLOGIES_COLLECTION),
|
|
17438
|
+
(0, import_firestore52.where)("isActive", "==", true),
|
|
17439
|
+
(0, import_firestore52.where)("subcategoryId", "==", subcategoryId),
|
|
17440
|
+
(0, import_firestore52.orderBy)("name")
|
|
17441
|
+
);
|
|
17442
|
+
const snapshot = await (0, import_firestore52.getDocs)(q);
|
|
17443
|
+
return snapshot.docs.map(
|
|
17444
|
+
(doc38) => ({
|
|
17445
|
+
id: doc38.id,
|
|
17446
|
+
...doc38.data()
|
|
17447
|
+
})
|
|
17448
|
+
);
|
|
17449
|
+
}
|
|
17422
17450
|
/**
|
|
17423
17451
|
* Gets all active technologies for a subcategory for filter dropdowns.
|
|
17424
17452
|
* @param categoryId - The ID of the parent category.
|
|
@@ -17473,12 +17501,7 @@ var ProductService = class extends BaseService {
|
|
|
17473
17501
|
* @returns Firestore collection reference
|
|
17474
17502
|
*/
|
|
17475
17503
|
getProductsRef(technologyId) {
|
|
17476
|
-
return (0, import_firestore53.collection)(
|
|
17477
|
-
this.db,
|
|
17478
|
-
TECHNOLOGIES_COLLECTION,
|
|
17479
|
-
technologyId,
|
|
17480
|
-
PRODUCTS_COLLECTION
|
|
17481
|
-
);
|
|
17504
|
+
return (0, import_firestore53.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
|
|
17482
17505
|
}
|
|
17483
17506
|
/**
|
|
17484
17507
|
* Creates a new product under technology
|
|
@@ -17493,10 +17516,7 @@ var ProductService = class extends BaseService {
|
|
|
17493
17516
|
updatedAt: now,
|
|
17494
17517
|
isActive: true
|
|
17495
17518
|
};
|
|
17496
|
-
const productRef = await (0, import_firestore53.addDoc)(
|
|
17497
|
-
this.getProductsRef(technologyId),
|
|
17498
|
-
newProduct
|
|
17499
|
-
);
|
|
17519
|
+
const productRef = await (0, import_firestore53.addDoc)(this.getProductsRef(technologyId), newProduct);
|
|
17500
17520
|
return { id: productRef.id, ...newProduct };
|
|
17501
17521
|
}
|
|
17502
17522
|
/**
|
|
@@ -17504,17 +17524,8 @@ var ProductService = class extends BaseService {
|
|
|
17504
17524
|
* This uses a collectionGroup query to search across all technologies.
|
|
17505
17525
|
*/
|
|
17506
17526
|
async getAll(options) {
|
|
17507
|
-
const {
|
|
17508
|
-
|
|
17509
|
-
lastVisible,
|
|
17510
|
-
categoryId,
|
|
17511
|
-
subcategoryId,
|
|
17512
|
-
technologyId
|
|
17513
|
-
} = options;
|
|
17514
|
-
const constraints = [
|
|
17515
|
-
(0, import_firestore53.where)("isActive", "==", true),
|
|
17516
|
-
(0, import_firestore53.orderBy)("name")
|
|
17517
|
-
];
|
|
17527
|
+
const { rowsPerPage, lastVisible, categoryId, subcategoryId, technologyId } = options;
|
|
17528
|
+
const constraints = [(0, import_firestore53.where)("isActive", "==", true), (0, import_firestore53.orderBy)("name")];
|
|
17518
17529
|
if (categoryId) {
|
|
17519
17530
|
constraints.push((0, import_firestore53.where)("categoryId", "==", categoryId));
|
|
17520
17531
|
}
|
|
@@ -17528,10 +17539,7 @@ var ProductService = class extends BaseService {
|
|
|
17528
17539
|
constraints.push((0, import_firestore53.startAfter)(lastVisible));
|
|
17529
17540
|
}
|
|
17530
17541
|
constraints.push((0, import_firestore53.limit)(rowsPerPage));
|
|
17531
|
-
const q = (0, import_firestore53.query)(
|
|
17532
|
-
(0, import_firestore53.collectionGroup)(this.db, PRODUCTS_COLLECTION),
|
|
17533
|
-
...constraints
|
|
17534
|
-
);
|
|
17542
|
+
const q = (0, import_firestore53.query)((0, import_firestore53.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
17535
17543
|
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17536
17544
|
const products = snapshot.docs.map(
|
|
17537
17545
|
(doc38) => ({
|
|
@@ -17557,10 +17565,7 @@ var ProductService = class extends BaseService {
|
|
|
17557
17565
|
if (technologyId) {
|
|
17558
17566
|
constraints.push((0, import_firestore53.where)("technologyId", "==", technologyId));
|
|
17559
17567
|
}
|
|
17560
|
-
const q = (0, import_firestore53.query)(
|
|
17561
|
-
(0, import_firestore53.collectionGroup)(this.db, PRODUCTS_COLLECTION),
|
|
17562
|
-
...constraints
|
|
17563
|
-
);
|
|
17568
|
+
const q = (0, import_firestore53.query)((0, import_firestore53.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
17564
17569
|
const snapshot = await (0, import_firestore53.getCountFromServer)(q);
|
|
17565
17570
|
return snapshot.data().count;
|
|
17566
17571
|
}
|
|
@@ -17569,10 +17574,7 @@ var ProductService = class extends BaseService {
|
|
|
17569
17574
|
* This uses a single collectionGroup query for efficiency.
|
|
17570
17575
|
*/
|
|
17571
17576
|
async getProductCounts() {
|
|
17572
|
-
const q = (0, import_firestore53.query)(
|
|
17573
|
-
(0, import_firestore53.collectionGroup)(this.db, PRODUCTS_COLLECTION),
|
|
17574
|
-
(0, import_firestore53.where)("isActive", "==", true)
|
|
17575
|
-
);
|
|
17577
|
+
const q = (0, import_firestore53.query)((0, import_firestore53.collectionGroup)(this.db, PRODUCTS_COLLECTION), (0, import_firestore53.where)("isActive", "==", true));
|
|
17576
17578
|
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17577
17579
|
const counts = {
|
|
17578
17580
|
byCategory: {},
|
|
@@ -17597,6 +17599,23 @@ var ProductService = class extends BaseService {
|
|
|
17597
17599
|
});
|
|
17598
17600
|
return counts;
|
|
17599
17601
|
}
|
|
17602
|
+
/**
|
|
17603
|
+
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
17604
|
+
*/
|
|
17605
|
+
async getAllByTechnology(technologyId) {
|
|
17606
|
+
const q = (0, import_firestore53.query)(
|
|
17607
|
+
this.getProductsRef(technologyId),
|
|
17608
|
+
(0, import_firestore53.where)("isActive", "==", true),
|
|
17609
|
+
(0, import_firestore53.orderBy)("name")
|
|
17610
|
+
);
|
|
17611
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17612
|
+
return snapshot.docs.map(
|
|
17613
|
+
(doc38) => ({
|
|
17614
|
+
id: doc38.id,
|
|
17615
|
+
...doc38.data()
|
|
17616
|
+
})
|
|
17617
|
+
);
|
|
17618
|
+
}
|
|
17600
17619
|
/**
|
|
17601
17620
|
* Gets all products for a brand by filtering through all technologies
|
|
17602
17621
|
*/
|