@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.
Files changed (168) hide show
  1. package/dist/cache/driver.d.ts +13 -13
  2. package/dist/cache/driver.js +83 -83
  3. package/dist/cache/index.d.ts +3 -3
  4. package/dist/cache/index.js +25 -25
  5. package/dist/cache/type.d.ts +32 -32
  6. package/dist/cache/type.js +8 -8
  7. package/dist/cache/utils.d.ts +3 -3
  8. package/dist/cache/utils.js +52 -52
  9. package/dist/config/index.d.ts +1 -1
  10. package/dist/config/index.js +23 -23
  11. package/dist/config/type.d.ts +36 -36
  12. package/dist/config/type.js +8 -8
  13. package/dist/decorator/constants.d.ts +40 -40
  14. package/dist/decorator/constants.js +52 -52
  15. package/dist/decorator/index.d.ts +6 -6
  16. package/dist/decorator/index.js +28 -28
  17. package/dist/decorator/preset/index.d.ts +2 -2
  18. package/dist/decorator/preset/index.js +24 -24
  19. package/dist/decorator/preset/type.d.ts +5 -5
  20. package/dist/decorator/preset/type.js +8 -8
  21. package/dist/decorator/preset/utils/check.d.ts +2 -2
  22. package/dist/decorator/preset/utils/check.js +17 -17
  23. package/dist/decorator/preset/utils/index.d.ts +3 -3
  24. package/dist/decorator/preset/utils/index.js +25 -25
  25. package/dist/decorator/preset/utils/load.d.ts +2 -2
  26. package/dist/decorator/preset/utils/load.js +44 -44
  27. package/dist/decorator/preset/utils/normalize.d.ts +1 -1
  28. package/dist/decorator/preset/utils/normalize.js +26 -26
  29. package/dist/decorator/property-manager/index.d.ts +2 -2
  30. package/dist/decorator/property-manager/index.js +24 -24
  31. package/dist/decorator/property-manager/module.d.ts +16 -16
  32. package/dist/decorator/property-manager/module.js +58 -58
  33. package/dist/decorator/property-manager/utils.d.ts +5 -5
  34. package/dist/decorator/property-manager/utils.js +91 -91
  35. package/dist/decorator/resolver/index.d.ts +2 -2
  36. package/dist/decorator/resolver/index.js +24 -24
  37. package/dist/decorator/resolver/module.d.ts +26 -26
  38. package/dist/decorator/resolver/module.js +71 -71
  39. package/dist/decorator/resolver/type.d.ts +9 -9
  40. package/dist/decorator/resolver/type.js +2 -2
  41. package/dist/decorator/sets/class.d.ts +6 -6
  42. package/dist/decorator/sets/class.js +8 -8
  43. package/dist/decorator/sets/index.d.ts +7 -7
  44. package/dist/decorator/sets/index.js +28 -28
  45. package/dist/decorator/sets/method.d.ts +13 -13
  46. package/dist/decorator/sets/method.js +8 -8
  47. package/dist/decorator/sets/mixed.d.ts +11 -11
  48. package/dist/decorator/sets/mixed.js +8 -8
  49. package/dist/decorator/sets/parameter.d.ts +20 -20
  50. package/dist/decorator/sets/parameter.js +8 -8
  51. package/dist/decorator/sets/request.d.ts +5 -5
  52. package/dist/decorator/sets/request.js +8 -8
  53. package/dist/decorator/sets/response.d.ts +16 -16
  54. package/dist/decorator/sets/response.js +8 -8
  55. package/dist/decorator/sets/type.d.ts +3 -3
  56. package/dist/decorator/sets/type.js +2 -2
  57. package/dist/decorator/type.d.ts +31 -31
  58. package/dist/decorator/type.js +8 -8
  59. package/dist/error/base.d.ts +2 -2
  60. package/dist/error/base.js +12 -12
  61. package/dist/error/index.d.ts +1 -1
  62. package/dist/error/index.js +23 -23
  63. package/dist/generator/abstract.d.ts +18 -18
  64. package/dist/generator/abstract.js +150 -150
  65. package/dist/generator/abstract.js.map +1 -1
  66. package/dist/generator/controller/index.d.ts +2 -2
  67. package/dist/generator/controller/index.js +24 -24
  68. package/dist/generator/controller/module.d.ts +12 -12
  69. package/dist/generator/controller/module.js +67 -67
  70. package/dist/generator/controller/type.d.ts +46 -46
  71. package/dist/generator/controller/type.js +2 -2
  72. package/dist/generator/index.d.ts +6 -6
  73. package/dist/generator/index.js +28 -28
  74. package/dist/generator/metadata/index.d.ts +3 -3
  75. package/dist/generator/metadata/index.js +25 -25
  76. package/dist/generator/metadata/module.d.ts +38 -38
  77. package/dist/generator/metadata/module.js +142 -142
  78. package/dist/generator/metadata/type.d.ts +24 -24
  79. package/dist/generator/metadata/type.js +2 -2
  80. package/dist/generator/metadata/utils.d.ts +2 -2
  81. package/dist/generator/metadata/utils.js +18 -18
  82. package/dist/generator/method/constants.d.ts +10 -10
  83. package/dist/generator/method/constants.js +20 -20
  84. package/dist/generator/method/index.d.ts +3 -3
  85. package/dist/generator/method/index.js +25 -25
  86. package/dist/generator/method/module.d.ts +18 -18
  87. package/dist/generator/method/module.js +187 -187
  88. package/dist/generator/method/type.d.ts +22 -22
  89. package/dist/generator/method/type.js +8 -8
  90. package/dist/generator/parameter/constants.d.ts +18 -18
  91. package/dist/generator/parameter/constants.js +29 -29
  92. package/dist/generator/parameter/error.d.ts +34 -34
  93. package/dist/generator/parameter/error.js +67 -67
  94. package/dist/generator/parameter/index.d.ts +4 -4
  95. package/dist/generator/parameter/index.js +26 -26
  96. package/dist/generator/parameter/module.d.ts +28 -28
  97. package/dist/generator/parameter/module.js +555 -555
  98. package/dist/generator/parameter/type.d.ts +24 -24
  99. package/dist/generator/parameter/type.js +8 -8
  100. package/dist/generator/type.d.ts +19 -19
  101. package/dist/generator/type.js +8 -8
  102. package/dist/index.d.ts +9 -9
  103. package/dist/index.js +31 -31
  104. package/dist/module.d.ts +4 -4
  105. package/dist/module.js +40 -40
  106. package/dist/resolver/constants.d.ts +26 -26
  107. package/dist/resolver/constants.js +36 -36
  108. package/dist/resolver/error.d.ts +7 -7
  109. package/dist/resolver/error.js +40 -40
  110. package/dist/resolver/extension/index.d.ts +2 -2
  111. package/dist/resolver/extension/index.js +24 -24
  112. package/dist/resolver/extension/module.d.ts +4 -4
  113. package/dist/resolver/extension/module.js +26 -26
  114. package/dist/resolver/extension/type.d.ts +7 -7
  115. package/dist/resolver/extension/type.js +8 -8
  116. package/dist/resolver/index.d.ts +5 -5
  117. package/dist/resolver/index.js +27 -27
  118. package/dist/resolver/module.d.ts +53 -53
  119. package/dist/resolver/module.js +1102 -1102
  120. package/dist/resolver/type.d.ts +138 -138
  121. package/dist/resolver/type.js +129 -129
  122. package/dist/type.d.ts +1 -1
  123. package/dist/type.js +8 -8
  124. package/dist/utils/array.d.ts +2 -0
  125. package/dist/utils/array.d.ts.map +1 -0
  126. package/dist/utils/array.js +22 -0
  127. package/dist/utils/array.js.map +1 -0
  128. package/dist/utils/index.d.ts +9 -8
  129. package/dist/utils/index.d.ts.map +1 -1
  130. package/dist/utils/index.js +31 -30
  131. package/dist/utils/index.js.map +1 -1
  132. package/dist/utils/initializer.d.ts +4 -4
  133. package/dist/utils/initializer.js +130 -130
  134. package/dist/utils/js-doc/constants.d.ts +18 -18
  135. package/dist/utils/js-doc/constants.js +29 -29
  136. package/dist/utils/js-doc/index.d.ts +3 -3
  137. package/dist/utils/js-doc/index.js +25 -25
  138. package/dist/utils/js-doc/module.d.ts +8 -8
  139. package/dist/utils/js-doc/module.js +97 -97
  140. package/dist/utils/js-doc/utils.d.ts +2 -2
  141. package/dist/utils/js-doc/utils.js +28 -28
  142. package/dist/utils/node/index.d.ts +2 -2
  143. package/dist/utils/node/index.js +24 -24
  144. package/dist/utils/node/module.d.ts +9 -9
  145. package/dist/utils/node/module.js +51 -51
  146. package/dist/utils/node/type.d.ts +5 -5
  147. package/dist/utils/node/type.js +8 -8
  148. package/dist/utils/object.d.ts +1 -1
  149. package/dist/utils/object.js +14 -14
  150. package/dist/utils/path-normalize.d.ts +1 -1
  151. package/dist/utils/path-normalize.js +16 -16
  152. package/dist/utils/source-files.d.ts +2 -2
  153. package/dist/utils/source-files.js +31 -31
  154. package/dist/utils/tsconfig/index.d.ts +2 -2
  155. package/dist/utils/tsconfig/index.js +24 -24
  156. package/dist/utils/tsconfig/module.d.ts +3 -3
  157. package/dist/utils/tsconfig/module.js +53 -53
  158. package/dist/utils/tsconfig/type.d.ts +10 -10
  159. package/dist/utils/tsconfig/type.js +8 -8
  160. package/dist/utils/validator/constants.d.ts +12 -12
  161. package/dist/utils/validator/constants.js +22 -22
  162. package/dist/utils/validator/index.d.ts +3 -3
  163. package/dist/utils/validator/index.js +25 -25
  164. package/dist/utils/validator/module.d.ts +3 -3
  165. package/dist/utils/validator/module.js +141 -141
  166. package/dist/utils/validator/type.d.ts +5 -5
  167. package/dist/utils/validator/type.js +8 -8
  168. package/package.json +5 -6
