@blackcode_sa/metaestetics-api 1.5.9 → 1.5.10

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
@@ -4818,7 +4818,11 @@ interface UpdateProcedureData {
4818
4818
  declare const PROCEDURES_COLLECTION = "procedures";
4819
4819
 
4820
4820
  declare class ProcedureService extends BaseService {
4821
- constructor(db: Firestore, auth: Auth, app: FirebaseApp);
4821
+ private categoryService;
4822
+ private subcategoryService;
4823
+ private technologyService;
4824
+ private productService;
4825
+ constructor(db: Firestore, auth: Auth, app: FirebaseApp, categoryService: CategoryService, subcategoryService: SubcategoryService, technologyService: TechnologyService, productService: ProductService);
4822
4826
  /**
4823
4827
  * Creates a new procedure
4824
4828
  * @param data - The data for creating a new procedure
@@ -4855,26 +4859,6 @@ declare class ProcedureService extends BaseService {
4855
4859
  * @param id - The ID of the procedure to deactivate
4856
4860
  */
4857
4861
  deactivateProcedure(id: string): Promise<void>;
4858
- /**
4859
- * Gets a category by ID
4860
- * @private
4861
- */
4862
- private getCategory;
4863
- /**
4864
- * Gets a subcategory by ID
4865
- * @private
4866
- */
4867
- private getSubcategory;
4868
- /**
4869
- * Gets a technology by ID
4870
- * @private
4871
- */
4872
- private getTechnology;
4873
- /**
4874
- * Gets a product by ID
4875
- * @private
4876
- */
4877
- private getProduct;
4878
4862
  }
4879
4863
 
4880
4864
  /**
package/dist/index.d.ts CHANGED
@@ -4818,7 +4818,11 @@ interface UpdateProcedureData {
4818
4818
  declare const PROCEDURES_COLLECTION = "procedures";
4819
4819
 
4820
4820
  declare class ProcedureService extends BaseService {
4821
- constructor(db: Firestore, auth: Auth, app: FirebaseApp);
4821
+ private categoryService;
4822
+ private subcategoryService;
4823
+ private technologyService;
4824
+ private productService;
4825
+ constructor(db: Firestore, auth: Auth, app: FirebaseApp, categoryService: CategoryService, subcategoryService: SubcategoryService, technologyService: TechnologyService, productService: ProductService);
4822
4826
  /**
4823
4827
  * Creates a new procedure
4824
4828
  * @param data - The data for creating a new procedure
@@ -4855,26 +4859,6 @@ declare class ProcedureService extends BaseService {
4855
4859
  * @param id - The ID of the procedure to deactivate
4856
4860
  */
4857
4861
  deactivateProcedure(id: string): Promise<void>;
4858
- /**
4859
- * Gets a category by ID
4860
- * @private
4861
- */
4862
- private getCategory;
4863
- /**
4864
- * Gets a subcategory by ID
4865
- * @private
4866
- */
4867
- private getSubcategory;
4868
- /**
4869
- * Gets a technology by ID
4870
- * @private
4871
- */
4872
- private getTechnology;
4873
- /**
4874
- * Gets a product by ID
4875
- * @private
4876
- */
4877
- private getProduct;
4878
4862
  }
4879
4863
 
