@hedhog/admin 0.0.104 → 0.0.105
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +141 -141
- package/dist/admin.module.js +7 -7
- package/dist/admin.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +1 -1
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js +8 -8
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/auth.service.spec.js +16 -16
- package/dist/auth/auth.service.spec.js.map +1 -1
- package/dist/dto/with-locale.dto.d.ts +4 -0
- package/dist/dto/with-locale.dto.d.ts.map +1 -0
- package/dist/dto/{with-locales.dto.js → with-locale.dto.js} +5 -5
- package/dist/dto/with-locale.dto.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/locale/locale.controller.js +1 -1
- package/dist/locale/locale.controller.js.map +1 -1
- package/dist/locale/locale.middleware.d.ts +1 -1
- package/dist/locale/locale.middleware.d.ts.map +1 -1
- package/dist/locale/locale.middleware.js +2 -2
- package/dist/locale/locale.middleware.js.map +1 -1
- package/dist/locale/locale.service.d.ts +6 -6
- package/dist/locale/locale.service.d.ts.map +1 -1
- package/dist/locale/locale.service.js +40 -40
- package/dist/locale/locale.service.js.map +1 -1
- package/dist/locale/locale.service.spec.js +14 -14
- package/dist/locale/locale.service.spec.js.map +1 -1
- package/dist/menu/menu.controller.js +3 -3
- package/dist/menu/menu.controller.js.map +1 -1
- package/dist/menu/menu.service.d.ts +3 -3
- package/dist/menu/menu.service.d.ts.map +1 -1
- package/dist/menu/menu.service.js +35 -35
- package/dist/menu/menu.service.js.map +1 -1
- package/dist/menu/menu.service.spec.js +33 -37
- package/dist/menu/menu.service.spec.js.map +1 -1
- package/dist/role/dto/create.dto.d.ts +2 -2
- package/dist/role/dto/create.dto.d.ts.map +1 -1
- package/dist/role/dto/create.dto.js +2 -2
- package/dist/role/dto/create.dto.js.map +1 -1
- package/dist/role/guards/role.guard.js +4 -4
- package/dist/role/guards/role.guard.js.map +1 -1
- package/dist/role/role.controller.js +7 -7
- package/dist/role/role.controller.js.map +1 -1
- package/dist/role/role.service.d.ts +2 -2
- package/dist/role/role.service.d.ts.map +1 -1
- package/dist/role/role.service.js +35 -35
- package/dist/role/role.service.js.map +1 -1
- package/dist/role/role.service.spec.d.ts +0 -1
- package/dist/role/role.service.spec.js +400 -340
- package/dist/role/role.service.spec.js.map +1 -1
- package/dist/route/route.controller.js +3 -3
- package/dist/route/route.controller.js.map +1 -1
- package/dist/route/route.service.d.ts +2 -2
- package/dist/route/route.service.d.ts.map +1 -1
- package/dist/route/route.service.js +18 -18
- package/dist/route/route.service.js.map +1 -1
- package/dist/route/route.service.spec.js +27 -27
- package/dist/route/route.service.spec.js.map +1 -1
- package/dist/screen/screen.controller.js +4 -4
- package/dist/screen/screen.controller.js.map +1 -1
- package/dist/screen/screen.service.d.ts +2 -2
- package/dist/screen/screen.service.d.ts.map +1 -1
- package/dist/screen/screen.service.js +16 -16
- package/dist/screen/screen.service.js.map +1 -1
- package/dist/screen/screen.service.spec.js +16 -16
- package/dist/screen/screen.service.spec.js.map +1 -1
- package/dist/setting/dto/setting.dto.d.ts +9 -0
- package/dist/setting/dto/setting.dto.d.ts.map +1 -0
- package/dist/setting/dto/{settings.dto.js → setting.dto.js} +6 -6
- package/dist/setting/dto/setting.dto.js.map +1 -0
- package/dist/setting/{settings.controller.d.ts → setting.controller.d.ts} +6 -6
- package/dist/setting/setting.controller.d.ts.map +1 -0
- package/dist/setting/{settings.controller.js → setting.controller.js} +20 -20
- package/dist/setting/setting.controller.js.map +1 -0
- package/dist/setting/setting.module.d.ts +3 -0
- package/dist/setting/setting.module.d.ts.map +1 -0
- package/dist/setting/{settings.module.js → setting.module.js} +6 -6
- package/dist/setting/setting.module.js.map +1 -0
- package/dist/setting/{settings.service.d.ts → setting.service.d.ts} +4 -4
- package/dist/setting/setting.service.d.ts.map +1 -0
- package/dist/setting/{settings.service.js → setting.service.js} +42 -42
- package/dist/setting/setting.service.js.map +1 -0
- package/dist/setting/setting.service.spec.d.ts +2 -0
- package/dist/setting/setting.service.spec.d.ts.map +1 -0
- package/dist/setting/{settings.service.spec.js → setting.service.spec.js} +17 -17
- package/dist/setting/setting.service.spec.js.map +1 -0
- package/dist/user/user.controller.js +3 -3
- package/dist/user/user.controller.js.map +1 -1
- package/dist/user/user.service.d.ts +2 -2
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js +9 -9
- package/dist/user/user.service.js.map +1 -1
- package/dist/user/user.service.spec.js +24 -24
- package/dist/user/user.service.spec.js.map +1 -1
- package/package.json +2 -2
- package/src/admin.module.ts +36 -0
- package/src/auth/auth.controller.ts +48 -0
- package/src/auth/auth.module.ts +39 -0
- package/src/auth/auth.service.spec.ts +196 -0
- package/src/auth/auth.service.ts +175 -0
- package/src/auth/decorators/public.decorator.ts +4 -0
- package/src/auth/decorators/user.decorator.ts +17 -0
- package/src/auth/dto/forget.dto.ts +6 -0
- package/src/auth/dto/login.dto.ts +15 -0
- package/src/auth/dto/otp.dto.ts +11 -0
- package/src/auth/enums/multifactor-type.enum.ts +4 -0
- package/src/auth/guards/auth.guard.ts +50 -0
- package/src/auth/types/user.type.ts +8 -0
- package/src/dto/delete.dto.ts +8 -0
- package/src/dto/update-ids.dto.ts +9 -0
- package/src/dto/with-locale.dto.ts +8 -0
- package/src/index.ts +34 -0
- package/src/locale/dto/create.dto.ts +12 -0
- package/src/locale/dto/delete.dto.ts +8 -0
- package/src/locale/dto/set-enabled.dto.ts +9 -0
- package/src/locale/dto/update.dto.ts +15 -0
- package/src/locale/index.ts +4 -0
- package/src/locale/locale.controller.ts +79 -0
- package/src/locale/locale.decorator.ts +8 -0
- package/src/locale/locale.middleware.ts +34 -0
- package/src/locale/locale.module.ts +23 -0
- package/src/locale/locale.service.spec.ts +193 -0
- package/src/locale/locale.service.ts +366 -0
- package/src/menu/dto/create.dto.ts +25 -0
- package/src/menu/dto/order.dto.ts +8 -0
- package/src/menu/dto/update.dto.ts +19 -0
- package/src/menu/menu.controller.ts +106 -0
- package/src/menu/menu.module.ts +18 -0
- package/src/menu/menu.service.spec.ts +247 -0
- package/src/menu/menu.service.ts +263 -0
- package/src/role/decorators/role.decorator.ts +4 -0
- package/src/role/dto/create.dto.ts +7 -0
- package/src/role/dto/update.dto.ts +4 -0
- package/src/role/guards/role.guard.ts +122 -0
- package/src/role/role.controller.ts +126 -0
- package/src/role/role.module.ts +28 -0
- package/src/role/role.service.spec.ts +417 -0
- package/src/role/role.service.ts +302 -0
- package/src/route/dto/create.dto.ts +13 -0
- package/src/route/dto/update.dto.ts +15 -0
- package/src/route/route.controller.ts +91 -0
- package/src/route/route.module.ts +18 -0
- package/src/route/route.service.spec.ts +299 -0
- package/src/route/route.service.ts +164 -0
- package/src/screen/dto/create.dto.ts +19 -0
- package/src/screen/dto/update.dto.ts +19 -0
- package/src/screen/screen.controller.ts +93 -0
- package/src/screen/screen.module.ts +18 -0
- package/src/screen/screen.service.spec.ts +298 -0
- package/src/screen/screen.service.ts +181 -0
- package/src/setting/dto/create.dto.ts +1 -0
- package/src/setting/dto/setting-user.dto.ts +6 -0
- package/src/setting/dto/setting.dto.ts +17 -0
- package/src/setting/dto/update.dto.ts +3 -0
- package/src/setting/setting.controller.ts +100 -0
- package/src/setting/setting.module.ts +18 -0
- package/src/setting/setting.service.spec.ts +183 -0
- package/src/setting/setting.service.ts +346 -0
- package/src/types/http-method.ts +8 -0
- package/src/user/constants/user.constants.ts +1 -0
- package/src/user/dto/create.dto.ts +24 -0
- package/src/user/dto/update.dto.ts +41 -0
- package/src/user/user.controller.ts +75 -0
- package/src/user/user.module.ts +18 -0
- package/src/user/user.service.spec.ts +294 -0
- package/src/user/user.service.ts +129 -0
- package/tsconfig.lib.json +9 -0
- package/tsconfig.production.json +20 -0
- package/dist/dto/with-locales.dto.d.ts +0 -4
- package/dist/dto/with-locales.dto.d.ts.map +0 -1
- package/dist/dto/with-locales.dto.js.map +0 -1
- package/dist/setting/dto/settings.dto.d.ts +0 -9
- package/dist/setting/dto/settings.dto.d.ts.map +0 -1
- package/dist/setting/dto/settings.dto.js.map +0 -1
- package/dist/setting/settings.controller.d.ts.map +0 -1
- package/dist/setting/settings.controller.js.map +0 -1
- package/dist/setting/settings.module.d.ts +0 -3
- package/dist/setting/settings.module.d.ts.map +0 -1
- package/dist/setting/settings.module.js.map +0 -1
- package/dist/setting/settings.service.d.ts.map +0 -1
- package/dist/setting/settings.service.js.map +0 -1
- package/dist/setting/settings.service.spec.d.ts +0 -2
- package/dist/setting/settings.service.spec.d.ts.map +0 -1
- package/dist/setting/settings.service.spec.js.map +0 -1
@@ -12,19 +12,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.
|
15
|
+
exports.SettingService = void 0;
|
16
16
|
const pagination_1 = require("@hedhog/pagination");
|
17
17
|
const prisma_1 = require("@hedhog/prisma");
|
18
18
|
const utils_1 = require("@hedhog/utils");
|
19
19
|
const common_1 = require("@nestjs/common");
|
20
|
-
let
|
20
|
+
let SettingService = class SettingService {
|
21
21
|
constructor(prismaService, paginationService) {
|
22
22
|
this.prismaService = prismaService;
|
23
23
|
this.paginationService = paginationService;
|
24
24
|
}
|
25
25
|
async setManySettings(data) {
|
26
|
-
for (const { slug, value } of data.
|
27
|
-
await this.prismaService.
|
26
|
+
for (const { slug, value } of data.setting) {
|
27
|
+
await this.prismaService.setting.updateMany({
|
28
28
|
where: {
|
29
29
|
slug,
|
30
30
|
},
|
@@ -39,21 +39,21 @@ let SettingsService = class SettingsService {
|
|
39
39
|
const fields = ['slug', 'value'];
|
40
40
|
paginationParams.pageSize = 100;
|
41
41
|
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
42
|
-
const result = await this.paginationService.paginate(this.prismaService.
|
42
|
+
const result = await this.paginationService.paginate(this.prismaService.setting, paginationParams, {
|
43
43
|
where: {
|
44
44
|
AND: {
|
45
|
-
|
45
|
+
setting_group: {
|
46
46
|
slug,
|
47
47
|
},
|
48
48
|
OR,
|
49
49
|
},
|
50
50
|
},
|
51
51
|
include: {
|
52
|
-
|
52
|
+
setting_group: {
|
53
53
|
include: {
|
54
|
-
|
54
|
+
setting_group_locale: {
|
55
55
|
where: {
|
56
|
-
|
56
|
+
locale: {
|
57
57
|
code: locale,
|
58
58
|
},
|
59
59
|
},
|
@@ -64,9 +64,9 @@ let SettingsService = class SettingsService {
|
|
64
64
|
},
|
65
65
|
},
|
66
66
|
},
|
67
|
-
|
67
|
+
setting_locale: {
|
68
68
|
where: {
|
69
|
-
|
69
|
+
locale: {
|
70
70
|
code: locale,
|
71
71
|
},
|
72
72
|
},
|
@@ -76,9 +76,9 @@ let SettingsService = class SettingsService {
|
|
76
76
|
},
|
77
77
|
},
|
78
78
|
},
|
79
|
-
}, '
|
79
|
+
}, 'setting_locale');
|
80
80
|
result.data = result.data.map((setting) => {
|
81
|
-
setting.
|
81
|
+
setting.setting_group = (0, utils_1.itemTranslations)('setting_group_locale', setting.setting_group);
|
82
82
|
return setting;
|
83
83
|
});
|
84
84
|
return result;
|
@@ -87,14 +87,14 @@ let SettingsService = class SettingsService {
|
|
87
87
|
const fields = ['slug', 'icon'];
|
88
88
|
paginationParams.pageSize = 100;
|
89
89
|
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
90
|
-
const result = await this.paginationService.paginate(this.prismaService.
|
90
|
+
const result = await this.paginationService.paginate(this.prismaService.setting_group, paginationParams, {
|
91
91
|
where: {
|
92
92
|
OR,
|
93
93
|
},
|
94
94
|
include: {
|
95
|
-
|
95
|
+
setting_group_locale: {
|
96
96
|
where: {
|
97
|
-
|
97
|
+
locale: {
|
98
98
|
code: locale,
|
99
99
|
},
|
100
100
|
},
|
@@ -104,22 +104,22 @@ let SettingsService = class SettingsService {
|
|
104
104
|
},
|
105
105
|
},
|
106
106
|
},
|
107
|
-
}, '
|
107
|
+
}, 'setting_group_locale');
|
108
108
|
return result;
|
109
109
|
}
|
110
110
|
async getSettings(locale, paginationParams) {
|
111
111
|
const fields = ['slug', 'value'];
|
112
112
|
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
113
|
-
const result = await this.paginationService.paginate(this.prismaService.
|
113
|
+
const result = await this.paginationService.paginate(this.prismaService.setting, paginationParams, {
|
114
114
|
where: {
|
115
115
|
OR,
|
116
116
|
},
|
117
117
|
include: {
|
118
|
-
|
118
|
+
setting_group: {
|
119
119
|
include: {
|
120
|
-
|
120
|
+
setting_group_locale: {
|
121
121
|
where: {
|
122
|
-
|
122
|
+
locale: {
|
123
123
|
code: locale,
|
124
124
|
},
|
125
125
|
},
|
@@ -130,9 +130,9 @@ let SettingsService = class SettingsService {
|
|
130
130
|
},
|
131
131
|
},
|
132
132
|
},
|
133
|
-
|
133
|
+
setting_locale: {
|
134
134
|
where: {
|
135
|
-
|
135
|
+
locale: {
|
136
136
|
code: locale,
|
137
137
|
},
|
138
138
|
},
|
@@ -142,31 +142,31 @@ let SettingsService = class SettingsService {
|
|
142
142
|
},
|
143
143
|
},
|
144
144
|
},
|
145
|
-
}, '
|
145
|
+
}, 'setting_locale');
|
146
146
|
result.data = result.data.map((setting) => {
|
147
|
-
setting.
|
147
|
+
setting.setting_group = (0, utils_1.itemTranslations)('setting_group_locale', setting.setting_group);
|
148
148
|
return setting;
|
149
149
|
});
|
150
150
|
return result;
|
151
151
|
}
|
152
152
|
async get(settingId) {
|
153
|
-
return this.prismaService.
|
153
|
+
return this.prismaService.setting.findUnique({
|
154
154
|
where: { id: settingId },
|
155
155
|
});
|
156
156
|
}
|
157
157
|
async create({}) {
|
158
|
-
return this.prismaService.
|
158
|
+
return this.prismaService.setting.create({
|
159
159
|
data: {},
|
160
160
|
});
|
161
161
|
}
|
162
162
|
async update({ id, data }) {
|
163
|
-
return this.prismaService.
|
163
|
+
return this.prismaService.setting.update({
|
164
164
|
where: { id },
|
165
165
|
data,
|
166
166
|
});
|
167
167
|
}
|
168
168
|
async updateFromSlug(slug, data) {
|
169
|
-
const { id } = await this.prismaService.
|
169
|
+
const { id } = await this.prismaService.setting.findFirst({
|
170
170
|
where: {
|
171
171
|
slug,
|
172
172
|
},
|
@@ -183,7 +183,7 @@ let SettingsService = class SettingsService {
|
|
183
183
|
if (ids == undefined || ids == null) {
|
184
184
|
throw new common_1.BadRequestException(`You must select at least one setting to delete.`);
|
185
185
|
}
|
186
|
-
return this.prismaService.
|
186
|
+
return this.prismaService.setting.deleteMany({
|
187
187
|
where: {
|
188
188
|
id: {
|
189
189
|
in: ids,
|
@@ -192,7 +192,7 @@ let SettingsService = class SettingsService {
|
|
192
192
|
});
|
193
193
|
}
|
194
194
|
async setSettingUserValue(user_id, slug, value) {
|
195
|
-
const user = await this.prismaService.
|
195
|
+
const user = await this.prismaService.user.findUnique({
|
196
196
|
where: {
|
197
197
|
id: user_id,
|
198
198
|
},
|
@@ -203,7 +203,7 @@ let SettingsService = class SettingsService {
|
|
203
203
|
if (!user) {
|
204
204
|
throw new common_1.BadRequestException(`User with id ${user_id} not found.`);
|
205
205
|
}
|
206
|
-
const setting = await this.prismaService.
|
206
|
+
const setting = await this.prismaService.setting.findFirst({
|
207
207
|
where: {
|
208
208
|
slug,
|
209
209
|
user_override: true,
|
@@ -212,7 +212,7 @@ let SettingsService = class SettingsService {
|
|
212
212
|
if (!setting) {
|
213
213
|
throw new common_1.BadRequestException(`Setting with slug ${slug} not found or user can not override.`);
|
214
214
|
}
|
215
|
-
return await this.prismaService.
|
215
|
+
return await this.prismaService.setting_user.upsert({
|
216
216
|
where: {
|
217
217
|
user_id_setting_id: {
|
218
218
|
setting_id: setting.id,
|
@@ -236,7 +236,7 @@ let SettingsService = class SettingsService {
|
|
236
236
|
}
|
237
237
|
async getSettingValues(slug) {
|
238
238
|
slug = Array.isArray(slug) ? slug : [slug];
|
239
|
-
let
|
239
|
+
let setting = await this.prismaService.setting.findMany({
|
240
240
|
where: {
|
241
241
|
slug: {
|
242
242
|
in: slug,
|
@@ -250,8 +250,8 @@ let SettingsService = class SettingsService {
|
|
250
250
|
user_override: true,
|
251
251
|
},
|
252
252
|
});
|
253
|
-
const slugUserOverride =
|
254
|
-
const
|
253
|
+
const slugUserOverride = setting.filter((setting) => setting.userOverride);
|
254
|
+
const settingUser = await this.prismaService.setting_user.findMany({
|
255
255
|
where: {
|
256
256
|
setting_id: {
|
257
257
|
in: slugUserOverride.map((setting) => setting.id),
|
@@ -263,22 +263,22 @@ let SettingsService = class SettingsService {
|
|
263
263
|
},
|
264
264
|
});
|
265
265
|
const data = {};
|
266
|
-
|
266
|
+
setting.forEach((setting) => {
|
267
267
|
data[setting.slug] = setting.value;
|
268
268
|
});
|
269
|
-
|
269
|
+
settingUser.forEach((setting) => {
|
270
270
|
data[slugUserOverride.find((s) => s.id === setting.setting_id).slug] =
|
271
271
|
setting.value;
|
272
272
|
});
|
273
273
|
return data;
|
274
274
|
}
|
275
275
|
};
|
276
|
-
exports.
|
277
|
-
exports.
|
276
|
+
exports.SettingService = SettingService;
|
277
|
+
exports.SettingService = SettingService = __decorate([
|
278
278
|
(0, common_1.Injectable)(),
|
279
279
|
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => prisma_1.PrismaService))),
|
280
280
|
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => pagination_1.PaginationService))),
|
281
281
|
__metadata("design:paramtypes", [prisma_1.PrismaService,
|
282
282
|
pagination_1.PaginationService])
|
283
|
-
],
|
284
|
-
//# sourceMappingURL=
|
283
|
+
], SettingService);
|
284
|
+
//# sourceMappingURL=setting.service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setting.service.js","sourceRoot":"","sources":["../../src/setting/setting.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,yCAAiD;AACjD,2CAKwB;AAOjB,IAAM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Z,sBAAa;QAET,8BAAiB;GAL5C,cAAc,CA0U1B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setting.service.spec.d.ts","sourceRoot":"","sources":["../../src/setting/setting.service.spec.ts"],"names":[],"mappings":""}
|
@@ -4,19 +4,19 @@ const pagination_1 = require("@hedhog/pagination");
|
|
4
4
|
const prisma_1 = require("@hedhog/prisma");
|
5
5
|
const common_1 = require("@nestjs/common");
|
6
6
|
const testing_1 = require("@nestjs/testing");
|
7
|
-
const
|
8
|
-
describe('
|
7
|
+
const setting_service_1 = require("./setting.service");
|
8
|
+
describe('SettingService', () => {
|
9
9
|
let service;
|
10
10
|
let prismaService;
|
11
11
|
// let paginationService: PaginationService;
|
12
12
|
beforeEach(async () => {
|
13
13
|
const module = await testing_1.Test.createTestingModule({
|
14
14
|
providers: [
|
15
|
-
|
15
|
+
setting_service_1.SettingService,
|
16
16
|
{
|
17
17
|
provide: prisma_1.PrismaService,
|
18
18
|
useValue: {
|
19
|
-
|
19
|
+
setting: {
|
20
20
|
findUnique: jest.fn(),
|
21
21
|
create: jest.fn(),
|
22
22
|
update: jest.fn(),
|
@@ -33,7 +33,7 @@ describe('SettingsService', () => {
|
|
33
33
|
},
|
34
34
|
],
|
35
35
|
}).compile();
|
36
|
-
service = module.get(
|
36
|
+
service = module.get(setting_service_1.SettingService);
|
37
37
|
prismaService = module.get(prisma_1.PrismaService);
|
38
38
|
// paginationService = module.get<PaginationService>(PaginationService);
|
39
39
|
});
|
@@ -41,7 +41,7 @@ describe('SettingsService', () => {
|
|
41
41
|
expect(service).toBeDefined();
|
42
42
|
});
|
43
43
|
/* describe('getSettings', () => {
|
44
|
-
it('should return paginated
|
44
|
+
it('should return paginated setting', async () => {
|
45
45
|
const paginationParams: PaginationDTO = {
|
46
46
|
page: 1,
|
47
47
|
pageSize: 10,
|
@@ -73,7 +73,7 @@ describe('SettingsService', () => {
|
|
73
73
|
paginationParams,
|
74
74
|
);
|
75
75
|
expect(paginationService.paginate).toHaveBeenCalledWith(
|
76
|
-
prismaService.
|
76
|
+
prismaService.setting,
|
77
77
|
paginationParams,
|
78
78
|
{ where: { OR: [] } },
|
79
79
|
);
|
@@ -89,10 +89,10 @@ describe('SettingsService', () => {
|
|
89
89
|
updated_at: new Date(),
|
90
90
|
};
|
91
91
|
jest
|
92
|
-
.spyOn(prismaService.
|
92
|
+
.spyOn(prismaService.setting, 'findUnique')
|
93
93
|
.mockResolvedValue(mockSetting);
|
94
94
|
const result = await service.get(1);
|
95
|
-
expect(prismaService.
|
95
|
+
expect(prismaService.setting.findUnique).toHaveBeenCalledWith({
|
96
96
|
where: { id: 1 },
|
97
97
|
});
|
98
98
|
expect(result).toEqual(mockSetting);
|
@@ -110,12 +110,12 @@ describe('SettingsService', () => {
|
|
110
110
|
};
|
111
111
|
|
112
112
|
jest
|
113
|
-
.spyOn(prismaService.
|
113
|
+
.spyOn(prismaService.setting, 'create')
|
114
114
|
.mockResolvedValue(mockSetting);
|
115
115
|
|
116
116
|
const result = await service.create(createDTO);
|
117
117
|
|
118
|
-
expect(prismaService.
|
118
|
+
expect(prismaService.setting.create).toHaveBeenCalledWith({
|
119
119
|
data: { name: createDTO.name },
|
120
120
|
});
|
121
121
|
expect(result).toEqual(mockSetting);
|
@@ -132,10 +132,10 @@ describe('SettingsService', () => {
|
|
132
132
|
updated_at: new Date(),
|
133
133
|
};
|
134
134
|
jest
|
135
|
-
.spyOn(prismaService.
|
135
|
+
.spyOn(prismaService.setting, 'update')
|
136
136
|
.mockResolvedValue(mockSetting);
|
137
137
|
const result = await service.update(updateInput);
|
138
|
-
expect(prismaService.
|
138
|
+
expect(prismaService.setting.update).toHaveBeenCalledWith({
|
139
139
|
where: { id: updateInput.id },
|
140
140
|
data: updateInput.data,
|
141
141
|
});
|
@@ -147,16 +147,16 @@ describe('SettingsService', () => {
|
|
147
147
|
const deleteDTO = { ids: null };
|
148
148
|
await expect(service.delete(deleteDTO)).rejects.toThrow(new common_1.BadRequestException(`You must select at least one setting to delete.`));
|
149
149
|
});
|
150
|
-
it('should delete
|
150
|
+
it('should delete setting by ids', async () => {
|
151
151
|
const deleteDTO = { ids: [1, 2] };
|
152
152
|
jest
|
153
|
-
.spyOn(prismaService.
|
153
|
+
.spyOn(prismaService.setting, 'deleteMany')
|
154
154
|
.mockResolvedValue({ count: 2 });
|
155
155
|
await service.delete(deleteDTO);
|
156
|
-
expect(prismaService.
|
156
|
+
expect(prismaService.setting.deleteMany).toHaveBeenCalledWith({
|
157
157
|
where: { id: { in: deleteDTO.ids } },
|
158
158
|
});
|
159
159
|
});
|
160
160
|
});
|
161
161
|
});
|
162
|
-
//# sourceMappingURL=
|
162
|
+
//# sourceMappingURL=setting.service.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setting.service.spec.js","sourceRoot":"","sources":["../../src/setting/setting.service.spec.ts"],"names":[],"mappings":";;AAAA,mDAAuD;AACvD,2CAA+C;AAC/C,2CAAqD;AACrD,6CAAsD;AAGtD,uDAAmD;AAEnD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,OAAuB,CAAC;IAC5B,IAAI,aAA4B,CAAC;IACjC,4CAA4C;IAE5C,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE;gBACT,gCAAc;gBACd;oBACE,OAAO,EAAE,sBAAa;oBACtB,QAAQ,EAAE;wBACR,OAAO,EAAE;4BACP,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;4BACrB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;4BACjB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;4BACjB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;yBACtB;wBACD,uBAAuB,EAAE,IAAI,CAAC,EAAE,EAAE;qBACnC;iBACF;gBACD;oBACE,OAAO,EAAE,8BAAiB;oBAC1B,QAAQ,EAA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AE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YAE7C,IAAI;iBACD,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,YAAY,CAAC;iBAC1C,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAEnC,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAEhC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;gBAC5D,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,GAAG,EAAE,EAAE;aACrC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -59,7 +59,7 @@ __decorate([
|
|
59
59
|
__metadata("design:returntype", Promise)
|
60
60
|
], UserController.prototype, "getUsers", null);
|
61
61
|
__decorate([
|
62
|
-
(0, common_1.Get)(':userId/
|
62
|
+
(0, common_1.Get)(':userId/role'),
|
63
63
|
__param(0, (0, common_1.Param)('userId', common_1.ParseIntPipe)),
|
64
64
|
__param(1, (0, pagination_1.Pagination)()),
|
65
65
|
__metadata("design:type", Function),
|
@@ -67,7 +67,7 @@ __decorate([
|
|
67
67
|
__metadata("design:returntype", Promise)
|
68
68
|
], UserController.prototype, "listRoles", null);
|
69
69
|
__decorate([
|
70
|
-
(0, common_1.Patch)(':userId/
|
70
|
+
(0, common_1.Patch)(':userId/role'),
|
71
71
|
__param(0, (0, common_1.Param)('userId', common_1.ParseIntPipe)),
|
72
72
|
__param(1, (0, common_1.Body)()),
|
73
73
|
__metadata("design:type", Function),
|
@@ -105,7 +105,7 @@ __decorate([
|
|
105
105
|
], UserController.prototype, "delete", null);
|
106
106
|
exports.UserController = UserController = __decorate([
|
107
107
|
(0, role_decorator_1.Role)(),
|
108
|
-
(0, common_1.Controller)('
|
108
|
+
(0, common_1.Controller)('user'),
|
109
109
|
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => user_service_1.UserService))),
|
110
110
|
__metadata("design:paramtypes", [user_service_1.UserService])
|
111
111
|
], UserController);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/user/user.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAgD;AAChD,2CAWwB;AACxB,kDAA8C;AAC9C,0DAAqD;AACrD,sEAAyD;AACzD,iDAA6C;AAC7C,iDAA6C;AAC7C,iDAA6C;AAItC,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAEmB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAGE,AAAN,KAAK,CAAC,QAAQ,CAAe,gBAAgB;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAGK,AAAN,KAAK,CAAC,SAAS,CACkB,MAAc,EAC/B,gBAAgB;QAE9B,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CACgB,MAAc,EACrC,IAAkB;QAE1B,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAGK,AAAN,KAAK,CAAC,IAAI,CAAgC,MAAc;QACtD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAGD,MAAM,CAAS,IAAe;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CACqB,MAAc,EACrC,IAAe;QAEvB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAC7B,EAAE,EAAE,MAA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GAAE;IACN,IAAA,mBAAU,EAAC,MAAM,CAAC;IAGd,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC,CAAC,CAAA;qCACR,0BAAW;GAHhC,cAAc,CAoD1B"}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { PaginationDTO, PaginationService } from '@hedhog/pagination';
|
2
2
|
import { PrismaService } from '@hedhog/prisma';
|
3
|
-
import { CreateDTO } from './dto/create.dto';
|
4
3
|
import { DeleteDTO } from '../dto/delete.dto';
|
5
|
-
import { UpdateDTO } from './dto/update.dto';
|
6
4
|
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
5
|
+
import { CreateDTO } from './dto/create.dto';
|
6
|
+
import { UpdateDTO } from './dto/update.dto';
|
7
7
|
export declare class UserService {
|
8
8
|
private readonly prismaService;
|
9
9
|
private readonly paginationService;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAQ/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,WAAW;IAGpB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,aAAa,EAAE,aAAa,EAE5B,iBAAiB,EAAE,iBAAiB;IAGjD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;IAoBzD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,YAAY;IAkBjD,QAAQ,CAAC,gBAAgB,EAAE,aAAa;IAkBxC,GAAG,CAAC,MAAM,EAAE,MAAM;IAIlB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK/C,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,SAAS;IAY3C,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IAOpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAoBhC"}
|
@@ -24,9 +24,9 @@ let UserService = class UserService {
|
|
24
24
|
this.paginationService = paginationService;
|
25
25
|
}
|
26
26
|
async listRoles(userId, paginationParams) {
|
27
|
-
return this.paginationService.paginate(this.prismaService.
|
27
|
+
return this.paginationService.paginate(this.prismaService.role, paginationParams, {
|
28
28
|
include: {
|
29
|
-
|
29
|
+
role_user: {
|
30
30
|
where: {
|
31
31
|
user_id: userId,
|
32
32
|
},
|
@@ -39,12 +39,12 @@ let UserService = class UserService {
|
|
39
39
|
});
|
40
40
|
}
|
41
41
|
async updateRoles(userId, { ids }) {
|
42
|
-
await this.prismaService.
|
42
|
+
await this.prismaService.role_user.deleteMany({
|
43
43
|
where: {
|
44
44
|
user_id: userId,
|
45
45
|
},
|
46
46
|
});
|
47
|
-
return this.prismaService.
|
47
|
+
return this.prismaService.role_user.createMany({
|
48
48
|
data: ids.map((role) => {
|
49
49
|
return {
|
50
50
|
user_id: userId,
|
@@ -57,14 +57,14 @@ let UserService = class UserService {
|
|
57
57
|
async getUsers(paginationParams) {
|
58
58
|
const fields = ['name', 'email'];
|
59
59
|
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
60
|
-
return this.paginationService.paginate(this.prismaService.
|
60
|
+
return this.paginationService.paginate(this.prismaService.user, paginationParams, {
|
61
61
|
where: {
|
62
62
|
OR,
|
63
63
|
},
|
64
64
|
});
|
65
65
|
}
|
66
66
|
async get(userId) {
|
67
|
-
return this.prismaService.
|
67
|
+
return this.prismaService.user.findUnique({ where: { id: userId } });
|
68
68
|
}
|
69
69
|
async hashPassword(password) {
|
70
70
|
const salt = await (0, bcrypt_1.genSalt)(user_constants_1.SALT_ROUNDS);
|
@@ -72,7 +72,7 @@ let UserService = class UserService {
|
|
72
72
|
}
|
73
73
|
async create({ email, name, password }) {
|
74
74
|
const hashedPassword = await this.hashPassword(password);
|
75
|
-
return this.prismaService.
|
75
|
+
return this.prismaService.user.create({
|
76
76
|
data: {
|
77
77
|
email,
|
78
78
|
name,
|
@@ -81,7 +81,7 @@ let UserService = class UserService {
|
|
81
81
|
});
|
82
82
|
}
|
83
83
|
async update({ id, data }) {
|
84
|
-
return this.prismaService.
|
84
|
+
return this.prismaService.user.update({
|
85
85
|
where: { id },
|
86
86
|
data,
|
87
87
|
});
|
@@ -90,7 +90,7 @@ let UserService = class UserService {
|
|
90
90
|
if (ids == undefined || ids == null) {
|
91
91
|
throw new common_1.BadRequestException(`You must select at least one user to delete.`);
|
92
92
|
}
|
93
|
-
return this.prismaService.
|
93
|
+
return this.prismaService.user.deleteMany({
|
94
94
|
where: {
|
95
95
|
id: {
|
96
96
|
in: ids,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AACxB,mCAAuC;
|
1
|
+
{"version":3,"file":"user.service.js","sourceR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