@innet/server 2.0.0-beta.1 → 2.0.0-beta.11

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 (193) hide show
  1. package/README.md +385 -9
  2. package/handler/handler.d.ts +6 -9
  3. package/handler/handler.es6.js +3 -4
  4. package/handler/handler.js +2 -3
  5. package/hooks/index.d.ts +24 -23
  6. package/hooks/index.es6.js +24 -23
  7. package/hooks/index.js +24 -23
  8. package/hooks/useEffect/index.d.ts +1 -0
  9. package/hooks/useEffect/index.es6.js +1 -0
  10. package/hooks/useEffect/index.js +9 -0
  11. package/hooks/useEffect/useEffect.d.ts +2 -0
  12. package/hooks/useEffect/useEffect.es6.js +8 -0
  13. package/hooks/useEffect/useEffect.js +12 -0
  14. package/hooks/useHeaders/useHeaders.d.ts +0 -1
  15. package/hooks/useNewSchema/useNewSchema.es6.js +1 -1
  16. package/hooks/useNewSchema/useNewSchema.js +1 -1
  17. package/hooks/useRequest/useRequest.d.ts +0 -1
  18. package/hooks/useResponse/useResponse.d.ts +0 -1
  19. package/hooks/useSchemaType/useSchemaType.es6.js +26 -9
  20. package/hooks/useSchemaType/useSchemaType.js +26 -9
  21. package/hooks/useServer/useServer.d.ts +0 -2
  22. package/index.d.ts +2 -2
  23. package/index.es6.js +89 -87
  24. package/index.js +202 -194
  25. package/package.json +16 -15
  26. package/plugins/handler/serverFn/serverFn.es6.js +2 -2
  27. package/plugins/handler/serverFn/serverFn.js +2 -6
  28. package/plugins/index.d.ts +2 -2
  29. package/plugins/index.es6.js +2 -2
  30. package/plugins/index.js +2 -2
  31. package/plugins/main/api/api.es6.js +74 -74
  32. package/plugins/main/api/api.js +75 -79
  33. package/plugins/main/body/body.es6.js +4 -4
  34. package/plugins/main/body/body.js +4 -8
  35. package/plugins/main/endpoint/endpoint.d.ts +5 -0
  36. package/plugins/main/endpoint/endpoint.es6.js +5 -5
  37. package/plugins/main/endpoint/endpoint.js +5 -9
  38. package/plugins/main/host/host.es6.js +4 -2
  39. package/plugins/main/host/host.js +4 -6
  40. package/plugins/main/index.d.ts +8 -8
  41. package/plugins/main/index.es6.js +8 -8
  42. package/plugins/main/index.js +8 -8
  43. package/plugins/main/param/param.es6.js +3 -4
  44. package/plugins/main/param/param.js +3 -8
  45. package/plugins/main/preset/preset.es6.js +1 -1
  46. package/plugins/main/preset/preset.js +1 -5
  47. package/plugins/main/response/response.es6.js +11 -4
  48. package/plugins/main/response/response.js +11 -8
  49. package/plugins/main/server/server.d.ts +0 -1
  50. package/plugins/main/server/server.es6.js +7 -10
  51. package/plugins/main/server/server.js +8 -12
  52. package/plugins/main/tag/index.es6.js +1 -1
  53. package/plugins/main/tag/index.js +1 -0
  54. package/plugins/main/tag/tag.d.ts +8 -1
  55. package/plugins/main/tag/tag.es6.js +20 -3
  56. package/plugins/main/tag/tag.js +20 -6
  57. package/plugins/main/variable/variable.es6.js +3 -4
  58. package/plugins/main/variable/variable.js +3 -4
  59. package/plugins/request/cms/cms.es6.js +1 -1
  60. package/plugins/request/cms/cms.js +2 -3
  61. package/plugins/request/cookie/cookie.d.ts +2 -2
  62. package/plugins/request/cookie/cookie.es6.js +1 -2
  63. package/plugins/request/cookie/cookie.js +1 -2
  64. package/plugins/request/error/error.es6.js +1 -2
  65. package/plugins/request/error/error.js +1 -2
  66. package/plugins/request/file/file.es6.js +2 -3
  67. package/plugins/request/file/file.js +2 -4
  68. package/plugins/request/index.d.ts +5 -5
  69. package/plugins/request/index.es6.js +5 -5
  70. package/plugins/request/index.js +5 -5
  71. package/plugins/request/proxy/proxy.d.ts +0 -1
  72. package/plugins/schema/array/array.d.ts +3 -0
  73. package/plugins/schema/array/array.es6.js +14 -6
  74. package/plugins/schema/array/array.js +15 -11
  75. package/plugins/schema/binary/binary.d.ts +4 -0
  76. package/plugins/schema/boolean/boolean.d.ts +1 -0
  77. package/plugins/schema/date/date.d.ts +2 -1
  78. package/plugins/schema/date/date.es6.js +10 -6
  79. package/plugins/schema/date/date.js +10 -6
  80. package/plugins/schema/field/field.d.ts +4 -0
  81. package/plugins/schema/field/field.es6.js +16 -3
  82. package/plugins/schema/field/field.js +16 -7
  83. package/plugins/schema/index.d.ts +8 -8
  84. package/plugins/schema/index.es6.js +8 -8
  85. package/plugins/schema/index.js +8 -8
  86. package/plugins/schema/integer/integer.d.ts +37 -0
  87. package/plugins/schema/integer/integer.es6.js +31 -11
  88. package/plugins/schema/integer/integer.js +31 -11
  89. package/plugins/schema/number/number.d.ts +32 -0
  90. package/plugins/schema/number/number.es6.js +23 -8
  91. package/plugins/schema/number/number.js +22 -7
  92. package/plugins/schema/object/object.es6.js +9 -8
  93. package/plugins/schema/object/object.js +9 -12
  94. package/plugins/schema/string/string.d.ts +27 -0
  95. package/plugins/schema/string/string.es6.js +11 -6
  96. package/plugins/schema/string/string.js +10 -5
  97. package/plugins/schema/tuple/tuple.es6.js +5 -6
  98. package/plugins/schema/tuple/tuple.js +5 -10
  99. package/plugins/schema/uuid/uuid.es6.js +7 -5
  100. package/plugins/schema/uuid/uuid.js +6 -4
  101. package/plugins/utils/dts/dts.es6.js +5 -2
  102. package/plugins/utils/dts/dts.js +5 -2
  103. package/plugins/utils/env/env.es6.js +1 -1
  104. package/plugins/utils/env/env.js +1 -5
  105. package/plugins/utils/index.d.ts +3 -2
  106. package/plugins/utils/index.es6.js +3 -2
  107. package/plugins/utils/index.js +3 -2
  108. package/plugins/utils/swagger/swagger.d.ts +1 -0
  109. package/plugins/utils/swagger/swagger.es6.js +1 -0
  110. package/plugins/utils/swagger/swagger.js +1 -0
  111. package/plugins/utils/ui/index.d.ts +1 -0
  112. package/plugins/utils/ui/index.es6.js +1 -0
  113. package/plugins/utils/ui/index.js +10 -0
  114. package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
  115. package/plugins/utils/ui/rapidoc.html.js +7 -0
  116. package/plugins/utils/ui/redoc.html.es6.js +3 -0
  117. package/plugins/utils/ui/redoc.html.js +7 -0
  118. package/plugins/utils/ui/scalar.html.es6.js +3 -0
  119. package/plugins/utils/ui/scalar.html.js +7 -0
  120. package/plugins/utils/ui/swagger.html.es6.js +3 -0
  121. package/plugins/utils/ui/swagger.html.js +7 -0
  122. package/plugins/utils/ui/ui.d.ts +13 -0
  123. package/plugins/utils/ui/ui.es6.js +45 -0
  124. package/plugins/utils/ui/ui.js +50 -0
  125. package/types.d.ts +8 -1
  126. package/utils/action/Action.d.ts +4 -5
  127. package/utils/action/Action.es6.js +14 -16
  128. package/utils/action/Action.js +13 -15
  129. package/utils/getSafeSchema/getSafeSchema.d.ts +2 -0
  130. package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
  131. package/utils/getSafeSchema/getSafeSchema.js +9 -0
  132. package/utils/getSafeSchema/index.d.ts +1 -0
  133. package/utils/getSafeSchema/index.es6.js +1 -0
  134. package/utils/getSafeSchema/index.js +9 -0
  135. package/utils/index.d.ts +9 -8
  136. package/utils/index.es6.js +9 -8
  137. package/utils/index.js +9 -8
  138. package/utils/parseBody/parseBody.d.ts +0 -1
  139. package/utils/parseBody/parseBody.es6.js +13 -16
  140. package/utils/parseBody/parseBody.js +13 -16
  141. package/utils/parseFormBody/parseFormBody.d.ts +0 -1
  142. package/utils/parseFormBody/parseFormBody.es6.js +41 -41
  143. package/utils/parseFormBody/parseFormBody.js +41 -41
  144. package/utils/parseSearch/parseSearch.es6.js +4 -1
  145. package/utils/parseSearch/parseSearch.js +4 -1
  146. package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
  147. package/utils/rules/arrayOf/arrayOf.js +1 -1
  148. package/utils/rules/bin/bin.es6.js +4 -1
  149. package/utils/rules/bin/bin.js +4 -1
  150. package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
  151. package/utils/rules/binaryAccept/binaryAccept.js +5 -2
  152. package/utils/rules/dateTo/dateTo.es6.js +4 -1
  153. package/utils/rules/dateTo/dateTo.js +4 -1
  154. package/utils/rules/helpers.es6.js +4 -1
  155. package/utils/rules/helpers.js +4 -1
  156. package/utils/rules/index.d.ts +17 -17
  157. package/utils/rules/index.es6.js +17 -17
  158. package/utils/rules/index.js +18 -18
  159. package/utils/rules/int/int.es6.js +17 -4
  160. package/utils/rules/int/int.js +17 -4
  161. package/utils/rules/max/max.es6.js +9 -3
  162. package/utils/rules/max/max.js +9 -3
  163. package/utils/rules/maxBin/maxBin.es6.js +5 -2
  164. package/utils/rules/maxBin/maxBin.js +5 -2
  165. package/utils/rules/maxDate/maxDate.es6.js +5 -1
  166. package/utils/rules/maxDate/maxDate.js +5 -1
  167. package/utils/rules/maxLength/maxLength.es6.js +5 -2
  168. package/utils/rules/maxLength/maxLength.js +5 -2
  169. package/utils/rules/min/min.es6.js +9 -3
  170. package/utils/rules/min/min.js +9 -3
  171. package/utils/rules/minBin/minBin.es6.js +5 -2
  172. package/utils/rules/minBin/minBin.js +5 -2
  173. package/utils/rules/minDate/minDate.es6.js +5 -1
  174. package/utils/rules/minDate/minDate.js +5 -1
  175. package/utils/rules/minLength/minLength.es6.js +5 -2
  176. package/utils/rules/minLength/minLength.js +5 -2
  177. package/utils/rules/num/num.es6.js +4 -1
  178. package/utils/rules/num/num.js +4 -1
  179. package/utils/rules/objectOf/objectOf.es6.js +6 -3
  180. package/utils/rules/objectOf/objectOf.js +6 -3
  181. package/utils/rules/pattern/pattern.es6.js +6 -2
  182. package/utils/rules/pattern/pattern.js +6 -2
  183. package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
  184. package/utils/rules/tupleOf/tupleOf.js +1 -1
  185. package/utils/rules/values/index.es6.js +1 -1
  186. package/utils/rules/values/index.js +1 -0
  187. package/utils/rules/values/values.d.ts +3 -1
  188. package/utils/rules/values/values.es6.js +9 -3
  189. package/utils/rules/values/values.js +9 -2
  190. package/utils/stringifySearch/stringifySearch.es6.js +4 -1
  191. package/utils/stringifySearch/stringifySearch.js +4 -1
  192. package/_virtual/_rollup-plugin-process-env.es6.js +0 -10
  193. package/_virtual/_rollup-plugin-process-env.js +0 -12