4880
4864
  /**
package/dist/index.js CHANGED
@@ -6432,22 +6432,14 @@ var procedureSchema = createProcedureSchema.extend({
6432
6432
  updatedAt: import_zod16.z.date()
6433
6433
  });
6434
6434
 
6435
- // src/backoffice/types/category.types.ts
6436
- var CATEGORIES_COLLECTION = "backoffice_categories";
6437
-
6438
- // src/backoffice/types/subcategory.types.ts
6439
- var SUBCATEGORIES_COLLECTION = "subcategories";
6440
-
6441
- // src/backoffice/types/technology.types.ts
6442
- var TECHNOLOGIES_COLLECTION = "technologies";
6443
-
6444
- // src/backoffice/types/product.types.ts
6445
- var PRODUCTS_COLLECTION = "products";
6446
-
6447
6435
  // src/services/procedure/procedure.service.ts
6448
6436
  var ProcedureService = class extends BaseService {
6449
- constructor(db, auth, app) {
6437
+ constructor(db, auth, app, categoryService, subcategoryService, technologyService, productService) {
6450
6438
  super(db, auth, app);
6439
+ this.categoryService = categoryService;
6440
+ this.subcategoryService = subcategoryService;
6441
+ this.technologyService = technologyService;
6442
+ this.productService = productService;
6451
6443
  }
6452
6444
  /**
6453
6445
  * Creates a new procedure
@@ -6457,10 +6449,22 @@ var ProcedureService = class extends BaseService {
6457
6449
  async createProcedure(data) {
6458
6450
  const validatedData = createProcedureSchema.parse(data);
6459
6451
  const [category, subcategory, technology, product] = await Promise.all([
6460
- this.getCategory(validatedData.categoryId),
6461
- this.getSubcategory(validatedData.subcategoryId),
6462
- this.getTechnology(validatedData.technologyId),
6463
- this.getProduct(validatedData.productId)
6452
+ this.categoryService.getById(validatedData.categoryId),
6453
+ this.subcategoryService.getById(
6454
+ validatedData.categoryId,
6455
+ validatedData.subcategoryId
6456
+ ),
6457
+ this.technologyService.getById(
6458
+ validatedData.categoryId,
6459
+ validatedData.subcategoryId,
6460
+ validatedData.technologyId
6461
+ ),
6462
+ this.productService.getById(
6463
+ validatedData.categoryId,
6464
+ validatedData.subcategoryId,
6465
+ validatedData.technologyId,
6466
+ validatedData.productId
6467
+ )
6464
6468
  ]);
6465
6469
  if (!category || !subcategory || !technology || !product) {
6466
6470
  throw new Error("One or more required entities not found");
@@ -6566,42 +6570,6 @@ var ProcedureService = class extends BaseService {
6566
6570
  updatedAt: (0, import_firestore21.serverTimestamp)()
6567
6571
  });
6568
6572
  }
6569
- /**
6570
- * Gets a category by ID
6571
- * @private
6572
- */
6573
- async getCategory(id) {
6574
- const docRef = (0, import_firestore21.doc)(this.db, CATEGORIES_COLLECTION, id);
6575
- const docSnap = await (0, import_firestore21.getDoc)(docRef);
6576
- return docSnap.exists() ? docSnap.data() : null;
6577
- }
6578
- /**
6579
- * Gets a subcategory by ID
6580
- * @private
6581
- */
6582
- async getSubcategory(id) {
6583
- const docRef = (0, import_firestore21.doc)(this.db, SUBCATEGORIES_COLLECTION, id);
6584
- const docSnap = await (0, import_firestore21.getDoc)(docRef);
6585
- return docSnap.exists() ? docSnap.data() : null;
6586
- }
6587
- /**
6588
- * Gets a technology by ID
6589
- * @private
6590
- */
6591
- async getTechnology(id) {
6592
- const docRef = (0, import_firestore21.doc)(this.db, TECHNOLOGIES_COLLECTION, id);
6593
- const docSnap = await (0, import_firestore21.getDoc)(docRef);
6594
- return docSnap.exists() ? docSnap.data() : null;
6595
- }
6596
- /**
6597
- * Gets a product by ID
6598
- * @private
6599
- */
6600
- async getProduct(id) {
6601
- const docRef = (0, import_firestore21.doc)(this.db, PRODUCTS_COLLECTION, id);
6602
- const docSnap = await (0, import_firestore21.getDoc)(docRef);
6603
- return docSnap.exists() ? docSnap.data() : null;
6604
- }
6605
6573
  };
6606
6574
 
6607
6575
  // src/services/documentation-templates/documentation-template.service.ts
