@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,151 +1,151 @@
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.AbstractGenerator = void 0;
10
- const locter_1 = require("locter");
11
- const decorator_1 = require("../decorator");
12
- const resolver_1 = require("../resolver");
13
- const utils_1 = require("../utils");
14
- class AbstractGenerator {
15
- // -------------------------------------------
16
- constructor(node, current) {
17
- this.node = node;
18
- this.current = current;
19
- }
20
- // --------------------------------------------------------------------
21
- buildPath() {
22
- const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.MOUNT, this.node);
23
- if (typeof representation !== 'undefined') {
24
- const value = representation.get('value');
25
- if (typeof value === 'string') {
26
- return (0, utils_1.normalizePath)(value);
27
- }
28
- }
29
- return '';
30
- }
31
- // -------------------------------------------
32
- getSecurity() {
33
- const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.SECURITY, this.node);
34
- if (typeof representation === 'undefined') {
35
- return [];
36
- }
37
- const securities = [];
38
- for (let i = 0; i < representation.decorators.length; i++) {
39
- let name = representation.get('key');
40
- // todo: check if Record<string, string[]>
41
- if ((0, locter_1.isObject)(name)) {
42
- securities.push(name);
43
- }
44
- else {
45
- if (typeof name !== 'string' || !name) {
46
- name = 'default';
47
- }
48
- const scopes = representation.get('value');
49
- if (Array.isArray(scopes)) {
50
- securities.push({
51
- [name]: scopes,
52
- });
53
- }
54
- }
55
- }
56
- return securities;
57
- }
58
- // -------------------------------------------
59
- getExamplesValue(argument) {
60
- let example = {};
61
- if (typeof argument === 'undefined') {
62
- return example;
63
- }
64
- if (argument.properties) {
65
- argument.properties.forEach((p) => {
66
- example[p.name.text] = (0, utils_1.getInitializerValue)(p.initializer, this.current.typeChecker);
67
- });
68
- }
69
- else {
70
- example = (0, utils_1.getInitializerValue)(argument, this.current.typeChecker);
71
- }
72
- return example;
73
- }
74
- // -------------------------------------------
75
- buildResponses() {
76
- const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.DESCRIPTION, this.node);
77
- if (typeof representation === 'undefined') {
78
- return [];
79
- }
80
- const responses = [];
81
- for (let i = 0; i < representation.decorators.length; i++) {
82
- const description = representation.get('description', i) || 'Ok';
83
- const status = representation.get('statusCode', i) || '200';
84
- const payload = representation.get('payload', i);
85
- const examples = [];
86
- if (typeof payload !== 'undefined') {
87
- examples.push({
88
- value: payload,
89
- });
90
- }
91
- const type = representation.get('type');
92
- const response = {
93
- description,
94
- examples,
95
- schema: type ? new resolver_1.TypeNodeResolver(type, this.current).resolve() : undefined,
96
- status: status,
97
- name: status,
98
- };
99
- responses.push(response);
100
- }
101
- return responses;
102
- }
103
- // -------------------------------------------
104
- getProduces() {
105
- const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.PRODUCES, this.node);
106
- if (typeof representation === 'undefined') {
107
- return [];
108
- }
109
- const value = representation.get('value');
110
- if (typeof value === 'undefined') {
111
- return [];
112
- }
113
- return Array.isArray(value) ? value : [value];
114
- }
115
- getConsumes() {
116
- const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.CONSUMES, this.node);
117
- if (typeof representation === 'undefined') {
118
- return [];
119
- }
120
- let value = representation.get('value');
121
- if (typeof value === 'undefined') {
122
- return [];
123
- }
124
- value = Array.isArray(value) ? value : [value];
125
- return value;
126
- }
127
- getTags() {
128
- const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.TAGS, this.node);
129
- if (typeof representation === 'undefined') {
130
- return [];
131
- }
132
- let value = representation.get('value');
133
- if (typeof value === 'undefined') {
134
- return [];
135
- }
136
- value = Array.isArray(value) ? value : [value];
137
- return value;
138
- }
139
- // -------------------------------------------
140
- isHidden(node) {
141
- return typeof this.current.decoratorResolver.match(decorator_1.DecoratorID.HIDDEN, node) !== 'undefined';
142
- }
143
- isDeprecated(node) {
144
- if ((0, utils_1.hasJSDocTag)(node, utils_1.JSDocTagName.DEPRECATED)) {
145
- return true;
146
- }
147
- return typeof this.current.decoratorResolver.match(decorator_1.DecoratorID.DEPRECATED, node) !== 'undefined';
148
- }
149
- }
150
- exports.AbstractGenerator = AbstractGenerator;
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.AbstractGenerator = void 0;
10
+ const locter_1 = require("locter");
11
+ const decorator_1 = require("../decorator");
12
+ const resolver_1 = require("../resolver");
13
+ const utils_1 = require("../utils");
14
+ class AbstractGenerator {
15
+ // -------------------------------------------
16
+ constructor(node, current) {
17
+ this.node = node;
18
+ this.current = current;
19
+ }
20
+ // --------------------------------------------------------------------
21
+ buildPath() {
22
+ const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.MOUNT, this.node);
23
+ if (typeof representation !== 'undefined') {
24
+ const value = representation.get('value');
25
+ if (typeof value === 'string') {
26
+ return (0, utils_1.normalizePath)(value);
27
+ }
28
+ }
29
+ return '';
30
+ }
31
+ // -------------------------------------------
32
+ getSecurity() {
33
+ const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.SECURITY, this.node);
34
+ if (typeof representation === 'undefined') {
35
+ return [];
36
+ }
37
+ const securities = [];
38
+ for (let i = 0; i < representation.decorators.length; i++) {
39
+ let name = representation.get('key');
40
+ // todo: check if Record<string, string[]>
41
+ if ((0, locter_1.isObject)(name)) {
42
+ securities.push(name);
43
+ }
44
+ else {
45
+ if (typeof name !== 'string' || !name) {
46
+ name = 'default';
47
+ }
48
+ const scopes = representation.get('value');
49
+ if ((0, utils_1.isStringArray)(scopes)) {
50
+ securities.push({
51
+ [name]: scopes,
52
+ });
53
+ }
54
+ }
55
+ }
56
+ return securities;
57
+ }
58
+ // -------------------------------------------
59
+ getExamplesValue(argument) {
60
+ let example = {};
61
+ if (typeof argument === 'undefined') {
62
+ return example;
63
+ }
64
+ if (argument.properties) {
65
+ argument.properties.forEach((p) => {
66
+ example[p.name.text] = (0, utils_1.getInitializerValue)(p.initializer, this.current.typeChecker);
67
+ });
68
+ }
69
+ else {
70
+ example = (0, utils_1.getInitializerValue)(argument, this.current.typeChecker);
71
+ }
72
+ return example;
73
+ }
74
+ // -------------------------------------------
75
+ buildResponses() {
76
+ const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.DESCRIPTION, this.node);
77
+ if (typeof representation === 'undefined') {
78
+ return [];
79
+ }
80
+ const responses = [];
81
+ for (let i = 0; i < representation.decorators.length; i++) {
82
+ const description = representation.get('description', i) || 'Ok';
83
+ const status = representation.get('statusCode', i) || '200';
84
+ const payload = representation.get('payload', i);
85
+ const examples = [];
86
+ if (typeof payload !== 'undefined') {
87
+ examples.push({
88
+ value: payload,
89
+ });
90
+ }
91
+ const type = representation.get('type');
92
+ const response = {
93
+ description,
94
+ examples,
95
+ schema: type ? new resolver_1.TypeNodeResolver(type, this.current).resolve() : undefined,
96
+ status: status,
97
+ name: status,
98
+ };
99
+ responses.push(response);
100
+ }
101
+ return responses;
102
+ }
103
+ // -------------------------------------------
104
+ getProduces() {
105
+ const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.PRODUCES, this.node);
106
+ if (typeof representation === 'undefined') {
107
+ return [];
108
+ }
109
+ const value = representation.get('value');
110
+ if (typeof value === 'undefined') {
111
+ return [];
112
+ }
113
+ return Array.isArray(value) ? value : [value];
114
+ }
115
+ getConsumes() {
116
+ const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.CONSUMES, this.node);
117
+ if (typeof representation === 'undefined') {
118
+ return [];
119
+ }
120
+ let value = representation.get('value');
121
+ if (typeof value === 'undefined') {
122
+ return [];
123
+ }
124
+ value = Array.isArray(value) ? value : [value];
125
+ return value;
126
+ }
127
+ getTags() {
128
+ const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.TAGS, this.node);
129
+ if (typeof representation === 'undefined') {
130
+ return [];
131
+ }
132
+ let value = representation.get('value');
133
+ if (typeof value === 'undefined') {
134
+ return [];
135
+ }
136
+ value = Array.isArray(value) ? value : [value];
137
+ return value;
138
+ }
139
+ // -------------------------------------------
140
+ isHidden(node) {
141
+ return typeof this.current.decoratorResolver.match(decorator_1.DecoratorID.HIDDEN, node) !== 'undefined';
142
+ }
143
+ isDeprecated(node) {
144
+ if ((0, utils_1.hasJSDocTag)(node, utils_1.JSDocTagName.DEPRECATED)) {
145
+ return true;
146
+ }
147
+ return typeof this.current.decoratorResolver.match(decorator_1.DecoratorID.DEPRECATED, node) !== 'undefined';
148
+ }
149
+ }
150
+ exports.AbstractGenerator = AbstractGenerator;
151
151
  //# sourceMappingURL=abstract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../src/generator/abstract.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAkC;AAElC,4CAA2C;AAC3C,0CAA+C;AAG/C,oCAEkB;AAGlB,MAAsB,iBAAiB;IAKnC,8CAA8C;IAE9C,YAAsB,IAAO,EAAE,OAA0B;QACrD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,uEAAuE;IAE7D,SAAS;QACf,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,uBAAW,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1F,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE;YACvC,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gB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IAAI,CAAC,KAAK,WAAW,CAAC;IACjG,CAAC;IAEM,YAAY,CAAC,IAAU;QAC1B,IAAI,IAAA,mBAAW,EAAC,IAAI,EAAE,oBAAY,CAAC,UAAU,CAAC,EAAE;YAC5C,OAAO,IAAI,CAAC;SACf;QAED,OAAO,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,uBAAW,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,WAAW,CAAC;IACrG,CAAC;CACJ;AAtLD,8CAsLC"}
