@lenne.tech/nest-server 8.6.12 → 8.6.13
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/types/maybe-promise.type.d.ts +1 -0
- package/dist/core/common/types/maybe-promise.type.js +3 -0
- package/dist/core/common/types/maybe-promise.type.js.map +1 -0
- package/dist/core/modules/file/{file-info.output.d.ts → core-file-info.model.d.ts} +4 -3
- package/dist/core/modules/file/{file-info.output.js → core-file-info.model.js} +35 -20
- package/dist/core/modules/file/core-file-info.model.js.map +1 -0
- package/dist/core/modules/file/core-file.controller.d.ts +7 -0
- package/dist/core/modules/file/core-file.controller.js +52 -0
- package/dist/core/modules/file/core-file.controller.js.map +1 -0
- package/dist/core/modules/file/core-file.resolver.d.ts +10 -0
- package/dist/core/modules/file/core-file.resolver.js +70 -0
- package/dist/core/modules/file/core-file.resolver.js.map +1 -0
- package/dist/core/modules/file/core-file.service.d.ts +20 -15
- package/dist/core/modules/file/core-file.service.js +59 -22
- package/dist/core/modules/file/core-file.service.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/server/modules/file/file-info.model.d.ts +26 -0
- package/dist/server/modules/file/file-info.model.js +21 -0
- package/dist/server/modules/file/file-info.model.js.map +1 -0
- package/dist/server/modules/file/file.controller.d.ts +2 -3
- package/dist/server/modules/file/file.controller.js +4 -26
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/modules/file/file.module.d.ts +2 -0
- package/dist/server/modules/file/file.module.js +27 -0
- package/dist/server/modules/file/file.module.js.map +1 -0
- package/dist/server/modules/file/file.resolver.d.ts +3 -4
- package/dist/server/modules/file/file.resolver.js +4 -5
- package/dist/server/modules/file/file.resolver.js.map +1 -1
- package/dist/server/modules/file/file.service.js +1 -1
- package/dist/server/modules/file/file.service.js.map +1 -1
- package/dist/server/server.module.js +4 -6
- package/dist/server/server.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/common/types/maybe-promise.type.ts +4 -0
- package/src/core/modules/file/core-file-info.model.ts +40 -0
- package/src/core/modules/file/core-file.controller.ts +34 -0
- package/src/core/modules/file/core-file.resolver.ts +56 -0
- package/src/core/modules/file/core-file.service.ts +81 -27
- package/src/index.ts +4 -1
- package/src/server/modules/file/file-info.model.ts +15 -0
- package/src/server/modules/file/file.controller.ts +7 -36
- package/src/server/modules/file/file.module.ts +17 -0
- package/src/server/modules/file/file.resolver.ts +1 -4
- package/src/server/modules/file/file.service.ts +4 -1
- package/src/server/server.module.ts +6 -8
- package/dist/core/modules/file/file-info.output.js.map +0 -1
- package/src/core/modules/file/file-info.output.ts +0 -26
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type MaybePromise<T = any> = T | Promise<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maybe-promise.type.js","sourceRoot":"","sources":["../../../../src/core/common/types/maybe-promise.type.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Types } from 'mongoose';
|
|
2
2
|
import { CoreModel } from '../../common/models/core-model.model';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class CoreFileInfo extends CoreModel {
|
|
4
4
|
_id: Types.ObjectId;
|
|
5
5
|
id: string;
|
|
6
|
-
length: number;
|
|
7
6
|
chunkSize: number;
|
|
8
|
-
filename?: string;
|
|
9
7
|
contentType?: string;
|
|
8
|
+
filename?: string;
|
|
9
|
+
length: number;
|
|
10
|
+
uploadDate: Date;
|
|
10
11
|
}
|
|
@@ -9,41 +9,56 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.CoreFileInfo = void 0;
|
|
13
13
|
const graphql_1 = require("@nestjs/graphql");
|
|
14
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
15
|
const core_model_model_1 = require("../../common/models/core-model.model");
|
|
15
|
-
let
|
|
16
|
+
let CoreFileInfo = class CoreFileInfo extends core_model_model_1.CoreModel {
|
|
16
17
|
constructor() {
|
|
17
18
|
super(...arguments);
|
|
18
19
|
this.id = undefined;
|
|
19
|
-
this.length = undefined;
|
|
20
20
|
this.chunkSize = undefined;
|
|
21
|
-
this.filename = undefined;
|
|
22
21
|
this.contentType = undefined;
|
|
22
|
+
this.filename = undefined;
|
|
23
|
+
this.length = undefined;
|
|
24
|
+
this.uploadDate = undefined;
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
27
|
__decorate([
|
|
26
|
-
(0, graphql_1.Field)(() => String, { description: 'ID of the file
|
|
28
|
+
(0, graphql_1.Field)(() => String, { description: 'ID of the file' }),
|
|
27
29
|
__metadata("design:type", String)
|
|
28
|
-
],
|
|
30
|
+
], CoreFileInfo.prototype, "id", void 0);
|
|
29
31
|
__decorate([
|
|
30
|
-
(0, graphql_1.Field)(() => Number, {
|
|
32
|
+
(0, graphql_1.Field)(() => Number, {
|
|
33
|
+
description: 'The size of each chunk in bytes. GridFS divides the document into chunks of size chunkSize, ' +
|
|
34
|
+
'except for the last, which is only as large as needed. The default size is 255 kilobytes (kB)',
|
|
35
|
+
nullable: true,
|
|
36
|
+
}),
|
|
37
|
+
(0, mongoose_1.Prop)({ type: Number, required: false }),
|
|
31
38
|
__metadata("design:type", Number)
|
|
32
|
-
],
|
|
39
|
+
], CoreFileInfo.prototype, "chunkSize", void 0);
|
|
33
40
|
__decorate([
|
|
34
|
-
(0, graphql_1.Field)(() =>
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
(0, graphql_1.Field)(() => String, { description: 'Content type', nullable: true }),
|
|
42
|
+
(0, mongoose_1.Prop)({ type: String, required: false }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], CoreFileInfo.prototype, "contentType", void 0);
|
|
37
45
|
__decorate([
|
|
38
46
|
(0, graphql_1.Field)(() => String, { description: 'Name of the file', nullable: true }),
|
|
47
|
+
(0, mongoose_1.Prop)({ type: String, required: false }),
|
|
39
48
|
__metadata("design:type", String)
|
|
40
|
-
],
|
|
49
|
+
], CoreFileInfo.prototype, "filename", void 0);
|
|
41
50
|
__decorate([
|
|
42
|
-
(0, graphql_1.Field)(() =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
(0, graphql_1.Field)(() => Number, { description: 'The size of the document in bytes', nullable: true }),
|
|
52
|
+
(0, mongoose_1.Prop)({ type: Number, required: false }),
|
|
53
|
+
__metadata("design:type", Number)
|
|
54
|
+
], CoreFileInfo.prototype, "length", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, graphql_1.Field)(() => Date, { description: 'The date the file was first stored', nullable: true }),
|
|
57
|
+
(0, mongoose_1.Prop)({ type: Date, required: false }),
|
|
58
|
+
__metadata("design:type", Date)
|
|
59
|
+
], CoreFileInfo.prototype, "uploadDate", void 0);
|
|
60
|
+
CoreFileInfo = __decorate([
|
|
61
|
+
(0, graphql_1.ObjectType)({ description: 'Information about file' })
|
|
62
|
+
], CoreFileInfo);
|
|
63
|
+
exports.CoreFileInfo = CoreFileInfo;
|
|
64
|
+
//# sourceMappingURL=core-file-info.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-file-info.model.js","sourceRoot":"","sources":["../../../../src/core/modules/file/core-file-info.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;AACpD,+CAAwC;AAExC,2EAAiE;AAMjE,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,4BAAS;IAA3C;;QAIE,OAAE,GAAW,SAAS,CAAC;QASvB,cAAS,GAAW,SAAS,CAAC;QAI9B,gBAAW,GAAY,SAAS,C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AAC;IACxF,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;8BAC1B,IAAI;gDAAa;AA7BlB,YAAY;IADxB,IAAA,oBAAU,EAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;GACzC,YAAY,CA8BxB;AA9BY,oCAAY"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { User } from '../../../server/modules/user/user.model';
|
|
2
|
+
import { CoreFileService } from './core-file.service';
|
|
3
|
+
export declare abstract class CoreFileController {
|
|
4
|
+
protected fileService: CoreFileService;
|
|
5
|
+
protected constructor(fileService: CoreFileService);
|
|
6
|
+
getFile(filename: string, res: any, user: User): Promise<any>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.CoreFileController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const user_model_1 = require("../../../server/modules/user/user.model");
|
|
18
|
+
const rest_user_decorator_1 = require("../../common/decorators/rest-user.decorator");
|
|
19
|
+
const core_file_service_1 = require("./core-file.service");
|
|
20
|
+
let CoreFileController = class CoreFileController {
|
|
21
|
+
constructor(fileService) {
|
|
22
|
+
this.fileService = fileService;
|
|
23
|
+
}
|
|
24
|
+
async getFile(filename, res, user) {
|
|
25
|
+
if (!filename) {
|
|
26
|
+
throw new common_1.BadRequestException('Missing filename for download');
|
|
27
|
+
}
|
|
28
|
+
const file = await this.fileService.getFileInfoByName(filename);
|
|
29
|
+
if (!file) {
|
|
30
|
+
throw new common_1.NotFoundException('File not found');
|
|
31
|
+
}
|
|
32
|
+
const filestream = await this.fileService.getFileStream(file.id);
|
|
33
|
+
res.header('Content-Type', file.contentType);
|
|
34
|
+
res.header('Content-Disposition', 'attachment; filename=' + file.filename);
|
|
35
|
+
return filestream.pipe(res);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, common_1.Get)(':filename'),
|
|
40
|
+
__param(0, (0, common_1.Param)('filename')),
|
|
41
|
+
__param(1, (0, common_1.Res)()),
|
|
42
|
+
__param(2, (0, rest_user_decorator_1.RESTUser)()),
|
|
43
|
+
__metadata("design:type", Function),
|
|
44
|
+
__metadata("design:paramtypes", [String, Object, user_model_1.User]),
|
|
45
|
+
__metadata("design:returntype", Promise)
|
|
46
|
+
], CoreFileController.prototype, "getFile", null);
|
|
47
|
+
CoreFileController = __decorate([
|
|
48
|
+
(0, common_1.Controller)('files'),
|
|
49
|
+
__metadata("design:paramtypes", [core_file_service_1.CoreFileService])
|
|
50
|
+
], CoreFileController);
|
|
51
|
+
exports.CoreFileController = CoreFileController;
|
|
52
|
+
//# sourceMappingURL=core-file.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-file.controller.js","sourceRoot":"","sources":["../../../../src/core/modules/file/core-file.controller.ts"],"names":[],"mappings":";;;;;;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'./interfaces/file-upload.interface';
|
|
3
|
+
export declare class CoreFileResolver {
|
|
4
|
+
protected readonly fileService: CoreFileService;
|
|
5
|
+
constructor(fileService: CoreFileService);
|
|
6
|
+
getFileInfo(filename: string): Promise<any>;
|
|
7
|
+
deleteFile(filename: string): Promise<any>;
|
|
8
|
+
uploadFile(file: FileUpload): Promise<any>;
|
|
9
|
+
uploadFiles(files: FileUpload[]): Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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.CoreFileResolver = void 0;
|
|
16
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
+
const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
|
|
18
|
+
const core_file_info_model_1 = require("./core-file-info.model");
|
|
19
|
+
const core_file_service_1 = require("./core-file.service");
|
|
20
|
+
let CoreFileResolver = class CoreFileResolver {
|
|
21
|
+
constructor(fileService) {
|
|
22
|
+
this.fileService = fileService;
|
|
23
|
+
}
|
|
24
|
+
async getFileInfo(filename) {
|
|
25
|
+
return await this.fileService.getFileInfoByName(filename);
|
|
26
|
+
}
|
|
27
|
+
async deleteFile(filename) {
|
|
28
|
+
return await this.fileService.deleteFileByName(filename);
|
|
29
|
+
}
|
|
30
|
+
async uploadFile(file) {
|
|
31
|
+
return await this.fileService.createFile(file);
|
|
32
|
+
}
|
|
33
|
+
async uploadFiles(files) {
|
|
34
|
+
return await this.fileService.createFiles(files);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, graphql_1.Query)(() => core_file_info_model_1.CoreFileInfo, { nullable: true }),
|
|
39
|
+
__param(0, (0, graphql_1.Args)({ name: 'filename', type: () => String })),
|
|
40
|
+
__metadata("design:type", Function),
|
|
41
|
+
__metadata("design:paramtypes", [String]),
|
|
42
|
+
__metadata("design:returntype", Promise)
|
|
43
|
+
], CoreFileResolver.prototype, "getFileInfo", null);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, graphql_1.Mutation)(() => core_file_info_model_1.CoreFileInfo),
|
|
46
|
+
__param(0, (0, graphql_1.Args)({ name: 'filename', type: () => String })),
|
|
47
|
+
__metadata("design:type", Function),
|
|
48
|
+
__metadata("design:paramtypes", [String]),
|
|
49
|
+
__metadata("design:returntype", Promise)
|
|
50
|
+
], CoreFileResolver.prototype, "deleteFile", null);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, graphql_1.Mutation)(() => core_file_info_model_1.CoreFileInfo),
|
|
53
|
+
__param(0, (0, graphql_1.Args)({ name: 'file', type: () => GraphQLUpload })),
|
|
54
|
+
__metadata("design:type", Function),
|
|
55
|
+
__metadata("design:paramtypes", [Object]),
|
|
56
|
+
__metadata("design:returntype", Promise)
|
|
57
|
+
], CoreFileResolver.prototype, "uploadFile", null);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, graphql_1.Mutation)(() => [core_file_info_model_1.CoreFileInfo]),
|
|
60
|
+
__param(0, (0, graphql_1.Args)({ name: 'files', type: () => [GraphQLUpload] })),
|
|
61
|
+
__metadata("design:type", Function),
|
|
62
|
+
__metadata("design:paramtypes", [Array]),
|
|
63
|
+
__metadata("design:returntype", Promise)
|
|
64
|
+
], CoreFileResolver.prototype, "uploadFiles", null);
|
|
65
|
+
CoreFileResolver = __decorate([
|
|
66
|
+
(0, graphql_1.Resolver)(),
|
|
67
|
+
__metadata("design:paramtypes", [core_file_service_1.CoreFileService])
|
|
68
|
+
], CoreFileResolver);
|
|
69
|
+
exports.CoreFileResolver = CoreFileResolver;
|
|
70
|
+
//# sourceMappingURL=core-file.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-file.resolver.js","sourceRoot":"","sources":["../../../../src/core/modules/file/core-file.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAkE;AAClE,iEAAiE;AACjE,iEAAsD;AACtD,2DAAsD;AAOtD,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAI3B,YAA+B,WAA4B;QAA5B,gBAAW,GAAX,WAAW,CAAiB;IAAG,CAAC;IAU/D,KAAK,CAAC,WAAW,CAAiD,QAAgB;QAChF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAUD,KAAK,CAAC,UAAU,CAAiD,QAAgB;QAC/E,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAMD,KAAK,CAAC,UAAU,CAAoD,IAAgB;QAClF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAMD,KAAK,CAAC,WAAW,CAAuD,KAAmB;QACzF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AA/BC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,mCAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3B,WAAA,IAAA,cAAI,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;;;;mDAEhE;AAUD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,mCAAY,CAAC;IACX,WAAA,IAAA,cAAI,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;;;;kDAE/D;AAMD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,mCAAY,CAAC;IACX,WAAA,IAAA,cAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC,CAAA;;;;kDAElE;AAMD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,CAAC,mCAAY,CAAC,CAAC;IACZ,WAAA,IAAA,cAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;;;;mDAEtE;AA5CU,gBAAgB;IAD5B,IAAA,kBAAQ,GAAE;qCAKmC,mCAAe;GAJhD,gBAAgB,CA6C5B;AA7CY,4CAAgB"}
|
|
@@ -3,24 +3,29 @@ import { GridFSBucket, GridFSBucketReadStreamOptions } from 'mongodb';
|
|
|
3
3
|
import { Connection, Types } from 'mongoose';
|
|
4
4
|
import { MongooseGridFS } from 'mongoose-gridfs';
|
|
5
5
|
import { FilterArgs } from '../../common/args/filter.args';
|
|
6
|
-
import {
|
|
6
|
+
import { MaybePromise } from '../../common/types/maybe-promise.type';
|
|
7
|
+
import { CoreFileInfo } from './core-file-info.model';
|
|
7
8
|
import { FileServiceOptions } from './interfaces/file-service-options.interface';
|
|
8
9
|
import { FileUpload } from './interfaces/file-upload.interface';
|
|
10
|
+
export declare type FileInputCheckType = 'file' | 'files' | 'filterArgs' | 'id' | 'filename';
|
|
9
11
|
export declare abstract class CoreFileService {
|
|
10
12
|
protected readonly connection: Connection;
|
|
11
13
|
files: GridFSBucket & MongooseGridFS;
|
|
12
|
-
protected constructor(connection: Connection,
|
|
13
|
-
createFile(file: FileUpload
|
|
14
|
-
createFiles(files: FileUpload[], serviceOptions?: FileServiceOptions): Promise<
|
|
15
|
-
findFileInfo(filterArgs?: FilterArgs, serviceOptions?: FileServiceOptions): Promise<
|
|
16
|
-
getFileInfo(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<
|
|
17
|
-
getFileInfoByName(filename: string, serviceOptions?: FileServiceOptions): Promise<
|
|
18
|
-
getFileStream(id: string | Types.ObjectId,
|
|
19
|
-
getFileStreamByName(filename: string): GridFSBucketReadStreamOptions
|
|
20
|
-
getBuffer(id: string | Types.ObjectId): Promise<Buffer>;
|
|
21
|
-
getBufferByName(filename: string): Promise<Buffer>;
|
|
22
|
-
deleteFile(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<
|
|
23
|
-
deleteFileByName(filename: string, serviceOptions?: FileServiceOptions): Promise<
|
|
24
|
-
protected
|
|
25
|
-
|
|
14
|
+
protected constructor(connection: Connection, bucketName?: string);
|
|
15
|
+
createFile(file: MaybePromise<FileUpload>, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo>;
|
|
16
|
+
createFiles(files: MaybePromise<FileUpload>[], serviceOptions?: FileServiceOptions): Promise<CoreFileInfo[]>;
|
|
17
|
+
findFileInfo(filterArgs?: FilterArgs, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo[]>;
|
|
18
|
+
getFileInfo(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo>;
|
|
19
|
+
getFileInfoByName(filename: string, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo>;
|
|
20
|
+
getFileStream(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<any>;
|
|
21
|
+
getFileStreamByName(filename: string, serviceOptions?: FileServiceOptions): Promise<GridFSBucketReadStreamOptions>;
|
|
22
|
+
getBuffer(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<Buffer>;
|
|
23
|
+
getBufferByName(filename: string, serviceOptions?: FileServiceOptions): Promise<Buffer>;
|
|
24
|
+
deleteFile(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo>;
|
|
25
|
+
deleteFileByName(filename: string, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo>;
|
|
26
|
+
protected checkRights(input: any, options?: FileServiceOptions & {
|
|
27
|
+
checkInputType: FileInputCheckType;
|
|
28
|
+
}): MaybePromise<boolean>;
|
|
29
|
+
protected prepareOutput(fileInfo: CoreFileInfo | CoreFileInfo[], options?: FileServiceOptions): Promise<any>;
|
|
30
|
+
protected setId(fileInfo: CoreFileInfo | CoreFileInfo[]): CoreFileInfo | CoreFileInfo[];
|
|
26
31
|
}
|
|
@@ -7,15 +7,18 @@ const db_helper_1 = require("../../common/helpers/db.helper");
|
|
|
7
7
|
const filter_helper_1 = require("../../common/helpers/filter.helper");
|
|
8
8
|
const input_helper_1 = require("../../common/helpers/input.helper");
|
|
9
9
|
const service_helper_1 = require("../../common/helpers/service.helper");
|
|
10
|
-
const
|
|
10
|
+
const core_file_info_model_1 = require("./core-file-info.model");
|
|
11
11
|
class CoreFileService {
|
|
12
|
-
constructor(connection,
|
|
12
|
+
constructor(connection, bucketName = 'fs') {
|
|
13
13
|
this.connection = connection;
|
|
14
|
-
this.files = (0, mongoose_gridfs_1.createBucket)({
|
|
14
|
+
this.files = (0, mongoose_gridfs_1.createBucket)({ bucketName, connection });
|
|
15
15
|
}
|
|
16
|
-
createFile(file, serviceOptions) {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
async createFile(file, serviceOptions) {
|
|
17
|
+
if (!(await this.checkRights(file, { ...serviceOptions, checkInputType: 'file' }))) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return await new Promise(async (resolve, reject) => {
|
|
21
|
+
const { filename, mimetype, encoding, createReadStream } = await file;
|
|
19
22
|
const readStream = createReadStream();
|
|
20
23
|
const options = { filename, contentType: mimetype };
|
|
21
24
|
this.files.writeFile(options, readStream, (error, fileInfo) => {
|
|
@@ -24,14 +27,21 @@ class CoreFileService {
|
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
async createFiles(files, serviceOptions) {
|
|
30
|
+
if (!(await this.checkRights(files, { ...serviceOptions, checkInputType: 'files' }))) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
console.log(files);
|
|
27
34
|
const promises = [];
|
|
28
35
|
for (const file of files) {
|
|
29
36
|
promises.push(this.createFile(file, serviceOptions));
|
|
30
37
|
}
|
|
31
38
|
return await Promise.all(promises);
|
|
32
39
|
}
|
|
33
|
-
findFileInfo(filterArgs, serviceOptions) {
|
|
34
|
-
|
|
40
|
+
async findFileInfo(filterArgs, serviceOptions) {
|
|
41
|
+
if (!(await this.checkRights(filterArgs, { ...serviceOptions, checkInputType: 'filterArgs' }))) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return await new Promise((resolve, reject) => {
|
|
35
45
|
const filterQuery = (0, filter_helper_1.convertFilterArgsToQuery)(filterArgs);
|
|
36
46
|
const cursor = this.files.find(filterQuery[0], filterQuery[1]);
|
|
37
47
|
if (!cursor) {
|
|
@@ -42,60 +52,87 @@ class CoreFileService {
|
|
|
42
52
|
});
|
|
43
53
|
});
|
|
44
54
|
}
|
|
45
|
-
getFileInfo(id, serviceOptions) {
|
|
46
|
-
|
|
55
|
+
async getFileInfo(id, serviceOptions) {
|
|
56
|
+
if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return await new Promise((resolve, reject) => {
|
|
47
60
|
this.files.findById((0, db_helper_1.getObjectIds)(id), (error, fileInfo) => {
|
|
48
61
|
error ? reject(error) : resolve(this.prepareOutput(fileInfo, serviceOptions));
|
|
49
62
|
});
|
|
50
63
|
});
|
|
51
64
|
}
|
|
52
|
-
getFileInfoByName(filename, serviceOptions) {
|
|
53
|
-
|
|
65
|
+
async getFileInfoByName(filename, serviceOptions) {
|
|
66
|
+
if (!(await this.checkRights(filename, { ...serviceOptions, checkInputType: 'filename' }))) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return await new Promise((resolve, reject) => {
|
|
54
70
|
this.files.findOne({ filename }, (error, fileInfo) => {
|
|
55
71
|
error ? reject(error) : resolve(this.prepareOutput(fileInfo, serviceOptions));
|
|
56
72
|
});
|
|
57
73
|
});
|
|
58
74
|
}
|
|
59
|
-
getFileStream(id,
|
|
60
|
-
|
|
75
|
+
async getFileStream(id, serviceOptions) {
|
|
76
|
+
if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return this.files.openDownloadStream((0, db_helper_1.getObjectIds)(id));
|
|
61
80
|
}
|
|
62
|
-
getFileStreamByName(filename) {
|
|
81
|
+
async getFileStreamByName(filename, serviceOptions) {
|
|
82
|
+
if (!(await this.checkRights(filename, { ...serviceOptions, checkInputType: 'filename' }))) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
63
85
|
return this.files.readFile({ filename });
|
|
64
86
|
}
|
|
65
|
-
getBuffer(id) {
|
|
66
|
-
|
|
87
|
+
async getBuffer(id, serviceOptions) {
|
|
88
|
+
if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return await new Promise((resolve, reject) => {
|
|
67
92
|
this.files.readFile({ _id: (0, db_helper_1.getObjectIds)(id) }, (error, buffer) => {
|
|
68
93
|
error ? reject(error) : resolve(buffer);
|
|
69
94
|
});
|
|
70
95
|
});
|
|
71
96
|
}
|
|
72
|
-
getBufferByName(filename) {
|
|
73
|
-
|
|
97
|
+
async getBufferByName(filename, serviceOptions) {
|
|
98
|
+
if (!(await this.checkRights(filename, { ...serviceOptions, checkInputType: 'filename' }))) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return await new Promise((resolve, reject) => {
|
|
74
102
|
this.files.readFile({ filename }, (error, buffer) => {
|
|
75
103
|
error ? reject(error) : resolve(buffer);
|
|
76
104
|
});
|
|
77
105
|
});
|
|
78
106
|
}
|
|
79
|
-
deleteFile(id, serviceOptions) {
|
|
80
|
-
|
|
107
|
+
async deleteFile(id, serviceOptions) {
|
|
108
|
+
if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
return await new Promise((resolve, reject) => {
|
|
81
112
|
return this.files.unlink((0, db_helper_1.getObjectIds)(id), (error, fileInfo) => {
|
|
82
113
|
error ? reject(error) : resolve(this.prepareOutput(fileInfo, serviceOptions));
|
|
83
114
|
});
|
|
84
115
|
});
|
|
85
116
|
}
|
|
86
117
|
async deleteFileByName(filename, serviceOptions) {
|
|
118
|
+
if (!(await this.checkRights(filename, { ...serviceOptions, checkInputType: 'filename' }))) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
87
121
|
const fileInfo = await this.getFileInfoByName(filename);
|
|
88
122
|
if (!fileInfo) {
|
|
89
123
|
throw new common_1.NotFoundException('File not found with filename ' + filename);
|
|
90
124
|
}
|
|
91
125
|
return await this.deleteFile(fileInfo.id, serviceOptions);
|
|
92
126
|
}
|
|
127
|
+
checkRights(input, options) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
93
130
|
async prepareOutput(fileInfo, options) {
|
|
94
131
|
if (!fileInfo) {
|
|
95
132
|
return fileInfo;
|
|
96
133
|
}
|
|
97
134
|
this.setId(fileInfo);
|
|
98
|
-
fileInfo = await (0, service_helper_1.prepareOutput)(fileInfo, { targetModel:
|
|
135
|
+
fileInfo = await (0, service_helper_1.prepareOutput)(fileInfo, { targetModel: core_file_info_model_1.CoreFileInfo });
|
|
99
136
|
return (0, input_helper_1.check)(fileInfo, options?.currentUser, { roles: options?.roles });
|
|
100
137
|
}
|
|
101
138
|
setId(fileInfo) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-file.service.js","sourceRoot":"","sources":["../../../../src/core/modules/file/core-file.service.ts"],"names":[],"mappings":";;;AAAA,2CAAmD;AAGnD,qDAAmF;AAEnF,8DAA4E;AAC5E,sEAA8E;AAC9E,oEAA0D;AAC1D,wEAAoE;
|
|
1
|
+
{"version":3,"file":"core-file.service.js","sourceRoot":"","sources":["../../../../src/core/modules/file/core-file.service.ts"],"names":[],"mappings":";;;AAAA,2CAAmD;AAGnD,qDAAmF;AAEnF,8DAA4E;AAC5E,sEAA8E;AAC9E,oEAA0D;AAC1D,wEAAoE;AAEpE,iEAAsD;AAYtD,MAAsB,eAAe;IAMnC,YAAyC,UAAsB,EAAE,UAAU,GAAG,IAAI;QAAzC,eAAU,GAAV,UAAU,CAAY;QAC7D,IAAI,CAAC,KAAK,GAAG,IAAA,8BAAY,EAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IACxD,CAAC;IAKD,KAAK,CAAC,UAAU,CAAC,IAA8B,EAAE,cAAmC;QAClF,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,GAAG,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE;YAClF,OAAO,IAAI,CAAC;SACb;QACD,OAAO,MAAM,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAI,CAAC;YACtE,MAAM,UAAU,GAAG,gBAAgB,EAAE,CA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AAO,IAAA,oBAAK,EAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;IAKS,KAAK,CAAC,QAAuC;QACrD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;oBAC5B,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAY,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBAClC;YACH,CAAC,CAAC,CAAC;SACJ;aAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YACvC,QAAQ,CAAC,EAAE,GAAG,IAAA,wBAAY,EAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SAC1C;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlND,0CAkNC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export * from './core/common/services/template.service';
|
|
|
48
48
|
export * from './core/common/types/core-model-constructor.type';
|
|
49
49
|
export * from './core/common/types/field-selection.type';
|
|
50
50
|
export * from './core/common/types/ids.type';
|
|
51
|
+
export * from './core/common/types/maybe-promise.type';
|
|
51
52
|
export * from './core/common/types/plain-input.type';
|
|
52
53
|
export * from './core/common/types/require-only-one.type';
|
|
53
54
|
export * from './core/common/types/required-at-least-one.type';
|
|
@@ -66,8 +67,10 @@ export * from './core/modules/auth/core-auth.resolver';
|
|
|
66
67
|
export * from './core/modules/auth/jwt.strategy';
|
|
67
68
|
export * from './core/modules/file/interfaces/file-service-options.interface';
|
|
68
69
|
export * from './core/modules/file/interfaces/file-upload.interface';
|
|
70
|
+
export * from './core/modules/file/core-file.controller';
|
|
71
|
+
export * from './core/modules/file/core-file.resolver';
|
|
69
72
|
export * from './core/modules/file/core-file.service';
|
|
70
|
-
export * from './core/modules/file/file-info.
|
|
73
|
+
export * from './core/modules/file/core-file-info.model';
|
|
71
74
|
export * from './core/modules/user/inputs/core-user.input';
|
|
72
75
|
export * from './core/modules/user/inputs/core-user-create.input';
|
|
73
76
|
export * from './core/modules/user/core-user.model';
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ __exportStar(require("./core/common/services/template.service"), exports);
|
|
|
64
64
|
__exportStar(require("./core/common/types/core-model-constructor.type"), exports);
|
|
65
65
|
__exportStar(require("./core/common/types/field-selection.type"), exports);
|
|
66
66
|
__exportStar(require("./core/common/types/ids.type"), exports);
|
|
67
|
+
__exportStar(require("./core/common/types/maybe-promise.type"), exports);
|
|
67
68
|
__exportStar(require("./core/common/types/plain-input.type"), exports);
|
|
68
69
|
__exportStar(require("./core/common/types/require-only-one.type"), exports);
|
|
69
70
|
__exportStar(require("./core/common/types/required-at-least-one.type"), exports);
|
|
@@ -82,8 +83,10 @@ __exportStar(require("./core/modules/auth/core-auth.resolver"), exports);
|
|
|
82
83
|
__exportStar(require("./core/modules/auth/jwt.strategy"), exports);
|
|
83
84
|
__exportStar(require("./core/modules/file/interfaces/file-service-options.interface"), exports);
|
|
84
85
|
__exportStar(require("./core/modules/file/interfaces/file-upload.interface"), exports);
|
|
86
|
+
__exportStar(require("./core/modules/file/core-file.controller"), exports);
|
|
87
|
+
__exportStar(require("./core/modules/file/core-file.resolver"), exports);
|
|
85
88
|
__exportStar(require("./core/modules/file/core-file.service"), exports);
|
|
86
|
-
__exportStar(require("./core/modules/file/file-info.
|
|
89
|
+
__exportStar(require("./core/modules/file/core-file-info.model"), exports);
|
|
87
90
|
__exportStar(require("./core/modules/user/inputs/core-user.input"), exports);
|
|
88
91
|
__exportStar(require("./core/modules/user/inputs/core-user-create.input"), exports);
|
|
89
92
|
__exportStar(require("./core/modules/user/core-user.model"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,gDAA8B;AAK9B,iEAA+C;AAC/C,qEAAmD;AACnD,kFAAgE;AAChE,+EAA6D;AAC7D,gFAA8D;AAC9D,2EAAyD;AACzD,+EAA6D;AAC7D,4EAA0D;AAC1D,wEAAsD;AACtD,gEAA8C;AAC9C,sEAAoD;AACpD,sEAAoD;AACpD,uEAAqD;AACrD,kEAAgD;AAChD,oEAAkD;AAClD,sEAAoD;AACpD,uEAAqD;AACrD,qEAAmD;AACnD,qEAAmD;AACnD,uEAAqD;AACrD,6EAA2D;AAC3D,wEAAsD;AACtD,oEAAkD;AAClD,2EAAyD;AACzD,kEAAgD;AAChD,wFAAsE;AACtE,4FAA0E;AAC1E,qFAAmE;AACnE,2FAAyE;AACzE,4FAA0E;AAC1E,sFAAoE;AACpE,oFAAkE;AAClE,qFAAmE;AACnE,wEAAsD;AACtD,8EAA4D;AAC5D,uEAAqD;AACrD,4EAA0D;AAC1D,mEAAiD;AACjD,oEAAkD;AAClD,oEAAkD;AAClD,wEAAsD;AACtD,sEAAoD;AACpD,uEAAqD;AACrD,yEAAuD;AACvD,wEAAsD;AACtD,0EAAwD;AACxD,kFAAgE;AAChE,2EAAyD;AACzD,+DAA6C;AAC7C,uEAAqD;AACrD,4EAA0D;AAC1D,iFAA+D;AAC/D,+EAA6D;AAM7D,wEAAsD;AACtD,yEAAuD;AACvD,qFAAmE;AACnE,qFAAmE;AACnE,0FAAwE;AACxE,uFAAqE;AACrE,iFAA+D;AAC/D,sFAAoE;AACpE,sEAAoD;AACpD,uEAAqD;AACrD,yEAAuD;AACvD,mEAAiD;AAMjD,gGAA8E;AAC9E,uFAAqE;AACrE,wEAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,gDAA8B;AAK9B,iEAA+C;AAC/C,qEAAmD;AACnD,kFAAgE;AAChE,+EAA6D;AAC7D,gFAA8D;AAC9D,2EAAyD;AACzD,+EAA6D;AAC7D,4EAA0D;AAC1D,wEAAsD;AACtD,gEAA8C;AAC9C,sEAAoD;AACpD,sEAAoD;AACpD,uEAAqD;AACrD,kEAAgD;AAChD,oEAAkD;AAClD,sEAAoD;AACpD,uEAAqD;AACrD,qEAAmD;AACnD,qEAAmD;AACnD,uEAAqD;AACrD,6EAA2D;AAC3D,wEAAsD;AACtD,oEAAkD;AAClD,2EAAyD;AACzD,kEAAgD;AAChD,wFAAsE;AACtE,4FAA0E;AAC1E,qFAAmE;AACnE,2FAAyE;AACzE,4FAA0E;AAC1E,sFAAoE;AACpE,oFAAkE;AAClE,qFAAmE;AACnE,wEAAsD;AACtD,8EAA4D;AAC5D,uEAAqD;AACrD,4EAA0D;AAC1D,mEAAiD;AACjD,oEAAkD;AAClD,oEAAkD;AAClD,wEAAsD;AACtD,sEAAoD;AACpD,uEAAqD;AACrD,yEAAuD;AACvD,wEAAsD;AACtD,0EAAwD;AACxD,kFAAgE;AAChE,2EAAyD;AACzD,+DAA6C;AAC7C,yEAAuD;AACvD,uEAAqD;AACrD,4EAA0D;AAC1D,iFAA+D;AAC/D,+EAA6D;AAM7D,wEAAsD;AACtD,yEAAuD;AACvD,qFAAmE;AACnE,qFAAmE;AACnE,0FAAwE;AACxE,uFAAqE;AACrE,iFAA+D;AAC/D,sFAAoE;AACpE,sEAAoD;AACpD,uEAAqD;AACrD,yEAAuD;AACvD,mEAAiD;AAMjD,gGAA8E;AAC9E,uFAAqE;AACrE,2EAAyD;AACzD,yEAAuD;AACvD,wEAAsD;AACtD,2EAAyD;AAMzD,6EAA2D;AAC3D,oFAAkE;AAClE,sEAAoD;AACpD,wEAAsD;AAMtD,qDAAmC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/helpers" />
|
|
9
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
10
|
+
/// <reference types="mongoose/types/indizes" />
|
|
11
|
+
/// <reference types="mongoose/types/models" />
|
|
12
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
13
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
14
|
+
/// <reference types="mongoose/types/populate" />
|
|
15
|
+
/// <reference types="mongoose/types/query" />
|
|
16
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
17
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
18
|
+
/// <reference types="mongoose/types/session" />
|
|
19
|
+
/// <reference types="mongoose/types/types" />
|
|
20
|
+
/// <reference types="mongoose/types/utility" />
|
|
21
|
+
/// <reference types="mongoose/types/validation" />
|
|
22
|
+
/// <reference types="mongoose" />
|
|
23
|
+
import { CoreFileInfo } from '../../../core/modules/file/core-file-info.model';
|
|
24
|
+
export declare class FileInfo extends CoreFileInfo {
|
|
25
|
+
}
|
|
26
|
+
export declare const FileInfoSchema: import("mongoose").Schema<FileInfo, import("mongoose").Model<FileInfo, any, any, any>, {}, {}, any>;
|
|
@@ -0,0 +1,21 @@
|
|
|
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.FileInfoSchema = exports.FileInfo = void 0;
|
|
10
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
11
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
12
|
+
const core_file_info_model_1 = require("../../../core/modules/file/core-file-info.model");
|
|
13
|
+
let FileInfo = class FileInfo extends core_file_info_model_1.CoreFileInfo {
|
|
14
|
+
};
|
|
15
|
+
FileInfo = __decorate([
|
|
16
|
+
(0, graphql_1.ObjectType)({ description: 'Information about file' }),
|
|
17
|
+
(0, mongoose_1.Schema)({ collection: 'fs.files' })
|
|
18
|
+
], FileInfo);
|
|
19
|
+
exports.FileInfo = FileInfo;
|
|
20
|
+
exports.FileInfoSchema = mongoose_1.SchemaFactory.createForClass(FileInfo);
|
|
21
|
+
//# sourceMappingURL=file-info.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-info.model.js","sourceRoot":"","sources":["../../../../src/server/modules/file/file-info.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6CAA6C;AAC7C,+CAA2E;AAC3E,0FAA+E;AAO/E,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,mCAAY;CAAG,CAAA;AAAhC,QAAQ;IAFpB,IAAA,oBAAU,EAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;IACrD,IAAA,iBAAc,EAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;GAC9B,QAAQ,CAAwB;AAAhC,4BAAQ;AAKR,QAAA,cAAc,GAAG,wBAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CoreFileController } from '../../../core/modules/file/core-file.controller';
|
|
2
2
|
import { FileService } from './file.service';
|
|
3
|
-
export declare class FileController {
|
|
3
|
+
export declare class FileController extends CoreFileController {
|
|
4
4
|
protected fileService: FileService;
|
|
5
5
|
constructor(fileService: FileService);
|
|
6
6
|
uploadFiles(files: any, fields: any): void;
|
|
7
|
-
getFile(filename: string, res: any, user: User): Promise<any>;
|
|
8
7
|
}
|