@maioradv/nestjs-core 1.2.6 → 1.2.8
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.
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export declare const IsStringClause: (
|
|
1
|
+
export declare const IsStringClause: (options?: {
|
|
2
|
+
isArray?: boolean;
|
|
3
|
+
}) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
2
4
|
export declare const IsEnumClause: (model: object) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
3
5
|
export declare const IsNumberClause: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
4
6
|
export declare const IsBooleanClause: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -5,11 +5,11 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
6
|
const class_transformer_1 = require("class-transformer");
|
|
7
7
|
const class_validator_1 = require("class-validator");
|
|
8
|
-
const IsStringClause = () => {
|
|
8
|
+
const IsStringClause = (options) => {
|
|
9
9
|
return (0, common_1.applyDecorators)((0, swagger_1.ApiPropertyOptional)({
|
|
10
10
|
type: String,
|
|
11
|
-
description: 'Check if field contains the string'
|
|
12
|
-
}), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)());
|
|
11
|
+
description: options?.isArray ? 'A string or a comma-separated list of strings' : 'Check if field contains the string'
|
|
12
|
+
}), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), options?.isArray ? (0, class_validator_1.IsArray)() : undefined, options?.isArray ? (0, class_transformer_1.Transform)(({ value }) => value.split(',')) : undefined);
|
|
13
13
|
};
|
|
14
14
|
exports.IsStringClause = IsStringClause;
|
|
15
15
|
const IsEnumClause = (model) => {
|
|
@@ -6,10 +6,12 @@ import { Stats } from 'fs';
|
|
|
6
6
|
import internal from 'stream';
|
|
7
7
|
export declare class StorageService {
|
|
8
8
|
rootPath: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
useRealPath: boolean;
|
|
10
|
+
read(relativePath: string): Promise<Buffer>;
|
|
11
|
+
write(relativePath: string, data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | internal.Stream): Promise<void>;
|
|
12
|
+
append(relativePath: string, data: string | Uint8Array): Promise<void>;
|
|
13
|
+
delete(relativePath: string): Promise<void>;
|
|
14
|
+
stat(relativePath: string): Promise<Stats>;
|
|
15
|
+
private realPath;
|
|
14
16
|
private safeDirectory;
|
|
15
17
|
}
|
|
@@ -15,32 +15,36 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
let StorageService = class StorageService {
|
|
16
16
|
constructor() {
|
|
17
17
|
this.rootPath = (0, path_helper_1.joinFromRoot)('public');
|
|
18
|
+
this.useRealPath = false;
|
|
18
19
|
}
|
|
19
|
-
async read(
|
|
20
|
-
const realPath =
|
|
20
|
+
async read(relativePath) {
|
|
21
|
+
const realPath = this.realPath(relativePath);
|
|
21
22
|
return await fs_1.promises.readFile(realPath, {});
|
|
22
23
|
}
|
|
23
|
-
async write(
|
|
24
|
-
const realPath =
|
|
24
|
+
async write(relativePath, data) {
|
|
25
|
+
const realPath = this.realPath(relativePath);
|
|
25
26
|
await this.safeDirectory(realPath);
|
|
26
27
|
return await fs_1.promises.writeFile(realPath, data, 'utf8');
|
|
27
28
|
}
|
|
28
|
-
async append(
|
|
29
|
-
const realPath =
|
|
29
|
+
async append(relativePath, data) {
|
|
30
|
+
const realPath = this.realPath(relativePath);
|
|
30
31
|
await this.safeDirectory(realPath);
|
|
31
32
|
return await fs_1.promises.appendFile(realPath, data + os_1.EOL);
|
|
32
33
|
}
|
|
33
|
-
async delete(
|
|
34
|
-
const realPath =
|
|
34
|
+
async delete(relativePath) {
|
|
35
|
+
const realPath = this.realPath(relativePath);
|
|
35
36
|
try {
|
|
36
37
|
return await fs_1.promises.unlink(realPath);
|
|
37
38
|
}
|
|
38
39
|
catch (e) { }
|
|
39
40
|
}
|
|
40
|
-
async stat(
|
|
41
|
-
const realPath =
|
|
41
|
+
async stat(relativePath) {
|
|
42
|
+
const realPath = this.realPath(relativePath);
|
|
42
43
|
return fs_1.promises.stat(realPath);
|
|
43
44
|
}
|
|
45
|
+
realPath(relativePath) {
|
|
46
|
+
return this.useRealPath ? relativePath : (0, path_1.join)(this.rootPath, relativePath);
|
|
47
|
+
}
|
|
44
48
|
async safeDirectory(path) {
|
|
45
49
|
const dirPath = (0, path_1.dirname)(path);
|
|
46
50
|
try {
|