@hedhog/admin 0.0.103 → 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
package/dist/admin.module.js
CHANGED
@@ -7,17 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
7
7
|
};
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
9
9
|
exports.AdminModule = void 0;
|
10
|
-
const prisma_1 = require("@hedhog/prisma");
|
11
10
|
const pagination_1 = require("@hedhog/pagination");
|
11
|
+
const prisma_1 = require("@hedhog/prisma");
|
12
12
|
const common_1 = require("@nestjs/common");
|
13
13
|
const auth_module_1 = require("./auth/auth.module");
|
14
|
+
const locale_1 = require("./locale");
|
14
15
|
const menu_module_1 = require("./menu/menu.module");
|
15
|
-
const screen_module_1 = require("./screen/screen.module");
|
16
|
-
const user_module_1 = require("./user/user.module");
|
17
16
|
const role_module_1 = require("./role/role.module");
|
18
17
|
const route_module_1 = require("./route/route.module");
|
19
|
-
const
|
20
|
-
const
|
18
|
+
const screen_module_1 = require("./screen/screen.module");
|
19
|
+
const setting_module_1 = require("./setting/setting.module");
|
20
|
+
const user_module_1 = require("./user/user.module");
|
21
21
|
let AdminModule = class AdminModule {
|
22
22
|
};
|
23
23
|
exports.AdminModule = AdminModule;
|
@@ -31,7 +31,7 @@ exports.AdminModule = AdminModule = __decorate([
|
|
31
31
|
(0, common_1.forwardRef)(() => route_module_1.RouteModule),
|
32
32
|
(0, common_1.forwardRef)(() => prisma_1.PrismaModule),
|
33
33
|
(0, common_1.forwardRef)(() => screen_module_1.ScreenModule),
|
34
|
-
(0, common_1.forwardRef)(() =>
|
34
|
+
(0, common_1.forwardRef)(() => setting_module_1.SettingModule),
|
35
35
|
(0, common_1.forwardRef)(() => locale_1.LocaleModule),
|
36
36
|
(0, common_1.forwardRef)(() => user_module_1.UserModule),
|
37
37
|
],
|
@@ -41,7 +41,7 @@ exports.AdminModule = AdminModule = __decorate([
|
|
41
41
|
route_module_1.RouteModule,
|
42
42
|
role_module_1.RoleModule,
|
43
43
|
menu_module_1.MenuModule,
|
44
|
-
|
44
|
+
setting_module_1.SettingModule,
|
45
45
|
screen_module_1.ScreenModule,
|
46
46
|
],
|
47
47
|
})
|
package/dist/admin.module.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"admin.module.js","sourceRoot":"","sources":["../src/admin.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8C;AAC9C,
|
1
|
+
{"version":3,"file":"admin.module.js","sourceRoot":"","sources":["../src/admin.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAsD;AACtD,2CAA8C;AAC9C,2CAAoD;AACpD,oDAAgD;AAChD,qCAAwC;AACxC,oDAAgD;AAChD,oDAAgD;AAChD,uDAAmD;AACnD,0DAAsD;AACtD,6DAAyD;AACzD,oDAAgD;AAyBzC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAvBvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6BAAgB,CAAC;YAClC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC;YAC7B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,4BAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAa,CAAC;YAC/B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;SAC7B;QACD,OAAO,EAAE;YACP,wBAAU;YACV,wBAAU;YACV,0BAAW;YACX,wBAAU;YACV,wBAAU;YACV,8BAAa;YACb,4BAAY;SACb;KACF,CAAC;GACW,WAAW,CAAG"}
|
@@ -1,9 +1,9 @@
|
|
1
|
+
import { MailService } from '@hedhog/mail';
|
1
2
|
import { PrismaService } from '@hedhog/prisma';
|
2
3
|
import { JwtService } from '@nestjs/jwt';
|
3
4
|
import { ForgetDTO } from './dto/forget.dto';
|
4
5
|
import { LoginDTO } from './dto/login.dto';
|
5
6
|
import { OtpDTO } from './dto/otp.dto';
|
6
|
-
import { MailService } from '@hedhog/mail';
|
7
7
|
export declare class AuthService {
|
8
8
|
private readonly prisma;
|
9
9
|
private readonly jwt;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,qBACa,WAAW;IAGpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAEpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAJJ,MAAM,EAAE,aAAa,EAErB,GAAG,EAAE,UAAU,EAEf,IAAI,EAAE,WAAW;IAG9B,WAAW,CAAC,KAAK,EAAE,MAAM;IAM/B,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAW5C,oBAAoB,IAAI,MAAM;IAMxB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;IAgDzD,QAAQ,CAAC,IAAI,KAAA;;;IAUb,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS;IAkC3B,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM;;;IA0BjC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,QAAQ;;;;;;IAInC,MAAM,CAAC,EAAE,EAAE,MAAM;CAGlB"}
|
@@ -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.AuthService = void 0;
|
16
|
+
const mail_1 = require("@hedhog/mail");
|
16
17
|
const prisma_1 = require("@hedhog/prisma");
|
17
18
|
const common_1 = require("@nestjs/common");
|
18
19
|
const jwt_1 = require("@nestjs/jwt");
|
19
20
|
const bcrypt_1 = require("bcrypt");
|
20
21
|
const multifactor_type_enum_1 = require("./enums/multifactor-type.enum");
|
21
|
-
const mail_1 = require("@hedhog/mail");
|
22
22
|
let AuthService = class AuthService {
|
23
23
|
constructor(prisma, jwt, mail) {
|
24
24
|
this.prisma = prisma;
|
@@ -45,7 +45,7 @@ let AuthService = class AuthService {
|
|
45
45
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
46
46
|
}
|
47
47
|
async loginWithEmailAndPassword(email, password) {
|
48
|
-
const user = await this.prisma.
|
48
|
+
const user = await this.prisma.user.findFirst({
|
49
49
|
where: {
|
50
50
|
email,
|
51
51
|
},
|
@@ -63,7 +63,7 @@ let AuthService = class AuthService {
|
|
63
63
|
else {
|
64
64
|
if (user.multifactor_id === multifactor_type_enum_1.MultifactorType.EMAIL) {
|
65
65
|
const code = this.generateRandomNumber();
|
66
|
-
await this.prisma.
|
66
|
+
await this.prisma.user.update({
|
67
67
|
where: {
|
68
68
|
id: user.id,
|
69
69
|
},
|
@@ -94,7 +94,7 @@ let AuthService = class AuthService {
|
|
94
94
|
};
|
95
95
|
}
|
96
96
|
async forget({ email }) {
|
97
|
-
const user = await this.prisma.
|
97
|
+
const user = await this.prisma.user.findFirst({
|
98
98
|
where: {
|
99
99
|
email,
|
100
100
|
},
|
@@ -106,7 +106,7 @@ let AuthService = class AuthService {
|
|
106
106
|
throw new common_1.NotFoundException('User not found');
|
107
107
|
}
|
108
108
|
const code = this.generateRandomString(32);
|
109
|
-
await this.prisma.
|
109
|
+
await this.prisma.user.update({
|
110
110
|
where: {
|
111
111
|
id: user.id,
|
112
112
|
},
|
@@ -123,7 +123,7 @@ let AuthService = class AuthService {
|
|
123
123
|
}
|
124
124
|
async otp({ token, code }) {
|
125
125
|
const data = this.jwt.decode(token);
|
126
|
-
const user = await this.prisma.
|
126
|
+
const user = await this.prisma.user.findFirst({
|
127
127
|
where: {
|
128
128
|
id: data['id'],
|
129
129
|
code: String(code),
|
@@ -132,7 +132,7 @@ let AuthService = class AuthService {
|
|
132
132
|
if (!user) {
|
133
133
|
throw new common_1.NotFoundException('Invalid code');
|
134
134
|
}
|
135
|
-
await this.prisma.
|
135
|
+
await this.prisma.user.update({
|
136
136
|
where: {
|
137
137
|
id: user.id,
|
138
138
|
},
|
@@ -146,7 +146,7 @@ let AuthService = class AuthService {
|
|
146
146
|
return this.loginWithEmailAndPassword(email, password);
|
147
147
|
}
|
148
148
|
verify(id) {
|
149
|
-
return this.prisma.
|
149
|
+
return this.prisma.user.findUnique({ where: { id } });
|
150
150
|
}
|
151
151
|
};
|
152
152
|
exports.AuthService = AuthService;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+C;AAC/C,2CAKwB;AACxB,qCAAyC;AACzC,mCAAiC;AAIjC,yEAAgE;
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAA2C;AAC3C,2CAA+C;AAC/C,2CAKwB;AACxB,qCAAyC;AACzC,mCAAiC;AAIjC,yEAAgE;AAGzD,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAEmB,MAAqB,EAErB,GAAe,EAEf,IAAiB;QAJjB,WAAM,GAAN,MAAM,CAAe;QAErB,QAAG,GAAH,GAAG,CAAY;QAEf,SAAI,GAAJ,IAAI,CAAa;IACjC,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE;YACjC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;IAED,oBAAoB,CAAC,MAAc;QACjC,MAAM,UAAU,GACd,gEAAgE,CAAC;QACnE,IAAI,MAAM,GA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E,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AA9JY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAGR,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,gBAAU,CAAC,CAAC,CAAA;IAEpC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kBAAW,CAAC,CAAC,CAAA;qCAHb,sBAAa;QAEhB,gBAAU;QAET,kBAAW;GAPzB,WAAW,CA8JvB"}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const testing_1 = require("@nestjs/testing");
|
4
|
-
const auth_service_1 = require("./auth.service");
|
5
|
-
const prisma_1 = require("@hedhog/prisma");
|
6
|
-
const jwt_1 = require("@nestjs/jwt");
|
7
3
|
const mail_1 = require("@hedhog/mail");
|
4
|
+
const prisma_1 = require("@hedhog/prisma");
|
8
5
|
const common_1 = require("@nestjs/common");
|
6
|
+
const jwt_1 = require("@nestjs/jwt");
|
7
|
+
const testing_1 = require("@nestjs/testing");
|
9
8
|
const bcrypt_1 = require("bcrypt");
|
9
|
+
const auth_service_1 = require("./auth.service");
|
10
10
|
jest.mock('bcrypt');
|
11
11
|
describe('AuthService', () => {
|
12
12
|
let authService;
|
@@ -20,7 +20,7 @@ describe('AuthService', () => {
|
|
20
20
|
{
|
21
21
|
provide: prisma_1.PrismaService,
|
22
22
|
useValue: {
|
23
|
-
|
23
|
+
user: {
|
24
24
|
findFirst: jest.fn(),
|
25
25
|
update: jest.fn(),
|
26
26
|
findUnique: jest.fn(),
|
@@ -53,7 +53,7 @@ describe('AuthService', () => {
|
|
53
53
|
});
|
54
54
|
describe('loginWithEmailAndPassword', () => {
|
55
55
|
it('should throw NotFoundException if user is not found', async () => {
|
56
|
-
jest.spyOn(prismaService.
|
56
|
+
jest.spyOn(prismaService.user, 'findFirst').mockResolvedValue(null);
|
57
57
|
await expect(authService.loginWithEmailAndPassword('test@example.com', 'password')).rejects.toThrow(common_1.NotFoundException);
|
58
58
|
});
|
59
59
|
it('should throw NotFoundException if password is invalid', async () => {
|
@@ -67,7 +67,7 @@ describe('AuthService', () => {
|
|
67
67
|
created_at: new Date(),
|
68
68
|
updated_at: new Date(),
|
69
69
|
};
|
70
|
-
jest.spyOn(prismaService.
|
70
|
+
jest.spyOn(prismaService.user, 'findFirst').mockResolvedValue(mockUser);
|
71
71
|
bcrypt_1.compare.mockResolvedValue(false);
|
72
72
|
await expect(authService.loginWithEmailAndPassword('test@example.com', 'password')).rejects.toThrow(common_1.NotFoundException);
|
73
73
|
});
|
@@ -82,7 +82,7 @@ describe('AuthService', () => {
|
|
82
82
|
created_at: new Date(),
|
83
83
|
updated_at: new Date(),
|
84
84
|
};
|
85
|
-
jest.spyOn(prismaService.
|
85
|
+
jest.spyOn(prismaService.user, 'findFirst').mockResolvedValue(mockUser);
|
86
86
|
bcrypt_1.compare.mockResolvedValue(true);
|
87
87
|
jest.spyOn(jwtService, 'sign').mockReturnValue('token');
|
88
88
|
const result = await authService.loginWithEmailAndPassword('test@example.com', 'password');
|
@@ -91,7 +91,7 @@ describe('AuthService', () => {
|
|
91
91
|
});
|
92
92
|
describe('forget', () => {
|
93
93
|
it('should throw NotFoundException if user is not found', async () => {
|
94
|
-
jest.spyOn(prismaService.
|
94
|
+
jest.spyOn(prismaService.user, 'findFirst').mockResolvedValue(null);
|
95
95
|
await expect(authService.forget({ email: 'test@example.com' })).rejects.toThrow(common_1.NotFoundException);
|
96
96
|
});
|
97
97
|
it('should update user with reset code and send email', async () => {
|
@@ -105,13 +105,13 @@ describe('AuthService', () => {
|
|
105
105
|
created_at: new Date(),
|
106
106
|
updated_at: new Date(),
|
107
107
|
};
|
108
|
-
jest.spyOn(prismaService.
|
109
|
-
jest.spyOn(prismaService.
|
108
|
+
jest.spyOn(prismaService.user, 'findFirst').mockResolvedValue(mockUser);
|
109
|
+
jest.spyOn(prismaService.user, 'update').mockResolvedValue(mockUser);
|
110
110
|
jest
|
111
111
|
.spyOn(authService, 'generateRandomString')
|
112
112
|
.mockReturnValue('resetCode');
|
113
113
|
const result = await authService.forget({ email: 'test@example.com' });
|
114
|
-
expect(prismaService.
|
114
|
+
expect(prismaService.user.update).toHaveBeenCalledWith({
|
115
115
|
where: { id: 1 },
|
116
116
|
data: { code: 'resetCode' },
|
117
117
|
});
|
@@ -126,7 +126,7 @@ describe('AuthService', () => {
|
|
126
126
|
describe('otp', () => {
|
127
127
|
it('should throw NotFoundException if user with code is not found', async () => {
|
128
128
|
jest.spyOn(jwtService, 'decode').mockReturnValue({ id: 1 });
|
129
|
-
jest.spyOn(prismaService.
|
129
|
+
jest.spyOn(prismaService.user, 'findFirst').mockResolvedValue(null);
|
130
130
|
await expect(authService.otp({ token: 'token', code: 123456 })).rejects.toThrow(common_1.NotFoundException);
|
131
131
|
});
|
132
132
|
it('should return a token if otp is valid', async () => {
|
@@ -141,11 +141,11 @@ describe('AuthService', () => {
|
|
141
141
|
updated_at: new Date(),
|
142
142
|
};
|
143
143
|
jest.spyOn(jwtService, 'decode').mockReturnValue({ id: 1 });
|
144
|
-
jest.spyOn(prismaService.
|
145
|
-
jest.spyOn(prismaService.
|
144
|
+
jest.spyOn(prismaService.user, 'findFirst').mockResolvedValue(mockUser);
|
145
|
+
jest.spyOn(prismaService.user, 'update').mockResolvedValue(mockUser);
|
146
146
|
jest.spyOn(jwtService, 'sign').mockReturnValue('newToken');
|
147
147
|
const result = await authService.otp({ token: 'token', code: 123456 });
|
148
|
-
expect(prismaService.
|
148
|
+
expect(prismaService.user.update).toHaveBeenCalledWith({
|
149
149
|
where: { id: 1 },
|
150
150
|
data: { code: null },
|
151
151
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.service.spec.js","sourceRoot":"","sources":["../../src/auth/auth.service.spec.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"auth.service.spec.js","sourceRoot":"","sources":["../../src/auth/auth.service.spec.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAA+C;AAC/C,2CAAmD;AACnD,qCAAyC;AACzC,6CAAsD;AACtD,mCAAiC;AACjC,iDAA6C;AAE7C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAEpB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,WAAwB,CAAC;IAC7B,IAAI,aAA4B,CAAC;IACjC,IAAI,UAAsB,CAAC;IAC3B,IAAI,WAAwB,CAAC;IAE7B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE;gBACT,0BAAW;gBACX;oBACE,OAAO,EAAE,sBAAa;oBACtB,QAAQ,EAAE;wBACR,IAAI,EAAE;4BACJ,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;4BACpB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;4BACjB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;yBACtB;qBACF;iBACF;gBACD;oBACE,OAAO,EAAE,gBAAU;oBACnB,QAAQ,EAAE;wBACR,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;wBACf,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;wBACtB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;qBAClB;iBACF;gBACD;oBACE,OAAO,EAAE,kBAAW;oBACpB,QAAQ,EAAE;wBACR,IAAI,EAAE,IAAI,CAAC,E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AM,CAAC,CAAC;CAChC"}
|
@@ -9,15 +9,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.
|
12
|
+
exports.WithLocaleDTO = void 0;
|
13
13
|
const class_validator_1 = require("class-validator");
|
14
|
-
class
|
14
|
+
class WithLocaleDTO {
|
15
15
|
}
|
16
|
-
exports.
|
16
|
+
exports.WithLocaleDTO = WithLocaleDTO;
|
17
17
|
__decorate([
|
18
18
|
(0, class_validator_1.IsOptional)(),
|
19
19
|
(0, class_validator_1.IsObject)(),
|
20
20
|
(0, class_validator_1.ValidateNested)({ each: true }),
|
21
21
|
__metadata("design:type", Object)
|
22
|
-
],
|
23
|
-
//# sourceMappingURL=with-
|
22
|
+
], WithLocaleDTO.prototype, "locale", void 0);
|
23
|
+
//# sourceMappingURL=with-locale.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"with-locale.dto.js","sourceRoot":"","sources":["../../src/dto/with-locale.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuE;AAEvE,MAAa,aAAa;CAKzB;AALD,sCAKC;AADC;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;6CACA"}
|
package/dist/index.d.ts
CHANGED
@@ -8,12 +8,12 @@ export * from './role/decorators/role.decorator';
|
|
8
8
|
export * from './role/guards/role.guard';
|
9
9
|
export * from './role/role.service';
|
10
10
|
export * from './screen/screen.service';
|
11
|
-
export * from './setting/
|
11
|
+
export * from './setting/setting.service';
|
12
12
|
export * from './user/constants/user.constants';
|
13
13
|
export * from './user/user.service';
|
14
14
|
export * from './locale/locale.decorator';
|
15
15
|
export * from './locale/locale.service';
|
16
16
|
export * from './dto/delete.dto';
|
17
17
|
export * from './dto/update-ids.dto';
|
18
|
-
export * from './dto/with-
|
18
|
+
export * from './dto/with-locale.dto';
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AAGzC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AAGzC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AAGpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AAExC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
@@ -30,7 +30,7 @@ __exportStar(require("./role/role.service"), exports);
|
|
30
30
|
// Screen Module
|
31
31
|
__exportStar(require("./screen/screen.service"), exports);
|
32
32
|
// Screen Module
|
33
|
-
__exportStar(require("./setting/
|
33
|
+
__exportStar(require("./setting/setting.service"), exports);
|
34
34
|
// User Module
|
35
35
|
__exportStar(require("./user/constants/user.constants"), exports);
|
36
36
|
__exportStar(require("./user/user.service"), exports);
|
@@ -39,5 +39,5 @@ __exportStar(require("./locale/locale.decorator"), exports);
|
|
39
39
|
__exportStar(require("./locale/locale.service"), exports);
|
40
40
|
__exportStar(require("./dto/delete.dto"), exports);
|
41
41
|
__exportStar(require("./dto/update-ids.dto"), exports);
|
42
|
-
__exportStar(require("./dto/with-
|
42
|
+
__exportStar(require("./dto/with-locale.dto"), exports);
|
43
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,eAAe;AACf,iDAA+B;AAE/B,cAAc;AACd,sDAAoC;AACpC,qEAAmD;AACnD,mEAAiD;AACjD,2DAAyC;AAEzC,cAAc;AACd,sDAAoC;AAEpC,oBAAoB;AACpB,mEAAiD;AACjD,2DAAyC;AACzC,sDAAoC;AAEpC,gBAAgB;AAChB,0DAAwC;AAExC,gBAAgB;AAChB,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,eAAe;AACf,iDAA+B;AAE/B,cAAc;AACd,sDAAoC;AACpC,qEAAmD;AACnD,mEAAiD;AACjD,2DAAyC;AAEzC,cAAc;AACd,sDAAoC;AAEpC,oBAAoB;AACpB,mEAAiD;AACjD,2DAAyC;AACzC,sDAAoC;AAEpC,gBAAgB;AAChB,0DAAwC;AAExC,gBAAgB;AAChB,4DAA0C;AAE1C,cAAc;AACd,kEAAgD;AAChD,sDAAoC;AAEpC,gBAAgB;AAChB,4DAA0C;AAC1C,0DAAwC;AAExC,mDAAiC;AACjC,uDAAqC;AACrC,wDAAsC"}
|
@@ -120,7 +120,7 @@ __decorate([
|
|
120
120
|
], LocaleController.prototype, "delete", null);
|
121
121
|
exports.LocaleController = LocaleController = __decorate([
|
122
122
|
(0, role_decorator_1.Role)(),
|
123
|
-
(0, common_1.Controller)('
|
123
|
+
(0, common_1.Controller)('locale'),
|
124
124
|
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => locale_service_1.LocaleService))),
|
125
125
|
__metadata("design:paramtypes", [locale_service_1.LocaleService])
|
126
126
|
], LocaleController);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locale.controller.js","sourceRoot":"","sources":["../../src/locale/locale.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAgD;AAChD,2CAYwB;AACxB,0EAA6D;AAC7D,sEAAyD;AACzD,iDAA6C;AAC7C,iDAA6C;AAC7C,2DAAsD;AACtD,iDAA6C;AAC7C,yDAA4C;AAC5C,qDAAiD;AAI1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,YAEmB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAIE,AAAN,KAAK,CAAC,UAAU,CAAe,gBAAgB,EAAY,MAAc;QACvE,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACjE,CAAC;IAIK,AAAN,KAAK,CAAC,eAAe,CACE,UAAkB,EACnB,SAAiB;QAErC,OAAO,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACnE,CAAC;IAGK,AAAN,KAAK,CAAC,GAAG,CAAe,gBAAgB,EAAY,MAAc;QAChE,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1D,CAAC;IAGK,AAAN,KAAK,CAAC,OAAO,CAA4B,EAAU;QACjD,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC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CAAO,sBAAS;;8CAE7B;AAGK;IADL,IAAA,YAAG,GAAE;IACY,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAY,+BAAa;;kDAEhD;AAGK;IADL,IAAA,cAAK,EAAC,KAAK,CAAC;IACC,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,sBAAS;;8CAK1E;AAGK;IADL,IAAA,eAAM,GAAE;IACK,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,sBAAS;;8CAEnC;2BApDU,gBAAgB;IAF5B,IAAA,qBAAI,GAAE;IACN,IAAA,mBAAU,EAAC,QAAQ,CAAC;IAGhB,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAa,CAAC,CAAC,CAAA;qCACR,8BAAa;GAHpC,gBAAgB,CAqD5B"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { PrismaService } from '@hedhog/prisma';
|
2
2
|
import { NestMiddleware } from '@nestjs/common';
|
3
|
-
import { Request, Response
|
3
|
+
import { NextFunction, Request, Response } from 'express';
|
4
4
|
export declare class LocaleMiddleware implements NestMiddleware {
|
5
5
|
private prisma;
|
6
6
|
private languages;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locale.middleware.d.ts","sourceRoot":"","sources":["../../src/locale/locale.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAc,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"locale.middleware.d.ts","sourceRoot":"","sources":["../../src/locale/locale.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAc,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1D,qBACa,gBAAiB,YAAW,cAAc;IAGzC,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,SAAS,CAAM;gBAEH,MAAM,EAAE,aAAa;IAEnC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY;CAuB3D"}
|
@@ -21,12 +21,12 @@ let LocaleMiddleware = class LocaleMiddleware {
|
|
21
21
|
const locale = req.headers['accept-language'] || 'en-US';
|
22
22
|
let code = locale.split(',')[0].split('-')[0];
|
23
23
|
if (!this.languages.length) {
|
24
|
-
const
|
24
|
+
const locale = await this.prisma.locale.findMany({
|
25
25
|
select: {
|
26
26
|
code: true,
|
27
27
|
},
|
28
28
|
});
|
29
|
-
for (const l of
|
29
|
+
for (const l of locale) {
|
30
30
|
this.languages.push(l.code);
|
31
31
|
}
|
32
32
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locale.middleware.js","sourceRoot":"","sources":["../../src/locale/locale.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA+C;AAC/C,2CAA4D;AAIrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAG3B,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QAFjC,cAAS,GAAG,EAAE,CAAC;IAEqB,CAAC;IAE7C,KAAK,CAAC,GAAG,CAAC,GAAY,EAAE,IAAc,EAAE,IAAkB;QACxD,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC;QACzD,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE9C,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YAC3B,MA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 @@ export declare class LocaleService {
|
|
9
9
|
private codes;
|
10
10
|
constructor(prismaService: PrismaService, paginationService: PaginationService);
|
11
11
|
setEnabled(codes: string[]): Promise<any>;
|
12
|
-
getEnables(
|
12
|
+
getEnables(currentLocale: string, paginationParams: PaginationDTO): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
|
13
13
|
parseLocale(locale: string): {
|
14
14
|
code: string;
|
15
15
|
region: string;
|
16
|
-
|
16
|
+
locale: string[];
|
17
17
|
};
|
18
18
|
getTranslations(localeCode: string, namespace: string): Promise<{}>;
|
19
|
-
get(
|
19
|
+
get(currentLocale: string, paginationParams: PaginationDTO): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
|
20
20
|
getByCode(code: string): Promise<any>;
|
21
|
-
getById(
|
21
|
+
getById(localeId: number): Promise<any>;
|
22
22
|
create(data: CreateDTO): Promise<any>;
|
23
23
|
update({ id, data }: {
|
24
24
|
id: number;
|
@@ -26,7 +26,7 @@ export declare class LocaleService {
|
|
26
26
|
}): Promise<any>;
|
27
27
|
delete({ ids }: DeleteDTO): Promise<any>;
|
28
28
|
private getTableNameTranslations;
|
29
|
-
|
30
|
-
|
29
|
+
createModelWithLocale<T>(modelName: string, foreginKeyName: string, data: T, locale: Record<string, string>): Promise<any>;
|
30
|
+
updateModelWithLocale<T extends any>(modelName: string, foreginKeyName: string, id: number, data: T, locale: Record<string, string>): Promise<any>;
|
31
31
|
}
|
32
32
|
//# sourceMappingURL=locale.service.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locale.service.d.ts","sourceRoot":"","sources":["../../src/locale/locale.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kB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