@@ -1,25 +1,25 @@
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("./module"), exports);
24
- __exportStar(require("./utils"), exports);
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("./module"), exports);
24
+ __exportStar(require("./utils"), exports);
25
25
  //# sourceMappingURL=index.js.map
@@ -1,17 +1,17 @@
1
- import type { DecoratorConfig, DecoratorID, DecoratorProperties, DecoratorPropertyConfig } from '../index';
2
- import type { NodeDecorator } from '../../utils';
3
- export declare class DecoratorPropertyManager<T extends `${DecoratorID}`> {
4
- readonly representation: DecoratorConfig<T>;
5
- readonly decorators: NodeDecorator[];
6
- protected properties: Record<string, DecoratorPropertyConfig>;
7
- constructor(representation: DecoratorConfig<T>, decorators: NodeDecorator[]);
8
- /**
9
- * Get one or more specific value(s) of the decorator arguments or typeArguments.
10
- *
11
- * @param type
12
- * @param decoratorOrIndex
13
- */
14
- get<P extends keyof DecoratorProperties<T>>(type: P, decoratorOrIndex?: number | NodeDecorator): DecoratorProperties<T>[P] | undefined;
15
- protected build(): void;
16
- }
1
+ import type { DecoratorConfig, DecoratorID, DecoratorProperties, DecoratorPropertyConfig } from '../index';
2
+ import type { NodeDecorator } from '../../utils';
3
+ export declare class DecoratorPropertyManager<T extends `${DecoratorID}`> {
4
+ readonly representation: DecoratorConfig<T>;
5
+ readonly decorators: NodeDecorator[];
6
+ protected properties: Record<string, DecoratorPropertyConfig>;
7
+ constructor(representation: DecoratorConfig<T>, decorators: NodeDecorator[]);
8
+ /**
9
+ * Get one or more specific value(s) of the decorator arguments or typeArguments.
10
+ *
11
+ * @param type
12
+ * @param decoratorOrIndex
13
+ */
14
+ get<P extends keyof DecoratorProperties<T>>(type: P, decoratorOrIndex?: number | NodeDecorator): DecoratorProperties<T>[P] | undefined;
15
+ protected build(): void;
16
+ }
17
17
  //# sourceMappingURL=module.d.ts.map