@@ -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,13 +1,13 @@
1
- import type { ClassDeclaration } from 'typescript';
2
- import { AbstractGenerator } from '../abstract';
3
- import type { Method } from '../method';
4
- import type { MetadataGenerator } from '../metadata';
5
- import type { Controller } from './type';
6
- export declare class ControllerGenerator extends AbstractGenerator<ClassDeclaration> {
7
- constructor(node: ClassDeclaration, current: MetadataGenerator);
8
- isValid(): boolean;
9
- generate(): Controller;
10
- protected getCurrentLocation(): string;
11
- protected buildMethods(controllerPath: string): Method[];
12
- }
1
+ import type { ClassDeclaration } from 'typescript';
2
+ import { AbstractGenerator } from '../abstract';
3
+ import type { Method } from '../method';
4
+ import type { MetadataGenerator } from '../metadata';
5
+ import type { Controller } from './type';
6
+ export declare class ControllerGenerator extends AbstractGenerator<ClassDeclaration> {
7
+ constructor(node: ClassDeclaration, current: MetadataGenerator);
8
+ isValid(): boolean;
9
+ generate(): Controller;
10
+ protected getCurrentLocation(): string;
11
+ protected buildMethods(controllerPath: string): Method[];
12
+ }
13
13
  //# sourceMappingURL=module.d.ts.map
