@lenne.tech/nest-server 8.6.8 → 8.6.9
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/core/common/decorators/graphql-user.decorator.js +2 -3
- package/dist/core/common/decorators/graphql-user.decorator.js.map +1 -1
- package/dist/core/common/decorators/restricted.decorator.js +14 -13
- package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
- package/dist/core/common/helpers/context.helper.js +4 -5
- package/dist/core/common/helpers/context.helper.js.map +1 -1
- package/dist/core/common/helpers/db.helper.js +32 -21
- package/dist/core/common/helpers/db.helper.js.map +1 -1
- package/dist/core/common/helpers/file.helper.js +5 -1
- package/dist/core/common/helpers/file.helper.js.map +1 -1
- package/dist/core/common/helpers/filter.helper.js +16 -9
- package/dist/core/common/helpers/filter.helper.js.map +1 -1
- package/dist/core/common/helpers/graphql.helper.js +11 -8
- package/dist/core/common/helpers/graphql.helper.js.map +1 -1
- package/dist/core/common/helpers/input.helper.js +17 -11
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/helpers/model.helper.d.ts +2 -0
- package/dist/core/common/helpers/model.helper.js +125 -3
- package/dist/core/common/helpers/model.helper.js.map +1 -1
- package/dist/core/common/helpers/service.helper.js +27 -13
- package/dist/core/common/helpers/service.helper.js.map +1 -1
- package/dist/core/common/inputs/core-input.input.js +6 -1
- package/dist/core/common/inputs/core-input.input.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.d.ts +1 -0
- package/dist/core/common/inputs/single-filter.input.js +8 -0
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/common/models/core-model.model.js +14 -2
- package/dist/core/common/models/core-model.model.js.map +1 -1
- package/dist/core/common/pipes/check-input.pipe.js +1 -1
- package/dist/core/common/pipes/check-input.pipe.js.map +1 -1
- package/dist/core/common/pipes/map-and-validate.pipe.js +2 -2
- package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
- package/dist/core/common/services/crud.service.js +3 -5
- package/dist/core/common/services/crud.service.js.map +1 -1
- package/dist/core/common/services/email.service.js +5 -1
- package/dist/core/common/services/email.service.js.map +1 -1
- package/dist/core/common/services/mailjet.service.js +8 -1
- package/dist/core/common/services/mailjet.service.js.map +1 -1
- package/dist/core/common/services/module.service.js +29 -7
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/core/modules/auth/core-auth.module.js +2 -2
- package/dist/core/modules/auth/core-auth.module.js.map +1 -1
- package/dist/core/modules/auth/guards/auth.guard.js +4 -5
- package/dist/core/modules/auth/guards/auth.guard.js.map +1 -1
- package/dist/core/modules/auth/guards/roles.guard.js +1 -2
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/file/core-file.service.d.ts +26 -0
- package/dist/core/modules/file/core-file.service.js +116 -0
- package/dist/core/modules/file/core-file.service.js.map +1 -0
- package/dist/core/modules/file/file-info.output.d.ts +10 -0
- package/dist/core/modules/file/file-info.output.js +49 -0
- package/dist/core/modules/file/file-info.output.js.map +1 -0
- package/dist/core/modules/file/interfaces/file-service-options.interface.d.ts +7 -0
- package/dist/core/modules/file/interfaces/file-service-options.interface.js +3 -0
- package/dist/core/modules/file/interfaces/file-service-options.interface.js.map +1 -0
- package/dist/core/modules/file/interfaces/file-upload.interface.d.ts +13 -0
- package/dist/core/modules/file/interfaces/file-upload.interface.js +3 -0
- package/dist/core/modules/file/interfaces/file-upload.interface.js.map +1 -0
- package/dist/core/modules/user/core-user.service.js +7 -3
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/core.module.js +32 -37
- package/dist/core.module.js.map +1 -1
- package/dist/server/modules/auth/auth.module.js +4 -1
- package/dist/server/modules/auth/auth.module.js.map +1 -1
- package/dist/server/modules/file/file.controller.d.ts +6 -1
- package/dist/server/modules/file/file.controller.js +33 -3
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/modules/file/file.resolver.d.ts +8 -2
- package/dist/server/modules/file/file.resolver.js +43 -6
- package/dist/server/modules/file/file.resolver.js.map +1 -1
- package/dist/server/modules/file/file.service.d.ts +6 -0
- package/dist/server/modules/file/file.service.js +32 -0
- package/dist/server/modules/file/file.service.js.map +1 -0
- package/dist/server/modules/user/user.model.d.ts +1 -0
- package/dist/server/modules/user/user.model.js +5 -0
- package/dist/server/modules/user/user.model.js.map +1 -1
- package/dist/server/modules/user/user.resolver.js +1 -2
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/server/modules/user/user.service.js +2 -2
- package/dist/server/modules/user/user.service.js.map +1 -1
- package/dist/server/server.module.js +2 -1
- package/dist/server/server.module.js.map +1 -1
- package/dist/test/test.helper.d.ts +21 -1
- package/dist/test/test.helper.js +99 -12
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/core/common/helpers/db.helper.ts +2 -0
- package/src/core/common/helpers/filter.helper.ts +7 -1
- package/src/core/common/helpers/model.helper.ts +152 -0
- package/src/core/common/inputs/single-filter.input.ts +10 -1
- package/src/core/common/services/module.service.ts +1 -1
- package/src/core/modules/file/core-file.service.ts +179 -0
- package/src/core/modules/file/file-info.output.ts +26 -0
- package/src/core/modules/file/interfaces/file-service-options.interface.ts +7 -0
- package/src/core/modules/file/interfaces/file-upload.interface.ts +38 -0
- package/src/server/modules/file/file.controller.ts +42 -3
- package/src/server/modules/file/file.resolver.ts +57 -33
- package/src/server/modules/file/file.service.ts +11 -0
- package/src/server/modules/user/user.model.ts +9 -0
- package/src/server/server.module.ts +2 -1
- package/src/test/test.helper.ts +122 -6
|
@@ -20,7 +20,10 @@ let AuthModule = AuthModule_1 = class AuthModule {
|
|
|
20
20
|
return {
|
|
21
21
|
module: AuthModule_1,
|
|
22
22
|
imports: [
|
|
23
|
-
core_auth_module_1.CoreAuthModule.forRoot(user_module_1.UserModule, user_service_1.UserService,
|
|
23
|
+
core_auth_module_1.CoreAuthModule.forRoot(user_module_1.UserModule, user_service_1.UserService, {
|
|
24
|
+
...options,
|
|
25
|
+
...{},
|
|
26
|
+
}),
|
|
24
27
|
],
|
|
25
28
|
providers: [auth_resolver_1.AuthResolver, auth_service_1.AuthService, email_service_1.EmailService],
|
|
26
29
|
exports: [auth_resolver_1.AuthResolver, core_auth_module_1.CoreAuthModule],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../../src/server/modules/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AAEvD,+EAA2E;AAC3E,kFAA6E;AAC7E,qDAAiD;AACjD,uDAAmD;AACnD,mDAA+C;AAC/C,iDAA6C;AAM7C,IAAa,UAAU,kBAAvB,MAAa,UAAU;IAKrB,MAAM,CAAC,OAAO,CAAC,OAAyB;QACtC,OAAO;YACL,MAAM,EAAE,YAAU;YAClB,OAAO,EAAE;gBACP,iCAAc,CAAC,OAAO,CAAC,wBAAU,EAAE,0BAAW,
|
|
1
|
+
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../../src/server/modules/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AAEvD,+EAA2E;AAC3E,kFAA6E;AAC7E,qDAAiD;AACjD,uDAAmD;AACnD,mDAA+C;AAC/C,iDAA6C;AAM7C,IAAa,UAAU,kBAAvB,MAAa,UAAU;IAKrB,MAAM,CAAC,OAAO,CAAC,OAAyB;QACtC,OAAO;YACL,MAAM,EAAE,YAAU;YAClB,OAAO,EAAE;gBACP,iCAAc,CAAC,OAAO,CAAC,wBAAU,EAAE,0BAAW,EAAE;oBAC9C,GAAG,OAAO;oBACV,GAAG,EAGF;iBACF,CAAC;aACH;YACD,SAAS,EAAE,CAAC,4BAAY,EAAE,0BAAW,EAAE,4BAAY,CAAC;YACpD,OAAO,EAAE,CAAC,4BAAY,EAAE,iCAAc,CAAC;SACxC,CAAC;IACJ,CAAC;CACF,CAAA;AArBY,UAAU;IADtB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAAU,CAqBtB;AArBY,gCAAU"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { User } from '../user/user.model';
|
|
2
|
+
import { FileService } from './file.service';
|
|
1
3
|
export declare class FileController {
|
|
2
|
-
|
|
4
|
+
protected fileService: FileService;
|
|
5
|
+
constructor(fileService: FileService);
|
|
6
|
+
uploadFiles(files: any, fields: any): void;
|
|
7
|
+
getFile(filename: string, res: any, user: User): Promise<any>;
|
|
3
8
|
}
|
|
@@ -17,13 +17,32 @@ const common_1 = require("@nestjs/common");
|
|
|
17
17
|
const platform_express_1 = require("@nestjs/platform-express");
|
|
18
18
|
const multer_1 = require("multer");
|
|
19
19
|
const config_env_1 = require("../../../config.env");
|
|
20
|
+
const rest_user_decorator_1 = require("../../../core/common/decorators/rest-user.decorator");
|
|
20
21
|
const roles_decorator_1 = require("../../../core/common/decorators/roles.decorator");
|
|
21
22
|
const role_enum_1 = require("../../../core/common/enums/role.enum");
|
|
22
23
|
const file_helper_1 = require("../../../core/common/helpers/file.helper");
|
|
24
|
+
const user_model_1 = require("../user/user.model");
|
|
25
|
+
const file_service_1 = require("./file.service");
|
|
23
26
|
let FileController = class FileController {
|
|
24
|
-
|
|
27
|
+
constructor(fileService) {
|
|
28
|
+
this.fileService = fileService;
|
|
29
|
+
}
|
|
30
|
+
uploadFiles(files, fields) {
|
|
25
31
|
console.log(JSON.stringify({ files, fields }, null, 2));
|
|
26
32
|
}
|
|
33
|
+
async getFile(filename, res, user) {
|
|
34
|
+
if (!filename) {
|
|
35
|
+
throw new common_1.BadRequestException('Missing filename for download');
|
|
36
|
+
}
|
|
37
|
+
const file = await this.fileService.getFileInfoByName(filename);
|
|
38
|
+
if (!file) {
|
|
39
|
+
throw new common_1.NotFoundException('File not found');
|
|
40
|
+
}
|
|
41
|
+
const filestream = await this.fileService.getFileStream(file.id);
|
|
42
|
+
res.header('Content-Type', file.contentType);
|
|
43
|
+
res.header('Content-Disposition', 'attachment; filename=' + file.filename);
|
|
44
|
+
return filestream.pipe(res);
|
|
45
|
+
}
|
|
27
46
|
};
|
|
28
47
|
__decorate([
|
|
29
48
|
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.ADMIN),
|
|
@@ -39,9 +58,20 @@ __decorate([
|
|
|
39
58
|
__metadata("design:type", Function),
|
|
40
59
|
__metadata("design:paramtypes", [Object, Object]),
|
|
41
60
|
__metadata("design:returntype", void 0)
|
|
42
|
-
], FileController.prototype, "
|
|
61
|
+
], FileController.prototype, "uploadFiles", null);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.ADMIN),
|
|
64
|
+
(0, common_1.Get)(':filename'),
|
|
65
|
+
__param(0, (0, common_1.Param)('filename')),
|
|
66
|
+
__param(1, (0, common_1.Res)()),
|
|
67
|
+
__param(2, (0, rest_user_decorator_1.RESTUser)()),
|
|
68
|
+
__metadata("design:type", Function),
|
|
69
|
+
__metadata("design:paramtypes", [String, Object, user_model_1.User]),
|
|
70
|
+
__metadata("design:returntype", Promise)
|
|
71
|
+
], FileController.prototype, "getFile", null);
|
|
43
72
|
FileController = __decorate([
|
|
44
|
-
(0, common_1.Controller)('files')
|
|
73
|
+
(0, common_1.Controller)('files'),
|
|
74
|
+
__metadata("design:paramtypes", [file_service_1.FileService])
|
|
45
75
|
], FileController);
|
|
46
76
|
exports.FileController = FileController;
|
|
47
77
|
//# sourceMappingURL=file.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.controller.js","sourceRoot":"","sources":["../../../../src/server/modules/file/file.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"file.controller.js","sourceRoot":"","sources":["../../../../src/server/modules/file/file.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAWwB;AACxB,+DAA4D;AAC5D,mCAAqC;AACrC,oDAA4C;AAC5C,6FAA+E;AAC/E,qFAAwE;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AAS,CAAC,YAAY,CAAC,IAAI;YAGxC,QAAQ,EAAE,IAAA,kCAAoB,GAAE;SACjC,CAAC;KACH,CAAC,CACH;IACY,WAAA,IAAA,sBAAa,GAAE,CAAA;IAAS,WAAA,IAAA,aAAI,GAAE,CAAA;;;;iDAE1C;AAOD;IAFC,IAAA,uBAAK,EAAC,oBAAQ,CAAC,KAAK,CAAC;IACrB,IAAA,YAAG,EAAC,WAAW,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;IAAoB,WAAA,IAAA,YAAG,GAAE,CAAA;IAAO,WAAA,IAAA,8BAAQ,GAAE,CAAA;;qDAAO,iBAAI;;6CAapF;AAhDU,cAAc;IAD1B,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAKiB,0BAAW;GAJnC,cAAc,CAiD1B;AAjDY,wCAAc"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FileInfo } from '../../../core/modules/file/file-info.output';
|
|
2
|
+
import { FileUpload } from '../../../core/modules/file/interfaces/file-upload.interface';
|
|
3
|
+
import { FileService } from './file.service';
|
|
2
4
|
export declare class FileResolver {
|
|
3
|
-
|
|
5
|
+
protected readonly fileService: FileService;
|
|
6
|
+
constructor(fileService: FileService);
|
|
7
|
+
getFileInfo(filename: string): Promise<FileInfo>;
|
|
8
|
+
deleteFile(filename: string): Promise<FileInfo>;
|
|
9
|
+
uploadFile(file: FileUpload): Promise<FileInfo>;
|
|
4
10
|
uploadFiles(files: FileUpload[]): Promise<boolean>;
|
|
5
11
|
}
|
|
@@ -14,29 +14,65 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.FileResolver = void 0;
|
|
16
16
|
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
+
const fs_1 = require("fs");
|
|
17
18
|
const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
|
|
19
|
+
const roles_decorator_1 = require("../../../core/common/decorators/roles.decorator");
|
|
20
|
+
const role_enum_1 = require("../../../core/common/enums/role.enum");
|
|
21
|
+
const file_info_output_1 = require("../../../core/modules/file/file-info.output");
|
|
22
|
+
const file_service_1 = require("./file.service");
|
|
18
23
|
let FileResolver = class FileResolver {
|
|
24
|
+
constructor(fileService) {
|
|
25
|
+
this.fileService = fileService;
|
|
26
|
+
}
|
|
27
|
+
async getFileInfo(filename) {
|
|
28
|
+
return await this.fileService.getFileInfoByName(filename);
|
|
29
|
+
}
|
|
30
|
+
async deleteFile(filename) {
|
|
31
|
+
return await this.fileService.deleteFileByName(filename);
|
|
32
|
+
}
|
|
19
33
|
async uploadFile(file) {
|
|
20
|
-
|
|
21
|
-
return
|
|
34
|
+
const { filename, mimetype, encoding, createReadStream } = file;
|
|
35
|
+
return await this.fileService.createFile(file);
|
|
22
36
|
}
|
|
23
37
|
async uploadFiles(files) {
|
|
24
38
|
const promises = [];
|
|
25
39
|
for (const file of files) {
|
|
26
|
-
|
|
40
|
+
const { filename, mimetype, encoding, createReadStream } = await file;
|
|
41
|
+
promises.push(new Promise((resolve, reject) => createReadStream()
|
|
42
|
+
.pipe((0, fs_1.createWriteStream)(`./uploads/${filename}`))
|
|
43
|
+
.on('finish', () => resolve(true))
|
|
44
|
+
.on('error', (error) => reject(error))));
|
|
27
45
|
}
|
|
28
|
-
await Promise.
|
|
46
|
+
await Promise.allSettled(promises);
|
|
29
47
|
return true;
|
|
30
48
|
}
|
|
31
49
|
};
|
|
32
50
|
__decorate([
|
|
33
|
-
(0,
|
|
51
|
+
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.ADMIN),
|
|
52
|
+
(0, graphql_1.Query)(() => file_info_output_1.FileInfo, { nullable: true }),
|
|
53
|
+
__param(0, (0, graphql_1.Args)({ name: 'filename', type: () => String })),
|
|
54
|
+
__metadata("design:type", Function),
|
|
55
|
+
__metadata("design:paramtypes", [String]),
|
|
56
|
+
__metadata("design:returntype", Promise)
|
|
57
|
+
], FileResolver.prototype, "getFileInfo", null);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.ADMIN),
|
|
60
|
+
(0, graphql_1.Mutation)(() => file_info_output_1.FileInfo),
|
|
61
|
+
__param(0, (0, graphql_1.Args)({ name: 'filename', type: () => String })),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [String]),
|
|
64
|
+
__metadata("design:returntype", Promise)
|
|
65
|
+
], FileResolver.prototype, "deleteFile", null);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.ADMIN),
|
|
68
|
+
(0, graphql_1.Mutation)(() => file_info_output_1.FileInfo),
|
|
34
69
|
__param(0, (0, graphql_1.Args)({ name: 'file', type: () => GraphQLUpload })),
|
|
35
70
|
__metadata("design:type", Function),
|
|
36
71
|
__metadata("design:paramtypes", [Object]),
|
|
37
72
|
__metadata("design:returntype", Promise)
|
|
38
73
|
], FileResolver.prototype, "uploadFile", null);
|
|
39
74
|
__decorate([
|
|
75
|
+
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.ADMIN),
|
|
40
76
|
(0, graphql_1.Mutation)(() => Boolean),
|
|
41
77
|
__param(0, (0, graphql_1.Args)({ name: 'files', type: () => [GraphQLUpload] })),
|
|
42
78
|
__metadata("design:type", Function),
|
|
@@ -44,7 +80,8 @@ __decorate([
|
|
|
44
80
|
__metadata("design:returntype", Promise)
|
|
45
81
|
], FileResolver.prototype, "uploadFiles", null);
|
|
46
82
|
FileResolver = __decorate([
|
|
47
|
-
(0, graphql_1.Resolver)()
|
|
83
|
+
(0, graphql_1.Resolver)(),
|
|
84
|
+
__metadata("design:paramtypes", [file_service_1.FileService])
|
|
48
85
|
], FileResolver);
|
|
49
86
|
exports.FileResolver = FileResolver;
|
|
50
87
|
//# sourceMappingURL=file.resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.resolver.js","sourceRoot":"","sources":["../../../../src/server/modules/file/file.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"file.resolver.js","sourceRoot":"","sources":["../../../../src/server/modules/file/file.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAkE;AAClE,2BAAuC;AACvC,iEAAiE;AACjE,qFAAwE;AACxE,oEAAgE;AAChE,kFAAuE;AAEvE,iDAA6C;AAM7C,IAAa,YAAY,GAAzB,MAAa,YAAY;IAIvB,YAA+B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAW3D,KAAK,CAAC,WAAW,CAAiD,QAAgB;QAChF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAWD,KAAK,CAAC,UAAU,CAAiD,QAAgB;QAC/E,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAOD,KAAK,CAAC,UAAU,CAAoD,IAAgB;QAClF,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;QAGhE,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAOD,KAAK,CAAC,WAAW,CAAuD,KAAmB;QAEzF,MAAM,QAAQ,GAAmB,EAAE,CAAC;QACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAI,CAAC;YACtE,QAAQ,CAAC,IAAI,CACX,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAC9B,gBAAgB,EAAE;iBACf,IAAI,CAAC,IAAA,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,cAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;;;;+CAgBtE;AAjEU,YAAY;IADxB,IAAA,kBAAQ,GAAE;qCAKmC,0BAAW;GAJ5C,YAAY,CAkExB;AAlEY,oCAAY"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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.FileService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
18
|
+
const mongoose_2 = require("mongoose");
|
|
19
|
+
const core_file_service_1 = require("../../../core/modules/file/core-file.service");
|
|
20
|
+
let FileService = class FileService extends core_file_service_1.CoreFileService {
|
|
21
|
+
constructor(connection) {
|
|
22
|
+
super(connection, 'File');
|
|
23
|
+
this.connection = connection;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
FileService = __decorate([
|
|
27
|
+
(0, common_1.Injectable)(),
|
|
28
|
+
__param(0, (0, mongoose_1.InjectConnection)()),
|
|
29
|
+
__metadata("design:paramtypes", [mongoose_2.Connection])
|
|
30
|
+
], FileService);
|
|
31
|
+
exports.FileService = FileService;
|
|
32
|
+
//# sourceMappingURL=file.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.service.js","sourceRoot":"","sources":["../../../../src/server/modules/file/file.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAAoD;AACpD,uCAAsC;AACtC,oFAA+E;AAG/E,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,mCAAe;IAC9C,YAAmD,UAAsB;QACvE,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QADuB,eAAU,GAAV,UAAU,CAAY;IAEzE,CAAC;CACF,CAAA;AAJY,WAAW;IADvB,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,2BAAgB,GAAE,CAAA;qCAAgC,qBAAU;GAD9D,WAAW,CAIvB;AAJY,kCAAW"}
|
|
@@ -28,5 +28,6 @@ export declare class User extends CoreUserModel implements PersistenceModel {
|
|
|
28
28
|
createdBy: User;
|
|
29
29
|
updatedBy: User;
|
|
30
30
|
init(): this;
|
|
31
|
+
map(input: any): this;
|
|
31
32
|
}
|
|
32
33
|
export declare const UserSchema: Schema<User, import("mongoose").Model<User, any, any, any>, {}, {}, any>;
|
|
@@ -14,6 +14,7 @@ exports.UserSchema = exports.User = void 0;
|
|
|
14
14
|
const graphql_1 = require("@nestjs/graphql");
|
|
15
15
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
16
16
|
const mongoose_2 = require("mongoose");
|
|
17
|
+
const model_helper_1 = require("../../../core/common/helpers/model.helper");
|
|
17
18
|
const core_user_model_1 = require("../../../core/modules/user/core-user.model");
|
|
18
19
|
let User = User_1 = class User extends core_user_model_1.CoreUserModel {
|
|
19
20
|
constructor() {
|
|
@@ -26,6 +27,10 @@ let User = User_1 = class User extends core_user_model_1.CoreUserModel {
|
|
|
26
27
|
super.init();
|
|
27
28
|
return this;
|
|
28
29
|
}
|
|
30
|
+
map(input) {
|
|
31
|
+
super.map(input);
|
|
32
|
+
return (0, model_helper_1.mapClasses)(input, { createdBy: User_1, updatedBy: User_1 }, this);
|
|
33
|
+
}
|
|
29
34
|
};
|
|
30
35
|
__decorate([
|
|
31
36
|
(0, graphql_1.Field)({ description: 'URL to avatar file of the user', nullable: true }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.js","sourceRoot":"","sources":["../../../../src/server/modules/user/user.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAAoD;AACpD,+CAAiF;AACjF,uCAA4C;AAC5C,gFAA2E;AAU3E,IAAa,IAAI,YAAjB,MAAa,IAAK,SAAQ,+BAAa;IAAvC;;QAUE,WAAM,GAAW,SAAS,CAAC;QAY3B,cAAS,GAAS,SAAS,CAAC;QAY5B,cAAS,GAAS,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"user.model.js","sourceRoot":"","sources":["../../../../src/server/modules/user/user.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAAoD;AACpD,+CAAiF;AACjF,uCAA4C;AAC5C,4EAAuE;AACvE,gFAA2E;AAU3E,IAAa,IAAI,YAAjB,MAAa,IAAK,SAAQ,+BAAa;IAAvC;;QAUE,WAAM,GAAW,SAAS,CAAC;QAY3B,cAAS,GAAS,SAAS,CAAC;QAY5B,cAAS,GAAS,SAAS,CAAC;IAsB9B,CAAC;IAbC,IAAI;QACF,KAAK,CAAC,IAAI,EAAE,CAAC;QAEb,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,GAAG,CAAC,KAAK;QACP,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO,IAAA,yBAAU,EAAC,KAAK,EAAE,EAAE,SAAS,EAAE,MAAI,EAAE,SAAS,EAAE,MAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IACvE,CAAC;CACF,CAAA;AA9CC;IAFC,IAAA,eAAK,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxE,IAAA,eAAI,GAAE;;oCACoB;AAY3B;IALC,IAAA,eAAK,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAI,EAAE;QACrB,WAAW,EAAE,uCAAuC;QACpD,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;8BACxC,IAAI;uCAAa;AAY5B;IALC,IAAA,eAAK,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAI,EAAE;QACrB,WAAW,EAAE,4CAA4C;QACzD,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;8BACxC,IAAI;uCAAa;AAlCjB,IAAI;IAFhB,IAAA,oBAAU,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IACnC,IAAA,iBAAc,EAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;GACxB,IAAI,CAwDhB;AAxDY,oBAAI;AA0DJ,QAAA,UAAU,GAAG,wBAAa,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -163,8 +163,7 @@ __decorate([
|
|
|
163
163
|
__decorate([
|
|
164
164
|
(0, graphql_1.Subscription)(() => user_model_1.User, {
|
|
165
165
|
filter(payload, variables, context) {
|
|
166
|
-
|
|
167
|
-
return (_b = (_a = context === null || context === void 0 ? void 0 : context.user) === null || _a === void 0 ? void 0 : _a.hasRole) === null || _b === void 0 ? void 0 : _b.call(_a, role_enum_1.RoleEnum.ADMIN);
|
|
166
|
+
return context?.user?.hasRole?.(role_enum_1.RoleEnum.ADMIN);
|
|
168
167
|
},
|
|
169
168
|
resolve: (user) => user,
|
|
170
169
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.resolver.js","sourceRoot":"","sources":["../../../../src/server/modules/user/user.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAsF;AAEtF,iEAA+C;AAC/C,uEAAmE;AACnE,mGAAqF;AACrF,qFAAwE;AACxE,oEAAgE;AAChE,kEAA6D;AAC7D,oDAAgD;AAChD,6CAAoC;AACpC,iDAA6C;AAM7C,IAAa,YAAY,GAAzB,MAAa,YAAY;IAIvB,YAA+B,WAAwB,EAAwC,MAAc;QAA9E,gBAAW,GAAX,WAAW,CAAa;QAAwC,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAWjH,KAAK,CAAC,SAAS,CAAS,IAAwB,EAAU,IAAiB;QACzE,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;YACvC,cAAc,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE;YAC7C,SAAS,EAAE,wBAAU;SACtB,CAAC,CAAC;IACL,CAAC;IAOD,KAAK,CAAC,OAAO,CAAa,EAAU,EAAU,IAAwB,EAAiB,IAAU;QAC/F,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE;YACpC,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE;YAC3C,KAAK,EAAE,CAAC,oBAAQ,CAAC,KAAK,EAAE,oBAAQ,CAAC,SAAS,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;IAMD,KAAK,CAAC,gBAAgB,CAAgB,KAAa;QACjD,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACx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Q,EAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;IACjD,WAAA,IAAA,cAAI,EAAC,OAAO,CAAC,CAAA;;;;8CAE9B;AAeD;IANC,IAAA,sBAAY,EAAC,GAAG,EAAE,CAAC,iBAAI,EAAE;QACxB,MAAM,CAAqB,OAAO,EAAE,SAAS,EAAE,OAAO;YACpD,OAAO,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,oBAAQ,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI;KACxB,CAAC;;;;+CAGD;AAxIU,YAAY;IADxB,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;IAKuC,WAAA,IAAA,eAAM,EAAC,SAAS,CAAC,CAAA;qCAA/B,0BAAW,EAAgD,8BAAM;GAJlG,YAAY,CAyIxB;AAzIY,oCAAY"}
|
|
@@ -36,9 +36,9 @@ let UserService = class UserService extends core_user_service_1.CoreUserService
|
|
|
36
36
|
let user = await super.create(input, serviceOptions);
|
|
37
37
|
if (!user.createdBy) {
|
|
38
38
|
await this.mainDbModel.findByIdAndUpdate(user.id, { createdBy: user.id });
|
|
39
|
-
user = await this.get(user.id,
|
|
39
|
+
user = await this.get(user.id, { ...serviceOptions, currentUser: serviceOptions?.currentUser || user });
|
|
40
40
|
}
|
|
41
|
-
if (
|
|
41
|
+
if (serviceOptions?.pubSub === undefined || serviceOptions.pubSub) {
|
|
42
42
|
await this.pubSub.publish('userCreated', user_model_1.User.map(user));
|
|
43
43
|
}
|
|
44
44
|
return user;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../../../src/server/modules/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyG;AACzG,+CAA+C;AAC/C,yBAAyB;AACzB,iEAA+C;AAC/C,uCAAiC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_1 = require("../core/modules/auth/services/core-auth.ser
|
|
|
14
14
|
const auth_module_1 = require("./modules/auth/auth.module");
|
|
15
15
|
const file_controller_1 = require("./modules/file/file.controller");
|
|
16
16
|
const file_resolver_1 = require("./modules/file/file.resolver");
|
|
17
|
+
const file_service_1 = require("./modules/file/file.service");
|
|
17
18
|
const server_controller_1 = require("./server.controller");
|
|
18
19
|
let ServerModule = class ServerModule {
|
|
19
20
|
};
|
|
@@ -24,7 +25,7 @@ ServerModule = __decorate([
|
|
|
24
25
|
auth_module_1.AuthModule.forRoot(config_env_1.default.jwt),
|
|
25
26
|
],
|
|
26
27
|
controllers: [file_controller_1.FileController, server_controller_1.ServerController],
|
|
27
|
-
providers: [file_resolver_1.FileResolver],
|
|
28
|
+
providers: [file_service_1.FileService, file_resolver_1.FileResolver],
|
|
28
29
|
exports: [core_module_1.CoreModule, auth_module_1.AuthModule],
|
|
29
30
|
})
|
|
30
31
|
], ServerModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.module.js","sourceRoot":"","sources":["../../src/server/server.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,8CAAsC;AACtC,gDAA4C;AAC5C,uFAAkF;AAClF,4DAAwD;AACxD,oEAAgE;AAChE,gEAA4D;AAC5D,2DAAuD;AA4BvD,IAAa,YAAY,GAAzB,MAAa,YAAY;CAAG,CAAA;AAAf,YAAY;IApBxB,IAAA,eAAM,EAAC;QAEN,OAAO,EAAE;YAEP,wBAAU,CAAC,OAAO,CAAC,mCAAe,EAAE,wBAAU,CAAC,OAAO,CAAC,oBAAS,CAAC,GAAG,CAAC,EAAE,oBAAS,CAAC;YAIjF,wBAAU,CAAC,OAAO,CAAC,oBAAS,CAAC,GAAG,CAAC;SAClC;QAGD,WAAW,EAAE,CAAC,gCAAc,EAAE,oCAAgB,CAAC;QAG/C,SAAS,EAAE,CAAC,4BAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"server.module.js","sourceRoot":"","sources":["../../src/server/server.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,8CAAsC;AACtC,gDAA4C;AAC5C,uFAAkF;AAClF,4DAAwD;AACxD,oEAAgE;AAChE,gEAA4D;AAC5D,8DAA0D;AAC1D,2DAAuD;AA4BvD,IAAa,YAAY,GAAzB,MAAa,YAAY;CAAG,CAAA;AAAf,YAAY;IApBxB,IAAA,eAAM,EAAC;QAEN,OAAO,EAAE;YAEP,wBAAU,CAAC,OAAO,CAAC,mCAAe,EAAE,wBAAU,CAAC,OAAO,CAAC,oBAAS,CAAC,GAAG,CAAC,EAAE,oBAAS,CAAC;YAIjF,wBAAU,CAAC,OAAO,CAAC,oBAAS,CAAC,GAAG,CAAC;SAClC;QAGD,WAAW,EAAE,CAAC,gCAAc,EAAE,oCAAgB,CAAC;QAG/C,SAAS,EAAE,CAAC,0BAAW,EAAE,4BAAY,CAAC;QAGtC,OAAO,EAAE,CAAC,wBAAU,EAAE,wBAAU,CAAC;KAClC,CAAC;GACW,YAAY,CAAG;AAAf,oCAAY"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import { INestApplication } from '@nestjs/common';
|
|
4
|
+
import { Blob } from 'buffer';
|
|
5
|
+
import * as fs from 'fs';
|
|
2
6
|
import * as LightMyRequest from 'light-my-request';
|
|
3
7
|
export declare enum TestGraphQLType {
|
|
4
8
|
QUERY = "query",
|
|
@@ -16,6 +20,18 @@ export interface TestGraphQLConfig {
|
|
|
16
20
|
fields?: TestFields | TestFields[];
|
|
17
21
|
name?: string;
|
|
18
22
|
type?: TestGraphQLType;
|
|
23
|
+
variables?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
export interface TestGraphQLAttachment {
|
|
26
|
+
file: Blob | Buffer | fs.ReadStream | string | boolean | number;
|
|
27
|
+
options?: string | {
|
|
28
|
+
filename?: string | undefined;
|
|
29
|
+
contentType?: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface TestGraphQLVariable {
|
|
33
|
+
value: string | string[] | TestGraphQLAttachment | TestGraphQLAttachment[] | any;
|
|
34
|
+
type: 'field' | 'attachment';
|
|
19
35
|
}
|
|
20
36
|
export interface TestGraphQLOptions {
|
|
21
37
|
convertEnums?: boolean | string[];
|
|
@@ -24,6 +40,7 @@ export interface TestGraphQLOptions {
|
|
|
24
40
|
logError?: boolean;
|
|
25
41
|
statusCode?: number;
|
|
26
42
|
token?: string;
|
|
43
|
+
variables?: Record<string, TestGraphQLVariable>;
|
|
27
44
|
}
|
|
28
45
|
export interface TestRestOptions {
|
|
29
46
|
log?: boolean;
|
|
@@ -37,9 +54,12 @@ export declare class TestHelper {
|
|
|
37
54
|
app: INestApplication;
|
|
38
55
|
subscriptionUrl: string;
|
|
39
56
|
constructor(app: any, subscriptionUrl?: string);
|
|
57
|
+
download(url: string, token?: string): Promise<unknown>;
|
|
40
58
|
graphQl(graphql: string | TestGraphQLConfig, options?: TestGraphQLOptions): Promise<any>;
|
|
41
59
|
rest(url: string, options?: TestRestOptions): Promise<any>;
|
|
42
60
|
prepareFields(fields: any): any;
|
|
43
|
-
protected getResponse(token: string, requestConfig: LightMyRequest.InjectOptions, statusCode: number, log: boolean, logError: boolean): Promise<any>;
|
|
61
|
+
protected getResponse(token: string, requestConfig: LightMyRequest.InjectOptions, statusCode: number, log: boolean, logError: boolean, variables?: Record<string, TestGraphQLVariable>): Promise<any>;
|
|
62
|
+
processVariables(request: any, variables: Record<string, TestGraphQLVariable>, query: string | object): any;
|
|
63
|
+
processResponse(response: any, statusCode: any, log: any, logError: any): any;
|
|
44
64
|
getSubscription(graphql: TestGraphQLConfig, query: string, options?: TestGraphQLOptions): Promise<any[]>;
|
|
45
65
|
}
|
package/dist/test/test.helper.js
CHANGED
|
@@ -17,9 +17,42 @@ class TestHelper {
|
|
|
17
17
|
this.app = app;
|
|
18
18
|
this.subscriptionUrl = subscriptionUrl;
|
|
19
19
|
}
|
|
20
|
+
download(url, token) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const request = supertest(this.app.getHttpServer()).get(url);
|
|
23
|
+
if (token) {
|
|
24
|
+
request.set('Authorization', 'bearer ' + token);
|
|
25
|
+
}
|
|
26
|
+
let data = '';
|
|
27
|
+
request
|
|
28
|
+
.buffer()
|
|
29
|
+
.parse((res, callback) => {
|
|
30
|
+
res.setEncoding('binary');
|
|
31
|
+
res.on('data', (chunk) => {
|
|
32
|
+
data += chunk;
|
|
33
|
+
});
|
|
34
|
+
res.on('error', reject);
|
|
35
|
+
res.on('end', (err) => {
|
|
36
|
+
err ? reject(err) : callback(null, null);
|
|
37
|
+
});
|
|
38
|
+
})
|
|
39
|
+
.end((err, res) => {
|
|
40
|
+
res.data = new Buffer(data, 'binary').toString();
|
|
41
|
+
err ? reject(err) : resolve(res);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
20
45
|
async graphQl(graphql, options = {}) {
|
|
21
|
-
const config =
|
|
22
|
-
|
|
46
|
+
const config = {
|
|
47
|
+
convertEnums: true,
|
|
48
|
+
countOfSubscriptionMessages: 1,
|
|
49
|
+
token: null,
|
|
50
|
+
statusCode: 200,
|
|
51
|
+
log: false,
|
|
52
|
+
logError: false,
|
|
53
|
+
...options,
|
|
54
|
+
};
|
|
55
|
+
const { token, statusCode, log, logError, variables } = config;
|
|
23
56
|
let query = '';
|
|
24
57
|
if ((typeof graphql === 'string' || graphql instanceof String) && /^[a-zA-Z]+$/.test(graphql)) {
|
|
25
58
|
query = graphql;
|
|
@@ -36,6 +69,9 @@ class TestHelper {
|
|
|
36
69
|
}, graphql);
|
|
37
70
|
const queryObj = {};
|
|
38
71
|
queryObj[graphql.type] = {};
|
|
72
|
+
if (graphql.variables) {
|
|
73
|
+
queryObj[graphql.type]['__variables'] = graphql.variables;
|
|
74
|
+
}
|
|
39
75
|
queryObj[graphql.type][graphql.name] = this.prepareFields(graphql.fields) || {};
|
|
40
76
|
if (graphql.arguments) {
|
|
41
77
|
queryObj[graphql.type][graphql.name].__args = graphql.arguments;
|
|
@@ -65,12 +101,20 @@ class TestHelper {
|
|
|
65
101
|
if (token) {
|
|
66
102
|
requestConfig.headers = { authorization: `Bearer ${token}` };
|
|
67
103
|
}
|
|
68
|
-
const response = await this.getResponse(token, requestConfig, statusCode, log, logError);
|
|
104
|
+
const response = await this.getResponse(token, requestConfig, statusCode, log, logError, variables);
|
|
69
105
|
expect(response.headers['content-type']).toMatch('application/json');
|
|
70
106
|
return response.body.data ? response.body.data[graphql.name] : response.body;
|
|
71
107
|
}
|
|
72
108
|
async rest(url, options = {}) {
|
|
73
|
-
const config =
|
|
109
|
+
const config = {
|
|
110
|
+
token: null,
|
|
111
|
+
statusCode: 200,
|
|
112
|
+
log: false,
|
|
113
|
+
logError: false,
|
|
114
|
+
payload: null,
|
|
115
|
+
method: 'GET',
|
|
116
|
+
...options,
|
|
117
|
+
};
|
|
74
118
|
const { token, statusCode, log, logError } = config;
|
|
75
119
|
const requestConfig = {
|
|
76
120
|
method: config.method,
|
|
@@ -118,16 +162,60 @@ class TestHelper {
|
|
|
118
162
|
}
|
|
119
163
|
return result;
|
|
120
164
|
}
|
|
121
|
-
async getResponse(token, requestConfig, statusCode, log, logError) {
|
|
165
|
+
async getResponse(token, requestConfig, statusCode, log, logError, variables) {
|
|
122
166
|
if (token) {
|
|
123
167
|
requestConfig.headers = { authorization: `Bearer ${token}` };
|
|
124
168
|
}
|
|
125
169
|
const method = requestConfig.method.toLowerCase();
|
|
126
170
|
let request = supertest(this.app.getHttpServer())[method](requestConfig.url);
|
|
127
171
|
if (token) {
|
|
128
|
-
request
|
|
172
|
+
request.set('Authorization', 'bearer ' + token);
|
|
173
|
+
}
|
|
174
|
+
if (variables) {
|
|
175
|
+
request = this.processVariables(request, variables, requestConfig.payload?.query);
|
|
176
|
+
}
|
|
177
|
+
const response = await (variables ? request : request.send(requestConfig.payload));
|
|
178
|
+
return this.processResponse(response, statusCode, log, logError);
|
|
179
|
+
}
|
|
180
|
+
processVariables(request, variables, query) {
|
|
181
|
+
if (!variables) {
|
|
182
|
+
return request;
|
|
183
|
+
}
|
|
184
|
+
if (typeof query === 'object') {
|
|
185
|
+
query = JSON.stringify(query).replace(/"/g, '');
|
|
129
186
|
}
|
|
130
|
-
const
|
|
187
|
+
const mapArray = [];
|
|
188
|
+
for (const [key, item] of Object.entries(variables)) {
|
|
189
|
+
if (item.type === 'attachment' && Array.isArray(item.value)) {
|
|
190
|
+
item.value.forEach((element, index) => {
|
|
191
|
+
mapArray.push({ key, type: 'attachment', value: element, index });
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
mapArray.push({ key, type: item.type, value: item.value });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const map = {};
|
|
199
|
+
mapArray.forEach((item, index) => {
|
|
200
|
+
map[index] = ['variables.' + item.key + ('index' in item ? '.' + item.index : '')];
|
|
201
|
+
});
|
|
202
|
+
request.field('operations', JSON.stringify({ query })).field('map', JSON.stringify(map));
|
|
203
|
+
mapArray.forEach((variable, i) => {
|
|
204
|
+
if (variable.type === 'attachment') {
|
|
205
|
+
if (typeof variable.value === 'object' && variable.value.file) {
|
|
206
|
+
request.attach(`${i}`, variable.value.file, variable.value.options);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
request.attach(`${i}`, variable.value);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
request.field(`${i}`, variable.value);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return request;
|
|
217
|
+
}
|
|
218
|
+
processResponse(response, statusCode, log, logError) {
|
|
131
219
|
if (log) {
|
|
132
220
|
console.log(JSON.stringify(response, null, 2));
|
|
133
221
|
}
|
|
@@ -135,7 +223,7 @@ class TestHelper {
|
|
|
135
223
|
if (response && response.error && response.error.text) {
|
|
136
224
|
const errors = JSON.parse(response.error.text).errors;
|
|
137
225
|
for (const error of errors) {
|
|
138
|
-
console.
|
|
226
|
+
console.error(util.inspect(error, false, null, true));
|
|
139
227
|
}
|
|
140
228
|
}
|
|
141
229
|
}
|
|
@@ -147,8 +235,8 @@ class TestHelper {
|
|
|
147
235
|
throw new Error("Missing subscriptionUrl in TestHelper: new TestHelper(app, 'ws://localhost:3030/graphql')");
|
|
148
236
|
}
|
|
149
237
|
let connectionParams;
|
|
150
|
-
if (options
|
|
151
|
-
connectionParams = { Authorization: `Bearer ${options
|
|
238
|
+
if (options?.token) {
|
|
239
|
+
connectionParams = { Authorization: `Bearer ${options?.token}` };
|
|
152
240
|
}
|
|
153
241
|
if (options.log) {
|
|
154
242
|
console.log('Subscription query', JSON.stringify(query, null, 2));
|
|
@@ -157,11 +245,10 @@ class TestHelper {
|
|
|
157
245
|
const messages = [];
|
|
158
246
|
let unsubscribe;
|
|
159
247
|
const onNext = (message) => {
|
|
160
|
-
var _a;
|
|
161
248
|
if (options.log) {
|
|
162
249
|
console.log('Subscription message', JSON.stringify(message, null, 2));
|
|
163
250
|
}
|
|
164
|
-
messages.push(
|
|
251
|
+
messages.push(message?.data?.[graphql.name]);
|
|
165
252
|
if (messages.length <= options.countOfSubscriptionMessages) {
|
|
166
253
|
unsubscribe();
|
|
167
254
|
}
|