@@ -1,59 +1,59 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
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.DecoratorPropertyManager = void 0;
10
- const utils_1 = require("../../utils");
11
- const utils_2 = require("./utils");
12
- class DecoratorPropertyManager {
13
- constructor(representation, decorators) {
14
- this.representation = representation;
15
- this.decorators = decorators;
16
- this.properties = {};
17
- this.build();
18
- }
19
- // -------------------------------------------
20
- /**
21
- * Get one or more specific value(s) of the decorator arguments or typeArguments.
22
- *
23
- * @param type
24
- * @param decoratorOrIndex
25
- */
26
- get(type, decoratorOrIndex) {
27
- if (!(0, utils_1.hasOwnProperty)(this.properties, type)) {
28
- return undefined;
29
- }
30
- const config = this.properties[type];
31
- let decorator;
32
- if (typeof decoratorOrIndex === 'number' ||
33
- typeof decoratorOrIndex === 'undefined') {
34
- decoratorOrIndex = decoratorOrIndex ?? 0;
35
- if (decoratorOrIndex < 0 || decoratorOrIndex >= this.decorators.length) {
36
- return undefined;
37
- }
38
- decorator = this.decorators[decoratorOrIndex];
39
- }
40
- else {
41
- decorator = decoratorOrIndex;
42
- }
43
- return (0, utils_2.extractPropertyFromDecorator)(decorator, config);
44
- }
45
- // -------------------------------------------
46
- build() {
47
- if (!this.representation.properties) {
48
- return;
49
- }
50
- const keys = Object.keys(this.representation.properties);
51
- const output = {};
52
- for (let i = 0; i < keys.length; i++) {
53
- output[keys[i]] = (0, utils_2.buildDecoratorPropertyConfig)(this.representation.properties[keys[i]]);
54
- }
55
- this.properties = output;
56
- }
57
- }
58
- exports.DecoratorPropertyManager = DecoratorPropertyManager;
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2022.
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.DecoratorPropertyManager = void 0;
10
+ const utils_1 = require("../../utils");
11
+ const utils_2 = require("./utils");
12
+ class DecoratorPropertyManager {
13
+ constructor(representation, decorators) {
14
+ this.representation = representation;
15
+ this.decorators = decorators;
16
+ this.properties = {};
17
+ this.build();
18
+ }
19
+ // -------------------------------------------
20
+ /**
21
+ * Get one or more specific value(s) of the decorator arguments or typeArguments.
22
+ *
23
+ * @param type
24
+ * @param decoratorOrIndex
25
+ */
26
+ get(type, decoratorOrIndex) {
27
+ if (!(0, utils_1.hasOwnProperty)(this.properties, type)) {
28
+ return undefined;
29
+ }
30
+ const config = this.properties[type];
31
+ let decorator;
32
+ if (typeof decoratorOrIndex === 'number' ||
33
+ typeof decoratorOrIndex === 'undefined') {
34
+ decoratorOrIndex = decoratorOrIndex ?? 0;
35
+ if (decoratorOrIndex < 0 || decoratorOrIndex >= this.decorators.length) {
36
+ return undefined;
37
+ }
38
+ decorator = this.decorators[decoratorOrIndex];
39
+ }
40
+ else {
41
+ decorator = decoratorOrIndex;
42
+ }
43
+ return (0, utils_2.extractPropertyFromDecorator)(decorator, config);
44
+ }
45
+ // -------------------------------------------
46
+ build() {
47
+ if (!this.representation.properties) {
48
+ return;
49
+ }
50
+ const keys = Object.keys(this.representation.properties);
51
+ const output = {};
52
+ for (let i = 0; i < keys.length; i++) {
53
+ output[keys[i]] = (0, utils_2.buildDecoratorPropertyConfig)(this.representation.properties[keys[i]]);
54
+ }
55
+ this.properties = output;
56
+ }
57
+ }
58
+ exports.DecoratorPropertyManager = DecoratorPropertyManager;
59
59
  //# sourceMappingURL=module.js.map
