@blackcode_sa/metaestetics-api 1.11.2 → 1.12.0
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 +331 -318
- package/dist/admin/index.d.ts +331 -318
- package/dist/backoffice/index.d.mts +1166 -430
- package/dist/backoffice/index.d.ts +1166 -430
- package/dist/backoffice/index.js +1128 -245
- package/dist/backoffice/index.mjs +1119 -209
- package/dist/index.d.mts +4429 -4034
- package/dist/index.d.ts +4429 -4034
- package/dist/index.js +1644 -666
- package/dist/index.mjs +1408 -402
- package/package.json +1 -1
- package/src/backoffice/expo-safe/index.ts +3 -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 +1 -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/procedure/procedure.service.ts +436 -234
- package/src/types/appointment/index.ts +4 -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 +20 -17
- package/src/validations/appointment.schema.ts +1 -0
- package/src/validations/clinic.schema.ts +1 -6
- package/src/validations/patient/medical-info.schema.ts +7 -2
- 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,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
|
-
});
|