@innet/server 2.0.0-beta.6 → 2.0.0-beta.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 (286) hide show
  1. package/README.md +28 -0
  2. package/hooks/useNewSchema/useNewSchema.es6.js +0 -1
  3. package/hooks/useNewSchema/useNewSchema.js +0 -1
  4. package/index.es6.js +2 -1
  5. package/index.js +3 -0
  6. package/package.json +2 -3
  7. package/plugins/main/endpoint/endpoint.es6.js +0 -2
  8. package/plugins/main/endpoint/endpoint.js +0 -2
  9. package/plugins/main/host/host.es6.js +0 -1
  10. package/plugins/main/host/host.js +0 -1
  11. package/plugins/main/tag/index.es6.js +1 -1
  12. package/plugins/main/tag/index.js +1 -0
  13. package/plugins/main/tag/tag.es6.js +18 -2
  14. package/plugins/main/tag/tag.js +18 -1
  15. package/plugins/main/variable/variable.es6.js +1 -4
  16. package/plugins/main/variable/variable.js +1 -4
  17. package/plugins/request/redirect/redirect.es6.js +0 -1
  18. package/plugins/request/redirect/redirect.js +0 -1
  19. package/plugins/schema/date/date.es6.js +0 -6
  20. package/plugins/schema/date/date.js +0 -6
  21. package/plugins/schema/field/field.es6.js +2 -1
  22. package/plugins/schema/field/field.js +2 -1
  23. package/plugins/schema/object/object.es6.js +4 -2
  24. package/plugins/schema/object/object.js +4 -2
  25. package/plugins/schema/tuple/tuple.es6.js +0 -1
  26. package/plugins/schema/tuple/tuple.js +0 -1
  27. package/plugins/schema/uuid/uuid.es6.js +0 -2
  28. package/plugins/schema/uuid/uuid.js +0 -2
  29. package/plugins/utils/swagger/swagger.es6.js +0 -1
  30. package/plugins/utils/swagger/swagger.js +0 -1
  31. package/utils/decorators/once/once.es6.js +0 -4
  32. package/utils/decorators/once/once.js +0 -4
  33. package/utils/generateTypes/generateTypes.es6.js +0 -1
  34. package/utils/generateTypes/generateTypes.js +0 -1
  35. package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
  36. package/utils/getSafeSchema/getSafeSchema.js +9 -0
  37. package/utils/getSafeSchema/index.es6.js +1 -0
  38. package/utils/getSafeSchema/index.js +9 -0
  39. package/utils/index.es6.js +1 -0
  40. package/utils/index.js +1 -0
  41. package/constants.d.ts +0 -4
  42. package/handler/handler.d.ts +0 -106
  43. package/handler/index.d.ts +0 -1
  44. package/hooks/index.d.ts +0 -33
  45. package/hooks/useAction/index.d.ts +0 -1
  46. package/hooks/useAction/useAction.d.ts +0 -4
  47. package/hooks/useApi/index.d.ts +0 -1
  48. package/hooks/useApi/useApi.d.ts +0 -11
  49. package/hooks/useBlock/index.d.ts +0 -1
  50. package/hooks/useBlock/useBlock.d.ts +0 -2
  51. package/hooks/useBody/index.d.ts +0 -1
  52. package/hooks/useBody/useBody.d.ts +0 -1
  53. package/hooks/useBodyFile/index.d.ts +0 -1
  54. package/hooks/useBodyFile/useBodyFile.d.ts +0 -3
  55. package/hooks/useClientIp/index.d.ts +0 -1
  56. package/hooks/useClientIp/useClientIp.d.ts +0 -1
  57. package/hooks/useComponentName/index.d.ts +0 -1
  58. package/hooks/useComponentName/useComponentName.d.ts +0 -1
  59. package/hooks/useCookies/index.d.ts +0 -1
  60. package/hooks/useCookies/useCookies.d.ts +0 -1
  61. package/hooks/useEffect/index.d.ts +0 -1
  62. package/hooks/useEffect/useEffect.d.ts +0 -2
  63. package/hooks/useEndpoint/index.d.ts +0 -1
  64. package/hooks/useEndpoint/useEndpoint.d.ts +0 -10
  65. package/hooks/useHeaders/index.d.ts +0 -1
  66. package/hooks/useHeaders/useHeaders.d.ts +0 -2
  67. package/hooks/useHost/index.d.ts +0 -1
  68. package/hooks/useHost/useHost.d.ts +0 -7
  69. package/hooks/useIsServerHttps/index.d.ts +0 -1
  70. package/hooks/useIsServerHttps/useIsServerHttps.d.ts +0 -3
  71. package/hooks/useNewSchema/index.d.ts +0 -1
  72. package/hooks/useNewSchema/useNewSchema.d.ts +0 -2
  73. package/hooks/useObjectRule/index.d.ts +0 -1
  74. package/hooks/useObjectRule/useObjectRule.d.ts +0 -4
  75. package/hooks/useObjectSchemaContext/index.d.ts +0 -1
  76. package/hooks/useObjectSchemaContext/useObjectSchemaContext.d.ts +0 -3
  77. package/hooks/useOneElementError/index.d.ts +0 -1
  78. package/hooks/useOneElementError/useOneElementError.d.ts +0 -1
  79. package/hooks/useParam/index.d.ts +0 -1
  80. package/hooks/useParam/useParam.d.ts +0 -7
  81. package/hooks/useParams/index.d.ts +0 -1
  82. package/hooks/useParams/useParams.d.ts +0 -3
  83. package/hooks/useParentRule/index.d.ts +0 -1
  84. package/hooks/useParentRule/useParentRule.d.ts +0 -4
  85. package/hooks/usePath/index.d.ts +0 -1
  86. package/hooks/usePath/usePath.d.ts +0 -1
  87. package/hooks/useRequest/index.d.ts +0 -1
  88. package/hooks/useRequest/useRequest.d.ts +0 -1
  89. package/hooks/useRequestHandler/index.d.ts +0 -1
  90. package/hooks/useRequestHandler/useRequestHandler.d.ts +0 -4
  91. package/hooks/useResponse/index.d.ts +0 -1
  92. package/hooks/useResponse/useResponse.d.ts +0 -1
  93. package/hooks/useRule/index.d.ts +0 -1
  94. package/hooks/useRule/useRule.d.ts +0 -6
  95. package/hooks/useSchemaContext/index.d.ts +0 -1
  96. package/hooks/useSchemaContext/useSchemaContext.d.ts +0 -5
  97. package/hooks/useSchemaType/index.d.ts +0 -1
  98. package/hooks/useSchemaType/useSchemaType.d.ts +0 -5
  99. package/hooks/useSearch/index.d.ts +0 -1
  100. package/hooks/useSearch/useSearch.d.ts +0 -1
  101. package/hooks/useServer/index.d.ts +0 -1
  102. package/hooks/useServer/useServer.d.ts +0 -10
  103. package/hooks/useServerPlugin/index.d.ts +0 -1
  104. package/hooks/useServerPlugin/useServerPlugin.d.ts +0 -2
  105. package/hooks/useServerPlugins/index.d.ts +0 -1
  106. package/hooks/useServerPlugins/useServerPlugins.d.ts +0 -4
  107. package/hooks/useServerPort/index.d.ts +0 -1
  108. package/hooks/useServerPort/useServerPort.d.ts +0 -3
  109. package/hooks/useTag/index.d.ts +0 -1
  110. package/hooks/useTag/useTag.d.ts +0 -3
  111. package/hooks/useThrow/index.d.ts +0 -1
  112. package/hooks/useThrow/useThrow.d.ts +0 -1
  113. package/index.d.ts +0 -6
  114. package/plugins/handler/index.d.ts +0 -1
  115. package/plugins/handler/serverFn/index.d.ts +0 -1
  116. package/plugins/handler/serverFn/serverFn.d.ts +0 -2
  117. package/plugins/index.d.ts +0 -5
  118. package/plugins/main/api/api.d.ts +0 -25
  119. package/plugins/main/api/index.d.ts +0 -1
  120. package/plugins/main/body/body.d.ts +0 -5
  121. package/plugins/main/body/index.d.ts +0 -1
  122. package/plugins/main/contact/contact.d.ts +0 -10
  123. package/plugins/main/contact/index.d.ts +0 -1
  124. package/plugins/main/endpoint/endpoint.d.ts +0 -43
  125. package/plugins/main/endpoint/index.d.ts +0 -1
  126. package/plugins/main/host/host.d.ts +0 -16
  127. package/plugins/main/host/index.d.ts +0 -1
  128. package/plugins/main/index.d.ts +0 -13
  129. package/plugins/main/license/index.d.ts +0 -1
  130. package/plugins/main/license/license.d.ts +0 -21
  131. package/plugins/main/param/index.d.ts +0 -1
  132. package/plugins/main/param/param.d.ts +0 -36
  133. package/plugins/main/preset/index.d.ts +0 -1
  134. package/plugins/main/preset/preset.d.ts +0 -3
  135. package/plugins/main/response/index.d.ts +0 -1
  136. package/plugins/main/response/response.d.ts +0 -21
  137. package/plugins/main/return/index.d.ts +0 -1
  138. package/plugins/main/return/return.d.ts +0 -4
  139. package/plugins/main/server/index.d.ts +0 -1
  140. package/plugins/main/server/server.d.ts +0 -13
  141. package/plugins/main/tag/index.d.ts +0 -1
  142. package/plugins/main/tag/tag.d.ts +0 -12
  143. package/plugins/main/variable/index.d.ts +0 -1
  144. package/plugins/main/variable/variable.d.ts +0 -24
  145. package/plugins/request/cms/cms.d.ts +0 -6
  146. package/plugins/request/cms/index.d.ts +0 -1
  147. package/plugins/request/cookie/cookie.d.ts +0 -7
  148. package/plugins/request/cookie/index.d.ts +0 -1
  149. package/plugins/request/error/error.d.ts +0 -61
  150. package/plugins/request/error/index.d.ts +0 -1
  151. package/plugins/request/file/file.d.ts +0 -5
  152. package/plugins/request/file/index.d.ts +0 -1
  153. package/plugins/request/header/header.d.ts +0 -6
  154. package/plugins/request/header/index.d.ts +0 -1
  155. package/plugins/request/index.d.ts +0 -8
  156. package/plugins/request/proxy/index.d.ts +0 -1
  157. package/plugins/request/proxy/proxy.d.ts +0 -8
  158. package/plugins/request/redirect/index.d.ts +0 -1
  159. package/plugins/request/redirect/redirect.d.ts +0 -18
  160. package/plugins/request/success/index.d.ts +0 -1
  161. package/plugins/request/success/success.d.ts +0 -19
  162. package/plugins/schema/any/any.d.ts +0 -5
  163. package/plugins/schema/any/index.d.ts +0 -1
  164. package/plugins/schema/array/array.d.ts +0 -9
  165. package/plugins/schema/array/index.d.ts +0 -1
  166. package/plugins/schema/binary/binary.d.ts +0 -9
  167. package/plugins/schema/binary/index.d.ts +0 -1
  168. package/plugins/schema/boolean/boolean.d.ts +0 -5
  169. package/plugins/schema/boolean/index.d.ts +0 -1
  170. package/plugins/schema/date/date.d.ts +0 -8
  171. package/plugins/schema/date/index.d.ts +0 -1
  172. package/plugins/schema/field/field.d.ts +0 -10
  173. package/plugins/schema/field/index.d.ts +0 -1
  174. package/plugins/schema/index.d.ts +0 -13
  175. package/plugins/schema/integer/index.d.ts +0 -1
  176. package/plugins/schema/integer/integer.d.ts +0 -45
  177. package/plugins/schema/null/index.d.ts +0 -1
  178. package/plugins/schema/null/null.d.ts +0 -5
  179. package/plugins/schema/number/index.d.ts +0 -1
  180. package/plugins/schema/number/number.d.ts +0 -41
  181. package/plugins/schema/object/index.d.ts +0 -1
  182. package/plugins/schema/object/object.d.ts +0 -6
  183. package/plugins/schema/string/index.d.ts +0 -1
  184. package/plugins/schema/string/string.d.ts +0 -36
  185. package/plugins/schema/tuple/index.d.ts +0 -1
  186. package/plugins/schema/tuple/tuple.d.ts +0 -6
  187. package/plugins/schema/uuid/index.d.ts +0 -1
  188. package/plugins/schema/uuid/uuid.d.ts +0 -6
  189. package/plugins/utils/blacklist/blacklist.d.ts +0 -5
  190. package/plugins/utils/blacklist/index.d.ts +0 -1
  191. package/plugins/utils/dts/dts.d.ts +0 -6
  192. package/plugins/utils/dts/index.d.ts +0 -1
  193. package/plugins/utils/env/env.d.ts +0 -7
  194. package/plugins/utils/env/index.d.ts +0 -1
  195. package/plugins/utils/index.d.ts +0 -7
  196. package/plugins/utils/protection/index.d.ts +0 -1
  197. package/plugins/utils/protection/protection.d.ts +0 -9
  198. package/plugins/utils/swagger/index.d.ts +0 -1
  199. package/plugins/utils/swagger/swagger.d.ts +0 -6
  200. package/plugins/utils/ui/index.d.ts +0 -1
  201. package/plugins/utils/ui/ui.d.ts +0 -13
  202. package/plugins/utils/whitelist/index.d.ts +0 -1
  203. package/plugins/utils/whitelist/whitelist.d.ts +0 -5
  204. package/types.d.ts +0 -69
  205. package/utils/FileData/Bin.d.ts +0 -47
  206. package/utils/FileData/index.d.ts +0 -1
  207. package/utils/JSONString/JSONString.d.ts +0 -1
  208. package/utils/JSONString/index.d.ts +0 -1
  209. package/utils/action/Action.d.ts +0 -31
  210. package/utils/action/index.d.ts +0 -1
  211. package/utils/dateFormat/dateFormat.d.ts +0 -2
  212. package/utils/dateFormat/index.d.ts +0 -1
  213. package/utils/decorators/index.d.ts +0 -1
  214. package/utils/decorators/once/index.d.ts +0 -1
  215. package/utils/decorators/once/once.d.ts +0 -4
  216. package/utils/generateTypes/generateTypes.d.ts +0 -3
  217. package/utils/generateTypes/index.d.ts +0 -1
  218. package/utils/getEndpoint/getEndpoint.d.ts +0 -2
  219. package/utils/getEndpoint/index.d.ts +0 -1
  220. package/utils/getOrAdd/getOrAdd.d.ts +0 -1
  221. package/utils/getOrAdd/index.d.ts +0 -1
  222. package/utils/httpOnStart/httpOnStart.d.ts +0 -2
  223. package/utils/httpOnStart/index.d.ts +0 -1
  224. package/utils/index.d.ts +0 -13
  225. package/utils/parseBody/index.d.ts +0 -1
  226. package/utils/parseBody/parseBody.d.ts +0 -2
  227. package/utils/parseFormBody/index.d.ts +0 -1
  228. package/utils/parseFormBody/parseFormBody.d.ts +0 -2
  229. package/utils/parseSearch/index.d.ts +0 -1
  230. package/utils/parseSearch/parseSearch.d.ts +0 -3
  231. package/utils/rules/arrayOf/arrayOf.d.ts +0 -2
  232. package/utils/rules/arrayOf/index.d.ts +0 -1
  233. package/utils/rules/bin/bin.d.ts +0 -2
  234. package/utils/rules/bin/index.d.ts +0 -1
  235. package/utils/rules/binaryAccept/binaryAccept.d.ts +0 -2
  236. package/utils/rules/binaryAccept/index.d.ts +0 -1
  237. package/utils/rules/constants.d.ts +0 -1
  238. package/utils/rules/dateTo/dateTo.d.ts +0 -2
  239. package/utils/rules/dateTo/index.d.ts +0 -1
  240. package/utils/rules/defaultTo/defaultTo.d.ts +0 -1
  241. package/utils/rules/defaultTo/index.d.ts +0 -1
  242. package/utils/rules/helpers.d.ts +0 -8
  243. package/utils/rules/index.d.ts +0 -28
  244. package/utils/rules/int/index.d.ts +0 -1
  245. package/utils/rules/int/int.d.ts +0 -2
  246. package/utils/rules/max/index.d.ts +0 -1
  247. package/utils/rules/max/max.d.ts +0 -1
  248. package/utils/rules/maxBin/index.d.ts +0 -1
  249. package/utils/rules/maxBin/maxBin.d.ts +0 -2
  250. package/utils/rules/maxDate/index.d.ts +0 -1
  251. package/utils/rules/maxDate/maxDate.d.ts +0 -1
  252. package/utils/rules/maxLength/index.d.ts +0 -1
  253. package/utils/rules/maxLength/maxLength.d.ts +0 -1
  254. package/utils/rules/min/index.d.ts +0 -1
  255. package/utils/rules/min/min.d.ts +0 -1
  256. package/utils/rules/minBin/index.d.ts +0 -1
  257. package/utils/rules/minBin/minBin.d.ts +0 -2
  258. package/utils/rules/minDate/index.d.ts +0 -1
  259. package/utils/rules/minDate/minDate.d.ts +0 -1
  260. package/utils/rules/minLength/index.d.ts +0 -1
  261. package/utils/rules/minLength/minLength.d.ts +0 -1
  262. package/utils/rules/nullable/index.d.ts +0 -1
  263. package/utils/rules/nullable/nullable.d.ts +0 -1
  264. package/utils/rules/num/index.d.ts +0 -1
  265. package/utils/rules/num/num.d.ts +0 -1
  266. package/utils/rules/objectOf/index.d.ts +0 -1
  267. package/utils/rules/objectOf/objectOf.d.ts +0 -3
  268. package/utils/rules/oneOf/index.d.ts +0 -1
  269. package/utils/rules/oneOf/oneOf.d.ts +0 -2
  270. package/utils/rules/optional/index.d.ts +0 -1
  271. package/utils/rules/optional/optional.d.ts +0 -2
  272. package/utils/rules/pattern/index.d.ts +0 -1
  273. package/utils/rules/pattern/pattern.d.ts +0 -1
  274. package/utils/rules/pipe/index.d.ts +0 -1
  275. package/utils/rules/pipe/pipe.d.ts +0 -2
  276. package/utils/rules/required/index.d.ts +0 -1
  277. package/utils/rules/required/required.d.ts +0 -2
  278. package/utils/rules/tupleOf/index.d.ts +0 -1
  279. package/utils/rules/tupleOf/tupleOf.d.ts +0 -2
  280. package/utils/rules/types.d.ts +0 -4
  281. package/utils/rules/uuidTo/index.d.ts +0 -1
  282. package/utils/rules/uuidTo/uuidTo.d.ts +0 -1
  283. package/utils/rules/values/index.d.ts +0 -1
  284. package/utils/rules/values/values.d.ts +0 -1
  285. package/utils/stringifySearch/index.d.ts +0 -1
  286. package/utils/stringifySearch/stringifySearch.d.ts +0 -2
