@blackcode_sa/metaestetics-api 1.11.0 → 1.11.1

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 (35) hide show
  1. package/dist/admin/index.d.mts +328 -319
  2. package/dist/admin/index.d.ts +328 -319
  3. package/dist/backoffice/index.d.mts +283 -67
  4. package/dist/backoffice/index.d.ts +283 -67
  5. package/dist/backoffice/index.js +114 -6
  6. package/dist/backoffice/index.mjs +112 -6
  7. package/dist/index.d.mts +3872 -3806
  8. package/dist/index.d.ts +3872 -3806
  9. package/dist/index.js +369 -123
  10. package/dist/index.mjs +369 -124
  11. package/package.json +1 -1
  12. package/src/backoffice/expo-safe/index.ts +2 -0
  13. package/src/backoffice/services/README.md +40 -0
  14. package/src/backoffice/services/constants.service.ts +268 -0
  15. package/src/backoffice/services/technology.service.ts +122 -10
  16. package/src/backoffice/types/admin-constants.types.ts +69 -0
  17. package/src/backoffice/types/index.ts +1 -0
  18. package/src/backoffice/types/product.types.ts +3 -1
  19. package/src/backoffice/types/technology.types.ts +4 -4
  20. package/src/backoffice/validations/schemas.ts +35 -9
  21. package/src/services/appointment/appointment.service.ts +0 -5
  22. package/src/services/appointment/utils/appointment.utils.ts +124 -113
  23. package/src/services/procedure/procedure.service.ts +434 -234
  24. package/src/types/appointment/index.ts +5 -3
  25. package/src/types/clinic/index.ts +1 -6
  26. package/src/types/patient/medical-info.types.ts +3 -3
  27. package/src/types/procedure/index.ts +20 -17
  28. package/src/validations/clinic.schema.ts +1 -6
  29. package/src/validations/patient/medical-info.schema.ts +7 -2
  30. package/src/backoffice/services/__tests__/brand.service.test.ts +0 -196
  31. package/src/backoffice/services/__tests__/category.service.test.ts +0 -201
  32. package/src/backoffice/services/__tests__/product.service.test.ts +0 -358
  33. package/src/backoffice/services/__tests__/requirement.service.test.ts +0 -226
  34. package/src/backoffice/services/__tests__/subcategory.service.test.ts +0 -181
  35. package/src/backoffice/services/__tests__/technology.service.test.ts +0 -1097
@@ -10,10 +10,12 @@ import {
10
10
  type PricingMeasure,
11
11
  } from "../../backoffice/types/static/pricing.types";
12
12
  import { BlockingCondition } from "../../backoffice/types/static/blocking-condition.types";
13
- import { Contraindication } from "../../backoffice/types/static/contraindication.types";
14
13
  import { Requirement } from "../../backoffice/types/requirement.types";
15
14
  import { FilledDocumentStatus } from "../documentation-templates";
16
- import type { ProcedureFamily } from "../../backoffice";
15
+ import type {
16
+ ContraindicationDynamic,
17
+ ProcedureFamily,
18
+ } from "../../backoffice";
17
19
  import type { MediaResource } from "../../services/media/media.service";
18
20
 
19
21
  /**
@@ -245,7 +247,7 @@ export interface Appointment {
245
247
 
246
248
  /** Procedure-related conditions and requirements */
247
249
  blockingConditions: BlockingCondition[];
248
- contraindications: Contraindication[];
250
+ contraindications: ContraindicationDynamic[];
249
251
  preProcedureRequirements: Requirement[];
250
252
  postProcedureRequirements: Requirement[];
251
253
 
@@ -1,10 +1,5 @@
1
1
  import { Timestamp, FieldValue } from "firebase/firestore";
2
- import type { ProcedureFamily } from "../../backoffice/types/static/procedure-family.types";
3
- import type { TreatmentBenefit } from "../../backoffice/types/static/treatment-benefit.types";
4
- import type {
5
- Currency,
6
- PricingMeasure,
7
- } from "../../backoffice/types/static/pricing.types";
2
+
8
3
  import type { ClinicInfo } from "../profile";
