@innet/server 2.0.0-beta.3 → 2.0.0-beta.5

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 (84) hide show
  1. package/README.md +215 -0
  2. package/handler/handler.d.ts +1 -1
  3. package/hooks/index.d.ts +24 -23
  4. package/hooks/index.es6.js +24 -23
  5. package/hooks/index.js +24 -23
  6. package/hooks/useEffect/index.d.ts +1 -0
  7. package/hooks/useEffect/index.es6.js +1 -0
  8. package/hooks/useEffect/index.js +9 -0
  9. package/hooks/useEffect/useEffect.d.ts +2 -0
  10. package/hooks/useEffect/useEffect.es6.js +8 -0
  11. package/hooks/useEffect/useEffect.js +12 -0
  12. package/index.d.ts +2 -2
  13. package/index.es6.js +86 -85
  14. package/index.js +195 -193
  15. package/package.json +7 -5
  16. package/plugins/handler/serverFn/serverFn.es6.js +1 -1
  17. package/plugins/handler/serverFn/serverFn.js +1 -5
  18. package/plugins/index.d.ts +2 -2
  19. package/plugins/index.es6.js +2 -2
  20. package/plugins/index.js +2 -2
  21. package/plugins/main/api/api.es6.js +1 -1
  22. package/plugins/main/api/api.js +3 -7
  23. package/plugins/main/body/body.es6.js +4 -4
  24. package/plugins/main/body/body.js +4 -8
  25. package/plugins/main/endpoint/endpoint.es6.js +4 -4
  26. package/plugins/main/endpoint/endpoint.js +4 -8
  27. package/plugins/main/host/host.es6.js +1 -1
  28. package/plugins/main/host/host.js +1 -5
  29. package/plugins/main/index.d.ts +8 -8
  30. package/plugins/main/index.es6.js +8 -8
  31. package/plugins/main/index.js +8 -8
  32. package/plugins/main/param/param.es6.js +1 -1
  33. package/plugins/main/param/param.js +1 -5
  34. package/plugins/main/preset/preset.es6.js +1 -1
  35. package/plugins/main/preset/preset.js +1 -5
  36. package/plugins/main/response/response.es6.js +1 -1
  37. package/plugins/main/response/response.js +1 -5
  38. package/plugins/main/server/server.es6.js +1 -1
  39. package/plugins/main/server/server.js +2 -3
  40. package/plugins/main/tag/tag.es6.js +1 -1
  41. package/plugins/main/tag/tag.js +1 -5
  42. package/plugins/request/cms/cms.es6.js +1 -1
  43. package/plugins/request/cms/cms.js +2 -3
  44. package/plugins/request/file/file.es6.js +1 -1
  45. package/plugins/request/file/file.js +1 -2
  46. package/plugins/request/index.d.ts +5 -5
  47. package/plugins/request/index.es6.js +5 -5
  48. package/plugins/request/index.js +5 -5
  49. package/plugins/schema/array/array.d.ts +3 -0
  50. package/plugins/schema/array/array.es6.js +14 -5
  51. package/plugins/schema/array/array.js +15 -10
  52. package/plugins/schema/field/field.d.ts +2 -0
  53. package/plugins/schema/field/field.es6.js +8 -2
  54. package/plugins/schema/field/field.js +8 -6
  55. package/plugins/schema/index.d.ts +8 -8
  56. package/plugins/schema/index.es6.js +8 -8
  57. package/plugins/schema/index.js +8 -8
  58. package/plugins/schema/integer/integer.d.ts +37 -0
  59. package/plugins/schema/integer/integer.es6.js +21 -7
  60. package/plugins/schema/integer/integer.js +21 -7
  61. package/plugins/schema/number/number.d.ts +32 -0
  62. package/plugins/schema/number/number.es6.js +21 -5
  63. package/plugins/schema/number/number.js +21 -5
  64. package/plugins/schema/object/object.es6.js +4 -4
  65. package/plugins/schema/object/object.js +4 -8
  66. package/plugins/schema/string/string.d.ts +27 -0
  67. package/plugins/schema/string/string.es6.js +9 -3
  68. package/plugins/schema/string/string.js +9 -3
  69. package/plugins/schema/tuple/tuple.es6.js +4 -4
  70. package/plugins/schema/tuple/tuple.js +4 -8
  71. package/plugins/utils/dts/dts.es6.js +5 -2
  72. package/plugins/utils/dts/dts.js +5 -2
  73. package/plugins/utils/env/env.es6.js +1 -1
  74. package/plugins/utils/env/env.js +1 -5
  75. package/plugins/utils/index.d.ts +2 -2
  76. package/plugins/utils/index.es6.js +2 -2
  77. package/plugins/utils/index.js +2 -2
  78. package/types.d.ts +1 -0
  79. package/utils/index.d.ts +8 -8
  80. package/utils/index.es6.js +8 -8
  81. package/utils/index.js +8 -8
  82. package/utils/rules/index.d.ts +17 -17
  83. package/utils/rules/index.es6.js +17 -17
  84. package/utils/rules/index.js +18 -18
