dl-commons 0.1.2 → 0.1.4
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/factories/exception.factory.js +9 -1
- package/dist/factories/exception.factory.js.map +1 -1
- package/dist/services/iam.service.d.ts +1 -0
- package/dist/services/iam.service.js +5 -4
- package/dist/services/iam.service.js.map +1 -1
- package/dist/services/sessions.service.d.ts +1 -0
- package/dist/services/sessions.service.js +4 -3
- package/dist/services/sessions.service.js.map +1 -1
- package/dist/services/smtp.service.d.ts +1 -0
- package/dist/services/smtp.service.js +3 -2
- package/dist/services/smtp.service.js.map +1 -1
- package/package.json +7 -6
|
@@ -4,10 +4,18 @@ exports.validationExceptionFactory = validationExceptionFactory;
|
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const custom_exception_1 = require("../exceptions/custom.exception");
|
|
6
6
|
const rest_wrapper_class_1 = require("../models/dtos/wrappers/rest-wrapper.class");
|
|
7
|
+
function sanitize(error) {
|
|
8
|
+
var _a;
|
|
9
|
+
return {
|
|
10
|
+
property: error.property,
|
|
11
|
+
constraints: error.constraints,
|
|
12
|
+
children: ((_a = error.children) === null || _a === void 0 ? void 0 : _a.length) ? error.children.map(sanitize) : error.children,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
7
15
|
function validationExceptionFactory(_errors) {
|
|
8
16
|
const error = new rest_wrapper_class_1.RESTError('data_validation');
|
|
9
17
|
_errors.forEach((i) => {
|
|
10
|
-
error.validation = i;
|
|
18
|
+
error.validation = sanitize(i);
|
|
11
19
|
});
|
|
12
20
|
return new custom_exception_1.HandledException([error], common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
13
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.factory.js","sourceRoot":"","sources":["../../src/factories/exception.factory.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"exception.factory.js","sourceRoot":"","sources":["../../src/factories/exception.factory.ts"],"names":[],"mappings":";;AA+BS,gEAA0B;AA/BnC,2CAA4C;AAE5C,qEAAkE;AAClE,mFAAuE;AAQvE,SAAS,QAAQ,CAAC,KAAsB;;IACpC,OAAO;QACH,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,QAAQ,EAAE,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,EAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ;KACnF,CAAC;AACN,CAAC;AAED,SAAS,0BAA0B,CAAC,OAA0B;IAC1D,MAAM,KAAK,GAAG,IAAI,8BAAS,CAAC,iBAAiB,CAAC,CAAC;IAK/C,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAClB,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,mCAAgB,CAAC,CAAC,KAAK,CAAC,EAAE,mBAAU,CAAC,oBAAoB,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -8,6 +8,7 @@ export declare class IAMService {
|
|
|
8
8
|
private readonly _httpService;
|
|
9
9
|
private readonly _configService;
|
|
10
10
|
private _baseUrl;
|
|
11
|
+
private _accessToken;
|
|
11
12
|
constructor(_httpService: HttpService, _configService: ConfigService);
|
|
12
13
|
list(firstName: string, lastName: string, types: UserType[], verificationLevels: UserVerificationLevel[]): Promise<RESTResult<IUser[]>>;
|
|
13
14
|
read(id: string): Promise<RESTResult<IUser>>;
|
|
@@ -20,6 +20,7 @@ let IAMService = class IAMService {
|
|
|
20
20
|
this._httpService = _httpService;
|
|
21
21
|
this._configService = _configService;
|
|
22
22
|
this._baseUrl = this._configService.getOrThrow('DL_IAM__REST__BASE_URL');
|
|
23
|
+
this._accessToken = this._configService.get('APP__ACCESS_TOKEN');
|
|
23
24
|
}
|
|
24
25
|
async list(firstName, lastName, types, verificationLevels) {
|
|
25
26
|
try {
|
|
@@ -38,7 +39,7 @@ let IAMService = class IAMService {
|
|
|
38
39
|
}
|
|
39
40
|
const qs = queryParams.toString();
|
|
40
41
|
const endpoint = `${this._baseUrl}/v1/users?${qs}`;
|
|
41
|
-
const response$ = this._httpService.get(endpoint);
|
|
42
|
+
const response$ = this._httpService.get(endpoint, { headers: { 'x-access-token': this._accessToken } });
|
|
42
43
|
const response = await (0, rxjs_1.firstValueFrom)(response$);
|
|
43
44
|
if (response.data.errors) {
|
|
44
45
|
throw new rest_wrapper_class_1.RESTError('iam_api_error', response.data.errors);
|
|
@@ -55,7 +56,7 @@ let IAMService = class IAMService {
|
|
|
55
56
|
async read(id) {
|
|
56
57
|
try {
|
|
57
58
|
const endpoint = `${this._baseUrl}/v1/users/${id}`;
|
|
58
|
-
const response$ = this._httpService.get(endpoint);
|
|
59
|
+
const response$ = this._httpService.get(endpoint, { headers: { 'x-access-token': this._accessToken } });
|
|
59
60
|
const response = await (0, rxjs_1.firstValueFrom)(response$);
|
|
60
61
|
if (response.data.errors) {
|
|
61
62
|
throw new rest_wrapper_class_1.RESTError('iam_api_error', response.data.errors);
|
|
@@ -72,7 +73,7 @@ let IAMService = class IAMService {
|
|
|
72
73
|
async listByRoleKeyword(keyword) {
|
|
73
74
|
try {
|
|
74
75
|
const endpoint = `${this._baseUrl}/v1/users/by-role-keyword/${keyword}`;
|
|
75
|
-
const response$ = this._httpService.get(endpoint);
|
|
76
|
+
const response$ = this._httpService.get(endpoint, { headers: { 'x-access-token': this._accessToken } });
|
|
76
77
|
const response = await (0, rxjs_1.firstValueFrom)(response$);
|
|
77
78
|
if (response.data.errors) {
|
|
78
79
|
throw new rest_wrapper_class_1.RESTError('iam_api_error', response.data.errors);
|
|
@@ -89,7 +90,7 @@ let IAMService = class IAMService {
|
|
|
89
90
|
async fetchUsername(id) {
|
|
90
91
|
try {
|
|
91
92
|
const endpoint = `${this._baseUrl}/v1/users/${id}/username`;
|
|
92
|
-
const response$ = this._httpService.get(endpoint);
|
|
93
|
+
const response$ = this._httpService.get(endpoint, { headers: { 'x-access-token': this._accessToken } });
|
|
93
94
|
const response = await (0, rxjs_1.firstValueFrom)(response$);
|
|
94
95
|
if (response.data.errors) {
|
|
95
96
|
throw new rest_wrapper_class_1.RESTError('iam_api_error', response.data.errors);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iam.service.js","sourceRoot":"","sources":["../../src/services/iam.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAA4C;AAC5C,2CAA+C;AAC/C,mFAAqG;AACrG,+BAAsC;AAM/B,IAAM,UAAU,GAAhB,MAAM,UAAU;
|
|
1
|
+
{"version":3,"file":"iam.service.js","sourceRoot":"","sources":["../../src/services/iam.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAA4C;AAC5C,2CAA+C;AAC/C,mFAAqG;AACrG,+BAAsC;AAM/B,IAAM,UAAU,GAAhB,MAAM,UAAU;IAOnB,YAA6B,YAAyB,EAAmB,cAA6B;QAAzE,iBAAY,GAAZ,YAAY,CAAa;QAAmB,mBAAc,GAAd,cAAc,CAAe;QAClG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;QAKzE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACrE,CAAC;IAIM,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,QAAgB,EAAE,KAAiB,EAAE,kBAA2C;QACjH,IAAI,CAAC;YACD,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;YAC1C,IAAI,SAAS,EAAE,CAAC;gBACZ,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;YAC/C,CAAC;YAED,I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,CAAC,CAAC;YAC/D,CAAC;YAED,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBACxE,MAAM,IAAI,8BAAS,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;YAC3D,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC9C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,MAAM,8BAAS,CAAC,eAAe,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;IACL,CAAC;CAEJ,CAAA;AArHY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAQkC,mBAAW,EAAmC,sBAAa;GAP7F,UAAU,CAqHtB"}
|
|
@@ -9,6 +9,7 @@ export declare class SessionsService {
|
|
|
9
9
|
private readonly _httpService;
|
|
10
10
|
private readonly _configService;
|
|
11
11
|
private _baseUrl;
|
|
12
|
+
private _accessToken;
|
|
12
13
|
constructor(_sessionModel: Model<SessionDocument>, _httpService: HttpService, _configService: ConfigService);
|
|
13
14
|
create(userId: string | Types.ObjectId, userAgent: string, ip: string): Promise<ISession>;
|
|
14
15
|
read(token: string): Promise<ISession>;
|
|
@@ -27,11 +27,12 @@ let SessionsService = class SessionsService {
|
|
|
27
27
|
this._httpService = _httpService;
|
|
28
28
|
this._configService = _configService;
|
|
29
29
|
this._baseUrl = this._configService.getOrThrow('DL_SESSIONS__REST__BASE_URL');
|
|
30
|
+
this._accessToken = this._configService.get('APP__ACCESS_TOKEN');
|
|
30
31
|
}
|
|
31
32
|
async create(userId, userAgent, ip) {
|
|
32
33
|
try {
|
|
33
34
|
const endpoint = `${this._baseUrl}/v1/sessions/${userId}`;
|
|
34
|
-
const headers = { 'user-agent': userAgent, 'x-ip': ip };
|
|
35
|
+
const headers = { 'user-agent': userAgent, 'x-ip': ip, 'x-access-token': this._accessToken };
|
|
35
36
|
const response$ = this._httpService.post(endpoint, null, { headers });
|
|
36
37
|
const response = await (0, rxjs_1.firstValueFrom)(response$);
|
|
37
38
|
if (response.data.errors) {
|
|
@@ -59,7 +60,7 @@ let SessionsService = class SessionsService {
|
|
|
59
60
|
async fetchAllById(id) {
|
|
60
61
|
try {
|
|
61
62
|
const endpoint = `${this._baseUrl}/v1/sessions/${id}/all`;
|
|
62
|
-
const response$ = this._httpService.get(endpoint);
|
|
63
|
+
const response$ = this._httpService.get(endpoint, { headers: { 'x-access-token': this._accessToken } });
|
|
63
64
|
const response = await (0, rxjs_1.firstValueFrom)(response$);
|
|
64
65
|
if (response.data.errors) {
|
|
65
66
|
throw new rest_wrapper_class_1.RESTError('sessions_api_error', response.data.errors);
|
|
@@ -76,7 +77,7 @@ let SessionsService = class SessionsService {
|
|
|
76
77
|
async fetchAllByUserId(id) {
|
|
77
78
|
try {
|
|
78
79
|
const endpoint = `${this._baseUrl}/v1/sessions/users/${id}/all`;
|
|
79
|
-
const response$ = this._httpService.get(endpoint);
|
|
80
|
+
const response$ = this._httpService.get(endpoint, { headers: { 'x-access-token': this._accessToken } });
|
|
80
81
|
const response = await (0, rxjs_1.firstValueFrom)(response$);
|
|
81
82
|
if (response.data.errors) {
|
|
82
83
|
throw new rest_wrapper_class_1.RESTError('sessions_api_error', response.data.errors);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.service.js","sourceRoot":"","sources":["../../src/services/sessions.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAAmE;AACnE,2CAA+C;AAC/C,mFAAyF;AAEzF,+BAAsC;AACtC,uCAAiC;AACjC,qEAA4E;AAC5E,+CAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;
|
|
1
|
+
{"version":3,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AC,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,4BAA4B,CAAC,MAAc;QACpD,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;CAEJ,CAAA;AA9FY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IASJ,WAAA,IAAA,sBAAW,EAAC,wBAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;qCACZ,gBAAK;QACN,mBAAW;QACT,sBAAa;GAXzC,eAAe,CA8F3B"}
|
|
@@ -5,6 +5,7 @@ export declare class SMTPService {
|
|
|
5
5
|
private readonly _httpService;
|
|
6
6
|
private readonly _configService;
|
|
7
7
|
private _baseUrl;
|
|
8
|
+
private _accessToken;
|
|
8
9
|
constructor(_httpService: HttpService, _configService: ConfigService);
|
|
9
10
|
send(subject: string, from: string, to: string, html: string, profileId: string): Promise<ISMTP>;
|
|
10
11
|
send$(subject: string, from: string, to: string, html: string, profileId: string): import("rxjs").Observable<ISMTP>;
|
|
@@ -20,6 +20,7 @@ let SMTPService = class SMTPService {
|
|
|
20
20
|
this._httpService = _httpService;
|
|
21
21
|
this._configService = _configService;
|
|
22
22
|
this._baseUrl = this._configService.getOrThrow('DL_SMTP__REST__BASE_URL');
|
|
23
|
+
this._accessToken = this._configService.get('APP__ACCESS_TOKEN');
|
|
23
24
|
}
|
|
24
25
|
async send(subject, from, to, html, profileId) {
|
|
25
26
|
const requestBody = {
|
|
@@ -30,7 +31,7 @@ let SMTPService = class SMTPService {
|
|
|
30
31
|
html,
|
|
31
32
|
},
|
|
32
33
|
};
|
|
33
|
-
const response$ = this._httpService.post(`${this._baseUrl}/v1/emails/send`, requestBody, { params: { profileId } });
|
|
34
|
+
const response$ = this._httpService.post(`${this._baseUrl}/v1/emails/send`, requestBody, { params: { profileId }, headers: { 'x-access-token': this._accessToken } });
|
|
34
35
|
const response = await (0, rxjs_1.firstValueFrom)(response$);
|
|
35
36
|
if (response.data.errors) {
|
|
36
37
|
throw new rest_wrapper_class_1.RESTError('smtp_api_error', response.data.errors);
|
|
@@ -49,7 +50,7 @@ let SMTPService = class SMTPService {
|
|
|
49
50
|
html,
|
|
50
51
|
},
|
|
51
52
|
};
|
|
52
|
-
const response$ = this._httpService.post(`${this._baseUrl}/v1/emails/send`, requestBody, { params: { profileId } });
|
|
53
|
+
const response$ = this._httpService.post(`${this._baseUrl}/v1/emails/send`, requestBody, { params: { profileId }, headers: { 'x-access-token': this._accessToken } });
|
|
53
54
|
return response$.pipe((0, rxjs_1.map)((response) => {
|
|
54
55
|
if (response.data.errors) {
|
|
55
56
|
throw new rest_wrapper_class_1.RESTError('smtp_api_error', response.data.errors);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smtp.service.js","sourceRoot":"","sources":["../../src/services/smtp.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAA+C;AAC/C,+BAAuD;AACvD,2CAA4C;AAC5C,mFAAyF;AAIlF,IAAM,WAAW,GAAjB,MAAM,WAAW;
|
|
1
|
+
{"version":3,"file":"smtp.service.js","sourceRoot":"","sources":["../../src/services/smtp.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAA+C;AAC/C,+BAAuD;AACvD,2CAA4C;AAC5C,mFAAyF;AAIlF,IAAM,WAAW,GAAjB,MAAM,WAAW;IAOpB,YAA6B,YAAyB,EAAmB,cAA6B;QAAzE,iBAAY,GAAZ,YAAY,CAAa;QAAmB,mBAAc,GAAd,cAAc,CAAe;QAClG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC;QAI1E,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,GAA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,IAAI,CAAC,QAAQ,iBAAiB,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC/L,OAAO,SAAS,CAAC,IAAI,CACjB,IAAA,UAAG,EAAC,CAAC,QAAQ,EAAE,EAAE;YACb,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACvB,MAAM,IAAI,8BAAS,CAAC,gBAAgB,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAChE,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC1C,MAAM,IAAI,8BAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;YAC5D,CAAC;YACD,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACrC,CAAC,CAAC,EACF,IAAA,iBAAU,EAAC,CAAC,CAAC,EAAE,EAAE;YACb,MAAM,IAAI,8BAAS,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CACL,CAAC;IACN,CAAC;CAEJ,CAAA;AAnEY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAQkC,mBAAW,EAAmC,sBAAa;GAP7F,WAAW,CAmEvB"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dl-commons",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "distance learning commons",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
|
-
],
|
|
10
|
+
],
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=20.19.0"
|
|
13
13
|
},
|
|
@@ -46,17 +46,18 @@
|
|
|
46
46
|
"@nestjs/mongoose": "^10.1.0",
|
|
47
47
|
"@types/express": "^4.17.25",
|
|
48
48
|
"@types/node": "^20.19.43",
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
50
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
51
49
|
"axios": "^1.7.2",
|
|
52
50
|
"bson": "^6.10.4",
|
|
53
51
|
"class-transformer": "^0.5.1",
|
|
54
52
|
"class-validator": "^0.14.4",
|
|
55
|
-
"eslint": "^8.
|
|
53
|
+
"eslint": "^10.8.0",
|
|
54
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
56
55
|
"express": "^4.18.2",
|
|
56
|
+
"globals": "^17.9.0",
|
|
57
57
|
"mongoose": "^8.24.2",
|
|
58
58
|
"reflect-metadata": "^0.2.2",
|
|
59
59
|
"rxjs": "^7.8.1",
|
|
60
|
-
"typescript": "^5.9.3"
|
|
60
|
+
"typescript": "^5.9.3",
|
|
61
|
+
"typescript-eslint": "^8.66.0"
|
|
61
62
|
}
|
|
62
63
|
}
|