package/README.md CHANGED
@@ -1556,6 +1556,34 @@ export default (
1556
1556
  )
1557
1557
  ```
1558
1558
 
1559
+ #### group
1560
+
1561
+ You can organize tags into groups using the `group` property.
1562
+ This adds tag groups support to the OpenAPI specification,
1563
+ which is displayed in documentation viewers.
1564
+
1565
+ *src/app.tsx*
1566
+ ```typescript jsx
1567
+ export default (
1568
+ <server>
1569
+ <api>
1570
+ <tag group='Authentication' name='auth'>
1571
+ <endpoint method='post' path='/login' />
1572
+ <endpoint method='post' path='/logout' />
1573
+ </tag>
1574
+ <tag group='Users' name='users'>
1575
+ <endpoint method='get' path='/users' />
1576
+ <endpoint method='post' path='/users' />
1577
+ </tag>
1578
+ </api>
1579
+ </server>
1580
+ )
1581
+ ```
1582
+
1583
+ This will create tag groups in your OpenAPI documentation:
1584
+ - **Authentication** group containing the `auth` tag
1585
+ - **Users** group containing the `users` tag
1586
+
1559
1587
  ### \<param>
1560
1588
 
1561
1589
  [← back](#endpoints)
@@ -17,7 +17,6 @@ function useNewSchema(schema = Object.create(null)) {
17
17
  else if (parentSchema.type || '$ref' in parentSchema) {
18
18
  const oldSchema = { ...parentSchema };
19
19
  for (const key in parentSchema) {
20
- // @ts-expect-error: FIXME
21
20
  delete parentSchema[key];
22
21
  }
23
22
  parentSchema.oneOf = [oldSchema, schema];
@@ -21,7 +21,6 @@ function useNewSchema(schema = Object.create(null)) {
21
21
  else if (parentSchema.type || '$ref' in parentSchema) {
22
22
  const oldSchema = { ...parentSchema };
23
23
  for (const key in parentSchema) {
24
- // @ts-expect-error: FIXME
25
24
  delete parentSchema[key];
26
25
  }
27
26
  parentSchema.oneOf = [oldSchema, schema];
package/index.es6.js CHANGED
@@ -49,7 +49,7 @@ export { preset } from './plugins/main/preset/preset.es6.js';
49
49
  export { response, statuses } from './plugins/main/response/response.es6.js';
50
50
  export { returnPlugin } from './plugins/main/return/return.es6.js';
51
51
  export { server } from './plugins/main/server/server.es6.js';
52
- export { tag } from './plugins/main/tag/tag.es6.js';
52
+ export { TAG_GROUP_NAME, tag } from './plugins/main/tag/tag.es6.js';
53
53
  export { variable } from './plugins/main/variable/variable.es6.js';
54
54
  export { cms } from './plugins/request/cms/cms.es6.js';
55
55
  export { cookie } from './plugins/request/cookie/cookie.es6.js';
@@ -86,6 +86,7 @@ export { once } from './utils/decorators/once/once.es6.js';
86
86
  export { generateSchemaTypes, generateTypes } from './utils/generateTypes/generateTypes.es6.js';
87
87
  export { getEndpoint } from './utils/getEndpoint/getEndpoint.es6.js';
88
88
  export { getOrAdd } from './utils/getOrAdd/getOrAdd.es6.js';
89
+ export { getSafeSchema } from './utils/getSafeSchema/getSafeSchema.es6.js';
89
90
  export { httpOnStart } from './utils/httpOnStart/httpOnStart.es6.js';
90
91
  export { parseBody } from './utils/parseBody/parseBody.es6.js';
91
92
  export { parseFormBody } from './utils/parseFormBody/parseFormBody.es6.js';
package/index.js CHANGED
@@ -90,6 +90,7 @@ var once = require('./utils/decorators/once/once.js');
90
90
  var generateTypes = require('./utils/generateTypes/generateTypes.js');
91
91
  var getEndpoint = require('./utils/getEndpoint/getEndpoint.js');
92
92
  var getOrAdd = require('./utils/getOrAdd/getOrAdd.js');
93
+ var getSafeSchema = require('./utils/getSafeSchema/getSafeSchema.js');
93
94
  var httpOnStart = require('./utils/httpOnStart/httpOnStart.js');
94
95
  var parseBody = require('./utils/parseBody/parseBody.js');
95
96
  var parseFormBody = require('./utils/parseFormBody/parseFormBody.js');
@@ -196,6 +197,7 @@ exports.response = response.response;
196
197
  exports.statuses = response.statuses;
197
198
  exports.returnPlugin = _return.returnPlugin;
198
199
  exports.server = server.server;
200
+ exports.TAG_GROUP_NAME = tag.TAG_GROUP_NAME;
199
201
  exports.tag = tag.tag;
200
202
  exports.variable = variable.variable;
201
203
  exports.cms = cms.cms;
@@ -239,6 +241,7 @@ exports.generateSchemaTypes = generateTypes.generateSchemaTypes;
239
241
  exports.generateTypes = generateTypes.generateTypes;
240
242
  exports.getEndpoint = getEndpoint.getEndpoint;
241
243
  exports.getOrAdd = getOrAdd.getOrAdd;
244
+ exports.getSafeSchema = getSafeSchema.getSafeSchema;
242
245
  exports.httpOnStart = httpOnStart.httpOnStart;
243
246
  exports.parseBody = parseBody.parseBody;
244
247
  exports.parseFormBody = parseFormBody.parseFormBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innet/server",
3
- "version": "2.0.0-beta.6",
3
+ "version": "2.0.0-beta.8",
4
4
  "description": "Create server-side application with innet",
5
5
  "main": "index.js",
6
6
  "module": "index.es6.js",
@@ -53,7 +53,6 @@
53
53
  "string_decoder": "^1.3.0",
54
54
  "tslib": "^2.8.1",
55
55
  "uuid": "^13.0.0",
56
- "watch-state": "^3.6.2",
57
- "youch": "^4.1.0"
56
+ "watch-state": "^3.6.2"
58
57
  }
59
58
  }
@@ -46,9 +46,7 @@ const endpoint = () => {
46
46
  endpoints[method] = { key: '', plugins: new Set() };
47
47
  }
48
48
  const endpoint = getEndpoint(path, endpoints[method]);
49
- // @ts-expect-error: it's always an object
50
49
  endpointContext.set(handler, { endpoint, operation, props });
51
- // @ts-expect-error: it's always an object
52
50
  serverPlugins.set(handler, endpoint.plugins);
53
51
  innet(children, handler);
54
52
  };
@@ -50,9 +50,7 @@ const endpoint = () => {
50
50
  endpoints[method] = { key: '', plugins: new Set() };
51
51
  }
52
52
  const endpoint = getEndpoint.getEndpoint(path, endpoints[method]);
53
- // @ts-expect-error: it's always an object
54
53
  useEndpoint.endpointContext.set(handler, { endpoint, operation, props });
55
- // @ts-expect-error: it's always an object
56
54
  useServerPlugins.serverPlugins.set(handler, endpoint.plugins);
57
55
  innet.innet(children, handler);
58
56
  };
@@ -19,7 +19,6 @@ const host = () => {
19
19
  const server = {
20
20
  ...props,
21
21
  };
22
- // @ts-expect-error: FIXME
23
22
  servers.push(server);
24
23
  handler[hostContext.key] = { server };
25
24
  innet(children, handler);
@@ -23,7 +23,6 @@ const host = () => {
23
23
  const server = {
24
24
  ...props,
25
25
  };
26
- // @ts-expect-error: FIXME
27
26
  servers.push(server);
28
27
  handler[useHost.hostContext.key] = { server };
29
28
  innet.innet(children, handler);
@@ -1 +1 @@
1
- export { tag } from './tag.es6.js';
1
+ export { TAG_GROUP_NAME, tag } from './tag.es6.js';
@@ -6,4 +6,5 @@ var tag = require('./tag.js');
6
6
 
7
7
 
8
8
 
9
+ exports.TAG_GROUP_NAME = tag.TAG_GROUP_NAME;
9
10
  exports.tag = tag.tag;
@@ -4,11 +4,12 @@ import '../../../hooks/index.es6.js';
4
4
  import { tagContext } from '../../../hooks/useTag/useTag.es6.js';
5
5
  import { useApi } from '../../../hooks/useApi/useApi.es6.js';
6
6
 
7
+ const TAG_GROUP_NAME = 'x-tagGroups';
7
8
  const tag = () => {
8
9
  if (useContext(tagContext)) {
9
10
  throw Error('You cannot use a <tag> inside another one');
10
11
  }
11
- const { children, description, name, } = useProps();
12
+ const { children, description, group, name, } = useProps();
12
13
  const { docs } = useApi();
13
14
  const tag = { name };
14
15
  if (description) {
@@ -23,9 +24,24 @@ const tag = () => {
23
24
  else {
24
25
  throw Error(`You cannot use two tags with the same name (${name})`);
25
26
  }
27
+ if (group) {
28
+ if (docs[TAG_GROUP_NAME]) {
29
+ const groups = docs[TAG_GROUP_NAME];
30
+ const tagGroup = groups.find(({ name }) => name === group);
31
+ if (tagGroup) {
32
+ tagGroup.tags.push(name);
33
+ }
34
+ else {
35
+ groups.push({ name: group, tags: [name] });
36
+ }
37
+ }
38
+ else {
39
+ docs[TAG_GROUP_NAME] = [{ name: group, tags: [name] }];
40
+ }
41
+ }
26
42
  const handler = useNewHandler();
27
43
  handler[tagContext.key] = tag;
28
44
  innet(children, handler);
29
45
  };
30
46
 
31
- export { tag };
47
+ export { TAG_GROUP_NAME, tag };
@@ -8,11 +8,12 @@ require('../../../hooks/index.js');
8
8
  var useTag = require('../../../hooks/useTag/useTag.js');
9
9
  var useApi = require('../../../hooks/useApi/useApi.js');
10
10
 
11
+ const TAG_GROUP_NAME = 'x-tagGroups';
11
12
  const tag = () => {
12
13
  if (jsx.useContext(useTag.tagContext)) {
13
14
  throw Error('You cannot use a <tag> inside another one');
14
15
  }
15
- const { children, description, name, } = jsx.useProps();
16
+ const { children, description, group, name, } = jsx.useProps();
16
17
  const { docs } = useApi.useApi();
17
18
  const tag = { name };
18
19
  if (description) {
@@ -27,9 +28,25 @@ const tag = () => {
27
28
  else {
28
29
  throw Error(`You cannot use two tags with the same name (${name})`);
29
30
  }
31
+ if (group) {
32
+ if (docs[TAG_GROUP_NAME]) {
33
+ const groups = docs[TAG_GROUP_NAME];
34
+ const tagGroup = groups.find(({ name }) => name === group);
35
+ if (tagGroup) {
36
+ tagGroup.tags.push(name);
37
+ }
38
+ else {
39
+ groups.push({ name: group, tags: [name] });
40
+ }
41
+ }
42
+ else {
43
+ docs[TAG_GROUP_NAME] = [{ name: group, tags: [name] }];
44
+ }
45
+ }
30
46
  const handler = innet.useNewHandler();
31
47
  handler[useTag.tagContext.key] = tag;
32
48
  innet.innet(children, handler);
33
49
  };
34
50
 
51
+ exports.TAG_GROUP_NAME = TAG_GROUP_NAME;
35
52
  exports.tag = tag;
@@ -4,13 +4,10 @@ import { useHost } from '../../../hooks/useHost/useHost.es6.js';
4
4
 
5
5
  const variable = () => {
6
6
  const { server } = useHost();
7
- const { key, values,
8
- // predefine
9
- value = values === null || values === void 0 ? void 0 : values[0], ...rest } = useProps();
7
+ const { key, values, value = values === null || values === void 0 ? void 0 : values[0], ...rest } = useProps();
10
8
  if (!server.variables) {
11
9
  server.variables = {};
12
10
  }
13
- // @ts-expect-error: FIXME
14
11
  server.variables[key] = { ...rest, default: value, enum: values };
15
12
  };
16
13
 
@@ -8,13 +8,10 @@ var useHost = require('../../../hooks/useHost/useHost.js');
8
8
 
9
9
  const variable = () => {
10
10
  const { server } = useHost.useHost();
11
- const { key, values,
12
- // predefine
13
- value = values === null || values === void 0 ? void 0 : values[0], ...rest } = jsx.useProps();
11
+ const { key, values, value = values === null || values === void 0 ? void 0 : values[0], ...rest } = jsx.useProps();
14
12
  if (!server.variables) {
15
13
  server.variables = {};
16
14
  }
17
- // @ts-expect-error: FIXME
18
15
  server.variables[key] = { ...rest, default: value, enum: values };
19
16
  };
20
17
 
@@ -16,7 +16,6 @@ const redirectStatuses = {
16
16
  function getStatus(status) {
17
17
  if (typeof status === 'number')
18
18
  return status;
19
- // @ts-expect-error: FIXME
20
19
  return redirectStatuses[status] || 301;
21
20
  }
22
21
  function customEncode(url) {
@@ -20,7 +20,6 @@ const redirectStatuses = {
20
20
  function getStatus(status) {
21
21
  if (typeof status === 'number')
22
22
  return status;
23
- // @ts-expect-error: FIXME
24
23
  return redirectStatuses[status] || 301;
25
24
  }
26
25
  function customEncode(url) {
@@ -21,14 +21,12 @@ const date = () => {
21
21
  const normDefault = dateFormat(defaultValue);
22
22
  const normExample = dateFormat(example);
23
23
  const normValues = values$1 === null || values$1 === void 0 ? void 0 : values$1.map(dateFormat);
24
- // @ts-expect-error: FIXME
25
24
  const stringValues = normValues === null || normValues === void 0 ? void 0 : normValues.map(value => value.toISOString());
26
25
  const normExamples = examples === null || examples === void 0 ? void 0 : examples.map(dateFormat);
27
26
  const schema = useSchemaType('string', {
28
27
  ...props,
29
28
  default: defaultValue === 'now' ? undefined : normDefault === null || normDefault === void 0 ? void 0 : normDefault.toISOString(),
30
29
  example: normExample === null || normExample === void 0 ? void 0 : normExample.toISOString(),
31
- // @ts-expect-error: FIXME
32
30
  examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
33
31
  values: stringValues,
34
32
  });
@@ -40,20 +38,16 @@ const date = () => {
40
38
  if (stringValues) {
41
39
  rules.push((value, data) => values(stringValues)(value.toISOString(), data));
42
40
  }
43
- // @ts-expect-error: FIXME
44
41
  schema.format = 'date-time';
45
42
  if (normMin) {
46
- // @ts-expect-error: FIXME
47
43
  schema['x-minimum'] = normMin.toISOString();
48
44
  rules.push(minDate(normMin));
49
45
  }
50
46
  if (normMax) {
51
- // @ts-expect-error: FIXME
52
47
  schema['x-maximum'] = normMax.toISOString();
53
48
  rules.push(maxDate(normMax));
54
49
  }
55
50
  if (defaultValue === 'now') {
56
- // @ts-expect-error: FIXME
57
51
  schema['x-default'] = 'now';
58
52
  }
59
53
  if (defaultValue === undefined) {
@@ -25,14 +25,12 @@ const date = () => {
25
25
  const normDefault = dateFormat.dateFormat(defaultValue);
26
26
  const normExample = dateFormat.dateFormat(example);
27
27
  const normValues = values$1 === null || values$1 === void 0 ? void 0 : values$1.map(dateFormat.dateFormat);
28
- // @ts-expect-error: FIXME
29
28
  const stringValues = normValues === null || normValues === void 0 ? void 0 : normValues.map(value => value.toISOString());
30
29
  const normExamples = examples === null || examples === void 0 ? void 0 : examples.map(dateFormat.dateFormat);
31
30
  const schema = useSchemaType.useSchemaType('string', {
32
31
  ...props,
33
32
  default: defaultValue === 'now' ? undefined : normDefault === null || normDefault === void 0 ? void 0 : normDefault.toISOString(),
34
33
  example: normExample === null || normExample === void 0 ? void 0 : normExample.toISOString(),
35
- // @ts-expect-error: FIXME
36
34
  examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
37
35
  values: stringValues,
38
36
  });
@@ -44,20 +42,16 @@ const date = () => {
44
42
  if (stringValues) {
45
43
  rules.push((value, data) => values.values(stringValues)(value.toISOString(), data));
46
44
  }
47
- // @ts-expect-error: FIXME
48
45
  schema.format = 'date-time';
49
46
  if (normMin) {
50
- // @ts-expect-error: FIXME
51
47
  schema['x-minimum'] = normMin.toISOString();
52
48
  rules.push(minDate.minDate(normMin));
53
49
  }
54
50
  if (normMax) {
55
- // @ts-expect-error: FIXME
56
51
  schema['x-maximum'] = normMax.toISOString();
57
52
  rules.push(maxDate.maxDate(normMax));
58
53
  }
59
54
  if (defaultValue === 'now') {
60
- // @ts-expect-error: FIXME
61
55
  schema['x-default'] = 'now';
62
56
  }
63
57
  if (defaultValue === undefined) {
@@ -2,6 +2,7 @@ import { useNewHandler, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import '../../../utils/index.es6.js';
5
+ import { getSafeSchema } from '../../../utils/getSafeSchema/getSafeSchema.es6.js';
5
6
  import { useObjectSchemaContext } from '../../../hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js';
6
7
  import { schemaContext } from '../../../hooks/useSchemaContext/useSchemaContext.es6.js';
7
8
  import { useObjectRule, objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es6.js';
@@ -11,7 +12,7 @@ import { required } from '../../../utils/rules/required/required.es6.js';
11
12
  const field = () => {
12
13
  const handler = useNewHandler();
13
14
  const { children, deprecated, key, optional, readOnly, writeOnly, } = useProps();
14
- const schema = useObjectSchemaContext();
15
+ const schema = getSafeSchema(useObjectSchemaContext());
15
16
  if (!schema.properties) {
16
17
  schema.properties = {};
17
18
  }
@@ -6,6 +6,7 @@ var innet = require('innet');
6
6
  var jsx = require('@innet/jsx');
7
7
  require('../../../hooks/index.js');
8
8
  require('../../../utils/index.js');
9
+ var getSafeSchema = require('../../../utils/getSafeSchema/getSafeSchema.js');
9
10
  var useObjectSchemaContext = require('../../../hooks/useObjectSchemaContext/useObjectSchemaContext.js');
10
11
  var useSchemaContext = require('../../../hooks/useSchemaContext/useSchemaContext.js');
11
12
  var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
@@ -15,7 +16,7 @@ var required = require('../../../utils/rules/required/required.js');
15
16
  const field = () => {
16
17
  const handler = innet.useNewHandler();
17
18
  const { children, deprecated, key, optional, readOnly, writeOnly, } = jsx.useProps();
18
- const schema = useObjectSchemaContext.useObjectSchemaContext();
19
+ const schema = getSafeSchema.getSafeSchema(useObjectSchemaContext.useObjectSchemaContext());
19
20
  if (!schema.properties) {
20
21
  schema.properties = {};
21
22
  }
@@ -15,6 +15,7 @@ import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
15
15
  import { useRule, ruleContext } from '../../../hooks/useRule/useRule.es6.js';
16
16
  import { objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es6.js';
17
17
  import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
18
+ import { getSafeSchema } from '../../../utils/getSafeSchema/getSafeSchema.es6.js';
18
19
 
19
20
  const object = () => {
20
21
  useBlock('path');
@@ -53,8 +54,9 @@ const object = () => {
53
54
  parentRuleContext.reset(handler);
54
55
  innet(children, handler);
55
56
  useEffect(() => {
56
- if (!Object.keys(schema.additionalProperties).length) {
57
- delete schema.additionalProperties;
57
+ const safeSchema = getSafeSchema(schema);
58
+ if (!Object.keys(safeSchema.additionalProperties).length) {
59
+ delete safeSchema.additionalProperties;
58
60
  }
59
61
  });
60
62
  }
@@ -19,6 +19,7 @@ var pipe = require('../../../utils/rules/pipe/pipe.js');
19
19
  var useRule = require('../../../hooks/useRule/useRule.js');
20
20
  var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
21
21
  var useEffect = require('../../../hooks/useEffect/useEffect.js');
22
+ var getSafeSchema = require('../../../utils/getSafeSchema/getSafeSchema.js');
22
23
 
23
24
  const object = () => {
24
25
  useBlock.useBlock('path');
@@ -57,8 +58,9 @@ const object = () => {
57
58
  useParentRule.parentRuleContext.reset(handler);
58
59
  innet.innet(children, handler);
59
60
  useEffect.useEffect(() => {
60
- if (!Object.keys(schema.additionalProperties).length) {
61
- delete schema.additionalProperties;
61
+ const safeSchema = getSafeSchema.getSafeSchema(schema);
62
+ if (!Object.keys(safeSchema.additionalProperties).length) {
63
+ delete safeSchema.additionalProperties;
62
64
  }
63
65
  });
64
66
  }
@@ -22,7 +22,6 @@ const tuple = () => {
22
22
  if (schema) {
23
23
  const schemas = [];
24
24
  handler[schemaContext.key] = schemas;
25
- // @ts-expect-error: FIXME
26
25
  schema.prefixItems = schemas;
27
26
  const rulesMap = [];
28
27
  const rules = [];
@@ -26,7 +26,6 @@ const tuple = () => {
26
26
  if (schema) {
27
27
  const schemas = [];
28
28
  handler[useSchemaContext.schemaContext.key] = schemas;
29
- // @ts-expect-error: FIXME
30
29
  schema.prefixItems = schemas;
31
30
  const rulesMap = [];
32
31
  const rules = [];
@@ -16,10 +16,8 @@ const uuid = () => {
16
16
  ...props,
17
17
  default: defaultValue === 'new' ? undefined : defaultValue,
18
18
  });
19
- // @ts-expect-error: FIXME
20
19
  schema.format = 'uuid';
21
20
  if (defaultValue === 'new') {
22
- // @ts-expect-error: FIXME
23
21
  schema['x-default'] = defaultValue;
24
22
  }
25
23
  const rules = [];
@@ -20,10 +20,8 @@ const uuid = () => {
20
20
  ...props,
21
21
  default: defaultValue === 'new' ? undefined : defaultValue,
22
22
  });
23
- // @ts-expect-error: FIXME
24
23
  schema.format = 'uuid';
25
24
  if (defaultValue === 'new') {
26
- // @ts-expect-error: FIXME
27
25
  schema['x-default'] = defaultValue;
28
26
  }
29
27
  const rules = [];
@@ -5,7 +5,6 @@ import { useApi } from '../../../hooks/useApi/useApi.es6.js';
5
5
  import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
6
6
  import { useAction } from '../../../hooks/useAction/useAction.es6.js';
7
7
 
8
- /** @deprecated Use <ui> */
9
8
  const swagger = () => {
10
9
  const { path = process.env.INNET_SWAGGER_PATH || '/swagger-ui', } = useProps() || {};
11
10
  const { docs, prefix, } = useApi();
@@ -9,7 +9,6 @@ var useApi = require('../../../hooks/useApi/useApi.js');
9
9
  var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
10
10
  var useAction = require('../../../hooks/useAction/useAction.js');
11
11
 
12
- /** @deprecated Use <ui> */
13
12
  const swagger = () => {
14
13
  const { path = process.env.INNET_SWAGGER_PATH || '/swagger-ui', } = jsx.useProps() || {};
15
14
  const { docs, prefix, } = useApi.useApi();
@@ -1,6 +1,5 @@
1
1
  const secretKey = Symbol('once');
2
2
  function getCacheObject(target) {
3
- // @ts-expect-error: FIXME
4
3
  return target[secretKey] || (target[secretKey] = {});
5
4
  }
6
5
  function once(target, context) {
@@ -10,17 +9,14 @@ function once(target, context) {
10
9
  return function () {
11
10
  if (cache !== secretKey)
12
11
  return cache;
13
- // @ts-expect-error: FIXME
14
12
  return (cache = ('apply' in fn ? fn.apply(this, arguments) : fn(...arguments)));
15
13
  };
16
14
  }
17
15
  : function once() {
18
- // @ts-expect-error: FIXME
19
16
  const map = getCacheObject(this);
20
17
  if (context.name in map) {
21
18
  return map[context.name];
22
19
  }
23
- // @ts-expect-error: FIXME
24
20
  return (map[context.name] = target.apply(this, arguments));
25
21
  };
26
22
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const secretKey = Symbol('once');
6
6
  function getCacheObject(target) {
7
- // @ts-expect-error: FIXME
8
7
  return target[secretKey] || (target[secretKey] = {});
9
8
  }
10
9
  function once(target, context) {
@@ -14,17 +13,14 @@ function once(target, context) {
14
13
  return function () {
15
14
  if (cache !== secretKey)
16
15
  return cache;
17
- // @ts-expect-error: FIXME
18
16
  return (cache = ('apply' in fn ? fn.apply(this, arguments) : fn(...arguments)));
19
17
  };
20
18
  }
21
19
  : function once() {
22
- // @ts-expect-error: FIXME
23
20
  const map = getCacheObject(this);
24
21
  if (context.name in map) {
25
22
  return map[context.name];
26
23
  }
27
- // @ts-expect-error: FIXME
28
24
  return (map[context.name] = target.apply(this, arguments));
29
25
  };
30
26
  }
@@ -95,7 +95,6 @@ function generateTypes(docs, namespace = 'Api') {
95
95
  for (const path in paths) {
96
96
  const pathObject = paths[path];
97
97
  for (const method in pathObject) {
98
- // @ts-expect-error: FIXME
99
98
  const endpoint = pathObject[method];
100
99
  const parameters = endpoint.parameters;
101
100
  const requestBody = endpoint.requestBody;
@@ -99,7 +99,6 @@ function generateTypes(docs, namespace = 'Api') {
99
99
  for (const path in paths) {
100
100
  const pathObject = paths[path];
101
101
  for (const method in pathObject) {
102
- // @ts-expect-error: FIXME
103
102
  const endpoint = pathObject[method];
104
103
  const parameters = endpoint.parameters;
105
104
  const requestBody = endpoint.requestBody;
@@ -0,0 +1,5 @@
1
+ function getSafeSchema(schema) {
2
+ return 'oneOf' in schema ? schema.oneOf[0] : schema;
3
+ }
4
+
5
+ export { getSafeSchema };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function getSafeSchema(schema) {
6
+ return 'oneOf' in schema ? schema.oneOf[0] : schema;
7
+ }
8
+
9
+ exports.getSafeSchema = getSafeSchema;
@@ -0,0 +1 @@
1
+ export { getSafeSchema } from './getSafeSchema.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var getSafeSchema = require('./getSafeSchema.js');
6
+
7
+
8
+
9
+ exports.getSafeSchema = getSafeSchema.getSafeSchema;
@@ -5,6 +5,7 @@ import './decorators/index.es6.js';
5
5
  import './generateTypes/index.es6.js';
6
6
  import './getEndpoint/index.es6.js';
7
7
  import './getOrAdd/index.es6.js';
8
+ import './getSafeSchema/index.es6.js';
8
9
  import './httpOnStart/index.es6.js';
9
10
  import './parseBody/index.es6.js';
10
11
  import './parseFormBody/index.es6.js';
package/utils/index.js CHANGED
@@ -7,6 +7,7 @@ require('./decorators/index.js');
7
7
  require('./generateTypes/index.js');
8
8
  require('./getEndpoint/index.js');
9
9
  require('./getOrAdd/index.js');
10
+ require('./getSafeSchema/index.js');
10
11
  require('./httpOnStart/index.js');
11
12
  require('./parseBody/index.js');
12
13
  require('./parseFormBody/index.js');
package/constants.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { type BodyType } from './types';
2
- export declare const apiErrors: readonly ["requestValidation", "requestBodyContentType"];
3
- export type ApiErrorValue = typeof apiErrors[number];
4
- export declare const allBodyTypes: BodyType[];