@tc-libs/file-handler 0.9.0
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/README.md +11 -0
- package/package.json +11 -0
- package/src/file-handler.module.d.ts +6 -0
- package/src/file-handler.module.js +53 -0
- package/src/file-handler.module.js.map +1 -0
- package/src/file-handler.module.options.d.ts +12 -0
- package/src/file-handler.module.options.js +5 -0
- package/src/file-handler.module.options.js.map +1 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +10 -0
- package/src/index.js.map +1 -0
- package/src/interfaces/file-handler.interface.d.ts +43 -0
- package/src/interfaces/file-handler.interface.js +3 -0
- package/src/interfaces/file-handler.interface.js.map +1 -0
- package/src/interfaces/file.interface.d.ts +12 -0
- package/src/interfaces/file.interface.js +3 -0
- package/src/interfaces/file.interface.js.map +1 -0
- package/src/repository/entities/file.entity.d.ts +43 -0
- package/src/repository/entities/file.entity.js +132 -0
- package/src/repository/entities/file.entity.js.map +1 -0
- package/src/repository/file.repository.module.d.ts +2 -0
- package/src/repository/file.repository.module.js +27 -0
- package/src/repository/file.repository.module.js.map +1 -0
- package/src/repository/index.d.ts +3 -0
- package/src/repository/index.js +7 -0
- package/src/repository/index.js.map +1 -0
- package/src/repository/repositories/file.repository.d.ts +11 -0
- package/src/repository/repositories/file.repository.js +28 -0
- package/src/repository/repositories/file.repository.js.map +1 -0
- package/src/services/file-handler.service.d.ts +26 -0
- package/src/services/file-handler.service.js +147 -0
- package/src/services/file-handler.service.js.map +1 -0
- package/src/services/file-handler.text.service.d.ts +10 -0
- package/src/services/file-handler.text.service.js +63 -0
- package/src/services/file-handler.text.service.js.map +1 -0
- package/src/services/file-handler.video.service.d.ts +13 -0
- package/src/services/file-handler.video.service.js +147 -0
- package/src/services/file-handler.video.service.js.map +1 -0
- package/src/services/handlers/audio.d.ts +0 -0
- package/src/services/handlers/audio.js +174 -0
- package/src/services/handlers/audio.js.map +1 -0
- package/src/services/handlers/file.d.ts +5 -0
- package/src/services/handlers/file.js +32 -0
- package/src/services/handlers/file.js.map +1 -0
- package/src/services/handlers/index.d.ts +2 -0
- package/src/services/handlers/index.js +8 -0
- package/src/services/handlers/index.js.map +1 -0
- package/src/services/handlers/jpg.d.ts +5 -0
- package/src/services/handlers/jpg.js +96 -0
- package/src/services/handlers/jpg.js.map +1 -0
- package/src/services/handlers/png.d.ts +0 -0
- package/src/services/handlers/png.js +2 -0
- package/src/services/handlers/png.js.map +1 -0
- package/src/services/handlers/video.d.ts +0 -0
- package/src/services/handlers/video.js +174 -0
- package/src/services/handlers/video.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import FileHandlerModuleAsyncOptions, { FileHandlerModuleOptions } from './file-handler.module.options';
|
|
3
|
+
export declare class FileHandlerModule {
|
|
4
|
+
static register(options: FileHandlerModuleOptions, isGlobal?: boolean): DynamicModule;
|
|
5
|
+
static registerAsync(options: FileHandlerModuleAsyncOptions, isGlobal?: boolean): DynamicModule;
|
|
6
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var FileHandlerModule_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FileHandlerModule = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const file_handler_service_1 = require("./services/file-handler.service");
|
|
8
|
+
const file_handler_video_service_1 = require("./services/file-handler.video.service");
|
|
9
|
+
const file_handler_text_service_1 = require("./services/file-handler.text.service");
|
|
10
|
+
const file_handler_module_options_1 = require("./file-handler.module.options");
|
|
11
|
+
const providers = [
|
|
12
|
+
file_handler_service_1.FileHandlerService,
|
|
13
|
+
file_handler_video_service_1.FileHandlerVideoService,
|
|
14
|
+
file_handler_text_service_1.FileHandlerTextService,
|
|
15
|
+
];
|
|
16
|
+
let FileHandlerModule = FileHandlerModule_1 = class FileHandlerModule {
|
|
17
|
+
static register(options, isGlobal) {
|
|
18
|
+
return {
|
|
19
|
+
module: FileHandlerModule_1,
|
|
20
|
+
providers: [
|
|
21
|
+
{ provide: file_handler_module_options_1.FILE_HANDLER_CONFIG_OPTIONS, useValue: options },
|
|
22
|
+
...providers,
|
|
23
|
+
],
|
|
24
|
+
exports: providers,
|
|
25
|
+
global: isGlobal,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static registerAsync(options, isGlobal) {
|
|
29
|
+
return {
|
|
30
|
+
module: FileHandlerModule_1,
|
|
31
|
+
imports: [...(options.imports || [])],
|
|
32
|
+
providers: [
|
|
33
|
+
{
|
|
34
|
+
provide: file_handler_module_options_1.FILE_HANDLER_CONFIG_OPTIONS,
|
|
35
|
+
useFactory: options.useFactory,
|
|
36
|
+
inject: options.inject,
|
|
37
|
+
},
|
|
38
|
+
...providers,
|
|
39
|
+
],
|
|
40
|
+
exports: providers,
|
|
41
|
+
global: isGlobal,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.FileHandlerModule = FileHandlerModule;
|
|
46
|
+
exports.FileHandlerModule = FileHandlerModule = FileHandlerModule_1 = tslib_1.__decorate([
|
|
47
|
+
(0, common_1.Module)({
|
|
48
|
+
imports: [],
|
|
49
|
+
providers,
|
|
50
|
+
exports: providers,
|
|
51
|
+
})
|
|
52
|
+
], FileHandlerModule);
|
|
53
|
+
//# sourceMappingURL=file-handler.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-handler.module.js","sourceRoot":"","sources":["../../../../packages/file-handler/src/file-handler.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AACvD,0EAAqE;AACrE,sFAAgF;AAChF,oFAA8E;AAC9E,+EAGuC;AACvC,MAAM,SAAS,GAAG;IAChB,yCAAkB;IAClB,oDAAuB;IACvB,kDAAsB;CACvB,CAAC;AAMK,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CACb,OAAiC,EACjC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,yDAA2B,EAAE,QAAQ,EAAE,OAAO,EAAE;gBAC3D,GAAG,SAAS;aACb;YACD,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,aAAa,CAClB,OAAsC,EACtC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,yDAA2B;oBACpC,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB;gBACD,GAAG,SAAS;aACb;YACD,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AAlCY,8CAAiB;4BAAjB,iBAAiB;IAL7B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,EAAE;QACX,SAAS;QACT,OAAO,EAAE,SAAS;KACnB,CAAC;GACW,iBAAiB,CAkC7B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface';
|
|
3
|
+
import { FileHandlerConfResize } from './interfaces/file-handler.interface';
|
|
4
|
+
export declare const FILE_HANDLER_CONFIG_OPTIONS = "FILE_HANDLER_CONFIG_OPTIONS";
|
|
5
|
+
export interface FileHandlerModuleOptions {
|
|
6
|
+
image: {
|
|
7
|
+
quality: number;
|
|
8
|
+
};
|
|
9
|
+
resizes: FileHandlerConfResize[];
|
|
10
|
+
}
|
|
11
|
+
type FileHandlerModuleAsyncOptions = Pick<ModuleMetadata, 'imports'> & Pick<FactoryProvider<FileHandlerModuleOptions>, 'useFactory' | 'inject'>;
|
|
12
|
+
export default FileHandlerModuleAsyncOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-handler.module.options.js","sourceRoot":"","sources":["../../../../packages/file-handler/src/file-handler.module.options.ts"],"names":[],"mappings":";;;AAIa,QAAA,2BAA2B,GAAG,6BAA6B,CAAC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './file-handler.module';
|
|
2
|
+
export * from './services/file-handler.service';
|
|
3
|
+
export * from './services/file-handler.text.service';
|
|
4
|
+
export * from './services/file-handler.video.service';
|
|
5
|
+
export * from './interfaces/file-handler.interface';
|
|
6
|
+
export * from './interfaces/file.interface';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./file-handler.module"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./services/file-handler.service"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./services/file-handler.text.service"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./services/file-handler.video.service"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./interfaces/file-handler.interface"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./interfaces/file.interface"), exports);
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/file-handler/src/index.ts"],"names":[],"mappings":";;;AAAA,gEAAsC;AACtC,0EAAgD;AAChD,+EAAqD;AACrD,gFAAsD;AACtD,8EAAoD;AACpD,sEAA4C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type FileHandlerConfResize = {
|
|
2
|
+
name: string;
|
|
3
|
+
size: number;
|
|
4
|
+
quality: number;
|
|
5
|
+
};
|
|
6
|
+
export type FileHandlerConf = {
|
|
7
|
+
resizes: FileHandlerConfResize[];
|
|
8
|
+
quality: number;
|
|
9
|
+
};
|
|
10
|
+
export type HandleFileResponseFormat = {
|
|
11
|
+
name: string;
|
|
12
|
+
meta: {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
size: number;
|
|
16
|
+
path: string;
|
|
17
|
+
folder: string;
|
|
18
|
+
completeUrl: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type HandleFileResponse = {
|
|
22
|
+
path: string;
|
|
23
|
+
folder: string;
|
|
24
|
+
filename: string;
|
|
25
|
+
hash: string;
|
|
26
|
+
ext: string;
|
|
27
|
+
mime: string;
|
|
28
|
+
size: number;
|
|
29
|
+
completeUrl: string;
|
|
30
|
+
baseUrl: string;
|
|
31
|
+
provider: string;
|
|
32
|
+
width: number | null;
|
|
33
|
+
height: number | null;
|
|
34
|
+
formats: HandleFileResponseFormat[];
|
|
35
|
+
} | null;
|
|
36
|
+
export type IFileRows = Record<string, string | number | Date>;
|
|
37
|
+
export interface IFileCreateExcelWorkbookOptions {
|
|
38
|
+
sheetName?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface IFileReadExcelOptions {
|
|
41
|
+
sheet?: string | number;
|
|
42
|
+
password?: string;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-handler.interface.js","sourceRoot":"","sources":["../../../../../packages/file-handler/src/interfaces/file-handler.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type IFile = {
|
|
2
|
+
fieldname: string;
|
|
3
|
+
originalname: string;
|
|
4
|
+
encoding: string;
|
|
5
|
+
mimetype: string;
|
|
6
|
+
buffer: Buffer;
|
|
7
|
+
size: number;
|
|
8
|
+
};
|
|
9
|
+
export type IFileExtract<T = Record<string, any>> = IFile & {
|
|
10
|
+
extract: Record<string, any>[];
|
|
11
|
+
dto?: T[];
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.interface.js","sourceRoot":"","sources":["../../../../../packages/file-handler/src/interfaces/file.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DatabaseMongoEntityAbstract } from '@tc-libs/database';
|
|
2
|
+
import { Document } from 'mongoose';
|
|
3
|
+
import { ENUM_FILE_TYPE } from '@tc-libs/constant';
|
|
4
|
+
export declare const FileDatabaseName = "files";
|
|
5
|
+
export declare class FileFormat {
|
|
6
|
+
name: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
size: number;
|
|
10
|
+
path: string;
|
|
11
|
+
folder: string;
|
|
12
|
+
completeUrl: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const FileFormatSchema: import("mongoose").Schema<FileFormat, import("mongoose").Model<FileFormat, any, any, any, Document<unknown, any, FileFormat> & FileFormat & {
|
|
15
|
+
_id: import("mongoose").Types.ObjectId;
|
|
16
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FileFormat, Document<unknown, {}, FileFormat> & FileFormat & {
|
|
17
|
+
_id: import("mongoose").Types.ObjectId;
|
|
18
|
+
}>;
|
|
19
|
+
export declare class FileEntity extends DatabaseMongoEntityAbstract {
|
|
20
|
+
user?: string;
|
|
21
|
+
uploadedBy?: string;
|
|
22
|
+
path: string;
|
|
23
|
+
folder: string;
|
|
24
|
+
type: ENUM_FILE_TYPE;
|
|
25
|
+
filename: string;
|
|
26
|
+
hash: string;
|
|
27
|
+
ext: string;
|
|
28
|
+
mime: string;
|
|
29
|
+
size: number;
|
|
30
|
+
completeUrl: string;
|
|
31
|
+
baseUrl: string;
|
|
32
|
+
provider: string;
|
|
33
|
+
tags: string[];
|
|
34
|
+
width?: number;
|
|
35
|
+
height?: number;
|
|
36
|
+
formats?: FileFormat[];
|
|
37
|
+
}
|
|
38
|
+
export declare const FileSchema: import("mongoose").Schema<FileEntity, import("mongoose").Model<FileEntity, any, any, any, Document<unknown, any, FileEntity> & FileEntity & Required<{
|
|
39
|
+
_id: import("mongoose").Types.ObjectId;
|
|
40
|
+
}>, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FileEntity, Document<unknown, {}, FileEntity> & FileEntity & Required<{
|
|
41
|
+
_id: import("mongoose").Types.ObjectId;
|
|
42
|
+
}>>;
|
|
43
|
+
export type FileDoc = FileEntity & Document;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileSchema = exports.FileEntity = exports.FileFormatSchema = exports.FileFormat = exports.FileDatabaseName = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const database_1 = require("@tc-libs/database");
|
|
6
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
7
|
+
const mongoose_2 = require("mongoose");
|
|
8
|
+
const constant_1 = require("@tc-libs/constant");
|
|
9
|
+
exports.FileDatabaseName = 'files';
|
|
10
|
+
let FileFormat = class FileFormat {
|
|
11
|
+
};
|
|
12
|
+
exports.FileFormat = FileFormat;
|
|
13
|
+
tslib_1.__decorate([
|
|
14
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
15
|
+
tslib_1.__metadata("design:type", String)
|
|
16
|
+
], FileFormat.prototype, "name", void 0);
|
|
17
|
+
tslib_1.__decorate([
|
|
18
|
+
(0, mongoose_1.Prop)({ required: false }),
|
|
19
|
+
tslib_1.__metadata("design:type", Number)
|
|
20
|
+
], FileFormat.prototype, "width", void 0);
|
|
21
|
+
tslib_1.__decorate([
|
|
22
|
+
(0, mongoose_1.Prop)({ required: false }),
|
|
23
|
+
tslib_1.__metadata("design:type", Number)
|
|
24
|
+
], FileFormat.prototype, "height", void 0);
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
27
|
+
tslib_1.__metadata("design:type", Number)
|
|
28
|
+
], FileFormat.prototype, "size", void 0);
|
|
29
|
+
tslib_1.__decorate([
|
|
30
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
31
|
+
tslib_1.__metadata("design:type", String)
|
|
32
|
+
], FileFormat.prototype, "path", void 0);
|
|
33
|
+
tslib_1.__decorate([
|
|
34
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
35
|
+
tslib_1.__metadata("design:type", String)
|
|
36
|
+
], FileFormat.prototype, "folder", void 0);
|
|
37
|
+
tslib_1.__decorate([
|
|
38
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
39
|
+
tslib_1.__metadata("design:type", String)
|
|
40
|
+
], FileFormat.prototype, "completeUrl", void 0);
|
|
41
|
+
exports.FileFormat = FileFormat = tslib_1.__decorate([
|
|
42
|
+
(0, mongoose_1.Schema)({ _id: false })
|
|
43
|
+
], FileFormat);
|
|
44
|
+
exports.FileFormatSchema = mongoose_1.SchemaFactory.createForClass(FileFormat);
|
|
45
|
+
let FileEntity = class FileEntity extends database_1.DatabaseMongoEntityAbstract {
|
|
46
|
+
};
|
|
47
|
+
exports.FileEntity = FileEntity;
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, mongoose_1.Prop)({
|
|
50
|
+
required: false,
|
|
51
|
+
ref: 'UserEntity',
|
|
52
|
+
type: mongoose_2.SchemaTypes.ObjectId,
|
|
53
|
+
}),
|
|
54
|
+
tslib_1.__metadata("design:type", String)
|
|
55
|
+
], FileEntity.prototype, "user", void 0);
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
(0, mongoose_1.Prop)({
|
|
58
|
+
required: false,
|
|
59
|
+
ref: 'UserEntity',
|
|
60
|
+
type: mongoose_2.SchemaTypes.ObjectId,
|
|
61
|
+
}),
|
|
62
|
+
tslib_1.__metadata("design:type", String)
|
|
63
|
+
], FileEntity.prototype, "uploadedBy", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
66
|
+
tslib_1.__metadata("design:type", String)
|
|
67
|
+
], FileEntity.prototype, "path", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
70
|
+
tslib_1.__metadata("design:type", String)
|
|
71
|
+
], FileEntity.prototype, "folder", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, mongoose_1.Prop)({
|
|
74
|
+
required: true,
|
|
75
|
+
type: String,
|
|
76
|
+
enum: constant_1.ENUM_FILE_TYPE,
|
|
77
|
+
}),
|
|
78
|
+
tslib_1.__metadata("design:type", String)
|
|
79
|
+
], FileEntity.prototype, "type", void 0);
|
|
80
|
+
tslib_1.__decorate([
|
|
81
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
82
|
+
tslib_1.__metadata("design:type", String)
|
|
83
|
+
], FileEntity.prototype, "filename", void 0);
|
|
84
|
+
tslib_1.__decorate([
|
|
85
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
86
|
+
tslib_1.__metadata("design:type", String)
|
|
87
|
+
], FileEntity.prototype, "hash", void 0);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
90
|
+
tslib_1.__metadata("design:type", String)
|
|
91
|
+
], FileEntity.prototype, "ext", void 0);
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
94
|
+
tslib_1.__metadata("design:type", String)
|
|
95
|
+
], FileEntity.prototype, "mime", void 0);
|
|
96
|
+
tslib_1.__decorate([
|
|
97
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
98
|
+
tslib_1.__metadata("design:type", Number)
|
|
99
|
+
], FileEntity.prototype, "size", void 0);
|
|
100
|
+
tslib_1.__decorate([
|
|
101
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
102
|
+
tslib_1.__metadata("design:type", String)
|
|
103
|
+
], FileEntity.prototype, "completeUrl", void 0);
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
106
|
+
tslib_1.__metadata("design:type", String)
|
|
107
|
+
], FileEntity.prototype, "baseUrl", void 0);
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
110
|
+
tslib_1.__metadata("design:type", String)
|
|
111
|
+
], FileEntity.prototype, "provider", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, mongoose_1.Prop)({ required: true, type: [String] }),
|
|
114
|
+
tslib_1.__metadata("design:type", Array)
|
|
115
|
+
], FileEntity.prototype, "tags", void 0);
|
|
116
|
+
tslib_1.__decorate([
|
|
117
|
+
(0, mongoose_1.Prop)({ required: false }),
|
|
118
|
+
tslib_1.__metadata("design:type", Number)
|
|
119
|
+
], FileEntity.prototype, "width", void 0);
|
|
120
|
+
tslib_1.__decorate([
|
|
121
|
+
(0, mongoose_1.Prop)({ required: false }),
|
|
122
|
+
tslib_1.__metadata("design:type", Number)
|
|
123
|
+
], FileEntity.prototype, "height", void 0);
|
|
124
|
+
tslib_1.__decorate([
|
|
125
|
+
(0, mongoose_1.Prop)({ required: false, type: [exports.FileFormatSchema] }),
|
|
126
|
+
tslib_1.__metadata("design:type", Array)
|
|
127
|
+
], FileEntity.prototype, "formats", void 0);
|
|
128
|
+
exports.FileEntity = FileEntity = tslib_1.__decorate([
|
|
129
|
+
(0, database_1.DatabaseEntity)({ collection: exports.FileDatabaseName })
|
|
130
|
+
], FileEntity);
|
|
131
|
+
exports.FileSchema = mongoose_1.SchemaFactory.createForClass(FileEntity);
|
|
132
|
+
//# sourceMappingURL=file.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.entity.js","sourceRoot":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C,wBAAgB,CAAC,EAAE,CAAC;;2CAC7B;qBA9CZ,UAAU;IADtB,IAAA,yBAAc,EAAC,EAAE,UAAU,EAAE,wBAAgB,EAAE,CAAC;GACpC,UAAU,CA+CtB;AAEY,QAAA,UAAU,GAAG,wBAAa,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileRepositoryModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
7
|
+
const file_entity_1 = require("./entities/file.entity");
|
|
8
|
+
const file_repository_1 = require("./repositories/file.repository");
|
|
9
|
+
let FileRepositoryModule = class FileRepositoryModule {
|
|
10
|
+
};
|
|
11
|
+
exports.FileRepositoryModule = FileRepositoryModule;
|
|
12
|
+
exports.FileRepositoryModule = FileRepositoryModule = tslib_1.__decorate([
|
|
13
|
+
(0, common_1.Module)({
|
|
14
|
+
providers: [file_repository_1.FileRepository],
|
|
15
|
+
exports: [file_repository_1.FileRepository],
|
|
16
|
+
controllers: [],
|
|
17
|
+
imports: [
|
|
18
|
+
mongoose_1.MongooseModule.forFeature([
|
|
19
|
+
{
|
|
20
|
+
name: file_entity_1.FileEntity.name,
|
|
21
|
+
schema: file_entity_1.FileSchema,
|
|
22
|
+
},
|
|
23
|
+
]),
|
|
24
|
+
],
|
|
25
|
+
})
|
|
26
|
+
], FileRepositoryModule);
|
|
27
|
+
//# sourceMappingURL=file.repository.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.repository.module.js","sourceRoot":"","sources":["../../../../../packages/file-handler/src/repository/file.repository.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,+CAAkD;AAClD,wDAAgE;AAChE,oEAAgE;AAezD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oDAAoB;+BAApB,oBAAoB;IAbhC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,gCAAc,CAAC;QAC3B,OAAO,EAAE,CAAC,gCAAc,CAAC;QACzB,WAAW,EAAE,EAAE;QACf,OAAO,EAAE;YACP,yBAAc,CAAC,UAAU,CAAC;gBACxB;oBACE,IAAI,EAAE,wBAAU,CAAC,IAAI;oBACrB,MAAM,EAAE,wBAAU;iBACnB;aACF,CAAC;SACH;KACF,CAAC;GACW,oBAAoB,CAAG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./entities/file.entity"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./repositories/file.repository"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./file.repository.module"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/file-handler/src/repository/index.ts"],"names":[],"mappings":";;;AAAA,iEAAuC;AACvC,yEAA+C;AAC/C,mEAAyC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { AppCacheService } from '@tc-libs/app-cache';
|
|
3
|
+
import { DatabaseMongoRepositoryAbstract } from '@tc-libs/database';
|
|
4
|
+
import { Connection, Model } from 'mongoose';
|
|
5
|
+
import { FileDoc, FileEntity } from '../entities/file.entity';
|
|
6
|
+
export declare class FileRepository extends DatabaseMongoRepositoryAbstract<FileEntity, FileDoc> {
|
|
7
|
+
protected readonly FileDoc: Model<FileEntity>;
|
|
8
|
+
protected readonly connection: Connection;
|
|
9
|
+
protected readonly _logger: Logger;
|
|
10
|
+
constructor(FileDoc: Model<FileEntity>, connection: Connection, _cache: AppCacheService);
|
|
11
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var FileRepository_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FileRepository = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const app_cache_1 = require("@tc-libs/app-cache");
|
|
8
|
+
const database_1 = require("@tc-libs/database");
|
|
9
|
+
const mongoose_1 = require("mongoose");
|
|
10
|
+
const file_entity_1 = require("../entities/file.entity");
|
|
11
|
+
let FileRepository = FileRepository_1 = class FileRepository extends database_1.DatabaseMongoRepositoryAbstract {
|
|
12
|
+
constructor(FileDoc, connection, _cache) {
|
|
13
|
+
super(FileDoc, connection, _cache);
|
|
14
|
+
this.FileDoc = FileDoc;
|
|
15
|
+
this.connection = connection;
|
|
16
|
+
this._logger = new common_1.Logger(FileRepository_1.name);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.FileRepository = FileRepository;
|
|
20
|
+
exports.FileRepository = FileRepository = FileRepository_1 = tslib_1.__decorate([
|
|
21
|
+
(0, common_1.Injectable)(),
|
|
22
|
+
tslib_1.__param(0, (0, database_1.DatabaseModel)(file_entity_1.FileEntity.name)),
|
|
23
|
+
tslib_1.__param(1, (0, database_1.DatabaseConnection)()),
|
|
24
|
+
tslib_1.__metadata("design:paramtypes", [mongoose_1.Model,
|
|
25
|
+
mongoose_1.Connection,
|
|
26
|
+
app_cache_1.AppCacheService])
|
|
27
|
+
], FileRepository);
|
|
28
|
+
//# sourceMappingURL=file.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.repository.js","sourceRoot":"","sources":["../../../../../../packages/file-handler/src/repository/repositories/file.repository.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,kDAAqD;AACrD,gDAI2B;AAC3B,uCAA6C;AAE7C,yDAA8D;AAGvD,IAAM,cAAc,sBAApB,MAAM,cAAe,SAAQ,0CAGnC;IAEC,YAEE,OAA6C,EAE7C,UAAyC,EACzC,MAAuB;QAEvB,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QALhB,YAAO,GAAP,OAAO,CAAmB;QAE1B,eAAU,GAAV,UAAU,CAAY;QALxB,YAAO,GAAW,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;IASrE,CAAC;CACF,CAAA;AAdY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAOR,mBAAA,IAAA,wBAAa,EAAC,wBAAU,CAAC,IAAI,CAAC,CAAA;IAE9B,mBAAA,IAAA,6BAAkB,GAAE,CAAA;6CADO,gBAAK;QAEF,qBAAU;QACjC,2BAAe;GAVd,cAAc,CAc1B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { ACL, StorageAwsS3Service } from '@tc-libs/storage';
|
|
3
|
+
import { FileHandlerModuleOptions } from '../file-handler.module.options';
|
|
4
|
+
import { HandleFileResponse } from '../interfaces/file-handler.interface';
|
|
5
|
+
import { IFile } from '../interfaces/file.interface';
|
|
6
|
+
export interface HandleFileOptions {
|
|
7
|
+
acl: ACL;
|
|
8
|
+
}
|
|
9
|
+
export declare class FileHandlerService {
|
|
10
|
+
private readonly _options;
|
|
11
|
+
private readonly _storage;
|
|
12
|
+
readonly logger: Logger;
|
|
13
|
+
private _imgConf;
|
|
14
|
+
constructor(_options: FileHandlerModuleOptions, _storage: StorageAwsS3Service);
|
|
15
|
+
protected fileToBuffer(filePath: string): Promise<Buffer>;
|
|
16
|
+
convertToBytes(megabytes: string): number;
|
|
17
|
+
handleFiles(files: IFile[]): Promise<HandleFileResponse[]>;
|
|
18
|
+
getFileInfo(file: IFile): {
|
|
19
|
+
mime: string;
|
|
20
|
+
fileType: string;
|
|
21
|
+
hashName: string;
|
|
22
|
+
ext: string;
|
|
23
|
+
};
|
|
24
|
+
handleFile(file: IFile, options?: HandleFileOptions): Promise<HandleFileResponse>;
|
|
25
|
+
hashName(name: string): string;
|
|
26
|
+
}
|