@@ -2,14 +2,13 @@
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
6
  require('../../../hooks/index.js');
8
7
  require('../../../utils/index.js');
9
8
  var useSchemaType = require('../../../hooks/useSchemaType/useSchemaType.js');
9
+ var values = require('../../../utils/rules/values/values.js');
10
10
  var defaultTo = require('../../../utils/rules/defaultTo/defaultTo.js');
11
11
  var int = require('../../../utils/rules/int/int.js');
12
- var values = require('../../../utils/rules/values/values.js');
13
12
  var min = require('../../../utils/rules/min/min.js');
14
13
  var max = require('../../../utils/rules/max/max.js');
15
14
  var useRule = require('../../../hooks/useRule/useRule.js');
@@ -17,21 +16,42 @@ var optional = require('../../../utils/rules/optional/optional.js');
17
16
  var pipe = require('../../../utils/rules/pipe/pipe.js');
18
17
 
19
18
  const integer = () => {
20
- const _a = jsx.useProps() || {}, { default: defaultValue, example, examples, format = 'int32', max: max$1, min: min$1, values: values$1 } = _a, props = tslib.__rest(_a, ["default", "example", "examples", "format", "max", "min", "values"]);
21
- const schema = useSchemaType.useSchemaType('integer', Object.assign(Object.assign({}, props), { default: defaultValue !== undefined ? Number(defaultValue) : undefined, example: example !== undefined ? Number(example) : undefined, examples: examples === null || examples === void 0 ? void 0 : examples.map(Number), values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number) }));
22
- // @ts-expect-error: FIXME
23
- schema.format = format;
24
- // @ts-expect-error: FIXME
25
- schema.minimum = min$1 !== undefined ? Number(min$1) : undefined;
26
- // @ts-expect-error: FIXME
27
- schema.maximum = max$1 !== undefined ? Number(max$1) : undefined;
19
+ const { default: defaultValue, example, examples, exclusiveMaximum, exclusiveMinimum, format = 'int32', max: max$1, min: min$1, multipleOf, values: values$1, ...props } = jsx.useProps() || {};
20
+ const schema = useSchemaType.useSchemaType('integer', {
21
+ ...props,
22
+ const: props.const !== undefined ? Number(props.const) : undefined,
23
+ default: defaultValue !== undefined ? Number(defaultValue) : undefined,
24
+ example: example !== undefined ? Number(example) : undefined,
25
+ examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
26
+ values: values$1 && values.getArrayValues(values$1, Number),
27
+ });
28
+ if (schema) {
29
+ if (format) {
30
+ schema.format = format;
31
+ }
32
+ if (min$1 !== undefined) {
33
+ schema.minimum = Number(min$1);
34
+ }
35
+ if (max$1 !== undefined) {
36
+ schema.maximum = Number(max$1);
37
+ }
38
+ if (exclusiveMinimum) {
39
+ schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
40
+ }
41
+ if (exclusiveMaximum) {
42
+ schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
43
+ }
44
+ if (multipleOf !== undefined) {
45
+ schema.multipleOf = Number(multipleOf);
46
+ }
47
+ }
28
48
  const rules = [];
