@trapi/metadata 0.4.1 → 1.0.0-alpha.2

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 (301) hide show
  1. package/README.md +36 -72
  2. package/dist/cache/driver.d.ts +6 -6
  3. package/dist/cache/driver.d.ts.map +1 -1
  4. package/dist/cache/driver.js +27 -45
  5. package/dist/cache/driver.js.map +1 -1
  6. package/dist/cache/type.d.ts +31 -32
  7. package/dist/cache/type.d.ts.map +1 -1
  8. package/dist/cache/utils.d.ts +3 -3
  9. package/dist/cache/utils.d.ts.map +1 -1
  10. package/dist/cache/utils.js +29 -24
  11. package/dist/cache/utils.js.map +1 -1
  12. package/dist/config/index.d.ts +1 -1
  13. package/dist/config/index.js +1 -1
  14. package/dist/config/type.d.ts +37 -0
  15. package/dist/config/type.d.ts.map +1 -0
  16. package/dist/config/type.js +9 -0
  17. package/dist/config/type.js.map +1 -0
  18. package/dist/decorator/constants.d.ts +40 -0
  19. package/dist/decorator/constants.d.ts.map +1 -0
  20. package/dist/decorator/constants.js +52 -0
  21. package/dist/decorator/constants.js.map +1 -0
  22. package/dist/decorator/index.d.ts +7 -0
  23. package/dist/decorator/index.d.ts.map +1 -0
  24. package/dist/decorator/index.js +29 -0
  25. package/dist/decorator/index.js.map +1 -0
  26. package/dist/decorator/preset/index.d.ts +3 -0
  27. package/dist/decorator/preset/index.d.ts.map +1 -0
  28. package/dist/decorator/preset/index.js +25 -0
  29. package/dist/decorator/preset/index.js.map +1 -0
  30. package/dist/decorator/preset/type.d.ts +6 -0
  31. package/dist/decorator/preset/type.d.ts.map +1 -0
  32. package/dist/decorator/preset/type.js +9 -0
  33. package/dist/decorator/preset/type.js.map +1 -0
  34. package/dist/decorator/preset/utils/check.d.ts +3 -0
  35. package/dist/decorator/preset/utils/check.d.ts.map +1 -0
  36. package/dist/decorator/preset/utils/check.js +18 -0
  37. package/dist/decorator/preset/utils/check.js.map +1 -0
  38. package/dist/decorator/preset/utils/index.d.ts +4 -0
  39. package/dist/decorator/preset/utils/index.d.ts.map +1 -0
  40. package/dist/decorator/preset/utils/index.js +26 -0
  41. package/dist/decorator/preset/utils/index.js.map +1 -0
  42. package/dist/decorator/preset/utils/load.d.ts +3 -0
  43. package/dist/decorator/preset/utils/load.d.ts.map +1 -0
  44. package/dist/decorator/preset/utils/load.js +48 -0
  45. package/dist/decorator/preset/utils/load.js.map +1 -0
  46. package/dist/decorator/preset/utils/normalize.d.ts +2 -0
  47. package/dist/decorator/preset/utils/normalize.d.ts.map +1 -0
  48. package/dist/decorator/preset/utils/normalize.js +27 -0
  49. package/dist/decorator/preset/utils/normalize.js.map +1 -0
  50. package/dist/decorator/property-manager/index.d.ts +3 -0
  51. package/dist/decorator/property-manager/index.d.ts.map +1 -0
  52. package/dist/decorator/property-manager/index.js +25 -0
  53. package/dist/decorator/property-manager/index.js.map +1 -0
  54. package/dist/decorator/property-manager/module.d.ts +19 -0
  55. package/dist/decorator/property-manager/module.d.ts.map +1 -0
  56. package/dist/decorator/property-manager/module.js +65 -0
  57. package/dist/decorator/property-manager/module.js.map +1 -0
  58. package/dist/decorator/property-manager/utils.d.ts +7 -0
  59. package/dist/decorator/property-manager/utils.d.ts.map +1 -0
  60. package/dist/decorator/property-manager/utils.js +121 -0
  61. package/dist/decorator/property-manager/utils.js.map +1 -0
  62. package/dist/decorator/resolver/index.d.ts +3 -0
  63. package/dist/decorator/resolver/index.d.ts.map +1 -0
  64. package/dist/decorator/resolver/index.js +25 -0
  65. package/dist/decorator/resolver/index.js.map +1 -0
  66. package/dist/decorator/resolver/module.d.ts +27 -0
  67. package/dist/decorator/resolver/module.d.ts.map +1 -0
  68. package/dist/decorator/resolver/module.js +72 -0
  69. package/dist/decorator/resolver/module.js.map +1 -0
  70. package/dist/decorator/resolver/type.d.ts +10 -0
  71. package/dist/decorator/resolver/type.d.ts.map +1 -0
  72. package/dist/decorator/resolver/type.js +3 -0
  73. package/dist/decorator/resolver/type.js.map +1 -0
  74. package/dist/decorator/sets/class.d.ts +7 -0
  75. package/dist/decorator/sets/class.d.ts.map +1 -0
  76. package/dist/decorator/sets/class.js +9 -0
  77. package/dist/decorator/sets/class.js.map +1 -0
  78. package/dist/decorator/sets/index.d.ts +8 -0
  79. package/dist/decorator/sets/index.d.ts.map +1 -0
  80. package/dist/decorator/sets/index.js +29 -0
  81. package/dist/decorator/sets/index.js.map +1 -0
  82. package/dist/decorator/sets/method.d.ts +14 -0
  83. package/dist/decorator/sets/method.d.ts.map +1 -0
  84. package/dist/decorator/sets/method.js +9 -0
  85. package/dist/decorator/sets/method.js.map +1 -0
  86. package/dist/decorator/sets/mixed.d.ts +8 -0
  87. package/dist/decorator/sets/mixed.d.ts.map +1 -0
  88. package/dist/decorator/sets/mixed.js +9 -0
  89. package/dist/decorator/sets/mixed.js.map +1 -0
  90. package/dist/decorator/sets/parameter.d.ts +21 -0
  91. package/dist/decorator/sets/parameter.d.ts.map +1 -0
  92. package/dist/decorator/sets/parameter.js +9 -0
  93. package/dist/decorator/sets/parameter.js.map +1 -0
  94. package/dist/decorator/sets/request.d.ts +6 -0
  95. package/dist/decorator/sets/request.d.ts.map +1 -0
  96. package/dist/decorator/sets/request.js +9 -0
  97. package/dist/decorator/sets/request.js.map +1 -0
  98. package/dist/decorator/sets/response.d.ts +16 -0
  99. package/dist/decorator/sets/response.d.ts.map +1 -0
  100. package/dist/decorator/sets/response.js +9 -0
  101. package/dist/decorator/sets/response.js.map +1 -0
  102. package/dist/decorator/sets/type.d.ts +4 -0
  103. package/dist/decorator/sets/type.d.ts.map +1 -0
  104. package/dist/decorator/sets/type.js +3 -0
  105. package/dist/decorator/sets/type.js.map +1 -0
  106. package/dist/decorator/type.d.ts +39 -0
  107. package/dist/decorator/type.d.ts.map +1 -0
  108. package/dist/decorator/type.js +9 -0
  109. package/dist/decorator/type.js.map +1 -0
  110. package/dist/error/base.d.ts +3 -0
  111. package/dist/error/base.d.ts.map +1 -0
  112. package/dist/error/base.js +13 -0
  113. package/dist/error/base.js.map +1 -0
  114. package/dist/error/index.d.ts +3 -0
  115. package/dist/error/index.d.ts.map +1 -0
  116. package/dist/{errors → error}/index.js +1 -0
  117. package/dist/error/index.js.map +1 -0
  118. package/dist/error/parameter-invalid.d.ts +4 -0
  119. package/dist/error/parameter-invalid.d.ts.map +1 -0
  120. package/dist/{errors → error}/parameter-invalid.js +2 -1
  121. package/dist/error/parameter-invalid.js.map +1 -0
  122. package/dist/generator/{endpoint.d.ts → abstract.d.ts} +9 -8
  123. package/dist/generator/abstract.d.ts.map +1 -0
  124. package/dist/generator/{endpoint.js → abstract.js} +26 -25
  125. package/dist/generator/abstract.js.map +1 -0
  126. package/dist/generator/controller/index.d.ts +3 -0
  127. package/dist/generator/controller/index.d.ts.map +1 -0
  128. package/dist/generator/controller/index.js +25 -0
  129. package/dist/generator/controller/index.js.map +1 -0
  130. package/dist/generator/controller/module.d.ts +13 -0
  131. package/dist/generator/controller/module.d.ts.map +1 -0
  132. package/dist/generator/{controller.js → controller/module.js} +7 -6
  133. package/dist/generator/controller/module.js.map +1 -0
  134. package/dist/generator/controller/type.d.ts +42 -0
  135. package/dist/generator/controller/type.d.ts.map +1 -0
  136. package/dist/generator/controller/type.js +3 -0
  137. package/dist/generator/controller/type.js.map +1 -0
  138. package/dist/generator/index.d.ts +3 -3
  139. package/dist/generator/index.d.ts.map +1 -1
  140. package/dist/generator/index.js +3 -3
  141. package/dist/generator/index.js.map +1 -1
  142. package/dist/generator/metadata/index.d.ts +3 -0
  143. package/dist/generator/metadata/index.d.ts.map +1 -0
  144. package/dist/generator/metadata/index.js +25 -0
  145. package/dist/generator/metadata/index.js.map +1 -0
  146. package/dist/generator/{module.d.ts → metadata/module.d.ts} +10 -9
  147. package/dist/generator/metadata/module.d.ts.map +1 -0
  148. package/dist/generator/{module.js → metadata/module.js} +22 -39
  149. package/dist/generator/metadata/module.js.map +1 -0
  150. package/dist/generator/metadata/type.d.ts +25 -0
  151. package/dist/generator/metadata/type.d.ts.map +1 -0
  152. package/dist/generator/metadata/type.js +3 -0
  153. package/dist/generator/metadata/type.js.map +1 -0
  154. package/dist/generator/method/constants.d.ts +11 -0
  155. package/dist/generator/method/constants.d.ts.map +1 -0
  156. package/dist/generator/method/constants.js +21 -0
  157. package/dist/generator/method/constants.js.map +1 -0
  158. package/dist/generator/method/index.d.ts +4 -0
  159. package/dist/generator/method/index.d.ts.map +1 -0
  160. package/dist/generator/method/index.js +26 -0
  161. package/dist/generator/method/index.js.map +1 -0
  162. package/dist/generator/{method.d.ts → method/module.d.ts} +6 -6
  163. package/dist/generator/method/module.d.ts.map +1 -0
  164. package/dist/generator/{method.js → method/module.js} +37 -33
  165. package/dist/generator/method/module.js.map +1 -0
  166. package/dist/generator/method/type.d.ts +30 -0
  167. package/dist/generator/method/type.d.ts.map +1 -0
  168. package/dist/generator/method/type.js +9 -0
  169. package/dist/generator/method/type.js.map +1 -0
  170. package/dist/generator/parameter/index.d.ts +4 -0
  171. package/dist/generator/parameter/index.d.ts.map +1 -0
  172. package/dist/generator/parameter/index.js +26 -0
  173. package/dist/generator/parameter/index.js.map +1 -0
  174. package/dist/generator/{parameter.d.ts → parameter/module.d.ts} +4 -4
  175. package/dist/generator/parameter/module.d.ts.map +1 -0
  176. package/dist/generator/{parameter.js → parameter/module.js} +70 -63
  177. package/dist/generator/parameter/module.js.map +1 -0
  178. package/dist/generator/parameter/type.d.ts +22 -0
  179. package/dist/generator/parameter/type.d.ts.map +1 -0
  180. package/dist/generator/parameter/type.js +9 -0
  181. package/dist/generator/parameter/type.js.map +1 -0
  182. package/dist/generator/parameter/validator.d.ts +4 -0
  183. package/dist/generator/parameter/validator.d.ts.map +1 -0
  184. package/dist/generator/parameter/validator.js +130 -0
  185. package/dist/generator/parameter/validator.js.map +1 -0
  186. package/dist/generator/type.d.ts +16 -0
  187. package/dist/generator/type.d.ts.map +1 -0
  188. package/dist/generator/type.js +9 -0
  189. package/dist/generator/type.js.map +1 -0
  190. package/dist/index.d.ts +5 -2
  191. package/dist/index.d.ts.map +1 -1
  192. package/dist/index.js +5 -2
  193. package/dist/index.js.map +1 -1
  194. package/dist/module.d.ts +4 -3
  195. package/dist/module.d.ts.map +1 -1
  196. package/dist/module.js +20 -2
  197. package/dist/module.js.map +1 -1
  198. package/dist/resolver/error.d.ts +8 -0
  199. package/dist/resolver/error.d.ts.map +1 -0
  200. package/dist/resolver/error.js +41 -0
  201. package/dist/resolver/error.js.map +1 -0
  202. package/dist/resolver/index.d.ts +4 -0
  203. package/dist/resolver/index.d.ts.map +1 -0
  204. package/dist/resolver/index.js +26 -0
  205. package/dist/resolver/index.js.map +1 -0
  206. package/dist/resolver/module.d.ts +51 -0
  207. package/dist/resolver/module.d.ts.map +1 -0
  208. package/dist/resolver/module.js +1092 -0
  209. package/dist/resolver/module.js.map +1 -0
  210. package/dist/resolver/type.d.ts +126 -0
  211. package/dist/resolver/type.d.ts.map +1 -0
  212. package/dist/resolver/type.js +54 -0
  213. package/dist/resolver/type.js.map +1 -0
  214. package/dist/type.d.ts +0 -149
  215. package/dist/type.d.ts.map +1 -1
  216. package/dist/type.js +0 -6
  217. package/dist/type.js.map +1 -1
  218. package/dist/utils/index.d.ts +6 -2
  219. package/dist/utils/index.d.ts.map +1 -1
  220. package/dist/utils/index.js +6 -2
  221. package/dist/utils/index.js.map +1 -1
  222. package/dist/utils/initializer.d.ts +5 -0
  223. package/dist/utils/initializer.d.ts.map +1 -0
  224. package/dist/utils/initializer.js +131 -0
  225. package/dist/utils/initializer.js.map +1 -0
  226. package/dist/utils/js-doc/constants.d.ts +19 -0
  227. package/dist/utils/js-doc/constants.d.ts.map +1 -0
  228. package/dist/utils/js-doc/constants.js +30 -0
  229. package/dist/utils/js-doc/constants.js.map +1 -0
  230. package/dist/utils/js-doc/index.d.ts +3 -0
  231. package/dist/utils/js-doc/index.d.ts.map +1 -0
  232. package/dist/utils/js-doc/index.js +25 -0
  233. package/dist/utils/js-doc/index.js.map +1 -0
  234. package/dist/utils/js-doc/module.d.ts +9 -0
  235. package/dist/utils/js-doc/module.d.ts.map +1 -0
  236. package/dist/utils/js-doc/module.js +103 -0
  237. package/dist/utils/js-doc/module.js.map +1 -0
  238. package/dist/utils/node/index.d.ts +3 -0
  239. package/dist/utils/node/index.d.ts.map +1 -0
  240. package/dist/utils/node/index.js +25 -0
  241. package/dist/utils/node/index.js.map +1 -0
  242. package/dist/utils/node/module.d.ts +10 -0
  243. package/dist/utils/node/module.d.ts.map +1 -0
  244. package/dist/utils/node/module.js +52 -0
  245. package/dist/utils/node/module.js.map +1 -0
  246. package/dist/utils/node/type.d.ts +6 -0
  247. package/dist/utils/node/type.d.ts.map +1 -0
  248. package/dist/utils/node/type.js +9 -0
  249. package/dist/utils/node/type.js.map +1 -0
  250. package/dist/utils/{path.d.ts → path-normalize.d.ts} +1 -1
  251. package/dist/utils/path-normalize.d.ts.map +1 -0
  252. package/dist/utils/{path.js → path-normalize.js} +1 -1
  253. package/dist/utils/path-normalize.js.map +1 -0
  254. package/dist/utils/source-files.d.ts +3 -0
  255. package/dist/utils/source-files.d.ts.map +1 -0
  256. package/dist/utils/source-files.js +32 -0
  257. package/dist/utils/source-files.js.map +1 -0
  258. package/dist/utils/tsconfig/index.d.ts +3 -0
  259. package/dist/utils/tsconfig/index.d.ts.map +1 -0
  260. package/dist/utils/tsconfig/index.js +25 -0
  261. package/dist/utils/tsconfig/index.js.map +1 -0
  262. package/dist/utils/tsconfig/module.d.ts +4 -0
  263. package/dist/utils/tsconfig/module.d.ts.map +1 -0
  264. package/dist/utils/tsconfig/module.js +54 -0
  265. package/dist/utils/tsconfig/module.js.map +1 -0
  266. package/dist/utils/tsconfig/type.d.ts +10 -0
  267. package/dist/utils/tsconfig/type.d.ts.map +1 -0
  268. package/dist/utils/tsconfig/type.js +9 -0
  269. package/dist/utils/tsconfig/type.js.map +1 -0
  270. package/package.json +11 -12
  271. package/dist/config/path.d.ts +0 -3
  272. package/dist/config/path.d.ts.map +0 -1
  273. package/dist/config/path.js +0 -32
  274. package/dist/config/path.js.map +0 -1
  275. package/dist/errors/index.d.ts +0 -2
  276. package/dist/errors/index.d.ts.map +0 -1
  277. package/dist/errors/index.js.map +0 -1
  278. package/dist/errors/parameter-invalid.d.ts +0 -3
  279. package/dist/errors/parameter-invalid.d.ts.map +0 -1
  280. package/dist/errors/parameter-invalid.js.map +0 -1
  281. package/dist/generator/controller.d.ts +0 -13
  282. package/dist/generator/controller.d.ts.map +0 -1
  283. package/dist/generator/controller.js.map +0 -1
  284. package/dist/generator/endpoint.d.ts.map +0 -1
  285. package/dist/generator/endpoint.js.map +0 -1
  286. package/dist/generator/method.d.ts.map +0 -1
  287. package/dist/generator/method.js.map +0 -1
  288. package/dist/generator/module.d.ts.map +0 -1
  289. package/dist/generator/module.js.map +0 -1
  290. package/dist/generator/parameter.d.ts.map +0 -1
  291. package/dist/generator/parameter.js.map +0 -1
  292. package/dist/generator/utils.d.ts +0 -5
  293. package/dist/generator/utils.d.ts.map +0 -1
  294. package/dist/generator/utils.js +0 -18
  295. package/dist/generator/utils.js.map +0 -1
  296. package/dist/utils/path.d.ts.map +0 -1
  297. package/dist/utils/path.js.map +0 -1
  298. package/dist/utils/typescript.d.ts +0 -8
  299. package/dist/utils/typescript.d.ts.map +0 -1
  300. package/dist/utils/typescript.js +0 -41
  301. package/dist/utils/typescript.js.map +0 -1
