@trapi/metadata 1.0.0-alpha.7 → 1.0.0-alpha.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.
- package/dist/cache/driver.d.ts +13 -13
- package/dist/cache/driver.js +83 -83
- package/dist/cache/index.d.ts +3 -3
- package/dist/cache/index.js +25 -25
- package/dist/cache/type.d.ts +32 -32
- package/dist/cache/type.js +8 -8
- package/dist/cache/utils.d.ts +3 -3
- package/dist/cache/utils.js +52 -52
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +23 -23
- package/dist/config/type.d.ts +36 -36
- package/dist/config/type.js +8 -8
- package/dist/decorator/constants.d.ts +40 -40
- package/dist/decorator/constants.js +52 -52
- package/dist/decorator/index.d.ts +6 -6
- package/dist/decorator/index.js +28 -28
- package/dist/decorator/preset/index.d.ts +2 -2
- package/dist/decorator/preset/index.js +24 -24
- package/dist/decorator/preset/type.d.ts +5 -5
- package/dist/decorator/preset/type.js +8 -8
- package/dist/decorator/preset/utils/check.d.ts +2 -2
- package/dist/decorator/preset/utils/check.js +17 -17
- package/dist/decorator/preset/utils/index.d.ts +3 -3
- package/dist/decorator/preset/utils/index.js +25 -25
- package/dist/decorator/preset/utils/load.d.ts +2 -2
- package/dist/decorator/preset/utils/load.js +44 -44
- package/dist/decorator/preset/utils/normalize.d.ts +1 -1
- package/dist/decorator/preset/utils/normalize.js +26 -26
- package/dist/decorator/property-manager/index.d.ts +2 -2
- package/dist/decorator/property-manager/index.js +24 -24
- package/dist/decorator/property-manager/module.d.ts +16 -16
- package/dist/decorator/property-manager/module.js +58 -58
- package/dist/decorator/property-manager/utils.d.ts +5 -5
- package/dist/decorator/property-manager/utils.js +91 -91
- package/dist/decorator/resolver/index.d.ts +2 -2
- package/dist/decorator/resolver/index.js +24 -24
- package/dist/decorator/resolver/module.d.ts +26 -26
- package/dist/decorator/resolver/module.js +71 -71
- package/dist/decorator/resolver/type.d.ts +9 -9
- package/dist/decorator/resolver/type.js +2 -2
- package/dist/decorator/sets/class.d.ts +6 -6
- package/dist/decorator/sets/class.js +8 -8
- package/dist/decorator/sets/index.d.ts +7 -7
- package/dist/decorator/sets/index.js +28 -28
- package/dist/decorator/sets/method.d.ts +13 -13
- package/dist/decorator/sets/method.js +8 -8
- package/dist/decorator/sets/mixed.d.ts +11 -11
- package/dist/decorator/sets/mixed.js +8 -8
- package/dist/decorator/sets/parameter.d.ts +20 -20
- package/dist/decorator/sets/parameter.js +8 -8
- package/dist/decorator/sets/request.d.ts +5 -5
- package/dist/decorator/sets/request.js +8 -8
- package/dist/decorator/sets/response.d.ts +16 -16
- package/dist/decorator/sets/response.js +8 -8
- package/dist/decorator/sets/type.d.ts +3 -3
- package/dist/decorator/sets/type.js +2 -2
- package/dist/decorator/type.d.ts +31 -31
- package/dist/decorator/type.js +8 -8
- package/dist/error/base.d.ts +2 -2
- package/dist/error/base.js +12 -12
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.js +23 -23
- package/dist/generator/abstract.d.ts +18 -18
- package/dist/generator/abstract.js +150 -150
- package/dist/generator/abstract.js.map +1 -1
- package/dist/generator/controller/index.d.ts +2 -2
- package/dist/generator/controller/index.js +24 -24
- package/dist/generator/controller/module.d.ts +12 -12
- package/dist/generator/controller/module.js +67 -67
- package/dist/generator/controller/type.d.ts +46 -46
- package/dist/generator/controller/type.js +2 -2
- package/dist/generator/index.d.ts +6 -6
- package/dist/generator/index.js +28 -28
- package/dist/generator/metadata/index.d.ts +3 -3
- package/dist/generator/metadata/index.js +25 -25
- package/dist/generator/metadata/module.d.ts +38 -38
- package/dist/generator/metadata/module.js +142 -142
- package/dist/generator/metadata/type.d.ts +24 -24
- package/dist/generator/metadata/type.js +2 -2
- package/dist/generator/metadata/utils.d.ts +2 -2
- package/dist/generator/metadata/utils.js +18 -18
- package/dist/generator/method/constants.d.ts +10 -10
- package/dist/generator/method/constants.js +20 -20
- package/dist/generator/method/index.d.ts +3 -3
- package/dist/generator/method/index.js +25 -25
- package/dist/generator/method/module.d.ts +18 -18
- package/dist/generator/method/module.js +187 -187
- package/dist/generator/method/type.d.ts +22 -22
- package/dist/generator/method/type.js +8 -8
- package/dist/generator/parameter/constants.d.ts +18 -18
- package/dist/generator/parameter/constants.js +29 -29
- package/dist/generator/parameter/error.d.ts +34 -34
- package/dist/generator/parameter/error.js +67 -67
- package/dist/generator/parameter/index.d.ts +4 -4
- package/dist/generator/parameter/index.js +26 -26
- package/dist/generator/parameter/module.d.ts +28 -28
- package/dist/generator/parameter/module.js +555 -555
- package/dist/generator/parameter/type.d.ts +24 -24
- package/dist/generator/parameter/type.js +8 -8
- package/dist/generator/type.d.ts +19 -19
- package/dist/generator/type.js +8 -8
- package/dist/index.d.ts +9 -9
- package/dist/index.js +31 -31
- package/dist/module.d.ts +4 -4
- package/dist/module.js +40 -40
- package/dist/resolver/constants.d.ts +26 -26
- package/dist/resolver/constants.js +36 -36
- package/dist/resolver/error.d.ts +7 -7
- package/dist/resolver/error.js +40 -40
- package/dist/resolver/extension/index.d.ts +2 -2
- package/dist/resolver/extension/index.js +24 -24
- package/dist/resolver/extension/module.d.ts +4 -4
- package/dist/resolver/extension/module.js +26 -26
- package/dist/resolver/extension/type.d.ts +7 -7
- package/dist/resolver/extension/type.js +8 -8
- package/dist/resolver/index.d.ts +5 -5
- package/dist/resolver/index.js +27 -27
- package/dist/resolver/module.d.ts +53 -53
- package/dist/resolver/module.js +1102 -1102
- package/dist/resolver/type.d.ts +138 -138
- package/dist/resolver/type.js +129 -129
- package/dist/type.d.ts +1 -1
- package/dist/type.js +8 -8
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +22 -0
- package/dist/utils/array.js.map +1 -0
- package/dist/utils/index.d.ts +9 -8
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +31 -30
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/initializer.d.ts +4 -4
- package/dist/utils/initializer.js +130 -130
- package/dist/utils/js-doc/constants.d.ts +18 -18
- package/dist/utils/js-doc/constants.js +29 -29
- package/dist/utils/js-doc/index.d.ts +3 -3
- package/dist/utils/js-doc/index.js +25 -25
- package/dist/utils/js-doc/module.d.ts +8 -8
- package/dist/utils/js-doc/module.js +97 -97
- package/dist/utils/js-doc/utils.d.ts +2 -2
- package/dist/utils/js-doc/utils.js +28 -28
- package/dist/utils/node/index.d.ts +2 -2
- package/dist/utils/node/index.js +24 -24
- package/dist/utils/node/module.d.ts +9 -9
- package/dist/utils/node/module.js +51 -51
- package/dist/utils/node/type.d.ts +5 -5
- package/dist/utils/node/type.js +8 -8
- package/dist/utils/object.d.ts +1 -1
- package/dist/utils/object.js +14 -14
- package/dist/utils/path-normalize.d.ts +1 -1
- package/dist/utils/path-normalize.js +16 -16
- package/dist/utils/source-files.d.ts +2 -2
- package/dist/utils/source-files.js +31 -31
- package/dist/utils/tsconfig/index.d.ts +2 -2
- package/dist/utils/tsconfig/index.js +24 -24
- package/dist/utils/tsconfig/module.d.ts +3 -3
- package/dist/utils/tsconfig/module.js +53 -53
- package/dist/utils/tsconfig/type.d.ts +10 -10
- package/dist/utils/tsconfig/type.js +8 -8
- package/dist/utils/validator/constants.d.ts +12 -12
- package/dist/utils/validator/constants.js +22 -22
- package/dist/utils/validator/index.d.ts +3 -3
- package/dist/utils/validator/index.js +25 -25
- package/dist/utils/validator/module.d.ts +3 -3
- package/dist/utils/validator/module.js +141 -141
- package/dist/utils/validator/type.d.ts +5 -5
- package/dist/utils/validator/type.js +8 -8
- package/package.json +5 -6
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./module"), exports);
|
|
24
|
-
__exportStar(require("./type"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./module"), exports);
|
|
24
|
+
__exportStar(require("./type"), exports);
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TsConfig, TsconfigLoadContext } from './type';
|
|
2
|
-
export declare function loadTSConfig(context?: TsconfigLoadContext): Promise<TsConfig>;
|
|
3
|
-
export declare function softLoadTsconfig(context?: TsconfigLoadContext): Promise<TsConfig>;
|
|
1
|
+
import type { TsConfig, TsconfigLoadContext } from './type';
|
|
2
|
+
export declare function loadTSConfig(context?: TsconfigLoadContext): Promise<TsConfig>;
|
|
3
|
+
export declare function softLoadTsconfig(context?: TsconfigLoadContext): Promise<TsConfig>;
|
|
4
4
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.softLoadTsconfig = exports.loadTSConfig = void 0;
|
|
13
|
-
const locter_1 = require("locter");
|
|
14
|
-
const node_process_1 = __importDefault(require("node:process"));
|
|
15
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
-
const typescript_1 = require("typescript");
|
|
17
|
-
async function loadTSConfig(context = {}) {
|
|
18
|
-
let fileName;
|
|
19
|
-
let filePath;
|
|
20
|
-
const cwd = context.cwd || node_process_1.default.cwd();
|
|
21
|
-
if (typeof context.name === 'string') {
|
|
22
|
-
if (node_path_1.default.isAbsolute(context.name)) {
|
|
23
|
-
filePath = context.name;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
filePath = node_path_1.default.resolve(cwd, context.name);
|
|
27
|
-
}
|
|
28
|
-
fileName = node_path_1.default.basename(filePath);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
fileName = 'tsconfig.json';
|
|
32
|
-
filePath = node_path_1.default.join(cwd, fileName);
|
|
33
|
-
}
|
|
34
|
-
const content = await (0, locter_1.load)(filePath);
|
|
35
|
-
if (!(0, locter_1.isObject)(content)) {
|
|
36
|
-
throw new Error('The tsconfig file is malformed.');
|
|
37
|
-
}
|
|
38
|
-
if (typeof content.compilerOptions !== 'undefined') {
|
|
39
|
-
const { options: compilerOptions } = (0, typescript_1.convertCompilerOptionsFromJson)(content.compilerOptions, cwd, fileName);
|
|
40
|
-
content.compilerOptions = compilerOptions;
|
|
41
|
-
}
|
|
42
|
-
return content;
|
|
43
|
-
}
|
|
44
|
-
exports.loadTSConfig = loadTSConfig;
|
|
45
|
-
async function softLoadTsconfig(context = {}) {
|
|
46
|
-
try {
|
|
47
|
-
return await loadTSConfig(context);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.softLoadTsconfig = softLoadTsconfig;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.softLoadTsconfig = exports.loadTSConfig = void 0;
|
|
13
|
+
const locter_1 = require("locter");
|
|
14
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
15
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
+
const typescript_1 = require("typescript");
|
|
17
|
+
async function loadTSConfig(context = {}) {
|
|
18
|
+
let fileName;
|
|
19
|
+
let filePath;
|
|
20
|
+
const cwd = context.cwd || node_process_1.default.cwd();
|
|
21
|
+
if (typeof context.name === 'string') {
|
|
22
|
+
if (node_path_1.default.isAbsolute(context.name)) {
|
|
23
|
+
filePath = context.name;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
filePath = node_path_1.default.resolve(cwd, context.name);
|
|
27
|
+
}
|
|
28
|
+
fileName = node_path_1.default.basename(filePath);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
fileName = 'tsconfig.json';
|
|
32
|
+
filePath = node_path_1.default.join(cwd, fileName);
|
|
33
|
+
}
|
|
34
|
+
const content = await (0, locter_1.load)(filePath);
|
|
35
|
+
if (!(0, locter_1.isObject)(content)) {
|
|
36
|
+
throw new Error('The tsconfig file is malformed.');
|
|
37
|
+
}
|
|
38
|
+
if (typeof content.compilerOptions !== 'undefined') {
|
|
39
|
+
const { options: compilerOptions } = (0, typescript_1.convertCompilerOptionsFromJson)(content.compilerOptions, cwd, fileName);
|
|
40
|
+
content.compilerOptions = compilerOptions;
|
|
41
|
+
}
|
|
42
|
+
return content;
|
|
43
|
+
}
|
|
44
|
+
exports.loadTSConfig = loadTSConfig;
|
|
45
|
+
async function softLoadTsconfig(context = {}) {
|
|
46
|
+
try {
|
|
47
|
+
return await loadTSConfig(context);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.softLoadTsconfig = softLoadTsconfig;
|
|
54
54
|
//# sourceMappingURL=module.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { CompilerOptions } from 'typescript';
|
|
2
|
-
export type TsconfigLoadContext = {
|
|
3
|
-
cwd?: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
};
|
|
6
|
-
export type TsCompilerOptions = CompilerOptions;
|
|
7
|
-
export type TsConfig = {
|
|
8
|
-
compilerOptions?: TsCompilerOptions;
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
1
|
+
import type { CompilerOptions } from 'typescript';
|
|
2
|
+
export type TsconfigLoadContext = {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
};
|
|
6
|
+
export type TsCompilerOptions = CompilerOptions;
|
|
7
|
+
export type TsConfig = {
|
|
8
|
+
compilerOptions?: TsCompilerOptions;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
11
|
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
//# sourceMappingURL=type.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare enum ValidatorName {
|
|
2
|
-
UNIQUE_ITEMS = "uniqueItems",
|
|
3
|
-
MINIMUM = "minimum",
|
|
4
|
-
MAXIMUM = "maximum",
|
|
5
|
-
MIN_ITEMS = "minItems",
|
|
6
|
-
MAX_ITEMS = "maxItems",
|
|
7
|
-
MIN_LENGTH = "minLength",
|
|
8
|
-
MAX_LENGTH = "maxLength",
|
|
9
|
-
MIN_DATE = "minDate",
|
|
10
|
-
MAX_DATE = "maxDate",
|
|
11
|
-
PATTERN = "pattern"
|
|
12
|
-
}
|
|
1
|
+
export declare enum ValidatorName {
|
|
2
|
+
UNIQUE_ITEMS = "uniqueItems",
|
|
3
|
+
MINIMUM = "minimum",
|
|
4
|
+
MAXIMUM = "maximum",
|
|
5
|
+
MIN_ITEMS = "minItems",
|
|
6
|
+
MAX_ITEMS = "maxItems",
|
|
7
|
+
MIN_LENGTH = "minLength",
|
|
8
|
+
MAX_LENGTH = "maxLength",
|
|
9
|
+
MIN_DATE = "minDate",
|
|
10
|
+
MAX_DATE = "maxDate",
|
|
11
|
+
PATTERN = "pattern"
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ValidatorName = void 0;
|
|
10
|
-
var ValidatorName;
|
|
11
|
-
(function (ValidatorName) {
|
|
12
|
-
ValidatorName["UNIQUE_ITEMS"] = "uniqueItems";
|
|
13
|
-
ValidatorName["MINIMUM"] = "minimum";
|
|
14
|
-
ValidatorName["MAXIMUM"] = "maximum";
|
|
15
|
-
ValidatorName["MIN_ITEMS"] = "minItems";
|
|
16
|
-
ValidatorName["MAX_ITEMS"] = "maxItems";
|
|
17
|
-
ValidatorName["MIN_LENGTH"] = "minLength";
|
|
18
|
-
ValidatorName["MAX_LENGTH"] = "maxLength";
|
|
19
|
-
ValidatorName["MIN_DATE"] = "minDate";
|
|
20
|
-
ValidatorName["MAX_DATE"] = "maxDate";
|
|
21
|
-
ValidatorName["PATTERN"] = "pattern";
|
|
22
|
-
})(ValidatorName = exports.ValidatorName || (exports.ValidatorName = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ValidatorName = void 0;
|
|
10
|
+
var ValidatorName;
|
|
11
|
+
(function (ValidatorName) {
|
|
12
|
+
ValidatorName["UNIQUE_ITEMS"] = "uniqueItems";
|
|
13
|
+
ValidatorName["MINIMUM"] = "minimum";
|
|
14
|
+
ValidatorName["MAXIMUM"] = "maximum";
|
|
15
|
+
ValidatorName["MIN_ITEMS"] = "minItems";
|
|
16
|
+
ValidatorName["MAX_ITEMS"] = "maxItems";
|
|
17
|
+
ValidatorName["MIN_LENGTH"] = "minLength";
|
|
18
|
+
ValidatorName["MAX_LENGTH"] = "maxLength";
|
|
19
|
+
ValidatorName["MIN_DATE"] = "minDate";
|
|
20
|
+
ValidatorName["MAX_DATE"] = "maxDate";
|
|
21
|
+
ValidatorName["PATTERN"] = "pattern";
|
|
22
|
+
})(ValidatorName = exports.ValidatorName || (exports.ValidatorName = {}));
|
|
23
23
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './module';
|
|
3
|
-
export * from './type';
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './module';
|
|
3
|
+
export * from './type';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./constants"), exports);
|
|
24
|
-
__exportStar(require("./module"), exports);
|
|
25
|
-
__exportStar(require("./type"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./constants"), exports);
|
|
24
|
+
__exportStar(require("./module"), exports);
|
|
25
|
+
__exportStar(require("./type"), exports);
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ParameterDeclaration, PropertyDeclaration, PropertySignature, TypeAliasDeclaration } from 'typescript';
|
|
2
|
-
import type { Validator } from './type';
|
|
3
|
-
export declare function getDeclarationValidators(declaration: PropertyDeclaration | TypeAliasDeclaration | PropertySignature | ParameterDeclaration, name?: string): Record<string, Validator>;
|
|
1
|
+
import type { ParameterDeclaration, PropertyDeclaration, PropertySignature, TypeAliasDeclaration } from 'typescript';
|
|
2
|
+
import type { Validator } from './type';
|
|
3
|
+
export declare function getDeclarationValidators(declaration: PropertyDeclaration | TypeAliasDeclaration | PropertySignature | ParameterDeclaration, name?: string): Record<string, Validator>;
|
|
4
4
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021-2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.getDeclarationValidators = void 0;
|
|
10
|
-
const js_doc_1 = require("../js-doc");
|
|
11
|
-
const constants_1 = require("./constants");
|
|
12
|
-
function getDeclarationValidators(declaration, name) {
|
|
13
|
-
if (!declaration.parent) {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
const getCommentValue = (comment) => comment && comment.split(' ')[0];
|
|
17
|
-
const parameterTags = getSupportedParameterTags();
|
|
18
|
-
const tags = (0, js_doc_1.getJSDocTags)(declaration.parent, (tag) => {
|
|
19
|
-
const { comment } = tag;
|
|
20
|
-
const text = (0, js_doc_1.transformJSDocComment)(comment);
|
|
21
|
-
if (!comment) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
const commentValue = getCommentValue(text);
|
|
25
|
-
return parameterTags.some((value) => {
|
|
26
|
-
if (value !== tag.tagName.text) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return !(name && name !== commentValue);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
function getErrorMsg(comment, isValue = true) {
|
|
33
|
-
if (!comment) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
if (isValue) {
|
|
37
|
-
const indexOf = comment.indexOf(' ');
|
|
38
|
-
if (indexOf > 0) {
|
|
39
|
-
return comment.substring(indexOf + 1);
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
return comment;
|
|
44
|
-
}
|
|
45
|
-
const validators = {};
|
|
46
|
-
for (let i = 0; i < tags.length; i++) {
|
|
47
|
-
const tag = tags[i];
|
|
48
|
-
if (!tag.comment) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const name = tag.tagName.text;
|
|
52
|
-
let comment = (0, js_doc_1.transformJSDocComment)(tag.comment);
|
|
53
|
-
comment = comment.substring(comment.indexOf(' ') + 1).trim();
|
|
54
|
-
const value = getCommentValue(comment);
|
|
55
|
-
switch (name) {
|
|
56
|
-
case constants_1.ValidatorName.UNIQUE_ITEMS:
|
|
57
|
-
validators[name] = {
|
|
58
|
-
message: getErrorMsg(comment, false),
|
|
59
|
-
value: undefined,
|
|
60
|
-
};
|
|
61
|
-
break;
|
|
62
|
-
case constants_1.ValidatorName.MINIMUM:
|
|
63
|
-
case constants_1.ValidatorName.MAXIMUM:
|
|
64
|
-
case constants_1.ValidatorName.MIN_ITEMS:
|
|
65
|
-
case constants_1.ValidatorName.MAX_ITEMS:
|
|
66
|
-
case constants_1.ValidatorName.MIN_LENGTH:
|
|
67
|
-
case constants_1.ValidatorName.MAX_LENGTH:
|
|
68
|
-
if (Number.isNaN(value)) {
|
|
69
|
-
throw new Error(`${name} parameter use number.`);
|
|
70
|
-
}
|
|
71
|
-
validators[name] = {
|
|
72
|
-
message: getErrorMsg(comment),
|
|
73
|
-
value: Number(value),
|
|
74
|
-
};
|
|
75
|
-
break;
|
|
76
|
-
case constants_1.ValidatorName.MIN_DATE:
|
|
77
|
-
case constants_1.ValidatorName.MAX_DATE:
|
|
78
|
-
if (typeof value !== 'string') {
|
|
79
|
-
throw new Error(`${name} parameter use date format ISO 8601 ex. 2017-05-14, 2017-05-14T05:18Z`);
|
|
80
|
-
}
|
|
81
|
-
validators[name] = {
|
|
82
|
-
message: getErrorMsg(comment),
|
|
83
|
-
value,
|
|
84
|
-
};
|
|
85
|
-
break;
|
|
86
|
-
case constants_1.ValidatorName.PATTERN:
|
|
87
|
-
if (typeof value !== 'string') {
|
|
88
|
-
throw new Error(`${name} parameter use string.`);
|
|
89
|
-
}
|
|
90
|
-
validators[name] = {
|
|
91
|
-
message: getErrorMsg(comment),
|
|
92
|
-
value: removeSurroundingQuotes(value),
|
|
93
|
-
};
|
|
94
|
-
break;
|
|
95
|
-
default:
|
|
96
|
-
if (name.toLowerCase().startsWith('is')) {
|
|
97
|
-
const errorMsg = getErrorMsg(comment, false);
|
|
98
|
-
if (errorMsg) {
|
|
99
|
-
validators[name] = {
|
|
100
|
-
message: errorMsg,
|
|
101
|
-
value: undefined,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return validators;
|
|
109
|
-
}
|
|
110
|
-
exports.getDeclarationValidators = getDeclarationValidators;
|
|
111
|
-
function getSupportedParameterTags() {
|
|
112
|
-
return [
|
|
113
|
-
'isString',
|
|
114
|
-
'isBoolean',
|
|
115
|
-
'isInt',
|
|
116
|
-
'isLong',
|
|
117
|
-
'isFloat',
|
|
118
|
-
'isDouble',
|
|
119
|
-
'isDate',
|
|
120
|
-
'isDateTime',
|
|
121
|
-
'minItems',
|
|
122
|
-
'maxItems',
|
|
123
|
-
'uniqueItems',
|
|
124
|
-
'minLength',
|
|
125
|
-
'maxLength',
|
|
126
|
-
'pattern',
|
|
127
|
-
'minimum',
|
|
128
|
-
'maximum',
|
|
129
|
-
'minDate',
|
|
130
|
-
'maxDate',
|
|
131
|
-
];
|
|
132
|
-
}
|
|
133
|
-
function removeSurroundingQuotes(str) {
|
|
134
|
-
if (str.startsWith('`') && str.endsWith('`')) {
|
|
135
|
-
return str.substring(1, str.length - 1);
|
|
136
|
-
}
|
|
137
|
-
if (str.startsWith('```') && str.endsWith('```')) {
|
|
138
|
-
return str.substring(3, str.length - 3);
|
|
139
|
-
}
|
|
140
|
-
return str;
|
|
141
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021-2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getDeclarationValidators = void 0;
|
|
10
|
+
const js_doc_1 = require("../js-doc");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
function getDeclarationValidators(declaration, name) {
|
|
13
|
+
if (!declaration.parent) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const getCommentValue = (comment) => comment && comment.split(' ')[0];
|
|
17
|
+
const parameterTags = getSupportedParameterTags();
|
|
18
|
+
const tags = (0, js_doc_1.getJSDocTags)(declaration.parent, (tag) => {
|
|
19
|
+
const { comment } = tag;
|
|
20
|
+
const text = (0, js_doc_1.transformJSDocComment)(comment);
|
|
21
|
+
if (!comment) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const commentValue = getCommentValue(text);
|
|
25
|
+
return parameterTags.some((value) => {
|
|
26
|
+
if (value !== tag.tagName.text) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return !(name && name !== commentValue);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
function getErrorMsg(comment, isValue = true) {
|
|
33
|
+
if (!comment) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (isValue) {
|
|
37
|
+
const indexOf = comment.indexOf(' ');
|
|
38
|
+
if (indexOf > 0) {
|
|
39
|
+
return comment.substring(indexOf + 1);
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return comment;
|
|
44
|
+
}
|
|
45
|
+
const validators = {};
|
|
46
|
+
for (let i = 0; i < tags.length; i++) {
|
|
47
|
+
const tag = tags[i];
|
|
48
|
+
if (!tag.comment) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const name = tag.tagName.text;
|
|
52
|
+
let comment = (0, js_doc_1.transformJSDocComment)(tag.comment);
|
|
53
|
+
comment = comment.substring(comment.indexOf(' ') + 1).trim();
|
|
54
|
+
const value = getCommentValue(comment);
|
|
55
|
+
switch (name) {
|
|
56
|
+
case constants_1.ValidatorName.UNIQUE_ITEMS:
|
|
57
|
+
validators[name] = {
|
|
58
|
+
message: getErrorMsg(comment, false),
|
|
59
|
+
value: undefined,
|
|
60
|
+
};
|
|
61
|
+
break;
|
|
62
|
+
case constants_1.ValidatorName.MINIMUM:
|
|
63
|
+
case constants_1.ValidatorName.MAXIMUM:
|
|
64
|
+
case constants_1.ValidatorName.MIN_ITEMS:
|
|
65
|
+
case constants_1.ValidatorName.MAX_ITEMS:
|
|
66
|
+
case constants_1.ValidatorName.MIN_LENGTH:
|
|
67
|
+
case constants_1.ValidatorName.MAX_LENGTH:
|
|
68
|
+
if (Number.isNaN(value)) {
|
|
69
|
+
throw new Error(`${name} parameter use number.`);
|
|
70
|
+
}
|
|
71
|
+
validators[name] = {
|
|
72
|
+
message: getErrorMsg(comment),
|
|
73
|
+
value: Number(value),
|
|
74
|
+
};
|
|
75
|
+
break;
|
|
76
|
+
case constants_1.ValidatorName.MIN_DATE:
|
|
77
|
+
case constants_1.ValidatorName.MAX_DATE:
|
|
78
|
+
if (typeof value !== 'string') {
|
|
79
|
+
throw new Error(`${name} parameter use date format ISO 8601 ex. 2017-05-14, 2017-05-14T05:18Z`);
|
|
80
|
+
}
|
|
81
|
+
validators[name] = {
|
|
82
|
+
message: getErrorMsg(comment),
|
|
83
|
+
value,
|
|
84
|
+
};
|
|
85
|
+
break;
|
|
86
|
+
case constants_1.ValidatorName.PATTERN:
|
|
87
|
+
if (typeof value !== 'string') {
|
|
88
|
+
throw new Error(`${name} parameter use string.`);
|
|
89
|
+
}
|
|
90
|
+
validators[name] = {
|
|
91
|
+
message: getErrorMsg(comment),
|
|
92
|
+
value: removeSurroundingQuotes(value),
|
|
93
|
+
};
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
if (name.toLowerCase().startsWith('is')) {
|
|
97
|
+
const errorMsg = getErrorMsg(comment, false);
|
|
98
|
+
if (errorMsg) {
|
|
99
|
+
validators[name] = {
|
|
100
|
+
message: errorMsg,
|
|
101
|
+
value: undefined,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return validators;
|
|
109
|
+
}
|
|
110
|
+
exports.getDeclarationValidators = getDeclarationValidators;
|
|
111
|
+
function getSupportedParameterTags() {
|
|
112
|
+
return [
|
|
113
|
+
'isString',
|
|
114
|
+
'isBoolean',
|
|
115
|
+
'isInt',
|
|
116
|
+
'isLong',
|
|
117
|
+
'isFloat',
|
|
118
|
+
'isDouble',
|
|
119
|
+
'isDate',
|
|
120
|
+
'isDateTime',
|
|
121
|
+
'minItems',
|
|
122
|
+
'maxItems',
|
|
123
|
+
'uniqueItems',
|
|
124
|
+
'minLength',
|
|
125
|
+
'maxLength',
|
|
126
|
+
'pattern',
|
|
127
|
+
'minimum',
|
|
128
|
+
'maximum',
|
|
129
|
+
'minDate',
|
|
130
|
+
'maxDate',
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
function removeSurroundingQuotes(str) {
|
|
134
|
+
if (str.startsWith('`') && str.endsWith('`')) {
|
|
135
|
+
return str.substring(1, str.length - 1);
|
|
136
|
+
}
|
|
137
|
+
if (str.startsWith('```') && str.endsWith('```')) {
|
|
138
|
+
return str.substring(3, str.length - 3);
|
|
139
|
+
}
|
|
140
|
+
return str;
|
|
141
|
+
}
|
|
142
142
|
//# sourceMappingURL=module.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type Validator = {
|
|
2
|
-
value?: any;
|
|
3
|
-
message?: string;
|
|
4
|
-
};
|
|
5
|
-
export type Validators = Record<string, Validator>;
|
|
1
|
+
export type Validator = {
|
|
2
|
+
value?: any;
|
|
3
|
+
message?: string;
|
|
4
|
+
};
|
|
5
|
+
export type Validators = Record<string, Validator>;
|
|
6
6
|
//# sourceMappingURL=type.d.ts.map
|