@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.
- package/README.md +215 -0
- package/handler/handler.d.ts +1 -1
- 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/index.d.ts +2 -2
- package/index.es6.js +86 -85
- package/index.js +195 -193
- package/package.json +7 -5
- package/plugins/handler/serverFn/serverFn.es6.js +1 -1
- package/plugins/handler/serverFn/serverFn.js +1 -5
- 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 +1 -1
- package/plugins/main/api/api.js +3 -7
- package/plugins/main/body/body.es6.js +4 -4
- package/plugins/main/body/body.js +4 -8
- package/plugins/main/endpoint/endpoint.es6.js +4 -4
- package/plugins/main/endpoint/endpoint.js +4 -8
- package/plugins/main/host/host.es6.js +1 -1
- package/plugins/main/host/host.js +1 -5
- 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 +1 -1
- package/plugins/main/param/param.js +1 -5
- package/plugins/main/preset/preset.es6.js +1 -1
- package/plugins/main/preset/preset.js +1 -5
- package/plugins/main/response/response.es6.js +1 -1
- package/plugins/main/response/response.js +1 -5
- package/plugins/main/server/server.es6.js +1 -1
- package/plugins/main/server/server.js +2 -3
- package/plugins/main/tag/tag.es6.js +1 -1
- package/plugins/main/tag/tag.js +1 -5
- package/plugins/request/cms/cms.es6.js +1 -1
- package/plugins/request/cms/cms.js +2 -3
- package/plugins/request/file/file.es6.js +1 -1
- package/plugins/request/file/file.js +1 -2
- 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 +14 -5
- package/plugins/schema/array/array.js +15 -10
- package/plugins/schema/field/field.d.ts +2 -0
- package/plugins/schema/field/field.es6.js +8 -2
- package/plugins/schema/field/field.js +8 -6
- 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/object/object.es6.js +4 -4
- package/plugins/schema/object/object.js +4 -8
- 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/schema/tuple/tuple.es6.js +4 -4
- package/plugins/schema/tuple/tuple.js +4 -8
- 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 +2 -2
- package/plugins/utils/index.es6.js +2 -2
- package/plugins/utils/index.js +2 -2
- package/types.d.ts +1 -0
- 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
|
@@ -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
|
var constants = require('../../../constants.js');
|
|
9
8
|
require('../../../hooks/index.js');
|
|
10
9
|
require('../../../utils/index.js');
|
|
@@ -13,10 +12,7 @@ var useSchemaContext = require('../../../hooks/useSchemaContext/useSchemaContext
|
|
|
13
12
|
var getOrAdd = require('../../../utils/getOrAdd/getOrAdd.js');
|
|
14
13
|
var useBodyFile = require('../../../hooks/useBodyFile/useBodyFile.js');
|
|
15
14
|
var useRule = require('../../../hooks/useRule/useRule.js');
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
15
|
+
var useEffect = require('../../../hooks/useEffect/useEffect.js');
|
|
20
16
|
|
|
21
17
|
const body = () => {
|
|
22
18
|
const endpoint = jsx.useContext(useEndpoint.endpointContext);
|
|
@@ -47,8 +43,8 @@ const body = () => {
|
|
|
47
43
|
useRule.ruleContext.set(handler, rule => {
|
|
48
44
|
rules.body = rule;
|
|
49
45
|
});
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
innet.innet(children, handler);
|
|
47
|
+
useEffect.useEffect(() => {
|
|
52
48
|
if (fileUsed) {
|
|
53
49
|
requestBody.content['multipart/form-data'] = { schema };
|
|
54
50
|
}
|
|
@@ -57,7 +53,7 @@ const body = () => {
|
|
|
57
53
|
requestBody.content[type] = { schema };
|
|
58
54
|
}
|
|
59
55
|
}
|
|
60
|
-
}
|
|
56
|
+
});
|
|
61
57
|
};
|
|
62
58
|
|
|
63
59
|
exports.body = body;
|
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -24,12 +24,12 @@ const endpoint = () => {
|
|
|
24
24
|
throw Error(`You cannot use the same endpoints ${method}:${path}`);
|
|
25
25
|
}
|
|
26
26
|
const operation = {};
|
|
27
|
-
if (summary) {
|
|
28
|
-
operation.summary = summary;
|
|
29
|
-
}
|
|
30
27
|
if (operationId) {
|
|
31
28
|
operation.operationId = operationId;
|
|
32
29
|
}
|
|
30
|
+
if (summary) {
|
|
31
|
+
operation.summary = summary;
|
|
32
|
+
}
|
|
33
33
|
if (description) {
|
|
34
34
|
operation.description = description;
|
|
35
35
|
}
|
|
@@ -12,10 +12,6 @@ var getEndpoint = require('../../../utils/getEndpoint/getEndpoint.js');
|
|
|
12
12
|
var useEndpoint = require('../../../hooks/useEndpoint/useEndpoint.js');
|
|
13
13
|
var useServerPlugins = require('../../../hooks/useServerPlugins/useServerPlugins.js');
|
|
14
14
|
|
|
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
15
|
const endpoint = () => {
|
|
20
16
|
const handler = innet.useNewHandler();
|
|
21
17
|
const tag = useTag.useTag();
|
|
@@ -32,12 +28,12 @@ const endpoint = () => {
|
|
|
32
28
|
throw Error(`You cannot use the same endpoints ${method}:${path}`);
|
|
33
29
|
}
|
|
34
30
|
const operation = {};
|
|
35
|
-
if (summary) {
|
|
36
|
-
operation.summary = summary;
|
|
37
|
-
}
|
|
38
31
|
if (operationId) {
|
|
39
32
|
operation.operationId = operationId;
|
|
40
33
|
}
|
|
34
|
+
if (summary) {
|
|
35
|
+
operation.summary = summary;
|
|
36
|
+
}
|
|
41
37
|
if (description) {
|
|
42
38
|
operation.description = description;
|
|
43
39
|
}
|
|
@@ -58,7 +54,7 @@ const endpoint = () => {
|
|
|
58
54
|
useEndpoint.endpointContext.set(handler, { endpoint, operation, props });
|
|
59
55
|
// @ts-expect-error: it's always an object
|
|
60
56
|
useServerPlugins.serverPlugins.set(handler, endpoint.plugins);
|
|
61
|
-
|
|
57
|
+
innet.innet(children, handler);
|
|
62
58
|
};
|
|
63
59
|
|
|
64
60
|
exports.endpoint = endpoint;
|
|
@@ -9,10 +9,6 @@ var useApi = require('../../../hooks/useApi/useApi.js');
|
|
|
9
9
|
var useEndpoint = require('../../../hooks/useEndpoint/useEndpoint.js');
|
|
10
10
|
var useHost = require('../../../hooks/useHost/useHost.js');
|
|
11
11
|
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
15
|
-
|
|
16
12
|
const host = () => {
|
|
17
13
|
const handler = innet.useNewHandler();
|
|
18
14
|
const { docs } = useApi.useApi();
|
|
@@ -30,7 +26,7 @@ const host = () => {
|
|
|
30
26
|
// @ts-expect-error: FIXME
|
|
31
27
|
servers.push(server);
|
|
32
28
|
handler[useHost.hostContext.key] = { server };
|
|
33
|
-
|
|
29
|
+
innet.innet(children, handler);
|
|
34
30
|
};
|
|
35
31
|
|
|
36
32
|
exports.host = host;
|
package/plugins/main/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './server';
|
|
2
1
|
export * from './api';
|
|
2
|
+
export * from './body';
|
|
3
3
|
export * from './contact';
|
|
4
|
-
export * from './license';
|
|
5
|
-
export * from './host';
|
|
6
|
-
export * from './variable';
|
|
7
|
-
export * from './tag';
|
|
8
4
|
export * from './endpoint';
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
5
|
+
export * from './host';
|
|
6
|
+
export * from './license';
|
|
11
7
|
export * from './param';
|
|
12
|
-
export * from './body';
|
|
13
8
|
export * from './preset';
|
|
9
|
+
export * from './response';
|
|
10
|
+
export * from './return';
|
|
11
|
+
export * from './server';
|
|
12
|
+
export * from './tag';
|
|
13
|
+
export * from './variable';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import './server/index.es6.js';
|
|
2
1
|
import './api/index.es6.js';
|
|
2
|
+
import './body/index.es6.js';
|
|
3
3
|
import './contact/index.es6.js';
|
|
4
|
-
import './license/index.es6.js';
|
|
5
|
-
import './host/index.es6.js';
|
|
6
|
-
import './variable/index.es6.js';
|
|
7
|
-
import './tag/index.es6.js';
|
|
8
4
|
import './endpoint/index.es6.js';
|
|
9
|
-
import './
|
|
10
|
-
import './
|
|
5
|
+
import './host/index.es6.js';
|
|
6
|
+
import './license/index.es6.js';
|
|
11
7
|
import './param/index.es6.js';
|
|
12
|
-
import './body/index.es6.js';
|
|
13
8
|
import './preset/index.es6.js';
|
|
9
|
+
import './response/index.es6.js';
|
|
10
|
+
import './return/index.es6.js';
|
|
11
|
+
import './server/index.es6.js';
|
|
12
|
+
import './tag/index.es6.js';
|
|
13
|
+
import './variable/index.es6.js';
|
package/plugins/main/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./server/index.js');
|
|
4
3
|
require('./api/index.js');
|
|
4
|
+
require('./body/index.js');
|
|
5
5
|
require('./contact/index.js');
|
|
6
|
-
require('./license/index.js');
|
|
7
|
-
require('./host/index.js');
|
|
8
|
-
require('./variable/index.js');
|
|
9
|
-
require('./tag/index.js');
|
|
10
6
|
require('./endpoint/index.js');
|
|
11
|
-
require('./
|
|
12
|
-
require('./
|
|
7
|
+
require('./host/index.js');
|
|
8
|
+
require('./license/index.js');
|
|
13
9
|
require('./param/index.js');
|
|
14
|
-
require('./body/index.js');
|
|
15
10
|
require('./preset/index.js');
|
|
11
|
+
require('./response/index.js');
|
|
12
|
+
require('./return/index.js');
|
|
13
|
+
require('./server/index.js');
|
|
14
|
+
require('./tag/index.js');
|
|
15
|
+
require('./variable/index.js');
|
|
16
16
|
|
|
@@ -16,10 +16,6 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
16
16
|
var required = require('../../../utils/rules/required/required.js');
|
|
17
17
|
var oneOf = require('../../../utils/rules/oneOf/oneOf.js');
|
|
18
18
|
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
22
|
-
|
|
23
19
|
const inMap = {
|
|
24
20
|
cookie: 'cookie',
|
|
25
21
|
header: 'header',
|
|
@@ -64,7 +60,7 @@ const param = () => {
|
|
|
64
60
|
rulesMap[key] = override(rule);
|
|
65
61
|
}
|
|
66
62
|
});
|
|
67
|
-
|
|
63
|
+
innet.innet(children, handler);
|
|
68
64
|
};
|
|
69
65
|
|
|
70
66
|
exports.param = param;
|
|
@@ -7,14 +7,10 @@ var jsx = require('@innet/jsx');
|
|
|
7
7
|
require('../../../hooks/index.js');
|
|
8
8
|
var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
|
|
9
9
|
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
13
|
-
|
|
14
10
|
function preset() {
|
|
15
11
|
const children = jsx.useChildren();
|
|
16
12
|
useServerPlugin.useServerPlugin(() => {
|
|
17
|
-
|
|
13
|
+
innet.innet(children, innet.useHandler());
|
|
18
14
|
});
|
|
19
15
|
}
|
|
20
16
|
|
|
@@ -16,10 +16,6 @@ var useSchemaContext = require('../../../hooks/useSchemaContext/useSchemaContext
|
|
|
16
16
|
var getOrAdd = require('../../../utils/getOrAdd/getOrAdd.js');
|
|
17
17
|
var useRule = require('../../../hooks/useRule/useRule.js');
|
|
18
18
|
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
22
|
-
|
|
23
19
|
const statuses = {
|
|
24
20
|
...error.errorStatuses,
|
|
25
21
|
...redirect.redirectStatuses,
|
|
@@ -62,7 +58,7 @@ const response = () => {
|
|
|
62
58
|
useRule.ruleContext.set(handler, rule => {
|
|
63
59
|
rules.response = rule;
|
|
64
60
|
});
|
|
65
|
-
|
|
61
|
+
innet.innet(children, handler);
|
|
66
62
|
};
|
|
67
63
|
|
|
68
64
|
exports.response = response;
|
|
@@ -20,7 +20,6 @@ var useRequestHandler = require('../../../hooks/useRequestHandler/useRequestHand
|
|
|
20
20
|
|
|
21
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
22
|
|
|
23
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
24
23
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
25
24
|
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
26
25
|
var http2__default = /*#__PURE__*/_interopDefaultLegacy(http2);
|
|
@@ -74,9 +73,9 @@ const server = () => {
|
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
|
-
|
|
76
|
+
innet.innet({ props, type: server }, requestHandler);
|
|
78
77
|
});
|
|
79
|
-
|
|
78
|
+
innet.innet(props.children, handler);
|
|
80
79
|
server.listen(port, () => {
|
|
81
80
|
onStart === null || onStart === void 0 ? void 0 : onStart({ https, port });
|
|
82
81
|
});
|
package/plugins/main/tag/tag.js
CHANGED
|
@@ -8,10 +8,6 @@ require('../../../hooks/index.js');
|
|
|
8
8
|
var useTag = require('../../../hooks/useTag/useTag.js');
|
|
9
9
|
var useApi = require('../../../hooks/useApi/useApi.js');
|
|
10
10
|
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
14
|
-
|
|
15
11
|
const tag = () => {
|
|
16
12
|
if (jsx.useContext(useTag.tagContext)) {
|
|
17
13
|
throw Error('You cannot use a <tag> inside another one');
|
|
@@ -33,7 +29,7 @@ const tag = () => {
|
|
|
33
29
|
}
|
|
34
30
|
const handler = innet.useNewHandler();
|
|
35
31
|
handler[useTag.tagContext.key] = tag;
|
|
36
|
-
|
|
32
|
+
innet.innet(children, handler);
|
|
37
33
|
};
|
|
38
34
|
|
|
39
35
|
exports.tag = tag;
|
|
@@ -12,7 +12,6 @@ var file = require('../file/file.js');
|
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
14
|
|
|
15
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
16
15
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
17
16
|
|
|
18
17
|
function cms() {
|
|
@@ -23,10 +22,10 @@ function cms() {
|
|
|
23
22
|
url = url.slice(prefix.length);
|
|
24
23
|
}
|
|
25
24
|
else {
|
|
26
|
-
return
|
|
25
|
+
return innet.innet(children, handler);
|
|
27
26
|
}
|
|
28
27
|
const filePath = path__default["default"].join(dir, url);
|
|
29
|
-
|
|
28
|
+
innet.innet({ children, props: { path: filePath }, type: file.file }, handler);
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
exports.cms = cms;
|
|
@@ -12,7 +12,6 @@ var useThrow = require('../../../hooks/useThrow/useThrow.js');
|
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
14
|
|
|
15
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
16
15
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
17
16
|
var mime__default = /*#__PURE__*/_interopDefaultLegacy(mime);
|
|
18
17
|
|
|
@@ -40,7 +39,7 @@ function file() {
|
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
|
-
|
|
42
|
+
innet.innet(children, handler);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
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,6 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useNewHandler, innet } from 'innet';
|
|
2
2
|
import { useContext, 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,16 +12,26 @@ import { defaultTo } from '../../../utils/rules/defaultTo/defaultTo.es6.js';
|
|
|
13
12
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
14
13
|
import { arrayOf } from '../../../utils/rules/arrayOf/arrayOf.es6.js';
|
|
15
14
|
import { oneOf } from '../../../utils/rules/oneOf/oneOf.es6.js';
|
|
15
|
+
import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
|
|
16
16
|
|
|
17
17
|
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 = [];
|
|
@@ -44,11 +53,11 @@ const array = () => {
|
|
|
44
53
|
}
|
|
45
54
|
});
|
|
46
55
|
innet(children, handler);
|
|
47
|
-
|
|
56
|
+
useEffect(() => {
|
|
48
57
|
if (!oneOfRulesMap && setRule) {
|
|
49
58
|
setRule(rootRule(e => e));
|
|
50
59
|
}
|
|
51
|
-
}
|
|
60
|
+
});
|
|
52
61
|
return;
|
|
53
62
|
}
|
|
54
63
|
innet(children, handler);
|
|
@@ -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,20 +16,26 @@ var defaultTo = require('../../../utils/rules/defaultTo/defaultTo.js');
|
|
|
17
16
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
18
17
|
var arrayOf = require('../../../utils/rules/arrayOf/arrayOf.js');
|
|
19
18
|
var oneOf = require('../../../utils/rules/oneOf/oneOf.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 array = () => {
|
|
26
22
|
useBlock.useBlock('path');
|
|
27
23
|
const setRule = jsx.useContext(useRule.ruleContext);
|
|
28
24
|
const handler = innet.useNewHandler();
|
|
29
|
-
const { children, ...props } = jsx.useProps();
|
|
25
|
+
const { children, maxItems, minItems, uniqueItems, ...props } = jsx.useProps();
|
|
30
26
|
const schema = useSchemaType.useSchemaType('array', props);
|
|
31
27
|
const fieldSchema = {};
|
|
32
28
|
handler[useSchemaContext.schemaContext.key] = fieldSchema;
|
|
33
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
|
+
}
|
|
34
39
|
if (setRule) {
|
|
35
40
|
let oneOfRulesMap;
|
|
36
41
|
const rules = [];
|
|
@@ -51,15 +56,15 @@ const array = () => {
|
|
|
51
56
|
setRule(rootRule(oneOf.oneOf(oneOfRulesMap)));
|
|
52
57
|
}
|
|
53
58
|
});
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
innet.innet(children, handler);
|
|
60
|
+
useEffect.useEffect(() => {
|
|
56
61
|
if (!oneOfRulesMap && setRule) {
|
|
57
62
|
setRule(rootRule(e => e));
|
|
58
63
|
}
|
|
59
|
-
}
|
|
64
|
+
});
|
|
60
65
|
return;
|
|
61
66
|
}
|
|
62
|
-
|
|
67
|
+
innet.innet(children, handler);
|
|
63
68
|
};
|
|
64
69
|
|
|
65
70
|
exports.array = array;
|
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -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) {
|
|
@@ -12,13 +12,9 @@ var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
|
|
|
12
12
|
var useRule = require('../../../hooks/useRule/useRule.js');
|
|
13
13
|
var required = require('../../../utils/rules/required/required.js');
|
|
14
14
|
|
|
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
15
|
const field = () => {
|
|
20
16
|
const handler = innet.useNewHandler();
|
|
21
|
-
const { children, deprecated, key, optional, } = jsx.useProps();
|
|
17
|
+
const { children, deprecated, key, optional, readOnly, writeOnly, } = jsx.useProps();
|
|
22
18
|
const schema = useObjectSchemaContext.useObjectSchemaContext();
|
|
23
19
|
if (!schema.properties) {
|
|
24
20
|
schema.properties = {};
|
|
@@ -31,6 +27,12 @@ const field = () => {
|
|
|
31
27
|
if (deprecated) {
|
|
32
28
|
fieldSchema.deprecated = true;
|
|
33
29
|
}
|
|
30
|
+
if (readOnly) {
|
|
31
|
+
fieldSchema.readOnly = true;
|
|
32
|
+
}
|
|
33
|
+
if (writeOnly) {
|
|
34
|
+
fieldSchema.writeOnly = true;
|
|
35
|
+
}
|
|
34
36
|
schema.properties[key] = fieldSchema;
|
|
35
37
|
if (!optional) {
|
|
36
38
|
if (!schema.required) {
|
|
@@ -48,7 +50,7 @@ const field = () => {
|
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
52
|
useObjectRule.objectRuleContext.set(handler, null);
|
|
51
|
-
|
|
53
|
+
innet.innet(children, handler);
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
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';
|