@innet/server 2.0.0-beta.1 → 2.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +26 -9
- package/hooks/useSchemaType/useSchemaType.js +26 -9
- package/hooks/useServer/useServer.d.ts +0 -2
- package/index.d.ts +2 -2
- package/index.es6.js +89 -87
- package/index.js +202 -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 +10 -6
- package/plugins/schema/date/date.js +10 -6
- 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 +31 -11
- package/plugins/schema/integer/integer.js +31 -11
- package/plugins/schema/number/number.d.ts +32 -0
- package/plugins/schema/number/number.es6.js +23 -8
- package/plugins/schema/number/number.js +22 -7
- 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 +11 -6
- package/plugins/schema/string/string.js +10 -5
- package/plugins/schema/tuple/tuple.es6.js +5 -6
- package/plugins/schema/tuple/tuple.js +5 -10
- package/plugins/schema/uuid/uuid.es6.js +7 -5
- package/plugins/schema/uuid/uuid.js +6 -4
- 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 +8 -1
- 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/index.es6.js +1 -1
- package/utils/rules/values/index.js +1 -0
- package/utils/rules/values/values.d.ts +3 -1
- package/utils/rules/values/values.es6.js +9 -3
- package/utils/rules/values/values.js +9 -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
|
@@ -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();
|
|
@@ -24,11 +20,13 @@ const host = () => {
|
|
|
24
20
|
target.servers = [];
|
|
25
21
|
}
|
|
26
22
|
const { servers } = operation || docs;
|
|
27
|
-
const server =
|
|
23
|
+
const server = {
|
|
24
|
+
...props,
|
|
25
|
+
};
|
|
28
26
|
// @ts-expect-error: FIXME
|
|
29
27
|
servers.push(server);
|
|
30
28
|
handler[useHost.hostContext.key] = { server };
|
|
31
|
-
|
|
29
|
+
innet.innet(children, handler);
|
|
32
30
|
};
|
|
33
31
|
|
|
34
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
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import innet, { useNewHandler } from 'innet';
|
|
1
|
+
import { useNewHandler, innet } from 'innet';
|
|
3
2
|
import { useProps } from '@innet/jsx';
|
|
4
3
|
import '../../../hooks/index.es6.js';
|
|
5
4
|
import '../../../utils/index.es6.js';
|
|
@@ -25,8 +24,8 @@ const param = () => {
|
|
|
25
24
|
if (!operation.parameters) {
|
|
26
25
|
operation.parameters = [];
|
|
27
26
|
}
|
|
28
|
-
const
|
|
29
|
-
const params =
|
|
27
|
+
const { children, ...props } = useProps();
|
|
28
|
+
const params = { ...props };
|
|
30
29
|
if (props.in === 'path') {
|
|
31
30
|
params.required = (_a = params.required) !== null && _a !== void 0 ? _a : true;
|
|
32
31
|
}
|
|
@@ -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
|
require('../../../hooks/index.js');
|
|
@@ -17,10 +16,6 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
17
16
|
var required = require('../../../utils/rules/required/required.js');
|
|
18
17
|
var oneOf = require('../../../utils/rules/oneOf/oneOf.js');
|
|
19
18
|
|
|
20
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
-
|
|
22
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
23
|
-
|
|
24
19
|
const inMap = {
|
|
25
20
|
cookie: 'cookie',
|
|
26
21
|
header: 'header',
|
|
@@ -33,8 +28,8 @@ const param = () => {
|
|
|
33
28
|
if (!operation.parameters) {
|
|
34
29
|
operation.parameters = [];
|
|
35
30
|
}
|
|
36
|
-
const
|
|
37
|
-
const params =
|
|
31
|
+
const { children, ...props } = jsx.useProps();
|
|
32
|
+
const params = { ...props };
|
|
38
33
|
if (props.in === 'path') {
|
|
39
34
|
params.required = (_a = params.required) !== null && _a !== void 0 ? _a : true;
|
|
40
35
|
}
|
|
@@ -65,7 +60,7 @@ const param = () => {
|
|
|
65
60
|
rulesMap[key] = override(rule);
|
|
66
61
|
}
|
|
67
62
|
});
|
|
68
|
-
|
|
63
|
+
innet.innet(children, handler);
|
|
69
64
|
};
|
|
70
65
|
|
|
71
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
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useNewHandler, innet } from 'innet';
|
|
2
2
|
import { useProps, useContext } from '@innet/jsx';
|
|
3
3
|
import '../../../hooks/index.es6.js';
|
|
4
4
|
import '../../../utils/index.es6.js';
|
|
@@ -12,7 +12,11 @@ import { schemaContext } from '../../../hooks/useSchemaContext/useSchemaContext.
|
|
|
12
12
|
import { getOrAdd } from '../../../utils/getOrAdd/getOrAdd.es6.js';
|
|
13
13
|
import { ruleContext } from '../../../hooks/useRule/useRule.es6.js';
|
|
14
14
|
|
|
15
|
-
const statuses =
|
|
15
|
+
const statuses = {
|
|
16
|
+
...errorStatuses,
|
|
17
|
+
...redirectStatuses,
|
|
18
|
+
...successStatuses,
|
|
19
|
+
};
|
|
16
20
|
const response = () => {
|
|
17
21
|
var _a;
|
|
18
22
|
let { children, description = '', status = 'default', type = 'application/json', } = useProps() || {};
|
|
@@ -37,9 +41,12 @@ const response = () => {
|
|
|
37
41
|
description,
|
|
38
42
|
};
|
|
39
43
|
if (schema) {
|
|
40
|
-
response.content =
|
|
44
|
+
response.content = {
|
|
45
|
+
...defaultResponse === null || defaultResponse === void 0 ? void 0 : defaultResponse.content,
|
|
46
|
+
[type]: {
|
|
41
47
|
schema,
|
|
42
|
-
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
43
50
|
}
|
|
44
51
|
operation.responses[status] = response;
|
|
45
52
|
schemaContext.set(handler, schema);
|
|
@@ -16,11 +16,11 @@ 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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const statuses = {
|
|
20
|
+
...error.errorStatuses,
|
|
21
|
+
...redirect.redirectStatuses,
|
|
22
|
+
...success.successStatuses,
|
|
23
|
+
};
|
|
24
24
|
const response = () => {
|
|
25
25
|
var _a;
|
|
26
26
|
let { children, description = '', status = 'default', type = 'application/json', } = jsx.useProps() || {};
|
|
@@ -45,9 +45,12 @@ const response = () => {
|
|
|
45
45
|
description,
|
|
46
46
|
};
|
|
47
47
|
if (schema) {
|
|
48
|
-
response.content =
|
|
48
|
+
response.content = {
|
|
49
|
+
...defaultResponse === null || defaultResponse === void 0 ? void 0 : defaultResponse.content,
|
|
50
|
+
[type]: {
|
|
49
51
|
schema,
|
|
50
|
-
}
|
|
52
|
+
},
|
|
53
|
+
};
|
|
51
54
|
}
|
|
52
55
|
operation.responses[status] = response;
|
|
53
56
|
useSchemaContext.schemaContext.set(handler, schema);
|
|
@@ -55,7 +58,7 @@ const response = () => {
|
|
|
55
58
|
useRule.ruleContext.set(handler, rule => {
|
|
56
59
|
rules.response = rule;
|
|
57
60
|
});
|
|
58
|
-
|
|
61
|
+
innet.innet(children, handler);
|
|
59
62
|
};
|
|
60
63
|
|
|
61
64
|
exports.response = response;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import innet, { useNewHandler } from 'innet';
|
|
1
|
+
import { useNewHandler, innet } from 'innet';
|
|
3
2
|
import { useProps } from '@innet/jsx';
|
|
4
3
|
import fs from 'node:fs';
|
|
5
4
|
import http from 'node:http';
|
|
@@ -56,15 +55,13 @@ const server = () => {
|
|
|
56
55
|
const requestHandler = Object.create(handler);
|
|
57
56
|
actionContext.set(requestHandler, action);
|
|
58
57
|
requestHandlerContext.set(requestHandler, requestHandler);
|
|
59
|
-
function server() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
58
|
+
async function server() {
|
|
59
|
+
for (const plugin of plugins) {
|
|
60
|
+
const result = await plugin();
|
|
61
|
+
if (result !== undefined) {
|
|
62
|
+
return result;
|
|
66
63
|
}
|
|
67
|
-
}
|
|
64
|
+
}
|
|
68
65
|
}
|
|
69
66
|
innet({ props, type: server }, requestHandler);
|
|
70
67
|
});
|
|
@@ -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');
|
|
@@ -21,7 +20,6 @@ var useRequestHandler = require('../../../hooks/useRequestHandler/useRequestHand
|
|
|
21
20
|
|
|
22
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
22
|
|
|
24
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
25
23
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
26
24
|
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
27
25
|
var http2__default = /*#__PURE__*/_interopDefaultLegacy(http2);
|
|
@@ -67,19 +65,17 @@ const server = () => {
|
|
|
67
65
|
const requestHandler = Object.create(handler);
|
|
68
66
|
useAction.actionContext.set(requestHandler, action);
|
|
69
67
|
useRequestHandler.requestHandlerContext.set(requestHandler, requestHandler);
|
|
70
|
-
function server() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
68
|
+
async function server() {
|
|
69
|
+
for (const plugin of plugins) {
|
|
70
|
+
const result = await plugin();
|
|
71
|
+
if (result !== undefined) {
|
|
72
|
+
return result;
|
|
77
73
|
}
|
|
78
|
-
}
|
|
74
|
+
}
|
|
79
75
|
}
|
|
80
|
-
|
|
76
|
+
innet.innet({ props, type: server }, requestHandler);
|
|
81
77
|
});
|
|
82
|
-
|
|
78
|
+
innet.innet(props.children, handler);
|
|
83
79
|
server.listen(port, () => {
|
|
84
80
|
onStart === null || onStart === void 0 ? void 0 : onStart({ https, port });
|
|
85
81
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { tag } from './tag.es6.js';
|
|
1
|
+
export { TAG_GROUP_NAME, tag } from './tag.es6.js';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
+
export interface TagGroup {
|
|
3
|
+
name: string;
|
|
4
|
+
tags: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare const TAG_GROUP_NAME = "x-tagGroups";
|
|
2
7
|
export interface TagProps {
|
|
3
8
|
children?: any;
|
|
4
9
|
/**
|
|
@@ -6,7 +11,9 @@ export interface TagProps {
|
|
|
6
11
|
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
7
12
|
* */
|
|
8
13
|
description?: string;
|
|
9
|
-
/**
|
|
14
|
+
/** A name of the tag group. */
|
|
15
|
+
group?: string;
|
|
16
|
+
/** A name of the tag. */
|
|
10
17
|
name: string;
|
|
11
18
|
}
|
|
12
19
|
export declare const tag: HandlerPlugin;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useNewHandler, innet } from 'innet';
|
|
2
2
|
import { useContext, useProps } from '@innet/jsx';
|
|
3
3
|
import '../../../hooks/index.es6.js';
|
|
4
4
|
import { tagContext } from '../../../hooks/useTag/useTag.es6.js';
|
|
5
5
|
import { useApi } from '../../../hooks/useApi/useApi.es6.js';
|
|
6
6
|
|
|
7
|
+
const TAG_GROUP_NAME = 'x-tagGroups';
|
|
7
8
|
const tag = () => {
|
|
8
9
|
if (useContext(tagContext)) {
|
|
9
10
|
throw Error('You cannot use a <tag> inside another one');
|
|
10
11
|
}
|
|
11
|
-
const { children, description, name, } = useProps();
|
|
12
|
+
const { children, description, group, name, } = useProps();
|
|
12
13
|
const { docs } = useApi();
|
|
13
14
|
const tag = { name };
|
|
14
15
|
if (description) {
|
|
@@ -23,9 +24,25 @@ const tag = () => {
|
|
|
23
24
|
else {
|
|
24
25
|
throw Error(`You cannot use two tags with the same name (${name})`);
|
|
25
26
|
}
|
|
27
|
+
if (group) {
|
|
28
|
+
if (docs[TAG_GROUP_NAME]) {
|
|
29
|
+
const groups = docs[TAG_GROUP_NAME];
|
|
30
|
+
const tagGroup = groups.find(({ name }) => name === group);
|
|
31
|
+
if (tagGroup) {
|
|
32
|
+
tagGroup.tags.push(name);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
groups.push({ name: group, tags: [name] });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// @ts-expect-error Custom field
|
|
40
|
+
docs[TAG_GROUP_NAME] = [{ name: group, tags: [name] }];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
26
43
|
const handler = useNewHandler();
|
|
27
44
|
handler[tagContext.key] = tag;
|
|
28
45
|
innet(children, handler);
|
|
29
46
|
};
|
|
30
47
|
|
|
31
|
-
export { tag };
|
|
48
|
+
export { TAG_GROUP_NAME, tag };
|
package/plugins/main/tag/tag.js
CHANGED
|
@@ -8,15 +8,12 @@ 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
|
-
|
|
12
|
-
|
|
13
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
14
|
-
|
|
11
|
+
const TAG_GROUP_NAME = 'x-tagGroups';
|
|
15
12
|
const tag = () => {
|
|
16
13
|
if (jsx.useContext(useTag.tagContext)) {
|
|
17
14
|
throw Error('You cannot use a <tag> inside another one');
|
|
18
15
|
}
|
|
19
|
-
const { children, description, name, } = jsx.useProps();
|
|
16
|
+
const { children, description, group, name, } = jsx.useProps();
|
|
20
17
|
const { docs } = useApi.useApi();
|
|
21
18
|
const tag = { name };
|
|
22
19
|
if (description) {
|
|
@@ -31,9 +28,26 @@ const tag = () => {
|
|
|
31
28
|
else {
|
|
32
29
|
throw Error(`You cannot use two tags with the same name (${name})`);
|
|
33
30
|
}
|
|
31
|
+
if (group) {
|
|
32
|
+
if (docs[TAG_GROUP_NAME]) {
|
|
33
|
+
const groups = docs[TAG_GROUP_NAME];
|
|
34
|
+
const tagGroup = groups.find(({ name }) => name === group);
|
|
35
|
+
if (tagGroup) {
|
|
36
|
+
tagGroup.tags.push(name);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
groups.push({ name: group, tags: [name] });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// @ts-expect-error Custom field
|
|
44
|
+
docs[TAG_GROUP_NAME] = [{ name: group, tags: [name] }];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
34
47
|
const handler = innet.useNewHandler();
|
|
35
48
|
handler[useTag.tagContext.key] = tag;
|
|
36
|
-
|
|
49
|
+
innet.innet(children, handler);
|
|
37
50
|
};
|
|
38
51
|
|
|
52
|
+
exports.TAG_GROUP_NAME = TAG_GROUP_NAME;
|
|
39
53
|
exports.tag = tag;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import { useProps } from '@innet/jsx';
|
|
3
2
|
import '../../../hooks/index.es6.js';
|
|
4
3
|
import { useHost } from '../../../hooks/useHost/useHost.es6.js';
|
|
5
4
|
|
|
6
5
|
const variable = () => {
|
|
7
6
|
const { server } = useHost();
|
|
8
|
-
const
|
|
7
|
+
const { key, values,
|
|
9
8
|
// predefine
|
|
10
|
-
value = values === null || values === void 0 ? void 0 : values[0]
|
|
9
|
+
value = values === null || values === void 0 ? void 0 : values[0], ...rest } = useProps();
|
|
11
10
|
if (!server.variables) {
|
|
12
11
|
server.variables = {};
|
|
13
12
|
}
|
|
14
13
|
// @ts-expect-error: FIXME
|
|
15
|
-
server.variables[key] =
|
|
14
|
+
server.variables[key] = { ...rest, default: value, enum: values };
|
|
16
15
|
};
|
|
17
16
|
|
|
18
17
|
export { variable };
|
|
@@ -2,21 +2,20 @@
|
|
|
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
|
var useHost = require('../../../hooks/useHost/useHost.js');
|
|
9
8
|
|
|
10
9
|
const variable = () => {
|
|
11
10
|
const { server } = useHost.useHost();
|
|
12
|
-
const
|
|
11
|
+
const { key, values,
|
|
13
12
|
// predefine
|
|
14
|
-
value = values === null || values === void 0 ? void 0 : values[0]
|
|
13
|
+
value = values === null || values === void 0 ? void 0 : values[0], ...rest } = jsx.useProps();
|
|
15
14
|
if (!server.variables) {
|
|
16
15
|
server.variables = {};
|
|
17
16
|
}
|
|
18
17
|
// @ts-expect-error: FIXME
|
|
19
|
-
server.variables[key] =
|
|
18
|
+
server.variables[key] = { ...rest, default: value, enum: values };
|
|
20
19
|
};
|
|
21
20
|
|
|
22
21
|
exports.variable = variable;
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface CookieProps extends
|
|
2
|
+
import { type Cookies } from 'cookie';
|
|
3
|
+
export interface CookieProps extends Cookies {
|
|
4
4
|
key: string;
|
|
5
5
|
value?: string;
|
|
6
6
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import { useProps } from '@innet/jsx';
|
|
3
2
|
import '../../../hooks/index.es6.js';
|
|
4
3
|
import { useAction } from '../../../hooks/useAction/useAction.es6.js';
|
|
5
4
|
|
|
6
5
|
const cookie = () => {
|
|
7
6
|
const action = useAction();
|
|
8
|
-
const
|
|
7
|
+
const { key, value, ...opt } = useProps();
|
|
9
8
|
action.setCookie(key, value, opt);
|
|
10
9
|
};
|
|
11
10
|
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var jsx = require('@innet/jsx');
|
|
7
6
|
require('../../../hooks/index.js');
|
|
8
7
|
var useAction = require('../../../hooks/useAction/useAction.js');
|
|
9
8
|
|
|
10
9
|
const cookie = () => {
|
|
11
10
|
const action = useAction.useAction();
|
|
12
|
-
const
|
|
11
|
+
const { key, value, ...opt } = jsx.useProps();
|
|
13
12
|
action.setCookie(key, value, opt);
|
|
14
13
|
};
|
|
15
14
|
|
|
@@ -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';
|
|
@@ -59,7 +58,7 @@ const errorStatuses = {
|
|
|
59
58
|
webServerIsDown: 521,
|
|
60
59
|
};
|
|
61
60
|
const error = () => {
|
|
62
|
-
const
|
|
61
|
+
const { children, ...props } = useProps();
|
|
63
62
|
const res = useResponse();
|
|
64
63
|
if (!res) {
|
|
65
64
|
throw Error('<error> MUST be in <request>');
|
|
@@ -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');
|
|
@@ -63,7 +62,7 @@ const errorStatuses = {
|
|
|
63
62
|
webServerIsDown: 521,
|
|
64
63
|
};
|
|
65
64
|
const error = () => {
|
|
66
|
-
const
|
|
65
|
+
const { children, ...props } = jsx.useProps();
|
|
67
66
|
const res = useResponse.useResponse();
|
|
68
67
|
if (!res) {
|
|
69
68
|
throw Error('<error> MUST be in <request>');
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import innet, { useHandler } from 'innet';
|
|
1
|
+
import { useHandler, innet } from 'innet';
|
|
3
2
|
import { useProps } from '@innet/jsx';
|
|
4
3
|
import fs from 'node:fs';
|
|
5
4
|
import mime from 'mime';
|
|
@@ -9,7 +8,7 @@ import { useThrow } from '../../../hooks/useThrow/useThrow.es6.js';
|
|
|
9
8
|
|
|
10
9
|
function file() {
|
|
11
10
|
const handler = useHandler();
|
|
12
|
-
const
|
|
11
|
+
const { children, ...props } = useProps();
|
|
13
12
|
const res = useResponse();
|
|
14
13
|
if (!res) {
|
|
15
14
|
useThrow('<{type}> MUST be in <request> or <fallback>');
|