@@ -1,6 +1,6 @@
1
- import type { NodeDecorator } from '../../utils';
2
- import type { DecoratorPropertyConfig, DecoratorPropertyConfigInput } from '../type';
3
- export declare function buildDecoratorPropertyConfig(property: DecoratorPropertyConfigInput): DecoratorPropertyConfig;
4
- export declare function extractPropertyFromDecorator(decorator: NodeDecorator, config: DecoratorPropertyConfig): unknown | undefined;
5
- export declare function mergeArguments(data: unknown[]): Record<string, any>;
1
+ import type { NodeDecorator } from '../../utils';
2
+ import type { DecoratorPropertyConfig, DecoratorPropertyConfigInput } from '../type';
3
+ export declare function buildDecoratorPropertyConfig(property: DecoratorPropertyConfigInput): DecoratorPropertyConfig;
4
+ export declare function extractPropertyFromDecorator(decorator: NodeDecorator, config: DecoratorPropertyConfig): unknown | undefined;
5
+ export declare function mergeArguments(data: unknown[]): Record<string, any>;
6
6
  //# sourceMappingURL=utils.d.ts.map
@@ -1,92 +1,92 @@
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.mergeArguments = exports.extractPropertyFromDecorator = exports.buildDecoratorPropertyConfig = void 0;
10
- const locter_1 = require("locter");
11
- const utils_1 = require("../../utils");
12
- function buildDecoratorPropertyConfig(property) {
13
- return {
14
- ...property,
15
- isType: property.isType ?? false,
16
- index: property.index ?? 0,
17
- amount: property.amount ?? 1,
18
- };
19
- }
20
- exports.buildDecoratorPropertyConfig = buildDecoratorPropertyConfig;
21
- function extractPropertyFromDecorator(decorator, config) {
22
- const items = config.isType ?
23
- decorator.typeArguments :
24
- extractValueFromArgumentType(decorator.arguments);
25
- if (items.length <= config.index) {
26
- return undefined;
27
- }
28
- const data = (config.amount >= 1 ?
29
- items.slice(config.index, config.index + config.amount) :
30
- items.slice(config.index));
31
- if (data.length === 0) {
32
- return undefined;
33
- }
34
- if (config.strategy) {
35
- if (config.strategy === 'merge') {
36
- return mergeArguments(data);
37
- }
38
- return config.strategy(data);
39
- }
40
- if (config.amount === 1) {
41
- if (data.length > 0) {
42
- return data[0];
43
- }
44
- return undefined;
45
- }
46
- return data;
47
- }
48
- exports.extractPropertyFromDecorator = extractPropertyFromDecorator;
49
- function mergeArguments(data) {
50
- if (data.length === 0) {
51
- return undefined;
52
- }
53
- // we are merging object properties
54
- if ((0, locter_1.isObject)(data[0])) {
55
- const element = data[0];
56
- if (data.length === 1) {
57
- return element;
58
- }
59
- for (let i = 1; i < data.length; i++) {
60
- if ((0, locter_1.isObject)(data[i])) {
61
- Object.assign(element, data[i]);
62
- }
63
- }
64
- return element;
65
- }
66
- const output = Array.isArray(data[0]) ? data[0] : [data[0]];
67
- if (data.length === 1) {
68
- return output;
69
- }
70
- for (let i = 1; i < data.length; i++) {
71
- if (Array.isArray(data[i])) {
72
- output.push(...data[i]);
73
- }
74
- else {
75
- output.push(data[i]);
76
- }
77
- }
78
- return output;
79
- }
80
- exports.mergeArguments = mergeArguments;
81
- function extractValueFromArgumentType(argument) {
82
- const values = [];
83
- for (let i = 0; i < argument.length; i++) {
84
- if (!(0, utils_1.hasOwnProperty)(argument[i], 'kind')) {
85
- values.push(argument[i]);
86
- continue;
87
- }
88
- values.push((0, utils_1.getInitializerValue)(argument[i]));
89
- }
90
- return values;
91
- }
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.mergeArguments = exports.extractPropertyFromDecorator = exports.buildDecoratorPropertyConfig = void 0;
10
+ const locter_1 = require("locter");
11
+ const utils_1 = require("../../utils");
12
+ function buildDecoratorPropertyConfig(property) {
13
+ return {
14
+ ...property,
15
+ isType: property.isType ?? false,
16
+ index: property.index ?? 0,
17
+ amount: property.amount ?? 1,
18
+ };
19
+ }
20
+ exports.buildDecoratorPropertyConfig = buildDecoratorPropertyConfig;
21
+ function extractPropertyFromDecorator(decorator, config) {
22
+ const items = config.isType ?
23
+ decorator.typeArguments :
24
+ extractValueFromArgumentType(decorator.arguments);
25
+ if (items.length <= config.index) {
26
+ return undefined;
27
+ }
28
+ const data = (config.amount >= 1 ?
29
+ items.slice(config.index, config.index + config.amount) :
30
+ items.slice(config.index));
31
+ if (data.length === 0) {
32
+ return undefined;
33
+ }
34
+ if (config.strategy) {
35
+ if (config.strategy === 'merge') {
36
+ return mergeArguments(data);
37
+ }
38
+ return config.strategy(data);
39
+ }
40
+ if (config.amount === 1) {
41
+ if (data.length > 0) {
42
+ return data[0];
43
+ }
44
+ return undefined;
45
+ }
46
+ return data;
47
+ }
48
+ exports.extractPropertyFromDecorator = extractPropertyFromDecorator;
49
+ function mergeArguments(data) {
50
+ if (data.length === 0) {
51
+ return undefined;
52
+ }
53
+ // we are merging object properties
54
+ if ((0, locter_1.isObject)(data[0])) {
55
+ const element = data[0];
56
+ if (data.length === 1) {
57
+ return element;
58
+ }
59
+ for (let i = 1; i < data.length; i++) {
60
+ if ((0, locter_1.isObject)(data[i])) {
61
+ Object.assign(element, data[i]);
62
+ }
63
+ }
64
+ return element;
65
+ }
66
+ const output = Array.isArray(data[0]) ? data[0] : [data[0]];
67
+ if (data.length === 1) {
68
+ return output;
69
+ }
70
+ for (let i = 1; i < data.length; i++) {
71
+ if (Array.isArray(data[i])) {
72
+ output.push(...data[i]);
73
+ }
74
+ else {
75
+ output.push(data[i]);
76
+ }
77
+ }
78
+ return output;
79
+ }
80
+ exports.mergeArguments = mergeArguments;
81
+ function extractValueFromArgumentType(argument) {
82
+ const values = [];
83
+ for (let i = 0; i < argument.length; i++) {
84
+ if (!(0, utils_1.hasOwnProperty)(argument[i], 'kind')) {
85
+ values.push(argument[i]);
86
+ continue;
87
+ }
88
+ values.push((0, utils_1.getInitializerValue)(argument[i]));
89
+ }
90
+ return values;
91
+ }
92
92
  //# sourceMappingURL=utils.js.map
