@hedhog/admin 0.0.108 → 0.0.109
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/admin.module.d.ts.map +1 -1
- package/dist/admin.module.js +1 -3
- package/dist/admin.module.js.map +1 -1
- package/dist/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.controller.js +5 -6
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/guards/auth.guard.js +2 -2
- package/dist/auth/guards/auth.guard.js.map +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/menu/menu.controller.js +3 -3
- package/dist/menu/menu.controller.js.map +1 -1
- package/dist/role/guards/role.guard.d.ts.map +1 -1
- package/dist/role/guards/role.guard.js +3 -4
- package/dist/role/guards/role.guard.js.map +1 -1
- package/dist/role/role.controller.js +3 -3
- package/dist/role/role.controller.js.map +1 -1
- package/dist/role/role.module.js +1 -1
- package/dist/role/role.module.js.map +1 -1
- package/dist/role/role.service.d.ts +1 -1
- package/dist/role/role.service.d.ts.map +1 -1
- package/dist/role/role.service.js +1 -1
- package/dist/role/role.service.js.map +1 -1
- package/dist/route/route.controller.js +3 -3
- package/dist/route/route.controller.js.map +1 -1
- package/dist/screen/screen.controller.js +3 -3
- package/dist/screen/screen.controller.js.map +1 -1
- package/dist/setting/setting.controller.d.ts +1 -0
- package/dist/setting/setting.controller.d.ts.map +1 -1
- package/dist/setting/setting.controller.js +14 -3
- package/dist/setting/setting.controller.js.map +1 -1
- package/dist/setting/setting.module.d.ts.map +1 -1
- package/dist/setting/setting.module.js +2 -0
- package/dist/setting/setting.module.js.map +1 -1
- package/dist/setting/setting.service.d.ts +2 -0
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +63 -0
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/user/user.controller.js +2 -2
- package/dist/user/user.controller.js.map +1 -1
- package/hedhog.yaml +1 -21
- package/package.json +8 -6
- package/src/admin.module.ts +1 -3
- package/src/auth/auth.controller.ts +1 -2
- package/src/auth/guards/auth.guard.ts +1 -1
- package/src/index.ts +0 -10
- package/src/menu/menu.controller.ts +2 -2
- package/src/role/guards/role.guard.ts +1 -2
- package/src/role/role.controller.ts +2 -2
- package/src/role/role.module.ts +1 -1
- package/src/role/role.service.ts +1 -1
- package/src/route/route.controller.ts +2 -2
- package/src/screen/screen.controller.ts +2 -2
- package/src/setting/setting.controller.ts +10 -3
- package/src/setting/setting.module.ts +2 -0
- package/src/setting/setting.service.ts +73 -0
- package/src/user/user.controller.ts +1 -1
- package/dist/auth/decorators/public.decorator.d.ts +0 -3
- package/dist/auth/decorators/public.decorator.d.ts.map +0 -1
- package/dist/auth/decorators/public.decorator.js +0 -8
- package/dist/auth/decorators/public.decorator.js.map +0 -1
- package/dist/locale/dto/create.dto.d.ts +0 -6
- package/dist/locale/dto/create.dto.d.ts.map +0 -1
- package/dist/locale/dto/create.dto.js +0 -29
- package/dist/locale/dto/create.dto.js.map +0 -1
- package/dist/locale/dto/delete.dto.d.ts +0 -4
- package/dist/locale/dto/delete.dto.d.ts.map +0 -1
- package/dist/locale/dto/delete.dto.js +0 -23
- package/dist/locale/dto/delete.dto.js.map +0 -1
- package/dist/locale/dto/set-enabled.dto.d.ts +0 -4
- package/dist/locale/dto/set-enabled.dto.d.ts.map +0 -1
- package/dist/locale/dto/set-enabled.dto.js +0 -24
- package/dist/locale/dto/set-enabled.dto.js.map +0 -1
- package/dist/locale/dto/update.dto.d.ts +0 -6
- package/dist/locale/dto/update.dto.d.ts.map +0 -1
- package/dist/locale/dto/update.dto.js +0 -32
- package/dist/locale/dto/update.dto.js.map +0 -1
- package/dist/locale/index.d.ts +0 -5
- package/dist/locale/index.d.ts.map +0 -1
- package/dist/locale/index.js +0 -21
- package/dist/locale/index.js.map +0 -1
- package/dist/locale/locale.controller.d.ts +0 -18
- package/dist/locale/locale.controller.d.ts.map +0 -1
- package/dist/locale/locale.controller.js +0 -127
- package/dist/locale/locale.controller.js.map +0 -1
- package/dist/locale/locale.decorator.d.ts +0 -2
- package/dist/locale/locale.decorator.d.ts.map +0 -1
- package/dist/locale/locale.decorator.js +0 -9
- package/dist/locale/locale.decorator.js.map +0 -1
- package/dist/locale/locale.middleware.d.ts +0 -10
- package/dist/locale/locale.middleware.d.ts.map +0 -1
- package/dist/locale/locale.middleware.js +0 -45
- package/dist/locale/locale.middleware.js.map +0 -1
- package/dist/locale/locale.module.d.ts +0 -5
- package/dist/locale/locale.module.d.ts.map +0 -1
- package/dist/locale/locale.module.js +0 -35
- package/dist/locale/locale.module.js.map +0 -1
- package/dist/locale/locale.service.d.ts +0 -32
- package/dist/locale/locale.service.d.ts.map +0 -1
- package/dist/locale/locale.service.js +0 -290
- package/dist/locale/locale.service.js.map +0 -1
- package/dist/locale/locale.service.spec.d.ts +0 -2
- package/dist/locale/locale.service.spec.d.ts.map +0 -1
- package/dist/locale/locale.service.spec.js +0 -174
- package/dist/locale/locale.service.spec.js.map +0 -1
- package/dist/role/decorators/role.decorator.d.ts +0 -3
- package/dist/role/decorators/role.decorator.d.ts.map +0 -1
- package/dist/role/decorators/role.decorator.js +0 -10
- package/dist/role/decorators/role.decorator.js.map +0 -1
- package/src/auth/decorators/public.decorator.ts +0 -4
- package/src/locale/dto/create.dto.ts +0 -12
- package/src/locale/dto/delete.dto.ts +0 -8
- package/src/locale/dto/set-enabled.dto.ts +0 -9
- package/src/locale/dto/update.dto.ts +0 -15
- package/src/locale/index.ts +0 -4
- package/src/locale/locale.controller.ts +0 -79
- package/src/locale/locale.decorator.ts +0 -8
- package/src/locale/locale.middleware.ts +0 -34
- package/src/locale/locale.module.ts +0 -23
- package/src/locale/locale.service.spec.ts +0 -193
- package/src/locale/locale.service.ts +0 -364
- package/src/role/decorators/role.decorator.ts +0 -7
@@ -1,290 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
-
};
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
-
};
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.LocaleService = void 0;
|
16
|
-
const pagination_1 = require("@hedhog/pagination");
|
17
|
-
const prisma_1 = require("@hedhog/prisma");
|
18
|
-
const common_1 = require("@nestjs/common");
|
19
|
-
let LocaleService = class LocaleService {
|
20
|
-
constructor(prismaService, paginationService) {
|
21
|
-
this.prismaService = prismaService;
|
22
|
-
this.paginationService = paginationService;
|
23
|
-
this.codes = {};
|
24
|
-
}
|
25
|
-
async setEnabled(codes) {
|
26
|
-
if (!codes || codes.length < 1) {
|
27
|
-
throw new common_1.BadRequestException('You must select at least one item code.');
|
28
|
-
}
|
29
|
-
await this.prismaService.locale.updateMany({
|
30
|
-
where: {
|
31
|
-
enabled: true,
|
32
|
-
},
|
33
|
-
data: {
|
34
|
-
enabled: false,
|
35
|
-
},
|
36
|
-
});
|
37
|
-
return this.prismaService.locale.updateMany({
|
38
|
-
where: {
|
39
|
-
code: {
|
40
|
-
in: codes,
|
41
|
-
},
|
42
|
-
},
|
43
|
-
data: {
|
44
|
-
enabled: true,
|
45
|
-
},
|
46
|
-
});
|
47
|
-
}
|
48
|
-
async getEnables(currentLocale, paginationParams) {
|
49
|
-
const fields = ['code', 'region'];
|
50
|
-
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
51
|
-
const result = await this.paginationService.paginate(this.prismaService.locale, paginationParams, {
|
52
|
-
where: {
|
53
|
-
AND: [
|
54
|
-
{
|
55
|
-
enabled: true,
|
56
|
-
},
|
57
|
-
{
|
58
|
-
OR,
|
59
|
-
},
|
60
|
-
],
|
61
|
-
},
|
62
|
-
});
|
63
|
-
const codes = [];
|
64
|
-
for (const item of result.data) {
|
65
|
-
codes.push(item.code);
|
66
|
-
}
|
67
|
-
const { code, region, locale } = this.parseLocale(currentLocale);
|
68
|
-
const where = {
|
69
|
-
locale: {
|
70
|
-
code,
|
71
|
-
},
|
72
|
-
translation_namespace: {
|
73
|
-
name: 'translation',
|
74
|
-
},
|
75
|
-
};
|
76
|
-
if (locale.length > 1) {
|
77
|
-
where.locale.region = region;
|
78
|
-
}
|
79
|
-
const values = await this.prismaService.translation.findMany({
|
80
|
-
where,
|
81
|
-
select: {
|
82
|
-
name: true,
|
83
|
-
value: true,
|
84
|
-
},
|
85
|
-
});
|
86
|
-
for (let i = 0; i < result.data.length; i++) {
|
87
|
-
for (const value of values) {
|
88
|
-
if (value.name === result.data[i].code) {
|
89
|
-
result.data[i].name = value.value;
|
90
|
-
break;
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}
|
94
|
-
return result;
|
95
|
-
}
|
96
|
-
parseLocale(locale) {
|
97
|
-
const localeCodes = locale.toLowerCase().split('-');
|
98
|
-
const code = localeCodes[0];
|
99
|
-
const region = localeCodes[1];
|
100
|
-
return {
|
101
|
-
code,
|
102
|
-
region,
|
103
|
-
locale: localeCodes,
|
104
|
-
};
|
105
|
-
}
|
106
|
-
async getTranslations(localeCode, namespace) {
|
107
|
-
if (!localeCode) {
|
108
|
-
throw new common_1.BadRequestException('Locale code is required.');
|
109
|
-
}
|
110
|
-
if (!namespace) {
|
111
|
-
namespace = 'translation';
|
112
|
-
}
|
113
|
-
const { code, region, locale } = this.parseLocale(localeCode);
|
114
|
-
const where = {
|
115
|
-
locale: {
|
116
|
-
code,
|
117
|
-
},
|
118
|
-
translation_namespace: {
|
119
|
-
name: namespace,
|
120
|
-
},
|
121
|
-
};
|
122
|
-
if (locale.length > 1) {
|
123
|
-
where.locale.region = region;
|
124
|
-
}
|
125
|
-
const values = await this.prismaService.translation.findMany({
|
126
|
-
where,
|
127
|
-
select: {
|
128
|
-
name: true,
|
129
|
-
value: true,
|
130
|
-
},
|
131
|
-
});
|
132
|
-
const translation = {};
|
133
|
-
for (const value of values) {
|
134
|
-
translation[value.name] = value.value;
|
135
|
-
}
|
136
|
-
return translation;
|
137
|
-
}
|
138
|
-
async get(currentLocale, paginationParams) {
|
139
|
-
const fields = ['code', 'region'];
|
140
|
-
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
141
|
-
const result = await this.paginationService.paginate(this.prismaService.locale, paginationParams, {
|
142
|
-
where: {
|
143
|
-
OR,
|
144
|
-
},
|
145
|
-
});
|
146
|
-
const codes = [];
|
147
|
-
for (const item of result.data) {
|
148
|
-
codes.push(item.code);
|
149
|
-
}
|
150
|
-
const { code, region, locale } = this.parseLocale(currentLocale);
|
151
|
-
const where = {
|
152
|
-
locale: {
|
153
|
-
code,
|
154
|
-
},
|
155
|
-
translation_namespace: {
|
156
|
-
name: 'translation',
|
157
|
-
},
|
158
|
-
};
|
159
|
-
if (locale.length > 1) {
|
160
|
-
where.locale.region = region;
|
161
|
-
}
|
162
|
-
const values = await this.prismaService.translation.findMany({
|
163
|
-
where,
|
164
|
-
select: {
|
165
|
-
name: true,
|
166
|
-
value: true,
|
167
|
-
},
|
168
|
-
});
|
169
|
-
for (let i = 0; i < result.data.length; i++) {
|
170
|
-
for (const value of values) {
|
171
|
-
if (value.name === result.data[i].code) {
|
172
|
-
result.data[i].name = value.value;
|
173
|
-
break;
|
174
|
-
}
|
175
|
-
}
|
176
|
-
}
|
177
|
-
return result;
|
178
|
-
}
|
179
|
-
async getByCode(code) {
|
180
|
-
if (this.codes[code]) {
|
181
|
-
return this.codes[code];
|
182
|
-
}
|
183
|
-
return (this.codes[code] = await this.prismaService.locale.findFirst({
|
184
|
-
where: { code },
|
185
|
-
}));
|
186
|
-
}
|
187
|
-
async getById(localeId) {
|
188
|
-
return this.prismaService.locale.findUnique({
|
189
|
-
where: { id: localeId },
|
190
|
-
});
|
191
|
-
}
|
192
|
-
async create(data) {
|
193
|
-
return this.prismaService.locale.create({
|
194
|
-
data,
|
195
|
-
});
|
196
|
-
}
|
197
|
-
async update({ id, data }) {
|
198
|
-
return this.prismaService.locale.update({
|
199
|
-
where: { id },
|
200
|
-
data,
|
201
|
-
});
|
202
|
-
}
|
203
|
-
async delete({ ids }) {
|
204
|
-
if (ids == undefined || ids == null) {
|
205
|
-
throw new common_1.BadRequestException('You must select at least one item to delete.');
|
206
|
-
}
|
207
|
-
return this.prismaService.locale.deleteMany({
|
208
|
-
where: {
|
209
|
-
id: {
|
210
|
-
in: ids,
|
211
|
-
},
|
212
|
-
},
|
213
|
-
});
|
214
|
-
}
|
215
|
-
getTableNameTranslations(modelName) {
|
216
|
-
return `${modelName}_locale`;
|
217
|
-
}
|
218
|
-
async createModelWithLocale(modelName, foreignKeyName, data, locale) {
|
219
|
-
try {
|
220
|
-
const model = await this.prismaService[modelName].create({ data });
|
221
|
-
if (locale) {
|
222
|
-
await Promise.all(Object.entries(locale).map(async ([localeCode, localeData]) => {
|
223
|
-
const localeRecord = await this.getByCode(localeCode);
|
224
|
-
const localeEntry = Object.assign({ [foreignKeyName]: model.id, locale_id: localeRecord.id }, localeData);
|
225
|
-
await this.prismaService[this.getTableNameTranslations(modelName)].create({
|
226
|
-
data: localeEntry,
|
227
|
-
});
|
228
|
-
}));
|
229
|
-
}
|
230
|
-
return this.prismaService[modelName].findUnique({
|
231
|
-
where: { id: model.id },
|
232
|
-
include: {
|
233
|
-
[this.getTableNameTranslations(modelName)]: {
|
234
|
-
where: { locale: { enabled: true } },
|
235
|
-
include: { locale: { select: { code: true } } },
|
236
|
-
},
|
237
|
-
},
|
238
|
-
});
|
239
|
-
}
|
240
|
-
catch (error) {
|
241
|
-
if (error.message.includes('Unique constraint failed')) {
|
242
|
-
throw new common_1.BadRequestException('Data already exists.');
|
243
|
-
}
|
244
|
-
else {
|
245
|
-
throw new common_1.BadRequestException(error);
|
246
|
-
}
|
247
|
-
}
|
248
|
-
}
|
249
|
-
async updateModelWithLocale(modelName, foreignKeyName, id, data, locale) {
|
250
|
-
try {
|
251
|
-
if (locale) {
|
252
|
-
await Promise.all(Object.entries(locale).map(async ([localeCode, localeData]) => {
|
253
|
-
const localeRecord = await this.getByCode(localeCode);
|
254
|
-
const localeEntry = Object.assign({ [foreignKeyName]: id, locale_id: localeRecord.id }, localeData);
|
255
|
-
await this.prismaService[this.getTableNameTranslations(modelName)].upsert({
|
256
|
-
where: {
|
257
|
-
[`${foreignKeyName}_locale_id`]: {
|
258
|
-
[foreignKeyName]: id,
|
259
|
-
locale_id: localeRecord.id,
|
260
|
-
},
|
261
|
-
},
|
262
|
-
create: localeEntry,
|
263
|
-
update: localeData,
|
264
|
-
});
|
265
|
-
}));
|
266
|
-
}
|
267
|
-
return this.prismaService[modelName].update({
|
268
|
-
where: { id },
|
269
|
-
data,
|
270
|
-
});
|
271
|
-
}
|
272
|
-
catch (error) {
|
273
|
-
if (error.message.includes('Unique constraint failed')) {
|
274
|
-
throw new common_1.BadRequestException('Data already exists.');
|
275
|
-
}
|
276
|
-
else {
|
277
|
-
throw new common_1.BadRequestException(error);
|
278
|
-
}
|
279
|
-
}
|
280
|
-
}
|
281
|
-
};
|
282
|
-
exports.LocaleService = LocaleService;
|
283
|
-
exports.LocaleService = LocaleService = __decorate([
|
284
|
-
(0, common_1.Injectable)(),
|
285
|
-
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => prisma_1.PrismaService))),
|
286
|
-
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => pagination_1.PaginationService))),
|
287
|
-
__metadata("design:paramtypes", [prisma_1.PrismaService,
|
288
|
-
pagination_1.PaginationService])
|
289
|
-
], LocaleService);
|
290
|
-
//# sourceMappingURL=locale.service.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"locale.service.js","sourceRoot":"","sources":["../../src/locale/locale.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AAMjB,IAAM,aAAa,GAAnB,MAAM,aAAa;IAGxB,YAEE,aAA6C,EAE7C,iBAAqD;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;QAN/C,UAAK,GAAQ,EAAE,CAAC;IAOrB,CAAC;IAEJ,KAAK,CAAC,UAAU,CAAC,KAAe;QAC9B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,4BAAmB,CAAC,yCAAyC,CAAC,CAAC;QAC3E,CAAC;QAED,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC;YACzC,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI;aACd;YACD,IAAI,EAAE;gBACJ,OAAO,EAAE,KAAK;aACf;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC;YAC1C,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,EAAE,EAAE,KAAK;iBACV;aACF;YACD,IAAI,EAAE;gBACJ,OAAO,EAAE,IAAI;aACd;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,aAAqB,EAAE,gBAA+B;QACrE,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAClC,MAAM,EAAE,GAAU,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAC1D,MAAM,EACN,gBAAgB,CACjB,CAAC;QAEF,MAAM,MAAM,GAAG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CAAC,MAAM,CAAC;wBACP,KAAK,EAAE;4BACL,CAAC,GAAG,cAAc,YAAY,CAAC,EAAE;gCAC/B,CAAC,cAAc,CAAC,EAAE,EAAE;gCACpB,SAAS,EAAE,YAAY,CAAC,EAAE;6BAC3B;yBACF;wBACD,MAAM,EAAE,WAAW;wBACnB,MAAM,EAAE,UAAU;qBACnB,CAAC,CAAC;gBACL,CAAC,CAAC,CACH,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;gBAC1C,KAAK,EAAE,EAAE,EAAE,EAAE;gBACb,IAAI;aACL,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;gBACvD,MAAM,IAAI,4BAAmB,CAAC,sBAAsB,CAAC,CAAC;YACxD,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,4BAAmB,CAAC,KAAK,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AA9VY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAiB,CAAC,CAAC,CAAA;qCADZ,sBAAa;QAET,8BAAiB;GAP5C,aAAa,CA8VzB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"locale.service.spec.d.ts","sourceRoot":"","sources":["../../src/locale/locale.service.spec.ts"],"names":[],"mappings":""}
|
@@ -1,174 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const pagination_1 = require("@hedhog/pagination");
|
4
|
-
const prisma_1 = require("@hedhog/prisma");
|
5
|
-
const common_1 = require("@nestjs/common");
|
6
|
-
const testing_1 = require("@nestjs/testing");
|
7
|
-
const locale_service_1 = require("./locale.service");
|
8
|
-
describe('LocaleService', () => {
|
9
|
-
let service;
|
10
|
-
let prismaService;
|
11
|
-
let paginationService;
|
12
|
-
beforeEach(async () => {
|
13
|
-
const module = await testing_1.Test.createTestingModule({
|
14
|
-
providers: [
|
15
|
-
locale_service_1.LocaleService,
|
16
|
-
{
|
17
|
-
provide: prisma_1.PrismaService,
|
18
|
-
useValue: {
|
19
|
-
translation: {
|
20
|
-
findMany: jest.fn(),
|
21
|
-
},
|
22
|
-
locale: {
|
23
|
-
findUnique: jest.fn(),
|
24
|
-
create: jest.fn(),
|
25
|
-
update: jest.fn(),
|
26
|
-
deleteMany: jest.fn(),
|
27
|
-
},
|
28
|
-
},
|
29
|
-
},
|
30
|
-
{
|
31
|
-
provide: pagination_1.PaginationService,
|
32
|
-
useValue: {
|
33
|
-
paginate: jest.fn(),
|
34
|
-
},
|
35
|
-
},
|
36
|
-
],
|
37
|
-
}).compile();
|
38
|
-
service = module.get(locale_service_1.LocaleService);
|
39
|
-
prismaService = module.get(prisma_1.PrismaService);
|
40
|
-
paginationService = module.get(pagination_1.PaginationService);
|
41
|
-
});
|
42
|
-
it('should be defined', () => {
|
43
|
-
expect(service).toBeDefined();
|
44
|
-
});
|
45
|
-
describe('getTranslations', () => {
|
46
|
-
it('should throw BadRequestException when localeCode is not provided', async () => {
|
47
|
-
await expect(service.getTranslations('', 'namespace')).rejects.toThrow(common_1.BadRequestException);
|
48
|
-
});
|
49
|
-
it('should return translation for a given localeCode and namespace', async () => {
|
50
|
-
const mockTranslations = [
|
51
|
-
{
|
52
|
-
id: 1,
|
53
|
-
locale_id: 1,
|
54
|
-
namespace_id: 1,
|
55
|
-
name: 'hello',
|
56
|
-
value: 'Hello',
|
57
|
-
created_at: new Date(),
|
58
|
-
updated_at: new Date(),
|
59
|
-
},
|
60
|
-
];
|
61
|
-
jest
|
62
|
-
.spyOn(prismaService.translation, 'findMany')
|
63
|
-
.mockResolvedValue(mockTranslations);
|
64
|
-
const result = await service.getTranslations('en-US', 'namespace');
|
65
|
-
expect(result).toEqual({ hello: 'Hello' });
|
66
|
-
});
|
67
|
-
});
|
68
|
-
/*
|
69
|
-
describe('get', () => {
|
70
|
-
it('should paginate locale', async () => {
|
71
|
-
const mockPaginationResult = {
|
72
|
-
data: [],
|
73
|
-
total: 10,
|
74
|
-
lastPage: 1,
|
75
|
-
page: 1,
|
76
|
-
prev: 0,
|
77
|
-
next: 2,
|
78
|
-
pageSize: 10,
|
79
|
-
};
|
80
|
-
jest
|
81
|
-
.spyOn(paginationService, 'paginate')
|
82
|
-
.mockResolvedValue(mockPaginationResult);
|
83
|
-
|
84
|
-
const paginationParams: PaginationDTO = {
|
85
|
-
page: 1,
|
86
|
-
pageSize: 20,
|
87
|
-
sortField: '',
|
88
|
-
sortOrder: PageOrderDirection.Asc,
|
89
|
-
fields: '',
|
90
|
-
search: '',
|
91
|
-
};
|
92
|
-
const result = await service.get(paginationParams );
|
93
|
-
|
94
|
-
expect(paginationService.paginate).toHaveBeenCalledWith(
|
95
|
-
prismaService.locale,
|
96
|
-
paginationParams,
|
97
|
-
expect.anything(),
|
98
|
-
);
|
99
|
-
expect(result).toBe(mockPaginationResult);
|
100
|
-
});
|
101
|
-
});
|
102
|
-
*/
|
103
|
-
describe('getById', () => {
|
104
|
-
it('should return a locale by ID', async () => {
|
105
|
-
const mockLocale = {
|
106
|
-
id: 1,
|
107
|
-
name: 'English',
|
108
|
-
code: 'en',
|
109
|
-
region: 'us',
|
110
|
-
created_at: new Date(),
|
111
|
-
updated_at: new Date(),
|
112
|
-
};
|
113
|
-
jest
|
114
|
-
.spyOn(prismaService.locale, 'findUnique')
|
115
|
-
.mockResolvedValue(mockLocale);
|
116
|
-
const result = await service.getById(1);
|
117
|
-
expect(result).toBe(mockLocale);
|
118
|
-
});
|
119
|
-
});
|
120
|
-
describe('create', () => {
|
121
|
-
it('should create a new locale', async () => {
|
122
|
-
const mockCreateDTO = {
|
123
|
-
name: 'English',
|
124
|
-
code: 'en',
|
125
|
-
region: 'us',
|
126
|
-
};
|
127
|
-
const mockLocale = {
|
128
|
-
id: 1,
|
129
|
-
name: 'English',
|
130
|
-
code: 'en',
|
131
|
-
region: 'us',
|
132
|
-
created_at: new Date(),
|
133
|
-
updated_at: new Date(),
|
134
|
-
};
|
135
|
-
jest.spyOn(prismaService.locale, 'create').mockResolvedValue(mockLocale);
|
136
|
-
const result = await service.create(mockCreateDTO);
|
137
|
-
expect(result).toBe(mockLocale);
|
138
|
-
});
|
139
|
-
});
|
140
|
-
describe('update', () => {
|
141
|
-
it('should update a locale', async () => {
|
142
|
-
const mockUpdateDTO = {
|
143
|
-
name: 'English Updated',
|
144
|
-
code: 'en',
|
145
|
-
region: 'us',
|
146
|
-
};
|
147
|
-
const mockLocale = {
|
148
|
-
id: 1,
|
149
|
-
name: 'English Updated',
|
150
|
-
code: 'en',
|
151
|
-
region: 'us',
|
152
|
-
created_at: new Date(),
|
153
|
-
updated_at: new Date(),
|
154
|
-
};
|
155
|
-
jest.spyOn(prismaService.locale, 'update').mockResolvedValue(mockLocale);
|
156
|
-
const result = await service.update({ id: 1, data: mockUpdateDTO });
|
157
|
-
expect(result).toBe(mockLocale);
|
158
|
-
});
|
159
|
-
});
|
160
|
-
describe('delete', () => {
|
161
|
-
it('should throw BadRequestException if no IDs are provided', async () => {
|
162
|
-
await expect(service.delete({ ids: null })).rejects.toThrow(common_1.BadRequestException);
|
163
|
-
});
|
164
|
-
it('should delete locale by IDs', async () => {
|
165
|
-
const mockDeleteDTO = { ids: [1, 2, 3] };
|
166
|
-
jest
|
167
|
-
.spyOn(prismaService.locale, 'deleteMany')
|
168
|
-
.mockResolvedValue({ count: 3 });
|
169
|
-
const result = await service.delete(mockDeleteDTO);
|
170
|
-
expect(result.count).toBe(3);
|
171
|
-
});
|
172
|
-
});
|
173
|
-
});
|
174
|
-
//# sourceMappingURL=locale.service.spec.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"locale.service.spec.js","sourceRoot":"","sources":["../../src/locale/locale.service.spec.ts"],"names":[],"mappings":";;AAAA,mDAAuD;AACvD,2CAA+C;AAC/C,2CAAqD;AACrD,6CAAsD;AAItD,qDAAiD;AAEjD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,OAAsB,CAAC;IAC3B,IAAI,aAA4B,CAAC;IACjC,IAAI,iBAAoC,CAAC;IAEzC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE;gBACT,8BAAa;gBACb;oBACE,OAAO,EAAE,sBAAa;oBACtB,QAAQ,EAAE;wBACR,WAAW,EAAE;4BACX,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;yBACpB;wBACD,MAAM,EAAE;4BACN,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;qBACF;iBACF;gBACD;oBACE,OAAO,EAAE,8BAAiB;oBAC1B,QAAQ,EAAE;wBACR,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;qBACpB;iBACF;aACF;SACF,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,OAAO,GAAG,MAAM,CAAC,GAAG,CAAgB,8BAAa,CAAC,CAAC;QACnD,aAAa,GAAG,MAAM,CAAC,GAAG,CAAgB,sBAAa,CAAC,CAAC;QACzD,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAoB,8BAAiB,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,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AAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"role.decorator.d.ts","sourceRoot":"","sources":["../../../src/role/decorators/role.decorator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC,wBAAgB,IAAI,qDAEnB"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.WITH_ROLE = void 0;
|
4
|
-
exports.Role = Role;
|
5
|
-
const common_1 = require("@nestjs/common");
|
6
|
-
exports.WITH_ROLE = 'withRole';
|
7
|
-
function Role() {
|
8
|
-
return (0, common_1.SetMetadata)(exports.WITH_ROLE, true);
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=role.decorator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"role.decorator.js","sourceRoot":"","sources":["../../../src/role/decorators/role.decorator.ts"],"names":[],"mappings":";;;AAIA,oBAEC;AAND,2CAA6C;AAEhC,QAAA,SAAS,GAAG,UAAU,CAAC;AAEpC,SAAgB,IAAI;IAClB,OAAO,IAAA,oBAAW,EAAC,iBAAS,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC"}
|
package/src/locale/index.ts
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
import { Pagination } from '@hedhog/pagination';
|
2
|
-
import {
|
3
|
-
Body,
|
4
|
-
Controller,
|
5
|
-
Delete,
|
6
|
-
forwardRef,
|
7
|
-
Get,
|
8
|
-
Inject,
|
9
|
-
Param,
|
10
|
-
ParseIntPipe,
|
11
|
-
Patch,
|
12
|
-
Post,
|
13
|
-
Put,
|
14
|
-
} from '@nestjs/common';
|
15
|
-
import { Public } from '../auth/decorators/public.decorator';
|
16
|
-
import { Role } from '../role/decorators/role.decorator';
|
17
|
-
import { CreateDTO } from './dto/create.dto';
|
18
|
-
import { DeleteDTO } from './dto/delete.dto';
|
19
|
-
import { SetEnabledDTO } from './dto/set-enabled.dto';
|
20
|
-
import { UpdateDTO } from './dto/update.dto';
|
21
|
-
import { Locale } from './locale.decorator';
|
22
|
-
import { LocaleService } from './locale.service';
|
23
|
-
|
24
|
-
@Role()
|
25
|
-
@Controller('locale')
|
26
|
-
export class LocaleController {
|
27
|
-
constructor(
|
28
|
-
@Inject(forwardRef(() => LocaleService))
|
29
|
-
private readonly localeService: LocaleService,
|
30
|
-
) {}
|
31
|
-
|
32
|
-
@Public()
|
33
|
-
@Get('system/enabled')
|
34
|
-
async listEnabled(@Pagination() paginationParams, @Locale() locale: string) {
|
35
|
-
return this.localeService.getEnables(locale, paginationParams);
|
36
|
-
}
|
37
|
-
|
38
|
-
@Public()
|
39
|
-
@Get(':localeCode/:namespace')
|
40
|
-
async getTranslations(
|
41
|
-
@Param('localeCode') localeCode: string,
|
42
|
-
@Param('namespace') namespace: string,
|
43
|
-
) {
|
44
|
-
return this.localeService.getTranslations(localeCode, namespace);
|
45
|
-
}
|
46
|
-
|
47
|
-
@Get()
|
48
|
-
async get(@Pagination() paginationParams, @Locale() locale: string) {
|
49
|
-
return this.localeService.get(locale, paginationParams);
|
50
|
-
}
|
51
|
-
|
52
|
-
@Get(':id')
|
53
|
-
async getById(@Param('id', ParseIntPipe) id: number) {
|
54
|
-
return this.localeService.getById(id);
|
55
|
-
}
|
56
|
-
|
57
|
-
@Post()
|
58
|
-
create(@Body() data: CreateDTO) {
|
59
|
-
return this.localeService.create(data);
|
60
|
-
}
|
61
|
-
|
62
|
-
@Put()
|
63
|
-
async setEnabled(@Body() { codes }: SetEnabledDTO) {
|
64
|
-
return this.localeService.setEnabled(codes);
|
65
|
-
}
|
66
|
-
|
67
|
-
@Patch(':id')
|
68
|
-
async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
|
69
|
-
return this.localeService.update({
|
70
|
-
id,
|
71
|
-
data,
|
72
|
-
});
|
73
|
-
}
|
74
|
-
|
75
|
-
@Delete()
|
76
|
-
async delete(@Body() data: DeleteDTO) {
|
77
|
-
return this.localeService.delete(data);
|
78
|
-
}
|
79
|
-
}
|