package/README.md CHANGED
@@ -30,83 +30,56 @@ npm install --save @trapi/metadata
30
30
  ### Metadata
31
31
  The metadata configuration object (Top-Level) is the main configuration object of this library
32
32
  and can be defined according the following type scheme:
33
+
33
34
  ```typescript
34
- import { Config as DecoratorConfig } from '@trapi/decorator';
35
- import { Cache } from '@trapi/metadata';
35
+ import {
36
+ CacheOptions,
37
+ DecoratorConfig
38
+ } from "@trapi/metadata";
36
39
 
37
- export type EntryPointConfig = {
40
+ export type EntryPointOptions = {
38
41
  cwd: string,
39
42
  pattern: string
40
43
  };
41
44
 
42
45
  export type EntryPoint = string |
43
- string[] |
44
- EntryPointConfig |
45
- EntryPointConfig[];
46
+ string[] |
47
+ EntryPointOptions |
48
+ EntryPointOptions[];
46
49
 
47
- export interface Config {
50
+ export interface Options {
48
51
  /**
49
52
  * The entry point to your API.
50
53
  */
51
54
  entryPoint: EntryPoint;
55
+
52
56
  /**
53
57
  * Directory to ignore during TypeScript files scan.
54
58
  * Default: []
55
59
  */
56
60
  ignore?: string[];
61
+
57
62
  /**
58
- * Directory to store and cache metadata files.
59
- * Default: false
60
- */
61
- cache?: string | boolean | Partial<Cache.Config>;
62
- /**
63
- * Decorator config.
64
- * Default: {
65
- * library: [],
66
- * internal: true,
67
- * map: {}
68
- * }
63
+ * Directory to allow during TypeScript files scan.
64
+ * Default: []
69
65
  */
70
- decorator?: DecoratorConfig;
71
- }
72
- ```
73
-
74
- ### Cache
75
- The Cache can be configured by providing different kind of values:
76
-
77
- - **boolean**:
78
- - `true`: Cache file will be saved to process.cwd() with generated hash file name and the cache will be cleared at a 10 percent chance.
79
- - `false`: Cache is disabled.
80
- - **string** Cache will be saved to `value` directory with generated hash file name ...
81
- - **object**: obda
82
- ```typescript
83
- export interface Config {
66
+ allow?: string[],
67
+
84
68
  /**
85
- * Specify if the cache driver should be enabled.
86
- *
69
+ * Directory to store and cache metadata files.
87
70
  * Default: false
88
- * */
89
- enabled?: boolean,
90
- /**
91
- * Directory relative or absolute path.
92
- *
93
- * Default: process.cwd()
94
71
  */
95
- directoryPath?: string,
72
+ cache?: string | boolean | Partial<CacheOptions>;
73
+
96
74
  /**
97
- * Specify the cache file name.
98
- *
99
- * Default: metadata-{hash}.json
75
+ * Manual decorator properties configuration.
100
76
  */
101
- fileName?: string,
102
-
77
+ decorators?: DecoratorConfig[],
78
+
103
79
  /**
104
- * The cache file(s) will be cleared at a 10% percent change
105
- * each time.
106
- *
107
- * Default: true
80
+ * Load a specific preset configuration.
108
81
  */
109
- clearAtRandom?: boolean
82
+ preset?: string;
110
83
  }
111
84
  ```
