@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
@@ -1,268 +0,0 @@
1
- import {
2
- arrayRemove,
3
- arrayUnion,
4
- collection,
5
- doc,
6
- getDoc,
7
- setDoc,
8
- updateDoc,
9
- } from "firebase/firestore";
10
- import { BaseService } from "../../services/base.service";
11
- import {
12
- ContraindicationDynamic,
13
- ContraindicationsDocument,
14
- TreatmentBenefitDynamic,
15
- TreatmentBenefitsDocument,
16
- } from "../types/admin-constants.types";
17
-
18
- const ADMIN_CONSTANTS_COLLECTION = "admin-constants";
19
- const TREATMENT_BENEFITS_DOC = "treatment-benefits";
20
- const CONTRAINDICATIONS_DOC = "contraindications";
21
-
22
- /**
23
- * @class ConstantsService
24
- * @description Service for managing administrative constants, such as treatment benefits and contraindications.
25
- * These constants are stored in a single Firestore collection 'admin-constants',
26
- * with each type of constant in its own document ('treatment-benefits', 'contraindications').
27
- * The constants themselves are stored in an array within these documents.
28
- * @extends {BaseService}
29
- */
30
- export class ConstantsService extends BaseService {
31
- /**
32
- * @description Gets the reference to the document holding treatment benefits.
33
- * @private
34
- * @type {DocumentReference}
35
- */
36
- private get treatmentBenefitsDocRef() {
37
- return doc(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
38
- }
39
-
40
- /**
41
- * @description Gets the reference to the document holding contraindications.
42
- * @private
43
- * @type {DocumentReference}
44
- */
45
- private get contraindicationsDocRef() {
46
- return doc(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
47
- }
48
-
49
- // =================================================================
50
- // Treatment Benefits
51
- // =================================================================
52
-
53
- /**
54
- * @description Retrieves all treatment benefits.
55
- * @returns {Promise<TreatmentBenefitDynamic[]>} An array of all treatment benefits.
56
- */
57
- async getAllBenefits(): Promise<TreatmentBenefitDynamic[]> {
58
- const docSnap = await getDoc(this.treatmentBenefitsDocRef);
59
- if (!docSnap.exists()) {
60
- return [];
61
- }
62
- return (docSnap.data() as TreatmentBenefitsDocument).benefits;
63
- }
64
-
65
- /**
66
- * @description Adds a new treatment benefit.
67
- * @param {Omit<TreatmentBenefitDynamic, "id">} benefit - The treatment benefit to add, without an ID.
68
- * @returns {Promise<TreatmentBenefitDynamic>} The newly created treatment benefit with its generated ID.
69
- */
70
- async addTreatmentBenefit(
71
- benefit: Omit<TreatmentBenefitDynamic, "id">
72
- ): Promise<TreatmentBenefitDynamic> {
73
- const newBenefit: TreatmentBenefitDynamic = {
74
- id: this.generateId(),
75
- ...benefit,
76
- };
77
-
78
- const docSnap = await getDoc(this.treatmentBenefitsDocRef);
79
- if (!docSnap.exists()) {
80
- await setDoc(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
81
- } else {
82
- await updateDoc(this.treatmentBenefitsDocRef, {
83
- benefits: arrayUnion(newBenefit),
84
- });
85
- }
86
-
87
- return newBenefit;
88
- }
89
-
90
- /**
91
- * @description Retrieves a single treatment benefit by its ID.
92
- * @param {string} benefitId - The ID of the treatment benefit to retrieve.
93
- * @returns {Promise<TreatmentBenefitDynamic | undefined>} The found treatment benefit or undefined.
94
- */
95
- async getBenefitById(
96
- benefitId: string
97
- ): Promise<TreatmentBenefitDynamic | undefined> {
98
- const benefits = await this.getAllBenefits();
99
- return benefits.find((b) => b.id === benefitId);
100
- }
101
-
102
- /**
103
- * @description Searches for treatment benefits by name (case-insensitive).
104
- * @param {string} searchTerm - The term to search for in the benefit names.
105
- * @returns {Promise<TreatmentBenefitDynamic[]>} An array of matching treatment benefits.
106
- */
107
- async searchBenefitsByName(
108
- searchTerm: string
109
- ): Promise<TreatmentBenefitDynamic[]> {
110
- const benefits = await this.getAllBenefits();
111
- const normalizedSearchTerm = searchTerm.toLowerCase();
112
- return benefits.filter((b) =>
113
- b.name.toLowerCase().includes(normalizedSearchTerm)
114
- );
115
- }
116
-
117
- /**
118
- * @description Updates an existing treatment benefit.
119
- * @param {TreatmentBenefitDynamic} benefit - The treatment benefit with updated data. Its ID must match an existing benefit.
120
- * @returns {Promise<TreatmentBenefitDynamic>} The updated treatment benefit.
121
- * @throws {Error} If the treatment benefit is not found.
122
- */
123
- async updateTreatmentBenefit(
124
- benefit: TreatmentBenefitDynamic
125
- ): Promise<TreatmentBenefitDynamic> {
126
- const benefits = await this.getAllBenefits();
127
- const benefitIndex = benefits.findIndex((b) => b.id === benefit.id);
128
-
129
- if (benefitIndex === -1) {
130
- throw new Error("Treatment benefit not found.");
131
- }
132
-
133
- benefits[benefitIndex] = benefit;
134
-
135
- await updateDoc(this.treatmentBenefitsDocRef, { benefits });
136
- return benefit;
137
- }
138
-
139
- /**
140
- * @description Deletes a treatment benefit by its ID.
141
- * @param {string} benefitId - The ID of the treatment benefit to delete.
142
- * @returns {Promise<void>}
143
- */
144
- async deleteTreatmentBenefit(benefitId: string): Promise<void> {
145
- const benefits = await this.getAllBenefits();
146
- const benefitToRemove = benefits.find((b) => b.id === benefitId);
147
-
148
- if (!benefitToRemove) {
149
- return;
150
- }
151
-
152
- await updateDoc(this.treatmentBenefitsDocRef, {
153
- benefits: arrayRemove(benefitToRemove),
154
- });
155
- }
156
-
157
- // =================================================================
158
- // Contraindications
159
- // =================================================================
160
-
161
- /**
162
- * @description Retrieves all contraindications.
163
- * @returns {Promise<ContraindicationDynamic[]>} An array of all contraindications.
164
- */
165
- async getAllContraindications(): Promise<ContraindicationDynamic[]> {
166
- const docSnap = await getDoc(this.contraindicationsDocRef);
167
- if (!docSnap.exists()) {
168
- return [];
169
- }
170
- return (docSnap.data() as ContraindicationsDocument).contraindications;
171
- }
172
-
173
- /**
174
- * @description Adds a new contraindication.
175
- * @param {Omit<ContraindicationDynamic, "id">} contraindication - The contraindication to add, without an ID.
176
- * @returns {Promise<ContraindicationDynamic>} The newly created contraindication with its generated ID.
177
- */
178
- async addContraindication(
179
- contraindication: Omit<ContraindicationDynamic, "id">
180
- ): Promise<ContraindicationDynamic> {
181
- const newContraindication: ContraindicationDynamic = {
182
- id: this.generateId(),
183
- ...contraindication,
184
- };
185
-
186
- const docSnap = await getDoc(this.contraindicationsDocRef);
187
- if (!docSnap.exists()) {
188
- await setDoc(this.contraindicationsDocRef, {
189
- contraindications: [newContraindication],
190
- });
191
- } else {
192
- await updateDoc(this.contraindicationsDocRef, {
193
- contraindications: arrayUnion(newContraindication),
194
- });
195
- }
196
-
197
- return newContraindication;
198
- }
199
-
200
- /**
201
- * @description Retrieves a single contraindication by its ID.
202
- * @param {string} contraindicationId - The ID of the contraindication to retrieve.
203
- * @returns {Promise<ContraindicationDynamic | undefined>} The found contraindication or undefined.
204
- */
205
- async getContraindicationById(
206
- contraindicationId: string
207
- ): Promise<ContraindicationDynamic | undefined> {
208
- const contraindications = await this.getAllContraindications();
209
- return contraindications.find((c) => c.id === contraindicationId);
210
- }
211
-
212
- /**
213
- * @description Searches for contraindications by name (case-insensitive).
214
- * @param {string} searchTerm - The term to search for in the contraindication names.
215
- * @returns {Promise<ContraindicationDynamic[]>} An array of matching contraindications.
216
- */
217
- async searchContraindicationsByName(
218
- searchTerm: string
219
- ): Promise<ContraindicationDynamic[]> {
220
- const contraindications = await this.getAllContraindications();
221
- const normalizedSearchTerm = searchTerm.toLowerCase();
222
- return contraindications.filter((c) =>
223
- c.name.toLowerCase().includes(normalizedSearchTerm)
224
- );
225
- }
226
-
227
- /**
228
- * @description Updates an existing contraindication.
229
- * @param {ContraindicationDynamic} contraindication - The contraindication with updated data. Its ID must match an existing one.
230
- * @returns {Promise<ContraindicationDynamic>} The updated contraindication.
231
- * @throws {Error} If the contraindication is not found.
232
- */
233
- async updateContraindication(
234
- contraindication: ContraindicationDynamic
235
- ): Promise<ContraindicationDynamic> {
236
- const contraindications = await this.getAllContraindications();
237
- const index = contraindications.findIndex(
238
- (c) => c.id === contraindication.id
239
- );
240
-
241
- if (index === -1) {
242
- throw new Error("Contraindication not found.");
243
- }
244
-
245
- contraindications[index] = contraindication;
246
-
247
- await updateDoc(this.contraindicationsDocRef, { contraindications });
248
- return contraindication;
249
- }
250
-
251
- /**
252
- * @description Deletes a contraindication by its ID.
253
- * @param {string} contraindicationId - The ID of the contraindication to delete.
254
- * @returns {Promise<void>}
255
- */
256
- async deleteContraindication(contraindicationId: string): Promise<void> {
257
- const contraindications = await this.getAllContraindications();
258
- const toRemove = contraindications.find((c) => c.id === contraindicationId);
259
-
260
- if (!toRemove) {
261
- return;
262
- }
263
-
264
- await updateDoc(this.contraindicationsDocRef, {
265
- contraindications: arrayRemove(toRemove),
266
- });
267
- }
268
- }
@@ -1,69 +0,0 @@
1
- /**
2
- * @file Defines types for dynamically managed administrative constants,
3
- * such as treatment benefits and contraindications. These are stored in
4
- * the 'admin-constants' collection in Firestore.
5
- */
6
-
7
- /**
8
- * Represents a single dynamic treatment benefit.
9
- * These are positive effects or results a patient can expect from a treatment.
10
- */
11
- export interface TreatmentBenefitDynamic {
12
- /**
13
- * A unique identifier for the benefit, typically in snake_case.
14
- * @example "wrinkle_reduction"
15
- */
16
- id: string;
17
-
18
- /**
19
- * A human-readable name for the treatment benefit.
20
- * @example "Wrinkle Reduction"
21
- */
22
- name: string;
23
-
24
- /**
25
- * A detailed description of the benefit.
26
- */
27
- description?: string;
28
- }
29
-
30
- /**
31
- * Defines the structure of the document storing all treatment benefits
32
- * in the 'admin-constants' collection.
33
- * The document ID for this type should be 'treatment-benefits'.
34
- */
35
- export interface TreatmentBenefitsDocument {
36
- benefits: TreatmentBenefitDynamic[];
37
- }
38
-
39
- /**
40
- * Represents a single dynamic contraindication.
41
- * These are conditions or factors that can affect a procedure and require special attention.
42
- */
43
- export interface ContraindicationDynamic {
44
- /**
45
- * A unique identifier for the contraindication, typically in snake_case.
46
- * @example "sensitive_skin"
47
- */
48
- id: string;
49
-
50
- /**
51
- * A human-readable name for the contraindication.
52
- * @example "Sensitive Skin"
53
- */
54
- name: string;
55
-
56
- /**
57
- * A detailed description of the contraindication.
58
- */
59
- description?: string;
60
- }
61
-
62
- /**
63
- * Defines the structure of the document storing all contraindications
64
- * in the 'admin-constants' collection.
65
- * The document ID for this type should be 'contraindications'.
66
- */
67
- export interface ContraindicationsDocument {
68
- contraindications: ContraindicationDynamic[];
69
- }