29
49
  if (defaultValue !== undefined) {
30
50
  rules.push(defaultTo.defaultTo(defaultValue));
31
51
  }
32
52
  rules.push(int.int(format));
33
53
  if (values$1) {
34
- rules.push(values.values(values$1.map(value => int.int(format)(value))));
54
+ rules.push(values.values(values.getArrayValues(values$1, int.int(format))));
35
55
  }
36
56
  if (min$1 !== undefined) {
37
57
  rules.push(min.min(min$1));
@@ -1,9 +1,41 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type ValuesSchemaProps } from '../../../types';
3
3
  export interface NumberProps extends ValuesSchemaProps<number> {
4
+ /**
5
+ * The `exclusiveMaximum` keyword is used to restrict the value to be less than the specified number.
6
+ * @example For example, the following value is valid:
7
+ * ```tsx
8
+ * <number exclusiveMaximum={10} />
9
+ * ```
10
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
11
+ * */
12
+ exclusiveMaximum?: boolean;
13
+ /**
14
+ * The `exclusiveMinimum` keyword is used to restrict the value to be greater than the specified number.
15
+ * @example For example, the following value is valid:
16
+ * ```tsx
17
+ * <number exclusiveMinimum={10} />
18
+ * ```
19
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
20
+ * */
21
+ exclusiveMinimum?: boolean;
22
+ /**
23
+ * An optional format modifier serves as a hint at the contents and format of the string.
24
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
25
+ * */
26
+ format?: 'double' | 'float' | (string & {});
4
27
  /** Validate the number value by maximum. */
5
28
  max?: number;
6
29
  /** Validate the number value by minimum. */
7
30
  min?: number;
31
+ /**
32
+ * The `multipleOf` keyword is used to restrict the value to be a multiple of the specified number.
33
+ * @example For example, the following value is valid:
34
+ * ```tsx
35
+ * <number multipleOf={2} />
36
+ * ```
37
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
38
+ * */
39
+ multipleOf?: number;
8
40
  }
