@innet/server 2.0.0-alpha.3 → 2.0.0-alpha.30

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 (304) hide show
  1. package/README.md +1375 -541
  2. package/handler/handler.d.ts +19 -13
  3. package/handler/handler.es6.js +17 -11
  4. package/handler/handler.js +17 -11
  5. package/hooks/index.d.ts +6 -0
  6. package/hooks/index.es6.js +6 -0
  7. package/hooks/index.js +6 -0
  8. package/hooks/useAction/useAction.es6.js +1 -1
  9. package/hooks/useAction/useAction.js +1 -1
  10. package/hooks/useApi/useApi.d.ts +1 -3
  11. package/hooks/useClientIp/index.d.ts +1 -0
  12. package/hooks/useClientIp/index.es6.js +1 -0
  13. package/hooks/useClientIp/index.js +9 -0
  14. package/hooks/useClientIp/useClientIp.d.ts +1 -0
  15. package/hooks/useClientIp/useClientIp.es6.js +9 -0
  16. package/hooks/useClientIp/useClientIp.js +13 -0
  17. package/hooks/useComponentName/useComponentName.d.ts +1 -1
  18. package/hooks/useEndpoint/useEndpoint.d.ts +1 -1
  19. package/hooks/useEndpoint/useEndpoint.es6.js +3 -1
  20. package/hooks/useEndpoint/useEndpoint.js +3 -1
  21. package/hooks/useIsServerHttps/index.d.ts +1 -0
  22. package/hooks/useIsServerHttps/index.es6.js +1 -0
  23. package/hooks/useIsServerHttps/index.js +10 -0
  24. package/hooks/useIsServerHttps/useIsServerHttps.d.ts +3 -0
  25. package/hooks/useIsServerHttps/useIsServerHttps.es6.js +14 -0
  26. package/hooks/useIsServerHttps/useIsServerHttps.js +19 -0
  27. package/hooks/useObjectSchemaContext/index.d.ts +1 -0
  28. package/hooks/useObjectSchemaContext/index.es6.js +1 -0
  29. package/hooks/useObjectSchemaContext/index.js +10 -0
  30. package/hooks/useObjectSchemaContext/useObjectSchemaContext.d.ts +3 -0
  31. package/hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js +14 -0
  32. package/hooks/useObjectSchemaContext/useObjectSchemaContext.js +19 -0
  33. package/hooks/useRequest/index.es6.js +1 -1
  34. package/hooks/useRequest/index.js +0 -1
  35. package/hooks/useRequest/useRequest.d.ts +1 -4
  36. package/hooks/useRequest/useRequest.es6.js +4 -4
  37. package/hooks/useRequest/useRequest.js +3 -4
  38. package/hooks/useResponse/index.es6.js +1 -1
  39. package/hooks/useResponse/index.js +0 -1
  40. package/hooks/useResponse/useResponse.d.ts +1 -4
  41. package/hooks/useResponse/useResponse.es6.js +4 -4
  42. package/hooks/useResponse/useResponse.js +3 -4
  43. package/hooks/useSchemaType/useSchemaType.d.ts +3 -2
  44. package/hooks/useSchemaType/useSchemaType.es6.js +5 -6
  45. package/hooks/useSchemaType/useSchemaType.js +5 -6
  46. package/hooks/useServer/useServer.d.ts +2 -1
  47. package/hooks/useServer/useServer.es6.js +3 -1
  48. package/hooks/useServer/useServer.js +3 -1
  49. package/hooks/useServerPlugin/index.d.ts +1 -0
  50. package/hooks/useServerPlugin/index.es6.js +1 -0
  51. package/hooks/useServerPlugin/index.js +9 -0
  52. package/hooks/useServerPlugin/useServerPlugin.d.ts +2 -0
  53. package/hooks/useServerPlugin/useServerPlugin.es6.js +13 -0
  54. package/hooks/useServerPlugin/useServerPlugin.js +17 -0
  55. package/hooks/useServerPlugins/index.d.ts +1 -0
  56. package/hooks/useServerPlugins/index.es6.js +1 -0
  57. package/hooks/useServerPlugins/index.js +10 -0
  58. package/hooks/useServerPlugins/useServerPlugins.d.ts +4 -0
  59. package/hooks/useServerPlugins/useServerPlugins.es6.js +14 -0
  60. package/hooks/useServerPlugins/useServerPlugins.js +19 -0
  61. package/hooks/useServerPort/index.d.ts +1 -0
  62. package/hooks/useServerPort/index.es6.js +1 -0
  63. package/hooks/useServerPort/index.js +10 -0
  64. package/hooks/useServerPort/useServerPort.d.ts +3 -0
  65. package/hooks/useServerPort/useServerPort.es6.js +14 -0
  66. package/hooks/useServerPort/useServerPort.js +19 -0
  67. package/index.es6.js +17 -8
  68. package/index.js +34 -12
  69. package/package.json +2 -2
  70. package/plugins/main/api/api.d.ts +10 -8
  71. package/plugins/main/api/api.es6.js +53 -55
  72. package/plugins/main/api/api.js +53 -55
  73. package/plugins/main/contact/contact.d.ts +2 -2
  74. package/plugins/main/endpoint/endpoint.d.ts +15 -15
  75. package/plugins/main/endpoint/endpoint.es6.js +7 -4
  76. package/plugins/main/endpoint/endpoint.js +7 -4
  77. package/plugins/main/host/host.d.ts +5 -5
  78. package/plugins/main/index.d.ts +2 -2
  79. package/plugins/main/index.es6.js +2 -2
  80. package/plugins/main/index.js +2 -2
  81. package/plugins/main/license/license.d.ts +5 -5
  82. package/plugins/main/param/param.d.ts +11 -11
  83. package/plugins/main/param/param.es6.js +3 -3
  84. package/plugins/main/param/param.js +3 -3
  85. package/plugins/main/preset/index.d.ts +1 -0
  86. package/plugins/main/preset/index.es6.js +1 -0
  87. package/plugins/{utils/prod → main/preset}/index.js +2 -2
  88. package/plugins/main/preset/preset.d.ts +3 -0
  89. package/plugins/main/preset/preset.es6.js +13 -0
  90. package/plugins/{utils/dev/dev.js → main/preset/preset.js} +9 -6
  91. package/plugins/main/response/index.es6.js +1 -1
  92. package/plugins/main/response/index.js +1 -0
  93. package/plugins/main/response/response.d.ts +6 -2
  94. package/plugins/main/response/response.es6.js +18 -10
  95. package/plugins/main/response/response.js +18 -9
  96. package/plugins/main/return/index.d.ts +1 -0
  97. package/plugins/main/return/index.es6.js +1 -0
  98. package/plugins/main/return/index.js +9 -0
  99. package/plugins/main/return/return.d.ts +4 -0
  100. package/plugins/main/return/return.es6.js +10 -0
  101. package/plugins/main/return/return.js +14 -0
  102. package/plugins/main/server/server.d.ts +5 -5
  103. package/plugins/main/server/server.es6.js +36 -10
  104. package/plugins/main/server/server.js +36 -10
  105. package/plugins/main/tag/tag.d.ts +2 -2
  106. package/plugins/main/tag/tag.es6.js +5 -2
  107. package/plugins/main/tag/tag.js +5 -2
  108. package/plugins/main/variable/variable.d.ts +5 -5
  109. package/plugins/main/variable/variable.es6.js +3 -1
  110. package/plugins/main/variable/variable.js +3 -1
  111. package/plugins/request/cms/cms.es6.js +2 -2
  112. package/plugins/request/cms/cms.js +2 -2
  113. package/plugins/request/cookie/cookie.es6.js +3 -19
  114. package/plugins/request/cookie/cookie.js +3 -23
  115. package/plugins/request/error/error.d.ts +40 -40
  116. package/plugins/request/error/error.es6.js +45 -42
  117. package/plugins/request/error/error.js +45 -42
  118. package/plugins/request/file/file.es6.js +2 -3
  119. package/plugins/request/file/file.js +2 -3
  120. package/plugins/request/header/header.es6.js +1 -1
  121. package/plugins/request/header/header.js +1 -1
  122. package/plugins/request/proxy/proxy.d.ts +4 -1
  123. package/plugins/request/proxy/proxy.es6.js +5 -2
  124. package/plugins/request/proxy/proxy.js +5 -2
  125. package/plugins/request/redirect/redirect.d.ts +8 -7
  126. package/plugins/request/redirect/redirect.es6.js +7 -7
  127. package/plugins/request/redirect/redirect.js +7 -7
  128. package/plugins/request/success/success.d.ts +7 -6
  129. package/plugins/request/success/success.es6.js +21 -10
  130. package/plugins/request/success/success.js +21 -10
  131. package/plugins/schema/any/any.d.ts +5 -0
  132. package/plugins/schema/any/any.es6.js +27 -0
  133. package/plugins/schema/any/any.js +31 -0
  134. package/plugins/schema/binary/binary.d.ts +3 -3
  135. package/plugins/schema/boolean/boolean.es6.js +2 -4
  136. package/plugins/schema/boolean/boolean.js +1 -3
  137. package/plugins/schema/date/date.d.ts +1 -1
  138. package/plugins/schema/date/date.es6.js +3 -3
  139. package/plugins/schema/date/date.js +3 -3
  140. package/plugins/schema/field/field.d.ts +1 -0
  141. package/plugins/schema/field/field.es6.js +7 -6
  142. package/plugins/schema/field/field.js +6 -5
  143. package/plugins/schema/index.d.ts +1 -0
  144. package/plugins/schema/index.es6.js +1 -0
  145. package/plugins/schema/index.js +1 -0
  146. package/plugins/schema/integer/integer.d.ts +3 -3
  147. package/plugins/schema/integer/integer.es6.js +1 -1
  148. package/plugins/schema/integer/integer.js +1 -1
  149. package/plugins/schema/number/number.d.ts +2 -2
  150. package/plugins/schema/number/number.es6.js +1 -1
  151. package/plugins/schema/number/number.js +1 -1
  152. package/plugins/schema/object/object.es6.js +17 -4
  153. package/plugins/schema/object/object.js +17 -4
  154. package/plugins/schema/string/string.d.ts +2 -2
  155. package/plugins/schema/string/string.es6.js +44 -30
  156. package/plugins/schema/string/string.js +44 -30
  157. package/plugins/utils/blacklist/blacklist.d.ts +4 -0
  158. package/plugins/utils/blacklist/blacklist.es6.js +18 -0
  159. package/plugins/utils/blacklist/blacklist.js +22 -0
  160. package/plugins/utils/blacklist/index.d.ts +1 -0
  161. package/plugins/utils/blacklist/index.es6.js +1 -0
  162. package/plugins/utils/blacklist/index.js +9 -0
  163. package/plugins/utils/dts/dts.d.ts +3 -3
  164. package/plugins/utils/dts/dts.es6.js +6 -25
  165. package/plugins/utils/dts/dts.js +5 -29
  166. package/plugins/utils/env/env.d.ts +6 -0
  167. package/plugins/utils/env/env.es6.js +11 -0
  168. package/plugins/utils/{prod/prod.js → env/env.js} +4 -3
  169. package/plugins/utils/env/index.d.ts +1 -0
  170. package/plugins/utils/env/index.es6.js +1 -0
  171. package/plugins/utils/{dev → env}/index.js +2 -2
  172. package/plugins/utils/index.d.ts +4 -2
  173. package/plugins/utils/index.es6.js +4 -2
  174. package/plugins/utils/index.js +4 -2
  175. package/plugins/utils/protection/index.d.ts +1 -0
  176. package/plugins/utils/protection/index.es6.js +1 -0
  177. package/plugins/utils/protection/index.js +9 -0
  178. package/plugins/utils/protection/protection.d.ts +8 -0
  179. package/plugins/utils/protection/protection.es6.js +36 -0
  180. package/plugins/utils/protection/protection.js +40 -0
  181. package/plugins/utils/swagger/swagger.es6.js +10 -12
  182. package/plugins/utils/swagger/swagger.js +10 -12
  183. package/plugins/utils/whitelist/index.d.ts +1 -0
  184. package/plugins/utils/whitelist/index.es6.js +1 -0
  185. package/plugins/utils/whitelist/index.js +9 -0
  186. package/plugins/utils/whitelist/whitelist.d.ts +4 -0
  187. package/plugins/utils/whitelist/whitelist.es6.js +20 -0
  188. package/plugins/utils/whitelist/whitelist.js +24 -0
  189. package/types.d.ts +15 -23
  190. package/utils/FileData/Bin.d.ts +13 -13
  191. package/utils/FileData/Bin.es6.js +2 -2
  192. package/utils/FileData/Bin.js +2 -2
  193. package/utils/action/Action.d.ts +17 -14
  194. package/utils/action/Action.es6.js +102 -78
  195. package/utils/action/Action.js +102 -78
  196. package/utils/dateFormat/dateFormat.d.ts +1 -1
  197. package/utils/dateFormat/dateFormat.es6.js +1 -1
  198. package/utils/dateFormat/dateFormat.js +1 -1
  199. package/utils/generateTypes/generateTypes.d.ts +3 -0
  200. package/utils/generateTypes/generateTypes.es6.js +157 -0
  201. package/utils/generateTypes/generateTypes.js +162 -0
  202. package/utils/generateTypes/index.d.ts +1 -0
  203. package/utils/generateTypes/index.es6.js +1 -0
  204. package/utils/generateTypes/index.js +10 -0
  205. package/utils/getEndpoint/getEndpoint.es6.js +2 -2
  206. package/utils/getEndpoint/getEndpoint.js +2 -2
  207. package/utils/getOrAdd/getOrAdd.d.ts +1 -1
  208. package/utils/httpOnStart/httpOnStart.d.ts +1 -1
  209. package/utils/httpOnStart/httpOnStart.es6.js +1 -1
  210. package/utils/httpOnStart/httpOnStart.js +1 -1
  211. package/utils/index.d.ts +1 -0
  212. package/utils/index.es6.js +1 -0
  213. package/utils/index.js +1 -0
  214. package/utils/rules/binaryAccept/binaryAccept.es6.js +2 -2
  215. package/utils/rules/binaryAccept/binaryAccept.js +2 -2
  216. package/utils/rules/dateTo/dateTo.d.ts +1 -1
  217. package/utils/rules/helpers.d.ts +1 -1
  218. package/utils/rules/index.d.ts +0 -1
  219. package/utils/rules/index.es6.js +0 -1
  220. package/utils/rules/index.js +0 -1
  221. package/utils/rules/int/int.es6.js +2 -2
  222. package/utils/rules/int/int.js +2 -2
  223. package/utils/rules/max/max.d.ts +1 -1
  224. package/utils/rules/max/max.es6.js +3 -3
  225. package/utils/rules/max/max.js +3 -3
  226. package/utils/rules/maxBin/maxBin.es6.js +2 -2
  227. package/utils/rules/maxBin/maxBin.js +2 -2
  228. package/utils/rules/maxDate/maxDate.es6.js +1 -1
  229. package/utils/rules/maxDate/maxDate.js +1 -1
  230. package/utils/rules/maxLength/maxLength.es6.js +2 -2
  231. package/utils/rules/maxLength/maxLength.js +2 -2
  232. package/utils/rules/min/min.d.ts +1 -1
  233. package/utils/rules/min/min.es6.js +3 -3
  234. package/utils/rules/min/min.js +3 -3
  235. package/utils/rules/minBin/minBin.es6.js +2 -2
  236. package/utils/rules/minBin/minBin.js +2 -2
  237. package/utils/rules/minDate/minDate.es6.js +1 -1
  238. package/utils/rules/minDate/minDate.js +1 -1
  239. package/utils/rules/minLength/minLength.es6.js +2 -2
  240. package/utils/rules/minLength/minLength.js +2 -2
  241. package/utils/rules/objectOf/objectOf.d.ts +1 -1
  242. package/utils/rules/objectOf/objectOf.es6.js +15 -2
  243. package/utils/rules/objectOf/objectOf.js +15 -2
  244. package/utils/rules/pattern/pattern.d.ts +1 -1
  245. package/utils/rules/pattern/pattern.es6.js +2 -1
  246. package/utils/rules/pattern/pattern.js +2 -1
  247. package/example/app/App/App.d.ts +0 -1
  248. package/example/app/App/index.d.ts +0 -1
  249. package/example/index.d.ts +0 -1
  250. package/example/requests/index.d.ts +0 -1
  251. package/example/requests/partners/EditPartner/EditPartner.d.ts +0 -1
  252. package/example/requests/partners/EditPartner/index.d.ts +0 -1
  253. package/example/requests/partners/GetPartner/GetPartner.d.ts +0 -1
  254. package/example/requests/partners/GetPartner/index.d.ts +0 -1
  255. package/example/requests/partners/GetPartners/GetPartners.d.ts +0 -1
  256. package/example/requests/partners/GetPartners/index.d.ts +0 -1
  257. package/example/requests/partners/index.d.ts +0 -3
  258. package/example/schemas/address/AddressSchema/AddressSchema.d.ts +0 -1
  259. package/example/schemas/address/AddressSchema/index.d.ts +0 -1
  260. package/example/schemas/address/index.d.ts +0 -1
  261. package/example/schemas/app/ListSchema/ListSchema.d.ts +0 -1
  262. package/example/schemas/app/ListSchema/index.d.ts +0 -1
  263. package/example/schemas/app/index.d.ts +0 -1
  264. package/example/schemas/index.d.ts +0 -4
  265. package/example/schemas/location/LocationSchema/LocationSchema.d.ts +0 -1
  266. package/example/schemas/location/LocationSchema/index.d.ts +0 -1
  267. package/example/schemas/location/index.d.ts +0 -1
  268. package/example/schemas/partner/EditPartnerSchema/EditPartnerSchema.d.ts +0 -1
  269. package/example/schemas/partner/EditPartnerSchema/index.d.ts +0 -1
  270. package/example/schemas/partner/PartnerSchema/PartnerSchema.d.ts +0 -1
  271. package/example/schemas/partner/PartnerSchema/index.d.ts +0 -1
  272. package/example/schemas/partner/index.d.ts +0 -2
  273. package/example/tags/Partner/Partner.d.ts +0 -1
  274. package/example/tags/Partner/index.d.ts +0 -1
  275. package/example/tags/index.d.ts +0 -1
  276. package/openApi.test.d.ts +0 -1
  277. package/plugins/main/fallback/fallback.d.ts +0 -4
  278. package/plugins/main/fallback/fallback.es6.js +0 -19
  279. package/plugins/main/fallback/fallback.js +0 -23
  280. package/plugins/main/fallback/index.d.ts +0 -1
  281. package/plugins/main/fallback/index.es6.js +0 -1
  282. package/plugins/main/fallback/index.js +0 -9
  283. package/plugins/main/request/index.d.ts +0 -1
  284. package/plugins/main/request/index.es6.js +0 -1
  285. package/plugins/main/request/index.js +0 -9
  286. package/plugins/main/request/request.d.ts +0 -4
  287. package/plugins/main/request/request.es6.js +0 -21
  288. package/plugins/main/request/request.js +0 -25
  289. package/plugins/utils/dev/dev.d.ts +0 -4
  290. package/plugins/utils/dev/dev.es6.js +0 -10
  291. package/plugins/utils/dev/index.d.ts +0 -1
  292. package/plugins/utils/dev/index.es6.js +0 -1
  293. package/plugins/utils/prod/index.d.ts +0 -1
  294. package/plugins/utils/prod/index.es6.js +0 -1
  295. package/plugins/utils/prod/prod.d.ts +0 -4
  296. package/plugins/utils/prod/prod.es6.js +0 -10
  297. package/utils/decorators/once/once.test.d.ts +0 -1
  298. package/utils/parseSearch/parseSearch.test.d.ts +0 -1
  299. package/utils/rules/any/any.d.ts +0 -1
  300. package/utils/rules/any/any.es6.js +0 -5
  301. package/utils/rules/any/any.js +0 -9
  302. /package/{utils/rules → plugins/schema}/any/index.d.ts +0 -0
  303. /package/{utils/rules → plugins/schema}/any/index.es6.js +0 -0
  304. /package/{utils/rules → plugins/schema}/any/index.js +0 -0