112
85
 
@@ -123,27 +96,18 @@ At the moment only the following TypeScript UtilityTypes are supported:
123
96
  ## Usage
124
97
 
125
98
  ```typescript
126
- import {createMetadata, Output} from "@trapi/metadata";
127
- import * as path from "path";
128
- import * as process from "process";
129
-
130
- const metadata : Output = createMetadata({
131
- entryPoint: {
132
- cwd: path.join(process.cwd(), 'src', 'controllers'),
133
- pattern: '**/*.ts'
134
- },
135
- ignore: ['**/node_modules/**'],
136
- cache: {
137
- enabled: true,
138
- directoryPath: path.join(process.cwd(), 'writable')
139
- },
140
- decorator: {
141
- internal: true,
142
- // Because both libaries does not have any decorator
143
- // names in common, the represnetation also does not differ and
144
- // we can use them both :)
145
- preset: ['decorators-express', 'typescript-rest']
146
- }
99
+ import {
100
+ generateMetadata,
101
+ Metadata
102
+ } from "@trapi/metadata";
103
+ import path from "node:path";
104
+ import process from "node:process";
105
+
106
+ const metadata : Metadata = await generateMetadata({
107
+ entryPoint: ['src/controllers/**/*.ts'],
108
+ ignore: ['**/node_modules/**'],
109
+ cache: true,
110
+ preset: '@trapi/preset-routup'
147
111
  });
148
112
 
149
113
  console.log(metadata);
@@ -1,13 +1,13 @@
1
- import { Cache } from './type';
1
+ import type { CacheData, CacheOptionsInput } from './type';
2
2
  export declare class CacheDriver {
3
- private readonly config;
4
- constructor(config: string | boolean | Partial<Cache.Config>);
5
- save(data: Cache.Data): string | undefined;
6
- get(sourceFilesSize: number): Cache.Data | undefined;
3
+ private readonly options;
4
+ constructor(input?: string | boolean | CacheOptionsInput);
5
+ save(data: CacheData): Promise<string | undefined>;
6
+ get(sourceFilesSize: number): Promise<CacheData | undefined>;
7
7
  /**
8
8
  * At a 10% chance, clear all cache files :)
9
9
  */
10
- clear(): void;
10
+ clear(): Promise<void>;
11
11
  private buildFilePath;
12
12
  private buildFileName;
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/cache/driver.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;IAMrD,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS;IAY1C,GAAG,CAAC,eAAe,EAAE,MAAM,GAAG,KAAK,CAAC,IAAI,GAAG,SAAS;IA8B3D;;OAEG;IAGI,KAAK,IAAI,IAAI;IAgBpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;CAMxB"}
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/cache/driver.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAgB,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEzE,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,iBAAiB;IAMlD,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAYlD,GAAG,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IA4BlE;;OAEG;IAGG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB5B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;CAMxB"}
@@ -5,63 +5,39 @@
5
5
  * For the full copyright and license information,
6
6
  * view the LICENSE file that was distributed with this source code.
7
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
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
32
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
33
10
  };
34
11
  Object.defineProperty(exports, "__esModule", { value: true });
35
12
  exports.CacheDriver = void 0;
36
- const fs_1 = __importDefault(require("fs"));
37
- const glob = __importStar(require("glob"));
38
- const path_1 = __importDefault(require("path"));
13
+ const locter_1 = require("locter");
14
+ const node_fs_1 = __importDefault(require("node:fs"));
15
+ const node_path_1 = __importDefault(require("node:path"));
39
16
  const utils_1 = require("./utils");
40
17
  class CacheDriver {
41
- constructor(config) {
42
- this.config = (0, utils_1.buildCacheConfig)(config);
18
+ constructor(input) {
19
+ this.options = (0, utils_1.buildCacheOptions)(input);
43
20
  }
44
21
  // -------------------------------------------------------------------------
45
- save(data) {
46
- if (!this.config.enabled) {
22
+ async save(data) {
23
+ if (!this.options.enabled) {
47
24
  return undefined;
48
25
  }
49
26
  const filePath = this.buildFilePath(undefined, data.sourceFilesSize);
50
- fs_1.default.writeFileSync(filePath, JSON.stringify(data));
27
+ await node_fs_1.default.promises.writeFile(filePath, JSON.stringify(data));
51
28
  return filePath;
52
29
  }
53
- get(sourceFilesSize) {
54
- if (!this.config.enabled) {
30
+ async get(sourceFilesSize) {
31
+ if (!this.options.enabled) {
55
32
  return undefined;
56
33
  }
57
- this.clear();
34
+ await this.clear();
58
35
  const filePath = this.buildFilePath(undefined, sourceFilesSize);
59
36
  try {
60
- const buffer = fs_1.default.readFileSync(filePath);
61
- const content = buffer.toString('utf-8');
37
+ const content = await node_fs_1.default.promises.readFile(filePath, { encoding: 'utf-8' });
62
38
  // todo: maybe add shape validation here :)
63
39
  const cache = JSON.parse(content);
64
- if (typeof cache === 'undefined' || cache.sourceFilesSize !== sourceFilesSize) {
40
+ if (!cache || cache.sourceFilesSize !== sourceFilesSize) {
65
41
  return undefined;
66
42
  }
67
43
  return cache;
@@ -76,26 +52,32 @@ class CacheDriver {
76
52
  * At a 10% chance, clear all cache files :)
77
53
  */
78
54
  /* istanbul ignore next */
79
- clear() {
80
- if (!this.config.enabled || !this.config.clearAtRandom) {
55
+ async clear() {
56
+ if (!this.options.enabled || !this.options.clearAtRandom) {
81
57
  return;
82
58
  }
83
59
  const rand = Math.floor(Math.random() * 100) + 1;
84
60
  if (rand > 10) {
85
61
  return;
86
62
  }
87
- const files = glob.sync(this.buildFilePath('**'));
88
- files.map((file) => fs_1.default.unlinkSync(file));
63
+ const files = await (0, locter_1.locateMany)(this.buildFileName('**'), {
64
+ path: this.options.directoryPath,
65
+ });
66
+ const unlinkPromises = [];
67
+ for (let i = 0; files.length; i++) {
68
+ unlinkPromises.push(node_fs_1.default.promises.unlink((0, locter_1.buildFilePath)(files[i])));
69
+ }
70
+ await Promise.all(unlinkPromises);
89
71
  }
90
72
  // -------------------------------------------------------------------------
91
73
  buildFilePath(hash, sourceFilesSize) {
92
- return path_1.default.join(this.config.directoryPath, this.buildFileName(hash, sourceFilesSize));
74
+ return node_path_1.default.join(this.options.directoryPath, this.buildFileName(hash, sourceFilesSize));
93
75
  }
94
76
  buildFileName(hash, sourceFilesSize) {
95
- if (typeof this.config.fileName === 'string') {
96
- return this.config.fileName;
77
+ if (typeof this.options.fileName === 'string') {
78
+ return this.options.fileName;
97
79
  }
98
- return `.swagger-${hash !== null && hash !== void 0 ? hash : (0, utils_1.buildFileHash)(sourceFilesSize)}.json`;
80
+ return `.swagger-${hash ?? (0, utils_1.generateFileHash)(sourceFilesSize)}.json`;
99
81
  }
100
82
  }
101
83
  exports.CacheDriver = CacheDriver;
@@ -1 +1 @@
1
- {"version":3,"file":"driver.js","sourceRoot":"","sources":["../../src/cache/driver.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,2CAA6B;AAC7B,gDAAwB;AACxB,mCAA0D;AAG1D,MAAa,WAAW;IAGpB,YAAY,MAAgD;QACxD,IAAI,CAAC,MAAM,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,4EAA4E;IAErE,IAAI,CAAC,IAAgB;QACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACtB,OAAO,SAAS,CAAC;SACpB;QAED,MAAM,QAAQ,GAAW,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAE7E,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAEjD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,GAAG,CAAC,eAAuB;QAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACtB,OAAO,SAAS,CAAC;SACpB;QAED,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,MAAM,QAAQ,GAAW,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAExE,IAAI;YACA,MAAM,MAAM,GAAW,YAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAEjD,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAEjD,2CAA2C;YAC3C,MAAM,KAAK,GAA2B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAe,CAAC;YAExE,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,K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AAC,QAAQ,CAAC;SAChC;QACD,OAAO,YAAY,IAAI,IAAI,IAAA,wBAAgB,EAAC,eAAe,CAAC,OAAO,CAAC;IACxE,CAAC;CACJ;AAxFD,kCAwFC"}
@@ -1,34 +1,33 @@
1
- import { GeneratorOutput } from '../type';
2
- export declare namespace Cache {
3
- interface Config {
4
- /**
5
- * Specify if the cache driver should be enabled.
6
- *
7
- * Default: false
8
- * */
9
- enabled: boolean;
10
- /**
11
- * Directory relative or absolute path.
12
- *
13
- * Default: process.cwd()
14
- */
15
- directoryPath: string;
16
- /**
17
- * Specify the cache file name.
18
- *
19
- * Default: metadata-{hash}.json
20
- */
21
- fileName?: string;
22
- /**
23
- * The cache file(s) will be cleared at a 10% percent change
24
- * each time.
25
- *
26
- * Default: true
27
- */
28
- clearAtRandom: boolean;
29
- }
30
- type Data = {
31
- sourceFilesSize: number;
32
- } & GeneratorOutput;
1
+ import type { Metadata } from '../generator';
2
+ export interface CacheOptions {
3
+ /**
4
+ * Specify if the cache driver should be enabled.
5
+ *
6
+ * Default: false
7
+ * */
8
+ enabled: boolean;
9
+ /**
10
+ * Directory relative or absolute path.
11
+ *
12
+ * Default: tmpDir()
13
+ */
14
+ directoryPath: string;
15
+ /**
16
+ * Specify the cache file name.
17
+ *
18
+ * Default: metadata-{hash}.json
19
+ */
20
+ fileName?: string;
21
+ /**
22
+ * The cache file(s) will be cleared at a 10% percent change
23
+ * each time.
24
+ *
25
+ * Default: true
26
+ */
27
+ clearAtRandom: boolean;
33
28
  }
29
+ export type CacheOptionsInput = Partial<CacheOptions>;
30
+ export type CacheData = {
31
+ sourceFilesSize: number;
32
+ } & Metadata;
34
33
  //# sourceMappingURL=type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/cache/type.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,yBAAiB,KAAK,CAAC;IACnB,UAAiB,MAAM;QACnB;;;;aAIK;QACL,OAAO,EAAE,OAAO,CAAC;QACjB;;;;WAIG;QACH,aAAa,EAAE,MAAM,CAAC;QACtB;;;;WAIG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB;;;;;WAKG;QACH,aAAa,EAAE,OAAO,CAAA;KACzB;IAED,KAAY,IAAI,GAAG;QACf,eAAe,EAAE,MAAM,CAAC;KAC3B,GAAG,eAAe,CAAC;CACvB"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/cache/type.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,WAAW,YAAY;IACzB;;;;SAIK;IACL,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,aAAa,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG;IACpB,eAAe,EAAE,MAAM,CAAC;CAC3B,GAAG,QAAQ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Cache } from './type';
2
- export declare function buildCacheConfig(config?: string | boolean | Partial<Cache.Config>): Cache.Config;
3
- export declare function buildFileHash(sourceFilesSize?: number): string;
1
+ import type { CacheOptions, CacheOptionsInput } from './type';
2
+ export declare function buildCacheOptions(input?: string | boolean | CacheOptionsInput): CacheOptions;
3
+ export declare function generateFileHash(sourceFilesSize?: number): string;
4
4
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cache/utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAI,KAAK,CAAC,MAAM,CA2BjG;AAED,wBAAgB,aAAa,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ9D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cache/utils.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE9D,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,iBAAiB,GAAI,YAAY,CAgC7F;AAED,wBAAgB,gBAAgB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAQjE"}
@@ -9,40 +9,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.buildFileHash = exports.buildCacheConfig = void 0;
13
- const path_1 = __importDefault(require("path"));
14
- const crypto_1 = __importDefault(require("crypto"));
15
- function buildCacheConfig(config) {
16
- var _a, _b;
17
- if (typeof config === 'string') {
18
- config = {
12
+ exports.generateFileHash = exports.buildCacheOptions = void 0;
13
+ const node_os_1 = require("node:os");
14
+ const node_path_1 = __importDefault(require("node:path"));
15
+ const node_crypto_1 = __importDefault(require("node:crypto"));
16
+ const node_process_1 = __importDefault(require("node:process"));
17
+ function buildCacheOptions(input) {
18
+ if (typeof input === 'string') {
19
+ input = {
19
20
  enabled: true,
20
- directoryPath: config,
21
+ directoryPath: input,
21
22
  };
22
23
  }
23
- if (typeof config === 'boolean') {
24
- config = {
25
- enabled: config,
24
+ if (typeof input === 'boolean') {
25
+ input = {
26
+ enabled: input,
26
27
  };
27
28
  }
28
- config !== null && config !== void 0 ? config : (config = {});
29
+ input = input || {};
29
30
  /* istanbul ignore next */
30
- const isTestEnvironment = !!process.env.NODE_ENV && process.env.NODE_ENV === 'test';
31
+ const isTestEnvironment = !!node_process_1.default.env.NODE_ENV && node_process_1.default.env.NODE_ENV === 'test';
32
+ let directoryPath = (0, node_os_1.tmpdir)();
33
+ if (typeof input.directoryPath === 'string') {
34
+ directoryPath = node_path_1.default.isAbsolute(input.directoryPath) ?
35
+ input.directoryPath :
36
+ node_path_1.default.join(node_process_1.default.cwd(), input.directoryPath);
37
+ }
31
38
  return {
32
- fileName: config.fileName,
33
- directoryPath: typeof config.directoryPath === 'string' ?
34
- path_1.default.isAbsolute(config.directoryPath) ? config.directoryPath : path_1.default.join(process.cwd(), config.directoryPath) :
35
- process.cwd(),
36
- enabled: (_a = config.enabled) !== null && _a !== void 0 ? _a : false,
37
- clearAtRandom: (_b = config.clearAtRandom) !== null && _b !== void 0 ? _b : !isTestEnvironment,
39
+ fileName: input.fileName,
40
+ directoryPath,
41
+ enabled: input.enabled ?? true,
42
+ clearAtRandom: input.clearAtRandom ?? !isTestEnvironment,
38
43
  };
39
44
  }
40
- exports.buildCacheConfig = buildCacheConfig;
41
- function buildFileHash(sourceFilesSize) {
42
- const hash = crypto_1.default.createHash('sha256');
43
- const strSize = (sourceFilesSize !== null && sourceFilesSize !== void 0 ? sourceFilesSize : 0).toString();
45
+ exports.buildCacheOptions = buildCacheOptions;
46
+ function generateFileHash(sourceFilesSize) {
47
+ const hash = node_crypto_1.default.createHash('sha256');
48
+ const strSize = (sourceFilesSize ?? 0).toString();
44
49
  hash.update(strSize);
45
50
  return hash.digest('hex');
46
51
  }
47
- exports.buildFileHash = buildFileHash;
52
+ exports.generateFileHash = generateFileHash;
48
53
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/cache/utils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,gDAAwB;AACxB,oDAA4B;AAG5B,SAAgB,gBAAgB,CAAC,MAAiD;;IAC9E,IAAI,OAAO,MAAM,KAAK,Q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CAAC;IAEzC,MAAM,OAAO,GAAW,CAAC,eAAe,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAE1D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAErB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AARD,4CAQC"}
@@ -1,2 +1,2 @@
1
- export * from './path';
1
+ export * from './type';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -20,5 +20,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./path"), exports);
23
+ __exportStar(require("./type"), exports);
24
24
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,37 @@
1
+ import type { CacheOptions } from '../cache';
2
+ import type { DecoratorConfig } from '../decorator';
3
+ export type EntryPointOptions = {
4
+ cwd: string;
5
+ pattern: string;
6
+ };
7
+ export type EntryPoint = string | string[] | EntryPointOptions | EntryPointOptions[];
8
+ export interface Options {
9
+ /**
10
+ * The entry point to your API.
11
+ */
12
+ entryPoint: EntryPoint;
13
+ /**
14
+ * Directory to ignore during TypeScript files scan.
15
+ * Default: []
16
+ */
17
+ ignore?: string[];
18
+ /**
19
+ * Directory to allow during TypeScript files scan.
20
+ * Default: []
21
+ */
22
+ allow?: string[];
23
+ /**
24
+ * Directory to store and cache metadata cache files.
25
+ * Default: false
26
+ */
27
+ cache?: string | boolean | Partial<CacheOptions>;
28
+ /**
29
+ * Manual decorator properties configuration.
30
+ */
31
+ decorators?: DecoratorConfig[];
32
+ /**
33
+ * Load a specific preset configuration.
34
+ */
35
+ preset?: string;
36
+ }
37
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/config/type.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAA;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;AAErF,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEjD;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAE/B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +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 });
9
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/config/type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -0,0 +1,40 @@
1
+ export declare enum DecoratorID {
2
+ SWAGGER_TAGS = "swaggerTags",
3
+ CLASS_PATH = "classPath",
4
+ RESPONSE_DESCRIPTION = "responseDescription",
5
+ RESPONSE_EXAMPLE = "responseExample",
6
+ RESPONSE_PRODUCES = "responseProduces",
7
+ REQUEST_ACCEPT = "requestAccept",
8
+ REQUEST_CONSUMES = "requestConsumes",
9
+ DEPRECATED = "deprecated",
10
+ EXTENSION = "extension",
11
+ HIDDEN = "hidden",
12
+ METHOD_PATH = "methodPath",
13
+ ALL = "all",
14
+ GET = "get",
15
+ POST = "post",
16
+ PUT = "put",
17
+ DELETE = "delete",
18
+ PATCH = "patch",
19
+ OPTIONS = "options",
20
+ HEAD = "head",
21
+ IS_INT = "isInt",
22
+ IS_LONG = "isLong",
23
+ IS_FLOAT = "isFloat",
24
+ IS_DOUBLE = "isDouble",
25
+ CONTEXT = "context",
26
+ PARAM = "param",
27
+ PARAMS = "params",
28
+ QUERY = "query",
29
+ FORM = "form",
30
+ BODY = "body",
31
+ HEADER = "header",
32
+ HEADERS = "headers",
33
+ COOKIE = "cookie",
34
+ COOKIES = "cookies",
35
+ PATH_PARAM = "pathParam",
36
+ PATH_PARAMS = "pathParams",
37
+ FILE_PARAM = "fileParam",
38
+ FILES_PARAM = "filesParam"
39
+ }
40
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/decorator/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,WAAW;IACnB,YAAY,gBAAgB;IAC5B,UAAU,cAAc;IAExB,oBAAoB,wBAAwB;IAC5C,gBAAgB,oBAAoB;IACpC,iBAAiB,qBAAqB;IAEtC,cAAc,kBAAkB;IAChC,gBAAgB,oBAAoB;IAEpC,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,MAAM,WAAW;IAEjB,WAAW,eAAe;IAE1B,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,IAAI,SAAS;IAGb,MAAM,UAAU;IAChB,OAAO,WAAW;IAClB,QAAQ,YAAY;IACpB,SAAS,aAAa;IAGtB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,UAAU,cAAc;IACxB,WAAW,eAAe;IAC1B,UAAU,cAAc;IACxB,WAAW,eAAe;CAC7B"}