@builder6/files 0.16.3-alpha.9 → 0.16.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.
|
@@ -13,14 +13,13 @@ const files_service_1 = require("./files.service");
|
|
|
13
13
|
const core_1 = require("@builder6/core");
|
|
14
14
|
const files_moleculer_1 = require("./files.moleculer");
|
|
15
15
|
const core_2 = require("@builder6/core");
|
|
16
|
-
const cms_files_controller_1 = require("./cms_files.controller");
|
|
17
16
|
let FilesModule = class FilesModule {
|
|
18
17
|
};
|
|
19
18
|
exports.FilesModule = FilesModule;
|
|
20
19
|
exports.FilesModule = FilesModule = __decorate([
|
|
21
20
|
(0, common_1.Module)({
|
|
22
21
|
imports: [core_2.AuthModule, core_1.MongodbModule],
|
|
23
|
-
controllers: [files_controller_1.FilesController
|
|
22
|
+
controllers: [files_controller_1.FilesController],
|
|
24
23
|
providers: [files_service_1.FilesService, files_moleculer_1.FilesMoleculer],
|
|
25
24
|
exports: [files_service_1.FilesService],
|
|
26
25
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.module.js","sourceRoot":"","sources":["../../src/files/files.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yDAAqD;AACrD,mDAA+C;AAC/C,yCAA+C;AAC/C,uDAAmD;AACnD,yCAA4C;
|
|
1
|
+
{"version":3,"file":"files.module.js","sourceRoot":"","sources":["../../src/files/files.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yDAAqD;AACrD,mDAA+C;AAC/C,yCAA+C;AAC/C,uDAAmD;AACnD,yCAA4C;AAQrC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IANvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,iBAAU,EAAE,oBAAa,CAAC;QACpC,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,EAAE,gCAAc,CAAC;QACzC,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder6/files",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"build:watch": "rimraf dist && tsc --watch"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@builder6/core": "0.16.
|
|
15
|
+
"@builder6/core": "0.16.4",
|
|
16
16
|
"nodemailer": "^6.9.16"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "9ebc74f72ab3139786046af17e11df8bb5b58a67"
|
|
22
22
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FilesService } from './files.service';
|
|
2
|
-
import { Request } from 'express';
|
|
3
|
-
import { AuthService, MongodbService } from '@builder6/core';
|
|
4
|
-
export declare class CMSFilesController {
|
|
5
|
-
private readonly filesService;
|
|
6
|
-
private readonly authService;
|
|
7
|
-
private mongodbService;
|
|
8
|
-
constructor(filesService: FilesService, authService: AuthService, mongodbService: MongodbService);
|
|
9
|
-
uploadCMSFile(file: Express.Multer.File, object_name: string, record_id: string, parent: string, description: string, req: Request): Promise<{
|
|
10
|
-
version_id: any;
|
|
11
|
-
size: any;
|
|
12
|
-
}>;
|
|
13
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
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.CMSFilesController = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const platform_express_1 = require("@nestjs/platform-express");
|
|
18
|
-
const files_service_1 = require("./files.service");
|
|
19
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
20
|
-
const core_1 = require("@builder6/core");
|
|
21
|
-
const uuid_1 = require("uuid");
|
|
22
|
-
const collectionName = 'cfs.files.filerecord';
|
|
23
|
-
let CMSFilesController = class CMSFilesController {
|
|
24
|
-
constructor(filesService, authService, mongodbService) {
|
|
25
|
-
this.filesService = filesService;
|
|
26
|
-
this.authService = authService;
|
|
27
|
-
this.mongodbService = mongodbService;
|
|
28
|
-
}
|
|
29
|
-
async uploadCMSFile(file, object_name, record_id, parent, description, req) {
|
|
30
|
-
console.log('cms file upload...');
|
|
31
|
-
const newParentId = (0, uuid_1.v4)();
|
|
32
|
-
const user = req['user'];
|
|
33
|
-
if (!file) {
|
|
34
|
-
throw new Error('未找到上传的文件');
|
|
35
|
-
}
|
|
36
|
-
const fileRecord = await this.filesService.uploadFile(collectionName, file, {
|
|
37
|
-
object_name,
|
|
38
|
-
record_id,
|
|
39
|
-
parent: parent || newParentId,
|
|
40
|
-
owner: user._id,
|
|
41
|
-
space: user.space,
|
|
42
|
-
});
|
|
43
|
-
const filename = fileRecord.original.name;
|
|
44
|
-
const size = fileRecord.original.size;
|
|
45
|
-
const name_split = filename.split('.');
|
|
46
|
-
const extention = name_split.pop();
|
|
47
|
-
if (parent) {
|
|
48
|
-
await this.mongodbService.findOneAndUpdate('cms_files', { _id: parent }, {
|
|
49
|
-
$set: {
|
|
50
|
-
name: filename,
|
|
51
|
-
extention: extention,
|
|
52
|
-
size: size,
|
|
53
|
-
modified: new Date(),
|
|
54
|
-
modified_by: user._id,
|
|
55
|
-
},
|
|
56
|
-
$push: {
|
|
57
|
-
versions: {
|
|
58
|
-
$each: [fileRecord._id],
|
|
59
|
-
$position: 0,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
}, { returnDocument: 'after' });
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
await this.mongodbService.insertOne('cms_files', {
|
|
66
|
-
_id: newParentId,
|
|
67
|
-
name: filename,
|
|
68
|
-
description: description,
|
|
69
|
-
extention: extention,
|
|
70
|
-
size: size,
|
|
71
|
-
versions: [fileRecord._id],
|
|
72
|
-
parent: {
|
|
73
|
-
o: object_name,
|
|
74
|
-
ids: [record_id],
|
|
75
|
-
},
|
|
76
|
-
owner: user._id,
|
|
77
|
-
space: user.space,
|
|
78
|
-
created: new Date(),
|
|
79
|
-
created_by: user._id,
|
|
80
|
-
modified: new Date(),
|
|
81
|
-
modified_by: user._id,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
version_id: fileRecord._id,
|
|
86
|
-
size: size,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
exports.CMSFilesController = CMSFilesController;
|
|
91
|
-
__decorate([
|
|
92
|
-
(0, common_1.Post)('upload'),
|
|
93
|
-
(0, common_1.UseGuards)(core_1.AuthGuard),
|
|
94
|
-
(0, common_1.HttpCode)(200),
|
|
95
|
-
(0, swagger_1.ApiOperation)({ summary: 'Upload a cms file' }),
|
|
96
|
-
(0, swagger_1.ApiConsumes)('multipart/form-data'),
|
|
97
|
-
(0, swagger_1.ApiBody)({
|
|
98
|
-
schema: {
|
|
99
|
-
type: 'object',
|
|
100
|
-
properties: {
|
|
101
|
-
file: {
|
|
102
|
-
type: 'string',
|
|
103
|
-
format: 'binary',
|
|
104
|
-
},
|
|
105
|
-
object_name: {
|
|
106
|
-
type: 'string',
|
|
107
|
-
description: 'Object Name',
|
|
108
|
-
default: '',
|
|
109
|
-
},
|
|
110
|
-
record_id: {
|
|
111
|
-
type: 'string',
|
|
112
|
-
description: 'Record id',
|
|
113
|
-
default: '',
|
|
114
|
-
},
|
|
115
|
-
parent: {
|
|
116
|
-
type: 'string',
|
|
117
|
-
description: 'Parent record id',
|
|
118
|
-
default: '',
|
|
119
|
-
},
|
|
120
|
-
description: {
|
|
121
|
-
type: 'string',
|
|
122
|
-
description: 'File description',
|
|
123
|
-
default: '',
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
}),
|
|
128
|
-
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file')),
|
|
129
|
-
__param(0, (0, common_1.UploadedFile)()),
|
|
130
|
-
__param(1, (0, common_1.Body)('object_name')),
|
|
131
|
-
__param(2, (0, common_1.Body)('record_id')),
|
|
132
|
-
__param(3, (0, common_1.Body)('parent')),
|
|
133
|
-
__param(4, (0, common_1.Body)('description')),
|
|
134
|
-
__param(5, (0, common_1.Req)()),
|
|
135
|
-
__metadata("design:type", Function),
|
|
136
|
-
__metadata("design:paramtypes", [Object, String, String, String, String, Object]),
|
|
137
|
-
__metadata("design:returntype", Promise)
|
|
138
|
-
], CMSFilesController.prototype, "uploadCMSFile", null);
|
|
139
|
-
exports.CMSFilesController = CMSFilesController = __decorate([
|
|
140
|
-
(0, common_1.Controller)('api/v6/cms_files/'),
|
|
141
|
-
__metadata("design:paramtypes", [files_service_1.FilesService,
|
|
142
|
-
core_1.AuthService,
|
|
143
|
-
core_1.MongodbService])
|
|
144
|
-
], CMSFilesController);
|
|
145
|
-
//# sourceMappingURL=cms_files.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cms_files.controller.js","sourceRoot":"","sources":["../../src/files/cms_files.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAcwB;AACxB,+DAA2D;AAC3D,mDAA+C;AAE/C,6CAA+E;AAC/E,yCAAwE;AACxE,+BAAoC;AAEpC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAGvC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YACmB,YAA0B,EAC1B,WAAwB,EACjC,cAA8B;QAFrB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,gBAAW,GAAX,WAAW,CAAa;QACjC,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAuCE,AAAN,KAAK,CAAC,aAAa,CACD,IAAyB,EACpB,WAAmB,EACrB,SAAiB,EACpB,MAAc,EACT,WAAmB,EACjC,GAAY;QAEnB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClC,MAAM,WAAW,GAAG,IAAA,SAAM,GAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;QACD,MAAM,UAAU,GAAQ,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CACxD,cAAc,EACd,IAAI,EACJ;YACE,WAAW;YACX,SAAS;YACT,MAAM,EAAE,MAAM,IAAI,WAAW;YAC7B,KAAK,EAAE,IAAI,CAAC,GAAG;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,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