@trapi/metadata 1.0.0-alpha.6 → 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.d.ts.map +1 -1
- package/dist/generator/method/module.js +187 -188
- package/dist/generator/method/module.js.map +1 -1
- package/dist/generator/method/type.d.ts +22 -29
- package/dist/generator/method/type.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/generator/parameter/module.js +555 -554
- package/dist/generator/parameter/module.js.map +1 -1
- package/dist/generator/parameter/type.d.ts +24 -24
- package/dist/generator/parameter/type.d.ts.map +1 -1
- package/dist/generator/parameter/type.js +8 -8
- package/dist/generator/type.d.ts +19 -18
- package/dist/generator/type.d.ts.map +1 -1
- 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 +27 -0
- package/dist/resolver/constants.d.ts.map +1 -0
- package/dist/resolver/constants.js +37 -0
- package/dist/resolver/constants.js.map +1 -0
- package/dist/resolver/error.d.ts +7 -7
- package/dist/resolver/error.js +40 -40
- package/dist/resolver/extension/index.d.ts +3 -0
- package/dist/resolver/extension/index.d.ts.map +1 -0
- package/dist/resolver/extension/index.js +25 -0
- package/dist/resolver/extension/index.js.map +1 -0
- package/dist/resolver/extension/module.d.ts +5 -0
- package/dist/resolver/extension/module.d.ts.map +1 -0
- package/dist/resolver/extension/module.js +27 -0
- package/dist/resolver/extension/module.js.map +1 -0
- package/dist/resolver/extension/type.d.ts +8 -0
- package/dist/resolver/extension/type.d.ts.map +1 -0
- package/dist/resolver/extension/type.js +9 -0
- package/dist/resolver/extension/type.js.map +1 -0
- package/dist/resolver/index.d.ts +5 -3
- package/dist/resolver/index.d.ts.map +1 -1
- package/dist/resolver/index.js +27 -25
- package/dist/resolver/index.js.map +1 -1
- package/dist/resolver/module.d.ts +53 -50
- package/dist/resolver/module.d.ts.map +1 -1
- package/dist/resolver/module.js +1102 -1088
- package/dist/resolver/module.js.map +1 -1
- package/dist/resolver/type.d.ts +138 -123
- package/dist/resolver/type.d.ts.map +1 -1
- package/dist/resolver/type.js +129 -53
- package/dist/resolver/type.js.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/utils/initializer.js +130 -130
- package/dist/utils/initializer.js.map +1 -1
- 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
package/dist/resolver/type.js
CHANGED
|
@@ -1,54 +1,130 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021.
|
|
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.isReferenceType = exports.isRefAliasType = exports.isRefObjectType = exports.isRefEnumType = exports.isUnionType = exports.isIntersectionType = exports.isNestedObjectLiteralType = exports.isArrayType = exports.isEnumType = exports.isVoidType = exports.isAnyType = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021.
|
|
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.isPrimitiveType = exports.isReferenceType = exports.isRefAliasType = exports.isRefObjectType = exports.isRefEnumType = exports.isUnionType = exports.isIntersectionType = exports.isNestedObjectLiteralType = exports.isArrayType = exports.isEnumType = exports.isObjectType = exports.isByteType = exports.isBufferType = exports.isBinaryType = exports.isDateTimeType = exports.isFileType = exports.isDateType = exports.isVoidType = exports.isLongType = exports.isIntegerType = exports.isFloatType = exports.isDoubleType = exports.isBooleanType = exports.isStringType = exports.isUndefinedType = exports.isAnyType = void 0;
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
function isAnyType(param) {
|
|
12
|
+
return param.typeName === constants_1.TypeName.ANY;
|
|
13
|
+
}
|
|
14
|
+
exports.isAnyType = isAnyType;
|
|
15
|
+
function isUndefinedType(param) {
|
|
16
|
+
return param.typeName === constants_1.TypeName.UNDEFINED;
|
|
17
|
+
}
|
|
18
|
+
exports.isUndefinedType = isUndefinedType;
|
|
19
|
+
function isStringType(param) {
|
|
20
|
+
return param.typeName === constants_1.TypeName.STRING;
|
|
21
|
+
}
|
|
22
|
+
exports.isStringType = isStringType;
|
|
23
|
+
function isBooleanType(param) {
|
|
24
|
+
return param.typeName === constants_1.TypeName.BOOLEAN;
|
|
25
|
+
}
|
|
26
|
+
exports.isBooleanType = isBooleanType;
|
|
27
|
+
function isDoubleType(param) {
|
|
28
|
+
return param.typeName === constants_1.TypeName.DOUBLE;
|
|
29
|
+
}
|
|
30
|
+
exports.isDoubleType = isDoubleType;
|
|
31
|
+
function isFloatType(param) {
|
|
32
|
+
return param.typeName === constants_1.TypeName.FLOAT;
|
|
33
|
+
}
|
|
34
|
+
exports.isFloatType = isFloatType;
|
|
35
|
+
function isIntegerType(param) {
|
|
36
|
+
return param.typeName === constants_1.TypeName.INTEGER;
|
|
37
|
+
}
|
|
38
|
+
exports.isIntegerType = isIntegerType;
|
|
39
|
+
function isLongType(param) {
|
|
40
|
+
return param.typeName === constants_1.TypeName.LONG;
|
|
41
|
+
}
|
|
42
|
+
exports.isLongType = isLongType;
|
|
43
|
+
function isVoidType(param) {
|
|
44
|
+
return typeof param === 'undefined' || param.typeName === constants_1.TypeName.VOID;
|
|
45
|
+
}
|
|
46
|
+
exports.isVoidType = isVoidType;
|
|
47
|
+
function isDateType(param) {
|
|
48
|
+
return param.typeName === constants_1.TypeName.DATE;
|
|
49
|
+
}
|
|
50
|
+
exports.isDateType = isDateType;
|
|
51
|
+
function isFileType(param) {
|
|
52
|
+
return param.typeName === constants_1.TypeName.FILE;
|
|
53
|
+
}
|
|
54
|
+
exports.isFileType = isFileType;
|
|
55
|
+
function isDateTimeType(param) {
|
|
56
|
+
return param.typeName === constants_1.TypeName.DATETIME;
|
|
57
|
+
}
|
|
58
|
+
exports.isDateTimeType = isDateTimeType;
|
|
59
|
+
function isBinaryType(param) {
|
|
60
|
+
return param.typeName === constants_1.TypeName.BINARY;
|
|
61
|
+
}
|
|
62
|
+
exports.isBinaryType = isBinaryType;
|
|
63
|
+
function isBufferType(param) {
|
|
64
|
+
return param.typeName === constants_1.TypeName.BUFFER;
|
|
65
|
+
}
|
|
66
|
+
exports.isBufferType = isBufferType;
|
|
67
|
+
function isByteType(param) {
|
|
68
|
+
return param.typeName === constants_1.TypeName.BYTE;
|
|
69
|
+
}
|
|
70
|
+
exports.isByteType = isByteType;
|
|
71
|
+
function isObjectType(param) {
|
|
72
|
+
return param.typeName === constants_1.TypeName.OBJECT;
|
|
73
|
+
}
|
|
74
|
+
exports.isObjectType = isObjectType;
|
|
75
|
+
function isEnumType(param) {
|
|
76
|
+
return param.typeName === constants_1.TypeName.ENUM;
|
|
77
|
+
}
|
|
78
|
+
exports.isEnumType = isEnumType;
|
|
79
|
+
function isArrayType(param) {
|
|
80
|
+
return param.typeName === constants_1.TypeName.ARRAY;
|
|
81
|
+
}
|
|
82
|
+
exports.isArrayType = isArrayType;
|
|
83
|
+
function isNestedObjectLiteralType(param) {
|
|
84
|
+
return param.typeName === constants_1.TypeName.NESTED_OBJECT_LITERAL;
|
|
85
|
+
}
|
|
86
|
+
exports.isNestedObjectLiteralType = isNestedObjectLiteralType;
|
|
87
|
+
function isIntersectionType(param) {
|
|
88
|
+
return param.typeName === constants_1.TypeName.INTERSECTION;
|
|
89
|
+
}
|
|
90
|
+
exports.isIntersectionType = isIntersectionType;
|
|
91
|
+
function isUnionType(param) {
|
|
92
|
+
return param.typeName === constants_1.TypeName.UNION;
|
|
93
|
+
}
|
|
94
|
+
exports.isUnionType = isUnionType;
|
|
95
|
+
function isRefEnumType(param) {
|
|
96
|
+
return param.typeName === constants_1.TypeName.REF_ENUM;
|
|
97
|
+
}
|
|
98
|
+
exports.isRefEnumType = isRefEnumType;
|
|
99
|
+
function isRefObjectType(param) {
|
|
100
|
+
return param.typeName === constants_1.TypeName.REF_OBJECT;
|
|
101
|
+
}
|
|
102
|
+
exports.isRefObjectType = isRefObjectType;
|
|
103
|
+
function isRefAliasType(param) {
|
|
104
|
+
return param.typeName === constants_1.TypeName.REF_ALIAS;
|
|
105
|
+
}
|
|
106
|
+
exports.isRefAliasType = isRefAliasType;
|
|
107
|
+
function isReferenceType(param) {
|
|
108
|
+
return param.typeName === constants_1.TypeName.REF_ALIAS ||
|
|
109
|
+
param.typeName === constants_1.TypeName.REF_ENUM ||
|
|
110
|
+
param.typeName === constants_1.TypeName.REF_OBJECT;
|
|
111
|
+
}
|
|
112
|
+
exports.isReferenceType = isReferenceType;
|
|
113
|
+
function isPrimitiveType(type) {
|
|
114
|
+
return isAnyType(type) ||
|
|
115
|
+
isBinaryType(type) ||
|
|
116
|
+
isBooleanType(type) ||
|
|
117
|
+
isBufferType(type) ||
|
|
118
|
+
isByteType(type) ||
|
|
119
|
+
isDateType(type) ||
|
|
120
|
+
isDateTimeType(type) ||
|
|
121
|
+
isDoubleType(type) ||
|
|
122
|
+
isFloatType(type) ||
|
|
123
|
+
isFileType(type) ||
|
|
124
|
+
isIntegerType(type) ||
|
|
125
|
+
isLongType(type) ||
|
|
126
|
+
isObjectType(type) ||
|
|
127
|
+
isStringType(type);
|
|
128
|
+
}
|
|
129
|
+
exports.isPrimitiveType = isPrimitiveType;
|
|
54
130
|
//# sourceMappingURL=type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/resolver/type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/resolver/type.ts"],"names":[],"mappings":"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"}
|
package/dist/type.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type VariableType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function';
|
|
1
|
+
export type VariableType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function';
|
|
2
2
|
//# sourceMappingURL=type.d.ts.map
|
package/dist/type.js
CHANGED
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":"AAOA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAI,KAAK,IAAI,MAAM,EAAE,CAYhE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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.isStringArray = void 0;
|
|
10
|
+
function isStringArray(input) {
|
|
11
|
+
if (!Array.isArray(input)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
for (let i = 0; i < input.length; i++) {
|
|
15
|
+
if (typeof input[i] !== 'string') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
exports.isStringArray = isStringArray;
|
|
22
|
+
//# sourceMappingURL=array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,SAAgB,aAAa,CAAC,KAAc;IACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACvB,OAAO,KAAK,CAAC;KAChB;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC9B,OAAO,KAAK,CAAC;SAChB;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAZD,sCAYC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
1
|
+
export * from './array';
|
|
2
|
+
export * from './initializer';
|
|
3
|
+
export * from './js-doc';
|
|
4
|
+
export * from './node';
|
|
5
|
+
export * from './object';
|
|
6
|
+
export * from './path-normalize';
|
|
7
|
+
export * from './source-files';
|
|
8
|
+
export * from './tsconfig';
|
|
9
|
+
export * from './validator';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAOA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021.
|
|
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("./
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./
|
|
26
|
-
__exportStar(require("./
|
|
27
|
-
__exportStar(require("./
|
|
28
|
-
__exportStar(require("./
|
|
29
|
-
__exportStar(require("./
|
|
30
|
-
__exportStar(require("./
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021.
|
|
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("./array"), exports);
|
|
24
|
+
__exportStar(require("./initializer"), exports);
|
|
25
|
+
__exportStar(require("./js-doc"), exports);
|
|
26
|
+
__exportStar(require("./node"), exports);
|
|
27
|
+
__exportStar(require("./object"), exports);
|
|
28
|
+
__exportStar(require("./path-normalize"), exports);
|
|
29
|
+
__exportStar(require("./source-files"), exports);
|
|
30
|
+
__exportStar(require("./tsconfig"), exports);
|
|
31
|
+
__exportStar(require("./validator"), exports);
|
|
31
32
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,gDAA8B;AAC9B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,mDAAiC;AACjC,iDAA+B;AAC/B,6CAA2B;AAC3B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,gDAA8B;AAC9B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,mDAAiC;AACjC,iDAA+B;AAC/B,6CAA2B;AAC3B,8CAA4B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function getInitializerValue(initializer?: ts.Expression, typeChecker?: ts.TypeChecker, type?:
|
|
4
|
-
export declare const hasInitializer: (node: ts.Node) => node is ts.HasInitializer;
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import type { Type } from '../resolver';
|
|
3
|
+
export declare function getInitializerValue(initializer?: ts.Expression, typeChecker?: ts.TypeChecker, type?: Type): unknown;
|
|
4
|
+
export declare const hasInitializer: (node: ts.Node) => node is ts.HasInitializer;
|
|
5
5
|
//# sourceMappingURL=initializer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializer.d.ts","sourceRoot":"","sources":["../../src/utils/initializer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"initializer.d.ts","sourceRoot":"","sources":["../../src/utils/initializer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGxC,wBAAgB,mBAAmB,CAC/B,WAAW,CAAC,EAAE,EAAE,CAAC,UAAU,EAC3B,WAAW,CAAC,EAAE,EAAE,CAAC,WAAW,EAC5B,IAAI,CAAC,EAAE,IAAI,GACX,OAAO,CAuGV;AAED,eAAO,MAAM,cAAc,SACjB,GAAG,IAAI,8BACwE,CAAC"}
|
|
@@ -1,131 +1,131 @@
|
|
|
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
|
-
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.hasInitializer = exports.getInitializerValue = void 0;
|
|
33
|
-
const ts = __importStar(require("typescript"));
|
|
34
|
-
const object_1 = require("./object");
|
|
35
|
-
function getInitializerValue(initializer, typeChecker, type) {
|
|
36
|
-
if (!initializer) {
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
switch (initializer.kind) {
|
|
40
|
-
case ts.SyntaxKind.ArrayLiteralExpression: {
|
|
41
|
-
const arrayLiteral = initializer;
|
|
42
|
-
return arrayLiteral.elements.map((element) => getInitializerValue(element, typeChecker));
|
|
43
|
-
}
|
|
44
|
-
case ts.SyntaxKind.StringLiteral:
|
|
45
|
-
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
46
|
-
return initializer.text;
|
|
47
|
-
case ts.SyntaxKind.TrueKeyword:
|
|
48
|
-
return true;
|
|
49
|
-
case ts.SyntaxKind.FalseKeyword:
|
|
50
|
-
return false;
|
|
51
|
-
case ts.SyntaxKind.PrefixUnaryExpression: {
|
|
52
|
-
const prefixUnary = initializer;
|
|
53
|
-
switch (prefixUnary.operator) {
|
|
54
|
-
case ts.SyntaxKind.PlusToken:
|
|
55
|
-
return Number(prefixUnary.operand.text);
|
|
56
|
-
case ts.SyntaxKind.MinusToken:
|
|
57
|
-
return Number(`-${prefixUnary.operand.text}`);
|
|
58
|
-
default:
|
|
59
|
-
throw new Error(`Unsupported prefix operator token: ${prefixUnary.operator}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
case ts.SyntaxKind.NumberKeyword:
|
|
63
|
-
case ts.SyntaxKind.FirstLiteralToken:
|
|
64
|
-
return Number(initializer.text);
|
|
65
|
-
case ts.SyntaxKind.NewExpression: {
|
|
66
|
-
const newExpression = initializer;
|
|
67
|
-
const ident = newExpression.expression;
|
|
68
|
-
if (ident.text === 'Date') {
|
|
69
|
-
let date = new Date();
|
|
70
|
-
if (newExpression.arguments) {
|
|
71
|
-
const newArguments = newExpression.arguments.filter((args) => args.kind !== undefined);
|
|
72
|
-
const argsValue = newArguments.map((args) => getInitializerValue(args, typeChecker));
|
|
73
|
-
if (argsValue.length > 0) {
|
|
74
|
-
date = new Date(argsValue);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const dateString = date.toISOString();
|
|
78
|
-
if (type && type.typeName === 'date') {
|
|
79
|
-
return dateString.split('T')[0];
|
|
80
|
-
}
|
|
81
|
-
return dateString;
|
|
82
|
-
}
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
case ts.SyntaxKind.NullKeyword: {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
case ts.SyntaxKind.ObjectLiteralExpression: {
|
|
89
|
-
const objectLiteral = initializer;
|
|
90
|
-
const nestedObject = {};
|
|
91
|
-
objectLiteral.properties.forEach((p) => {
|
|
92
|
-
nestedObject[p.name.text] = getInitializerValue(p.initializer, typeChecker);
|
|
93
|
-
});
|
|
94
|
-
return nestedObject;
|
|
95
|
-
}
|
|
96
|
-
case ts.SyntaxKind.ImportSpecifier: {
|
|
97
|
-
if (typeof typeChecker === 'undefined') {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
const importSpecifier = initializer;
|
|
101
|
-
const importSymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);
|
|
102
|
-
if (!importSymbol) {
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
const aliasedSymbol = typeChecker.getAliasedSymbol(importSymbol);
|
|
106
|
-
const declarations = aliasedSymbol.getDeclarations();
|
|
107
|
-
const declaration = declarations && declarations.length > 0 ? declarations[0] : undefined;
|
|
108
|
-
return getInitializerValue(extractInitializer(declaration), typeChecker);
|
|
109
|
-
}
|
|
110
|
-
default: {
|
|
111
|
-
if (typeof initializer === 'undefined') {
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
if (typeof initializer.parent === 'undefined' ||
|
|
115
|
-
typeof typeChecker === 'undefined') {
|
|
116
|
-
if ((0, object_1.hasOwnProperty)(initializer, 'text')) {
|
|
117
|
-
return initializer.text;
|
|
118
|
-
}
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
const symbol = typeChecker.getSymbolAtLocation(initializer);
|
|
122
|
-
return getInitializerValue(extractInitializer(symbol.valueDeclaration) || extractInitializer(extractImportSpecifier(symbol)), typeChecker);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
exports.getInitializerValue = getInitializerValue;
|
|
127
|
-
const hasInitializer = (node) => Object.prototype.hasOwnProperty.call(node, 'initializer');
|
|
128
|
-
exports.hasInitializer = hasInitializer;
|
|
129
|
-
const extractInitializer = (valueDeclaration) => (valueDeclaration && (0, exports.hasInitializer)(valueDeclaration) && valueDeclaration.initializer) || undefined;
|
|
130
|
-
const extractImportSpecifier = (symbol) => (symbol?.declarations && symbol.declarations.length > 0 && ts.isImportSpecifier(symbol.declarations[0]) && symbol.declarations[0]) || undefined;
|
|
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
|
+
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.hasInitializer = exports.getInitializerValue = void 0;
|
|
33
|
+
const ts = __importStar(require("typescript"));
|
|
34
|
+
const object_1 = require("./object");
|
|
35
|
+
function getInitializerValue(initializer, typeChecker, type) {
|
|
36
|
+
if (!initializer) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
switch (initializer.kind) {
|
|
40
|
+
case ts.SyntaxKind.ArrayLiteralExpression: {
|
|
41
|
+
const arrayLiteral = initializer;
|
|
42
|
+
return arrayLiteral.elements.map((element) => getInitializerValue(element, typeChecker));
|
|
43
|
+
}
|
|
44
|
+
case ts.SyntaxKind.StringLiteral:
|
|
45
|
+
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
46
|
+
return initializer.text;
|
|
47
|
+
case ts.SyntaxKind.TrueKeyword:
|
|
48
|
+
return true;
|
|
49
|
+
case ts.SyntaxKind.FalseKeyword:
|
|
50
|
+
return false;
|
|
51
|
+
case ts.SyntaxKind.PrefixUnaryExpression: {
|
|
52
|
+
const prefixUnary = initializer;
|
|
53
|
+
switch (prefixUnary.operator) {
|
|
54
|
+
case ts.SyntaxKind.PlusToken:
|
|
55
|
+
return Number(prefixUnary.operand.text);
|
|
56
|
+
case ts.SyntaxKind.MinusToken:
|
|
57
|
+
return Number(`-${prefixUnary.operand.text}`);
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported prefix operator token: ${prefixUnary.operator}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
case ts.SyntaxKind.NumberKeyword:
|
|
63
|
+
case ts.SyntaxKind.FirstLiteralToken:
|
|
64
|
+
return Number(initializer.text);
|
|
65
|
+
case ts.SyntaxKind.NewExpression: {
|
|
66
|
+
const newExpression = initializer;
|
|
67
|
+
const ident = newExpression.expression;
|
|
68
|
+
if (ident.text === 'Date') {
|
|
69
|
+
let date = new Date();
|
|
70
|
+
if (newExpression.arguments) {
|
|
71
|
+
const newArguments = newExpression.arguments.filter((args) => args.kind !== undefined);
|
|
72
|
+
const argsValue = newArguments.map((args) => getInitializerValue(args, typeChecker));
|
|
73
|
+
if (argsValue.length > 0) {
|
|
74
|
+
date = new Date(argsValue);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const dateString = date.toISOString();
|
|
78
|
+
if (type && type.typeName === 'date') {
|
|
79
|
+
return dateString.split('T')[0];
|
|
80
|
+
}
|
|
81
|
+
return dateString;
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
case ts.SyntaxKind.NullKeyword: {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
case ts.SyntaxKind.ObjectLiteralExpression: {
|
|
89
|
+
const objectLiteral = initializer;
|
|
90
|
+
const nestedObject = {};
|
|
91
|
+
objectLiteral.properties.forEach((p) => {
|
|
92
|
+
nestedObject[p.name.text] = getInitializerValue(p.initializer, typeChecker);
|
|
93
|
+
});
|
|
94
|
+
return nestedObject;
|
|
95
|
+
}
|
|
96
|
+
case ts.SyntaxKind.ImportSpecifier: {
|
|
97
|
+
if (typeof typeChecker === 'undefined') {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const importSpecifier = initializer;
|
|
101
|
+
const importSymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);
|
|
102
|
+
if (!importSymbol) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
const aliasedSymbol = typeChecker.getAliasedSymbol(importSymbol);
|
|
106
|
+
const declarations = aliasedSymbol.getDeclarations();
|
|
107
|
+
const declaration = declarations && declarations.length > 0 ? declarations[0] : undefined;
|
|
108
|
+
return getInitializerValue(extractInitializer(declaration), typeChecker);
|
|
109
|
+
}
|
|
110
|
+
default: {
|
|
111
|
+
if (typeof initializer === 'undefined') {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
if (typeof initializer.parent === 'undefined' ||
|
|
115
|
+
typeof typeChecker === 'undefined') {
|
|
116
|
+
if ((0, object_1.hasOwnProperty)(initializer, 'text')) {
|
|
117
|
+
return initializer.text;
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
const symbol = typeChecker.getSymbolAtLocation(initializer);
|
|
122
|
+
return getInitializerValue(extractInitializer(symbol.valueDeclaration) || extractInitializer(extractImportSpecifier(symbol)), typeChecker);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.getInitializerValue = getInitializerValue;
|
|
127
|
+
const hasInitializer = (node) => Object.prototype.hasOwnProperty.call(node, 'initializer');
|
|
128
|
+
exports.hasInitializer = hasInitializer;
|
|
129
|
+
const extractInitializer = (valueDeclaration) => (valueDeclaration && (0, exports.hasInitializer)(valueDeclaration) && valueDeclaration.initializer) || undefined;
|
|
130
|
+
const extractImportSpecifier = (symbol) => (symbol?.declarations && symbol.declarations.length > 0 && ts.isImportSpecifier(symbol.declarations[0]) && symbol.declarations[0]) || undefined;
|
|
131
131
|
//# sourceMappingURL=initializer.js.map
|