9
41
  export declare const number: HandlerPlugin;
@@ -1,4 +1,3 @@
1
- import { __rest } from 'tslib';
2
1
  import { useProps } from '@innet/jsx';
3
2
  import '../../../hooks/index.es6.js';
4
3
  import '../../../hooks/useParentRule/index.es6.js';
@@ -6,7 +5,7 @@ import '../../../utils/index.es6.js';
6
5
  import { useSchemaType } from '../../../hooks/useSchemaType/useSchemaType.es6.js';
7
6
  import { defaultTo } from '../../../utils/rules/defaultTo/defaultTo.es6.js';
8
7
  import { num } from '../../../utils/rules/num/num.es6.js';
9
- import { values } from '../../../utils/rules/values/values.es6.js';
8
+ import { values, getArrayValues } from '../../../utils/rules/values/values.es6.js';
10
9
  import { min } from '../../../utils/rules/min/min.es6.js';
11
10
  import { max } from '../../../utils/rules/max/max.es6.js';
12
11
  import { useParentRule } from '../../../hooks/useParentRule/useParentRule.es6.js';
@@ -14,19 +13,35 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
14
13
  import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
15
14
 
16
15
  const number = () => {
17
- const _a = useProps() || {}, { max: max$1, min: min$1 } = _a, props = __rest(_a, ["max", "min"]);
16
+ const { exclusiveMaximum, exclusiveMinimum, format, max: max$1, min: min$1, multipleOf, ...props } = useProps() || {};
18
17
  const schema = useSchemaType('number', props);
19
- // @ts-expect-error: FIXME
20
- schema.minimum = min$1;
21
- // @ts-expect-error: FIXME
22
- schema.maximum = max$1;
18
+ if (schema) {
19
+ if (format !== undefined) {
20
+ schema.format = format;
21
+ }
22
+ if (min$1 !== undefined) {
23
+ schema.minimum = min$1;
24
+ }
25
+ if (max$1 !== undefined) {
26
+ schema.maximum = max$1;
27
+ }
28
+ if (exclusiveMinimum) {
29
+ schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
30
+ }
31
+ if (exclusiveMaximum) {
32
+ schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
33
+ }
34
+ if (multipleOf !== undefined) {
35
+ schema.multipleOf = Number(multipleOf);
36
+ }
37
+ }
23
38
  const rules = [];
24
39
  if (props.default !== undefined) {
25
40
  rules.push(defaultTo(props.default));
26
41
  }
27
42
  rules.push(num);
28
43
  if (props.values) {
29
- rules.push(values(props.values));
44
+ rules.push(values(getArrayValues(props.values, Number)));
30
45
  }
31
46
  if (min$1 !== undefined) {
32
47
  rules.push(min(min$1));
@@ -2,7 +2,6 @@
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
6
  require('../../../hooks/index.js');
8
7
  require('../../../hooks/useParentRule/index.js');
@@ -18,19 +17,35 @@ var useRule = require('../../../hooks/useRule/useRule.js');
18
17
  var pipe = require('../../../utils/rules/pipe/pipe.js');
19
18
 
20
19
  const number = () => {
21
- const _a = jsx.useProps() || {}, { max: max$1, min: min$1 } = _a, props = tslib.__rest(_a, ["max", "min"]);
20
+ const { exclusiveMaximum, exclusiveMinimum, format, max: max$1, min: min$1, multipleOf, ...props } = jsx.useProps() || {};
22
21
  const schema = useSchemaType.useSchemaType('number', props);
23
- // @ts-expect-error: FIXME
24
- schema.minimum = min$1;
25
- // @ts-expect-error: FIXME
26
- schema.maximum = max$1;
22
+ if (schema) {
23
+ if (format !== undefined) {
24
+ schema.format = format;
25
+ }
26
+ if (min$1 !== undefined) {
27
+ schema.minimum = min$1;
28
+ }
29
+ if (max$1 !== undefined) {
30
+ schema.maximum = max$1;
31
+ }
32
+ if (exclusiveMinimum) {
33
+ schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
34
+ }
35
+ if (exclusiveMaximum) {
36
+ schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
37
+ }
38
+ if (multipleOf !== undefined) {
39
+ schema.multipleOf = Number(multipleOf);
40
+ }
41
+ }
27
42
  const rules = [];
28
43
  if (props.default !== undefined) {
29
44
  rules.push(defaultTo.defaultTo(props.default));
30
45
  }
31
46
  rules.push(num.num);
32
47
  if (props.values) {
33
- rules.push(values.values(props.values));
48
+ rules.push(values.values(values.getArrayValues(props.values, Number)));
34
49
  }
35
50
  if (min$1 !== undefined) {
36
51
  rules.push(min.min(min$1));
@@ -1,7 +1,5 @@
1
- import { __rest } from 'tslib';
2
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
3
2
  import { useProps } from '@innet/jsx';
4
- import { callHandler } from '@innet/utils';
5
3
  import '../../../hooks/index.es6.js';
6
4
  import '../../../hooks/useParentRule/index.es6.js';
7
5
  import '../../../utils/index.es6.js';
@@ -16,10 +14,12 @@ import { objectOf } from '../../../utils/rules/objectOf/objectOf.es6.js';
16
14
  import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
17
15
  import { useRule, ruleContext } from '../../../hooks/useRule/useRule.es6.js';
18
16
  import { objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es6.js';
17
+ import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
18
+ import { getSafeSchema } from '../../../utils/getSafeSchema/getSafeSchema.es6.js';
19
19
 
20
20
  const object = () => {
21
21
  useBlock('path');
22
- const _a = useProps(), { children } = _a, props = __rest(_a, ["children"]);
22
+ const { children, ...props } = useProps();
23
23
  const { refRules } = useApi();
24
24
  const schema = useSchemaType('object', props);
25
25
  const handler = useNewHandler();
@@ -53,11 +53,12 @@ const object = () => {
53
53
  });
54
54
  parentRuleContext.reset(handler);
55
55
  innet(children, handler);
56
- innet(() => {
57
- if (!Object.keys(schema.additionalProperties).length) {
58
- delete schema.additionalProperties;
56
+ useEffect(() => {
57
+ const safeSchema = getSafeSchema(schema);
58
+ if (!Object.keys(safeSchema.additionalProperties).length) {
59
+ delete safeSchema.additionalProperties;
59
60
  }
60
- }, callHandler);
61
+ });
61
62
  }
62
63
  else if (props.ref) {
63
64
  useRule(refRules[props.ref]);
@@ -2,10 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var innet = require('innet');
7
6
  var jsx = require('@innet/jsx');
8
- var utils = require('@innet/utils');
9
7
  require('../../../hooks/index.js');
10
8
  require('../../../hooks/useParentRule/index.js');
11
9
  require('../../../utils/index.js');
@@ -20,14 +18,12 @@ var objectOf = require('../../../utils/rules/objectOf/objectOf.js');
20
18
  var pipe = require('../../../utils/rules/pipe/pipe.js');
21
19
  var useRule = require('../../../hooks/useRule/useRule.js');
22
20
  var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
23
-
24
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
25
-
26
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
21
+ var useEffect = require('../../../hooks/useEffect/useEffect.js');
22
+ var getSafeSchema = require('../../../utils/getSafeSchema/getSafeSchema.js');
27
23
 
28
24
  const object = () => {
29
25
  useBlock.useBlock('path');
30
- const _a = jsx.useProps(), { children } = _a, props = tslib.__rest(_a, ["children"]);
26
+ const { children, ...props } = jsx.useProps();
31
27
  const { refRules } = useApi.useApi();
32
28
  const schema = useSchemaType.useSchemaType('object', props);
33
29
  const handler = innet.useNewHandler();
@@ -60,12 +56,13 @@ const object = () => {
60
56
  childRule = rule;
61
57
  });
62
58
  useParentRule.parentRuleContext.reset(handler);
63
- innet__default["default"](children, handler);
64
- innet__default["default"](() => {
65
- if (!Object.keys(schema.additionalProperties).length) {
66
- delete schema.additionalProperties;
59
+ innet.innet(children, handler);
60
+ useEffect.useEffect(() => {
61
+ const safeSchema = getSafeSchema.getSafeSchema(schema);
62
+ if (!Object.keys(safeSchema.additionalProperties).length) {
63
+ delete safeSchema.additionalProperties;
67
64
  }
68
- }, utils.callHandler);
65
+ });
69
66
  }
70
67
  else if (props.ref) {
71
68
  useRule.useRule(refRules[props.ref]);
@@ -1,9 +1,36 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type ValuesSchemaProps } from '../../../types';
3
3
  export interface StringProps extends ValuesSchemaProps<string> {
4
+ /**
5
+ * An optional format modifier serves as a hint at the contents and format of the string.
6
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
7
+ * */
8
+ format?: 'binary' | 'byte' | 'date' | 'date-time' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'password' | 'uri' | 'uuid' | (string & {});
9
+ /**
10
+ * String length can be restricted using `min` and `max`.
11
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
12
+ * */
4
13
  max?: number;
14
+ /**
15
+ * String length can be restricted using `min` and `max`.
16
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
17
+ * */
5
18
  min?: number;
19
+ /**
20
+ * The pattern keyword lets you define a regular expression template for the string value.
21
+ * Only the values that match this template will be accepted.
22
+ * The regular expression syntax used is from JavaScript (more specifically, ECMA 262).
23
+ * Regular expressions are case-sensitive, that is, [a-z] and [A-Z] are different expressions.
24
+ * @example For example, the following pattern matches a Social Security Number (SSN) in the 123-45-6789 format:
25
+ * ```tsx
26
+ * <string pattern='^\d{3}-\d{2}-\d{4}$' />
27
+ * ```
28
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
29
+ * */
6
30
  pattern?: RegExp | string;
31
+ /**
32
+ * The `patternId` keyword is used to reference a pattern from the OpenAPI specification.
33
+ * */
7
34
  patternId?: string;
8
35
  }
9
36
  export declare const string: HandlerPlugin;
@@ -1,4 +1,3 @@
1
- import { __rest } from 'tslib';
2
1
  import { useProps } from '@innet/jsx';
3
2
  import '../../../hooks/index.es6.js';
4
3
  import '../../../hooks/useParentRule/index.es6.js';
@@ -6,7 +5,7 @@ import '../../../utils/index.es6.js';
6
5
  import { useApi } from '../../../hooks/useApi/useApi.es6.js';
7
6
  import { useSchemaType } from '../../../hooks/useSchemaType/useSchemaType.es6.js';
8
7
  import { defaultTo } from '../../../utils/rules/defaultTo/defaultTo.es6.js';
9
- import { values } from '../../../utils/rules/values/values.es6.js';
8
+ import { values, getArrayValues } from '../../../utils/rules/values/values.es6.js';
10
9
  import { minLength } from '../../../utils/rules/minLength/minLength.es6.js';
11
10
  import { maxLength } from '../../../utils/rules/maxLength/maxLength.es6.js';
12
11
  import { pattern } from '../../../utils/rules/pattern/pattern.es6.js';
@@ -15,24 +14,30 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
15
14
  import { useParentRule } from '../../../hooks/useParentRule/useParentRule.es6.js';
16
15
 
17
16
  const string = () => {
18
- const _a = useProps() || {}, { max, min, pattern: pattern$1, patternId } = _a, props = __rest(_a, ["max", "min", "pattern", "patternId"]);
17
+ const { format, max, min, pattern: pattern$1, patternId, ...props } = useProps() || {};
19
18
  const { refRules } = useApi();
20
19
  const schema = useSchemaType('string', props);
21
20
  if (schema) {
22
21
  const rules = [];
22
+ if (format !== undefined) {
23
+ schema.format = format;
24
+ }
23
25
  if (props.default !== undefined) {
24
26
  rules.push(defaultTo(props.default));
25
27
  }
26
28
  rules.push(String);
27
29
  if (props.values) {
28
- rules.push(values(props.values));
30
+ rules.push(values(getArrayValues(props.values)));
31
+ }
32
+ if (format !== undefined) {
33
+ schema.format = format;
29
34
  }
30
35
  if (min !== undefined) {
31
- schema.minimum = min;
36
+ schema.minLength = min;
32
37
  rules.push(minLength(min));
33
38
  }
34
39
  if (max !== undefined) {
35
- schema.maximum = max;
40
+ schema.maxLength = max;
36
41
  rules.push(maxLength(max));
37
42
  }
38
43
  if (pattern$1 !== undefined) {
@@ -2,7 +2,6 @@
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
6
  require('../../../hooks/index.js');
8
7
  require('../../../hooks/useParentRule/index.js');
@@ -19,24 +18,30 @@ var useRule = require('../../../hooks/useRule/useRule.js');
19
18
  var useParentRule = require('../../../hooks/useParentRule/useParentRule.js');
20
19
 
21
20
  const string = () => {
22
- const _a = jsx.useProps() || {}, { max, min, pattern: pattern$1, patternId } = _a, props = tslib.__rest(_a, ["max", "min", "pattern", "patternId"]);
21
+ const { format, max, min, pattern: pattern$1, patternId, ...props } = jsx.useProps() || {};
23
22
  const { refRules } = useApi.useApi();
24
23
  const schema = useSchemaType.useSchemaType('string', props);
25
24
  if (schema) {
26
25
  const rules = [];
26
+ if (format !== undefined) {
27
+ schema.format = format;
28
+ }
27
29
  if (props.default !== undefined) {
28
30
  rules.push(defaultTo.defaultTo(props.default));
29
31
  }
30
32
  rules.push(String);
31
33
  if (props.values) {
32
- rules.push(values.values(props.values));
34
+ rules.push(values.values(values.getArrayValues(props.values)));
35
+ }
36
+ if (format !== undefined) {
37
+ schema.format = format;
33
38
  }
34
39
  if (min !== undefined) {
35
- schema.minimum = min;
40
+ schema.minLength = min;
36
41
  rules.push(minLength.minLength(min));
37
42
  }
38
43
  if (max !== undefined) {
39
- schema.maximum = max;
44
+ schema.maxLength = max;
40
45
  rules.push(maxLength.maxLength(max));
41
46
  }
42
47
  if (pattern$1 !== undefined) {
@@ -1,7 +1,5 @@
1
- import { __rest } from 'tslib';
2
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
3
2
  import { useProps } from '@innet/jsx';
4
- import { callHandler } from '@innet/utils';
5
3
  import '../../../hooks/index.es6.js';
6
4
  import '../../../hooks/useParentRule/index.es6.js';
7
5
  import '../../../utils/index.es6.js';
@@ -14,11 +12,12 @@ import { useParentRule, parentRuleContext } from '../../../hooks/useParentRule/u
14
12
  import { useRule, ruleContext } from '../../../hooks/useRule/useRule.es6.js';
15
13
  import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
16
14
  import { required } from '../../../utils/rules/required/required.es6.js';
15
+ import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
17
16
 
18
17
  const tuple = () => {
19
18
  useBlock('path');
20
19
  const handler = useNewHandler();
21
- const _a = useProps(), { children } = _a, props = __rest(_a, ["children"]);
20
+ const { children, ...props } = useProps();
22
21
  const schema = useSchemaType('array', props);
23
22
  if (schema) {
24
23
  const schemas = [];
@@ -43,11 +42,11 @@ const tuple = () => {
43
42
  rulesMap.push(rule);
44
43
  });
45
44
  innet(children, handler);
46
- innet(() => {
45
+ useEffect(() => {
47
46
  if (!rulesMap.length) {
48
47
  throw Error('<tuple> MUST have content');
49
48
  }
50
- }, callHandler);
49
+ });
51
50
  }
52
51
  };
53
52
 
@@ -2,10 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var innet = require('innet');
7
6
  var jsx = require('@innet/jsx');
8
- var utils = require('@innet/utils');
9
7
  require('../../../hooks/index.js');
10
8
  require('../../../hooks/useParentRule/index.js');
11
9
  require('../../../utils/index.js');
@@ -18,15 +16,12 @@ var useParentRule = require('../../../hooks/useParentRule/useParentRule.js');
18
16
  var useRule = require('../../../hooks/useRule/useRule.js');
19
17
  var pipe = require('../../../utils/rules/pipe/pipe.js');
20
18
  var required = require('../../../utils/rules/required/required.js');
21
-
22
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
-
24
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
19
+ var useEffect = require('../../../hooks/useEffect/useEffect.js');
25
20
 
26
21
  const tuple = () => {
27
22
  useBlock.useBlock('path');
28
23
  const handler = innet.useNewHandler();
29
- const _a = jsx.useProps(), { children } = _a, props = tslib.__rest(_a, ["children"]);
24
+ const { children, ...props } = jsx.useProps();
30
25
  const schema = useSchemaType.useSchemaType('array', props);
31
26
  if (schema) {
32
27
  const schemas = [];
@@ -50,12 +45,12 @@ const tuple = () => {
50
45
  useRule.ruleContext.set(handler, rule => {
51
46
  rulesMap.push(rule);
52
47
  });
53
- innet__default["default"](children, handler);
54
- innet__default["default"](() => {
48
+ innet.innet(children, handler);
49
+ useEffect.useEffect(() => {
55
50
  if (!rulesMap.length) {
56
51
  throw Error('<tuple> MUST have content');
57
52
  }
58
- }, utils.callHandler);
53
+ });
59
54
  }
60
55
  };
61
56
 
@@ -1,4 +1,3 @@
1
- import { __rest } from 'tslib';
2
1
  import { useProps } from '@innet/jsx';
3
2
  import { v4 } from 'uuid';
4
3
  import '../../../hooks/index.es6.js';
@@ -6,14 +5,17 @@ import '../../../utils/index.es6.js';
6
5
  import { useSchemaType } from '../../../hooks/useSchemaType/useSchemaType.es6.js';
7
6
  import { defaultTo } from '../../../utils/rules/defaultTo/defaultTo.es6.js';
8
7
  import { uuidTo } from '../../../utils/rules/uuidTo/uuidTo.es6.js';
9
- import { values } from '../../../utils/rules/values/values.es6.js';
8
+ import { values, getArrayValues } from '../../../utils/rules/values/values.es6.js';
10
9
  import { useRule } from '../../../hooks/useRule/useRule.es6.js';
11
10
  import { optional } from '../../../utils/rules/optional/optional.es6.js';
12
11
  import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
13
12
 
14
13
  const uuid = () => {
15
- const _a = useProps(), { default: defaultValue } = _a, props = __rest(_a, ["default"]);
16
- const schema = useSchemaType('string', Object.assign(Object.assign({}, props), { default: defaultValue === 'new' ? undefined : defaultValue }));
14
+ const { default: defaultValue, ...props } = useProps();
15
+ const schema = useSchemaType('string', {
16
+ ...props,
17
+ default: defaultValue === 'new' ? undefined : defaultValue,
18
+ });
17
19
  // @ts-expect-error: FIXME
18
20
  schema.format = 'uuid';
19
21
  if (defaultValue === 'new') {
@@ -26,7 +28,7 @@ const uuid = () => {
26
28
  }
27
29
  rules.push(uuidTo);
28
30
  if (props.values) {
29
- rules.push(values(props.values));
31
+ rules.push(values(getArrayValues(props.values)));
30
32
  }
31
33
  if (defaultValue === undefined) {
32
34
  useRule(optional(pipe(...rules)));
@@ -2,7 +2,6 @@
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
6
  var uuid$1 = require('uuid');
8
7
  require('../../../hooks/index.js');
@@ -16,8 +15,11 @@ var optional = require('../../../utils/rules/optional/optional.js');
16
15
  var pipe = require('../../../utils/rules/pipe/pipe.js');
17
16
 
18
17
  const uuid = () => {
19
- const _a = jsx.useProps(), { default: defaultValue } = _a, props = tslib.__rest(_a, ["default"]);
20
- const schema = useSchemaType.useSchemaType('string', Object.assign(Object.assign({}, props), { default: defaultValue === 'new' ? undefined : defaultValue }));
18
+ const { default: defaultValue, ...props } = jsx.useProps();
19
+ const schema = useSchemaType.useSchemaType('string', {
20
+ ...props,
21
+ default: defaultValue === 'new' ? undefined : defaultValue,
22
+ });
21
23
  // @ts-expect-error: FIXME
22
24
  schema.format = 'uuid';
23
25
  if (defaultValue === 'new') {
@@ -30,7 +32,7 @@ const uuid = () => {
30
32
  }
31
33
  rules.push(uuidTo.uuidTo);
32
34
  if (props.values) {
33
- rules.push(values.values(props.values));
35
+ rules.push(values.values(values.getArrayValues(props.values)));
34
36
  }
35
37
  if (defaultValue === undefined) {
36
38
  useRule.useRule(optional.optional(pipe.pipe(...rules)));
@@ -3,13 +3,16 @@ import { promises } from 'node:fs';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import '../../../utils/index.es6.js';
5
5
  import { useApi } from '../../../hooks/useApi/useApi.es6.js';
6
+ import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
6
7
  import { generateTypes } from '../../../utils/generateTypes/generateTypes.es6.js';
7
8
 
8
9
  const dts = () => {
9
10
  const { namespace = process.env.INNET_DTS_NAMESPACE, path = process.env.INNET_DTS_PATH || 'src/apiTypes.d.ts', } = useProps() || {};
10
11
  const { docs } = useApi();
11
- promises.writeFile(path, generateTypes(docs, namespace)).catch(e => {
12
- console.error(e);
12
+ useEffect(() => {
13
+ promises.writeFile(path, generateTypes(docs, namespace)).catch(e => {
14
+ console.error(e);
15
+ });
13
16
  });
14
17
  };
15
18
 
@@ -7,13 +7,16 @@ var fs = require('node:fs');
7
7
  require('../../../hooks/index.js');
8
8
  require('../../../utils/index.js');
9
9
  var useApi = require('../../../hooks/useApi/useApi.js');
10
+ var useEffect = require('../../../hooks/useEffect/useEffect.js');
10
11
  var generateTypes = require('../../../utils/generateTypes/generateTypes.js');
11
12
 
12
13
  const dts = () => {
13
14
  const { namespace = process.env.INNET_DTS_NAMESPACE, path = process.env.INNET_DTS_PATH || 'src/apiTypes.d.ts', } = jsx.useProps() || {};
14
15
  const { docs } = useApi.useApi();
15
- fs.promises.writeFile(path, generateTypes.generateTypes(docs, namespace)).catch(e => {
16
- console.error(e);
16
+ useEffect.useEffect(() => {
17
+ fs.promises.writeFile(path, generateTypes.generateTypes(docs, namespace)).catch(e => {
18
+ console.error(e);
19
+ });
17
20
  });
18
21
  };
19
22
 
@@ -1,4 +1,4 @@
1
- import innet, { useHandler } from 'innet';
1
+ import { innet, useHandler } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
3
 
4
4
  const env = () => {