@blackcode_sa/metaestetics-api 1.11.3 → 1.12.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.
- package/dist/admin/index.d.mts +378 -334
- package/dist/admin/index.d.ts +378 -334
- package/dist/backoffice/index.d.mts +1198 -430
- package/dist/backoffice/index.d.ts +1198 -430
- package/dist/backoffice/index.js +1128 -245
- package/dist/backoffice/index.mjs +1119 -209
- package/dist/index.d.mts +4478 -4031
- package/dist/index.d.ts +4478 -4031
- package/dist/index.js +1974 -757
- package/dist/index.mjs +1735 -490
- package/package.json +1 -1
- package/src/backoffice/expo-safe/index.ts +4 -0
- package/src/backoffice/services/README.md +40 -0
- package/src/backoffice/services/brand.service.ts +85 -6
- package/src/backoffice/services/category.service.ts +92 -10
- package/src/backoffice/services/constants.service.ts +308 -0
- package/src/backoffice/services/documentation-template.service.ts +56 -2
- package/src/backoffice/services/index.ts +1 -0
- package/src/backoffice/services/product.service.ts +126 -5
- package/src/backoffice/services/requirement.service.ts +13 -0
- package/src/backoffice/services/subcategory.service.ts +184 -13
- package/src/backoffice/services/technology.service.ts +344 -129
- package/src/backoffice/types/admin-constants.types.ts +69 -0
- package/src/backoffice/types/brand.types.ts +1 -0
- package/src/backoffice/types/index.ts +2 -0
- package/src/backoffice/types/procedure-product.types.ts +38 -0
- package/src/backoffice/types/product.types.ts +31 -4
- package/src/backoffice/types/static/contraindication.types.ts +1 -0
- package/src/backoffice/types/static/treatment-benefit.types.ts +1 -0
- package/src/backoffice/types/technology.types.ts +113 -4
- package/src/backoffice/validations/schemas.ts +35 -9
- package/src/services/appointment/appointment.service.ts +0 -5
- package/src/services/appointment/utils/appointment.utils.ts +124 -113
- package/src/services/base.service.ts +10 -3
- package/src/services/documentation-templates/documentation-template.service.ts +116 -0
- package/src/services/media/media.service.ts +2 -2
- package/src/services/practitioner/practitioner.service.ts +201 -83
- package/src/services/procedure/README.md +76 -1
- package/src/services/procedure/procedure.service.ts +538 -235
- package/src/types/appointment/index.ts +2 -3
- package/src/types/clinic/index.ts +1 -6
- package/src/types/patient/medical-info.types.ts +3 -3
- package/src/types/procedure/index.ts +39 -20
- package/src/validations/clinic.schema.ts +1 -6
- package/src/validations/patient/medical-info.schema.ts +7 -2
- package/src/validations/procedure-product.schema.ts +41 -0
- package/src/validations/procedure.schema.ts +59 -8
- package/src/backoffice/services/__tests__/brand.service.test.ts +0 -196
- package/src/backoffice/services/__tests__/category.service.test.ts +0 -201
- package/src/backoffice/services/__tests__/product.service.test.ts +0 -358
- package/src/backoffice/services/__tests__/requirement.service.test.ts +0 -226
- package/src/backoffice/services/__tests__/subcategory.service.test.ts +0 -181
- package/src/backoffice/services/__tests__/technology.service.test.ts +0 -1097
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { RequirementService } from "../requirement.service";
|
|
2
|
-
import {
|
|
3
|
-
Requirement,
|
|
4
|
-
RequirementType,
|
|
5
|
-
TimeUnit,
|
|
6
|
-
} from "../../types/requirement.types";
|
|
7
|
-
import {
|
|
8
|
-
collection,
|
|
9
|
-
doc,
|
|
10
|
-
getDoc,
|
|
11
|
-
getDocs,
|
|
12
|
-
addDoc,
|
|
13
|
-
updateDoc,
|
|
14
|
-
query,
|
|
15
|
-
where,
|
|
16
|
-
} from "firebase/firestore";
|
|
17
|
-
|
|
18
|
-
// Mock Firebase Firestore
|
|
19
|
-
jest.mock("firebase/firestore");
|
|
20
|
-
|
|
21
|
-
// Dodati na vrh fajla
|
|
22
|
-
jest.mock("../../../config/firebase", () => ({
|
|
23
|
-
getFirebaseInstance: jest.fn().mockResolvedValue({
|
|
24
|
-
db: {},
|
|
25
|
-
auth: {},
|
|
26
|
-
}),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
const COLLECTION = "backoffice_requirements";
|
|
30
|
-
|
|
31
|
-
describe("RequirementService", () => {
|
|
32
|
-
let service: RequirementService;
|
|
33
|
-
const mockDb = {} as any;
|
|
34
|
-
|
|
35
|
-
// Test data
|
|
36
|
-
const mockRequirement: Omit<Requirement, "id" | "createdAt" | "updatedAt"> = {
|
|
37
|
-
name: "Test Requirement",
|
|
38
|
-
description: "Test Description",
|
|
39
|
-
type: RequirementType.PRE,
|
|
40
|
-
timeframe: {
|
|
41
|
-
duration: 2,
|
|
42
|
-
unit: TimeUnit.HOURS,
|
|
43
|
-
notifyAt: [1, 2],
|
|
44
|
-
},
|
|
45
|
-
importance: "high",
|
|
46
|
-
isActive: true,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
jest.clearAllMocks();
|
|
51
|
-
service = new RequirementService();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("create", () => {
|
|
55
|
-
it("treba da kreira novi zahtev", async () => {
|
|
56
|
-
const mockDocRef = { id: "test-id" };
|
|
57
|
-
(collection as jest.Mock).mockReturnValue("requirements-collection");
|
|
58
|
-
(addDoc as jest.Mock).mockResolvedValue(mockDocRef);
|
|
59
|
-
|
|
60
|
-
const result = await service.create(mockRequirement);
|
|
61
|
-
|
|
62
|
-
expect(collection).toHaveBeenCalledWith(mockDb, COLLECTION);
|
|
63
|
-
expect(addDoc).toHaveBeenCalledWith(
|
|
64
|
-
"requirements-collection",
|
|
65
|
-
expect.objectContaining({
|
|
66
|
-
...mockRequirement,
|
|
67
|
-
createdAt: expect.any(Date),
|
|
68
|
-
updatedAt: expect.any(Date),
|
|
69
|
-
})
|
|
70
|
-
);
|
|
71
|
-
expect(result).toEqual({
|
|
72
|
-
id: "test-id",
|
|
73
|
-
...mockRequirement,
|
|
74
|
-
createdAt: expect.any(Date),
|
|
75
|
-
updatedAt: expect.any(Date),
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("treba da baci grešku ako kreiranje ne uspe", async () => {
|
|
80
|
-
(collection as jest.Mock).mockReturnValue("requirements-collection");
|
|
81
|
-
(addDoc as jest.Mock).mockRejectedValue(new Error("Firebase Error"));
|
|
82
|
-
|
|
83
|
-
await expect(service.create(mockRequirement)).rejects.toThrow(
|
|
84
|
-
"Firebase Error"
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe("getAll", () => {
|
|
90
|
-
it("treba da vrati sve aktivne zahteve", async () => {
|
|
91
|
-
const mockDocs = [
|
|
92
|
-
{
|
|
93
|
-
id: "req-1",
|
|
94
|
-
data: () => ({ ...mockRequirement }),
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: "req-2",
|
|
98
|
-
data: () => ({ ...mockRequirement }),
|
|
99
|
-
},
|
|
100
|
-
];
|
|
101
|
-
|
|
102
|
-
(collection as jest.Mock).mockReturnValue("requirements-collection");
|
|
103
|
-
(query as jest.Mock).mockReturnValue("filtered-query");
|
|
104
|
-
(where as jest.Mock).mockReturnValue("where-clause");
|
|
105
|
-
(getDocs as jest.Mock).mockResolvedValue({ docs: mockDocs });
|
|
106
|
-
|
|
107
|
-
const results = await service.getAll();
|
|
108
|
-
|
|
109
|
-
expect(collection).toHaveBeenCalledWith(mockDb, COLLECTION);
|
|
110
|
-
expect(query).toHaveBeenCalledWith(
|
|
111
|
-
"requirements-collection",
|
|
112
|
-
"where-clause"
|
|
113
|
-
);
|
|
114
|
-
expect(where).toHaveBeenCalledWith("isActive", "==", true);
|
|
115
|
-
expect(results).toHaveLength(2);
|
|
116
|
-
expect(results[0]).toEqual({
|
|
117
|
-
id: "req-1",
|
|
118
|
-
...mockRequirement,
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe("getById", () => {
|
|
124
|
-
it("treba da vrati zahtev po ID-u", async () => {
|
|
125
|
-
const mockDoc = {
|
|
126
|
-
exists: () => true,
|
|
127
|
-
data: () => ({ ...mockRequirement }),
|
|
128
|
-
id: "test-id",
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
(collection as jest.Mock).mockReturnValue("requirements-collection");
|
|
132
|
-
(doc as jest.Mock).mockReturnValue("doc-ref");
|
|
133
|
-
(getDoc as jest.Mock).mockResolvedValue(mockDoc);
|
|
134
|
-
|
|
135
|
-
const result = await service.getById("test-id");
|
|
136
|
-
|
|
137
|
-
expect(collection).toHaveBeenCalledWith(mockDb, COLLECTION);
|
|
138
|
-
expect(doc).toHaveBeenCalledWith("requirements-collection", "test-id");
|
|
139
|
-
expect(result).toEqual({
|
|
140
|
-
id: "test-id",
|
|
141
|
-
...mockRequirement,
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("treba da vrati null ako zahtev ne postoji", async () => {
|
|
146
|
-
const mockDoc = {
|
|
147
|
-
exists: () => false,
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
(collection as jest.Mock).mockReturnValue("requirements-collection");
|
|
151
|
-
(doc as jest.Mock).mockReturnValue("doc-ref");
|
|
152
|
-
(getDoc as jest.Mock).mockResolvedValue(mockDoc);
|
|
153
|
-
|
|
154
|
-
const result = await service.getById("non-existent-id");
|
|
155
|
-
|
|
156
|
-
expect(result).toBeNull();
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe("update", () => {
|
|
161
|
-
it("treba da ažurira postojeći zahtev", async () => {
|
|
162
|
-
const updateData = {
|
|
163
|
-
name: "Updated Name",
|
|
164
|
-
description: "Updated Description",
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
(collection as jest.Mock).mockReturnValue("requirements-collection");
|
|
168
|
-
(doc as jest.Mock).mockReturnValue("doc-ref");
|
|
169
|
-
(updateDoc as jest.Mock).mockResolvedValue(undefined);
|
|
170
|
-
|
|
171
|
-
await service.update("test-id", updateData);
|
|
172
|
-
|
|
173
|
-
expect(collection).toHaveBeenCalledWith(mockDb, COLLECTION);
|
|
174
|
-
expect(doc).toHaveBeenCalledWith("requirements-collection", "test-id");
|
|
175
|
-
expect(updateDoc).toHaveBeenCalledWith(
|
|
176
|
-
"doc-ref",
|
|
177
|
-
expect.objectContaining({
|
|
178
|
-
...updateData,
|
|
179
|
-
updatedAt: expect.any(Date),
|
|
180
|
-
})
|
|
181
|
-
);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it("treba da baci grešku ako ažuriranje ne uspe", async () => {
|
|
185
|
-
(collection as jest.Mock).mockReturnValue("requirements-collection");
|
|
186
|
-
(doc as jest.Mock).mockReturnValue("doc-ref");
|
|
187
|
-
(updateDoc as jest.Mock).mockRejectedValue(new Error("Update Failed"));
|
|
188
|
-
|
|
189
|
-
await expect(
|
|
190
|
-
service.update("test-id", { name: "New Name" })
|
|
191
|
-
).rejects.toThrow("Update Failed");
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe("getAllByType", () => {
|
|
196
|
-
it("treba da vrati sve zahteve određenog tipa", async () => {
|
|
197
|
-
const mockDocs = [
|
|
198
|
-
{
|
|
199
|
-
id: "req-1",
|
|
200
|
-
data: () => ({ ...mockRequirement, type: RequirementType.PRE }),
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
id: "req-2",
|
|
204
|
-
data: () => ({ ...mockRequirement, type: RequirementType.PRE }),
|
|
205
|
-
},
|
|
206
|
-
];
|
|
207
|
-
|
|
208
|
-
(collection as jest.Mock).mockReturnValue("requirements-collection");
|
|
209
|
-
(query as jest.Mock).mockReturnValue("filtered-query");
|
|
210
|
-
(where as jest.Mock).mockReturnValue("where-clause");
|
|
211
|
-
(getDocs as jest.Mock).mockResolvedValue({ docs: mockDocs });
|
|
212
|
-
|
|
213
|
-
const results = await service.getAllByType(RequirementType.PRE);
|
|
214
|
-
|
|
215
|
-
expect(query).toHaveBeenCalledWith(
|
|
216
|
-
"requirements-collection",
|
|
217
|
-
"where-clause",
|
|
218
|
-
"where-clause"
|
|
219
|
-
);
|
|
220
|
-
expect(where).toHaveBeenCalledWith("type", "==", RequirementType.PRE);
|
|
221
|
-
expect(where).toHaveBeenCalledWith("isActive", "==", true);
|
|
222
|
-
expect(results).toHaveLength(2);
|
|
223
|
-
expect(results[0].type).toBe(RequirementType.PRE);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
});
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { SubcategoryService } from "../subcategory.service";
|
|
2
|
-
import { Subcategory } from "../../types/subcategory.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
|
-
jest.mock("firebase/firestore");
|
|
15
|
-
jest.mock("../../../config/firebase", () => ({
|
|
16
|
-
getFirebaseInstance: jest.fn().mockResolvedValue({
|
|
17
|
-
db: {},
|
|
18
|
-
auth: {},
|
|
19
|
-
}),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
const COLLECTION = "backoffice_categories";
|
|
23
|
-
const SUB_COLLECTION = "subcategories";
|
|
24
|
-
const mockDb = {} as any;
|
|
25
|
-
const CATEGORY_ID = "test-category-id";
|
|
26
|
-
|
|
27
|
-
describe("SubcategoryService", () => {
|
|
28
|
-
let service: SubcategoryService;
|
|
29
|
-
|
|
30
|
-
const mockSubcategory: Omit<Subcategory, "id" | "createdAt" | "updatedAt"> = {
|
|
31
|
-
name: "Test Subcategory",
|
|
32
|
-
description: "Test Description",
|
|
33
|
-
categoryId: CATEGORY_ID,
|
|
34
|
-
isActive: true,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
jest.clearAllMocks();
|
|
39
|
-
service = new SubcategoryService();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe("create", () => {
|
|
43
|
-
it("treba da kreira novu podkategoriju", async () => {
|
|
44
|
-
const mockDocRef = { id: "test-id" };
|
|
45
|
-
(collection as jest.Mock).mockReturnValue("subcategories-collection");
|
|
46
|
-
(addDoc as jest.Mock).mockResolvedValue(mockDocRef);
|
|
47
|
-
|
|
48
|
-
const result = await service.create(CATEGORY_ID, mockSubcategory);
|
|
49
|
-
|
|
50
|
-
expect(collection).toHaveBeenCalledWith(
|
|
51
|
-
mockDb,
|
|
52
|
-
COLLECTION,
|
|
53
|
-
CATEGORY_ID,
|
|
54
|
-
SUB_COLLECTION
|
|
55
|
-
);
|
|
56
|
-
expect(addDoc).toHaveBeenCalledWith(
|
|
57
|
-
"subcategories-collection",
|
|
58
|
-
expect.objectContaining({
|
|
59
|
-
...mockSubcategory,
|
|
60
|
-
categoryId: CATEGORY_ID,
|
|
61
|
-
createdAt: expect.any(Date),
|
|
62
|
-
updatedAt: expect.any(Date),
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe("getAllByCategoryId", () => {
|
|
69
|
-
it("treba da vrati sve aktivne podkategorije za kategoriju", async () => {
|
|
70
|
-
const mockDocs = [
|
|
71
|
-
{
|
|
72
|
-
id: "sub-1",
|
|
73
|
-
data: () => ({
|
|
74
|
-
...mockSubcategory,
|
|
75
|
-
createdAt: new Date(),
|
|
76
|
-
updatedAt: new Date(),
|
|
77
|
-
}),
|
|
78
|
-
},
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
(collection as jest.Mock).mockReturnValue("subcategories-collection");
|
|
82
|
-
(query as jest.Mock).mockReturnValue("filtered-query");
|
|
83
|
-
(where as jest.Mock).mockReturnValue("where-clause");
|
|
84
|
-
(getDocs as jest.Mock).mockResolvedValue({ docs: mockDocs });
|
|
85
|
-
|
|
86
|
-
const results = await service.getAllByCategoryId(CATEGORY_ID);
|
|
87
|
-
|
|
88
|
-
expect(collection).toHaveBeenCalledWith(
|
|
89
|
-
mockDb,
|
|
90
|
-
COLLECTION,
|
|
91
|
-
CATEGORY_ID,
|
|
92
|
-
SUB_COLLECTION
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
describe("update", () => {
|
|
98
|
-
it("treba da ažurira postojeću podkategoriju", async () => {
|
|
99
|
-
const updateData = { name: "Updated Subcategory" };
|
|
100
|
-
const SUBCATEGORY_ID = "test-sub-id";
|
|
101
|
-
|
|
102
|
-
(collection as jest.Mock).mockReturnValue("subcategories-collection");
|
|
103
|
-
(doc as jest.Mock).mockReturnValue("doc-ref");
|
|
104
|
-
(updateDoc as jest.Mock).mockResolvedValue(undefined);
|
|
105
|
-
(getDoc as jest.Mock).mockResolvedValue({
|
|
106
|
-
exists: () => true,
|
|
107
|
-
id: SUBCATEGORY_ID,
|
|
108
|
-
data: () => ({
|
|
109
|
-
...mockSubcategory,
|
|
110
|
-
...updateData,
|
|
111
|
-
createdAt: new Date(),
|
|
112
|
-
updatedAt: new Date(),
|
|
113
|
-
}),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
await service.update(CATEGORY_ID, SUBCATEGORY_ID, updateData);
|
|
117
|
-
|
|
118
|
-
expect(collection).toHaveBeenCalledWith(
|
|
119
|
-
mockDb,
|
|
120
|
-
COLLECTION,
|
|
121
|
-
CATEGORY_ID,
|
|
122
|
-
SUB_COLLECTION
|
|
123
|
-
);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe("delete", () => {
|
|
128
|
-
it("treba da izvrši soft delete podkategorije", async () => {
|
|
129
|
-
const SUBCATEGORY_ID = "test-sub-id";
|
|
130
|
-
|
|
131
|
-
(collection as jest.Mock).mockReturnValue("subcategories-collection");
|
|
132
|
-
(doc as jest.Mock).mockReturnValue("doc-ref");
|
|
133
|
-
(updateDoc as jest.Mock).mockResolvedValue(undefined);
|
|
134
|
-
(getDoc as jest.Mock).mockResolvedValue({
|
|
135
|
-
exists: () => true,
|
|
136
|
-
id: SUBCATEGORY_ID,
|
|
137
|
-
data: () => ({
|
|
138
|
-
...mockSubcategory,
|
|
139
|
-
createdAt: new Date(),
|
|
140
|
-
updatedAt: new Date(),
|
|
141
|
-
}),
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
await service.delete(CATEGORY_ID, SUBCATEGORY_ID);
|
|
145
|
-
|
|
146
|
-
expect(collection).toHaveBeenCalledWith(
|
|
147
|
-
mockDb,
|
|
148
|
-
COLLECTION,
|
|
149
|
-
CATEGORY_ID,
|
|
150
|
-
SUB_COLLECTION
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
describe("getById", () => {
|
|
156
|
-
it("treba da vrati podkategoriju po ID-u", async () => {
|
|
157
|
-
const SUBCATEGORY_ID = "test-sub-id";
|
|
158
|
-
|
|
159
|
-
(collection as jest.Mock).mockReturnValue("subcategories-collection");
|
|
160
|
-
(doc as jest.Mock).mockReturnValue("doc-ref");
|
|
161
|
-
(getDoc as jest.Mock).mockResolvedValue({
|
|
162
|
-
exists: () => true,
|
|
163
|
-
id: SUBCATEGORY_ID,
|
|
164
|
-
data: () => ({
|
|
165
|
-
...mockSubcategory,
|
|
166
|
-
createdAt: new Date(),
|
|
167
|
-
updatedAt: new Date(),
|
|
168
|
-
}),
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const result = await service.getById(CATEGORY_ID, SUBCATEGORY_ID);
|
|
172
|
-
|
|
173
|
-
expect(collection).toHaveBeenCalledWith(
|
|
174
|
-
mockDb,
|
|
175
|
-
COLLECTION,
|
|
176
|
-
CATEGORY_ID,
|
|
177
|
-
SUB_COLLECTION
|
|
178
|
-
);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
});
|