@@ -1,13 +1,13 @@
1
- import './object/index.es6.js';
2
- import './field/index.es6.js';
3
- import './number/index.es6.js';
4
- import './integer/index.es6.js';
5
- import './string/index.es6.js';
1
+ import './any/index.es6.js';
6
2
  import './array/index.es6.js';
3
+ import './binary/index.es6.js';
7
4
  import './boolean/index.es6.js';
8
- import './null/index.es6.js';
9
5
  import './date/index.es6.js';
6
+ import './field/index.es6.js';
7
+ import './integer/index.es6.js';
8
+ import './null/index.es6.js';
9
+ import './number/index.es6.js';
10
+ import './object/index.es6.js';
11
+ import './string/index.es6.js';
10
12
  import './tuple/index.es6.js';
11
13
  import './uuid/index.es6.js';
12
- import './binary/index.es6.js';
13
- import './any/index.es6.js';
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- require('./object/index.js');
4
- require('./field/index.js');
5
- require('./number/index.js');
6
- require('./integer/index.js');
7
- require('./string/index.js');
3
+ require('./any/index.js');
8
4
  require('./array/index.js');
5
+ require('./binary/index.js');
9
6
  require('./boolean/index.js');
10
- require('./null/index.js');
11
7
  require('./date/index.js');
8
+ require('./field/index.js');
9
+ require('./integer/index.js');
10
+ require('./null/index.js');
11
+ require('./number/index.js');
12
+ require('./object/index.js');
13
+ require('./string/index.js');
12
14
  require('./tuple/index.js');
13
15
  require('./uuid/index.js');
14
- require('./binary/index.js');
15
- require('./any/index.js');
16
16
 
@@ -1,8 +1,45 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type IntegerFormats, type ValuesSchemaProps } from '../../../types';
3
3
  export interface IntegerProps extends ValuesSchemaProps<bigint | 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
+ * <integer exclusiveMaximum={10} />
9
+ * ```
10
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
11
+ * */
12
+ exclusiveMaximum?: bigint | boolean | number;
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
+ * <integer exclusiveMinimum={10} />
18
+ * ```
19
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
20
+ * */
21
+ exclusiveMinimum?: bigint | boolean | number;
22
+ /**
23
+ * An optional format modifier serves as a hint at the contents and format of the string.
24
+ * @example For example, the following value is valid:
25
+ * ```tsx
26
+ * <integer format='int64' />
27
+ * ```
28
+ * @see https://swagger.io/docs/specification/data-models/data-types/#numbers
29
+ * */
4
30
  format?: IntegerFormats;
31
+ /** Validate the integer number value by maximum. */
5
32
  max?: bigint | number;
33
+ /** Validate the integer number value by minimum. */
6
34
  min?: bigint | number;