@@ -1,3 +1,3 @@
1
- export * from './module';
2
- export * from './type';
1
+ export * from './module';
2
+ export * from './type';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -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,27 +1,27 @@
1
- import type { Node } from 'typescript';
2
- import { DecoratorPropertyManager } from '../property-manager';
3
- import type { DecoratorID } from '../constants';
4
- import type { DecoratorConfig } from '../type';
5
- import type { NodeDecorator } from '../../utils';
6
- import type { DecoratorResolverMap } from './type';
7
- export declare class DecoratorResolver {
8
- protected items: DecoratorConfig[];
9
- protected map: DecoratorResolverMap;
10
- constructor();
11
- /**
12
- * Try to find a matching representation for a given decorator type and decorators or node.
13
- *
14
- * @param id
15
- * @param data
16
- */
17
- match<T extends `${DecoratorID}`>(id: T, data: NodeDecorator[] | Node): DecoratorPropertyManager<T> | undefined;
18
- apply(items: DecoratorConfig[]): void;
19
- applyPreset(name: string): Promise<void>;
20
- /**
21
- * Aggregate/group different annotation sources.
22
- *
23
- * @private
24
- */
25
- private aggregate;
26
- }
1
+ import type { Node } from 'typescript';
2
+ import { DecoratorPropertyManager } from '../property-manager';
3
+ import type { DecoratorID } from '../constants';
4
+ import type { DecoratorConfig } from '../type';
5
+ import type { NodeDecorator } from '../../utils';
6
+ import type { DecoratorResolverMap } from './type';
7
+ export declare class DecoratorResolver {
8
+ protected items: DecoratorConfig[];
9
+ protected map: DecoratorResolverMap;
10
+ constructor();
11
+ /**
12
+ * Try to find a matching representation for a given decorator type and decorators or node.
13
+ *
14
+ * @param id
15
+ * @param data
16
+ */
17
+ match<T extends `${DecoratorID}`>(id: T, data: NodeDecorator[] | Node): DecoratorPropertyManager<T> | undefined;
18
+ apply(items: DecoratorConfig[]): void;
19
+ applyPreset(name: string): Promise<void>;
20
+ /**
21
+ * Aggregate/group different annotation sources.
22
+ *
23
+ * @private
24
+ */
25
+ private aggregate;
26
+ }
27
27
  //# sourceMappingURL=module.d.ts.map