@@ -1,68 +1,68 @@
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.ControllerGenerator = void 0;
10
- const typescript_1 = require("typescript");
11
- const decorator_1 = require("../../decorator");
12
- const abstract_1 = require("../abstract");
13
- const method_1 = require("../method");
14
- class ControllerGenerator extends abstract_1.AbstractGenerator {
15
- // eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-useless-constructor
16
- constructor(node, current) {
17
- super(node, current);
18
- }
19
- isValid() {
20
- const isController = this.current.decoratorResolver.match(decorator_1.DecoratorID.CONTROLLER, this.node);
21
- return !!isController;
22
- }
23
- generate() {
24
- if (!this.node.parent) {
25
- throw new Error('Controller node doesn\'t have a valid parent source file.');
26
- }
27
- if (!this.node.name) {
28
- throw new Error('Controller node doesn\'t have a valid name.');
29
- }
30
- const sourceFile = this.node.parent.getSourceFile();
31
- const path = this.buildPath();
32
- return {
33
- consumes: this.getConsumes(),
34
- hidden: this.isHidden(this.node),
35
- location: sourceFile.fileName,
36
- name: this.getCurrentLocation(),
37
- path,
38
- produces: this.getProduces(),
39
- responses: this.buildResponses(),
40
- security: this.getSecurity(),
41
- tags: this.getTags(),
42
- methods: this.buildMethods(path),
43
- };
44
- }
45
- getCurrentLocation() {
46
- return this.node.name.text;
47
- }
48
- buildMethods(controllerPath) {
49
- const set = new Set();
50
- const output = [];
51
- for (let i = 0; i < this.node.members.length; i++) {
52
- const node = this.node.members[i];
53
- if (!(0, typescript_1.isMethodDeclaration)(node) || this.isHidden(node)) {
54
- continue;
55
- }
56
- const generator = new method_1.MethodGenerator(node, this.current);
57
- const methodName = generator.getMethodName();
58
- if (set.has(methodName) || !generator.isValid()) {
59
- continue;
60
- }
61
- set.add(methodName);
62
- output.push(generator.generate(controllerPath));
63
- }
64
- return output;
65
- }
66
- }
67
- exports.ControllerGenerator = ControllerGenerator;
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.ControllerGenerator = void 0;
10
+ const typescript_1 = require("typescript");
11
+ const decorator_1 = require("../../decorator");
12
+ const abstract_1 = require("../abstract");
13
+ const method_1 = require("../method");
14
+ class ControllerGenerator extends abstract_1.AbstractGenerator {
15
+ // eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-useless-constructor
16
+ constructor(node, current) {
17
+ super(node, current);
18
+ }
19
+ isValid() {
20
+ const isController = this.current.decoratorResolver.match(decorator_1.DecoratorID.CONTROLLER, this.node);
21
+ return !!isController;
22
+ }
23
+ generate() {
24
+ if (!this.node.parent) {
25
+ throw new Error('Controller node doesn\'t have a valid parent source file.');
26
+ }
27
+ if (!this.node.name) {
28
+ throw new Error('Controller node doesn\'t have a valid name.');
29
+ }
30
+ const sourceFile = this.node.parent.getSourceFile();
31
+ const path = this.buildPath();
32
+ return {
33
+ consumes: this.getConsumes(),
34
+ hidden: this.isHidden(this.node),
35
+ location: sourceFile.fileName,
36
+ name: this.getCurrentLocation(),
37
+ path,
38
+ produces: this.getProduces(),
39
+ responses: this.buildResponses(),
40
+ security: this.getSecurity(),
41
+ tags: this.getTags(),
42
+ methods: this.buildMethods(path),
43
+ };
44
+ }
45
+ getCurrentLocation() {
46
+ return this.node.name.text;
47
+ }
48
+ buildMethods(controllerPath) {
49
+ const set = new Set();
50
+ const output = [];
51
+ for (let i = 0; i < this.node.members.length; i++) {
52
+ const node = this.node.members[i];
53
+ if (!(0, typescript_1.isMethodDeclaration)(node) || this.isHidden(node)) {
54
+ continue;
55
+ }
56
+ const generator = new method_1.MethodGenerator(node, this.current);
57
+ const methodName = generator.getMethodName();
58
+ if (set.has(methodName) || !generator.isValid()) {
59
+ continue;
60
+ }
61
+ set.add(methodName);
62
+ output.push(generator.generate(controllerPath));
63
+ }
64
+ return output;
65
+ }
66
+ }
67
+ exports.ControllerGenerator = ControllerGenerator;
68
68
  //# sourceMappingURL=module.js.map
