@innet/server 2.0.0-beta.1 → 2.0.0-beta.10
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 +385 -9
- package/handler/handler.d.ts +6 -9
- package/handler/handler.es6.js +3 -4
- package/handler/handler.js +2 -3
- package/hooks/index.d.ts +24 -23
- package/hooks/index.es6.js +24 -23
- package/hooks/index.js +24 -23
- package/hooks/useEffect/index.d.ts +1 -0
- package/hooks/useEffect/index.es6.js +1 -0
- package/hooks/useEffect/index.js +9 -0
- package/hooks/useEffect/useEffect.d.ts +2 -0
- package/hooks/useEffect/useEffect.es6.js +8 -0
- package/hooks/useEffect/useEffect.js +12 -0
- package/hooks/useHeaders/useHeaders.d.ts +0 -1
- package/hooks/useNewSchema/useNewSchema.es6.js +1 -1
- package/hooks/useNewSchema/useNewSchema.js +1 -1
- package/hooks/useRequest/useRequest.d.ts +0 -1
- package/hooks/useResponse/useResponse.d.ts +0 -1
- package/hooks/useSchemaType/useSchemaType.es6.js +17 -9
- package/hooks/useSchemaType/useSchemaType.js +17 -9
- package/hooks/useServer/useServer.d.ts +0 -2
- package/index.d.ts +2 -2
- package/index.es6.js +88 -86
- package/index.js +201 -194
- package/package.json +16 -15
- package/plugins/handler/serverFn/serverFn.es6.js +2 -2
- package/plugins/handler/serverFn/serverFn.js +2 -6
- package/plugins/index.d.ts +2 -2
- package/plugins/index.es6.js +2 -2
- package/plugins/index.js +2 -2
- package/plugins/main/api/api.es6.js +74 -74
- package/plugins/main/api/api.js +75 -79
- package/plugins/main/body/body.es6.js +4 -4
- package/plugins/main/body/body.js +4 -8
- package/plugins/main/endpoint/endpoint.d.ts +5 -0
- package/plugins/main/endpoint/endpoint.es6.js +5 -5
- package/plugins/main/endpoint/endpoint.js +5 -9
- package/plugins/main/host/host.es6.js +4 -2
- package/plugins/main/host/host.js +4 -6
- 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/main/param/param.es6.js +3 -4
- package/plugins/main/param/param.js +3 -8
- package/plugins/main/preset/preset.es6.js +1 -1
- package/plugins/main/preset/preset.js +1 -5
- package/plugins/main/response/response.es6.js +11 -4
- package/plugins/main/response/response.js +11 -8
- package/plugins/main/server/server.d.ts +0 -1
- package/plugins/main/server/server.es6.js +7 -10
- package/plugins/main/server/server.js +8 -12
- package/plugins/main/tag/index.es6.js +1 -1
- package/plugins/main/tag/index.js +1 -0
- package/plugins/main/tag/tag.d.ts +8 -1
- package/plugins/main/tag/tag.es6.js +20 -3
- package/plugins/main/tag/tag.js +20 -6
- package/plugins/main/variable/variable.es6.js +3 -4
- package/plugins/main/variable/variable.js +3 -4
- package/plugins/request/cms/cms.es6.js +1 -1
- package/plugins/request/cms/cms.js +2 -3
- package/plugins/request/cookie/cookie.d.ts +2 -2
- package/plugins/request/cookie/cookie.es6.js +1 -2
- package/plugins/request/cookie/cookie.js +1 -2
- package/plugins/request/error/error.es6.js +1 -2
- package/plugins/request/error/error.js +1 -2
- package/plugins/request/file/file.es6.js +2 -3
- package/plugins/request/file/file.js +2 -4
- 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/request/proxy/proxy.d.ts +0 -1
- package/plugins/schema/array/array.d.ts +3 -0
- package/plugins/schema/array/array.es6.js +14 -6
- package/plugins/schema/array/array.js +15 -11
- package/plugins/schema/binary/binary.d.ts +4 -0
- package/plugins/schema/boolean/boolean.d.ts +1 -0
- package/plugins/schema/date/date.d.ts +2 -1
- package/plugins/schema/date/date.es6.js +8 -4
- package/plugins/schema/date/date.js +8 -4
- package/plugins/schema/field/field.d.ts +4 -0
- package/plugins/schema/field/field.es6.js +16 -3
- package/plugins/schema/field/field.js +16 -7
- 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 +29 -9
- package/plugins/schema/integer/integer.js +29 -9
- package/plugins/schema/number/number.d.ts +32 -0
- package/plugins/schema/number/number.es6.js +21 -6
- package/plugins/schema/number/number.js +21 -6
- package/plugins/schema/object/object.es6.js +9 -8
- package/plugins/schema/object/object.js +9 -12
- package/plugins/schema/string/string.d.ts +27 -0
- package/plugins/schema/string/string.es6.js +9 -4
- package/plugins/schema/string/string.js +9 -4
- package/plugins/schema/tuple/tuple.es6.js +5 -6
- package/plugins/schema/tuple/tuple.js +5 -10
- package/plugins/schema/uuid/uuid.es6.js +5 -3
- package/plugins/schema/uuid/uuid.js +5 -3
- package/plugins/utils/dts/dts.es6.js +5 -2
- package/plugins/utils/dts/dts.js +5 -2
- package/plugins/utils/env/env.es6.js +1 -1
- package/plugins/utils/env/env.js +1 -5
- package/plugins/utils/index.d.ts +3 -2
- package/plugins/utils/index.es6.js +3 -2
- package/plugins/utils/index.js +3 -2
- package/plugins/utils/swagger/swagger.d.ts +1 -0
- package/plugins/utils/swagger/swagger.es6.js +1 -0
- package/plugins/utils/swagger/swagger.js +1 -0
- package/plugins/utils/ui/index.d.ts +1 -0
- package/plugins/utils/ui/index.es6.js +1 -0
- package/plugins/utils/ui/index.js +10 -0
- package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
- package/plugins/utils/ui/rapidoc.html.js +7 -0
- package/plugins/utils/ui/redoc.html.es6.js +3 -0
- package/plugins/utils/ui/redoc.html.js +7 -0
- package/plugins/utils/ui/scalar.html.es6.js +3 -0
- package/plugins/utils/ui/scalar.html.js +7 -0
- package/plugins/utils/ui/swagger.html.es6.js +3 -0
- package/plugins/utils/ui/swagger.html.js +7 -0
- package/plugins/utils/ui/ui.d.ts +13 -0
- package/plugins/utils/ui/ui.es6.js +45 -0
- package/plugins/utils/ui/ui.js +50 -0
- package/types.d.ts +6 -0
- package/utils/action/Action.d.ts +4 -5
- package/utils/action/Action.es6.js +14 -16
- package/utils/action/Action.js +13 -15
- package/utils/getSafeSchema/getSafeSchema.d.ts +2 -0
- package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
- package/utils/getSafeSchema/getSafeSchema.js +9 -0
- package/utils/getSafeSchema/index.d.ts +1 -0
- package/utils/getSafeSchema/index.es6.js +1 -0
- package/utils/getSafeSchema/index.js +9 -0
- package/utils/index.d.ts +9 -8
- package/utils/index.es6.js +9 -8
- package/utils/index.js +9 -8
- package/utils/parseBody/parseBody.d.ts +0 -1
- package/utils/parseBody/parseBody.es6.js +13 -16
- package/utils/parseBody/parseBody.js +13 -16
- package/utils/parseFormBody/parseFormBody.d.ts +0 -1
- package/utils/parseFormBody/parseFormBody.es6.js +41 -41
- package/utils/parseFormBody/parseFormBody.js +41 -41
- package/utils/parseSearch/parseSearch.es6.js +4 -1
- package/utils/parseSearch/parseSearch.js +4 -1
- package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
- package/utils/rules/arrayOf/arrayOf.js +1 -1
- package/utils/rules/bin/bin.es6.js +4 -1
- package/utils/rules/bin/bin.js +4 -1
- package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
- package/utils/rules/binaryAccept/binaryAccept.js +5 -2
- package/utils/rules/dateTo/dateTo.es6.js +4 -1
- package/utils/rules/dateTo/dateTo.js +4 -1
- package/utils/rules/helpers.es6.js +4 -1
- package/utils/rules/helpers.js +4 -1
- package/utils/rules/index.d.ts +17 -17
- package/utils/rules/index.es6.js +17 -17
- package/utils/rules/index.js +18 -18
- package/utils/rules/int/int.es6.js +17 -4
- package/utils/rules/int/int.js +17 -4
- package/utils/rules/max/max.es6.js +9 -3
- package/utils/rules/max/max.js +9 -3
- package/utils/rules/maxBin/maxBin.es6.js +5 -2
- package/utils/rules/maxBin/maxBin.js +5 -2
- package/utils/rules/maxDate/maxDate.es6.js +5 -1
- package/utils/rules/maxDate/maxDate.js +5 -1
- package/utils/rules/maxLength/maxLength.es6.js +5 -2
- package/utils/rules/maxLength/maxLength.js +5 -2
- package/utils/rules/min/min.es6.js +9 -3
- package/utils/rules/min/min.js +9 -3
- package/utils/rules/minBin/minBin.es6.js +5 -2
- package/utils/rules/minBin/minBin.js +5 -2
- package/utils/rules/minDate/minDate.es6.js +5 -1
- package/utils/rules/minDate/minDate.js +5 -1
- package/utils/rules/minLength/minLength.es6.js +5 -2
- package/utils/rules/minLength/minLength.js +5 -2
- package/utils/rules/num/num.es6.js +4 -1
- package/utils/rules/num/num.js +4 -1
- package/utils/rules/objectOf/objectOf.es6.js +6 -3
- package/utils/rules/objectOf/objectOf.js +6 -3
- package/utils/rules/pattern/pattern.es6.js +6 -2
- package/utils/rules/pattern/pattern.js +6 -2
- package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
- package/utils/rules/tupleOf/tupleOf.js +1 -1
- package/utils/rules/values/values.es6.js +5 -2
- package/utils/rules/values/values.js +5 -2
- package/utils/stringifySearch/stringifySearch.es6.js +4 -1
- package/utils/stringifySearch/stringifySearch.js +4 -1
- package/_virtual/_rollup-plugin-process-env.es6.js +0 -10
- package/_virtual/_rollup-plugin-process-env.js +0 -12
|
@@ -2,7 +2,6 @@
|
|
|
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
7
|
var fs = require('node:fs');
|
|
@@ -13,13 +12,12 @@ var useThrow = require('../../../hooks/useThrow/useThrow.js');
|
|
|
13
12
|
|
|
14
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
14
|
|
|
16
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
17
15
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
18
16
|
var mime__default = /*#__PURE__*/_interopDefaultLegacy(mime);
|
|
19
17
|
|
|
20
18
|
function file() {
|
|
21
19
|
const handler = innet.useHandler();
|
|
22
|
-
const
|
|
20
|
+
const { children, ...props } = jsx.useProps();
|
|
23
21
|
const res = useResponse.useResponse();
|
|
24
22
|
if (!res) {
|
|
25
23
|
useThrow.useThrow('<{type}> MUST be in <request> or <fallback>');
|
|
@@ -41,7 +39,7 @@ function file() {
|
|
|
41
39
|
return;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
|
|
42
|
+
innet.innet(children, handler);
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
exports.file = file;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './cms';
|
|
2
|
+
export * from './cookie';
|
|
2
3
|
export * from './error';
|
|
4
|
+
export * from './file';
|
|
5
|
+
export * from './header';
|
|
3
6
|
export * from './proxy';
|
|
4
7
|
export * from './redirect';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './cookie';
|
|
7
|
-
export * from './file';
|
|
8
|
-
export * from './cms';
|
|
8
|
+
export * from './success';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './cms/index.es6.js';
|
|
2
|
+
import './cookie/index.es6.js';
|
|
2
3
|
import './error/index.es6.js';
|
|
4
|
+
import './file/index.es6.js';
|
|
5
|
+
import './header/index.es6.js';
|
|
3
6
|
import './proxy/index.es6.js';
|
|
4
7
|
import './redirect/index.es6.js';
|
|
5
|
-
import './
|
|
6
|
-
import './cookie/index.es6.js';
|
|
7
|
-
import './file/index.es6.js';
|
|
8
|
-
import './cms/index.es6.js';
|
|
8
|
+
import './success/index.es6.js';
|
package/plugins/request/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./
|
|
3
|
+
require('./cms/index.js');
|
|
4
|
+
require('./cookie/index.js');
|
|
4
5
|
require('./error/index.js');
|
|
6
|
+
require('./file/index.js');
|
|
7
|
+
require('./header/index.js');
|
|
5
8
|
require('./proxy/index.js');
|
|
6
9
|
require('./redirect/index.js');
|
|
7
|
-
require('./
|
|
8
|
-
require('./cookie/index.js');
|
|
9
|
-
require('./file/index.js');
|
|
10
|
-
require('./cms/index.js');
|
|
10
|
+
require('./success/index.js');
|
|
11
11
|
|
|
@@ -2,5 +2,8 @@ import { type HandlerPlugin } from 'innet';
|
|
|
2
2
|
import { type BaseSchemaProps } from '../../../types';
|
|
3
3
|
export interface ArrayProps extends BaseSchemaProps<any[]> {
|
|
4
4
|
children?: any;
|
|
5
|
+
maxItems?: number;
|
|
6
|
+
minItems?: number;
|
|
7
|
+
uniqueItems?: boolean;
|
|
5
8
|
}
|
|
6
9
|
export declare const array: HandlerPlugin;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import innet, { useNewHandler } from 'innet';
|
|
1
|
+
import { useNewHandler, innet } from 'innet';
|
|
3
2
|
import { useContext, 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,16 +12,26 @@ import { defaultTo } from '../../../utils/rules/defaultTo/defaultTo.es6.js';
|
|
|
14
12
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
15
13
|
import { arrayOf } from '../../../utils/rules/arrayOf/arrayOf.es6.js';
|
|
16
14
|
import { oneOf } from '../../../utils/rules/oneOf/oneOf.es6.js';
|
|
15
|
+
import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
|
|
17
16
|
|
|
18
17
|
const array = () => {
|
|
19
18
|
useBlock('path');
|
|
20
19
|
const setRule = useContext(ruleContext);
|
|
21
20
|
const handler = useNewHandler();
|
|
22
|
-
const
|
|
21
|
+
const { children, maxItems, minItems, uniqueItems, ...props } = useProps();
|
|
23
22
|
const schema = useSchemaType('array', props);
|
|
24
23
|
const fieldSchema = {};
|
|
25
24
|
handler[schemaContext.key] = fieldSchema;
|
|
26
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
|
+
}
|
|
27
35
|
if (setRule) {
|
|
28
36
|
let oneOfRulesMap;
|
|
29
37
|
const rules = [];
|
|
@@ -45,11 +53,11 @@ const array = () => {
|
|
|
45
53
|
}
|
|
46
54
|
});
|
|
47
55
|
innet(children, handler);
|
|
48
|
-
|
|
56
|
+
useEffect(() => {
|
|
49
57
|
if (!oneOfRulesMap && setRule) {
|
|
50
58
|
setRule(rootRule(e => e));
|
|
51
59
|
}
|
|
52
|
-
}
|
|
60
|
+
});
|
|
53
61
|
return;
|
|
54
62
|
}
|
|
55
63
|
innet(children, handler);
|
|
@@ -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,20 +16,26 @@ var defaultTo = require('../../../utils/rules/defaultTo/defaultTo.js');
|
|
|
18
16
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
19
17
|
var arrayOf = require('../../../utils/rules/arrayOf/arrayOf.js');
|
|
20
18
|
var oneOf = require('../../../utils/rules/oneOf/oneOf.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 array = () => {
|
|
27
22
|
useBlock.useBlock('path');
|
|
28
23
|
const setRule = jsx.useContext(useRule.ruleContext);
|
|
29
24
|
const handler = innet.useNewHandler();
|
|
30
|
-
const
|
|
25
|
+
const { children, maxItems, minItems, uniqueItems, ...props } = jsx.useProps();
|
|
31
26
|
const schema = useSchemaType.useSchemaType('array', props);
|
|
32
27
|
const fieldSchema = {};
|
|
33
28
|
handler[useSchemaContext.schemaContext.key] = fieldSchema;
|
|
34
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
|
+
}
|
|
35
39
|
if (setRule) {
|
|
36
40
|
let oneOfRulesMap;
|
|
37
41
|
const rules = [];
|
|
@@ -52,15 +56,15 @@ const array = () => {
|
|
|
52
56
|
setRule(rootRule(oneOf.oneOf(oneOfRulesMap)));
|
|
53
57
|
}
|
|
54
58
|
});
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
innet.innet(children, handler);
|
|
60
|
+
useEffect.useEffect(() => {
|
|
57
61
|
if (!oneOfRulesMap && setRule) {
|
|
58
62
|
setRule(rootRule(e => e));
|
|
59
63
|
}
|
|
60
|
-
}
|
|
64
|
+
});
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
|
-
|
|
67
|
+
innet.innet(children, handler);
|
|
64
68
|
};
|
|
65
69
|
|
|
66
70
|
exports.array = array;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export interface BinaryProps {
|
|
3
3
|
accept?: string;
|
|
4
|
+
deprecated: boolean;
|
|
4
5
|
description?: string;
|
|
5
6
|
max?: number;
|
|
6
7
|
min?: number;
|
|
8
|
+
readOnly: boolean;
|
|
7
9
|
ref?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
writeOnly: boolean;
|
|
8
12
|
}
|
|
9
13
|
export declare const binary: HandlerPlugin;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type ValuesSchemaProps } from '../../../types';
|
|
3
3
|
import { type DateFormat } from '../../../utils';
|
|
4
|
-
export interface DateProps extends ValuesSchemaProps<DateFormat> {
|
|
4
|
+
export interface DateProps extends Omit<ValuesSchemaProps<DateFormat>, 'const'> {
|
|
5
|
+
const?: string;
|
|
5
6
|
max?: DateFormat;
|
|
6
7
|
min?: DateFormat;
|
|
7
8
|
}
|
|
@@ -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';
|
|
@@ -16,7 +15,7 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
|
16
15
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
17
16
|
|
|
18
17
|
const date = () => {
|
|
19
|
-
const
|
|
18
|
+
const { default: defaultValue, example, examples, max, min, values: values$1, ...props } = useProps() || {};
|
|
20
19
|
const normMin = dateFormat(min);
|
|
21
20
|
const normMax = dateFormat(max);
|
|
22
21
|
const normDefault = dateFormat(defaultValue);
|
|
@@ -25,9 +24,14 @@ const date = () => {
|
|
|
25
24
|
// @ts-expect-error: FIXME
|
|
26
25
|
const stringValues = normValues === null || normValues === void 0 ? void 0 : normValues.map(value => value.toISOString());
|
|
27
26
|
const normExamples = examples === null || examples === void 0 ? void 0 : examples.map(dateFormat);
|
|
28
|
-
const schema = useSchemaType('string',
|
|
27
|
+
const schema = useSchemaType('string', {
|
|
28
|
+
...props,
|
|
29
|
+
default: defaultValue === 'now' ? undefined : normDefault === null || normDefault === void 0 ? void 0 : normDefault.toISOString(),
|
|
30
|
+
example: normExample === null || normExample === void 0 ? void 0 : normExample.toISOString(),
|
|
29
31
|
// @ts-expect-error: FIXME
|
|
30
|
-
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
|
|
32
|
+
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
|
|
33
|
+
values: stringValues,
|
|
34
|
+
});
|
|
31
35
|
const rules = [];
|
|
32
36
|
if (defaultValue !== undefined) {
|
|
33
37
|
rules.push(defaultTo(defaultValue === 'now' ? () => new Date(Date.now()) : normDefault));
|
|
@@ -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');
|
|
@@ -20,7 +19,7 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
20
19
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
21
20
|
|
|
22
21
|
const date = () => {
|
|
23
|
-
const
|
|
22
|
+
const { default: defaultValue, example, examples, max, min, values: values$1, ...props } = jsx.useProps() || {};
|
|
24
23
|
const normMin = dateFormat.dateFormat(min);
|
|
25
24
|
const normMax = dateFormat.dateFormat(max);
|
|
26
25
|
const normDefault = dateFormat.dateFormat(defaultValue);
|
|
@@ -29,9 +28,14 @@ const date = () => {
|
|
|
29
28
|
// @ts-expect-error: FIXME
|
|
30
29
|
const stringValues = normValues === null || normValues === void 0 ? void 0 : normValues.map(value => value.toISOString());
|
|
31
30
|
const normExamples = examples === null || examples === void 0 ? void 0 : examples.map(dateFormat.dateFormat);
|
|
32
|
-
const schema = useSchemaType.useSchemaType('string',
|
|
31
|
+
const schema = useSchemaType.useSchemaType('string', {
|
|
32
|
+
...props,
|
|
33
|
+
default: defaultValue === 'now' ? undefined : normDefault === null || normDefault === void 0 ? void 0 : normDefault.toISOString(),
|
|
34
|
+
example: normExample === null || normExample === void 0 ? void 0 : normExample.toISOString(),
|
|
33
35
|
// @ts-expect-error: FIXME
|
|
34
|
-
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
|
|
36
|
+
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
|
|
37
|
+
values: stringValues,
|
|
38
|
+
});
|
|
35
39
|
const rules = [];
|
|
36
40
|
if (defaultValue !== undefined) {
|
|
37
41
|
rules.push(defaultTo.defaultTo(defaultValue === 'now' ? () => new Date(Date.now()) : normDefault));
|
|
@@ -2,7 +2,11 @@ import { type HandlerPlugin } from 'innet';
|
|
|
2
2
|
export interface FieldProps {
|
|
3
3
|
children?: any;
|
|
4
4
|
deprecated?: boolean;
|
|
5
|
+
description?: string;
|
|
5
6
|
key: string;
|
|
6
7
|
optional?: boolean;
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
title?: string;
|
|
10
|
+
writeOnly?: boolean;
|
|
7
11
|
}
|
|
8
12
|
export declare const field: HandlerPlugin;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useNewHandler, innet } from 'innet';
|
|
2
2
|
import { useProps } from '@innet/jsx';
|
|
3
3
|
import '../../../hooks/index.es6.js';
|
|
4
4
|
import '../../../utils/index.es6.js';
|
|
5
|
+
import { getSafeSchema } from '../../../utils/getSafeSchema/getSafeSchema.es6.js';
|
|
5
6
|
import { useObjectSchemaContext } from '../../../hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js';
|
|
6
7
|
import { schemaContext } from '../../../hooks/useSchemaContext/useSchemaContext.es6.js';
|
|
7
8
|
import { useObjectRule, objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es6.js';
|
|
@@ -10,8 +11,8 @@ import { required } from '../../../utils/rules/required/required.es6.js';
|
|
|
10
11
|
|
|
11
12
|
const field = () => {
|
|
12
13
|
const handler = useNewHandler();
|
|
13
|
-
const { children, deprecated, key, optional, } = useProps();
|
|
14
|
-
const schema = useObjectSchemaContext();
|
|
14
|
+
const { children, deprecated, description, key, optional, readOnly, title, writeOnly, } = useProps();
|
|
15
|
+
const schema = getSafeSchema(useObjectSchemaContext());
|
|
15
16
|
if (!schema.properties) {
|
|
16
17
|
schema.properties = {};
|
|
17
18
|
}
|
|
@@ -23,6 +24,18 @@ const field = () => {
|
|
|
23
24
|
if (deprecated) {
|
|
24
25
|
fieldSchema.deprecated = true;
|
|
25
26
|
}
|
|
27
|
+
if (title) {
|
|
28
|
+
fieldSchema.title = title;
|
|
29
|
+
}
|
|
30
|
+
if (description) {
|
|
31
|
+
fieldSchema.description = description;
|
|
32
|
+
}
|
|
33
|
+
if (readOnly) {
|
|
34
|
+
fieldSchema.readOnly = true;
|
|
35
|
+
}
|
|
36
|
+
if (writeOnly) {
|
|
37
|
+
fieldSchema.writeOnly = true;
|
|
38
|
+
}
|
|
26
39
|
schema.properties[key] = fieldSchema;
|
|
27
40
|
if (!optional) {
|
|
28
41
|
if (!schema.required) {
|
|
@@ -6,20 +6,17 @@ var innet = require('innet');
|
|
|
6
6
|
var jsx = require('@innet/jsx');
|
|
7
7
|
require('../../../hooks/index.js');
|
|
8
8
|
require('../../../utils/index.js');
|
|
9
|
+
var getSafeSchema = require('../../../utils/getSafeSchema/getSafeSchema.js');
|
|
9
10
|
var useObjectSchemaContext = require('../../../hooks/useObjectSchemaContext/useObjectSchemaContext.js');
|
|
10
11
|
var useSchemaContext = require('../../../hooks/useSchemaContext/useSchemaContext.js');
|
|
11
12
|
var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
|
|
12
13
|
var useRule = require('../../../hooks/useRule/useRule.js');
|
|
13
14
|
var required = require('../../../utils/rules/required/required.js');
|
|
14
15
|
|
|
15
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
-
|
|
17
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
18
|
-
|
|
19
16
|
const field = () => {
|
|
20
17
|
const handler = innet.useNewHandler();
|
|
21
|
-
const { children, deprecated, key, optional, } = jsx.useProps();
|
|
22
|
-
const schema = useObjectSchemaContext.useObjectSchemaContext();
|
|
18
|
+
const { children, deprecated, description, key, optional, readOnly, title, writeOnly, } = jsx.useProps();
|
|
19
|
+
const schema = getSafeSchema.getSafeSchema(useObjectSchemaContext.useObjectSchemaContext());
|
|
23
20
|
if (!schema.properties) {
|
|
24
21
|
schema.properties = {};
|
|
25
22
|
}
|
|
@@ -31,6 +28,18 @@ const field = () => {
|
|
|
31
28
|
if (deprecated) {
|
|
32
29
|
fieldSchema.deprecated = true;
|
|
33
30
|
}
|
|
31
|
+
if (title) {
|
|
32
|
+
fieldSchema.title = title;
|
|
33
|
+
}
|
|
34
|
+
if (description) {
|
|
35
|
+
fieldSchema.description = description;
|
|
36
|
+
}
|
|
37
|
+
if (readOnly) {
|
|
38
|
+
fieldSchema.readOnly = true;
|
|
39
|
+
}
|
|
40
|
+
if (writeOnly) {
|
|
41
|
+
fieldSchema.writeOnly = true;
|
|
42
|
+
}
|
|
34
43
|
schema.properties[key] = fieldSchema;
|
|
35
44
|
if (!optional) {
|
|
36
45
|
if (!schema.required) {
|
|
@@ -48,7 +57,7 @@ const field = () => {
|
|
|
48
57
|
}
|
|
49
58
|
});
|
|
50
59
|
useObjectRule.objectRuleContext.set(handler, null);
|
|
51
|
-
|
|
60
|
+
innet.innet(children, handler);
|
|
52
61
|
};
|
|
53
62
|
|
|
54
63
|
exports.field = field;
|
|
@@ -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;
|
|
@@ -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 '../../../utils/index.es6.js';
|
|
@@ -13,14 +12,35 @@ import { optional } from '../../../utils/rules/optional/optional.es6.js';
|
|
|
13
12
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
14
13
|
|
|
15
14
|
const integer = () => {
|
|
16
|
-
const
|
|
17
|
-
const schema = useSchemaType('integer',
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
const { default: defaultValue, example, examples, exclusiveMaximum, exclusiveMinimum, format = 'int32', max: max$1, min: min$1, multipleOf, values: values$1, ...props } = useProps() || {};
|
|
16
|
+
const schema = useSchemaType('integer', {
|
|
17
|
+
...props,
|
|
18
|
+
const: props.const !== undefined ? Number(props.const) : undefined,
|
|
19
|
+
default: defaultValue !== undefined ? Number(defaultValue) : undefined,
|
|
20
|
+
example: example !== undefined ? Number(example) : undefined,
|
|
21
|
+
examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
|
|
22
|
+
values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number),
|
|
23
|
+
});
|
|
24
|
+
if (schema) {
|
|
25
|
+
if (format) {
|
|
26
|
+
schema.format = format;
|
|
27
|
+
}
|
|
28
|
+
if (min$1 !== undefined) {
|
|
29
|
+
schema.minimum = Number(min$1);
|
|
30
|
+
}
|
|
31
|
+
if (max$1 !== undefined) {
|
|
32
|
+
schema.maximum = Number(max$1);
|
|
33
|
+
}
|
|
34
|
+
if (exclusiveMinimum) {
|
|
35
|
+
schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
|
|
36
|
+
}
|
|
37
|
+
if (exclusiveMaximum) {
|
|
38
|
+
schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
|
|
39
|
+
}
|
|
40
|
+
if (multipleOf !== undefined) {
|
|
41
|
+
schema.multipleOf = Number(multipleOf);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
24
44
|
const rules = [];
|
|
25
45
|
if (defaultValue !== undefined) {
|
|
26
46
|
rules.push(defaultTo(defaultValue));
|
|
@@ -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('../../../utils/index.js');
|
|
@@ -17,14 +16,35 @@ 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
|
|
21
|
-
const schema = useSchemaType.useSchemaType('integer',
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 === null || values$1 === void 0 ? void 0 : values$1.map(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));
|