@hed-hog/core 0.0.139 → 0.0.140
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/menu/dto/update.dto.d.ts +1 -0
- package/dist/menu/dto/update.dto.d.ts.map +1 -1
- package/dist/menu/dto/update.dto.js +4 -0
- package/dist/menu/dto/update.dto.js.map +1 -1
- package/dist/menu/menu.controller.d.ts +4 -16
- package/dist/menu/menu.controller.d.ts.map +1 -1
- package/dist/menu/menu.controller.js +26 -47
- 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 +54 -6
- package/dist/menu/menu.service.js.map +1 -1
- package/dist/role/role.controller.d.ts +2 -2
- package/dist/role/role.controller.d.ts.map +1 -1
- package/dist/role/role.controller.js +8 -6
- 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 +22 -4
- package/dist/role/role.service.js.map +1 -1
- package/dist/route/route.controller.d.ts +4 -4
- package/dist/route/route.controller.d.ts.map +1 -1
- package/dist/route/route.controller.js +20 -16
- package/dist/route/route.controller.js.map +1 -1
- package/dist/route/route.service.d.ts +4 -4
- package/dist/route/route.service.d.ts.map +1 -1
- package/dist/route/route.service.js +37 -5
- package/dist/route/route.service.js.map +1 -1
- package/hedhog/data/route.yaml +8 -0
- package/package.json +2 -2
- package/src/menu/dto/update.dto.ts +3 -0
- package/src/menu/menu.controller.ts +10 -28
- package/src/menu/menu.service.ts +48 -6
- package/src/role/role.controller.ts +4 -3
- package/src/role/role.service.ts +28 -4
- package/src/route/route.controller.ts +12 -11
- package/src/route/route.service.ts +49 -6
|
@@ -16,10 +16,10 @@ export declare class RouteController {
|
|
|
16
16
|
next: number;
|
|
17
17
|
data: any[];
|
|
18
18
|
}>;
|
|
19
|
-
get(routeId: number): Promise<any>;
|
|
20
|
-
create({ url, method }: CreateDTO): Promise<any>;
|
|
21
|
-
update(routeId: number, data: UpdateDTO): Promise<any>;
|
|
22
|
-
delete(data: DeleteDTO): Promise<{
|
|
19
|
+
get(routeId: number, locale: any): Promise<any>;
|
|
20
|
+
create({ url, method }: CreateDTO, locale: any): Promise<any>;
|
|
21
|
+
update(routeId: number, data: UpdateDTO, locale: any): Promise<any>;
|
|
22
|
+
delete(data: DeleteDTO, locale: any): Promise<{
|
|
23
23
|
count: number;
|
|
24
24
|
}>;
|
|
25
25
|
listRoles(routeId: number, paginationParams: PaginationDTO, locale: any): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.controller.d.ts","sourceRoot":"","sources":["../../src/route/route.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.controller.d.ts","sourceRoot":"","sources":["../../src/route/route.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAapE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,qBAEa,eAAe;IAGxB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,YAAY;IAIvC,IAAI,CAAe,gBAAgB,KAAA;;;;;;;;;IAKnC,GAAG,CAAiC,OAAO,EAAE,MAAM,EAAY,MAAM,KAAA;IAKrE,MAAM,CAAS,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,SAAS,EAAY,MAAM,KAAA;IAK3D,MAAM,CACsB,OAAO,EAAE,MAAM,EACvC,IAAI,EAAE,SAAS,EACb,MAAM,KAAA;IAMZ,MAAM,CAAS,IAAI,EAAE,SAAS,EAAY,MAAM,KAAA;;;IAKhD,SAAS,CACmB,OAAO,EAAE,MAAM,EACjC,gBAAgB,EAAE,aAAa,EACnC,MAAM,KAAA;;;;;;;;;IAMZ,WAAW,CACiB,OAAO,EAAE,MAAM,EACvC,IAAI,EAAE,YAAY;;;IAMtB,WAAW,CACiB,OAAO,EAAE,MAAM,EACjC,gBAAgB,EAAE,aAAa,EACnC,MAAM,KAAA;;;;;;;;;IAMZ,aAAa,CACe,OAAO,EAAE,MAAM,EACvC,IAAI,EAAE,YAAY;;;CAI7B"}
|
|
@@ -13,12 +13,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RouteController = void 0;
|
|
16
|
+
const api_1 = require("@hed-hog/api");
|
|
17
|
+
const api_locale_1 = require("@hed-hog/api-locale");
|
|
16
18
|
const api_pagination_1 = require("@hed-hog/api-pagination");
|
|
17
19
|
const common_1 = require("@nestjs/common");
|
|
18
20
|
const delete_dto_1 = require("../dto/delete.dto");
|
|
19
21
|
const update_ids_dto_1 = require("../dto/update-ids.dto");
|
|
20
|
-
const api_locale_1 = require("@hed-hog/api-locale");
|
|
21
|
-
const api_1 = require("@hed-hog/api");
|
|
22
22
|
const create_dto_1 = require("./dto/create.dto");
|
|
23
23
|
const update_dto_1 = require("./dto/update.dto");
|
|
24
24
|
const route_service_1 = require("./route.service");
|
|
@@ -29,17 +29,17 @@ let RouteController = class RouteController {
|
|
|
29
29
|
async list(paginationParams) {
|
|
30
30
|
return this.routeService.list(paginationParams);
|
|
31
31
|
}
|
|
32
|
-
async get(routeId) {
|
|
33
|
-
return this.routeService.get(routeId);
|
|
32
|
+
async get(routeId, locale) {
|
|
33
|
+
return this.routeService.get(routeId, locale);
|
|
34
34
|
}
|
|
35
|
-
async create({ url, method }) {
|
|
36
|
-
return this.routeService.create({ url, method });
|
|
35
|
+
async create({ url, method }, locale) {
|
|
36
|
+
return this.routeService.create({ url, method }, locale);
|
|
37
37
|
}
|
|
38
|
-
async update(routeId, data) {
|
|
39
|
-
return this.routeService.update({ id: routeId, data });
|
|
38
|
+
async update(routeId, data, locale) {
|
|
39
|
+
return this.routeService.update({ id: routeId, data }, locale);
|
|
40
40
|
}
|
|
41
|
-
async delete(data) {
|
|
42
|
-
return this.routeService.delete(data);
|
|
41
|
+
async delete(data, locale) {
|
|
42
|
+
return this.routeService.delete(data, locale);
|
|
43
43
|
}
|
|
44
44
|
async listRoles(routeId, paginationParams, locale) {
|
|
45
45
|
return this.routeService.listRoles(locale, routeId, paginationParams);
|
|
@@ -65,30 +65,34 @@ __decorate([
|
|
|
65
65
|
__decorate([
|
|
66
66
|
(0, common_1.Get)(':routeId'),
|
|
67
67
|
__param(0, (0, common_1.Param)('routeId', common_1.ParseIntPipe)),
|
|
68
|
+
__param(1, (0, api_locale_1.Locale)()),
|
|
68
69
|
__metadata("design:type", Function),
|
|
69
|
-
__metadata("design:paramtypes", [Number]),
|
|
70
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
70
71
|
__metadata("design:returntype", Promise)
|
|
71
72
|
], RouteController.prototype, "get", null);
|
|
72
73
|
__decorate([
|
|
73
74
|
(0, common_1.Post)(),
|
|
74
75
|
__param(0, (0, common_1.Body)()),
|
|
76
|
+
__param(1, (0, api_locale_1.Locale)()),
|
|
75
77
|
__metadata("design:type", Function),
|
|
76
|
-
__metadata("design:paramtypes", [create_dto_1.CreateDTO]),
|
|
78
|
+
__metadata("design:paramtypes", [create_dto_1.CreateDTO, Object]),
|
|
77
79
|
__metadata("design:returntype", Promise)
|
|
78
80
|
], RouteController.prototype, "create", null);
|
|
79
81
|
__decorate([
|
|
80
82
|
(0, common_1.Patch)(':routeId'),
|
|
81
83
|
__param(0, (0, common_1.Param)('routeId', common_1.ParseIntPipe)),
|
|
82
84
|
__param(1, (0, common_1.Body)()),
|
|
85
|
+
__param(2, (0, api_locale_1.Locale)()),
|
|
83
86
|
__metadata("design:type", Function),
|
|
84
|
-
__metadata("design:paramtypes", [Number, update_dto_1.UpdateDTO]),
|
|
87
|
+
__metadata("design:paramtypes", [Number, update_dto_1.UpdateDTO, Object]),
|
|
85
88
|
__metadata("design:returntype", Promise)
|
|
86
89
|
], RouteController.prototype, "update", null);
|
|
87
90
|
__decorate([
|
|
88
91
|
(0, common_1.Delete)(),
|
|
89
92
|
__param(0, (0, common_1.Body)()),
|
|
93
|
+
__param(1, (0, api_locale_1.Locale)()),
|
|
90
94
|
__metadata("design:type", Function),
|
|
91
|
-
__metadata("design:paramtypes", [delete_dto_1.DeleteDTO]),
|
|
95
|
+
__metadata("design:paramtypes", [delete_dto_1.DeleteDTO, Object]),
|
|
92
96
|
__metadata("design:returntype", Promise)
|
|
93
97
|
], RouteController.prototype, "delete", null);
|
|
94
98
|
__decorate([
|
|
@@ -109,7 +113,7 @@ __decorate([
|
|
|
109
113
|
__metadata("design:returntype", Promise)
|
|
110
114
|
], RouteController.prototype, "updateRoles", null);
|
|
111
115
|
__decorate([
|
|
112
|
-
(0, common_1.Get)(':routeId/
|
|
116
|
+
(0, common_1.Get)(':routeId/screen'),
|
|
113
117
|
__param(0, (0, common_1.Param)('routeId', common_1.ParseIntPipe)),
|
|
114
118
|
__param(1, (0, api_pagination_1.Pagination)()),
|
|
115
119
|
__param(2, (0, api_locale_1.Locale)()),
|
|
@@ -118,7 +122,7 @@ __decorate([
|
|
|
118
122
|
__metadata("design:returntype", Promise)
|
|
119
123
|
], RouteController.prototype, "listScreens", null);
|
|
120
124
|
__decorate([
|
|
121
|
-
(0, common_1.Patch)(':routeId/
|
|
125
|
+
(0, common_1.Patch)(':routeId/screen'),
|
|
122
126
|
__param(0, (0, common_1.Param)('routeId', common_1.ParseIntPipe)),
|
|
123
127
|
__param(1, (0, common_1.Body)()),
|
|
124
128
|
__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.controller.js","sourceRoot":"","sources":["../../src/route/route.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAAoE;AACpE,2CAWwB;AACxB,kDAA8C;AAC9C,0DAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"route.controller.js","sourceRoot":"","sources":["../../src/route/route.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAoC;AACpC,oDAA6C;AAC7C,4DAAoE;AACpE,2CAWwB;AACxB,kDAA8C;AAC9C,0DAAqD;AACrD,iDAA6C;AAC7C,iDAA6C;AAC7C,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAEmB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAC1C,CAAC;IAGE,AAAN,KAAK,CAAC,IAAI,CAAe,gBAAgB;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAGK,AAAN,KAAK,CAAC,GAAG,CAAiC,OAAe,EAAY,MAAM;QACzE,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAAS,EAAE,GAAG,EAAE,MAAM,EAAa,EAAY,MAAM;QAC/D,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CACsB,OAAe,EACvC,IAAe,EACb,MAAM;QAEhB,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAAS,IAAe,EAAY,MAAM;QACpD,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MA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
create({ url, method }: CreateDTO): Promise<any>;
|
|
20
|
+
get(routeId: number, locale: string): Promise<any>;
|
|
21
|
+
create({ url, method }: CreateDTO, locale: string): Promise<any>;
|
|
22
22
|
update({ id, data }: {
|
|
23
23
|
id: number;
|
|
24
24
|
data: UpdateDTO;
|
|
25
|
-
}): Promise<any>;
|
|
26
|
-
delete({ ids }: DeleteDTO): Promise<{
|
|
25
|
+
}, locale: string): Promise<any>;
|
|
26
|
+
delete({ ids }: DeleteDTO, locale: string): Promise<{
|
|
27
27
|
count: number;
|
|
28
28
|
}>;
|
|
29
29
|
listRoles(locale: string, routeId: number, paginationParams: PaginationDTO): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.service.d.ts","sourceRoot":"","sources":["../../src/route/route.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.service.d.ts","sourceRoot":"","sources":["../../src/route/route.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,YAAY;IAGrB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,aAAa,EAAE,aAAa,EAE5B,iBAAiB,EAAE,iBAAiB;IAGjD,IAAI,CAAC,gBAAgB,EAAE,aAAa;;;;;;;;;IAmBpC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAUlD,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAgBhE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAgBnF,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;IAyBlE,SAAS,CACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,aAAa;;;;;;;;;IAiC3B,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAE,OAAO,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;IAgBxE,WAAW,CACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,aAAa;;;;;;;;;IAgC3B,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAE,OAAO,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;CAejF"}
|
|
@@ -13,6 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RouteService = void 0;
|
|
16
|
+
const api_locale_1 = require("@hed-hog/api-locale");
|
|
16
17
|
const api_pagination_1 = require("@hed-hog/api-pagination");
|
|
17
18
|
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
18
19
|
const common_1 = require("@nestjs/common");
|
|
@@ -30,19 +31,50 @@ let RouteService = class RouteService {
|
|
|
30
31
|
},
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
async get(routeId) {
|
|
34
|
-
|
|
34
|
+
async get(routeId, locale) {
|
|
35
|
+
const route = await this.prismaService.route.findUnique({ where: { id: routeId } });
|
|
36
|
+
if (!route) {
|
|
37
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('itemNotFound', locale, `Route with ID ${routeId} not found`).replace('{{item}}', 'Route'));
|
|
38
|
+
}
|
|
39
|
+
return route;
|
|
35
40
|
}
|
|
36
|
-
async create({ url, method }) {
|
|
41
|
+
async create({ url, method }, locale) {
|
|
42
|
+
const existingRoute = await this.prismaService.route.findFirst({
|
|
43
|
+
where: {
|
|
44
|
+
url,
|
|
45
|
+
method,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
if (existingRoute) {
|
|
49
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('itemAlreadyExists', locale, `Route with URL ${url} and method ${method} already exists`).replace('{{item}}', 'Route'));
|
|
50
|
+
}
|
|
37
51
|
return this.prismaService.route.create({ data: { url, method } });
|
|
38
52
|
}
|
|
39
|
-
async update({ id, data }) {
|
|
53
|
+
async update({ id, data }, locale) {
|
|
54
|
+
const routeExists = await this.prismaService.route.findUnique({
|
|
55
|
+
where: { id },
|
|
56
|
+
});
|
|
57
|
+
if (!routeExists) {
|
|
58
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('itemNotFound', locale, `Route with ID ${id} not found`).replace('{{item}}', 'Route'));
|
|
59
|
+
}
|
|
40
60
|
return this.prismaService.route.update({
|
|
41
61
|
where: { id },
|
|
42
62
|
data,
|
|
43
63
|
});
|
|
44
64
|
}
|
|
45
|
-
async delete({ ids }) {
|
|
65
|
+
async delete({ ids }, locale) {
|
|
66
|
+
const existingRoutes = await this.prismaService.route.findMany({
|
|
67
|
+
where: {
|
|
68
|
+
id: {
|
|
69
|
+
in: ids,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
if (existingRoutes.length !== ids.length) {
|
|
74
|
+
const existingIds = existingRoutes.map((route) => route.id);
|
|
75
|
+
const missingIds = ids.filter((id) => !existingIds.includes(id));
|
|
76
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('itemsNotFound', locale, `Routes with IDs ${missingIds.join(', ')} not found`).replace('{{items}}', 'Routes'));
|
|
77
|
+
}
|
|
46
78
|
return this.prismaService.route.deleteMany({
|
|
47
79
|
where: {
|
|
48
80
|
id: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.service.js","sourceRoot":"","sources":["../../src/route/route.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAA2E;AAC3E,oDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"route.service.js","sourceRoot":"","sources":["../../src/route/route.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoD;AACpD,4DAA2E;AAC3E,oDAAoD;AACpD,2CAAwG;AAOjG,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,gBAA+B;QACxC,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAEjC,MAAM,EAAE,GAAU,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAC1D,MAAM,EACN,gBAAgB,CACjB,CAAC;QAEF,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CACpC,IAAI,CAAC,aAAa,CAAC,KAAK,EACxB,gBAAgB,EAChB;YACE,KAAK,EAAE;gBACL,EAAE;aACH;SACF,CACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAAe,EAAE,MAAc;QACvC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,K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AAE;wBACN,QAAQ,EAAE,IAAI;wBACd,SAAS,EAAE,IAAI;qBAChB;iBACF;aACF;SACF,EACD,eAAe,CAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAe,EAAE,IAAkB;QACrD,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC;YAC/C,KAAK,EAAE;gBACL,QAAQ,EAAE,OAAO;aAClB;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC;YAChD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBAChC,SAAS,EAAE,QAAQ;gBACnB,QAAQ,EAAE,OAAO;aAClB,CAAC,CAAC;YACH,cAAc,EAAE,IAAI;SACrB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AApMY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kCAAiB,CAAC,CAAC,CAAA;qCADZ,0BAAa;QAET,kCAAiB;GAL5C,YAAY,CAoMxB"}
|
package/hedhog/data/route.yaml
CHANGED
|
@@ -36,6 +36,14 @@
|
|
|
36
36
|
slug: admin
|
|
37
37
|
- where:
|
|
38
38
|
slug: admin-access
|
|
39
|
+
- url: /sessions/revoke-all-other
|
|
40
|
+
method: DELETE
|
|
41
|
+
relations:
|
|
42
|
+
role:
|
|
43
|
+
- where:
|
|
44
|
+
slug: admin
|
|
45
|
+
- where:
|
|
46
|
+
slug: admin-access
|
|
39
47
|
- url: /sessions/:sessionId/revoke
|
|
40
48
|
method: DELETE
|
|
41
49
|
relations:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hed-hog/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.140",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"speakeasy": "^2.0.0",
|
|
31
31
|
"uuid": "^11.1.0",
|
|
32
32
|
"@hed-hog/api-locale": "0.0.11",
|
|
33
|
-
"@hed-hog/api-mail": "0.0.7",
|
|
34
33
|
"@hed-hog/api-prisma": "0.0.4",
|
|
34
|
+
"@hed-hog/api-mail": "0.0.7",
|
|
35
35
|
"@hed-hog/types": "0.0.1",
|
|
36
36
|
"@hed-hog/api-pagination": "0.0.5",
|
|
37
37
|
"@hed-hog/api": "0.0.3"
|
|
@@ -47,15 +47,6 @@ export class MenuController {
|
|
|
47
47
|
return this.menuService.listRoles(locale, menuId, paginationParams);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
@Get(':menuId/screen')
|
|
51
|
-
async listScreens(
|
|
52
|
-
@Param('menuId', ParseIntPipe) menuId: number,
|
|
53
|
-
@Pagination() paginationParams,
|
|
54
|
-
@Locale() locale,
|
|
55
|
-
) {
|
|
56
|
-
return this.menuService.listScreens(locale, menuId, paginationParams);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
50
|
@Patch(':menuId/role')
|
|
60
51
|
async updateRoles(
|
|
61
52
|
@Param('menuId', ParseIntPipe) menuId: number,
|
|
@@ -65,30 +56,26 @@ export class MenuController {
|
|
|
65
56
|
return this.menuService.updateRoles(locale, menuId, data);
|
|
66
57
|
}
|
|
67
58
|
|
|
68
|
-
@Patch(':menuId/screen')
|
|
69
|
-
async updateScreens(
|
|
70
|
-
@Param('menuId', ParseIntPipe) menuId: number,
|
|
71
|
-
@Body() data: UpdateIdsDTO,
|
|
72
|
-
@Locale() locale,
|
|
73
|
-
) {
|
|
74
|
-
return this.menuService.updateScreens(locale, menuId, data);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
59
|
@Get(':menuId')
|
|
78
60
|
async show(@Locale() locale,@Param('menuId', ParseIntPipe) menuId: number) {
|
|
79
61
|
return this.menuService.get(locale, menuId);
|
|
80
62
|
}
|
|
81
63
|
|
|
82
64
|
@Post()
|
|
83
|
-
async create(@Body() data: CreateDTO) {
|
|
84
|
-
return this.menuService.create(data);
|
|
65
|
+
async create(@Locale() locale, @Body() data: CreateDTO) {
|
|
66
|
+
return this.menuService.create(locale,data);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Patch('order')
|
|
70
|
+
async updateOrder(@Locale() locale, @Body() data: OrderDTO): Promise<void> {
|
|
71
|
+
return this.menuService.updateOrder(locale, data);
|
|
85
72
|
}
|
|
86
73
|
|
|
87
74
|
@Patch(':menuId')
|
|
88
75
|
async update(
|
|
76
|
+
@Locale() locale,
|
|
89
77
|
@Param('menuId', ParseIntPipe) menuId: number,
|
|
90
78
|
@Body() data: UpdateDTO,
|
|
91
|
-
@Locale() locale,
|
|
92
79
|
) {
|
|
93
80
|
return this.menuService.update(locale,{
|
|
94
81
|
id: menuId,
|
|
@@ -97,12 +84,7 @@ export class MenuController {
|
|
|
97
84
|
}
|
|
98
85
|
|
|
99
86
|
@Delete()
|
|
100
|
-
async delete(@Body() data: DeleteDTO) {
|
|
101
|
-
return this.menuService.delete(data);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
@Patch('order')
|
|
105
|
-
async updateOrder(@Body() data: OrderDTO): Promise<void> {
|
|
106
|
-
return this.menuService.updateOrder(data);
|
|
87
|
+
async delete(@Locale() locale, @Body() data: DeleteDTO) {
|
|
88
|
+
return this.menuService.delete(locale, data);
|
|
107
89
|
}
|
|
108
90
|
}
|
package/src/menu/menu.service.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
BadRequestException,
|
|
7
7
|
Inject,
|
|
8
8
|
Injectable,
|
|
9
|
+
NotFoundException,
|
|
9
10
|
forwardRef,
|
|
10
11
|
} from '@nestjs/common';
|
|
11
12
|
import { DeleteDTO } from '../dto/delete.dto';
|
|
@@ -276,7 +277,7 @@ export class MenuService {
|
|
|
276
277
|
});
|
|
277
278
|
|
|
278
279
|
if (!user) {
|
|
279
|
-
throw new
|
|
280
|
+
throw new NotFoundException(
|
|
280
281
|
getLocaleText('menuNotFound', locale, 'Menu not found.'),
|
|
281
282
|
);
|
|
282
283
|
}
|
|
@@ -284,7 +285,7 @@ export class MenuService {
|
|
|
284
285
|
return user;
|
|
285
286
|
}
|
|
286
287
|
|
|
287
|
-
async create({ slug, url, icon, order, menuId }: CreateDTO) {
|
|
288
|
+
async create(_locale:string, { slug, url, icon, order, menuId }: CreateDTO) {
|
|
288
289
|
return this.prismaService.menu.create({
|
|
289
290
|
data: { slug, url, icon, order, menu_id: menuId },
|
|
290
291
|
});
|
|
@@ -304,13 +305,54 @@ export class MenuService {
|
|
|
304
305
|
);
|
|
305
306
|
}
|
|
306
307
|
|
|
307
|
-
|
|
308
|
+
const { locale: localeData, ...menuData } = data;
|
|
309
|
+
|
|
310
|
+
// Update menu data
|
|
311
|
+
const result = await this.prismaService.menu.update({
|
|
308
312
|
where: { id },
|
|
309
|
-
data,
|
|
313
|
+
data: menuData,
|
|
310
314
|
});
|
|
315
|
+
|
|
316
|
+
// Update locale translations if provided
|
|
317
|
+
if (localeData) {
|
|
318
|
+
for (const [localeCode, translation] of Object.entries(localeData)) {
|
|
319
|
+
const localeRecord = await this.prismaService.locale.findUnique({
|
|
320
|
+
where: { code: localeCode },
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
if (localeRecord) {
|
|
324
|
+
// Check if translation exists
|
|
325
|
+
const existingTranslation = await this.prismaService.menu_locale.findFirst({
|
|
326
|
+
where: {
|
|
327
|
+
menu_id: id,
|
|
328
|
+
locale_id: localeRecord.id,
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
if (existingTranslation) {
|
|
333
|
+
// Update existing translation
|
|
334
|
+
await this.prismaService.menu_locale.update({
|
|
335
|
+
where: { id: existingTranslation.id },
|
|
336
|
+
data: { name: translation },
|
|
337
|
+
});
|
|
338
|
+
} else {
|
|
339
|
+
// Create new translation
|
|
340
|
+
await this.prismaService.menu_locale.create({
|
|
341
|
+
data: {
|
|
342
|
+
menu_id: id,
|
|
343
|
+
locale_id: localeRecord.id,
|
|
344
|
+
name: translation,
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return result;
|
|
311
353
|
}
|
|
312
354
|
|
|
313
|
-
async delete({ ids }: DeleteDTO
|
|
355
|
+
async delete(locale: string, { ids }: DeleteDTO): Promise<{count:number}> {
|
|
314
356
|
if (ids == undefined || ids == null) {
|
|
315
357
|
throw new BadRequestException(
|
|
316
358
|
getLocaleText('deleteItemsRequired', locale, 'You must select at least one menu to delete.'),
|
|
@@ -340,7 +382,7 @@ export class MenuService {
|
|
|
340
382
|
});
|
|
341
383
|
}
|
|
342
384
|
|
|
343
|
-
async updateOrder({ ids }: OrderDTO
|
|
385
|
+
async updateOrder(locale: string, { ids }: OrderDTO): Promise<void> {
|
|
344
386
|
const count = await this.prismaService.menu.count({
|
|
345
387
|
where: {
|
|
346
388
|
id: {
|
|
@@ -116,12 +116,13 @@ export class RoleController {
|
|
|
116
116
|
async update(
|
|
117
117
|
@Param('roleId', ParseIntPipe) roleId: number,
|
|
118
118
|
@Body() data: UpdateDTO,
|
|
119
|
+
@Locale() locale,
|
|
119
120
|
) {
|
|
120
|
-
return this.roleService.update(roleId, data);
|
|
121
|
+
return this.roleService.update(roleId, data, locale);
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
@Delete()
|
|
124
|
-
async delete(@Body() data: DeleteDTO) {
|
|
125
|
-
return this.roleService.delete(data);
|
|
125
|
+
async delete(@Body() data: DeleteDTO, @Locale() locale) {
|
|
126
|
+
return this.roleService.delete(data, locale);
|
|
126
127
|
}
|
|
127
128
|
}
|
package/src/role/role.service.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Inject,
|
|
7
7
|
Injectable,
|
|
8
|
+
NotFoundException,
|
|
8
9
|
forwardRef,
|
|
9
10
|
} from '@nestjs/common';
|
|
10
11
|
import { DeleteDTO } from '../dto/delete.dto';
|
|
@@ -378,7 +379,7 @@ export class RoleService {
|
|
|
378
379
|
});
|
|
379
380
|
|
|
380
381
|
if (!role) {
|
|
381
|
-
|
|
382
|
+
throw new NotFoundException(`Role with ID ${roleId} not found`);
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
const localeData = role.role_locale.reduce((acc, item) => {
|
|
@@ -423,7 +424,16 @@ export class RoleService {
|
|
|
423
424
|
return this.get(role.id);
|
|
424
425
|
}
|
|
425
426
|
|
|
426
|
-
async update(id: number, body: UpdateDTO) {
|
|
427
|
+
async update(id: number, body: UpdateDTO, localeRequest:string) {
|
|
428
|
+
|
|
429
|
+
const roleExists = await this.prismaService.role.findUnique({
|
|
430
|
+
where: { id },
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
if (!roleExists) {
|
|
434
|
+
throw new NotFoundException(getLocaleText('itemNotFound', localeRequest, `Role with ID ${id} not found`).replace('{{item}}', 'Role'));
|
|
435
|
+
}
|
|
436
|
+
|
|
427
437
|
const { locale } = body;
|
|
428
438
|
|
|
429
439
|
if (locale) {
|
|
@@ -463,13 +473,27 @@ export class RoleService {
|
|
|
463
473
|
return this.get(id);
|
|
464
474
|
}
|
|
465
475
|
|
|
466
|
-
async delete({ ids }: DeleteDTO,
|
|
476
|
+
async delete({ ids }: DeleteDTO, localeRequest: string = 'en'):Promise<{count:number}> {
|
|
467
477
|
if (ids == undefined || ids == null) {
|
|
468
478
|
throw new BadRequestException(
|
|
469
|
-
getLocaleText('deleteItemsRequired',
|
|
479
|
+
getLocaleText('deleteItemsRequired', localeRequest, 'You must select at least one permission to delete.'),
|
|
470
480
|
);
|
|
471
481
|
}
|
|
472
482
|
|
|
483
|
+
const existingRoles = await this.prismaService.role.findMany({
|
|
484
|
+
where: {
|
|
485
|
+
id: {
|
|
486
|
+
in: ids,
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
if (existingRoles.length !== ids.length) {
|
|
492
|
+
const existingIds = existingRoles.map((role) => role.id);
|
|
493
|
+
const missingIds = ids.filter((id) => !existingIds.includes(id));
|
|
494
|
+
throw new NotFoundException(getLocaleText('itemsNotFound', localeRequest, `Roles with IDs ${missingIds.join(', ')} not found`).replace('{{items}}', 'Roles'));
|
|
495
|
+
}
|
|
496
|
+
|
|
473
497
|
return this.prismaService.role.deleteMany({
|
|
474
498
|
where: {
|
|
475
499
|
id: {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Role } from '@hed-hog/api';
|
|
2
|
+
import { Locale } from '@hed-hog/api-locale';
|
|
1
3
|
import { Pagination, PaginationDTO } from '@hed-hog/api-pagination';
|
|
2
4
|
import {
|
|
3
5
|
Body,
|
|
@@ -13,8 +15,6 @@ import {
|
|
|
13
15
|
} from '@nestjs/common';
|
|
14
16
|
import { DeleteDTO } from '../dto/delete.dto';
|
|
15
17
|
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
|
16
|
-
import { Locale } from '@hed-hog/api-locale';
|
|
17
|
-
import { Role } from '@hed-hog/api';
|
|
18
18
|
import { CreateDTO } from './dto/create.dto';
|
|
19
19
|
import { UpdateDTO } from './dto/update.dto';
|
|
20
20
|
import { RouteService } from './route.service';
|
|
@@ -33,26 +33,27 @@ export class RouteController {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
@Get(':routeId')
|
|
36
|
-
async get(@Param('routeId', ParseIntPipe) routeId: number) {
|
|
37
|
-
return this.routeService.get(routeId);
|
|
36
|
+
async get(@Param('routeId', ParseIntPipe) routeId: number, @Locale() locale) {
|
|
37
|
+
return this.routeService.get(routeId, locale);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
@Post()
|
|
41
|
-
async create(@Body() { url, method }: CreateDTO) {
|
|
42
|
-
return this.routeService.create({ url, method });
|
|
41
|
+
async create(@Body() { url, method }: CreateDTO, @Locale() locale) {
|
|
42
|
+
return this.routeService.create({ url, method }, locale);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@Patch(':routeId')
|
|
46
46
|
async update(
|
|
47
47
|
@Param('routeId', ParseIntPipe) routeId: number,
|
|
48
48
|
@Body() data: UpdateDTO,
|
|
49
|
+
@Locale() locale
|
|
49
50
|
) {
|
|
50
|
-
return this.routeService.update({ id: routeId, data });
|
|
51
|
+
return this.routeService.update({ id: routeId, data }, locale);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
@Delete()
|
|
54
|
-
async delete(@Body() data: DeleteDTO) {
|
|
55
|
-
return this.routeService.delete(data);
|
|
55
|
+
async delete(@Body() data: DeleteDTO, @Locale() locale) {
|
|
56
|
+
return this.routeService.delete(data, locale);
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
@Get(':routeId/role')
|
|
@@ -72,7 +73,7 @@ export class RouteController {
|
|
|
72
73
|
return this.routeService.updateRoles(routeId, data);
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
@Get(':routeId/
|
|
76
|
+
@Get(':routeId/screen')
|
|
76
77
|
async listScreens(
|
|
77
78
|
@Param('routeId', ParseIntPipe) routeId: number,
|
|
78
79
|
@Pagination() paginationParams: PaginationDTO,
|
|
@@ -81,7 +82,7 @@ export class RouteController {
|
|
|
81
82
|
return this.routeService.listScreens(locale, routeId, paginationParams);
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
@Patch(':routeId/
|
|
85
|
+
@Patch(':routeId/screen')
|
|
85
86
|
async updateScreens(
|
|
86
87
|
@Param('routeId', ParseIntPipe) routeId: number,
|
|
87
88
|
@Body() data: UpdateIdsDTO,
|