@@ -1,47 +1,47 @@
1
- import type { Response, Security } from '../type';
2
- import type { Method } from '../method';
3
- export interface Controller {
4
- /**
5
- * Allowed Content-Types to pass
6
- * data according the definition.
7
- *
8
- * i.e. ['application/json']
9
- */
10
- consumes: string[];
11
- /**
12
- * Is controller hidden, and should
13
- * not be used/displayed in some scenarios.
14
- */
15
- hidden: boolean;
16
- /**
17
- * File Location of the Controller.
18
- */
19
- location: string;
20
- /**
21
- * Array of found method ( class functions )
22
- * for a specific controller (class)
23
- */
24
- methods: Method[];
25
- name: string;
26
- /**
27
- * The relative URL Path, i.e /users
28
- */
29
- path: string;
30
- /**
31
- * Possible Content-Types to receive
32
- * data according the definition.
33
- *
34
- * i.e. ['application/json']
35
- */
36
- produces: string[];
37
- responses: Response[];
38
- /**
39
- * Tags can be used to group controllers
40
- * by a name together.
41
- *
42
- * i.e. ['auth']
43
- */
44
- tags: string[];
45
- security?: Security[];
46
- }
1
+ import type { Response, Security } from '../type';
2
+ import type { Method } from '../method';
3
+ export interface Controller {
4
+ /**
5
+ * Allowed Content-Types to pass
6
+ * data according the definition.
7
+ *
8
+ * i.e. ['application/json']
9
+ */
10
+ consumes: string[];
11
+ /**
12
+ * Is controller hidden, and should
13
+ * not be used/displayed in some scenarios.
14
+ */
15
+ hidden: boolean;
16
+ /**
17
+ * File Location of the Controller.
18
+ */
19
+ location: string;
20
+ /**
21
+ * Array of found method ( class functions )
22
+ * for a specific controller (class)
23
+ */
24
+ methods: Method[];
25
+ name: string;
26
+ /**
27
+ * The relative URL Path, i.e /users
28
+ */
29
+ path: string;
30
+ /**
31
+ * Possible Content-Types to receive
32
+ * data according the definition.
33
+ *
34
+ * i.e. ['application/json']
35
+ */
36
+ produces: string[];
37
+ responses: Response[];
38
+ /**
39
+ * Tags can be used to group controllers
40
+ * by a name together.
41
+ *
42
+ * i.e. ['auth']
43
+ */
44
+ tags: string[];
45
+ security?: Security[];
46
+ }
47
47
  //# sourceMappingURL=type.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=type.js.map