@@ -1,52 +1,58 @@
1
1
  import { __rest, __awaiter } from 'tslib';
2
2
  import innet, { useNewHandler, useApp } from 'innet';
3
- import { onDestroy } from 'watch-state';
4
3
  import '../../../hooks/index.es6.js';
5
4
  import '../../../utils/index.es6.js';
6
5
  import '../../../utils/rules/index.es6.js';
7
- import { useServer } from '../../../hooks/useServer/useServer.es6.js';
6
+ import { serverPlugins } from '../../../hooks/useServerPlugins/useServerPlugins.es6.js';
8
7
  import { apiContext } from '../../../hooks/useApi/useApi.es6.js';
9
- import { Action } from '../../../utils/action/Action.es6.js';
8
+ import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
9
+ import { useAction, actionContext } from '../../../hooks/useAction/useAction.es6.js';
10
10
  import { JSONString } from '../../../utils/JSONString/JSONString.es6.js';
11
11
  import { RulesError } from '../../../utils/rules/helpers.es6.js';
12
- import { responseContext } from '../../../hooks/useResponse/useResponse.es6.js';
13
- import { requestContext } from '../../../hooks/useRequest/useRequest.es6.js';
14
12
  import { paramsContext } from '../../../hooks/useParams/useParams.es6.js';
