@builder6/core 0.6.5 → 0.7.1
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/config/default.config.d.ts +4 -0
- package/dist/config/default.config.js +6 -0
- package/dist/config/default.config.js.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.js +77 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/moleculer.config.d.ts +63 -0
- package/dist/config/moleculer.config.js +67 -0
- package/dist/config/moleculer.config.js.map +1 -0
- package/dist/files/files.controller.d.ts +11 -0
- package/dist/files/files.controller.js +170 -0
- package/dist/files/files.controller.js.map +1 -0
- package/dist/files/files.controller.spec.d.ts +1 -0
- package/dist/files/files.controller.spec.js +17 -0
- package/dist/files/files.controller.spec.js.map +1 -0
- package/dist/files/files.module.d.ts +2 -0
- package/dist/files/files.module.js +27 -0
- package/dist/files/files.module.js.map +1 -0
- package/dist/files/files.moleculer.d.ts +10 -0
- package/dist/files/files.moleculer.js +50 -0
- package/dist/files/files.moleculer.js.map +1 -0
- package/dist/files/files.service.d.ts +31 -0
- package/dist/files/files.service.js +210 -0
- package/dist/files/files.service.js.map +1 -0
- package/dist/files/files.service.spec.d.ts +1 -0
- package/dist/files/files.service.spec.js +17 -0
- package/dist/files/files.service.spec.js.map +1 -0
- package/dist/files/index.d.ts +3 -0
- package/dist/files/index.js +20 -0
- package/dist/files/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +20 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/moleculer.service.d.ts +11 -0
- package/dist/plugin/moleculer.service.js +96 -0
- package/dist/plugin/moleculer.service.js.map +1 -0
- package/dist/plugin/plugin.module.d.ts +22 -0
- package/dist/plugin/plugin.module.js +220 -0
- package/dist/plugin/plugin.module.js.map +1 -0
- package/dist/plugin/plugin.service.d.ts +2 -0
- package/dist/plugin/plugin.service.js +17 -0
- package/dist/plugin/plugin.service.js.map +1 -0
- package/dist/plugin/plugin.service.spec.d.ts +1 -0
- package/dist/plugin/plugin.service.spec.js +17 -0
- package/dist/plugin/plugin.service.spec.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.config.js","sourceRoot":"","sources":["../../src/config/default.config.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,MAAM,EAAE,EAAE;CACX,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnvConfigs = getEnvConfigs;
|
|
4
|
+
exports.getDbConfigs = getDbConfigs;
|
|
5
|
+
exports.getFileConfigs = getFileConfigs;
|
|
6
|
+
exports.getConfigs = getConfigs;
|
|
7
|
+
exports.getMoleculerConfigs = getMoleculerConfigs;
|
|
8
|
+
const dotenvFlow = require("dotenv-flow");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const default_config_1 = require("./default.config");
|
|
11
|
+
const moleculer_config_1 = require("./moleculer.config");
|
|
12
|
+
dotenvFlow.config({
|
|
13
|
+
path: process.cwd(),
|
|
14
|
+
silent: true,
|
|
15
|
+
});
|
|
16
|
+
process.env.B6_ROOT_URL = process.env.B6_ROOT_URL || process.env.ROOT_URL;
|
|
17
|
+
process.env.B6_MONGO_URL = process.env.B6_MONGO_URL || process.env.MONGO_URL;
|
|
18
|
+
process.env.B6_TRANSPORTER =
|
|
19
|
+
process.env.B6_TRANSPORTER ||
|
|
20
|
+
process.env.STEEDOS_TRANSPORTER ||
|
|
21
|
+
process.env.TRANSPORTER;
|
|
22
|
+
process.env.B6_HOME = process.env.B6_HOME || process.cwd();
|
|
23
|
+
process.env.B6_PLUGIN_DIR =
|
|
24
|
+
process.env.B6_PLUGIN_DIR || path.join(process.cwd(), 'plugins');
|
|
25
|
+
function parseEnvToJSON(env, prefixes) {
|
|
26
|
+
const result = {};
|
|
27
|
+
Object.keys(env).forEach((key) => {
|
|
28
|
+
const hasValidPrefix = prefixes.some((prefix) => key.startsWith(prefix));
|
|
29
|
+
if (!hasValidPrefix) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const strippedKey = key
|
|
33
|
+
.replace(new RegExp(`^(${prefixes.join('|')})`), '')
|
|
34
|
+
.toLowerCase();
|
|
35
|
+
const keys = strippedKey.split('_');
|
|
36
|
+
let current = result;
|
|
37
|
+
keys.forEach((k, index) => {
|
|
38
|
+
if (index === keys.length - 1) {
|
|
39
|
+
current[k] = isNaN(env[key]) ? env[key] : Number(env[key]);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
current[k] = current[k] || {};
|
|
43
|
+
current = current[k];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function getEnvConfigs() {
|
|
50
|
+
const env = parseEnvToJSON(process.env, ['STEEDOS_', 'B6_']);
|
|
51
|
+
return env;
|
|
52
|
+
}
|
|
53
|
+
async function getDbConfigs() {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
function getFileConfigs() {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
function getConfigs() {
|
|
60
|
+
const env = getEnvConfigs();
|
|
61
|
+
const file = getFileConfigs();
|
|
62
|
+
return {
|
|
63
|
+
...default_config_1.default,
|
|
64
|
+
...env,
|
|
65
|
+
...file,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function getMoleculerConfigs() {
|
|
69
|
+
const env = getEnvConfigs();
|
|
70
|
+
const file = getFileConfigs();
|
|
71
|
+
return {
|
|
72
|
+
...moleculer_config_1.default,
|
|
73
|
+
...env,
|
|
74
|
+
...file
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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a,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAC9B,OAAO;QACL,GAAG,wBAAa;QAChB,GAAG,GAAG;QACN,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAED,SAAgB,mBAAmB;IACjC,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAC9B,OAAO;QACL,GAAG,0BAAe;QAClB,GAAG,GAAG;QACN,GAAG,IAAI;KACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
namespace: string;
|
|
3
|
+
nodeID: any;
|
|
4
|
+
metadata: {};
|
|
5
|
+
logger: {
|
|
6
|
+
type: string;
|
|
7
|
+
options: {
|
|
8
|
+
level: string;
|
|
9
|
+
colors: boolean;
|
|
10
|
+
moduleColors: boolean;
|
|
11
|
+
formatter: string;
|
|
12
|
+
objectPrinter: any;
|
|
13
|
+
autoPadding: boolean;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
transporter: string;
|
|
17
|
+
cacher: string;
|
|
18
|
+
serializer: string;
|
|
19
|
+
requestTimeout: number;
|
|
20
|
+
retryPolicy: {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
};
|
|
23
|
+
maxCallLevel: number;
|
|
24
|
+
heartbeatInterval: number;
|
|
25
|
+
heartbeatTimeout: number;
|
|
26
|
+
contextParamsCloning: boolean;
|
|
27
|
+
tracking: {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
};
|
|
30
|
+
disableBalancer: boolean;
|
|
31
|
+
registry: {
|
|
32
|
+
strategy: string;
|
|
33
|
+
preferLocal: boolean;
|
|
34
|
+
};
|
|
35
|
+
circuitBreaker: {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
threshold: number;
|
|
38
|
+
minRequestCount: number;
|
|
39
|
+
windowTime: number;
|
|
40
|
+
halfOpenTime: number;
|
|
41
|
+
check: (err: any) => boolean;
|
|
42
|
+
};
|
|
43
|
+
bulkhead: {
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
concurrency: number;
|
|
46
|
+
maxQueueSize: number;
|
|
47
|
+
};
|
|
48
|
+
validator: boolean;
|
|
49
|
+
errorHandler: any;
|
|
50
|
+
metrics: {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
};
|
|
53
|
+
tracing: {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
};
|
|
56
|
+
middlewares: any[];
|
|
57
|
+
replCommands: any;
|
|
58
|
+
skipProcessEventRegistration: boolean;
|
|
59
|
+
created(broker: any): void;
|
|
60
|
+
started(broker: any): void;
|
|
61
|
+
stopped(broker: any): void;
|
|
62
|
+
};
|
|
63
|
+
export default _default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
namespace: 'steedos',
|
|
5
|
+
nodeID: null,
|
|
6
|
+
metadata: {},
|
|
7
|
+
logger: {
|
|
8
|
+
type: 'Console',
|
|
9
|
+
options: {
|
|
10
|
+
level: 'info',
|
|
11
|
+
colors: true,
|
|
12
|
+
moduleColors: false,
|
|
13
|
+
formatter: '[MO] {timestamp} {level} [{mod}] {msg}',
|
|
14
|
+
objectPrinter: null,
|
|
15
|
+
autoPadding: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
transporter: process.env.B6_TRANSPORTER,
|
|
19
|
+
cacher: process.env.B6_CACHER,
|
|
20
|
+
serializer: 'JSON',
|
|
21
|
+
requestTimeout: 0,
|
|
22
|
+
retryPolicy: {
|
|
23
|
+
enabled: false,
|
|
24
|
+
},
|
|
25
|
+
maxCallLevel: 100,
|
|
26
|
+
heartbeatInterval: 10,
|
|
27
|
+
heartbeatTimeout: 30,
|
|
28
|
+
contextParamsCloning: false,
|
|
29
|
+
tracking: {
|
|
30
|
+
enabled: false,
|
|
31
|
+
},
|
|
32
|
+
disableBalancer: false,
|
|
33
|
+
registry: {
|
|
34
|
+
strategy: 'RoundRobin',
|
|
35
|
+
preferLocal: true,
|
|
36
|
+
},
|
|
37
|
+
circuitBreaker: {
|
|
38
|
+
enabled: false,
|
|
39
|
+
threshold: 0.5,
|
|
40
|
+
minRequestCount: 20,
|
|
41
|
+
windowTime: 60,
|
|
42
|
+
halfOpenTime: 10000,
|
|
43
|
+
check: (err) => err && err.code >= 500,
|
|
44
|
+
},
|
|
45
|
+
bulkhead: {
|
|
46
|
+
enabled: false,
|
|
47
|
+
concurrency: 10,
|
|
48
|
+
maxQueueSize: 100,
|
|
49
|
+
},
|
|
50
|
+
validator: true,
|
|
51
|
+
errorHandler: null,
|
|
52
|
+
metrics: {
|
|
53
|
+
enabled: false,
|
|
54
|
+
},
|
|
55
|
+
tracing: {
|
|
56
|
+
enabled: false,
|
|
57
|
+
},
|
|
58
|
+
middlewares: [],
|
|
59
|
+
replCommands: null,
|
|
60
|
+
skipProcessEventRegistration: true,
|
|
61
|
+
created(broker) { },
|
|
62
|
+
started(broker) {
|
|
63
|
+
},
|
|
64
|
+
stopped(broker) {
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=moleculer.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moleculer.config.js","sourceRoot":"","sources":["../../src/config/moleculer.config.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAUb,kBAAe;IACb,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,EAAE;IAEZ,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YAEP,KAAK,EAAE,MAAM;YAEb,MAAM,EAAE,IAAI;YAEZ,YAAY,EAAE,KAAK;YAEnB,SAAS,EAAE,wCAAwC;YAEnD,aAAa,EAAE,IAAI;YAEnB,WAAW,EAAE,KAAK;SACnB;KACF;IAED,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;IAEvC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS;IAE7B,UAAU,EAAE,MAAM;IAElB,cAAc,EAAE,CAAC;IAEjB,WAAW,EAAE;QACX,OAAO,EAAE,KAAK;KACf;IAED,YAAY,EAAE,GAAG;IAEjB,iBAAiB,EAAE,EAAE;IACrB,gBAAgB,EAAE,EAAE;IAEpB,oBAAoB,EAAE,KAAK;IAE3B,QAAQ,EAAE;QACR,OAAO,EAAE,KAAK;KACf;IAED,eAAe,EAAE,KAAK;IAEtB,QAAQ,EAAE;QACR,QAAQ,EAAE,YAAY;QACtB,WAAW,EAAE,IAAI;KAClB;IAED,cAAc,EAAE;QACd,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,GAAG;QACd,eAAe,EAAE,EAAE;QACnB,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,KAAK;QACnB,KAAK,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG;KAC5C;IAED,QAAQ,EAAE;QACR,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,GAAG;KAClB;IAED,SAAS,EAAE,IAAI;IAEf,YAAY,EAAE,IAAI;IAElB,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;KACf;IAED,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;KACf;IAED,WAAW,EAAE,EAAE;IAEf,YAAY,EAAE,IAAI;IAElB,4BAA4B,EAAE,IAAI;IAElC,OAAO,CAAC,MAAW,IAAG,CAAC;IAEvB,OAAO,CAAC,MAAW;IAEnB,CAAC;IAED,OAAO,CAAC,MAAW;IAEnB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FilesService } from './files.service';
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
export declare class FilesController {
|
|
4
|
+
private readonly filesService;
|
|
5
|
+
constructor(filesService: FilesService);
|
|
6
|
+
uploadFile(collectionName: string, file: Express.Multer.File, object_name: string, record_id: string, parent: string, req: Request): Promise<object>;
|
|
7
|
+
downloadFile(collectionName: string, fileId: string, fileName: string, res: Response): Promise<void>;
|
|
8
|
+
presignedUrls(collectionName: string, records: string[]): Promise<{
|
|
9
|
+
urls: string[];
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
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.FilesController = 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 auth_guard_1 = require("../auth/auth.guard");
|
|
21
|
+
let FilesController = class FilesController {
|
|
22
|
+
constructor(filesService) {
|
|
23
|
+
this.filesService = filesService;
|
|
24
|
+
}
|
|
25
|
+
async uploadFile(collectionName, file, object_name, record_id, parent, req) {
|
|
26
|
+
const user = req['user'];
|
|
27
|
+
if (!file) {
|
|
28
|
+
throw new Error('未找到上传的文件');
|
|
29
|
+
}
|
|
30
|
+
const fileRecord = await this.filesService.uploadFile(collectionName, file, { object_name, record_id, parent, owner: user._id, space: user.space });
|
|
31
|
+
return fileRecord;
|
|
32
|
+
}
|
|
33
|
+
async downloadFile(collectionName, fileId, fileName, res) {
|
|
34
|
+
try {
|
|
35
|
+
if (this.filesService.cfsStore === 'S3') {
|
|
36
|
+
const s3SignedUrl = await this.filesService.getPreSignedUrl(collectionName, fileId);
|
|
37
|
+
if (s3SignedUrl) {
|
|
38
|
+
return res.redirect(s3SignedUrl);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const fileStream = await this.filesService.downloadFileStream(collectionName, fileId);
|
|
42
|
+
fileStream.pipe(res).on('error', () => {
|
|
43
|
+
throw new common_1.HttpException('文件下载失败', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async presignedUrls(collectionName, records) {
|
|
51
|
+
const urls = await Promise.all(records.map(async (attachmentId) => {
|
|
52
|
+
return this.filesService.getPreSignedUrl(collectionName, attachmentId);
|
|
53
|
+
}));
|
|
54
|
+
return { urls };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.FilesController = FilesController;
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, common_1.Post)(':collectionName'),
|
|
60
|
+
(0, swagger_1.ApiOperation)({ summary: 'Upload a file' }),
|
|
61
|
+
(0, swagger_1.ApiParam)({
|
|
62
|
+
name: 'collectionName',
|
|
63
|
+
required: true,
|
|
64
|
+
type: 'string',
|
|
65
|
+
schema: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
default: 'cfs.files.filerecord',
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
(0, swagger_1.ApiConsumes)('multipart/form-data'),
|
|
71
|
+
(0, swagger_1.ApiBody)({
|
|
72
|
+
schema: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
file: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
format: 'binary',
|
|
78
|
+
},
|
|
79
|
+
object_name: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
description: 'Object Name',
|
|
82
|
+
default: '',
|
|
83
|
+
},
|
|
84
|
+
record_id: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: 'Record id',
|
|
87
|
+
default: '',
|
|
88
|
+
},
|
|
89
|
+
parent: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
description: 'Parent record id',
|
|
92
|
+
default: '',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file')),
|
|
98
|
+
__param(0, (0, common_1.Param)('collectionName')),
|
|
99
|
+
__param(1, (0, common_1.UploadedFile)()),
|
|
100
|
+
__param(2, (0, common_1.Body)('object_name')),
|
|
101
|
+
__param(3, (0, common_1.Body)('record_id')),
|
|
102
|
+
__param(4, (0, common_1.Body)('parent')),
|
|
103
|
+
__param(5, (0, common_1.Req)()),
|
|
104
|
+
__metadata("design:type", Function),
|
|
105
|
+
__metadata("design:paramtypes", [String, Object, String, String, String, Request]),
|
|
106
|
+
__metadata("design:returntype", Promise)
|
|
107
|
+
], FilesController.prototype, "uploadFile", null);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, common_1.Get)(':collectionName/:fileId/:fileName?'),
|
|
110
|
+
(0, swagger_1.ApiOperation)({ summary: 'Download a file' }),
|
|
111
|
+
(0, swagger_1.ApiParam)({
|
|
112
|
+
name: 'collectionName',
|
|
113
|
+
required: true,
|
|
114
|
+
type: 'string',
|
|
115
|
+
schema: {
|
|
116
|
+
type: 'string',
|
|
117
|
+
default: 'cfs.files.filerecord',
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
(0, swagger_1.ApiParam)({
|
|
121
|
+
name: 'fileName',
|
|
122
|
+
required: false,
|
|
123
|
+
type: 'string',
|
|
124
|
+
}),
|
|
125
|
+
__param(0, (0, common_1.Param)('collectionName')),
|
|
126
|
+
__param(1, (0, common_1.Param)('fileId')),
|
|
127
|
+
__param(2, (0, common_1.Param)('fileName')),
|
|
128
|
+
__param(3, (0, common_1.Res)()),
|
|
129
|
+
__metadata("design:type", Function),
|
|
130
|
+
__metadata("design:paramtypes", [String, String, String, Object]),
|
|
131
|
+
__metadata("design:returntype", Promise)
|
|
132
|
+
], FilesController.prototype, "downloadFile", null);
|
|
133
|
+
__decorate([
|
|
134
|
+
(0, common_1.Post)(':collectionName/presigned-urls'),
|
|
135
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get presigned urls for files' }),
|
|
136
|
+
(0, swagger_1.ApiBody)({
|
|
137
|
+
schema: {
|
|
138
|
+
type: 'object',
|
|
139
|
+
description: 'Array of record id',
|
|
140
|
+
properties: {
|
|
141
|
+
records: {
|
|
142
|
+
type: 'array',
|
|
143
|
+
items: {
|
|
144
|
+
type: 'string',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
(0, swagger_1.ApiParam)({
|
|
151
|
+
name: 'collectionName',
|
|
152
|
+
required: true,
|
|
153
|
+
type: 'string',
|
|
154
|
+
schema: {
|
|
155
|
+
type: 'string',
|
|
156
|
+
default: 'cfs.files.filerecord',
|
|
157
|
+
},
|
|
158
|
+
}),
|
|
159
|
+
__param(0, (0, common_1.Param)('collectionName')),
|
|
160
|
+
__param(1, (0, common_1.Body)('records')),
|
|
161
|
+
__metadata("design:type", Function),
|
|
162
|
+
__metadata("design:paramtypes", [String, Array]),
|
|
163
|
+
__metadata("design:returntype", Promise)
|
|
164
|
+
], FilesController.prototype, "presignedUrls", null);
|
|
165
|
+
exports.FilesController = FilesController = __decorate([
|
|
166
|
+
(0, common_1.Controller)('api/v6/files/'),
|
|
167
|
+
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
|
|
168
|
+
__metadata("design:paramtypes", [files_service_1.FilesService])
|
|
169
|
+
], FilesController);
|
|
170
|
+
//# sourceMappingURL=files.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.controller.js","sourceRoot":"","sources":["../../src/files/files.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAawB;AACxB,+DAA2D;AAC3D,mDAA+C;AAE/C,6CAA+E;AAC/E,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAyCrD,AAAN,KAAK,CAAC,UAAU,CACW,cAAsB,EAC/B,IAAyB,EACpB,WAAmB,EACrB,SAAiB,EACpB,MAAc,EACvB,GAAY;QAGnB,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,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CACnD,cAAc,EACd,IAAI,EACJ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CACvE,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC;IAkBK,AAAN,KAAK,CAAC,YAAY,CACS,cAAsB,EAC9B,MAAc,EACZ,QAAgB,EAC5B,GAAa;QAEpB,IAAI,CAAC;YAEH,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,KAA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@nestjs/testing");
|
|
4
|
+
const files_controller_1 = require("./files.controller");
|
|
5
|
+
describe('FilesController', () => {
|
|
6
|
+
let controller;
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
const module = await testing_1.Test.createTestingModule({
|
|
9
|
+
controllers: [files_controller_1.FilesController],
|
|
10
|
+
}).compile();
|
|
11
|
+
controller = module.get(files_controller_1.FilesController);
|
|
12
|
+
});
|
|
13
|
+
it('should be defined', () => {
|
|
14
|
+
expect(controller).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=files.controller.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.controller.spec.js","sourceRoot":"","sources":["../../src/files/files.controller.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,yDAAqD;AAErD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,UAA2B,CAAC;IAEhC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,WAAW,EAAE,CAAC,kCAAe,CAAC;SAC/B,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,UAAU,GAAG,MAAM,CAAC,GAAG,CAAkB,kCAAe,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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.FilesModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const files_controller_1 = require("./files.controller");
|
|
12
|
+
const files_service_1 = require("./files.service");
|
|
13
|
+
const mongodb_module_1 = require("../mongodb/mongodb.module");
|
|
14
|
+
const files_moleculer_1 = require("./files.moleculer");
|
|
15
|
+
const auth_module_1 = require("../auth/auth.module");
|
|
16
|
+
let FilesModule = class FilesModule {
|
|
17
|
+
};
|
|
18
|
+
exports.FilesModule = FilesModule;
|
|
19
|
+
exports.FilesModule = FilesModule = __decorate([
|
|
20
|
+
(0, common_1.Module)({
|
|
21
|
+
imports: [auth_module_1.AuthModule, mongodb_module_1.MongodbModule],
|
|
22
|
+
controllers: [files_controller_1.FilesController],
|
|
23
|
+
providers: [files_service_1.FilesService, files_moleculer_1.FilesMoleculer],
|
|
24
|
+
exports: [files_service_1.FilesService],
|
|
25
|
+
})
|
|
26
|
+
], FilesModule);
|
|
27
|
+
//# sourceMappingURL=files.module.js.map
|
|
@@ -0,0 +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,8DAA0D;AAC1D,uDAAmD;AACnD,qDAAiD;AAQ1C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IANvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,wBAAU,EAAE,8BAAa,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Service, Context, ServiceBroker } from 'moleculer';
|
|
2
|
+
import { FilesService } from './files.service';
|
|
3
|
+
export declare class FilesMoleculer extends Service {
|
|
4
|
+
private filesService;
|
|
5
|
+
constructor(filesService: FilesService, broker: ServiceBroker);
|
|
6
|
+
serviceCreated(): void;
|
|
7
|
+
serviceStarted(): Promise<void>;
|
|
8
|
+
serviceStopped(): Promise<void>;
|
|
9
|
+
getPreSignedUrl(ctx: Context): Promise<string>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.FilesMoleculer = void 0;
|
|
16
|
+
const moleculer_1 = require("moleculer");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const moleculer_2 = require("@builder6/moleculer");
|
|
19
|
+
const files_service_1 = require("./files.service");
|
|
20
|
+
let FilesMoleculer = class FilesMoleculer extends moleculer_1.Service {
|
|
21
|
+
constructor(filesService, broker) {
|
|
22
|
+
super(broker);
|
|
23
|
+
this.filesService = filesService;
|
|
24
|
+
this.parseServiceSchema({
|
|
25
|
+
name: '@builder6/files',
|
|
26
|
+
settings: {},
|
|
27
|
+
actions: {
|
|
28
|
+
getPreSignedUrl: this.getPreSignedUrl,
|
|
29
|
+
},
|
|
30
|
+
created: this.serviceCreated,
|
|
31
|
+
started: this.serviceStarted,
|
|
32
|
+
stopped: this.serviceStopped,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
serviceCreated() { }
|
|
36
|
+
async serviceStarted() { }
|
|
37
|
+
async serviceStopped() { }
|
|
38
|
+
async getPreSignedUrl(ctx) {
|
|
39
|
+
const { collectionName, fileId } = ctx.params;
|
|
40
|
+
return this.filesService.getPreSignedUrl(collectionName, fileId);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.FilesMoleculer = FilesMoleculer;
|
|
44
|
+
exports.FilesMoleculer = FilesMoleculer = __decorate([
|
|
45
|
+
(0, common_1.Injectable)(),
|
|
46
|
+
__param(1, (0, moleculer_2.InjectBroker)()),
|
|
47
|
+
__metadata("design:paramtypes", [files_service_1.FilesService,
|
|
48
|
+
moleculer_1.ServiceBroker])
|
|
49
|
+
], FilesMoleculer);
|
|
50
|
+
//# sourceMappingURL=files.moleculer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.moleculer.js","sourceRoot":"","sources":["../../src/files/files.moleculer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA4D;AAC5D,2CAAoD;AACpD,mDAAmD;AACnD,mDAA+C;AAGxC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,mBAAO;IACzC,YACU,YAA0B,EAClB,MAAqB;QAErC,KAAK,CAAC,MAAM,CAAC,CAAC;QAHN,iBAAY,GAAZ,YAAY,CAAc;QAKlC,IAAI,CAAC,kBAAkB,CAAC;YACtB,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE;gBACP,eAAe,EAAE,IAAI,CAAC,eAAe;aACtC;YACD,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,OAAO,EAAE,IAAI,CAAC,cAAc;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,cAAc,KAAI,CAAC;IAEnB,KAAK,CAAC,cAAc,KAAI,CAAC;IAEzB,KAAK,CAAC,cAAc,KAAI,CAAC;IAEzB,KAAK,CAAC,eAAe,CAAC,GAAY;QAChC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAa,CAAC;QAErD,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AA9BY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,wBAAY,GAAE,CAAA;qCADO,4BAAY;QACV,yBAAa;GAH5B,cAAc,CA8B1B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MongodbService } from '../mongodb/mongodb.service';
|
|
2
|
+
import stream from 'stream';
|
|
3
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
|
+
export declare class FilesService {
|
|
5
|
+
private configService;
|
|
6
|
+
private mongodbService;
|
|
7
|
+
private s3;
|
|
8
|
+
cfsStore: string;
|
|
9
|
+
storageDir: string;
|
|
10
|
+
s3Bucket: string;
|
|
11
|
+
rootUrl: string;
|
|
12
|
+
private readonly logger;
|
|
13
|
+
constructor(configService: ConfigService, mongodbService: MongodbService);
|
|
14
|
+
getCollectionFolderName(collectionName: any): string;
|
|
15
|
+
uploadFile(collectionName: string, file: {
|
|
16
|
+
buffer: Buffer;
|
|
17
|
+
originalname: string;
|
|
18
|
+
size: number;
|
|
19
|
+
mimetype?: string;
|
|
20
|
+
}, metadata: {
|
|
21
|
+
_id?: string;
|
|
22
|
+
owner?: string;
|
|
23
|
+
space?: string;
|
|
24
|
+
object_name?: string;
|
|
25
|
+
record_id?: string;
|
|
26
|
+
parent?: string;
|
|
27
|
+
}): Promise<object>;
|
|
28
|
+
getFile(collectionName: string, fileId: string): Promise<any>;
|
|
29
|
+
getPreSignedUrl(collectionName: string, fileId: string): Promise<string | null>;
|
|
30
|
+
downloadFileStream(collectionName: string, fileId: string): Promise<stream.Readable>;
|
|
31
|
+
}
|