@flusys/nestjs-storage 1.1.0-beta → 2.0.0-rc.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 +148 -6
- package/cjs/config/index.js +0 -1
- package/cjs/config/storage.constants.js +0 -17
- package/cjs/controllers/file-manager.controller.js +44 -1
- package/cjs/controllers/folder.controller.js +44 -1
- package/cjs/controllers/storage-config.controller.js +44 -1
- package/cjs/controllers/upload.controller.js +18 -29
- package/cjs/docs/storage-swagger.config.js +24 -136
- package/cjs/dtos/file-manager.dto.js +70 -34
- package/cjs/dtos/folder.dto.js +15 -9
- package/cjs/dtos/storage-config.dto.js +4 -85
- package/cjs/dtos/upload.dto.js +24 -17
- package/cjs/entities/file-manager-with-company.entity.js +3 -4
- package/cjs/entities/file-manager.entity.js +71 -3
- package/cjs/entities/folder-with-company.entity.js +3 -4
- package/cjs/entities/folder.entity.js +19 -3
- package/cjs/entities/index.js +9 -10
- package/cjs/entities/storage-config-with-company.entity.js +3 -4
- package/cjs/entities/storage-config.entity.js +74 -3
- package/cjs/interfaces/index.js +0 -1
- package/cjs/middlewares/file-serve.middleware.js +113 -100
- package/cjs/modules/storage.module.js +82 -136
- package/cjs/providers/azure-provider.optional.js +10 -38
- package/cjs/providers/local-provider.js +38 -31
- package/cjs/providers/s3-provider.optional.js +19 -40
- package/cjs/providers/storage-factory.service.js +54 -99
- package/cjs/providers/storage-provider.registry.js +8 -18
- package/cjs/services/file-manager.service.js +238 -323
- package/cjs/services/folder.service.js +8 -11
- package/cjs/services/index.js +1 -0
- package/cjs/{config → services}/storage-config.service.js +32 -76
- package/cjs/services/storage-datasource.provider.js +16 -26
- package/cjs/services/storage-provider-config.service.js +15 -37
- package/cjs/services/upload.service.js +72 -88
- package/cjs/utils/file-validator.util.js +458 -0
- package/cjs/utils/image-compressor.util.js +3 -8
- package/config/index.d.ts +0 -1
- package/config/storage.constants.d.ts +0 -8
- package/controllers/upload.controller.d.ts +3 -6
- package/dtos/file-manager.dto.d.ts +12 -5
- package/dtos/folder.dto.d.ts +5 -5
- package/dtos/storage-config.dto.d.ts +7 -13
- package/entities/file-manager-with-company.entity.d.ts +2 -2
- package/entities/file-manager.entity.d.ts +12 -2
- package/entities/folder-with-company.entity.d.ts +2 -2
- package/entities/folder.entity.d.ts +4 -2
- package/entities/index.d.ts +3 -4
- package/entities/storage-config-with-company.entity.d.ts +2 -2
- package/entities/storage-config.entity.d.ts +8 -2
- package/fesm/config/index.js +0 -1
- package/fesm/config/storage.constants.js +0 -8
- package/fesm/controllers/file-manager.controller.js +45 -2
- package/fesm/controllers/folder.controller.js +45 -2
- package/fesm/controllers/storage-config.controller.js +45 -2
- package/fesm/controllers/upload.controller.js +19 -30
- package/fesm/docs/storage-swagger.config.js +27 -142
- package/fesm/dtos/file-manager.dto.js +71 -35
- package/fesm/dtos/folder.dto.js +16 -10
- package/fesm/dtos/storage-config.dto.js +8 -95
- package/fesm/dtos/upload.dto.js +25 -19
- package/fesm/entities/file-manager-with-company.entity.js +3 -4
- package/fesm/entities/file-manager.entity.js +72 -4
- package/fesm/entities/folder-with-company.entity.js +3 -4
- package/fesm/entities/folder.entity.js +20 -4
- package/fesm/entities/index.js +5 -13
- package/fesm/entities/storage-config-with-company.entity.js +3 -4
- package/fesm/entities/storage-config.entity.js +75 -4
- package/fesm/interfaces/index.js +0 -1
- package/fesm/interfaces/storage-config.interface.js +1 -3
- package/fesm/middlewares/file-serve.middleware.js +114 -101
- package/fesm/modules/storage.module.js +83 -136
- package/fesm/providers/azure-provider.optional.js +11 -42
- package/fesm/providers/local-provider.js +38 -31
- package/fesm/providers/s3-provider.optional.js +20 -44
- package/fesm/providers/storage-factory.service.js +52 -97
- package/fesm/providers/storage-provider.registry.js +10 -20
- package/fesm/services/file-manager.service.js +237 -322
- package/fesm/services/folder.service.js +6 -9
- package/fesm/services/index.js +1 -0
- package/fesm/{config → services}/storage-config.service.js +32 -76
- package/fesm/services/storage-datasource.provider.js +16 -26
- package/fesm/services/storage-provider-config.service.js +13 -35
- package/fesm/services/upload.service.js +71 -87
- package/fesm/utils/file-validator.util.js +451 -0
- package/fesm/utils/image-compressor.util.js +3 -8
- package/interfaces/file-manager.interface.d.ts +7 -4
- package/interfaces/index.d.ts +0 -1
- package/interfaces/storage-config.interface.d.ts +0 -20
- package/interfaces/storage-module-options.interface.d.ts +0 -5
- package/middlewares/file-serve.middleware.d.ts +9 -1
- package/modules/storage.module.d.ts +1 -2
- package/package.json +6 -6
- package/providers/azure-provider.optional.d.ts +8 -6
- package/providers/local-provider.d.ts +2 -7
- package/providers/s3-provider.optional.d.ts +9 -7
- package/providers/storage-factory.service.d.ts +8 -9
- package/providers/storage-provider.registry.d.ts +4 -4
- package/services/file-manager.service.d.ts +23 -16
- package/services/folder.service.d.ts +4 -4
- package/services/index.d.ts +1 -0
- package/services/storage-config.service.d.ts +24 -0
- package/services/storage-datasource.provider.d.ts +3 -4
- package/services/storage-provider-config.service.d.ts +4 -4
- package/services/upload.service.d.ts +3 -2
- package/utils/file-validator.util.d.ts +19 -0
- package/cjs/entities/file-manager-base.entity.js +0 -115
- package/cjs/entities/folder-base.entity.js +0 -55
- package/cjs/entities/storage-config-base.entity.js +0 -93
- package/cjs/interfaces/file-upload-response.interface.js +0 -4
- package/config/storage-config.service.d.ts +0 -22
- package/entities/file-manager-base.entity.d.ts +0 -13
- package/entities/folder-base.entity.d.ts +0 -5
- package/entities/storage-config-base.entity.d.ts +0 -9
- package/fesm/entities/file-manager-base.entity.js +0 -108
- package/fesm/entities/folder-base.entity.js +0 -48
- package/fesm/entities/storage-config-base.entity.js +0 -83
- package/fesm/interfaces/file-upload-response.interface.js +0 -1
- package/interfaces/file-upload-response.interface.d.ts +0 -6
|
@@ -21,7 +21,7 @@ function _ts_metadata(k, v) {
|
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
23
|
import { ApiProperty, ApiPropertyOptional, PartialType } from '@nestjs/swagger';
|
|
24
|
-
import { IsBoolean, IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
24
|
+
import { IsBoolean, IsEnum, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
|
|
25
25
|
import { FileLocationEnum } from '../enums';
|
|
26
26
|
export class CreateFileManagerDto {
|
|
27
27
|
constructor(){
|
|
@@ -37,8 +37,8 @@ export class CreateFileManagerDto {
|
|
|
37
37
|
}
|
|
38
38
|
_ts_decorate([
|
|
39
39
|
ApiProperty({
|
|
40
|
-
description: '
|
|
41
|
-
example: '
|
|
40
|
+
description: 'Original file name',
|
|
41
|
+
example: 'vacation-photo.jpg'
|
|
42
42
|
}),
|
|
43
43
|
IsNotEmpty(),
|
|
44
44
|
IsString(),
|
|
@@ -46,8 +46,8 @@ _ts_decorate([
|
|
|
46
46
|
], CreateFileManagerDto.prototype, "name", void 0);
|
|
47
47
|
_ts_decorate([
|
|
48
48
|
ApiProperty({
|
|
49
|
-
description: '
|
|
50
|
-
example: '
|
|
49
|
+
description: 'Storage key or path of the file',
|
|
50
|
+
example: 'uploads/abc123-vacation-photo.jpg'
|
|
51
51
|
}),
|
|
52
52
|
IsNotEmpty(),
|
|
53
53
|
IsString(),
|
|
@@ -55,7 +55,7 @@ _ts_decorate([
|
|
|
55
55
|
], CreateFileManagerDto.prototype, "key", void 0);
|
|
56
56
|
_ts_decorate([
|
|
57
57
|
ApiProperty({
|
|
58
|
-
description: 'Size of the
|
|
58
|
+
description: 'Size of the file in bytes',
|
|
59
59
|
example: '1024'
|
|
60
60
|
}),
|
|
61
61
|
IsNotEmpty(),
|
|
@@ -64,7 +64,7 @@ _ts_decorate([
|
|
|
64
64
|
], CreateFileManagerDto.prototype, "size", void 0);
|
|
65
65
|
_ts_decorate([
|
|
66
66
|
ApiProperty({
|
|
67
|
-
description: '
|
|
67
|
+
description: 'MIME type of file',
|
|
68
68
|
example: 'image/jpeg'
|
|
69
69
|
}),
|
|
70
70
|
IsNotEmpty(),
|
|
@@ -73,7 +73,7 @@ _ts_decorate([
|
|
|
73
73
|
], CreateFileManagerDto.prototype, "contentType", void 0);
|
|
74
74
|
_ts_decorate([
|
|
75
75
|
ApiProperty({
|
|
76
|
-
description: 'Indicates if the
|
|
76
|
+
description: 'Indicates if the file is private',
|
|
77
77
|
example: true
|
|
78
78
|
}),
|
|
79
79
|
IsNotEmpty(),
|
|
@@ -81,21 +81,21 @@ _ts_decorate([
|
|
|
81
81
|
_ts_metadata("design:type", Boolean)
|
|
82
82
|
], CreateFileManagerDto.prototype, "isPrivate", void 0);
|
|
83
83
|
_ts_decorate([
|
|
84
|
-
|
|
84
|
+
ApiPropertyOptional({
|
|
85
85
|
description: 'Folder ID (UUID)',
|
|
86
86
|
example: 'f2e9c8d0-7a2a-11eb-9439-0242ac130002'
|
|
87
87
|
}),
|
|
88
88
|
IsOptional(),
|
|
89
|
-
|
|
89
|
+
IsUUID(),
|
|
90
90
|
_ts_metadata("design:type", String)
|
|
91
91
|
], CreateFileManagerDto.prototype, "folderId", void 0);
|
|
92
92
|
_ts_decorate([
|
|
93
93
|
ApiPropertyOptional({
|
|
94
|
-
description: 'Storage configuration ID
|
|
94
|
+
description: 'Storage configuration ID',
|
|
95
95
|
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
96
96
|
}),
|
|
97
97
|
IsOptional(),
|
|
98
|
-
|
|
98
|
+
IsUUID(),
|
|
99
99
|
_ts_metadata("design:type", String)
|
|
100
100
|
], CreateFileManagerDto.prototype, "storageConfigId", void 0);
|
|
101
101
|
_ts_decorate([
|
|
@@ -115,21 +115,66 @@ export class UpdateFileManagerDto extends PartialType(CreateFileManagerDto) {
|
|
|
115
115
|
}
|
|
116
116
|
_ts_decorate([
|
|
117
117
|
ApiProperty({
|
|
118
|
-
description: 'Unique identifier of the
|
|
118
|
+
description: 'Unique identifier of the file',
|
|
119
119
|
example: 'f2e9c8d0-7a2a-11eb-9439-0242ac130002'
|
|
120
120
|
}),
|
|
121
|
+
IsUUID(),
|
|
121
122
|
IsNotEmpty(),
|
|
122
123
|
_ts_metadata("design:type", String)
|
|
123
124
|
], UpdateFileManagerDto.prototype, "id", void 0);
|
|
124
|
-
export class FileManagerResponseDto
|
|
125
|
-
constructor(
|
|
126
|
-
|
|
125
|
+
export class FileManagerResponseDto {
|
|
126
|
+
constructor(){
|
|
127
|
+
_define_property(this, "id", void 0);
|
|
128
|
+
_define_property(this, "name", void 0);
|
|
129
|
+
_define_property(this, "key", void 0);
|
|
130
|
+
_define_property(this, "size", void 0);
|
|
131
|
+
_define_property(this, "contentType", void 0);
|
|
132
|
+
_define_property(this, "isPrivate", void 0);
|
|
133
|
+
_define_property(this, "folderId", void 0);
|
|
134
|
+
_define_property(this, "storageConfigId", void 0);
|
|
135
|
+
_define_property(this, "location", void 0);
|
|
136
|
+
_define_property(this, "providerName", void 0);
|
|
127
137
|
}
|
|
128
138
|
}
|
|
139
|
+
_ts_decorate([
|
|
140
|
+
ApiProperty(),
|
|
141
|
+
_ts_metadata("design:type", String)
|
|
142
|
+
], FileManagerResponseDto.prototype, "id", void 0);
|
|
143
|
+
_ts_decorate([
|
|
144
|
+
ApiProperty(),
|
|
145
|
+
_ts_metadata("design:type", String)
|
|
146
|
+
], FileManagerResponseDto.prototype, "name", void 0);
|
|
147
|
+
_ts_decorate([
|
|
148
|
+
ApiProperty(),
|
|
149
|
+
_ts_metadata("design:type", String)
|
|
150
|
+
], FileManagerResponseDto.prototype, "key", void 0);
|
|
151
|
+
_ts_decorate([
|
|
152
|
+
ApiProperty(),
|
|
153
|
+
_ts_metadata("design:type", String)
|
|
154
|
+
], FileManagerResponseDto.prototype, "size", void 0);
|
|
155
|
+
_ts_decorate([
|
|
156
|
+
ApiProperty(),
|
|
157
|
+
_ts_metadata("design:type", String)
|
|
158
|
+
], FileManagerResponseDto.prototype, "contentType", void 0);
|
|
159
|
+
_ts_decorate([
|
|
160
|
+
ApiProperty(),
|
|
161
|
+
_ts_metadata("design:type", Boolean)
|
|
162
|
+
], FileManagerResponseDto.prototype, "isPrivate", void 0);
|
|
163
|
+
_ts_decorate([
|
|
164
|
+
ApiPropertyOptional(),
|
|
165
|
+
_ts_metadata("design:type", String)
|
|
166
|
+
], FileManagerResponseDto.prototype, "folderId", void 0);
|
|
167
|
+
_ts_decorate([
|
|
168
|
+
ApiPropertyOptional(),
|
|
169
|
+
_ts_metadata("design:type", String)
|
|
170
|
+
], FileManagerResponseDto.prototype, "storageConfigId", void 0);
|
|
171
|
+
_ts_decorate([
|
|
172
|
+
ApiPropertyOptional(),
|
|
173
|
+
_ts_metadata("design:type", typeof FileLocationEnum === "undefined" ? Object : FileLocationEnum)
|
|
174
|
+
], FileManagerResponseDto.prototype, "location", void 0);
|
|
129
175
|
_ts_decorate([
|
|
130
176
|
ApiPropertyOptional({
|
|
131
|
-
|
|
132
|
-
description: 'Name of the storage configuration/provider'
|
|
177
|
+
description: 'Name of the storage provider'
|
|
133
178
|
}),
|
|
134
179
|
_ts_metadata("design:type", String)
|
|
135
180
|
], FileManagerResponseDto.prototype, "providerName", void 0);
|
|
@@ -142,6 +187,8 @@ _ts_decorate([
|
|
|
142
187
|
ApiProperty({
|
|
143
188
|
example: 'f2e9c8d0-7a2a-11eb-9439-0242ac130002'
|
|
144
189
|
}),
|
|
190
|
+
IsUUID(),
|
|
191
|
+
IsNotEmpty(),
|
|
145
192
|
_ts_metadata("design:type", String)
|
|
146
193
|
], GetFilesRequestDto.prototype, "id", void 0);
|
|
147
194
|
export class FilesResponseDto {
|
|
@@ -156,47 +203,36 @@ export class FilesResponseDto {
|
|
|
156
203
|
}
|
|
157
204
|
}
|
|
158
205
|
_ts_decorate([
|
|
159
|
-
ApiProperty(
|
|
160
|
-
example: 'file123.jpg'
|
|
161
|
-
}),
|
|
206
|
+
ApiProperty(),
|
|
162
207
|
_ts_metadata("design:type", String)
|
|
163
208
|
], FilesResponseDto.prototype, "id", void 0);
|
|
164
209
|
_ts_decorate([
|
|
165
|
-
ApiProperty(
|
|
166
|
-
example: 'file123.jpg'
|
|
167
|
-
}),
|
|
210
|
+
ApiProperty(),
|
|
168
211
|
_ts_metadata("design:type", String)
|
|
169
212
|
], FilesResponseDto.prototype, "name", void 0);
|
|
170
213
|
_ts_decorate([
|
|
171
|
-
ApiProperty(
|
|
172
|
-
example: 'image/jpeg'
|
|
173
|
-
}),
|
|
214
|
+
ApiProperty(),
|
|
174
215
|
_ts_metadata("design:type", String)
|
|
175
216
|
], FilesResponseDto.prototype, "contentType", void 0);
|
|
176
217
|
_ts_decorate([
|
|
177
|
-
ApiProperty(
|
|
178
|
-
example: 'https://example.com/file123.jpg'
|
|
179
|
-
}),
|
|
218
|
+
ApiProperty(),
|
|
180
219
|
_ts_metadata("design:type", String)
|
|
181
220
|
], FilesResponseDto.prototype, "url", void 0);
|
|
182
221
|
_ts_decorate([
|
|
183
222
|
ApiPropertyOptional({
|
|
184
|
-
|
|
185
|
-
description: 'Storage provider type (local, aws, azure, sftp)'
|
|
223
|
+
description: 'Storage provider type'
|
|
186
224
|
}),
|
|
187
225
|
_ts_metadata("design:type", String)
|
|
188
226
|
], FilesResponseDto.prototype, "location", void 0);
|
|
189
227
|
_ts_decorate([
|
|
190
228
|
ApiPropertyOptional({
|
|
191
|
-
example: '123e4567-e89b-12d3-a456-426614174000',
|
|
192
229
|
description: 'Storage configuration ID'
|
|
193
230
|
}),
|
|
194
231
|
_ts_metadata("design:type", String)
|
|
195
232
|
], FilesResponseDto.prototype, "storageConfigId", void 0);
|
|
196
233
|
_ts_decorate([
|
|
197
234
|
ApiPropertyOptional({
|
|
198
|
-
|
|
199
|
-
description: 'Name of the storage configuration/provider'
|
|
235
|
+
description: 'Name of the storage provider'
|
|
200
236
|
}),
|
|
201
237
|
_ts_metadata("design:type", String)
|
|
202
238
|
], FilesResponseDto.prototype, "providerName", void 0);
|
package/fesm/dtos/folder.dto.js
CHANGED
|
@@ -21,7 +21,7 @@ function _ts_metadata(k, v) {
|
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
23
|
import { ApiProperty, PartialType } from '@nestjs/swagger';
|
|
24
|
-
import { IsNotEmpty, IsString } from 'class-validator';
|
|
24
|
+
import { IsNotEmpty, IsString, IsUUID } from 'class-validator';
|
|
25
25
|
export class CreateFolderDto {
|
|
26
26
|
constructor(){
|
|
27
27
|
_define_property(this, "name", void 0);
|
|
@@ -46,20 +46,26 @@ _ts_decorate([
|
|
|
46
46
|
description: 'Unique identifier of the folder',
|
|
47
47
|
example: 'f2e9c8d0-7a2a-11eb-9439-0242ac130002'
|
|
48
48
|
}),
|
|
49
|
+
IsUUID(),
|
|
49
50
|
IsNotEmpty(),
|
|
50
51
|
_ts_metadata("design:type", String)
|
|
51
52
|
], UpdateFolderDto.prototype, "id", void 0);
|
|
52
|
-
export class FolderResponseDto
|
|
53
|
-
constructor(
|
|
54
|
-
|
|
53
|
+
export class FolderResponseDto {
|
|
54
|
+
constructor(){
|
|
55
|
+
_define_property(this, "id", void 0);
|
|
56
|
+
_define_property(this, "name", void 0);
|
|
57
|
+
_define_property(this, "slug", void 0);
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
_ts_decorate([
|
|
58
|
-
ApiProperty(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
ApiProperty(),
|
|
62
|
+
_ts_metadata("design:type", String)
|
|
63
|
+
], FolderResponseDto.prototype, "id", void 0);
|
|
64
|
+
_ts_decorate([
|
|
65
|
+
ApiProperty(),
|
|
66
|
+
_ts_metadata("design:type", String)
|
|
67
|
+
], FolderResponseDto.prototype, "name", void 0);
|
|
68
|
+
_ts_decorate([
|
|
69
|
+
ApiProperty(),
|
|
64
70
|
_ts_metadata("design:type", String)
|
|
65
71
|
], FolderResponseDto.prototype, "slug", void 0);
|
|
@@ -22,11 +22,9 @@ function _ts_metadata(k, v) {
|
|
|
22
22
|
}
|
|
23
23
|
import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
|
|
24
24
|
import { FileLocationEnum } from '../enums';
|
|
25
|
-
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
26
|
-
import { IsBoolean, IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, MaxLength } from 'class-validator';
|
|
27
|
-
|
|
28
|
-
* DTO for creating storage configuration
|
|
29
|
-
*/ export class CreateStorageConfigDto {
|
|
25
|
+
import { ApiProperty, ApiPropertyOptional, OmitType, PartialType } from '@nestjs/swagger';
|
|
26
|
+
import { IsBoolean, IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
|
|
27
|
+
export class CreateStorageConfigDto {
|
|
30
28
|
constructor(){
|
|
31
29
|
_define_property(this, "name", void 0);
|
|
32
30
|
_define_property(this, "storage", void 0);
|
|
@@ -56,20 +54,6 @@ _ts_decorate([
|
|
|
56
54
|
], CreateStorageConfigDto.prototype, "storage", void 0);
|
|
57
55
|
_ts_decorate([
|
|
58
56
|
ApiProperty({
|
|
59
|
-
type: 'object',
|
|
60
|
-
properties: {
|
|
61
|
-
region: {
|
|
62
|
-
type: 'string',
|
|
63
|
-
example: 'us-east-1',
|
|
64
|
-
description: 'Cloud region'
|
|
65
|
-
},
|
|
66
|
-
bucket: {
|
|
67
|
-
type: 'string',
|
|
68
|
-
example: 'my-bucket',
|
|
69
|
-
description: 'Bucket name'
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
additionalProperties: true,
|
|
73
57
|
description: 'Provider-specific configuration',
|
|
74
58
|
example: {
|
|
75
59
|
region: 'us-east-1',
|
|
@@ -98,91 +82,20 @@ _ts_decorate([
|
|
|
98
82
|
IsOptional(),
|
|
99
83
|
_ts_metadata("design:type", Boolean)
|
|
100
84
|
], CreateStorageConfigDto.prototype, "isDefault", void 0);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
constructor(){
|
|
105
|
-
_define_property(this, "id", void 0);
|
|
106
|
-
_define_property(this, "name", void 0);
|
|
107
|
-
_define_property(this, "storage", void 0);
|
|
108
|
-
_define_property(this, "config", void 0);
|
|
109
|
-
_define_property(this, "isActive", void 0);
|
|
110
|
-
_define_property(this, "isDefault", void 0);
|
|
85
|
+
export class UpdateStorageConfigDto extends PartialType(OmitType(CreateStorageConfigDto, [])) {
|
|
86
|
+
constructor(...args){
|
|
87
|
+
super(...args), _define_property(this, "id", void 0);
|
|
111
88
|
}
|
|
112
89
|
}
|
|
113
90
|
_ts_decorate([
|
|
114
91
|
ApiProperty({
|
|
115
92
|
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
116
93
|
}),
|
|
117
|
-
|
|
94
|
+
IsUUID(),
|
|
118
95
|
IsNotEmpty(),
|
|
119
96
|
_ts_metadata("design:type", String)
|
|
120
97
|
], UpdateStorageConfigDto.prototype, "id", void 0);
|
|
121
|
-
|
|
122
|
-
ApiPropertyOptional({
|
|
123
|
-
example: 'Production AWS S3'
|
|
124
|
-
}),
|
|
125
|
-
IsString(),
|
|
126
|
-
IsOptional(),
|
|
127
|
-
MaxLength(255),
|
|
128
|
-
_ts_metadata("design:type", String)
|
|
129
|
-
], UpdateStorageConfigDto.prototype, "name", void 0);
|
|
130
|
-
_ts_decorate([
|
|
131
|
-
ApiPropertyOptional({
|
|
132
|
-
enum: FileLocationEnum,
|
|
133
|
-
example: FileLocationEnum.AWS
|
|
134
|
-
}),
|
|
135
|
-
IsEnum(FileLocationEnum),
|
|
136
|
-
IsOptional(),
|
|
137
|
-
_ts_metadata("design:type", typeof FileLocationEnum === "undefined" ? Object : FileLocationEnum)
|
|
138
|
-
], UpdateStorageConfigDto.prototype, "storage", void 0);
|
|
139
|
-
_ts_decorate([
|
|
140
|
-
ApiPropertyOptional({
|
|
141
|
-
type: 'object',
|
|
142
|
-
properties: {
|
|
143
|
-
region: {
|
|
144
|
-
type: 'string',
|
|
145
|
-
example: 'us-east-1',
|
|
146
|
-
description: 'Cloud region'
|
|
147
|
-
},
|
|
148
|
-
bucket: {
|
|
149
|
-
type: 'string',
|
|
150
|
-
example: 'my-bucket',
|
|
151
|
-
description: 'Bucket name'
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
additionalProperties: true,
|
|
155
|
-
description: 'Provider-specific configuration',
|
|
156
|
-
example: {
|
|
157
|
-
region: 'us-east-1',
|
|
158
|
-
bucket: 'my-bucket'
|
|
159
|
-
}
|
|
160
|
-
}),
|
|
161
|
-
IsObject(),
|
|
162
|
-
IsOptional(),
|
|
163
|
-
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
164
|
-
], UpdateStorageConfigDto.prototype, "config", void 0);
|
|
165
|
-
_ts_decorate([
|
|
166
|
-
ApiPropertyOptional({
|
|
167
|
-
example: true,
|
|
168
|
-
description: 'Whether storage configuration is active'
|
|
169
|
-
}),
|
|
170
|
-
IsBoolean(),
|
|
171
|
-
IsOptional(),
|
|
172
|
-
_ts_metadata("design:type", Boolean)
|
|
173
|
-
], UpdateStorageConfigDto.prototype, "isActive", void 0);
|
|
174
|
-
_ts_decorate([
|
|
175
|
-
ApiPropertyOptional({
|
|
176
|
-
example: false,
|
|
177
|
-
description: 'Set as default storage configuration'
|
|
178
|
-
}),
|
|
179
|
-
IsBoolean(),
|
|
180
|
-
IsOptional(),
|
|
181
|
-
_ts_metadata("design:type", Boolean)
|
|
182
|
-
], UpdateStorageConfigDto.prototype, "isDefault", void 0);
|
|
183
|
-
/**
|
|
184
|
-
* Response DTO for storage configuration
|
|
185
|
-
*/ export class StorageConfigResponseDto extends IdentityResponseDto {
|
|
98
|
+
export class StorageConfigResponseDto extends IdentityResponseDto {
|
|
186
99
|
constructor(...args){
|
|
187
100
|
super(...args), _define_property(this, "name", void 0), _define_property(this, "storage", void 0), _define_property(this, "config", void 0), _define_property(this, "isActive", void 0), _define_property(this, "isDefault", void 0);
|
|
188
101
|
}
|
package/fesm/dtos/upload.dto.js
CHANGED
|
@@ -21,9 +21,8 @@ function _ts_metadata(k, v) {
|
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
23
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
24
|
-
import { IsBoolean, IsEnum, IsInt, IsOptional, IsUUID, Matches, Max, Min } from 'class-validator';
|
|
24
|
+
import { IsArray, IsBoolean, IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, IsUUID, Matches, Max, Min } from 'class-validator';
|
|
25
25
|
import { Type } from 'class-transformer';
|
|
26
|
-
// Image format enum
|
|
27
26
|
export var ImageFormat = /*#__PURE__*/ function(ImageFormat) {
|
|
28
27
|
ImageFormat["ORIGINAL"] = "original";
|
|
29
28
|
ImageFormat["JPEG"] = "jpeg";
|
|
@@ -40,13 +39,15 @@ export class DeleteSingleFileDto {
|
|
|
40
39
|
_ts_decorate([
|
|
41
40
|
ApiProperty({
|
|
42
41
|
description: 'Key of the file to delete',
|
|
43
|
-
example: '/uploads/some
|
|
42
|
+
example: '/uploads/some-path'
|
|
44
43
|
}),
|
|
44
|
+
IsNotEmpty(),
|
|
45
|
+
IsString(),
|
|
45
46
|
_ts_metadata("design:type", String)
|
|
46
47
|
], DeleteSingleFileDto.prototype, "key", void 0);
|
|
47
48
|
_ts_decorate([
|
|
48
49
|
ApiPropertyOptional({
|
|
49
|
-
description: 'Storage configuration ID
|
|
50
|
+
description: 'Storage configuration ID',
|
|
50
51
|
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
51
52
|
}),
|
|
52
53
|
IsOptional(),
|
|
@@ -61,20 +62,25 @@ export class DeleteMultipleFileDto {
|
|
|
61
62
|
}
|
|
62
63
|
_ts_decorate([
|
|
63
64
|
ApiProperty({
|
|
64
|
-
description: 'Array of file
|
|
65
|
+
description: 'Array of file keys to delete',
|
|
65
66
|
example: [
|
|
66
|
-
'/uploads/
|
|
67
|
-
'
|
|
67
|
+
'/uploads/file1',
|
|
68
|
+
'/uploads/file2'
|
|
68
69
|
],
|
|
69
70
|
type: [
|
|
70
71
|
String
|
|
71
72
|
]
|
|
72
73
|
}),
|
|
74
|
+
IsNotEmpty(),
|
|
75
|
+
IsArray(),
|
|
76
|
+
IsString({
|
|
77
|
+
each: true
|
|
78
|
+
}),
|
|
73
79
|
_ts_metadata("design:type", Array)
|
|
74
80
|
], DeleteMultipleFileDto.prototype, "keys", void 0);
|
|
75
81
|
_ts_decorate([
|
|
76
82
|
ApiPropertyOptional({
|
|
77
|
-
description: 'Storage configuration ID
|
|
83
|
+
description: 'Storage configuration ID',
|
|
78
84
|
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
79
85
|
}),
|
|
80
86
|
IsOptional(),
|
|
@@ -94,7 +100,7 @@ export class UploadOptionsDto {
|
|
|
94
100
|
}
|
|
95
101
|
_ts_decorate([
|
|
96
102
|
ApiPropertyOptional({
|
|
97
|
-
description: 'Storage configuration ID
|
|
103
|
+
description: 'Storage configuration ID',
|
|
98
104
|
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
99
105
|
}),
|
|
100
106
|
IsOptional(),
|
|
@@ -103,7 +109,7 @@ _ts_decorate([
|
|
|
103
109
|
], UploadOptionsDto.prototype, "storageConfigId", void 0);
|
|
104
110
|
_ts_decorate([
|
|
105
111
|
ApiPropertyOptional({
|
|
106
|
-
description: 'Folder path
|
|
112
|
+
description: 'Folder path for upload',
|
|
107
113
|
example: 'uploads/images'
|
|
108
114
|
}),
|
|
109
115
|
IsOptional(),
|
|
@@ -114,7 +120,7 @@ _ts_decorate([
|
|
|
114
120
|
], UploadOptionsDto.prototype, "folderPath", void 0);
|
|
115
121
|
_ts_decorate([
|
|
116
122
|
ApiPropertyOptional({
|
|
117
|
-
description: 'Maximum width
|
|
123
|
+
description: 'Maximum width in pixels',
|
|
118
124
|
example: 1280,
|
|
119
125
|
minimum: 100,
|
|
120
126
|
maximum: 10000,
|
|
@@ -129,7 +135,7 @@ _ts_decorate([
|
|
|
129
135
|
], UploadOptionsDto.prototype, "maxWidth", void 0);
|
|
130
136
|
_ts_decorate([
|
|
131
137
|
ApiPropertyOptional({
|
|
132
|
-
description: 'Maximum height
|
|
138
|
+
description: 'Maximum height in pixels',
|
|
133
139
|
example: 1280,
|
|
134
140
|
minimum: 100,
|
|
135
141
|
maximum: 10000,
|
|
@@ -144,7 +150,7 @@ _ts_decorate([
|
|
|
144
150
|
], UploadOptionsDto.prototype, "maxHeight", void 0);
|
|
145
151
|
_ts_decorate([
|
|
146
152
|
ApiPropertyOptional({
|
|
147
|
-
description: 'Compression quality (1
|
|
153
|
+
description: 'Compression quality (1-100)',
|
|
148
154
|
example: 85,
|
|
149
155
|
minimum: 1,
|
|
150
156
|
maximum: 100,
|
|
@@ -159,7 +165,7 @@ _ts_decorate([
|
|
|
159
165
|
], UploadOptionsDto.prototype, "quality", void 0);
|
|
160
166
|
_ts_decorate([
|
|
161
167
|
ApiPropertyOptional({
|
|
162
|
-
description: 'Output
|
|
168
|
+
description: 'Output image format',
|
|
163
169
|
enum: ImageFormat,
|
|
164
170
|
default: "original"
|
|
165
171
|
}),
|
|
@@ -169,7 +175,7 @@ _ts_decorate([
|
|
|
169
175
|
], UploadOptionsDto.prototype, "format", void 0);
|
|
170
176
|
_ts_decorate([
|
|
171
177
|
ApiPropertyOptional({
|
|
172
|
-
description: 'Whether to compress the image
|
|
178
|
+
description: 'Whether to compress the image',
|
|
173
179
|
example: true,
|
|
174
180
|
default: true
|
|
175
181
|
}),
|
|
@@ -196,7 +202,7 @@ _ts_decorate([
|
|
|
196
202
|
], FileUploadResponsePayloadDto.prototype, "name", void 0);
|
|
197
203
|
_ts_decorate([
|
|
198
204
|
ApiProperty({
|
|
199
|
-
example: '
|
|
205
|
+
example: 'image/jpeg'
|
|
200
206
|
}),
|
|
201
207
|
_ts_metadata("design:type", String)
|
|
202
208
|
], FileUploadResponsePayloadDto.prototype, "contentType", void 0);
|
|
@@ -208,21 +214,21 @@ _ts_decorate([
|
|
|
208
214
|
], FileUploadResponsePayloadDto.prototype, "size", void 0);
|
|
209
215
|
_ts_decorate([
|
|
210
216
|
ApiProperty({
|
|
211
|
-
example: '
|
|
217
|
+
example: 'uploads/file123.jpg'
|
|
212
218
|
}),
|
|
213
219
|
_ts_metadata("design:type", String)
|
|
214
220
|
], FileUploadResponsePayloadDto.prototype, "key", void 0);
|
|
215
221
|
_ts_decorate([
|
|
216
222
|
ApiProperty({
|
|
217
223
|
example: 'local',
|
|
218
|
-
description: 'Storage provider type
|
|
224
|
+
description: 'Storage provider type'
|
|
219
225
|
}),
|
|
220
226
|
_ts_metadata("design:type", String)
|
|
221
227
|
], FileUploadResponsePayloadDto.prototype, "location", void 0);
|
|
222
228
|
_ts_decorate([
|
|
223
229
|
ApiProperty({
|
|
224
230
|
example: '123e4567-e89b-12d3-a456-426614174000',
|
|
225
|
-
description: 'Storage configuration ID
|
|
231
|
+
description: 'Storage configuration ID'
|
|
226
232
|
}),
|
|
227
233
|
_ts_metadata("design:type", String)
|
|
228
234
|
], FileUploadResponsePayloadDto.prototype, "storageConfigId", void 0);
|
|
@@ -21,11 +21,10 @@ function _ts_metadata(k, v) {
|
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
23
|
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
|
24
|
-
import {
|
|
25
|
-
export class FileManagerWithCompany extends
|
|
24
|
+
import { FileManager } from './file-manager.entity';
|
|
25
|
+
export class FileManagerWithCompany extends FileManager {
|
|
26
26
|
constructor(...args){
|
|
27
|
-
super(...args),
|
|
28
|
-
_define_property(this, "companyId", void 0), _define_property(this, "folder", void 0);
|
|
27
|
+
super(...args), _define_property(this, "companyId", void 0);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
_ts_decorate([
|
|
@@ -20,13 +20,81 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
20
20
|
function _ts_metadata(k, v) {
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
|
|
23
|
+
import { Identity } from '@flusys/nestjs-shared/entities';
|
|
24
|
+
import { FileLocationEnum } from '../enums';
|
|
25
|
+
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
|
26
|
+
export class FileManager extends Identity {
|
|
26
27
|
constructor(...args){
|
|
27
|
-
super(...args), _define_property(this, "folder", void 0);
|
|
28
|
+
super(...args), _define_property(this, "name", void 0), _define_property(this, "contentType", void 0), _define_property(this, "size", void 0), _define_property(this, "key", void 0), _define_property(this, "url", void 0), _define_property(this, "location", void 0), _define_property(this, "storageConfigId", void 0), _define_property(this, "expiresAt", null), _define_property(this, "isPrivate", void 0), _define_property(this, "folder", void 0);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
_ts_decorate([
|
|
32
|
+
Column({
|
|
33
|
+
type: 'varchar',
|
|
34
|
+
length: 255,
|
|
35
|
+
nullable: false
|
|
36
|
+
}),
|
|
37
|
+
_ts_metadata("design:type", String)
|
|
38
|
+
], FileManager.prototype, "name", void 0);
|
|
39
|
+
_ts_decorate([
|
|
40
|
+
Column({
|
|
41
|
+
type: 'varchar',
|
|
42
|
+
length: 255,
|
|
43
|
+
nullable: false
|
|
44
|
+
}),
|
|
45
|
+
_ts_metadata("design:type", String)
|
|
46
|
+
], FileManager.prototype, "contentType", void 0);
|
|
47
|
+
_ts_decorate([
|
|
48
|
+
Column({
|
|
49
|
+
type: 'varchar',
|
|
50
|
+
length: 255,
|
|
51
|
+
nullable: false
|
|
52
|
+
}),
|
|
53
|
+
_ts_metadata("design:type", String)
|
|
54
|
+
], FileManager.prototype, "size", void 0);
|
|
55
|
+
_ts_decorate([
|
|
56
|
+
Column({
|
|
57
|
+
type: 'text',
|
|
58
|
+
nullable: false
|
|
59
|
+
}),
|
|
60
|
+
_ts_metadata("design:type", String)
|
|
61
|
+
], FileManager.prototype, "key", void 0);
|
|
62
|
+
_ts_decorate([
|
|
63
|
+
Column({
|
|
64
|
+
type: 'text',
|
|
65
|
+
nullable: true
|
|
66
|
+
}),
|
|
67
|
+
_ts_metadata("design:type", Object)
|
|
68
|
+
], FileManager.prototype, "url", void 0);
|
|
69
|
+
_ts_decorate([
|
|
70
|
+
Column({
|
|
71
|
+
type: 'text',
|
|
72
|
+
nullable: false
|
|
73
|
+
}),
|
|
74
|
+
_ts_metadata("design:type", typeof FileLocationEnum === "undefined" ? Object : FileLocationEnum)
|
|
75
|
+
], FileManager.prototype, "location", void 0);
|
|
76
|
+
_ts_decorate([
|
|
77
|
+
Column({
|
|
78
|
+
type: 'uuid',
|
|
79
|
+
nullable: true
|
|
80
|
+
}),
|
|
81
|
+
_ts_metadata("design:type", Object)
|
|
82
|
+
], FileManager.prototype, "storageConfigId", void 0);
|
|
83
|
+
_ts_decorate([
|
|
84
|
+
Column({
|
|
85
|
+
type: 'bigint',
|
|
86
|
+
nullable: true
|
|
87
|
+
}),
|
|
88
|
+
_ts_metadata("design:type", Object)
|
|
89
|
+
], FileManager.prototype, "expiresAt", void 0);
|
|
90
|
+
_ts_decorate([
|
|
91
|
+
Column({
|
|
92
|
+
type: 'boolean',
|
|
93
|
+
nullable: false,
|
|
94
|
+
default: false
|
|
95
|
+
}),
|
|
96
|
+
_ts_metadata("design:type", Boolean)
|
|
97
|
+
], FileManager.prototype, "isPrivate", void 0);
|
|
30
98
|
_ts_decorate([
|
|
31
99
|
ManyToOne('Folder', (folder)=>folder.fileManager, {
|
|
32
100
|
nullable: true,
|
|
@@ -21,11 +21,10 @@ function _ts_metadata(k, v) {
|
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
23
|
import { Column, Entity, OneToMany } from 'typeorm';
|
|
24
|
-
import {
|
|
25
|
-
export class FolderWithCompany extends
|
|
24
|
+
import { Folder } from './folder.entity';
|
|
25
|
+
export class FolderWithCompany extends Folder {
|
|
26
26
|
constructor(...args){
|
|
27
|
-
super(...args),
|
|
28
|
-
_define_property(this, "companyId", void 0), _define_property(this, "fileManager", void 0);
|
|
27
|
+
super(...args), _define_property(this, "companyId", void 0);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
_ts_decorate([
|