@serene-dev/la-nest-library 0.0.18 → 0.0.21
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/libs/la-library/src/controllers/base.controller.d.ts +15 -0
- package/dist/libs/la-library/src/controllers/base.controller.js +53 -0
- package/dist/libs/la-library/src/controllers/base.controller.js.map +1 -0
- package/dist/libs/la-library/src/dtos/base.dto.d.ts +1 -0
- package/dist/libs/la-library/src/dtos/base.dto.js +6 -0
- package/dist/libs/la-library/src/dtos/base.dto.js.map +1 -1
- package/dist/libs/la-library/src/dtos/search.dto.d.ts +1 -0
- package/dist/libs/la-library/src/dtos/search.dto.js +3 -3
- package/dist/libs/la-library/src/dtos/search.dto.js.map +1 -1
- package/dist/libs/la-library/src/entities/base.entity.d.ts +2 -2
- package/dist/libs/la-library/src/entities/base.entity.js.map +1 -1
- package/dist/libs/la-library/src/enums/base.enum.d.ts +2 -0
- package/dist/libs/la-library/src/enums/base.enum.js +2 -0
- package/dist/libs/la-library/src/enums/base.enum.js.map +1 -1
- package/dist/libs/la-library/src/index.d.ts +6 -0
- package/dist/libs/la-library/src/index.js +20 -1
- package/dist/libs/la-library/src/index.js.map +1 -1
- package/dist/libs/la-library/src/interfaces/index.interface.d.ts +3 -0
- package/dist/libs/la-library/src/interfaces/index.interface.js +3 -0
- package/dist/libs/la-library/src/interfaces/index.interface.js.map +1 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.controller.d.ts +10 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.controller.js +77 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.controller.js.map +1 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.dto.d.ts +24 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.dto.js +73 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.dto.js.map +1 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.entity.d.ts +16 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.entity.js +65 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.entity.js.map +1 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.enum.d.ts +9 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.enum.js +15 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.enum.js.map +1 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.guard.d.ts +14 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.guard.js +69 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.guard.js.map +1 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.module.d.ts +4 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.module.js +38 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.module.js.map +1 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.service.d.ts +32 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.service.js +142 -0
- package/dist/libs/la-library/src/modules/authentication/authentication.service.js.map +1 -0
- package/dist/libs/la-library/src/modules/logs/logs.controller.d.ts +16 -2
- package/dist/libs/la-library/src/modules/logs/logs.controller.js +47 -8
- package/dist/libs/la-library/src/modules/logs/logs.controller.js.map +1 -1
- package/dist/libs/la-library/src/modules/logs/logs.dto.d.ts +29 -0
- package/dist/libs/la-library/src/modules/logs/logs.dto.js +135 -0
- package/dist/libs/la-library/src/modules/logs/logs.dto.js.map +1 -0
- package/dist/libs/la-library/src/modules/logs/logs.entity.d.ts +7 -7
- package/dist/libs/la-library/src/modules/logs/logs.entity.js +5 -5
- package/dist/libs/la-library/src/modules/logs/logs.entity.js.map +1 -1
- package/dist/libs/la-library/src/modules/logs/logs.module.js +1 -1
- package/dist/libs/la-library/src/modules/logs/logs.module.js.map +1 -1
- package/dist/libs/la-library/src/modules/logs/logs.service.d.ts +6 -2
- package/dist/libs/la-library/src/modules/logs/logs.service.js +22 -1
- package/dist/libs/la-library/src/modules/logs/logs.service.js.map +1 -1
- package/dist/libs/la-library/src/samples/base.sample.d.ts +2 -0
- package/dist/libs/la-library/src/samples/base.sample.js +2 -0
- package/dist/libs/la-library/src/samples/base.sample.js.map +1 -1
- package/dist/libs/la-library/src/services/base.service.d.ts +6 -1
- package/dist/libs/la-library/src/services/base.service.js +14 -0
- package/dist/libs/la-library/src/services/base.service.js.map +1 -1
- package/dist/libs/la-library/src/services/environment.service.d.ts +4 -0
- package/dist/libs/la-library/src/services/environment.service.js +2 -2
- package/dist/libs/la-library/src/services/environment.service.js.map +1 -1
- package/dist/libs/la-library/src/services/file.service.d.ts +3 -1
- package/dist/libs/la-library/src/services/file.service.js +1 -1
- package/dist/libs/la-library/src/services/file.service.js.map +1 -1
- package/dist/libs/la-library/src/services/search.service.js +17 -10
- package/dist/libs/la-library/src/services/search.service.js.map +1 -1
- package/dist/libs/la-library/src/services/token.service.d.ts +6 -2
- package/dist/libs/la-library/src/services/token.service.js +3 -2
- package/dist/libs/la-library/src/services/token.service.js.map +1 -1
- package/dist/libs/la-library/src/services/utility.service.d.ts +4 -1
- package/dist/libs/la-library/src/services/utility.service.js +13 -0
- package/dist/libs/la-library/src/services/utility.service.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PublicAuth = exports.IS_PUBLIC_KEY = exports.AuthenticationGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const token_service_1 = require("../../services/token.service");
|
|
15
|
+
const authentication_service_1 = require("./authentication.service");
|
|
16
|
+
const authentication_enum_1 = require("./authentication.enum");
|
|
17
|
+
const common_2 = require("@nestjs/common");
|
|
18
|
+
const core_1 = require("@nestjs/core");
|
|
19
|
+
const environment_service_1 = require("../../services/environment.service");
|
|
20
|
+
let AuthenticationGuard = class AuthenticationGuard {
|
|
21
|
+
constructor(tokenService, authS, reflector) {
|
|
22
|
+
this.tokenService = tokenService;
|
|
23
|
+
this.authS = authS;
|
|
24
|
+
this.reflector = reflector;
|
|
25
|
+
}
|
|
26
|
+
async canActivate(context) {
|
|
27
|
+
const isPublic = this.reflector.getAllAndOverride(exports.IS_PUBLIC_KEY, [
|
|
28
|
+
context.getHandler(),
|
|
29
|
+
context.getClass(),
|
|
30
|
+
]);
|
|
31
|
+
if (isPublic) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (environment_service_1.evt.ENVIRONMENT == 'dev')
|
|
35
|
+
return true;
|
|
36
|
+
const request = context.switchToHttp().getRequest();
|
|
37
|
+
const token = this.extractTokenFromHeader(request);
|
|
38
|
+
if (!token) {
|
|
39
|
+
throw new common_1.UnauthorizedException();
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const payload = await this.tokenService.decryptToken(token);
|
|
43
|
+
request['user'] = payload;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
this.authS.forceLogoutSingle({
|
|
47
|
+
token,
|
|
48
|
+
logoutReason: authentication_enum_1.ELogOutType.expiration,
|
|
49
|
+
});
|
|
50
|
+
throw new common_1.UnauthorizedException();
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
extractTokenFromHeader(request) {
|
|
55
|
+
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
|
56
|
+
return type === 'Bearer' ? token : undefined;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.AuthenticationGuard = AuthenticationGuard;
|
|
60
|
+
exports.AuthenticationGuard = AuthenticationGuard = __decorate([
|
|
61
|
+
(0, common_1.Injectable)(),
|
|
62
|
+
__metadata("design:paramtypes", [token_service_1.TokenService,
|
|
63
|
+
authentication_service_1.AuthenticationService,
|
|
64
|
+
core_1.Reflector])
|
|
65
|
+
], AuthenticationGuard);
|
|
66
|
+
exports.IS_PUBLIC_KEY = 'isPublic';
|
|
67
|
+
const PublicAuth = () => (0, common_2.SetMetadata)(exports.IS_PUBLIC_KEY, true);
|
|
68
|
+
exports.PublicAuth = PublicAuth;
|
|
69
|
+
//# sourceMappingURL=authentication.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.guard.js","sourceRoot":"","sources":["../../../../../../libs/la-library/src/modules/authentication/authentication.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AAExB,gEAA4D;AAC5D,qEAAiE;AACjE,+DAAoD;AACpD,2CAA6C;AAC7C,uCAAyC;AACzC,4EAAyD;AAGlD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,YACY,YAA0B,EAC1B,KAA4B,EAC9B,SAAoB;QAFlB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,UAAK,GAAL,KAAK,CAAuB;QAC9B,cAAS,GAAT,SAAS,CAAW;IAC3B,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,qBAAa,EAAE;YACxE,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QACH,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CA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0 +1,38 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuthenticationModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const authentication_service_1 = require("./authentication.service");
|
|
12
|
+
const authentication_controller_1 = require("./authentication.controller");
|
|
13
|
+
const authentication_entity_1 = require("./authentication.entity");
|
|
14
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
15
|
+
const token_service_1 = require("../../services/token.service");
|
|
16
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
17
|
+
const authentication_guard_1 = require("./authentication.guard");
|
|
18
|
+
const providers = [
|
|
19
|
+
jwt_1.JwtService,
|
|
20
|
+
token_service_1.TokenService,
|
|
21
|
+
authentication_service_1.AuthenticationService,
|
|
22
|
+
authentication_service_1.AuthenticationSessionService,
|
|
23
|
+
authentication_guard_1.AuthenticationGuard,
|
|
24
|
+
];
|
|
25
|
+
const controllers = [authentication_controller_1.AuthenticationController];
|
|
26
|
+
let AuthenticationModule = class AuthenticationModule {
|
|
27
|
+
};
|
|
28
|
+
exports.AuthenticationModule = AuthenticationModule;
|
|
29
|
+
AuthenticationModule.entities = [authentication_entity_1.AuthEntity, authentication_entity_1.AuthSessionEntity];
|
|
30
|
+
exports.AuthenticationModule = AuthenticationModule = __decorate([
|
|
31
|
+
(0, common_1.Module)({
|
|
32
|
+
imports: [typeorm_1.TypeOrmModule.forFeature(AuthenticationModule.entities)],
|
|
33
|
+
providers,
|
|
34
|
+
controllers,
|
|
35
|
+
exports: [...providers],
|
|
36
|
+
})
|
|
37
|
+
], AuthenticationModule);
|
|
38
|
+
//# sourceMappingURL=authentication.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../../../../libs/la-library/src/modules/authentication/authentication.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qEAGkC;AAClC,2EAAuE;AACvE,mEAAwE;AACxE,6CAAgD;AAChD,gEAA4D;AAC5D,qCAAyC;AACzC,iEAA6D;AAE7D,MAAM,SAAS,GAAG;IAChB,gBAAU;IACV,4BAAY;IACZ,8CAAqB;IACrB,qDAA4B;IAC5B,0CAAmB;CACpB,CAAC;AACF,MAAM,WAAW,GAAG,CAAC,oDAAwB,CAAC,CAAC;AAOxC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;;AAApB,oDAAoB;AACxB,6BAAQ,GAAG,CAAC,kCAAU,EAAE,yCAAiB,CAAC,AAAlC,CAAmC;+BADvC,oBAAoB;IANhC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAClE,SAAS;QACT,WAAW;QACX,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC;KACxB,CAAC;GACW,oBAAoB,CAEhC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseService } from '../../services/base.service';
|
|
2
|
+
import { AuthEntity, AuthSessionEntity } from './authentication.entity';
|
|
3
|
+
import { LoginDTO, LogoutDTO, RegisterDTO, SystemLogoutDTO } from './authentication.dto';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
import { TokenService } from '../../services/token.service';
|
|
6
|
+
import { ELogOutType } from './authentication.enum';
|
|
7
|
+
export declare class AuthenticationSessionService extends BaseService<AuthSessionEntity> {
|
|
8
|
+
protected readonly repo: Repository<AuthSessionEntity>;
|
|
9
|
+
constructor(repo: Repository<AuthSessionEntity>);
|
|
10
|
+
}
|
|
11
|
+
export declare class AuthenticationService extends BaseService<AuthEntity> {
|
|
12
|
+
protected readonly repo: Repository<AuthEntity>;
|
|
13
|
+
protected readonly tokenService: TokenService;
|
|
14
|
+
protected authenticationSessionService: AuthenticationSessionService;
|
|
15
|
+
static path: string;
|
|
16
|
+
readonly saltOrRounds = 10;
|
|
17
|
+
constructor(repo: Repository<AuthEntity>, tokenService: TokenService, authenticationSessionService: AuthenticationSessionService);
|
|
18
|
+
decryptToken(token: string, ignoreExpiration?: boolean): Promise<{
|
|
19
|
+
id: string;
|
|
20
|
+
}>;
|
|
21
|
+
generateToken(auth: AuthEntity): Promise<{
|
|
22
|
+
token: string;
|
|
23
|
+
}>;
|
|
24
|
+
login(body: LoginDTO): Promise<AuthEntity>;
|
|
25
|
+
forceLogout(body: SystemLogoutDTO): Promise<boolean>;
|
|
26
|
+
forceLogoutSingle(body: {
|
|
27
|
+
token: string;
|
|
28
|
+
logoutReason: ELogOutType;
|
|
29
|
+
}): Promise<boolean>;
|
|
30
|
+
logout(body: LogoutDTO): Promise<boolean>;
|
|
31
|
+
register(body: RegisterDTO): Promise<AuthEntity>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
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.AuthenticationService = exports.AuthenticationSessionService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const base_service_1 = require("../../services/base.service");
|
|
18
|
+
const authentication_entity_1 = require("./authentication.entity");
|
|
19
|
+
const base_enum_1 = require("../../enums/base.enum");
|
|
20
|
+
const typeorm_1 = require("typeorm");
|
|
21
|
+
const typeorm_2 = require("@nestjs/typeorm");
|
|
22
|
+
const utility_service_1 = require("../../services/utility.service");
|
|
23
|
+
const bcrypt = require("bcrypt");
|
|
24
|
+
const token_service_1 = require("../../services/token.service");
|
|
25
|
+
const authentication_enum_1 = require("./authentication.enum");
|
|
26
|
+
let AuthenticationSessionService = class AuthenticationSessionService extends base_service_1.BaseService {
|
|
27
|
+
constructor(repo) {
|
|
28
|
+
super(repo, base_enum_1.ETableName.authenticationSession);
|
|
29
|
+
this.repo = repo;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.AuthenticationSessionService = AuthenticationSessionService;
|
|
33
|
+
exports.AuthenticationSessionService = AuthenticationSessionService = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
__param(0, (0, typeorm_2.InjectRepository)(authentication_entity_1.AuthSessionEntity)),
|
|
36
|
+
__metadata("design:paramtypes", [typeorm_1.Repository])
|
|
37
|
+
], AuthenticationSessionService);
|
|
38
|
+
let AuthenticationService = class AuthenticationService extends base_service_1.BaseService {
|
|
39
|
+
constructor(repo, tokenService, authenticationSessionService) {
|
|
40
|
+
super(repo, base_enum_1.ETableName.authentication);
|
|
41
|
+
this.repo = repo;
|
|
42
|
+
this.tokenService = tokenService;
|
|
43
|
+
this.authenticationSessionService = authenticationSessionService;
|
|
44
|
+
this.saltOrRounds = 10;
|
|
45
|
+
}
|
|
46
|
+
decryptToken(token, ignoreExpiration = false) {
|
|
47
|
+
return this.tokenService.decryptToken(token, {
|
|
48
|
+
ignoreExpiration,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
generateToken(auth) {
|
|
52
|
+
return this.tokenService.generateToken({ id: auth.id });
|
|
53
|
+
}
|
|
54
|
+
async login(body) {
|
|
55
|
+
const found = await this.repo.findOneBy({
|
|
56
|
+
orgID: body.orgID,
|
|
57
|
+
email: body.email,
|
|
58
|
+
type: body.type || authentication_enum_1.EAuthType.user,
|
|
59
|
+
});
|
|
60
|
+
if (!found)
|
|
61
|
+
utility_service_1.UtilityClass.throwError({ message: `User doesn't exist` });
|
|
62
|
+
const correct = await bcrypt.compare(body.password, found.password);
|
|
63
|
+
if (!correct)
|
|
64
|
+
throw utility_service_1.UtilityClass.throwError({
|
|
65
|
+
message: `Wrong authentication details. Please check the details`,
|
|
66
|
+
});
|
|
67
|
+
found.token = (await this.generateToken(found)).token;
|
|
68
|
+
delete found.password;
|
|
69
|
+
this.authenticationSessionService.create({
|
|
70
|
+
loginDate: Date.now(),
|
|
71
|
+
token: found.token,
|
|
72
|
+
});
|
|
73
|
+
found.token = `Bearer ${found.token}`;
|
|
74
|
+
return found;
|
|
75
|
+
}
|
|
76
|
+
async forceLogout(body) {
|
|
77
|
+
const found = await this.authenticationSessionService.find({
|
|
78
|
+
ownerID: body.ownerID,
|
|
79
|
+
active: true,
|
|
80
|
+
});
|
|
81
|
+
if (!found?.length)
|
|
82
|
+
return true;
|
|
83
|
+
await Promise.all(found.map((ses) => {
|
|
84
|
+
this.authenticationSessionService.updateByID(ses.id, {
|
|
85
|
+
...body,
|
|
86
|
+
forced: true,
|
|
87
|
+
active: false,
|
|
88
|
+
logoutDate: Date.now(),
|
|
89
|
+
});
|
|
90
|
+
}));
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
async forceLogoutSingle(body) {
|
|
94
|
+
return this.logout({
|
|
95
|
+
...body,
|
|
96
|
+
forced: true,
|
|
97
|
+
logoutReason: body.logoutReason,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async logout(body) {
|
|
101
|
+
const found = await this.authenticationSessionService.findOne({
|
|
102
|
+
token: body.token,
|
|
103
|
+
});
|
|
104
|
+
if (!found)
|
|
105
|
+
return true;
|
|
106
|
+
delete body.token;
|
|
107
|
+
this.authenticationSessionService.updateByID(found.id, {
|
|
108
|
+
...body,
|
|
109
|
+
active: false,
|
|
110
|
+
forced: body.forced || false,
|
|
111
|
+
logoutReason: body.logoutReason || authentication_enum_1.ELogOutType.user,
|
|
112
|
+
logoutDate: Date.now(),
|
|
113
|
+
});
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
async register(body) {
|
|
117
|
+
const auth = Object.assign(new authentication_entity_1.AuthEntity(), body);
|
|
118
|
+
const found = await this.repo.findOneBy({
|
|
119
|
+
orgID: auth.orgID,
|
|
120
|
+
email: auth.email,
|
|
121
|
+
type: auth.type || authentication_enum_1.EAuthType.user,
|
|
122
|
+
});
|
|
123
|
+
if (found)
|
|
124
|
+
utility_service_1.UtilityClass.throwError({ message: `User already exists` });
|
|
125
|
+
const password = await bcrypt.hash(auth.password, this.saltOrRounds);
|
|
126
|
+
const res = await this.repo.save({ ...auth, password });
|
|
127
|
+
if (body.login)
|
|
128
|
+
return this.login(body);
|
|
129
|
+
delete res.password;
|
|
130
|
+
return res;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
exports.AuthenticationService = AuthenticationService;
|
|
134
|
+
AuthenticationService.path = 'authentication';
|
|
135
|
+
exports.AuthenticationService = AuthenticationService = __decorate([
|
|
136
|
+
(0, common_1.Injectable)(),
|
|
137
|
+
__param(0, (0, typeorm_2.InjectRepository)(authentication_entity_1.AuthEntity)),
|
|
138
|
+
__metadata("design:paramtypes", [typeorm_1.Repository,
|
|
139
|
+
token_service_1.TokenService,
|
|
140
|
+
AuthenticationSessionService])
|
|
141
|
+
], AuthenticationService);
|
|
142
|
+
//# sourceMappingURL=authentication.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../../../../libs/la-library/src/modules/authentication/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,8DAA0D;AAC1D,mEAAwE;AAOxE,qDAAmD;AACnD,qCAAqC;AACrC,6CAAmD;AACnD,oEAA8D;AAC9D,iCAAiC;AACjC,gEAA4D;AAC5D,+DAA+D;AAGxD,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,0BAA8B;IAC9E,YAEqB,IAAmC;QAEtD,KAAK,CAAC,IAAI,EAAE,sBAAU,CAAC,qBAAqB,CAAC,CAAC;QAF3B,SAAI,GAAJ,IAAI,CAA+B;IAGxD,CAAC;CACF,CAAA;AAPY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,yCAAiB,CAAC,CAAA;qCACX,oBAAU;GAH1B,4BAA4B,CAOxC;AAGM,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,0BAAuB;IAIhE,YAEE,IAA+C,EAC5B,YAA0B,EACnC,4BAA0D;QAEpE,KAAK,CAAC,IAAI,EAAE,sBAAU,CAAC,cAAc,CAAC,CAAC;QAJpB,SAAI,GAAJ,IAAI,CAAwB;QAC5B,iBAAY,GAAZ,YAAY,CAAc;QACnC,iCAA4B,GAA5B,4BAA4B,CAA8B;QAN7D,iBAAY,GAAG,EAAE,CAAC;IAS3B,CAAC;IAED,YAAY,CAAC,KAAa,EAAE,gBAAgB,GAAG,KAAK;QAClD,OAAO,IAAI,CA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ACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAiB;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,kCAAU,EAAE,EAAE,IAAI,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YACtC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,+BAAS,CAAC,IAAI;SAClC,CAAC,CAAC;QACH,IAAI,KAAK;YAAE,8BAAY,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAErE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxD,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,OAAO,GAAG,CAAC,QAAQ,CAAC;QACpB,OAAO,GAAG,CAAC;IACb,CAAC;;AAzGU,sDAAqB;AACzB,0BAAI,GAAW,gBAAgB,AAA3B,CAA4B;gCAD5B,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,0BAAgB,EAAC,kCAAU,CAAC,CAAA;qCACJ,oBAAU;QACF,4BAAY;QACL,4BAA4B;GAR3D,qBAAqB,CA0GjC"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { BaseController } from '../../controllers/base.controller';
|
|
2
|
+
import { LogEntity } from './logs.entity';
|
|
3
|
+
import { LogsService } from './logs.service';
|
|
4
|
+
import { LogCreateMultipleDTO, LogCreateSingleDTO, LogSerarchDTO } from './logs.dto';
|
|
5
|
+
export declare class LogsController extends BaseController<LogEntity, LogSerarchDTO> {
|
|
6
|
+
protected readonly service: LogsService;
|
|
7
|
+
constructor(service: LogsService);
|
|
8
|
+
create(body: LogCreateSingleDTO): Promise<{
|
|
9
|
+
data: Partial<LogEntity> & import("../..").BaseEntity;
|
|
10
|
+
message: string;
|
|
11
|
+
}>;
|
|
12
|
+
multiple(body: LogCreateMultipleDTO): Promise<{
|
|
13
|
+
data: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
search(query: LogSerarchDTO): Promise<import("../..").ISearchResponse<LogEntity>>;
|
|
3
17
|
}
|
|
@@ -8,24 +8,63 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.LogsController = void 0;
|
|
13
16
|
const common_1 = require("@nestjs/common");
|
|
14
17
|
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const base_controller_1 = require("../../controllers/base.controller");
|
|
19
|
+
const logs_service_1 = require("./logs.service");
|
|
20
|
+
const utility_service_1 = require("../../services/utility.service");
|
|
21
|
+
const logs_dto_1 = require("./logs.dto");
|
|
22
|
+
let LogsController = class LogsController extends base_controller_1.BaseController {
|
|
23
|
+
constructor(service) {
|
|
24
|
+
super(service);
|
|
25
|
+
this.service = service;
|
|
26
|
+
}
|
|
27
|
+
async create(body) {
|
|
28
|
+
return utility_service_1.UtilityClass.handleSuccess({
|
|
29
|
+
data: await this.service.create(body),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async multiple(body) {
|
|
33
|
+
return utility_service_1.UtilityClass.handleSuccess({
|
|
34
|
+
data: await this.service.createMultiple(body),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async search(query) {
|
|
38
|
+
return super.search(query);
|
|
18
39
|
}
|
|
19
40
|
};
|
|
20
41
|
exports.LogsController = LogsController;
|
|
21
42
|
__decorate([
|
|
22
|
-
(0, common_1.
|
|
43
|
+
(0, common_1.Post)('single'),
|
|
44
|
+
__param(0, (0, common_1.Body)()),
|
|
45
|
+
__metadata("design:type", Function),
|
|
46
|
+
__metadata("design:paramtypes", [logs_dto_1.LogCreateSingleDTO]),
|
|
47
|
+
__metadata("design:returntype", Promise)
|
|
48
|
+
], LogsController.prototype, "create", null);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, common_1.Post)(),
|
|
51
|
+
__param(0, (0, common_1.Body)()),
|
|
52
|
+
__metadata("design:type", Function),
|
|
53
|
+
__metadata("design:paramtypes", [logs_dto_1.LogCreateMultipleDTO]),
|
|
54
|
+
__metadata("design:returntype", Promise)
|
|
55
|
+
], LogsController.prototype, "multiple", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, common_1.Get)('search'),
|
|
58
|
+
__param(0, (0, common_1.Query)()),
|
|
23
59
|
__metadata("design:type", Function),
|
|
24
|
-
__metadata("design:paramtypes", []),
|
|
25
|
-
__metadata("design:returntype",
|
|
26
|
-
], LogsController.prototype, "
|
|
60
|
+
__metadata("design:paramtypes", [logs_dto_1.LogSerarchDTO]),
|
|
61
|
+
__metadata("design:returntype", Promise)
|
|
62
|
+
], LogsController.prototype, "search", null);
|
|
27
63
|
exports.LogsController = LogsController = __decorate([
|
|
28
64
|
(0, swagger_1.ApiTags)('Logs'),
|
|
29
|
-
(0, common_1.Controller)(
|
|
65
|
+
(0, common_1.Controller)({
|
|
66
|
+
path: 'logs',
|
|
67
|
+
}),
|
|
68
|
+
__metadata("design:paramtypes", [logs_service_1.LogsService])
|
|
30
69
|
], LogsController);
|
|
31
70
|
//# sourceMappingURL=logs.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.controller.js","sourceRoot":"","sources":["../../../../../../libs/la-library/src/modules/logs/logs.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logs.controller.js","sourceRoot":"","sources":["../../../../../../libs/la-library/src/modules/logs/logs.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoE;AACpE,6CAA0C;AAC1C,uEAAmE;AAEnE,iDAA6C;AAC7C,oEAA8D;AAC9D,yCAIoB;AAOb,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,gCAAwC;IAC1E,YAA+B,OAAoB;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QADc,YAAO,GAAP,OAAO,CAAa;IAEnD,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAAS,IAAwB;QAC3C,OAAO,8BAAY,CAAC,aAAa,CAAC;YAChC,IAAI,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;SACtC,CAAC,CAAC;IACL,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ,CAAS,IAA0B;QAC/C,OAAO,8BAAY,CAAC,aAAa,CAAC;YAChC,IAAI,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC;SAC9C,CAAC,CAAC;IACL,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAAU,KAAoB;QAExC,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AAxBY,wCAAc;AAMnB;IADL,IAAA,aAAI,EAAC,QAAQ,CAAC;IACD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,6BAAkB;;4CAI5C;AAGK;IADL,IAAA,aAAI,GAAE;IACS,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,+BAAoB;;8CAIhD;AAGK;IADL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACA,WAAA,IAAA,cAAK,GAAE,CAAA;;qCAAQ,wBAAa;;4CAGzC;yBAvBU,cAAc;IAL1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC;QAEV,IAAI,EAAE,MAAM;KACb,CAAC;qCAEwC,0BAAW;GADxC,cAAc,CAwB1B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseDto } from '../../dtos/base.dto';
|
|
2
|
+
import { LogEntity } from './logs.entity';
|
|
3
|
+
import { SearchQueryDto } from '../../dtos/search.dto';
|
|
4
|
+
export declare class LogCreateSingleDTO extends BaseDto implements Partial<LogEntity> {
|
|
5
|
+
category: string;
|
|
6
|
+
ipAddress: string;
|
|
7
|
+
macAddress: string;
|
|
8
|
+
message: string;
|
|
9
|
+
meta?: object;
|
|
10
|
+
origin: string;
|
|
11
|
+
refCat: string;
|
|
12
|
+
refNo: string;
|
|
13
|
+
}
|
|
14
|
+
declare class LogCreateForMultipleDTO extends LogCreateSingleDTO implements Partial<LogEntity> {
|
|
15
|
+
createdAt: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class LogCreateMultipleDTO {
|
|
18
|
+
logs: LogCreateForMultipleDTO[];
|
|
19
|
+
}
|
|
20
|
+
export declare class LogSerarchDTO extends SearchQueryDto implements Partial<LogEntity> {
|
|
21
|
+
category: string;
|
|
22
|
+
ipAddress: string;
|
|
23
|
+
macAddress: string;
|
|
24
|
+
message: string;
|
|
25
|
+
origin: string;
|
|
26
|
+
refCat: string;
|
|
27
|
+
refNo: string;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LogSerarchDTO = exports.LogCreateMultipleDTO = exports.LogCreateSingleDTO = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const base_dto_1 = require("../../dtos/base.dto");
|
|
15
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
+
const search_dto_1 = require("../../dtos/search.dto");
|
|
17
|
+
const class_transformer_1 = require("class-transformer");
|
|
18
|
+
class LogCreateSingleDTO extends base_dto_1.BaseDto {
|
|
19
|
+
}
|
|
20
|
+
exports.LogCreateSingleDTO = LogCreateSingleDTO;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsString)(),
|
|
23
|
+
(0, class_validator_1.IsOptional)(),
|
|
24
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], LogCreateSingleDTO.prototype, "category", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsString)(),
|
|
29
|
+
(0, class_validator_1.IsOptional)(),
|
|
30
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], LogCreateSingleDTO.prototype, "ipAddress", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_validator_1.IsString)(),
|
|
35
|
+
(0, class_validator_1.IsOptional)(),
|
|
36
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], LogCreateSingleDTO.prototype, "macAddress", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, class_validator_1.IsString)(),
|
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
|
42
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], LogCreateSingleDTO.prototype, "message", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, class_validator_1.IsObject)(),
|
|
47
|
+
(0, class_validator_1.IsOptional)(),
|
|
48
|
+
(0, swagger_1.ApiProperty)({ type: {}, required: false }),
|
|
49
|
+
__metadata("design:type", Object)
|
|
50
|
+
], LogCreateSingleDTO.prototype, "meta", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, class_validator_1.IsString)(),
|
|
53
|
+
(0, class_validator_1.IsOptional)(),
|
|
54
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], LogCreateSingleDTO.prototype, "origin", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, class_validator_1.IsString)(),
|
|
59
|
+
(0, class_validator_1.IsOptional)(),
|
|
60
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], LogCreateSingleDTO.prototype, "refCat", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, class_validator_1.IsString)(),
|
|
65
|
+
(0, class_validator_1.IsOptional)(),
|
|
66
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], LogCreateSingleDTO.prototype, "refNo", void 0);
|
|
69
|
+
class LogCreateForMultipleDTO extends LogCreateSingleDTO {
|
|
70
|
+
}
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, class_validator_1.IsDateString)(),
|
|
73
|
+
(0, swagger_1.ApiProperty)({ type: Date, required: true }),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], LogCreateForMultipleDTO.prototype, "createdAt", void 0);
|
|
76
|
+
class LogCreateMultipleDTO {
|
|
77
|
+
}
|
|
78
|
+
exports.LogCreateMultipleDTO = LogCreateMultipleDTO;
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, class_validator_1.IsArray)(),
|
|
81
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
82
|
+
(0, class_transformer_1.Type)(() => LogCreateForMultipleDTO),
|
|
83
|
+
(0, swagger_1.ApiProperty)({
|
|
84
|
+
type: LogCreateForMultipleDTO,
|
|
85
|
+
isArray: true,
|
|
86
|
+
required: false,
|
|
87
|
+
}),
|
|
88
|
+
__metadata("design:type", Array)
|
|
89
|
+
], LogCreateMultipleDTO.prototype, "logs", void 0);
|
|
90
|
+
class LogSerarchDTO extends search_dto_1.SearchQueryDto {
|
|
91
|
+
}
|
|
92
|
+
exports.LogSerarchDTO = LogSerarchDTO;
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, class_validator_1.IsString)(),
|
|
95
|
+
(0, class_validator_1.IsOptional)(),
|
|
96
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
97
|
+
__metadata("design:type", String)
|
|
98
|
+
], LogSerarchDTO.prototype, "category", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, class_validator_1.IsString)(),
|
|
101
|
+
(0, class_validator_1.IsOptional)(),
|
|
102
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
103
|
+
__metadata("design:type", String)
|
|
104
|
+
], LogSerarchDTO.prototype, "ipAddress", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, class_validator_1.IsString)(),
|
|
107
|
+
(0, class_validator_1.IsOptional)(),
|
|
108
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
109
|
+
__metadata("design:type", String)
|
|
110
|
+
], LogSerarchDTO.prototype, "macAddress", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, class_validator_1.IsString)(),
|
|
113
|
+
(0, class_validator_1.IsOptional)(),
|
|
114
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
115
|
+
__metadata("design:type", String)
|
|
116
|
+
], LogSerarchDTO.prototype, "message", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, class_validator_1.IsString)(),
|
|
119
|
+
(0, class_validator_1.IsOptional)(),
|
|
120
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
121
|
+
__metadata("design:type", String)
|
|
122
|
+
], LogSerarchDTO.prototype, "origin", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, class_validator_1.IsString)(),
|
|
125
|
+
(0, class_validator_1.IsOptional)(),
|
|
126
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
127
|
+
__metadata("design:type", String)
|
|
128
|
+
], LogSerarchDTO.prototype, "refCat", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
(0, class_validator_1.IsString)(),
|
|
131
|
+
(0, class_validator_1.IsOptional)(),
|
|
132
|
+
(0, swagger_1.ApiProperty)({ type: 'string', required: false }),
|
|
133
|
+
__metadata("design:type", String)
|
|
134
|
+
], LogSerarchDTO.prototype, "refNo", void 0);
|
|
135
|
+
//# sourceMappingURL=logs.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.dto.js","sourceRoot":"","sources":["../../../../../../libs/la-library/src/modules/logs/logs.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAOyB;AACzB,kDAA8C;AAE9C,6CAA8C;AAC9C,sDAAuD;AACvD,yDAAyC;AAEzC,MAAa,kBAAmB,SAAQ,kBAAO;CAiC9C;AA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,qBAAW,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;6CAClC;AAIf;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;6CAClC;AAIf;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;4CACnC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseEntity } from '../../entities/base.entity';
|
|
2
2
|
export declare class LogEntity extends BaseEntity {
|
|
3
|
-
refCat
|
|
4
|
-
refNo
|
|
5
|
-
message
|
|
6
|
-
category
|
|
7
|
-
ipAddress
|
|
8
|
-
macAddress
|
|
9
|
-
origin
|
|
3
|
+
refCat?: string;
|
|
4
|
+
refNo?: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
category?: string;
|
|
7
|
+
ipAddress?: string;
|
|
8
|
+
macAddress?: string;
|
|
9
|
+
origin?: string;
|
|
10
10
|
}
|
|
@@ -25,23 +25,23 @@ __decorate([
|
|
|
25
25
|
__metadata("design:type", String)
|
|
26
26
|
], LogEntity.prototype, "refNo", void 0);
|
|
27
27
|
__decorate([
|
|
28
|
-
(0, typeorm_1.Column)({ type: 'text' }),
|
|
28
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
29
29
|
__metadata("design:type", String)
|
|
30
30
|
], LogEntity.prototype, "message", void 0);
|
|
31
31
|
__decorate([
|
|
32
|
-
(0, typeorm_1.Column)({ type: 'text' }),
|
|
32
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
33
33
|
__metadata("design:type", String)
|
|
34
34
|
], LogEntity.prototype, "category", void 0);
|
|
35
35
|
__decorate([
|
|
36
|
-
(0, typeorm_1.Column)({ type: 'text' }),
|
|
36
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
37
37
|
__metadata("design:type", String)
|
|
38
38
|
], LogEntity.prototype, "ipAddress", void 0);
|
|
39
39
|
__decorate([
|
|
40
|
-
(0, typeorm_1.Column)({ type: 'text' }),
|
|
40
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
41
41
|
__metadata("design:type", String)
|
|
42
42
|
], LogEntity.prototype, "macAddress", void 0);
|
|
43
43
|
__decorate([
|
|
44
|
-
(0, typeorm_1.Column)({ type: 'text' }),
|
|
44
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
45
45
|
__metadata("design:type", String)
|
|
46
46
|
], LogEntity.prototype, "origin", void 0);
|
|
47
47
|
exports.LogEntity = LogEntity = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.entity.js","sourceRoot":"","sources":["../../../../../../libs/la-library/src/modules/logs/logs.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyC;AACzC,qDAAmD;AACnD,4DAAwD;AAGjD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAAU;CAqBxC,CAAA;AArBY,8BAAS;AAEpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;
|
|
1
|
+
{"version":3,"file":"logs.entity.js","sourceRoot":"","sources":["../../../../../../libs/la-library/src/modules/logs/logs.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyC;AACzC,qDAAmD;AACnD,4DAAwD;AAGjD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAAU;CAqBxC,CAAA;AArBY,8BAAS;AAEpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACzB;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCAC1B;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACxB;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACvB;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACtB;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACrB;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACzB;oBApBL,SAAS;IADrB,IAAA,gBAAM,EAAC,sBAAU,CAAC,IAAI,CAAC;GACX,SAAS,CAqBrB"}
|
|
@@ -20,7 +20,7 @@ exports.LogsModule = LogsModule;
|
|
|
20
20
|
LogsModule.entities = [logs_entity_1.LogEntity];
|
|
21
21
|
exports.LogsModule = LogsModule = __decorate([
|
|
22
22
|
(0, common_1.Module)({
|
|
23
|
-
imports: [typeorm_1.TypeOrmModule.forFeature(
|
|
23
|
+
imports: [typeorm_1.TypeOrmModule.forFeature(LogsModule.entities)],
|
|
24
24
|
providers,
|
|
25
25
|
controllers,
|
|
26
26
|
exports: [...providers],
|