@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
@@ -7,48 +7,62 @@ var jsx = require('@innet/jsx');
7
7
  require('../../../hooks/index.js');
8
8
  require('../../../hooks/useParentRule/index.js');
9
9
  require('../../../utils/index.js');
10
+ var useApi = require('../../../hooks/useApi/useApi.js');
10
11
  var useSchemaType = require('../../../hooks/useSchemaType/useSchemaType.js');
11
12
  var defaultTo = require('../../../utils/rules/defaultTo/defaultTo.js');
12
13
  var values = require('../../../utils/rules/values/values.js');
13
14
  var minLength = require('../../../utils/rules/minLength/minLength.js');
14
15
  var maxLength = require('../../../utils/rules/maxLength/maxLength.js');
15
16
  var pattern = require('../../../utils/rules/pattern/pattern.js');
16
- var useRule = require('../../../hooks/useRule/useRule.js');
17
17
  var pipe = require('../../../utils/rules/pipe/pipe.js');
18
+ var useRule = require('../../../hooks/useRule/useRule.js');
18
19
  var useParentRule = require('../../../hooks/useParentRule/useParentRule.js');
19
20
 
20
21
  const string = () => {
21
- const _a = jsx.useProps() || {}, { min, max, pattern: pattern$1, patternId } = _a, props = tslib.__rest(_a, ["min", "max", "pattern", "patternId"]);
22
+ const _a = jsx.useProps() || {}, { max, min, pattern: pattern$1, patternId } = _a, props = tslib.__rest(_a, ["max", "min", "pattern", "patternId"]);
23
+ const { refRules } = useApi.useApi();
22
24
  const schema = useSchemaType.useSchemaType('string', props);
23
- const rules = [];
24
- if (props.default !== undefined) {
25
- rules.push(defaultTo.defaultTo(props.default));
26
- }
27
- rules.push(String);
28
- if (props.values) {
29
- rules.push(values.values(props.values));
30
- }
31
- if (min !== undefined) {
32
- // @ts-expect-error: FIXME
33
- schema.minimum = min;
34
- rules.push(minLength.minLength(min));
35
- }
36
- if (max !== undefined) {
37
- // @ts-expect-error: FIXME
38
- schema.maximum = max;
39
- rules.push(maxLength.maxLength(max));
40
- }
41
- if (pattern$1 !== undefined) {
42
- // @ts-expect-error: FIXME
43
- schema.pattern = String(pattern$1);
44
- rules.push(pattern.pattern(pattern$1, patternId));
45
- }
46
- if (props.default) {
47
- useRule.useRule(pipe.pipe(...rules));
25
+ if (schema) {
26
+ const rules = [];
27
+ if (props.default !== undefined) {
28
+ rules.push(defaultTo.defaultTo(props.default));
29
+ }
30
+ rules.push(String);
31
+ if (props.values) {
32
+ rules.push(values.values(props.values));
33
+ }
34
+ if (min !== undefined) {
35
+ schema.minimum = min;
36
+ rules.push(minLength.minLength(min));
37
+ }
38
+ if (max !== undefined) {
39
+ schema.maximum = max;
40
+ rules.push(maxLength.maxLength(max));
41
+ }
42
+ if (pattern$1 !== undefined) {
43
+ schema.pattern = String(pattern$1);
44
+ rules.push(pattern.pattern(pattern$1, patternId));
45
+ }
46
+ const rule = pipe.pipe(...rules);
47
+ if (props.ref) {
48
+ refRules[props.ref] = rule;
49
+ }
50
+ if (props.default) {
51
+ useRule.useRule(rule);
52
+ }
53
+ else {
54
+ const parentRule = useParentRule.useParentRule();
55
+ useRule.useRule(parentRule(rule));
56
+ }
48
57
  }
49
- else {
50
- const parentRule = useParentRule.useParentRule();
51
- useRule.useRule(parentRule(pipe.pipe(...rules)));
58
+ else if (props.ref) {
59
+ if (props.default) {
60
+ useRule.useRule(refRules[props.ref]);
61
+ }
62
+ else {
63
+ const parentRule = useParentRule.useParentRule();
64
+ useRule.useRule(parentRule(refRules[props.ref]));
65
+ }
52
66
  }
53
67
  };
54
68
 
@@ -0,0 +1,4 @@
1
+ export interface BlacklistProps {
2
+ ip?: string | string[];
3
+ }
4
+ export declare function blacklist(): void;
@@ -0,0 +1,18 @@
1
+ import { useProps, useChildren } from '@innet/jsx';
2
+ import '../../../hooks/index.es6.js';
3
+ import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
4
+ import { useAction } from '../../../hooks/useAction/useAction.es6.js';
5
+
6
+ function blacklist() {
7
+ const { ip = process.env.INNET_BLACKLIST_IP, } = useProps() || {};
8
+ const children = useChildren();
9
+ const ips = typeof ip === 'string' ? ip.split(',') : ip;
10
+ useServerPlugin(() => {
11
+ const action = useAction();
12
+ if (!action.clientIp || (ips === null || ips === void 0 ? void 0 : ips.includes(action.clientIp))) {
13
+ return children;
14
+ }
15
+ });
16
+ }
17
+
18
+ export { blacklist };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsx = require('@innet/jsx');
6
+ require('../../../hooks/index.js');
7
+ var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
8
+ var useAction = require('../../../hooks/useAction/useAction.js');
9
+
10
+ function blacklist() {
11
+ const { ip = process.env.INNET_BLACKLIST_IP, } = jsx.useProps() || {};
12
+ const children = jsx.useChildren();
13
+ const ips = typeof ip === 'string' ? ip.split(',') : ip;
14
+ useServerPlugin.useServerPlugin(() => {
15
+ const action = useAction.useAction();
16
+ if (!action.clientIp || (ips === null || ips === void 0 ? void 0 : ips.includes(action.clientIp))) {
17
+ return children;
18
+ }
19
+ });
20
+ }
21
+
22
+ exports.blacklist = blacklist;
@@ -0,0 +1 @@
1
+ export * from './blacklist';
@@ -0,0 +1 @@
1
+ export { blacklist } from './blacklist.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var blacklist = require('./blacklist.js');
6
+
7
+
8
+
9
+ exports.blacklist = blacklist.blacklist;
@@ -1,6 +1,6 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
- import { type Config } from 'dtsgenerator/dist/core/config';
3
- export interface DtsProps extends Partial<Config> {
4
- path: string;
2
+ export interface DtsProps {
3
+ namespace?: string;
4
+ path?: string;
5
5
  }
6
6
  export declare const dts: HandlerPlugin;
@@ -1,34 +1,15 @@
1
- import { __rest, __awaiter } from 'tslib';
2
1
  import { useProps } from '@innet/jsx';
3
- import dtsGenerator, { parseSchema } from 'dtsgenerator';
4
- import fs from 'node:fs';
2
+ import { promises } from 'node:fs';
5
3
  import '../../../hooks/index.es6.js';
4
+ import '../../../utils/index.es6.js';
6
5
  import { useApi } from '../../../hooks/useApi/useApi.es6.js';
6
+ import { generateTypes } from '../../../utils/generateTypes/generateTypes.es6.js';
7
7
 
8
8
  const dts = () => {
9
- const _a = useProps(), { path } = _a, config = __rest(_a, ["path"]);
9
+ const { namespace = process.env.INNET_DTS_NAMESPACE, path = process.env.INNET_DTS_PATH || 'src/apiTypes.d.ts', } = useProps() || {};
10
10
  const { docs } = useApi();
11
- dtsGenerator({
12
- contents: [parseSchema(JSON.parse(JSON.stringify(docs)))],
13
- config,
14
- }).then((content) => __awaiter(void 0, void 0, void 0, function* () {
15
- yield fs.promises.writeFile(path, `interface Bin {
16
- filename: string
17
- fieldName: string
18
- originalFilename: string
19
- path: string
20
- type: string
21
- disposition: string
22
- size: number
23
- extension?: string
24
- }
25
- ${content
26
- .replaceAll(';', '')
27
- .replaceAll('number // int64', 'bigint')
28
- .replaceAll('string // binary', 'Bin')
29
- .replaceAll('string // date-time', 'Date')}`);
30
- })).catch(error => {
31
- console.warn(error);
11
+ promises.writeFile(path, generateTypes(docs, namespace)).catch(e => {
12
+ console.error(e);
32
13
  });
33
14
  };
34
15
 
@@ -2,42 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var jsx = require('@innet/jsx');
7
- var dtsGenerator = require('dtsgenerator');
8
6
  var fs = require('node:fs');
9
7
  require('../../../hooks/index.js');
8
+ require('../../../utils/index.js');
10
9
  var useApi = require('../../../hooks/useApi/useApi.js');
11
-
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- var dtsGenerator__default = /*#__PURE__*/_interopDefaultLegacy(dtsGenerator);
15
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
10
+ var generateTypes = require('../../../utils/generateTypes/generateTypes.js');
16
11
 
17
12
  const dts = () => {
18
- const _a = jsx.useProps(), { path } = _a, config = tslib.__rest(_a, ["path"]);
13
+ const { namespace = process.env.INNET_DTS_NAMESPACE, path = process.env.INNET_DTS_PATH || 'src/apiTypes.d.ts', } = jsx.useProps() || {};
19
14
  const { docs } = useApi.useApi();
20
- dtsGenerator__default["default"]({
21
- contents: [dtsGenerator.parseSchema(JSON.parse(JSON.stringify(docs)))],
22
- config,
23
- }).then((content) => tslib.__awaiter(void 0, void 0, void 0, function* () {
24
- yield fs__default["default"].promises.writeFile(path, `interface Bin {
25
- filename: string
26
- fieldName: string
27
- originalFilename: string
28
- path: string
29
- type: string
30
- disposition: string
31
- size: number
32
- extension?: string
33
- }
34
- ${content
35
- .replaceAll(';', '')
36
- .replaceAll('number // int64', 'bigint')
37
- .replaceAll('string // binary', 'Bin')
38
- .replaceAll('string // date-time', 'Date')}`);
39
- })).catch(error => {
40
- console.warn(error);
15
+ fs.promises.writeFile(path, generateTypes.generateTypes(docs, namespace)).catch(e => {
16
+ console.error(e);
41
17
  });
42
18
  };
43
19
 
@@ -0,0 +1,6 @@
1
+ import { type HandlerPlugin } from 'innet';
2
+ export interface EnvProps {
3
+ is: string | string[];
4
+ of?: string;
5
+ }
6
+ export declare const env: HandlerPlugin;
@@ -0,0 +1,11 @@
1
+ import innet, { useHandler } from 'innet';
2
+ import { useProps, useChildren } from '@innet/jsx';
3
+
4
+ const env = () => {
5
+ const { is, of = 'NODE_ENV', } = useProps();
6
+ if (Array.isArray(is) ? is.includes(process.env[of]) : process.env[of] === is) {
7
+ innet(useChildren(), useHandler());
8
+ }
9
+ };
10
+
11
+ export { env };
@@ -9,10 +9,11 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
9
9
 
10
10
  var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
11
11
 
12
- const prod = () => {
13
- if (process.env.NODE_ENV === 'production') {
12
+ const env = () => {
13
+ const { is, of = 'NODE_ENV', } = jsx.useProps();
14
+ if (Array.isArray(is) ? is.includes(process.env[of]) : process.env[of] === is) {
14
15
  innet__default["default"](jsx.useChildren(), innet.useHandler());
15
16
  }
16
17
  };
17
18
 
18
- exports.prod = prod;
19
+ exports.env = env;
@@ -0,0 +1 @@
1
+ export * from './env';
@@ -0,0 +1 @@
1
+ export { env } from './env.es6.js';
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dev = require('./dev.js');
5
+ var env = require('./env.js');
6
6
 
7
7
 
8
8
 
9
- exports.dev = dev.dev;
9
+ exports.env = env.env;
@@ -1,4 +1,6 @@
1
1
  export * from './swagger';
2
2
  export * from './dts';
3
- export * from './dev';
4
- export * from './prod';
3
+ export * from './env';
4
+ export * from './protection';
5
+ export * from './blacklist';
6
+ export * from './whitelist';
@@ -1,4 +1,6 @@
1
1
  import './swagger/index.es6.js';
2
2
  import './dts/index.es6.js';
3
- import './dev/index.es6.js';
4
- import './prod/index.es6.js';
3
+ import './env/index.es6.js';
4
+ import './protection/index.es6.js';
5
+ import './blacklist/index.es6.js';
6
+ import './whitelist/index.es6.js';
@@ -2,6 +2,8 @@
2
2
 
3
3
  require('./swagger/index.js');
4
4
  require('./dts/index.js');
5
- require('./dev/index.js');
6
- require('./prod/index.js');
5
+ require('./env/index.js');
6
+ require('./protection/index.js');
7
+ require('./blacklist/index.js');
8
+ require('./whitelist/index.js');
7
9
 
@@ -0,0 +1 @@
1
+ export * from './protection';
@@ -0,0 +1 @@
1
+ export { protection } from './protection.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var protection = require('./protection.js');
6
+
7
+
8
+
9
+ exports.protection = protection.protection;
@@ -0,0 +1,8 @@
1
+ export interface ProtectionProps {
2
+ cookieKey?: string;
3
+ excludeIp?: string | string[];
4
+ maxAge?: number;
5
+ searchKey?: string;
6
+ value?: string;
7
+ }
8
+ export declare function protection(): void;
@@ -0,0 +1,36 @@
1
+ import { useProps, useChildren } from '@innet/jsx';
2
+ import '../../../hooks/index.es6.js';
3
+ import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
4
+ import { useAction } from '../../../hooks/useAction/useAction.es6.js';
5
+
6
+ function protection() {
7
+ const { cookieKey = process.env.INNET_PROTECTION_COOKIE_KEY || 'protection', excludeIp = process.env.INNET_PROTECTED_IP, maxAge = Number(process.env.INNET_PROTECTION_MAX_AGE) || 365 * 24 * 60 * 60, searchKey = process.env.INNET_PROTECTION_SEARCH_KEY || 'protection', value = process.env.INNET_PROTECTION, } = useProps() || {};
8
+ const children = useChildren();
9
+ if (!value)
10
+ return;
11
+ const excludeIps = Array.isArray(excludeIp) ? excludeIp : excludeIp === null || excludeIp === void 0 ? void 0 : excludeIp.split(',');
12
+ useServerPlugin(() => {
13
+ const action = useAction();
14
+ if (!action.clientIp)
15
+ return children;
16
+ if (excludeIps === null || excludeIps === void 0 ? void 0 : excludeIps.includes(action.clientIp))
17
+ return;
18
+ const { [cookieKey]: cookieProtection } = action.cookies;
19
+ if (cookieProtection && cookieProtection === value)
20
+ return;
21
+ const { [searchKey]: searchProtection } = action.search;
22
+ if (searchProtection && searchProtection === value) {
23
+ action.setCookie(cookieKey, value, {
24
+ httpOnly: true,
25
+ maxAge,
26
+ path: '/',
27
+ secure: true,
28
+ });
29
+ return;
30
+ }
31
+ action.setCookie(cookieKey);
32
+ return children;
33
+ });
34
+ }
35
+
36
+ export { protection };
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsx = require('@innet/jsx');
6
+ require('../../../hooks/index.js');
7
+ var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
8
+ var useAction = require('../../../hooks/useAction/useAction.js');
9
+
10
+ function protection() {
11
+ const { cookieKey = process.env.INNET_PROTECTION_COOKIE_KEY || 'protection', excludeIp = process.env.INNET_PROTECTED_IP, maxAge = Number(process.env.INNET_PROTECTION_MAX_AGE) || 365 * 24 * 60 * 60, searchKey = process.env.INNET_PROTECTION_SEARCH_KEY || 'protection', value = process.env.INNET_PROTECTION, } = jsx.useProps() || {};
12
+ const children = jsx.useChildren();
13
+ if (!value)
14
+ return;
15
+ const excludeIps = Array.isArray(excludeIp) ? excludeIp : excludeIp === null || excludeIp === void 0 ? void 0 : excludeIp.split(',');
16
+ useServerPlugin.useServerPlugin(() => {
17
+ const action = useAction.useAction();
18
+ if (!action.clientIp)
19
+ return children;
20
+ if (excludeIps === null || excludeIps === void 0 ? void 0 : excludeIps.includes(action.clientIp))
21
+ return;
22
+ const { [cookieKey]: cookieProtection } = action.cookies;
23
+ if (cookieProtection && cookieProtection === value)
24
+ return;
25
+ const { [searchKey]: searchProtection } = action.search;
26
+ if (searchProtection && searchProtection === value) {
27
+ action.setCookie(cookieKey, value, {
28
+ httpOnly: true,
29
+ maxAge,
30
+ path: '/',
31
+ secure: true,
32
+ });
33
+ return;
34
+ }
35
+ action.setCookie(cookieKey);
36
+ return children;
37
+ });
38
+ }
39
+
40
+ exports.protection = protection;
@@ -1,27 +1,25 @@
1
1
  import { useProps } from '@innet/jsx';
2
- import { onDestroy } from 'watch-state';
3
2
  import '../../../hooks/index.es6.js';
4
3
  import html from './swagger.html.es6.js';
5
4
  import { useApi } from '../../../hooks/useApi/useApi.es6.js';
5
+ import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
6
+ import { useAction } from '../../../hooks/useAction/useAction.es6.js';
6
7
 
7
8
  const swagger = () => {
8
- const { path = '/swagger-ui' } = useProps() || {};
9
- const { docs, requestPlugins, prefix } = useApi();
9
+ const { path = process.env.INNET_SWAGGER_PATH || '/swagger-ui', } = useProps() || {};
10
+ const { docs, prefix, } = useApi();
10
11
  let swaggerResponse;
11
- const listener = (req, res) => {
12
- if (req.url === prefix + path) {
12
+ useServerPlugin(() => {
13
+ const action = useAction();
14
+ if (action.path === prefix + path) {
13
15
  if (!swaggerResponse) {
14
16
  swaggerResponse = html.replace('spec: {},', `spec: ${JSON.stringify(docs)},`);
15
17
  }
16
- res.statusCode = 200;
17
- res.write(swaggerResponse);
18
- res.end();
18
+ action.res.statusCode = 200;
19
+ action.res.write(swaggerResponse);
20
+ action.res.end();
19
21
  return true;
20
22
  }
21
- };
22
- requestPlugins.add(listener);
23
- onDestroy(() => {
24
- requestPlugins.delete(listener);
25
23
  });
26
24
  };
27
25
 
@@ -3,29 +3,27 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsx = require('@innet/jsx');
6
- var watchState = require('watch-state');
7
6
  require('../../../hooks/index.js');
8
7
  var swagger$1 = require('./swagger.html.js');
9
8
  var useApi = require('../../../hooks/useApi/useApi.js');
9
+ var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
10
+ var useAction = require('../../../hooks/useAction/useAction.js');
10
11
 
11
12
  const swagger = () => {
12
- const { path = '/swagger-ui' } = jsx.useProps() || {};
13
- const { docs, requestPlugins, prefix } = useApi.useApi();
13
+ const { path = process.env.INNET_SWAGGER_PATH || '/swagger-ui', } = jsx.useProps() || {};
14
+ const { docs, prefix, } = useApi.useApi();
14
15
  let swaggerResponse;
15
- const listener = (req, res) => {
16
- if (req.url === prefix + path) {
16
+ useServerPlugin.useServerPlugin(() => {
17
+ const action = useAction.useAction();
18
+ if (action.path === prefix + path) {
17
19
  if (!swaggerResponse) {
18
20
  swaggerResponse = swagger$1["default"].replace('spec: {},', `spec: ${JSON.stringify(docs)},`);
19
21
  }
20
- res.statusCode = 200;
21
- res.write(swaggerResponse);
22
- res.end();
22
+ action.res.statusCode = 200;
23
+ action.res.write(swaggerResponse);
24
+ action.res.end();
23
25
  return true;
24
26
  }
25
- };
26
- requestPlugins.add(listener);
27
- watchState.onDestroy(() => {
28
- requestPlugins.delete(listener);
29
27
  });
30
28
  };
31
29
 
@@ -0,0 +1 @@
1
+ export * from './whitelist';
@@ -0,0 +1 @@
1
+ export { whitelist } from './whitelist.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var whitelist = require('./whitelist.js');
6
+
7
+
8
+
9
+ exports.whitelist = whitelist.whitelist;
@@ -0,0 +1,4 @@
1
+ export interface WhitelistProps {
2
+ ip?: string | string[];
3
+ }
4
+ export declare function whitelist(): void;
@@ -0,0 +1,20 @@
1
+ import { useProps, useChildren } from '@innet/jsx';
2
+ import '../../../hooks/index.es6.js';
3
+ import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
4
+ import { useAction } from '../../../hooks/useAction/useAction.es6.js';
5
+
6
+ function whitelist() {
7
+ const { ip = process.env.INNET_WHITELIST_IP, } = useProps() || {};
8
+ const children = useChildren();
9
+ const ips = typeof ip === 'string' ? ip.split(',') : ip;
10
+ if (!ips)
11
+ return;
12
+ useServerPlugin(() => {
13
+ const action = useAction();
14
+ if (!action.clientIp || !ips.includes(action.clientIp)) {
15
+ return children;
16
+ }
17
+ });
18
+ }
19
+
20
+ export { whitelist };
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsx = require('@innet/jsx');
6
+ require('../../../hooks/index.js');
7
+ var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
8
+ var useAction = require('../../../hooks/useAction/useAction.js');
9
+
10
+ function whitelist() {
11
+ const { ip = process.env.INNET_WHITELIST_IP, } = jsx.useProps() || {};
12
+ const children = jsx.useChildren();
13
+ const ips = typeof ip === 'string' ? ip.split(',') : ip;
14
+ if (!ips)
15
+ return;
16
+ useServerPlugin.useServerPlugin(() => {
17
+ const action = useAction.useAction();
18
+ if (!action.clientIp || !ips.includes(action.clientIp)) {
19
+ return children;
20
+ }
21
+ });
22
+ }
23
+
24
+ exports.whitelist = whitelist;