@@ -1,72 +1,72 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022-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.DecoratorResolver = void 0;
10
- const property_manager_1 = require("../property-manager");
11
- const preset_1 = require("../preset");
12
- const utils_1 = require("../../utils");
13
- class DecoratorResolver {
14
- // -------------------------------------------
15
- constructor() {
16
- this.items = [];
17
- this.map = {};
18
- }
19
- // -------------------------------------------
20
- /**
21
- * Try to find a matching representation for a given decorator type and decorators or node.
22
- *
23
- * @param id
24
- * @param data
25
- */
26
- match(id, data) {
27
- if (!(0, utils_1.hasOwnProperty)(this.map, id)) {
28
- return undefined;
29
- }
30
- const decorators = Array.isArray(data) ?
31
- data :
32
- (0, utils_1.getNodeDecorators)(data);
33
- if (!(0, utils_1.hasOwnProperty)(this.map, id)) {
34
- return undefined;
35
- }
36
- for (let i = 0; i < this.map[id].length; i++) {
37
- const items = decorators.filter((decorator) => decorator.text === this.map[id][i].name);
38
- if (items.length > 0) {
39
- return new property_manager_1.DecoratorPropertyManager(this.map[id][i], items);
40
- }
41
- }
42
- return undefined;
43
- }
44
- // -------------------------------------------
45
- apply(items) {
46
- this.items.push(...items);
47
- this.aggregate();
48
- }
49
- async applyPreset(name) {
50
- const items = await (0, preset_1.loadPreset)(name);
51
- this.items.push(...items);
52
- this.aggregate();
53
- }
54
- /**
55
- * Aggregate/group different annotation sources.
56
- *
57
- * @private
58
- */
59
- aggregate() {
60
- const result = {};
61
- for (let i = 0; i < this.items.length; i++) {
62
- const mapping = this.items[i];
63
- if (!Object.prototype.hasOwnProperty.call(result, mapping.id)) {
64
- result[mapping.id] = [];
65
- }
66
- result[mapping.id].push(mapping);
67
- }
68
- this.map = result;
69
- }
70
- }
71
- exports.DecoratorResolver = DecoratorResolver;
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2022-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.DecoratorResolver = void 0;
10
+ const property_manager_1 = require("../property-manager");
11
+ const preset_1 = require("../preset");
12
+ const utils_1 = require("../../utils");
13
+ class DecoratorResolver {
14
+ // -------------------------------------------
15
+ constructor() {
16
+ this.items = [];
17
+ this.map = {};
18
+ }
19
+ // -------------------------------------------
20
+ /**
21
+ * Try to find a matching representation for a given decorator type and decorators or node.
22
+ *
23
+ * @param id
24
+ * @param data
25
+ */
26
+ match(id, data) {
27
+ if (!(0, utils_1.hasOwnProperty)(this.map, id)) {
28
+ return undefined;
29
+ }
30
+ const decorators = Array.isArray(data) ?
31
+ data :
32
+ (0, utils_1.getNodeDecorators)(data);
33
+ if (!(0, utils_1.hasOwnProperty)(this.map, id)) {
34
+ return undefined;
35
+ }
36
+ for (let i = 0; i < this.map[id].length; i++) {
37
+ const items = decorators.filter((decorator) => decorator.text === this.map[id][i].name);
38
+ if (items.length > 0) {
39
+ return new property_manager_1.DecoratorPropertyManager(this.map[id][i], items);
40
+ }
41
+ }
42
+ return undefined;
43
+ }
44
+ // -------------------------------------------
45
+ apply(items) {
46
+ this.items.push(...items);
47
+ this.aggregate();
48
+ }
49
+ async applyPreset(name) {
50
+ const items = await (0, preset_1.loadPreset)(name);
51
+ this.items.push(...items);
52
+ this.aggregate();
53
+ }
54
+ /**
55
+ * Aggregate/group different annotation sources.
56
+ *
57
+ * @private
58
+ */
59
+ aggregate() {
60
+ const result = {};
61
+ for (let i = 0; i < this.items.length; i++) {
62
+ const mapping = this.items[i];
63
+ if (!Object.prototype.hasOwnProperty.call(result, mapping.id)) {
64
+ result[mapping.id] = [];
65
+ }
66
+ result[mapping.id].push(mapping);
67
+ }
68
+ this.map = result;
69
+ }
70
+ }
71
+ exports.DecoratorResolver = DecoratorResolver;
72
72
  //# sourceMappingURL=module.js.map