@innet/server 2.0.0-beta.4 → 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.
- package/README.md +215 -0
- package/handler/handler.d.ts +1 -1
- package/hooks/index.d.ts +24 -24
- package/hooks/index.es6.js +24 -24
- package/hooks/index.js +24 -24
- package/index.d.ts +2 -2
- package/index.es6.js +86 -86
- package/index.js +195 -195
- package/package.json +3 -3
- package/plugins/index.d.ts +2 -2
- package/plugins/index.es6.js +2 -2
- package/plugins/index.js +2 -2
- package/plugins/main/index.d.ts +8 -8
- package/plugins/main/index.es6.js +8 -8
- package/plugins/main/index.js +8 -8
- package/plugins/request/index.d.ts +5 -5
- package/plugins/request/index.es6.js +5 -5
- package/plugins/request/index.js +5 -5
- package/plugins/schema/array/array.d.ts +3 -0
- package/plugins/schema/array/array.es6.js +10 -1
- package/plugins/schema/array/array.js +10 -1
- package/plugins/schema/field/field.d.ts +2 -0
- package/plugins/schema/field/field.es6.js +7 -1
- package/plugins/schema/field/field.js +7 -1
- package/plugins/schema/index.d.ts +8 -8
- package/plugins/schema/index.es6.js +8 -8
- package/plugins/schema/index.js +8 -8
- package/plugins/schema/integer/integer.d.ts +37 -0
- package/plugins/schema/integer/integer.es6.js +21 -7
- package/plugins/schema/integer/integer.js +21 -7
- package/plugins/schema/number/number.d.ts +32 -0
- package/plugins/schema/number/number.es6.js +21 -5
- package/plugins/schema/number/number.js +21 -5
- package/plugins/schema/string/string.d.ts +27 -0
- package/plugins/schema/string/string.es6.js +9 -3
- package/plugins/schema/string/string.js +9 -3
- package/plugins/utils/index.d.ts +2 -2
- package/plugins/utils/index.es6.js +2 -2
- package/plugins/utils/index.js +2 -2
- package/utils/index.d.ts +8 -8
- package/utils/index.es6.js +8 -8
- package/utils/index.js +8 -8
- package/utils/rules/index.d.ts +17 -17
- package/utils/rules/index.es6.js +17 -17
- package/utils/rules/index.js +18 -18
|
@@ -18,11 +18,20 @@ const array = () => {
|
|
|
18
18
|
useBlock('path');
|
|
19
19
|
const setRule = useContext(ruleContext);
|
|
20
20
|
const handler = useNewHandler();
|
|
21
|
-
const { children, ...props } = useProps();
|
|
21
|
+
const { children, maxItems, minItems, uniqueItems, ...props } = useProps();
|
|
22
22
|
const schema = useSchemaType('array', props);
|
|
23
23
|
const fieldSchema = {};
|
|
24
24
|
handler[schemaContext.key] = fieldSchema;
|
|
25
25
|
schema.items = fieldSchema;
|
|
26
|
+
if (maxItems) {
|
|
27
|
+
schema.maxItems = maxItems;
|
|
28
|
+
}
|
|
29
|
+
if (minItems) {
|
|
30
|
+
schema.minItems = minItems;
|
|
31
|
+
}
|
|
32
|
+
if (uniqueItems) {
|
|
33
|
+
schema.uniqueItems = uniqueItems;
|
|
34
|
+
}
|
|
26
35
|
if (setRule) {
|
|
27
36
|
let oneOfRulesMap;
|
|
28
37
|
const rules = [];
|
|
@@ -22,11 +22,20 @@ const array = () => {
|
|
|
22
22
|
useBlock.useBlock('path');
|
|
23
23
|
const setRule = jsx.useContext(useRule.ruleContext);
|
|
24
24
|
const handler = innet.useNewHandler();
|
|
25
|
-
const { children, ...props } = jsx.useProps();
|
|
25
|
+
const { children, maxItems, minItems, uniqueItems, ...props } = jsx.useProps();
|
|
26
26
|
const schema = useSchemaType.useSchemaType('array', props);
|
|
27
27
|
const fieldSchema = {};
|
|
28
28
|
handler[useSchemaContext.schemaContext.key] = fieldSchema;
|
|
29
29
|
schema.items = fieldSchema;
|
|
30
|
+
if (maxItems) {
|
|
31
|
+
schema.maxItems = maxItems;
|
|
32
|
+
}
|
|
33
|
+
if (minItems) {
|
|
34
|
+
schema.minItems = minItems;
|
|
35
|
+
}
|
|
36
|
+
if (uniqueItems) {
|
|
37
|
+
schema.uniqueItems = uniqueItems;
|
|
38
|
+
}
|
|
30
39
|
if (setRule) {
|
|
31
40
|
let oneOfRulesMap;
|
|
32
41
|
const rules = [];
|
|
@@ -10,7 +10,7 @@ import { required } from '../../../utils/rules/required/required.es6.js';
|
|
|
10
10
|
|
|
11
11
|
const field = () => {
|
|
12
12
|
const handler = useNewHandler();
|
|
13
|
-
const { children, deprecated, key, optional, } = useProps();
|
|
13
|
+
const { children, deprecated, key, optional, readOnly, writeOnly, } = useProps();
|
|
14
14
|
const schema = useObjectSchemaContext();
|
|
15
15
|
if (!schema.properties) {
|
|
16
16
|
schema.properties = {};
|
|
@@ -23,6 +23,12 @@ const field = () => {
|
|
|
23
23
|
if (deprecated) {
|
|
24
24
|
fieldSchema.deprecated = true;
|
|
25
25
|
}
|
|
26
|
+
if (readOnly) {
|
|
27
|
+
fieldSchema.readOnly = true;
|
|
28
|
+
}
|
|
29
|
+
if (writeOnly) {
|
|
30
|
+
fieldSchema.writeOnly = true;
|
|
31
|
+
}
|
|
26
32
|
schema.properties[key] = fieldSchema;
|
|
27
33
|
if (!optional) {
|
|
28
34
|
if (!schema.required) {
|
|
@@ -14,7 +14,7 @@ var required = require('../../../utils/rules/required/required.js');
|
|
|
14
14
|
|
|
15
15
|
const field = () => {
|
|
16
16
|
const handler = innet.useNewHandler();
|
|
17
|
-
const { children, deprecated, key, optional, } = jsx.useProps();
|
|
17
|
+
const { children, deprecated, key, optional, readOnly, writeOnly, } = jsx.useProps();
|
|
18
18
|
const schema = useObjectSchemaContext.useObjectSchemaContext();
|
|
19
19
|
if (!schema.properties) {
|
|
20
20
|
schema.properties = {};
|
|
@@ -27,6 +27,12 @@ const field = () => {
|
|
|
27
27
|
if (deprecated) {
|
|
28
28
|
fieldSchema.deprecated = true;
|
|
29
29
|
}
|
|
30
|
+
if (readOnly) {
|
|
31
|
+
fieldSchema.readOnly = true;
|
|
32
|
+
}
|
|
33
|
+
if (writeOnly) {
|
|
34
|
+
fieldSchema.writeOnly = true;
|
|
35
|
+
}
|
|
30
36
|
schema.properties[key] = fieldSchema;
|
|
31
37
|
if (!optional) {
|
|
32
38
|
if (!schema.required) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './field';
|
|
3
|
-
export * from './number';
|
|
4
|
-
export * from './integer';
|
|
5
|
-
export * from './string';
|
|
1
|
+
export * from './any';
|
|
6
2
|
export * from './array';
|
|
3
|
+
export * from './binary';
|
|
7
4
|
export * from './boolean';
|
|
8
|
-
export * from './null';
|
|
9
5
|
export * from './date';
|
|
6
|
+
export * from './field';
|
|
7
|
+
export * from './integer';
|
|
8
|
+
export * from './null';
|
|
9
|
+
export * from './number';
|
|
10
|
+
export * from './object';
|
|
11
|
+
export * from './string';
|
|
10
12
|
export * from './tuple';
|
|
11
13
|
export * from './uuid';
|
|
12
|
-
export * from './binary';
|
|
13
|
-
export * from './any';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import './
|
|
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';
|
package/plugins/schema/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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,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.
|
|
36
|
+
schema.minLength = min;
|
|
31
37
|
rules.push(minLength(min));
|
|
32
38
|
}
|
|
33
39
|
if (max !== undefined) {
|
|
34
|
-
schema.
|
|
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.
|
|
40
|
+
schema.minLength = min;
|
|
35
41
|
rules.push(minLength.minLength(min));
|
|
36
42
|
}
|
|
37
43
|
if (max !== undefined) {
|
|
38
|
-
schema.
|
|
44
|
+
schema.maxLength = max;
|
|
39
45
|
rules.push(maxLength.maxLength(max));
|
|
40
46
|
}
|
|
41
47
|
if (pattern$1 !== undefined) {
|
package/plugins/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import './
|
|
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 './
|
|
5
|
+
import './swagger/index.es6.js';
|
|
6
6
|
import './whitelist/index.es6.js';
|
package/plugins/utils/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./
|
|
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('./
|
|
7
|
+
require('./swagger/index.js');
|
|
8
8
|
require('./whitelist/index.js');
|
|
9
9
|
|
package/utils/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './FileData';
|
|
2
|
+
export * from './JSONString';
|
|
3
|
+
export * from './action';
|
|
4
|
+
export * from './decorators';
|
|
5
|
+
export * from './generateTypes';
|
|
4
6
|
export * from './getEndpoint';
|
|
5
7
|
export * from './getOrAdd';
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './action';
|
|
8
|
+
export * from './httpOnStart';
|
|
8
9
|
export * from './parseBody';
|
|
9
10
|
export * from './parseFormBody';
|
|
11
|
+
export * from './parseSearch';
|
|
10
12
|
export * from './rules';
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './FileData';
|
|
13
|
-
export * from './generateTypes';
|
|
13
|
+
export * from './stringifySearch';
|
package/utils/index.es6.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import './
|
|
2
|
-
import './
|
|
3
|
-
import './
|
|
1
|
+
import './FileData/index.es6.js';
|
|
2
|
+
import './JSONString/index.es6.js';
|
|
3
|
+
import './action/index.es6.js';
|
|
4
|
+
import './decorators/index.es6.js';
|
|
5
|
+
import './generateTypes/index.es6.js';
|
|
4
6
|
import './getEndpoint/index.es6.js';
|
|
5
7
|
import './getOrAdd/index.es6.js';
|
|
6
|
-
import './
|
|
7
|
-
import './action/index.es6.js';
|
|
8
|
+
import './httpOnStart/index.es6.js';
|
|
8
9
|
import './parseBody/index.es6.js';
|
|
9
10
|
import './parseFormBody/index.es6.js';
|
|
11
|
+
import './parseSearch/index.es6.js';
|
|
10
12
|
import './rules/index.es6.js';
|
|
11
|
-
import './
|
|
12
|
-
import './FileData/index.es6.js';
|
|
13
|
-
import './generateTypes/index.es6.js';
|
|
13
|
+
import './stringifySearch/index.es6.js';
|
package/utils/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./
|
|
4
|
-
require('./
|
|
5
|
-
require('./
|
|
3
|
+
require('./FileData/index.js');
|
|
4
|
+
require('./JSONString/index.js');
|
|
5
|
+
require('./action/index.js');
|
|
6
|
+
require('./decorators/index.js');
|
|
7
|
+
require('./generateTypes/index.js');
|
|
6
8
|
require('./getEndpoint/index.js');
|
|
7
9
|
require('./getOrAdd/index.js');
|
|
8
|
-
require('./
|
|
9
|
-
require('./action/index.js');
|
|
10
|
+
require('./httpOnStart/index.js');
|
|
10
11
|
require('./parseBody/index.js');
|
|
11
12
|
require('./parseFormBody/index.js');
|
|
13
|
+
require('./parseSearch/index.js');
|
|
12
14
|
require('./rules/index.js');
|
|
13
|
-
require('./
|
|
14
|
-
require('./FileData/index.js');
|
|
15
|
-
require('./generateTypes/index.js');
|
|
15
|
+
require('./stringifySearch/index.js');
|
|
16
16
|
|