35
+ /**
36
+ * The `multipleOf` keyword is used to restrict the value to be a multiple of the specified number.
37
+ * @example For example, the following value is valid:
38
+ * ```tsx
39
+ * <number multipleOf={2} />
40
+ * ```
41
+ * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
42
+ * */
43
+ multipleOf?: bigint | number;
7
44
  }
8
45
  export declare const integer: HandlerPlugin;
@@ -12,7 +12,7 @@ import { optional } from '../../../utils/rules/optional/optional.es6.js';
12
12
  import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
13
13
 
14
14
  const integer = () => {
15
- const { default: defaultValue, example, examples, format = 'int32', max: max$1, min: min$1, values: values$1, ...props } = useProps() || {};
15
+ const { default: defaultValue, example, examples, exclusiveMaximum, exclusiveMinimum, format = 'int32', max: max$1, min: min$1, multipleOf, values: values$1, ...props } = useProps() || {};
16
16
  const schema = useSchemaType('integer', {
17
17
  ...props,
18
18
  default: defaultValue !== undefined ? Number(defaultValue) : undefined,
@@ -20,12 +20,26 @@ const integer = () => {
20
20
  examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
21
21
  values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number),
22
22
  });
23
- // @ts-expect-error: FIXME
24
- schema.format = format;
25
- // @ts-expect-error: FIXME
26
- schema.minimum = min$1 !== undefined ? Number(min$1) : undefined;
27
- // @ts-expect-error: FIXME
28
- schema.maximum = max$1 !== undefined ? Number(max$1) : undefined;
23
+ if (schema) {
24
+ if (format) {
25
+ schema.format = format;
26
+ }
27
+ if (min$1 !== undefined) {
28
+ schema.minimum = Number(min$1);
29
+ }
30
+ if (max$1 !== undefined) {
31
+ schema.maximum = Number(max$1);
32
+ }
33
+ if (exclusiveMinimum) {
34
+ schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
35
+ }
36
+ if (exclusiveMaximum) {
37
+ schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
38
+ }
39
+ if (multipleOf !== undefined) {
40
+ schema.multipleOf = Number(multipleOf);
41
+ }
42
+ }
29
43
  const rules = [];
30
44
  if (defaultValue !== undefined) {
31
45
  rules.push(defaultTo(defaultValue));
@@ -16,7 +16,7 @@ var optional = require('../../../utils/rules/optional/optional.js');
16
16
  var pipe = require('../../../utils/rules/pipe/pipe.js');
17
17
 
18
18
  const integer = () => {
19
- const { default: defaultValue, example, examples, format = 'int32', max: max$1, min: min$1, values: values$1, ...props } = jsx.useProps() || {};
19
+ const { default: defaultValue, example, examples, exclusiveMaximum, exclusiveMinimum, format = 'int32', max: max$1, min: min$1, multipleOf, values: values$1, ...props } = jsx.useProps() || {};
20
20
  const schema = useSchemaType.useSchemaType('integer', {
21
21
  ...props,
22
22
  default: defaultValue !== undefined ? Number(defaultValue) : undefined,
@@ -24,12 +24,26 @@ const integer = () => {
24
24
  examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
25
25
  values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number),
26
26
  });
27
- // @ts-expect-error: FIXME
28
- schema.format = format;
29
- // @ts-expect-error: FIXME
30
- schema.minimum = min$1 !== undefined ? Number(min$1) : undefined;
31
- // @ts-expect-error: FIXME
32
- schema.maximum = max$1 !== undefined ? Number(max$1) : undefined;
27
+ if (schema) {
28
+ if (format) {
29
+ schema.format = format;
30
+ }
31
+ if (min$1 !== undefined) {
32
+ schema.minimum = Number(min$1);
33
+ }
34
+ if (max$1 !== undefined) {
35
+ schema.maximum = Number(max$1);
36
+ }
37
+ if (exclusiveMinimum) {
38
+ schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
39
+ }
40
+ if (exclusiveMaximum) {
41
+ schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
42
+ }
43
+ if (multipleOf !== undefined) {
44
+ schema.multipleOf = Number(multipleOf);
45
+ }
46
+ }
33
47
  const rules = [];
34
48
  if (defaultValue !== undefined) {
35
49
  rules.push(defaultTo.defaultTo(defaultValue));
@@ -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;
@@ -13,12 +13,28 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
13
13
  import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
14
14
 
15
15
  const number = () => {
16
- const { max: max$1, min: min$1, ...props } = useProps() || {};
16
+ const { exclusiveMaximum, exclusiveMinimum, format, max: max$1, min: min$1, multipleOf, ...props } = useProps() || {};
17
17
  const schema = useSchemaType('number', props);
18
- // @ts-expect-error: FIXME
19
- schema.minimum = min$1;
20
- // @ts-expect-error: FIXME
21
- 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
+ }
22
38
  const rules = [];
23
39
  if (props.default !== undefined) {
24
40
  rules.push(defaultTo(props.default));
@@ -17,12 +17,28 @@ var useRule = require('../../../hooks/useRule/useRule.js');
17
17
  var pipe = require('../../../utils/rules/pipe/pipe.js');
18
18
 
19
19
  const number = () => {
20
- const { max: max$1, min: min$1, ...props } = jsx.useProps() || {};
20
+ const { exclusiveMaximum, exclusiveMinimum, format, max: max$1, min: min$1, multipleOf, ...props } = jsx.useProps() || {};
21
21
  const schema = useSchemaType.useSchemaType('number', props);
22
- // @ts-expect-error: FIXME
23
- schema.minimum = min$1;
24
- // @ts-expect-error: FIXME
25
- 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
+ }
26
42
  const rules = [];
27
43
  if (props.default !== undefined) {
28
44
  rules.push(defaultTo.defaultTo(props.default));
@@ -1,6 +1,5 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
- import { callHandler } from '@innet/utils';
4
3
  import '../../../hooks/index.es6.js';
5
4
  import '../../../hooks/useParentRule/index.es6.js';
6
5
  import '../../../utils/index.es6.js';
@@ -15,6 +14,7 @@ import { objectOf } from '../../../utils/rules/objectOf/objectOf.es6.js';
15
14
  import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
16
15
  import { useRule, ruleContext } from '../../../hooks/useRule/useRule.es6.js';
17
16
  import { objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es6.js';
17
+ import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
18
18
 
19
19
  const object = () => {
20
20
  useBlock('path');
@@ -52,11 +52,11 @@ const object = () => {
52
52
  });
53
53
  parentRuleContext.reset(handler);
54
54
  innet(children, handler);
55
- innet(() => {
55
+ useEffect(() => {
56
56
  if (!Object.keys(schema.additionalProperties).length) {
57
57
  delete schema.additionalProperties;
58
58
  }
59
- }, callHandler);
59
+ });
60
60
  }
61
61
  else if (props.ref) {
62
62
  useRule(refRules[props.ref]);
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var innet = require('innet');
6
6
  var jsx = require('@innet/jsx');
7
- var utils = require('@innet/utils');
8
7
  require('../../../hooks/index.js');
9
8
  require('../../../hooks/useParentRule/index.js');
10
9
  require('../../../utils/index.js');
@@ -19,10 +18,7 @@ var objectOf = require('../../../utils/rules/objectOf/objectOf.js');
19
18
  var pipe = require('../../../utils/rules/pipe/pipe.js');
20
19
  var useRule = require('../../../hooks/useRule/useRule.js');
21
20
  var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
22
-
23
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
-
25
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
21
+ var useEffect = require('../../../hooks/useEffect/useEffect.js');
26
22
 
27
23
  const object = () => {
28
24
  useBlock.useBlock('path');
@@ -59,12 +55,12 @@ const object = () => {
59
55
  childRule = rule;
60
56
  });
61
57
  useParentRule.parentRuleContext.reset(handler);
62
- innet__default["default"](children, handler);
63
- innet__default["default"](() => {
58
+ innet.innet(children, handler);
59
+ useEffect.useEffect(() => {
64
60
  if (!Object.keys(schema.additionalProperties).length) {
65
61
  delete schema.additionalProperties;
66
62
  }
67
- }, utils.callHandler);
63
+ });
68
64
  }
69
65
  else if (props.ref) {
70
66
  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;
@@ -14,11 +14,14 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
14
14
  import { useParentRule } from '../../../hooks/useParentRule/useParentRule.es6.js';
15
15
 
16
16
  const string = () => {
17
- const { max, min, pattern: pattern$1, patternId, ...props } = useProps() || {};
17
+ const { format, max, min, pattern: pattern$1, patternId, ...props } = useProps() || {};
18
18
  const { refRules } = useApi();
19
19
  const schema = useSchemaType('string', props);
20
20
  if (schema) {
21
21
  const rules = [];
22
+ if (format !== undefined) {
23
+ schema.format = format;
24
+ }
22
25
  if (props.default !== undefined) {
23
26
  rules.push(defaultTo(props.default));
24
27
  }
@@ -26,12 +29,15 @@ const string = () => {
26
29
  if (props.values) {
27
30
  rules.push(values(props.values));
28
31
  }
32
+ if (format !== undefined) {
33
+ schema.format = format;
34
+ }
29
35
  if (min !== undefined) {
30
- schema.minimum = min;
36
+ schema.minLength = min;
31
37
  rules.push(minLength(min));
32
38
  }
33
39
  if (max !== undefined) {
34
- schema.maximum = max;
40
+ schema.maxLength = max;
35
41
  rules.push(maxLength(max));
36
42
  }
37
43
  if (pattern$1 !== undefined) {
@@ -18,11 +18,14 @@ var useRule = require('../../../hooks/useRule/useRule.js');
18
18
  var useParentRule = require('../../../hooks/useParentRule/useParentRule.js');
19
19
 
20
20
  const string = () => {
21
- const { max, min, pattern: pattern$1, patternId, ...props } = jsx.useProps() || {};
21
+ const { format, max, min, pattern: pattern$1, patternId, ...props } = jsx.useProps() || {};
22
22
  const { refRules } = useApi.useApi();
23
23
  const schema = useSchemaType.useSchemaType('string', props);
24
24
  if (schema) {
25
25
  const rules = [];
26
+ if (format !== undefined) {
27
+ schema.format = format;
28
+ }
26
29
  if (props.default !== undefined) {
27
30
  rules.push(defaultTo.defaultTo(props.default));
28
31
  }
@@ -30,12 +33,15 @@ const string = () => {
30
33
  if (props.values) {
31
34
  rules.push(values.values(props.values));
32
35
  }
36
+ if (format !== undefined) {
37
+ schema.format = format;
38
+ }
33
39
  if (min !== undefined) {
34
- schema.minimum = min;
40
+ schema.minLength = min;
35
41
  rules.push(minLength.minLength(min));
36
42
  }
37
43
  if (max !== undefined) {
38
- schema.maximum = max;
44
+ schema.maxLength = max;
39
45
  rules.push(maxLength.maxLength(max));
40
46
  }
41
47
  if (pattern$1 !== undefined) {
@@ -1,6 +1,5 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
- import { callHandler } from '@innet/utils';
4
3
  import '../../../hooks/index.es6.js';
5
4
  import '../../../hooks/useParentRule/index.es6.js';
6
5
  import '../../../utils/index.es6.js';
@@ -13,6 +12,7 @@ import { useParentRule, parentRuleContext } from '../../../hooks/useParentRule/u
13
12
  import { useRule, ruleContext } from '../../../hooks/useRule/useRule.es6.js';
14
13
  import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
15
14
  import { required } from '../../../utils/rules/required/required.es6.js';
15
+ import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
16
16
 
17
17
  const tuple = () => {
18
18
  useBlock('path');
@@ -42,11 +42,11 @@ const tuple = () => {
42
42
  rulesMap.push(rule);
43
43
  });
44
44
  innet(children, handler);
45
- innet(() => {
45
+ useEffect(() => {
46
46
  if (!rulesMap.length) {
47
47
  throw Error('<tuple> MUST have content');
48
48
  }
49
- }, callHandler);
49
+ });
50
50
  }
51
51
  };
52
52
 
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var innet = require('innet');
6
6
  var jsx = require('@innet/jsx');
7
- var utils = require('@innet/utils');
8
7
  require('../../../hooks/index.js');
9
8
  require('../../../hooks/useParentRule/index.js');
10
9
  require('../../../utils/index.js');
@@ -17,10 +16,7 @@ var useParentRule = require('../../../hooks/useParentRule/useParentRule.js');
17
16
  var useRule = require('../../../hooks/useRule/useRule.js');
18
17
  var pipe = require('../../../utils/rules/pipe/pipe.js');
19
18
  var required = require('../../../utils/rules/required/required.js');
20
-
21
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
-
23
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
19
+ var useEffect = require('../../../hooks/useEffect/useEffect.js');
24
20
 
25
21
  const tuple = () => {
26
22
  useBlock.useBlock('path');
@@ -49,12 +45,12 @@ const tuple = () => {
49
45
  useRule.ruleContext.set(handler, rule => {
50
46
  rulesMap.push(rule);
51
47
  });
52
- innet__default["default"](children, handler);
53
- innet__default["default"](() => {
48
+ innet.innet(children, handler);
49
+ useEffect.useEffect(() => {
54
50
  if (!rulesMap.length) {
55
51
  throw Error('<tuple> MUST have content');
56
52
  }
57
- }, utils.callHandler);
53
+ });
58
54
  }
59
55
  };
60
56
 
@@ -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 = () => {
@@ -5,14 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var innet = require('innet');
6
6
  var jsx = require('@innet/jsx');
7
7
 
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
11
-
12
8
  const env = () => {
13
9
  const { children, is, of = 'NODE_ENV', } = jsx.useProps();
14
10
  if (Array.isArray(is) ? is.includes(process.env[of]) : process.env[of] === is) {
15
- innet__default["default"](children, innet.useHandler());
11
+ innet.innet(children, innet.useHandler());
16
12
  }
17
13
  };
18
14
 
@@ -1,6 +1,6 @@
1
- export * from './swagger';
1
+ export * from './blacklist';
2
2
  export * from './dts';
3
3
  export * from './env';
4
4
  export * from './protection';
5
- export * from './blacklist';
5
+ export * from './swagger';
6
6
  export * from './whitelist';
@@ -1,6 +1,6 @@
1
- import './swagger/index.es6.js';
1
+ import './blacklist/index.es6.js';
2
2
  import './dts/index.es6.js';
3
3
  import './env/index.es6.js';
4
4
  import './protection/index.es6.js';
5
- import './blacklist/index.es6.js';
5
+ import './swagger/index.es6.js';
6
6
  import './whitelist/index.es6.js';
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- require('./swagger/index.js');
3
+ require('./blacklist/index.js');
4
4
  require('./dts/index.js');
5
5
  require('./env/index.js');
6
6
  require('./protection/index.js');
7
- require('./blacklist/index.js');
7
+ require('./swagger/index.js');
8
8
  require('./whitelist/index.js');
9
9
 
package/types.d.ts CHANGED
@@ -16,6 +16,7 @@ export type ParameterObject = API.ParameterObject;
16
16
  export type RequestBodyObject = API.RequestBodyObject;
17
17
  export type ObjectType = ArraySchemaObjectType | NonArraySchemaObjectType;
18
18
  export type RefSchemaObject = ReferenceObject | SchemaObject;
19
+ export type Effect = () => void;
19
20
  export interface IValidationErrorData extends Record<string, any> {
20
21
  error: RulesErrors;
21
22
  }