9
4
  import { ClinicReviewInfo } from "../reviews";
10
5
  import { ProcedureSummaryInfo } from "../procedure";
@@ -1,7 +1,7 @@
1
1
  import { Timestamp } from "firebase/firestore";
2
2
  import { BlockingCondition } from "../../backoffice/types/static/blocking-condition.types";
3
- import { Contraindication } from "../../backoffice/types/static/contraindication.types";
4
3
  import { AllergyType, AllergySubtype } from "./allergies";
4
+ import type { ContraindicationDynamic } from "../../backoffice";
5
5
 
6
6
  export const PATIENT_MEDICAL_INFO_COLLECTION = "medical_info";
7
7
 
@@ -38,7 +38,7 @@ export interface PatientMedicalInfo {
38
38
  }[];
39
39
 
40
40
  contraindications: {
41
- condition: Contraindication;
41
+ condition: ContraindicationDynamic;
42
42
  lastOccurrence: Timestamp;
43
43
  frequency: "rare" | "occasional" | "frequent";
44
44
  isActive: boolean;
@@ -113,7 +113,7 @@ export interface UpdateBlockingConditionData
113
113
 
114
114
  // Interfejsi za kontraindikacije
115
115
  export interface AddContraindicationData {
116
- condition: Contraindication;
116
+ condition: ContraindicationDynamic;
117
117
  lastOccurrence: Timestamp;
118
118
  frequency: "rare" | "occasional" | "frequent";
119
119
  isActive: boolean;
@@ -1,25 +1,24 @@
1
- import { ProcedureFamily } from "../../backoffice/types/static/procedure-family.types";
1
+ import {
2
+ BlockingCondition,
3
+ CertificationRequirement,
4
+ ProcedureFamily,
5
+ } from "../../backoffice/types";
6
+ import {
7
+ ContraindicationDynamic,
8
+ TreatmentBenefitDynamic,
9
+ } from "../../backoffice/types/admin-constants.types";
10
+ import { Requirement } from "../../backoffice/types/requirement.types";
2
11
  import { Category } from "../../backoffice/types/category.types";
3
12
  import { Subcategory } from "../../backoffice/types/subcategory.types";
4
- import {
5
- Technology,
6
- type TechnologyDocumentationTemplate,
7
- } from "../../backoffice/types/technology.types";
13
+ import { Technology } from "../../backoffice/types/technology.types";
8
14
  import { Product } from "../../backoffice/types/product.types";
15
+ import { ClinicInfo, DoctorInfo } from "../../types/";
16
+ import { ProcedureReviewInfo } from "../reviews";
17
+ import { TechnologyDocumentationTemplate } from "../../backoffice/types/technology.types";
9
18
  import {
10
19
  PricingMeasure,
11
20
  Currency,
12
21
  } from "../../backoffice/types/static/pricing.types";
13
- import { Requirement } from "../../backoffice/types/requirement.types";
14
- import { BlockingCondition } from "../../backoffice/types/static/blocking-condition.types";
15
- import { TreatmentBenefit } from "../../backoffice/types/static/treatment-benefit.types";
16
- import { CertificationRequirement } from "../../backoffice/types/static/certification.types";
17
- import { DocumentTemplate } from "../documentation-templates";
18
- import { ClinicInfo } from "../profile";
19
- import { DoctorInfo } from "../clinic";
20
- import { PRACTITIONERS_COLLECTION } from "../practitioner";
21
- import { ProcedureReviewInfo } from "../reviews";
22
- import type { Contraindication } from "../../backoffice/types/static/contraindication.types";
23
22
  import { MediaResource } from "../../services/media/media.service";
24
23
 
25
24
  /**
@@ -58,9 +57,13 @@ export interface Procedure {
58
57
  /** Blocking conditions that prevent this procedure */
59
58
  blockingConditions: BlockingCondition[];
60
59
  /** Treatment benefits of this procedure */
61
- treatmentBenefits: TreatmentBenefit[];
60
+ treatmentBenefits: TreatmentBenefitDynamic[];
61
+ /** A list of just the string IDs of the treatment benefits, for efficient querying. */
62
+ treatmentBenefitIds: string[];
62
63
  /** Contraindications of this procedure */
63
- contraindications: Contraindication[];
64
+ contraindications: ContraindicationDynamic[];
65
+ /** A list of just the string IDs of the contraindications, for efficient querying. */
66
+ contraindicationIds: string[];
64
67
  /** Pre-procedure requirements */
65
68
  preRequirements: Requirement[];
66
69
  /** Post-procedure requirements */
@@ -7,12 +7,7 @@ import {
7
7
  PracticeType,
8
8
  Language,
9
9
  } from "../types/clinic";
10
- import { ProcedureFamily } from "../backoffice/types/static/procedure-family.types";
11
- import { TreatmentBenefit } from "../backoffice/types/static/treatment-benefit.types";
12
- import {
13
- Currency,
14
- PricingMeasure,
15
- } from "../backoffice/types/static/pricing.types";
10
+
16
11
  import { clinicReviewInfoSchema } from "./reviews.schema";
17
12
  import {
18
13
  procedureSummaryInfoSchema,
@@ -7,7 +7,6 @@ import {
7
7
  CosmeticAllergySubtype,
8
8
  } from "../../types/patient/allergies";
9
9
  import { BlockingCondition } from "../../backoffice/types/static/blocking-condition.types";
10
- import { Contraindication } from "../../backoffice/types/static/contraindication.types";
11
10
  import { timestampSchema } from "../common.schema";
12
11
 
13
12
  export const allergySubtypeSchema = z.union([
@@ -50,8 +49,14 @@ export const blockingConditionSchema = z.object({
50
49
  isActive: z.boolean(),
51
50
  });
52
51
 
52
+ export const contraindicationDynamicSchema = z.object({
53
+ id: z.string(),
54
+ name: z.string(),
55
+ description: z.string().optional(),
56
+ });
57
+
53
58
  export const contraindicationSchema = z.object({
54
- condition: z.nativeEnum(Contraindication),
59
+ condition: contraindicationDynamicSchema,
55
60
  lastOccurrence: timestampSchema,
56
61
  frequency: z.enum(["rare", "occasional", "frequent"]),
57
62
  notes: z.string().optional().nullable(),
@@ -1,196 +0,0 @@
1
- import { BrandService } from "../brand.service";
2
- import { Brand } from "../../types/brand.types";
3
- import {
4
- collection,
5
- doc,
6
- getDoc,
7
- getDocs,
8
- addDoc,
9
- updateDoc,
10
- query,
11
- where,
12
- } from "firebase/firestore";
13
-
14
- // Mock Firebase
15
- jest.mock("firebase/firestore");
16
- jest.mock("../../../config/firebase", () => ({
17
- getFirebaseInstance: jest.fn().mockResolvedValue({
18
- db: {},
19
- auth: {},
20
- }),
21
- }));
22
-
23
- const COLLECTION = "backoffice_brands";
24
-
25
- describe("BrandService", () => {
26
- let service: BrandService;
27
-
28
- const mockBrand: Omit<Brand, "id" | "createdAt" | "updatedAt"> = {
29
- name: "Test Brand",
30
- manufacturer: "Test Manufacturer",
31
- website: "https://test.com",
32
- description: "Test Description",
33
- isActive: true,
34
- };
35
-
36
- beforeEach(() => {
37
- jest.clearAllMocks();
38
- service = new BrandService();
39
- });
40
-
41
- describe("create", () => {
42
- it("treba da kreira novi brend sa ispravnim podacima", async () => {
43
- const mockDocRef = { id: "test-id" };
44
- (collection as jest.Mock).mockReturnValue("brands-collection");
45
- (addDoc as jest.Mock).mockResolvedValue(mockDocRef);
46
-
47
- const result = await service.create(mockBrand);
48
-
49
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
50
- expect(addDoc).toHaveBeenCalledWith(
51
- "brands-collection",
52
- expect.objectContaining({
53
- ...mockBrand,
54
- createdAt: expect.any(Date),
55
- updatedAt: expect.any(Date),
56
- })
57
- );
58
- expect(result).toEqual({
59
- id: "test-id",
60
- ...mockBrand,
61
- createdAt: expect.any(Date),
62
- updatedAt: expect.any(Date),
63
- });
64
- });
65
- });
66
-
67
- describe("getAll", () => {
68
- it("treba da vrati sve aktivne brendove", async () => {
69
- const mockDocs = [
70
- {
71
- id: "test-id-1",
72
- data: () => ({
73
- ...mockBrand,
74
- createdAt: new Date(),
75
- updatedAt: new Date(),
76
- }),
77
- },
78
- {
79
- id: "test-id-2",
80
- data: () => ({
81
- ...mockBrand,
82
- name: "Test Brand 2",
83
- createdAt: new Date(),
84
- updatedAt: new Date(),
85
- }),
86
- },
87
- ];
88
-
89
- (collection as jest.Mock).mockReturnValue("brands-collection");
90
- (query as jest.Mock).mockReturnValue("filtered-query");
91
- (where as jest.Mock).mockReturnValue("where-clause");
92
- (getDocs as jest.Mock).mockResolvedValue({ docs: mockDocs });
93
-
94
- const result = await service.getAll();
95
-
96
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
97
- expect(query).toHaveBeenCalledWith("brands-collection", "where-clause");
98
- expect(where).toHaveBeenCalledWith("isActive", "==", true);
99
- expect(result).toHaveLength(2);
100
- expect(result[0]).toEqual({
101
- id: "test-id-1",
102
- ...mockBrand,
103
- createdAt: expect.any(Date),
104
- updatedAt: expect.any(Date),
105
- });
106
- });
107
- });
108
-
109
- describe("update", () => {
110
- it("treba da ažurira postojeći brend", async () => {
111
- const updateData = { name: "Updated Brand" };
112
-
113
- (collection as jest.Mock).mockReturnValue("brands-collection");
114
- (doc as jest.Mock).mockReturnValue("doc-ref");
115
- (getDoc as jest.Mock).mockResolvedValue({
116
- exists: () => true,
117
- id: "test-id",
118
- data: () => ({
119
- ...mockBrand,
120
- ...updateData,
121
- createdAt: new Date(),
122
- updatedAt: new Date(),
123
- }),
124
- });
125
- (updateDoc as jest.Mock).mockResolvedValue(undefined);
126
-
127
- const result = await service.update("test-id", updateData);
128
-
129
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
130
- expect(doc).toHaveBeenCalledWith("brands-collection", "test-id");
131
- expect(updateDoc).toHaveBeenCalledWith(
132
- "doc-ref",
133
- expect.objectContaining({
134
- ...updateData,
135
- updatedAt: expect.any(Date),
136
- })
137
- );
138
- });
139
- });
140
-
141
- describe("delete", () => {
142
- it("treba da izvrši soft delete brenda", async () => {
143
- (collection as jest.Mock).mockReturnValue("brands-collection");
144
- (doc as jest.Mock).mockReturnValue("doc-ref");
145
- (updateDoc as jest.Mock).mockResolvedValue(undefined);
146
-
147
- await service.delete("test-id");
148
-
149
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
150
- expect(doc).toHaveBeenCalledWith("brands-collection", "test-id");
151
- expect(updateDoc).toHaveBeenCalledWith("doc-ref", {
152
- isActive: false,
153
- updatedAt: expect.any(Date),
154
- });
155
- });
156
- });
157
-
158
- describe("getById", () => {
159
- it("treba da vrati brend po ID-u", async () => {
160
- (collection as jest.Mock).mockReturnValue("brands-collection");
161
- (doc as jest.Mock).mockReturnValue("doc-ref");
162
- (getDoc as jest.Mock).mockResolvedValue({
163
- exists: () => true,
164
- id: "test-id",
165
- data: () => ({
166
- ...mockBrand,
167
- createdAt: new Date(),
168
- updatedAt: new Date(),
169
- }),
170
- });
171
-
172
- const result = await service.getById("test-id");
173
-
174
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
175
- expect(doc).toHaveBeenCalledWith("brands-collection", "test-id");
176
- expect(result).toEqual({
177
- id: "test-id",
178
- ...mockBrand,
179
- createdAt: expect.any(Date),
180
- updatedAt: expect.any(Date),
181
- });
182
- });
183
-
184
- it("treba da vrati null ako brend ne postoji", async () => {
185
- (collection as jest.Mock).mockReturnValue("brands-collection");
186
- (doc as jest.Mock).mockReturnValue("doc-ref");
187
- (getDoc as jest.Mock).mockResolvedValue({
188
- exists: () => false,
189
- });
190
-
191
- const result = await service.getById("non-existent-id");
192
-
193
- expect(result).toBeNull();
194
- });
195
- });
196
- });
@@ -1,201 +0,0 @@
1
- import { CategoryService } from "../category.service";
2
- import { Category } from "../../types/category.types";
3
- import { ProcedureFamily } from "../../types/static/procedure-family.types";
4
- import {
5
- collection,
6
- doc,
7
- getDoc,
8
- getDocs,
9
- addDoc,
10
- updateDoc,
11
- query,
12
- where,
13
- } from "firebase/firestore";
14
-
15
- // Mock Firebase
16
- jest.mock("firebase/firestore");
17
- jest.mock("../../../config/firebase", () => ({
18
- getFirebaseInstance: jest.fn().mockResolvedValue({
19
- db: {},
20
- auth: {},
21
- }),
22
- }));
23
-
24
- const COLLECTION = "backoffice_categories";
25
-
26
- describe("CategoryService", () => {
27
- let service: CategoryService;
28
-
29
- const mockCategory: Omit<Category, "id" | "createdAt" | "updatedAt"> = {
30
- name: "Test Category",
31
- description: "Test Description",
32
- family: ProcedureFamily.AESTHETICS,
33
- isActive: true,
34
- };
35
-
36
- beforeEach(() => {
37
- jest.clearAllMocks();
38
- service = new CategoryService();
39
- });
40
-
41
- describe("create", () => {
42
- it("treba da kreira novu kategoriju", async () => {
43
- const mockDocRef = { id: "test-id" };
44
- (collection as jest.Mock).mockReturnValue("categories-collection");
45
- (addDoc as jest.Mock).mockResolvedValue(mockDocRef);
46
-
47
- const result = await service.create(mockCategory);
48
-
49
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
50
- expect(addDoc).toHaveBeenCalledWith(
51
- "categories-collection",
52
- expect.objectContaining({
53
- ...mockCategory,
54
- createdAt: expect.any(Date),
55
- updatedAt: expect.any(Date),
56
- })
57
- );
58
- expect(result).toEqual({
59
- id: "test-id",
60
- ...mockCategory,
61
- createdAt: expect.any(Date),
62
- updatedAt: expect.any(Date),
63
- });
64
- });
65
- });
66
-
67
- describe("getAll", () => {
68
- it("treba da vrati sve aktivne kategorije", async () => {
69
- const mockDocs = [
70
- {
71
- id: "cat-1",
72
- data: () => ({
73
- ...mockCategory,
74
- createdAt: new Date(),
75
- updatedAt: new Date(),
76
- }),
77
- },
78
- {
79
- id: "cat-2",
80
- data: () => ({
81
- ...mockCategory,
82
- name: "Test Category 2",
83
- createdAt: new Date(),
84
- updatedAt: new Date(),
85
- }),
86
- },
87
- ];
88
-
89
- (collection as jest.Mock).mockReturnValue("categories-collection");
90
- (query as jest.Mock).mockReturnValue("filtered-query");
91
- (where as jest.Mock).mockReturnValue("where-clause");
92
- (getDocs as jest.Mock).mockResolvedValue({ docs: mockDocs });
93
-
94
- const results = await service.getAll();
95
-
96
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
97
- expect(query).toHaveBeenCalledWith(
98
- "categories-collection",
99
- "where-clause"
100
- );
101
- expect(where).toHaveBeenCalledWith("isActive", "==", true);
102
- expect(results).toHaveLength(2);
103
- expect(results[0]).toEqual({
104
- id: "cat-1",
105
- ...mockCategory,
106
- createdAt: expect.any(Date),
107
- updatedAt: expect.any(Date),
108
- });
109
- });
110
- });
111
-
112
- describe("getAllByFamily", () => {
113
- it("treba da vrati sve kategorije za određenu familiju", async () => {
114
- const mockDocs = [
115
- {
116
- id: "cat-1",
117
- data: () => ({
118
- ...mockCategory,
119
- family: ProcedureFamily.AESTHETICS,
120
- createdAt: new Date(),
121
- updatedAt: new Date(),
122
- }),
123
- },
124
- ];
125
-
126
- (collection as jest.Mock).mockReturnValue("categories-collection");
127
- (query as jest.Mock).mockReturnValue("filtered-query");
128
- (where as jest.Mock).mockReturnValue("where-clause");
129
- (getDocs as jest.Mock).mockResolvedValue({ docs: mockDocs });
130
-
131
- const results = await service.getAllByFamily(ProcedureFamily.AESTHETICS);
132
-
133
- expect(query).toHaveBeenCalledWith(
134
- "categories-collection",
135
- "where-clause",
136
- "where-clause"
137
- );
138
- expect(where).toHaveBeenCalledWith(
139
- "family",
140
- "==",
141
- ProcedureFamily.AESTHETICS
142
- );
143
- expect(where).toHaveBeenCalledWith("isActive", "==", true);
144
- expect(results).toHaveLength(1);
145
- expect(results[0].family).toBe(ProcedureFamily.AESTHETICS);
146
- });
147
- });
148
-
149
- describe("update", () => {
150
- it("treba da ažurira postojeću kategoriju", async () => {
151
- const updateData = { name: "Updated Category" };
152
-
153
- (collection as jest.Mock).mockReturnValue("categories-collection");
154
- (doc as jest.Mock).mockReturnValue("doc-ref");
155
- (updateDoc as jest.Mock).mockResolvedValue(undefined);
156
- (getDoc as jest.Mock).mockResolvedValue({
157
- exists: () => true,
158
- id: "test-id",
159
- data: () => ({
160
- ...mockCategory,
161
- ...updateData,
162
- createdAt: new Date(),
163
- updatedAt: new Date(),
164
- }),
165
- });
166
-
167
- const result = await service.update("test-id", updateData);
168
-
169
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
170
- expect(doc).toHaveBeenCalledWith("categories-collection", "test-id");
171
- expect(updateDoc).toHaveBeenCalledWith("doc-ref", {
172
- ...updateData,
173
- updatedAt: expect.any(Date),
174
- });
175
- expect(result).toEqual({
176
- id: "test-id",
177
- ...mockCategory,
178
- ...updateData,
179
- createdAt: expect.any(Date),
180
- updatedAt: expect.any(Date),
181
- });
182
- });
183
- });
184
-
185
- describe("delete", () => {
186
- it("treba da izvrši soft delete kategorije", async () => {
187
- (collection as jest.Mock).mockReturnValue("categories-collection");
188
- (doc as jest.Mock).mockReturnValue("doc-ref");
189
- (updateDoc as jest.Mock).mockResolvedValue(undefined);
190
-
191
- await service.delete("test-id");
192
-
193
- expect(collection).toHaveBeenCalledWith({}, COLLECTION);
194
- expect(doc).toHaveBeenCalledWith("categories-collection", "test-id");
195
- expect(updateDoc).toHaveBeenCalledWith("doc-ref", {
196
- isActive: false,
197
- updatedAt: expect.any(Date),
198
- });
199
- });
200
- });
201
- });