@@ -9616,6 +9584,11 @@ var BrandService = class extends BaseService {
9616
9584
 
9617
9585
  // src/backoffice/services/category.service.ts
9618
9586
  var import_firestore35 = require("firebase/firestore");
9587
+
9588
+ // src/backoffice/types/category.types.ts
9589
+ var CATEGORIES_COLLECTION = "backoffice_categories";
9590
+
9591
+ // src/backoffice/services/category.service.ts
9619
9592
  var CategoryService = class extends BaseService {
9620
9593
  /**
9621
9594
  * Referenca na Firestore kolekciju kategorija
@@ -9712,6 +9685,11 @@ var CategoryService = class extends BaseService {
9712
9685
 
9713
9686
  // src/backoffice/services/subcategory.service.ts
9714
9687
  var import_firestore36 = require("firebase/firestore");
9688
+
9689
+ // src/backoffice/types/subcategory.types.ts
9690
+ var SUBCATEGORIES_COLLECTION = "subcategories";
9691
+
9692
+ // src/backoffice/services/subcategory.service.ts
9715
9693
  var SubcategoryService = class extends BaseService {
9716
9694
  /**
9717
9695
  * Vraća referencu na Firestore kolekciju podkategorija za određenu kategoriju
@@ -9807,6 +9785,11 @@ var SubcategoryService = class extends BaseService {
9807
9785
 
9808
9786
  // src/backoffice/services/technology.service.ts
9809
9787
  var import_firestore37 = require("firebase/firestore");
9788
+
9789
+ // src/backoffice/types/technology.types.ts
9790
+ var TECHNOLOGIES_COLLECTION = "technologies";
9791
+
9792
+ // src/backoffice/services/technology.service.ts
9810
9793
  var DEFAULT_CERTIFICATION_REQUIREMENT = {
9811
9794
  minimumLevel: "aesthetician" /* AESTHETICIAN */,
9812
9795
  requiredSpecialties: []
@@ -10206,6 +10189,11 @@ var TechnologyService = class extends BaseService {
10206
10189
 
10207
10190
  // src/backoffice/services/product.service.ts
10208
10191
  var import_firestore38 = require("firebase/firestore");
10192
+
10193
+ // src/backoffice/types/product.types.ts
10194
+ var PRODUCTS_COLLECTION = "products";
10195
+
10196
+ // src/backoffice/services/product.service.ts
10209
10197
  var ProductService = class extends BaseService {
10210
10198
  getProductsRefByTechnology(categoryId, subcategoryId, technologyId) {
10211
10199
  return (0, import_firestore38.collection)(
package/dist/index.mjs CHANGED
@@ -6397,22 +6397,14 @@ var procedureSchema = createProcedureSchema.extend({
6397
6397
  updatedAt: z16.date()
6398
6398
  });
6399
6399
 
6400
- // src/backoffice/types/category.types.ts
6401
- var CATEGORIES_COLLECTION = "backoffice_categories";
6402
-
6403
- // src/backoffice/types/subcategory.types.ts
6404
- var SUBCATEGORIES_COLLECTION = "subcategories";
6405
-
6406
- // src/backoffice/types/technology.types.ts
6407
- var TECHNOLOGIES_COLLECTION = "technologies";
6408
-
6409
- // src/backoffice/types/product.types.ts
6410
- var PRODUCTS_COLLECTION = "products";
6411
-
6412
6400
  // src/services/procedure/procedure.service.ts
6413
6401
  var ProcedureService = class extends BaseService {
6414
- constructor(db, auth, app) {
6402
+ constructor(db, auth, app, categoryService, subcategoryService, technologyService, productService) {
6415
6403
  super(db, auth, app);
6404
+ this.categoryService = categoryService;
6405
+ this.subcategoryService = subcategoryService;
6406
+ this.technologyService = technologyService;
6407
+ this.productService = productService;
6416
6408
  }
6417
6409
  /**
6418
6410
  * Creates a new procedure
@@ -6422,10 +6414,22 @@ var ProcedureService = class extends BaseService {
6422
6414
  async createProcedure(data) {
6423
6415
  const validatedData = createProcedureSchema.parse(data);
6424
6416
  const [category, subcategory, technology, product] = await Promise.all([
6425
- this.getCategory(validatedData.categoryId),
6426
- this.getSubcategory(validatedData.subcategoryId),
6427
- this.getTechnology(validatedData.technologyId),
6428
- this.getProduct(validatedData.productId)
6417
+ this.categoryService.getById(validatedData.categoryId),
6418
+ this.subcategoryService.getById(
6419
+ validatedData.categoryId,
6420
+ validatedData.subcategoryId
6421
+ ),
6422
+ this.technologyService.getById(
6423
+ validatedData.categoryId,
6424
+ validatedData.subcategoryId,
6425
+ validatedData.technologyId
6426
+ ),
6427
+ this.productService.getById(
6428
+ validatedData.categoryId,
6429
+ validatedData.subcategoryId,
6430
+ validatedData.technologyId,
6431
+ validatedData.productId
6432
+ )
6429
6433
  ]);
6430
6434
  if (!category || !subcategory || !technology || !product) {
6431
6435
  throw new Error("One or more required entities not found");
@@ -6531,42 +6535,6 @@ var ProcedureService = class extends BaseService {
6531
6535
  updatedAt: serverTimestamp13()
6532
6536
  });
6533
6537
  }
6534
- /**
6535
- * Gets a category by ID
6536
- * @private
6537
- */
6538
- async getCategory(id) {
6539
- const docRef = doc12(this.db, CATEGORIES_COLLECTION, id);
6540
- const docSnap = await getDoc16(docRef);
6541
- return docSnap.exists() ? docSnap.data() : null;
6542
- }
6543
- /**
6544
- * Gets a subcategory by ID
6545
- * @private
6546
- */
6547
- async getSubcategory(id) {
6548
- const docRef = doc12(this.db, SUBCATEGORIES_COLLECTION, id);
6549
- const docSnap = await getDoc16(docRef);
6550
- return docSnap.exists() ? docSnap.data() : null;
6551
- }
6552
- /**
6553
- * Gets a technology by ID
6554
- * @private
6555
- */
6556
- async getTechnology(id) {
6557
- const docRef = doc12(this.db, TECHNOLOGIES_COLLECTION, id);
6558
- const docSnap = await getDoc16(docRef);
6559
- return docSnap.exists() ? docSnap.data() : null;
6560
- }
6561
- /**
6562
- * Gets a product by ID
6563
- * @private
6564
- */
6565
- async getProduct(id) {
6566
- const docRef = doc12(this.db, PRODUCTS_COLLECTION, id);
6567
- const docSnap = await getDoc16(docRef);
6568
- return docSnap.exists() ? docSnap.data() : null;
6569
- }
6570
6538
  };
6571
6539
 
6572
6540
  // src/services/documentation-templates/documentation-template.service.ts
@@ -9681,6 +9649,11 @@ import {
9681
9649
  updateDoc as updateDoc23,
9682
9650
  where as where19
9683
9651
  } from "firebase/firestore";
9652
+
9653
+ // src/backoffice/types/category.types.ts
9654
+ var CATEGORIES_COLLECTION = "backoffice_categories";
9655
+
9656
+ // src/backoffice/services/category.service.ts
9684
9657
  var CategoryService = class extends BaseService {
9685
9658
  /**
9686
9659
  * Referenca na Firestore kolekciju kategorija
@@ -9786,6 +9759,11 @@ import {
9786
9759
  updateDoc as updateDoc24,
9787
9760
  where as where20
9788
9761
  } from "firebase/firestore";
9762
+
9763
+ // src/backoffice/types/subcategory.types.ts
9764
+ var SUBCATEGORIES_COLLECTION = "subcategories";
9765
+
9766
+ // src/backoffice/services/subcategory.service.ts
9789
9767
  var SubcategoryService = class extends BaseService {
9790
9768
  /**
9791
9769
  * Vraća referencu na Firestore kolekciju podkategorija za određenu kategoriju
@@ -9892,6 +9870,11 @@ import {
9892
9870
  arrayUnion as arrayUnion5,
9893
9871
  arrayRemove as arrayRemove3
9894
9872
  } from "firebase/firestore";
9873
+
9874
+ // src/backoffice/types/technology.types.ts
9875
+ var TECHNOLOGIES_COLLECTION = "technologies";
9876
+
9877
+ // src/backoffice/services/technology.service.ts
9895
9878
  var DEFAULT_CERTIFICATION_REQUIREMENT = {
9896
9879
  minimumLevel: "aesthetician" /* AESTHETICIAN */,
9897
9880
  requiredSpecialties: []
@@ -10301,6 +10284,11 @@ import {
10301
10284
  updateDoc as updateDoc26,
10302
10285
  where as where22
10303
10286
  } from "firebase/firestore";
10287
+
10288
+ // src/backoffice/types/product.types.ts
10289
+ var PRODUCTS_COLLECTION = "products";
10290
+
10291
+ // src/backoffice/services/product.service.ts
10304
10292
  var ProductService = class extends BaseService {
10305
10293
  getProductsRefByTechnology(categoryId, subcategoryId, technologyId) {
10306
10294
  return collection23(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.5.9",
4
+ "version": "1.5.10",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -43,10 +43,31 @@ import {
43
43
  Product,
44
44
  PRODUCTS_COLLECTION,
45
45
  } from "../../backoffice/types/product.types";
46
+ import { CategoryService } from "../../backoffice/services/category.service";
47
+ import { SubcategoryService } from "../../backoffice/services/subcategory.service";
48
+ import { TechnologyService } from "../../backoffice/services/technology.service";
49
+ import { ProductService } from "../../backoffice/services/product.service";
46
50
 
47
51
  export class ProcedureService extends BaseService {
48
- constructor(db: Firestore, auth: Auth, app: FirebaseApp) {
52
+ private categoryService: CategoryService;
53
+ private subcategoryService: SubcategoryService;
54
+ private technologyService: TechnologyService;
55
+ private productService: ProductService;
56
+
57
+ constructor(
58
+ db: Firestore,
59
+ auth: Auth,
60
+ app: FirebaseApp,
61
+ categoryService: CategoryService,
62
+ subcategoryService: SubcategoryService,
63
+ technologyService: TechnologyService,
64
+ productService: ProductService
65
+ ) {
49
66
  super(db, auth, app);
67
+ this.categoryService = categoryService;
68
+ this.subcategoryService = subcategoryService;
69
+ this.technologyService = technologyService;
70
+ this.productService = productService;
50
71
  }
51
72
 
52
73
  /**
@@ -60,10 +81,22 @@ export class ProcedureService extends BaseService {
60
81
 
61
82
  // Get references to related entities
62
83
  const [category, subcategory, technology, product] = await Promise.all([
63
- this.getCategory(validatedData.categoryId),
64
- this.getSubcategory(validatedData.subcategoryId),
65
- this.getTechnology(validatedData.technologyId),
66
- this.getProduct(validatedData.productId),
84
+ this.categoryService.getById(validatedData.categoryId),
85
+ this.subcategoryService.getById(
86
+ validatedData.categoryId,
87
+ validatedData.subcategoryId
88
+ ),
89
+ this.technologyService.getById(
90
+ validatedData.categoryId,
91
+ validatedData.subcategoryId,
92
+ validatedData.technologyId
93
+ ),
94
+ this.productService.getById(
95
+ validatedData.categoryId,
96
+ validatedData.subcategoryId,
97
+ validatedData.technologyId,
98
+ validatedData.productId
99
+ ),
67
100
  ]);
68
101
 
69
102
  if (!category || !subcategory || !technology || !product) {
@@ -195,44 +228,4 @@ export class ProcedureService extends BaseService {
195
228
  updatedAt: serverTimestamp(),
196
229
  });
197
230
  }
198
-
199
- /**
200
- * Gets a category by ID
201
- * @private
202
- */
203
- private async getCategory(id: string): Promise<Category | null> {
204
- const docRef = doc(this.db, CATEGORIES_COLLECTION, id);
205
- const docSnap = await getDoc(docRef);
206
- return docSnap.exists() ? (docSnap.data() as Category) : null;
207
- }
208
-
209
- /**
210
- * Gets a subcategory by ID
211
- * @private
212
- */
213
- private async getSubcategory(id: string): Promise<Subcategory | null> {
214
- const docRef = doc(this.db, SUBCATEGORIES_COLLECTION, id);
215
- const docSnap = await getDoc(docRef);
216
- return docSnap.exists() ? (docSnap.data() as Subcategory) : null;
217
- }
218
-
219
- /**
220
- * Gets a technology by ID
221
- * @private
222
- */
223
- private async getTechnology(id: string): Promise<Technology | null> {
224
- const docRef = doc(this.db, TECHNOLOGIES_COLLECTION, id);
225
- const docSnap = await getDoc(docRef);
226
- return docSnap.exists() ? (docSnap.data() as Technology) : null;
227
- }
228
-
229
- /**
230
- * Gets a product by ID
231
- * @private
232
- */
233
- private async getProduct(id: string): Promise<Product | null> {
234
- const docRef = doc(this.db, PRODUCTS_COLLECTION, id);
235
- const docSnap = await getDoc(docRef);
236
- return docSnap.exists() ? (docSnap.data() as Product) : null;
237
- }
238
231
  }