15
- import { actionContext } from '../../../hooks/useAction/useAction.es6.js';
16
13
 
17
14
  const api = () => {
18
- var _a;
19
15
  const handler = useNewHandler();
20
- const { props = {}, children } = useApp();
21
- const { server } = useServer();
22
- const { prefix = '', title = '' } = props, rest = __rest(props, ["prefix", "title"]);
23
- const info = Object.assign(Object.assign({}, rest), { version: (_a = rest.version) !== null && _a !== void 0 ? _a : '0.0.0', title });
16
+ const { children, props = {}, } = useApp();
17
+ const { exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0' } = props, rest = __rest(props, ["exclude", "include", "prefix", "title", "version"]);
18
+ const info = Object.assign(Object.assign({}, rest), { title, version });
24
19
  const endpoints = {};
25
20
  const docs = {
26
- openapi: '3.1.0',
27
21
  info,
22
+ openapi: '3.1.0',
28
23
  paths: {},
29
24
  };
30
- const requestPlugins = new Set();
31
- const context = { docs, endpoints, prefix, requestPlugins, refRules: {} };
25
+ const plugins = new Set();
26
+ const context = { docs, endpoints, prefix, refRules: {} };
27
+ const condition = (action) => {
28
+ const path = action.parsedUrl.path;
29
+ const url = path.endsWith('/') ? path.slice(0, -1) : path;
30
+ if (!url.startsWith(prefix) || (exclude === null || exclude === void 0 ? void 0 : exclude.test(url))) {
31
+ return false;
32
+ }
33
+ if (include && !include.test(url)) {
34
+ return false;
35
+ }
36
+ return true;
37
+ };
38
+ serverPlugins.set(handler, plugins);
32
39
  apiContext.set(handler, context);
33
- const listener = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
34
- var _b, _c, _d, _e, _f, _g;
35
- if (res.writableEnded)
40
+ useServerPlugin(() => __awaiter(void 0, void 0, void 0, function* () {
41
+ var _a, _b, _c, _d, _e, _f;
42
+ const action = useAction();
43
+ if (!condition(action))
36
44
  return;
37
- const action = new Action(req);
45
+ const actionHandler = useNewHandler();
38
46
  const path = action.parsedUrl.path;
39
47
  const url = path.endsWith('/') ? path.slice(0, -1) : path;
48
+ const { req, res, } = action;
40
49
  if (url === (prefix || '')) {
41
50
  res.setHeader('Content-Type', 'application/json');
42
51
  res.write(JSONString(docs));
43
52
  res.end();
44
- return;
45
- }
46
- if (!url.startsWith(prefix)) {
47
- return;
53
+ return null;
48
54
  }
49
- const method = ((_c = (_b = req.method) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : 'get');
55
+ const method = ((_b = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'get');
50
56
  const rawSplitPath = url.slice(prefix.length).split('/').slice(1);
51
57
  const splitPath = rawSplitPath.at(-1) ? rawSplitPath : rawSplitPath.slice(0, -1);
52
58
  const endpoint = endpoints[method];
@@ -81,8 +87,8 @@ const api = () => {
81
87
  if (e instanceof RulesError) {
82
88
  res.statusCode = 400;
83
89
  res.write(JSONString({
84
- error: 'requestValidation',
85
90
  data: Object.assign(Object.assign({}, e.data), { in: key }),
91
+ error: 'requestValidation',
86
92
  }));
87
93
  res.end();
88
94
  }
@@ -90,8 +96,8 @@ const api = () => {
90
96
  console.error(e);
91
97
  res.statusCode = 500;
92
98
  res.write(JSONString({
93
- error: 'unknown',
94
99
  data: { in: key },
100
+ error: 'unknown',
95
101
  }));
96
102
  res.end();
97
103
  }
@@ -120,32 +126,34 @@ const api = () => {
120
126
  if (checkActionRules(bodyRules, 'body'))
121
127
  return true;
122
128
  }
123
- const newHandler = Object.create(runEndpoint.handler);
124
- responseContext.set(newHandler, res);
125
- requestContext.set(newHandler, req);
126
- paramsContext.set(newHandler, params);
127
- actionContext.set(newHandler, action);
128
- innet(runEndpoint.content, newHandler);
129
+ paramsContext.set(actionHandler, params);
130
+ for (const plugin of runEndpoint.plugins) {
131
+ const result = yield plugin();
132
+ if (result === undefined)
133
+ continue;
134
+ innet(result, actionHandler);
135
+ return true;
136
+ }
129
137
  return true;
130
138
  });
131
139
  }
132
- if ((_e = (_d = currentEndpoint.static) === null || _d === void 0 ? void 0 : _d[key]) === null || _e === void 0 ? void 0 : _e.content) {
133
- if (!(yield run((_f = currentEndpoint.static) === null || _f === void 0 ? void 0 : _f[key], params)))
140
+ if ((_d = (_c = currentEndpoint.static) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.plugins) {
141
+ if (!(yield run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params)))
134
142
  continue;
135
- return;
143
+ return null;
136
144
  }
137
145
  if (currentEndpoint.dynamic) {
138
146
  for (const dynamicEndpoint of currentEndpoint.dynamic) {
139
- if (dynamicEndpoint.content) {
147
+ if (dynamicEndpoint.plugins) {
140
148
  if (!(yield run(dynamicEndpoint, Object.assign(Object.assign({}, params), { [dynamicEndpoint.key.slice(1, -1)]: key }))))
141
149
  continue;
142
- return;
150
+ return null;
143
151
  }
144
152
  }
145
153
  }
146
154
  break;
147
155
  }
148
- if ((_g = currentEndpoint.static) === null || _g === void 0 ? void 0 : _g[key]) {
156
+ if ((_f = currentEndpoint.static) === null || _f === void 0 ? void 0 : _f[key]) {
149
157
  endpointQueue.push([deep + 1, currentEndpoint.static[key], params]);
150
158
  }
151
159
  if (currentEndpoint.dynamic) {
@@ -154,26 +162,16 @@ const api = () => {
154
162
  }
155
163
  }
156
164
  }
157
- for (const requestPlugin of requestPlugins) {
158
- if (requestPlugin(req, res))
159
- return;
160
- }
161
- if (context.fallback) {
162
- const newHandler = Object.create(context.fallback.handler);
163
- responseContext.set(newHandler, res);
164
- requestContext.set(newHandler, req);
165
+ for (const plugin of plugins) {
166
+ const result = yield plugin();
167
+ if (result === undefined)
168
+ continue;
169
+ const newHandler = Object.create(handler);
165
170
  actionContext.set(newHandler, action);
166
- innet(context.fallback.children, newHandler);
167
- }
168
- else {
169
- res.statusCode = 404;
170
- res.end();
171
+ innet(result, newHandler);
172
+ return null;
171
173
  }
172
- });
173
- server.on('request', listener);
174
- onDestroy(() => {
175
- server.off('request', listener);
176
- });
174
+ }));
177
175
  innet(children, handler);
178
176
  };
179
177
 
@@ -4,57 +4,63 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
  var innet = require('innet');
7
- var watchState = require('watch-state');
8
7
  require('../../../hooks/index.js');
9
8
  require('../../../utils/index.js');
10
9
  require('../../../utils/rules/index.js');
11
- var useServer = require('../../../hooks/useServer/useServer.js');
10
+ var useServerPlugins = require('../../../hooks/useServerPlugins/useServerPlugins.js');
12
11
  var useApi = require('../../../hooks/useApi/useApi.js');
13
- var Action = require('../../../utils/action/Action.js');
12
+ var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
13
+ var useAction = require('../../../hooks/useAction/useAction.js');
14
14
  var JSONString = require('../../../utils/JSONString/JSONString.js');
15
15
  var helpers = require('../../../utils/rules/helpers.js');
16
- var useResponse = require('../../../hooks/useResponse/useResponse.js');
17
- var useRequest = require('../../../hooks/useRequest/useRequest.js');
18
16
  var useParams = require('../../../hooks/useParams/useParams.js');
19
- var useAction = require('../../../hooks/useAction/useAction.js');
20
17
 
21
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
19
 
23
20
  var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
24
21
 
25
22
  const api = () => {
26
- var _a;
27
23
  const handler = innet.useNewHandler();
28
- const { props = {}, children } = innet.useApp();
29
- const { server } = useServer.useServer();
30
- const { prefix = '', title = '' } = props, rest = tslib.__rest(props, ["prefix", "title"]);
31
- const info = Object.assign(Object.assign({}, rest), { version: (_a = rest.version) !== null && _a !== void 0 ? _a : '0.0.0', title });
24
+ const { children, props = {}, } = innet.useApp();
25
+ const { exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0' } = props, rest = tslib.__rest(props, ["exclude", "include", "prefix", "title", "version"]);
26
+ const info = Object.assign(Object.assign({}, rest), { title, version });
32
27
  const endpoints = {};
33
28
  const docs = {
34
- openapi: '3.1.0',
35
29
  info,
30
+ openapi: '3.1.0',
36
31
  paths: {},
37
32
  };
38
- const requestPlugins = new Set();
39
- const context = { docs, endpoints, prefix, requestPlugins, refRules: {} };
33
+ const plugins = new Set();
34
+ const context = { docs, endpoints, prefix, refRules: {} };
35
+ const condition = (action) => {
36
+ const path = action.parsedUrl.path;
37
+ const url = path.endsWith('/') ? path.slice(0, -1) : path;
38
+ if (!url.startsWith(prefix) || (exclude === null || exclude === void 0 ? void 0 : exclude.test(url))) {
39
+ return false;
40
+ }
41
+ if (include && !include.test(url)) {
42
+ return false;
43
+ }
44
+ return true;
45
+ };
46
+ useServerPlugins.serverPlugins.set(handler, plugins);
40
47
  useApi.apiContext.set(handler, context);
41
- const listener = (req, res) => tslib.__awaiter(void 0, void 0, void 0, function* () {
42
- var _b, _c, _d, _e, _f, _g;
43
- if (res.writableEnded)
48
+ useServerPlugin.useServerPlugin(() => tslib.__awaiter(void 0, void 0, void 0, function* () {
49
+ var _a, _b, _c, _d, _e, _f;
50
+ const action = useAction.useAction();
51
+ if (!condition(action))
44
52
  return;
45
- const action = new Action.Action(req);
53
+ const actionHandler = innet.useNewHandler();
46
54
  const path = action.parsedUrl.path;
47
55
  const url = path.endsWith('/') ? path.slice(0, -1) : path;
56
+ const { req, res, } = action;
48
57
  if (url === (prefix || '')) {
49
58
  res.setHeader('Content-Type', 'application/json');
50
59
  res.write(JSONString.JSONString(docs));
51
60
  res.end();
52
- return;
53
- }
54
- if (!url.startsWith(prefix)) {
55
- return;
61
+ return null;
56
62
  }
57
- const method = ((_c = (_b = req.method) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : 'get');
63
+ const method = ((_b = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'get');
58
64
  const rawSplitPath = url.slice(prefix.length).split('/').slice(1);
59
65
  const splitPath = rawSplitPath.at(-1) ? rawSplitPath : rawSplitPath.slice(0, -1);
60
66
  const endpoint = endpoints[method];
@@ -89,8 +95,8 @@ const api = () => {
89
95
  if (e instanceof helpers.RulesError) {
90
96
  res.statusCode = 400;
91
97
  res.write(JSONString.JSONString({
92
- error: 'requestValidation',
93
98
  data: Object.assign(Object.assign({}, e.data), { in: key }),
99
+ error: 'requestValidation',
94
100
  }));
95
101
  res.end();
96
102
  }
@@ -98,8 +104,8 @@ const api = () => {
98
104
  console.error(e);
99
105
  res.statusCode = 500;
100
106
  res.write(JSONString.JSONString({
101
- error: 'unknown',
102
107
  data: { in: key },
108
+ error: 'unknown',
103
109
  }));
104
110
  res.end();
105
111
  }
@@ -128,32 +134,34 @@ const api = () => {
128
134
  if (checkActionRules(bodyRules, 'body'))
129
135
  return true;
130
136
  }
131
- const newHandler = Object.create(runEndpoint.handler);
132
- useResponse.responseContext.set(newHandler, res);
133
- useRequest.requestContext.set(newHandler, req);
134
- useParams.paramsContext.set(newHandler, params);
135
- useAction.actionContext.set(newHandler, action);
136
- innet__default["default"](runEndpoint.content, newHandler);
137
+ useParams.paramsContext.set(actionHandler, params);
138
+ for (const plugin of runEndpoint.plugins) {
139
+ const result = yield plugin();
140
+ if (result === undefined)
141
+ continue;
142
+ innet__default["default"](result, actionHandler);
143
+ return true;
144
+ }
137
145
  return true;
138
146
  });
139
147
  }
140
- if ((_e = (_d = currentEndpoint.static) === null || _d === void 0 ? void 0 : _d[key]) === null || _e === void 0 ? void 0 : _e.content) {
141
- if (!(yield run((_f = currentEndpoint.static) === null || _f === void 0 ? void 0 : _f[key], params)))
148
+ if ((_d = (_c = currentEndpoint.static) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.plugins) {
149
+ if (!(yield run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params)))
142
150
  continue;
143
- return;
151
+ return null;
144
152
  }
145
153
  if (currentEndpoint.dynamic) {
146
154
  for (const dynamicEndpoint of currentEndpoint.dynamic) {
147
- if (dynamicEndpoint.content) {
155
+ if (dynamicEndpoint.plugins) {
148
156
  if (!(yield run(dynamicEndpoint, Object.assign(Object.assign({}, params), { [dynamicEndpoint.key.slice(1, -1)]: key }))))
149
157
  continue;
150
- return;
158
+ return null;
151
159
  }
152
160
  }
153
161
  }
154
162
  break;
155
163
  }
156
- if ((_g = currentEndpoint.static) === null || _g === void 0 ? void 0 : _g[key]) {
164
+ if ((_f = currentEndpoint.static) === null || _f === void 0 ? void 0 : _f[key]) {
157
165
  endpointQueue.push([deep + 1, currentEndpoint.static[key], params]);
158
166
  }
159
167
  if (currentEndpoint.dynamic) {
@@ -162,26 +170,16 @@ const api = () => {
162
170
  }
163
171
  }
164
172
  }
165
- for (const requestPlugin of requestPlugins) {
166
- if (requestPlugin(req, res))
167
- return;
168
- }
169
- if (context.fallback) {
170
- const newHandler = Object.create(context.fallback.handler);
171
- useResponse.responseContext.set(newHandler, res);
172
- useRequest.requestContext.set(newHandler, req);
173
+ for (const plugin of plugins) {
174
+ const result = yield plugin();
175
+ if (result === undefined)
176
+ continue;
177
+ const newHandler = Object.create(handler);
173
178
  useAction.actionContext.set(newHandler, action);
174
- innet__default["default"](context.fallback.children, newHandler);
175
- }
176
- else {
177
- res.statusCode = 404;
178
- res.end();
179
+ innet__default["default"](result, newHandler);
180
+ return null;
179
181
  }
180
- });
181
- server.on('request', listener);
182
- watchState.onDestroy(() => {
183
- server.off('request', listener);
184
- });
182
+ }));
185
183
  innet__default["default"](children, handler);
186
184
  };
187
185
 
@@ -1,10 +1,10 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  export interface ContactProps {
3
+ /** The email address of the contact person/organization. This MUST be in the form of an email address. */
4
+ email?: string;
3
5
  /** The identifying name of the contact person/organization. */
4
6
  name?: string;
5
7
  /** The URL pointing to the contact information. This MUST be in the form of a URL. */
6
8
  url?: string;
7
- /** The email address of the contact person/organization. This MUST be in the form of an email address. */
8
- email?: string;
9
9
  }
10
10
  export declare const contact: HandlerPlugin;
@@ -1,6 +1,17 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type EndpointsMethods } from '../../../types';
3
3
  export interface EndpointProps {
4
+ /**
5
+ * Declares this operation to be deprecated.
6
+ * Consumers SHOULD refrain from usage of the declared operation.
7
+ * Default value is false.
8
+ * */
9
+ deprecated?: boolean;
10
+ /**
11
+ * An optional, string description, intended to apply to all operations in this path.
12
+ * [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
13
+ * */
14
+ description?: string;
4
15
  /**
5
16
  * A method of the endpoint.
6
17
  * */
@@ -13,25 +24,14 @@ export interface EndpointProps {
13
24
  * Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical.
14
25
  * */
15
26
  path: string;
16
- /**
17
- * An optional, string summary, intended to apply to all operations in this path.
18
- * */
19
- summary?: string;
20
- /**
21
- * An optional, string description, intended to apply to all operations in this path.
22
- * [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
23
- * */
24
- description?: string;
25
- /**
26
- * Declares this operation to be deprecated.
27
- * Consumers SHOULD refrain from usage of the declared operation.
28
- * Default value is false.
29
- * */
30
- deprecated?: boolean;
31
27
  /**
32
28
  * Declares this operation to make an endpoint private.
33
29
  * That means the endpoint should not be described and will not be shown in the Open API documentation.
34
30
  * */
35
31
  private?: boolean;
32
+ /**
33
+ * An optional, string summary, intended to apply to all operations in this path.
34
+ * */
35
+ summary?: string;
36
36
  }
37
37
  export declare const endpoint: HandlerPlugin;
@@ -6,13 +6,14 @@ import { useTag } from '../../../hooks/useTag/useTag.es6.js';
6
6
  import { useApi } from '../../../hooks/useApi/useApi.es6.js';
7
7
  import { getEndpoint } from '../../../utils/getEndpoint/getEndpoint.es6.js';
8
8
  import { endpointContext } from '../../../hooks/useEndpoint/useEndpoint.es6.js';
9
+ import { serverPlugins } from '../../../hooks/useServerPlugins/useServerPlugins.es6.js';
9
10
 
10
11
  const endpoint = () => {
11
12
  const handler = useNewHandler();
12
13
  const tag = useTag();
13
- const { docs, endpoints } = useApi();
14
+ const { docs, endpoints, } = useApi();
14
15
  const props = useProps();
15
- const { path, summary, description, deprecated, method, private: privateMode } = props;
16
+ const { deprecated, description, method, path, private: privateMode, summary, } = props;
16
17
  const children = useChildren();
17
18
  const { paths } = docs;
18
19
  if (!paths)
@@ -42,12 +43,14 @@ const endpoint = () => {
42
43
  paths[path][method] = operation;
43
44
  }
44
45
  if (!endpoints[method]) {
45
- endpoints[method] = { key: '' };
46
+ endpoints[method] = { key: '', plugins: new Set() };
46
47
  }
47
48
  // @ts-expect-error: it's always an object
48
49
  const endpoint = getEndpoint(path, endpoints[method]);
49
50
  // @ts-expect-error: it's always an object
50
- endpointContext.set(handler, { operation, props, endpoint });
51
+ endpointContext.set(handler, { endpoint, operation, props });
52
+ // @ts-expect-error: it's always an object
53
+ serverPlugins.set(handler, endpoint.plugins);
51
54
  innet(children, handler);
52
55
  };
53
56
 
@@ -10,6 +10,7 @@ var useTag = require('../../../hooks/useTag/useTag.js');
10
10
  var useApi = require('../../../hooks/useApi/useApi.js');
11
11
  var getEndpoint = require('../../../utils/getEndpoint/getEndpoint.js');
12
12
  var useEndpoint = require('../../../hooks/useEndpoint/useEndpoint.js');
13
+ var useServerPlugins = require('../../../hooks/useServerPlugins/useServerPlugins.js');
13
14
 
14
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
16
 
@@ -18,9 +19,9 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
18
19
  const endpoint = () => {
19
20
  const handler = innet.useNewHandler();
20
21
  const tag = useTag.useTag();
21
- const { docs, endpoints } = useApi.useApi();
22
+ const { docs, endpoints, } = useApi.useApi();
22
23
  const props = jsx.useProps();
23
- const { path, summary, description, deprecated, method, private: privateMode } = props;
24
+ const { deprecated, description, method, path, private: privateMode, summary, } = props;
24
25
  const children = jsx.useChildren();
25
26
  const { paths } = docs;
26
27
  if (!paths)
@@ -50,12 +51,14 @@ const endpoint = () => {
50
51
  paths[path][method] = operation;
51
52
  }
52
53
  if (!endpoints[method]) {
53
- endpoints[method] = { key: '' };
54
+ endpoints[method] = { key: '', plugins: new Set() };
54
55
  }
55
56
  // @ts-expect-error: it's always an object
56
57
  const endpoint = getEndpoint.getEndpoint(path, endpoints[method]);
57
58
  // @ts-expect-error: it's always an object
58
- useEndpoint.endpointContext.set(handler, { operation, props, endpoint });
59
+ useEndpoint.endpointContext.set(handler, { endpoint, operation, props });
60
+ // @ts-expect-error: it's always an object
61
+ useServerPlugins.serverPlugins.set(handler, endpoint.plugins);
59
62
  innet__default["default"](children, handler);
60
63
  };
61
64
 
@@ -1,5 +1,10 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  export interface HostProps {
3
+ /**
4
+ * An optional string describing the host designated by the URL.
5
+ * [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
6
+ * */
7
+ description?: string;
3
8
  /**
4
9
  * A URL to the target host.
5
10
  * This URL supports Server Variables and MAY be relative,
@@ -7,10 +12,5 @@ export interface HostProps {
7
12
  * Variable substitutions will be made when a variable is named in {brackets}.
8
13
  * */
9
14
  url: string;
10
- /**
11
- * An optional string describing the host designated by the URL.
12
- * [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
13
- * */
14
- description?: string;
15
15
  }
16
16
  export declare const host: HandlerPlugin;
@@ -7,7 +7,7 @@ export * from './variable';
7
7
  export * from './tag';
8
8
  export * from './endpoint';
9
9
  export * from './response';
10
- export * from './request';
10
+ export * from './return';
11
11
  export * from './param';
12
12
  export * from './body';
13
- export * from './fallback';
13
+ export * from './preset';
@@ -7,7 +7,7 @@ import './variable/index.es6.js';
7
7
  import './tag/index.es6.js';
8
8
  import './endpoint/index.es6.js';
9
9
  import './response/index.es6.js';
10
- import './request/index.es6.js';
10
+ import './return/index.es6.js';
11
11
  import './param/index.es6.js';
12
12
  import './body/index.es6.js';
13
- import './fallback/index.es6.js';
13
+ import './preset/index.es6.js';
@@ -9,8 +9,8 @@ require('./variable/index.js');
9
9
  require('./tag/index.js');
10
10
  require('./endpoint/index.js');
11
11
  require('./response/index.js');
12
- require('./request/index.js');
12
+ require('./return/index.js');
13
13
  require('./param/index.js');
14
14
  require('./body/index.js');
15
- require('./fallback/index.js');
15
+ require('./preset/index.js');
16
16
 
@@ -1,16 +1,16 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  export interface LicenseProps {
3
- /**
4
- * The license name used for the API.
5
- * @example: Apache 2.0
6
- * */
7
- name: string;
8
3
  /**
9
4
  * An [SPDX](https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60) license expression for the API.
10
5
  * The `identifier` field is mutually exclusive of the `url` field.
11
6
  * @example: Apache-2.0
12
7
  * */
13
8
  identifier?: string;
9
+ /**
10
+ * The license name used for the API.
11
+ * @example: Apache 2.0
12
+ * */
13
+ name: string;
14
14
  /**
15
15
  * A URL to the license used for the API.
16
16
  * This MUST be in the form of a URL.
@@ -1,6 +1,17 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type InParam } from '../../../types';
3
3
  export interface ParamProps {
4
+ /**
5
+ * Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
6
+ * Default value is `false`.
7
+ * */
8
+ deprecated?: boolean;
9
+ /**
10
+ * A brief description of the parameter.
11
+ * This could contain examples of use.
12
+ * [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
13
+ * */
14
+ description?: string;
4
15
  /**
5
16
  * The location of the parameter.
6
17
  * Possible values are "query", "header", "path" or "cookie".
@@ -14,22 +25,11 @@ export interface ParamProps {
14
25
  * - For all other cases, the `name` corresponds to the parameter name used by the `in` property.
15
26
  * */
16
27
  name: string;
17
- /**
18
- * A brief description of the parameter.
19
- * This could contain examples of use.
20
- * [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
21
- * */
22
- description?: string;
23
28
  /**
24
29
  * Determines whether this parameter is mandatory.
25
30
  * If the parameter location is "path", this property is `true` and its value MUST be `true`.
26
31
  * Otherwise, the property MAY be included and its default value is `false`.
27
32
  * */
28
33
  required?: boolean;
29
- /**
30
- * Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
31
- * Default value is `false`.
32
- * */
33
- deprecated?: boolean;
34
34
  }
35
35
  export declare const param: HandlerPlugin;
@@ -13,14 +13,14 @@ import { required } from '../../../utils/rules/required/required.es6.js';
13
13
  import { oneOf } from '../../../utils/rules/oneOf/oneOf.es6.js';
14
14
 
15
15
  const inMap = {
16
- query: 'search',
17
- path: 'path',
18
16
  cookie: 'cookie',
19
17
  header: 'header',
18
+ path: 'path',
19
+ query: 'search',
20
20
  };
21
21
  const param = () => {
22
22
  var _a;
23
- const { operation, endpoint } = useEndpoint();
23
+ const { endpoint, operation, } = useEndpoint();
24
24
  if (!operation.parameters) {
25
25
  operation.parameters = [];
26
26
  }