@innet/server 2.0.0-alpha.23 → 2.0.0-alpha.25
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/handler/handler.d.ts +5 -5
- package/handler/handler.es6.js +3 -3
- package/handler/handler.js +3 -3
- package/hooks/index.d.ts +1 -0
- package/hooks/index.es6.js +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useClientIp/useClientIp.d.ts +1 -1
- package/hooks/useEndpoint/useEndpoint.d.ts +1 -1
- package/hooks/useSchemaType/useSchemaType.d.ts +3 -3
- package/hooks/useSchemaType/useSchemaType.es6.js +5 -5
- package/hooks/useSchemaType/useSchemaType.js +5 -5
- package/hooks/useServer/useServer.d.ts +1 -1
- package/hooks/useServerPort/index.d.ts +1 -0
- package/hooks/useServerPort/index.es6.js +1 -0
- package/hooks/useServerPort/index.js +10 -0
- package/hooks/useServerPort/useServerPort.d.ts +3 -0
- package/hooks/useServerPort/useServerPort.es6.js +14 -0
- package/hooks/useServerPort/useServerPort.js +19 -0
- package/index.es6.js +1 -0
- package/index.js +3 -0
- package/package.json +1 -1
- package/plugins/main/api/api.d.ts +10 -10
- package/plugins/main/api/api.es6.js +7 -7
- package/plugins/main/api/api.js +7 -7
- package/plugins/main/contact/contact.d.ts +2 -2
- package/plugins/main/endpoint/endpoint.d.ts +15 -15
- package/plugins/main/endpoint/endpoint.es6.js +3 -3
- package/plugins/main/endpoint/endpoint.js +3 -3
- package/plugins/main/host/host.d.ts +5 -5
- package/plugins/main/license/license.d.ts +5 -5
- package/plugins/main/param/param.d.ts +11 -11
- package/plugins/main/param/param.es6.js +3 -3
- package/plugins/main/param/param.js +3 -3
- package/plugins/main/response/response.d.ts +1 -1
- package/plugins/main/response/response.es6.js +2 -2
- package/plugins/main/response/response.js +2 -2
- package/plugins/main/server/server.d.ts +4 -4
- package/plugins/main/server/server.es6.js +9 -7
- package/plugins/main/server/server.js +9 -7
- package/plugins/main/tag/tag.d.ts +2 -2
- package/plugins/main/tag/tag.es6.js +1 -1
- package/plugins/main/tag/tag.js +1 -1
- package/plugins/main/variable/variable.d.ts +5 -5
- package/plugins/main/variable/variable.es6.js +3 -1
- package/plugins/main/variable/variable.js +3 -1
- package/plugins/request/cms/cms.es6.js +2 -2
- package/plugins/request/cms/cms.js +2 -2
- package/plugins/request/error/error.d.ts +40 -40
- package/plugins/request/error/error.es6.js +42 -42
- package/plugins/request/error/error.js +42 -42
- package/plugins/request/file/file.es6.js +2 -3
- package/plugins/request/file/file.js +2 -3
- package/plugins/request/header/header.es6.js +1 -1
- package/plugins/request/header/header.js +1 -1
- package/plugins/request/proxy/proxy.d.ts +2 -2
- package/plugins/request/proxy/proxy.es6.js +2 -2
- package/plugins/request/proxy/proxy.js +2 -2
- package/plugins/request/redirect/redirect.d.ts +7 -7
- package/plugins/request/redirect/redirect.es6.js +7 -7
- package/plugins/request/redirect/redirect.js +7 -7
- package/plugins/request/success/success.d.ts +6 -6
- package/plugins/request/success/success.es6.js +8 -8
- package/plugins/request/success/success.js +8 -8
- package/plugins/schema/binary/binary.d.ts +3 -3
- package/plugins/schema/date/date.d.ts +1 -1
- package/plugins/schema/date/date.es6.js +3 -3
- package/plugins/schema/date/date.js +3 -3
- package/plugins/schema/field/field.es6.js +1 -1
- package/plugins/schema/field/field.js +1 -1
- package/plugins/schema/integer/integer.d.ts +3 -3
- package/plugins/schema/integer/integer.es6.js +1 -1
- package/plugins/schema/integer/integer.js +1 -1
- package/plugins/schema/number/number.d.ts +2 -2
- package/plugins/schema/number/number.es6.js +1 -1
- package/plugins/schema/number/number.js +1 -1
- package/plugins/schema/string/string.d.ts +2 -2
- package/plugins/schema/string/string.es6.js +1 -1
- package/plugins/schema/string/string.js +1 -1
- package/plugins/utils/dts/dts.d.ts +1 -1
- package/plugins/utils/dts/dts.es6.js +1 -1
- package/plugins/utils/dts/dts.js +1 -1
- package/plugins/utils/env/env.d.ts +1 -1
- package/plugins/utils/env/env.es6.js +1 -1
- package/plugins/utils/env/env.js +1 -1
- package/plugins/utils/protection/protection.d.ts +3 -3
- package/plugins/utils/protection/protection.es6.js +3 -3
- package/plugins/utils/protection/protection.js +3 -3
- package/plugins/utils/swagger/swagger.es6.js +1 -1
- package/plugins/utils/swagger/swagger.js +1 -1
- package/types.d.ts +13 -13
- package/utils/FileData/Bin.d.ts +13 -13
- package/utils/FileData/Bin.es6.js +2 -2
- package/utils/FileData/Bin.js +2 -2
- package/utils/action/Action.d.ts +12 -12
- package/utils/action/Action.es6.js +80 -80
- package/utils/action/Action.js +79 -79
- package/utils/dateFormat/dateFormat.d.ts +1 -1
- package/utils/dateFormat/dateFormat.es6.js +1 -1
- package/utils/dateFormat/dateFormat.js +1 -1
- package/utils/generateTypes/generateTypes.es6.js +3 -3
- package/utils/generateTypes/generateTypes.js +3 -3
- package/utils/getOrAdd/getOrAdd.d.ts +1 -1
- package/utils/httpOnStart/httpOnStart.d.ts +1 -1
- package/utils/httpOnStart/httpOnStart.es6.js +1 -1
- package/utils/httpOnStart/httpOnStart.js +1 -1
- package/utils/rules/binaryAccept/binaryAccept.es6.js +2 -2
- package/utils/rules/binaryAccept/binaryAccept.js +2 -2
- package/utils/rules/dateTo/dateTo.d.ts +1 -1
- package/utils/rules/helpers.d.ts +1 -1
- package/utils/rules/int/int.es6.js +2 -2
- package/utils/rules/int/int.js +2 -2
- package/utils/rules/max/max.d.ts +1 -1
- package/utils/rules/max/max.es6.js +3 -3
- package/utils/rules/max/max.js +3 -3
- package/utils/rules/maxBin/maxBin.es6.js +2 -2
- package/utils/rules/maxBin/maxBin.js +2 -2
- package/utils/rules/maxDate/maxDate.es6.js +1 -1
- package/utils/rules/maxDate/maxDate.js +1 -1
- package/utils/rules/maxLength/maxLength.es6.js +2 -2
- package/utils/rules/maxLength/maxLength.js +2 -2
- package/utils/rules/min/min.d.ts +1 -1
- package/utils/rules/min/min.es6.js +3 -3
- package/utils/rules/min/min.js +3 -3
- package/utils/rules/minBin/minBin.es6.js +2 -2
- package/utils/rules/minBin/minBin.js +2 -2
- package/utils/rules/minDate/minDate.es6.js +1 -1
- package/utils/rules/minDate/minDate.js +1 -1
- package/utils/rules/minLength/minLength.es6.js +2 -2
- package/utils/rules/minLength/minLength.js +2 -2
- package/utils/rules/pattern/pattern.d.ts +1 -1
- package/utils/rules/pattern/pattern.es6.js +2 -1
- package/utils/rules/pattern/pattern.js +2 -1
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { type HandlerPlugin } from 'innet';
|
|
3
3
|
import { type IncomingMessage } from 'http';
|
|
4
4
|
export interface ProxyProps {
|
|
5
|
-
to: string;
|
|
6
|
-
secure?: boolean;
|
|
7
5
|
onProxyRes?: (res: IncomingMessage) => void;
|
|
6
|
+
secure?: boolean;
|
|
7
|
+
to: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const proxy: HandlerPlugin;
|
|
@@ -6,7 +6,7 @@ import { useResponse } from '../../../hooks/useResponse/useResponse.es6.js';
|
|
|
6
6
|
import { useThrow } from '../../../hooks/useThrow/useThrow.es6.js';
|
|
7
7
|
|
|
8
8
|
const proxy = () => {
|
|
9
|
-
const {
|
|
9
|
+
const { onProxyRes, secure = false, to, } = useProps();
|
|
10
10
|
const req = useRequest();
|
|
11
11
|
const res = useResponse();
|
|
12
12
|
if (!req || !res) {
|
|
@@ -17,7 +17,7 @@ const proxy = () => {
|
|
|
17
17
|
if (onProxyRes) {
|
|
18
18
|
proxyServer.on('proxyRes', onProxyRes);
|
|
19
19
|
}
|
|
20
|
-
proxyServer.web(req, res, { target: to
|
|
20
|
+
proxyServer.web(req, res, { secure, target: to });
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export { proxy };
|
|
@@ -14,7 +14,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
14
14
|
var httpProxy__default = /*#__PURE__*/_interopDefaultLegacy(httpProxy);
|
|
15
15
|
|
|
16
16
|
const proxy = () => {
|
|
17
|
-
const {
|
|
17
|
+
const { onProxyRes, secure = false, to, } = jsx.useProps();
|
|
18
18
|
const req = useRequest.useRequest();
|
|
19
19
|
const res = useResponse.useResponse();
|
|
20
20
|
if (!req || !res) {
|
|
@@ -25,7 +25,7 @@ const proxy = () => {
|
|
|
25
25
|
if (onProxyRes) {
|
|
26
26
|
proxyServer.on('proxyRes', onProxyRes);
|
|
27
27
|
}
|
|
28
|
-
proxyServer.web(req, res, { target: to
|
|
28
|
+
proxyServer.web(req, res, { secure, target: to });
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
exports.proxy = proxy;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export declare const redirectStatuses: {
|
|
3
|
-
multipleChoices: number;
|
|
4
|
-
movedPermanently: number;
|
|
5
3
|
found: number;
|
|
6
|
-
|
|
4
|
+
movedPermanently: number;
|
|
5
|
+
multipleChoices: number;
|
|
7
6
|
notModified: number;
|
|
8
|
-
useProxy: number;
|
|
9
|
-
temporaryRedirect: number;
|
|
10
7
|
permanentRedirect: number;
|
|
8
|
+
seeOther: number;
|
|
9
|
+
temporaryRedirect: number;
|
|
10
|
+
useProxy: number;
|
|
11
11
|
};
|
|
12
12
|
export type RedirectStatuses = keyof typeof redirectStatuses;
|
|
13
13
|
export interface RedirectProps {
|
|
14
|
-
to: string;
|
|
15
14
|
encode?: boolean;
|
|
16
|
-
status?:
|
|
15
|
+
status?: RedirectStatuses | number;
|
|
16
|
+
to: string;
|
|
17
17
|
}
|
|
18
18
|
export declare const redirect: HandlerPlugin;
|
|
@@ -4,14 +4,14 @@ import { useResponse } from '../../../hooks/useResponse/useResponse.es6.js';
|
|
|
4
4
|
import { useHeaders } from '../../../hooks/useHeaders/useHeaders.es6.js';
|
|
5
5
|
|
|
6
6
|
const redirectStatuses = {
|
|
7
|
-
multipleChoices: 300,
|
|
8
|
-
movedPermanently: 301,
|
|
9
7
|
found: 302,
|
|
10
|
-
|
|
8
|
+
movedPermanently: 301,
|
|
9
|
+
multipleChoices: 300,
|
|
11
10
|
notModified: 304,
|
|
12
|
-
useProxy: 305,
|
|
13
|
-
temporaryRedirect: 307,
|
|
14
11
|
permanentRedirect: 308,
|
|
12
|
+
seeOther: 303,
|
|
13
|
+
temporaryRedirect: 307,
|
|
14
|
+
useProxy: 305,
|
|
15
15
|
};
|
|
16
16
|
function getStatus(status) {
|
|
17
17
|
if (typeof status === 'number')
|
|
@@ -30,10 +30,10 @@ const redirect = () => {
|
|
|
30
30
|
}
|
|
31
31
|
const headers = useHeaders();
|
|
32
32
|
const props = useProps();
|
|
33
|
-
const {
|
|
33
|
+
const { encode, status = 301, to, } = props;
|
|
34
34
|
res.writeHead(getStatus(status), {
|
|
35
|
-
location: encode ? customEncode(to) : to,
|
|
36
35
|
'Cache-Control': (_a = headers['Cache-Control']) !== null && _a !== void 0 ? _a : 'no-cache, no-store, must-revalidate',
|
|
36
|
+
location: encode ? customEncode(to) : to,
|
|
37
37
|
});
|
|
38
38
|
res.end();
|
|
39
39
|
};
|
|
@@ -8,14 +8,14 @@ var useResponse = require('../../../hooks/useResponse/useResponse.js');
|
|
|
8
8
|
var useHeaders = require('../../../hooks/useHeaders/useHeaders.js');
|
|
9
9
|
|
|
10
10
|
const redirectStatuses = {
|
|
11
|
-
multipleChoices: 300,
|
|
12
|
-
movedPermanently: 301,
|
|
13
11
|
found: 302,
|
|
14
|
-
|
|
12
|
+
movedPermanently: 301,
|
|
13
|
+
multipleChoices: 300,
|
|
15
14
|
notModified: 304,
|
|
16
|
-
useProxy: 305,
|
|
17
|
-
temporaryRedirect: 307,
|
|
18
15
|
permanentRedirect: 308,
|
|
16
|
+
seeOther: 303,
|
|
17
|
+
temporaryRedirect: 307,
|
|
18
|
+
useProxy: 305,
|
|
19
19
|
};
|
|
20
20
|
function getStatus(status) {
|
|
21
21
|
if (typeof status === 'number')
|
|
@@ -34,10 +34,10 @@ const redirect = () => {
|
|
|
34
34
|
}
|
|
35
35
|
const headers = useHeaders.useHeaders();
|
|
36
36
|
const props = jsx.useProps();
|
|
37
|
-
const {
|
|
37
|
+
const { encode, status = 301, to, } = props;
|
|
38
38
|
res.writeHead(getStatus(status), {
|
|
39
|
-
location: encode ? customEncode(to) : to,
|
|
40
39
|
'Cache-Control': (_a = headers['Cache-Control']) !== null && _a !== void 0 ? _a : 'no-cache, no-store, must-revalidate',
|
|
40
|
+
location: encode ? customEncode(to) : to,
|
|
41
41
|
});
|
|
42
42
|
res.end();
|
|
43
43
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export declare const successStatuses: {
|
|
3
|
-
readonly ok: 200;
|
|
4
|
-
readonly created: 201;
|
|
5
3
|
readonly accepted: 202;
|
|
6
|
-
readonly
|
|
4
|
+
readonly alreadyReported: 208;
|
|
5
|
+
readonly created: 201;
|
|
6
|
+
readonly multiStatus: 207;
|
|
7
7
|
readonly noContent: 204;
|
|
8
|
-
readonly
|
|
8
|
+
readonly ok: 200;
|
|
9
|
+
readonly outside: 203;
|
|
9
10
|
readonly partialContent: 206;
|
|
10
|
-
readonly
|
|
11
|
-
readonly alreadyReported: 208;
|
|
11
|
+
readonly resetContent: 205;
|
|
12
12
|
};
|
|
13
13
|
export type SuccessStatuses = keyof typeof successStatuses;
|
|
14
14
|
export interface SuccessProps {
|
|
@@ -5,19 +5,19 @@ import { useResponse } from '../../../hooks/useResponse/useResponse.es6.js';
|
|
|
5
5
|
import { JSONString } from '../../../utils/JSONString/JSONString.es6.js';
|
|
6
6
|
|
|
7
7
|
const successStatuses = {
|
|
8
|
-
ok: 200,
|
|
9
|
-
created: 201,
|
|
10
8
|
accepted: 202,
|
|
11
|
-
|
|
9
|
+
alreadyReported: 208,
|
|
10
|
+
created: 201,
|
|
11
|
+
multiStatus: 207,
|
|
12
12
|
noContent: 204,
|
|
13
|
-
|
|
13
|
+
ok: 200,
|
|
14
|
+
outside: 203,
|
|
14
15
|
partialContent: 206,
|
|
15
|
-
|
|
16
|
-
alreadyReported: 208,
|
|
16
|
+
resetContent: 205,
|
|
17
17
|
};
|
|
18
18
|
const success = () => {
|
|
19
19
|
const children = useChildren();
|
|
20
|
-
const { status, type } = useProps() || {};
|
|
20
|
+
const { status, type, } = useProps() || {};
|
|
21
21
|
const res = useResponse();
|
|
22
22
|
if (!res) {
|
|
23
23
|
throw Error('<success> MUST be in <request>');
|
|
@@ -25,7 +25,7 @@ const success = () => {
|
|
|
25
25
|
res.statusCode = typeof status === 'string' ? successStatuses[status] : status !== null && status !== void 0 ? status : ((children) ? 200 : 204);
|
|
26
26
|
if (children === null || children === void 0 ? void 0 : children[0]) {
|
|
27
27
|
const child = children[0];
|
|
28
|
-
const contentType = type || (['
|
|
28
|
+
const contentType = type || (['bigint', 'boolean', 'number', 'string'].includes(typeof child)
|
|
29
29
|
? 'text/plain'
|
|
30
30
|
: 'application/json');
|
|
31
31
|
res.setHeader('Content-Type', contentType);
|
|
@@ -9,19 +9,19 @@ var useResponse = require('../../../hooks/useResponse/useResponse.js');
|
|
|
9
9
|
var JSONString = require('../../../utils/JSONString/JSONString.js');
|
|
10
10
|
|
|
11
11
|
const successStatuses = {
|
|
12
|
-
ok: 200,
|
|
13
|
-
created: 201,
|
|
14
12
|
accepted: 202,
|
|
15
|
-
|
|
13
|
+
alreadyReported: 208,
|
|
14
|
+
created: 201,
|
|
15
|
+
multiStatus: 207,
|
|
16
16
|
noContent: 204,
|
|
17
|
-
|
|
17
|
+
ok: 200,
|
|
18
|
+
outside: 203,
|
|
18
19
|
partialContent: 206,
|
|
19
|
-
|
|
20
|
-
alreadyReported: 208,
|
|
20
|
+
resetContent: 205,
|
|
21
21
|
};
|
|
22
22
|
const success = () => {
|
|
23
23
|
const children = jsx.useChildren();
|
|
24
|
-
const { status, type } = jsx.useProps() || {};
|
|
24
|
+
const { status, type, } = jsx.useProps() || {};
|
|
25
25
|
const res = useResponse.useResponse();
|
|
26
26
|
if (!res) {
|
|
27
27
|
throw Error('<success> MUST be in <request>');
|
|
@@ -29,7 +29,7 @@ const success = () => {
|
|
|
29
29
|
res.statusCode = typeof status === 'string' ? successStatuses[status] : status !== null && status !== void 0 ? status : ((children) ? 200 : 204);
|
|
30
30
|
if (children === null || children === void 0 ? void 0 : children[0]) {
|
|
31
31
|
const child = children[0];
|
|
32
|
-
const contentType = type || (['
|
|
32
|
+
const contentType = type || (['bigint', 'boolean', 'number', 'string'].includes(typeof child)
|
|
33
33
|
? 'text/plain'
|
|
34
34
|
: 'application/json');
|
|
35
35
|
res.setHeader('Content-Type', contentType);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export interface BinaryProps {
|
|
3
|
-
ref?: string;
|
|
4
|
-
description?: string;
|
|
5
3
|
accept?: string;
|
|
6
|
-
|
|
4
|
+
description?: string;
|
|
7
5
|
max?: number;
|
|
6
|
+
min?: number;
|
|
7
|
+
ref?: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const binary: HandlerPlugin;
|
|
@@ -2,7 +2,7 @@ import { type HandlerPlugin } from 'innet';
|
|
|
2
2
|
import { type ValuesSchemaProps } from '../../../types';
|
|
3
3
|
import { type DateFormat } from '../../../utils';
|
|
4
4
|
export interface DateProps extends ValuesSchemaProps<DateFormat> {
|
|
5
|
-
min?: DateFormat;
|
|
6
5
|
max?: DateFormat;
|
|
6
|
+
min?: DateFormat;
|
|
7
7
|
}
|
|
8
8
|
export declare const date: HandlerPlugin;
|
|
@@ -16,7 +16,7 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
|
16
16
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
17
17
|
|
|
18
18
|
const date = () => {
|
|
19
|
-
const _a = useProps() || {}, {
|
|
19
|
+
const _a = useProps() || {}, { default: defaultValue, example, examples, max, min, values: values$1 } = _a, props = __rest(_a, ["default", "example", "examples", "max", "min", "values"]);
|
|
20
20
|
const normMin = dateFormat(min);
|
|
21
21
|
const normMax = dateFormat(max);
|
|
22
22
|
const normDefault = dateFormat(defaultValue);
|
|
@@ -25,9 +25,9 @@ const date = () => {
|
|
|
25
25
|
// @ts-expect-error: FIXME
|
|
26
26
|
const stringValues = normValues === null || normValues === void 0 ? void 0 : normValues.map(value => value.toISOString());
|
|
27
27
|
const normExamples = examples === null || examples === void 0 ? void 0 : examples.map(dateFormat);
|
|
28
|
-
const schema = useSchemaType('string', Object.assign(Object.assign({}, props), {
|
|
28
|
+
const schema = useSchemaType('string', Object.assign(Object.assign({}, props), { default: defaultValue === 'now' ? undefined : normDefault === null || normDefault === void 0 ? void 0 : normDefault.toISOString(), example: normExample === null || normExample === void 0 ? void 0 : normExample.toISOString(),
|
|
29
29
|
// @ts-expect-error: FIXME
|
|
30
|
-
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
|
|
30
|
+
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()), values: stringValues }));
|
|
31
31
|
const rules = [];
|
|
32
32
|
if (defaultValue !== undefined) {
|
|
33
33
|
rules.push(defaultTo(defaultValue === 'now' ? () => new Date(Date.now()) : normDefault));
|
|
@@ -20,7 +20,7 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
20
20
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
21
21
|
|
|
22
22
|
const date = () => {
|
|
23
|
-
const _a = jsx.useProps() || {}, {
|
|
23
|
+
const _a = jsx.useProps() || {}, { default: defaultValue, example, examples, max, min, values: values$1 } = _a, props = tslib.__rest(_a, ["default", "example", "examples", "max", "min", "values"]);
|
|
24
24
|
const normMin = dateFormat.dateFormat(min);
|
|
25
25
|
const normMax = dateFormat.dateFormat(max);
|
|
26
26
|
const normDefault = dateFormat.dateFormat(defaultValue);
|
|
@@ -29,9 +29,9 @@ const date = () => {
|
|
|
29
29
|
// @ts-expect-error: FIXME
|
|
30
30
|
const stringValues = normValues === null || normValues === void 0 ? void 0 : normValues.map(value => value.toISOString());
|
|
31
31
|
const normExamples = examples === null || examples === void 0 ? void 0 : examples.map(dateFormat.dateFormat);
|
|
32
|
-
const schema = useSchemaType.useSchemaType('string', Object.assign(Object.assign({}, props), {
|
|
32
|
+
const schema = useSchemaType.useSchemaType('string', Object.assign(Object.assign({}, props), { default: defaultValue === 'now' ? undefined : normDefault === null || normDefault === void 0 ? void 0 : normDefault.toISOString(), example: normExample === null || normExample === void 0 ? void 0 : normExample.toISOString(),
|
|
33
33
|
// @ts-expect-error: FIXME
|
|
34
|
-
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
|
|
34
|
+
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()), values: stringValues }));
|
|
35
35
|
const rules = [];
|
|
36
36
|
if (defaultValue !== undefined) {
|
|
37
37
|
rules.push(defaultTo.defaultTo(defaultValue === 'now' ? () => new Date(Date.now()) : normDefault));
|
|
@@ -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 { key, optional } = useProps();
|
|
13
|
+
const { key, optional, } = useProps();
|
|
14
14
|
const schema = useObjectSchemaContext();
|
|
15
15
|
const children = useChildren();
|
|
16
16
|
if (!schema.properties) {
|
|
@@ -18,7 +18,7 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
|
18
18
|
|
|
19
19
|
const field = () => {
|
|
20
20
|
const handler = innet.useNewHandler();
|
|
21
|
-
const { key, optional } = jsx.useProps();
|
|
21
|
+
const { key, optional, } = jsx.useProps();
|
|
22
22
|
const schema = useObjectSchemaContext.useObjectSchemaContext();
|
|
23
23
|
const children = jsx.useChildren();
|
|
24
24
|
if (!schema.properties) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type IntegerFormats, type ValuesSchemaProps } from '../../../types';
|
|
3
|
-
export interface IntegerProps extends ValuesSchemaProps<
|
|
3
|
+
export interface IntegerProps extends ValuesSchemaProps<bigint | number> {
|
|
4
4
|
format?: IntegerFormats;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
max?: bigint | number;
|
|
6
|
+
min?: bigint | number;
|
|
7
7
|
}
|
|
8
8
|
export declare const integer: HandlerPlugin;
|
|
@@ -13,7 +13,7 @@ import { optional } from '../../../utils/rules/optional/optional.es6.js';
|
|
|
13
13
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
14
14
|
|
|
15
15
|
const integer = () => {
|
|
16
|
-
const _a = useProps() || {}, { format = 'int32',
|
|
16
|
+
const _a = useProps() || {}, { default: defaultValue, example, examples, format = 'int32', max: max$1, min: min$1, values: values$1 } = _a, props = __rest(_a, ["default", "example", "examples", "format", "max", "min", "values"]);
|
|
17
17
|
const schema = useSchemaType('integer', Object.assign(Object.assign({}, props), { default: defaultValue !== undefined ? Number(defaultValue) : undefined, example: example !== undefined ? Number(example) : undefined, examples: examples === null || examples === void 0 ? void 0 : examples.map(Number), values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number) }));
|
|
18
18
|
// @ts-expect-error: FIXME
|
|
19
19
|
schema.format = format;
|
|
@@ -17,7 +17,7 @@ var optional = require('../../../utils/rules/optional/optional.js');
|
|
|
17
17
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
18
18
|
|
|
19
19
|
const integer = () => {
|
|
20
|
-
const _a = jsx.useProps() || {}, { format = 'int32',
|
|
20
|
+
const _a = jsx.useProps() || {}, { default: defaultValue, example, examples, format = 'int32', max: max$1, min: min$1, values: values$1 } = _a, props = tslib.__rest(_a, ["default", "example", "examples", "format", "max", "min", "values"]);
|
|
21
21
|
const schema = useSchemaType.useSchemaType('integer', Object.assign(Object.assign({}, props), { default: defaultValue !== undefined ? Number(defaultValue) : undefined, example: example !== undefined ? Number(example) : undefined, examples: examples === null || examples === void 0 ? void 0 : examples.map(Number), values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number) }));
|
|
22
22
|
// @ts-expect-error: FIXME
|
|
23
23
|
schema.format = format;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type ValuesSchemaProps } from '../../../types';
|
|
3
3
|
export interface NumberProps extends ValuesSchemaProps<number> {
|
|
4
|
-
/** Validate the number value by minimum. */
|
|
5
|
-
min?: number;
|
|
6
4
|
/** Validate the number value by maximum. */
|
|
7
5
|
max?: number;
|
|
6
|
+
/** Validate the number value by minimum. */
|
|
7
|
+
min?: number;
|
|
8
8
|
}
|
|
9
9
|
export declare const number: HandlerPlugin;
|
|
@@ -14,7 +14,7 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
|
14
14
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
15
15
|
|
|
16
16
|
const number = () => {
|
|
17
|
-
const _a = useProps() || {}, {
|
|
17
|
+
const _a = useProps() || {}, { max: max$1, min: min$1 } = _a, props = __rest(_a, ["max", "min"]);
|
|
18
18
|
const schema = useSchemaType('number', props);
|
|
19
19
|
// @ts-expect-error: FIXME
|
|
20
20
|
schema.minimum = min$1;
|
|
@@ -18,7 +18,7 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
18
18
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
19
19
|
|
|
20
20
|
const number = () => {
|
|
21
|
-
const _a = jsx.useProps() || {}, {
|
|
21
|
+
const _a = jsx.useProps() || {}, { max: max$1, min: min$1 } = _a, props = tslib.__rest(_a, ["max", "min"]);
|
|
22
22
|
const schema = useSchemaType.useSchemaType('number', props);
|
|
23
23
|
// @ts-expect-error: FIXME
|
|
24
24
|
schema.minimum = min$1;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type ValuesSchemaProps } from '../../../types';
|
|
3
3
|
export interface StringProps extends ValuesSchemaProps<string> {
|
|
4
|
-
min?: number;
|
|
5
4
|
max?: number;
|
|
6
|
-
|
|
5
|
+
min?: number;
|
|
6
|
+
pattern?: RegExp | string;
|
|
7
7
|
patternId?: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const string: HandlerPlugin;
|
|
@@ -15,7 +15,7 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
|
15
15
|
import { useParentRule } from '../../../hooks/useParentRule/useParentRule.es6.js';
|
|
16
16
|
|
|
17
17
|
const string = () => {
|
|
18
|
-
const _a = useProps() || {}, {
|
|
18
|
+
const _a = useProps() || {}, { max, min, pattern: pattern$1, patternId } = _a, props = __rest(_a, ["max", "min", "pattern", "patternId"]);
|
|
19
19
|
const { refRules } = useApi();
|
|
20
20
|
const schema = useSchemaType('string', props);
|
|
21
21
|
if (schema) {
|
|
@@ -19,7 +19,7 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
19
19
|
var useParentRule = require('../../../hooks/useParentRule/useParentRule.js');
|
|
20
20
|
|
|
21
21
|
const string = () => {
|
|
22
|
-
const _a = jsx.useProps() || {}, {
|
|
22
|
+
const _a = jsx.useProps() || {}, { max, min, pattern: pattern$1, patternId } = _a, props = tslib.__rest(_a, ["max", "min", "pattern", "patternId"]);
|
|
23
23
|
const { refRules } = useApi.useApi();
|
|
24
24
|
const schema = useSchemaType.useSchemaType('string', props);
|
|
25
25
|
if (schema) {
|
|
@@ -6,7 +6,7 @@ import { useApi } from '../../../hooks/useApi/useApi.es6.js';
|
|
|
6
6
|
import { generateTypes } from '../../../utils/generateTypes/generateTypes.es6.js';
|
|
7
7
|
|
|
8
8
|
const dts = () => {
|
|
9
|
-
const { path = process.env.INNET_DTS_PATH || 'src/apiTypes.d.ts',
|
|
9
|
+
const { namespace = process.env.INNET_DTS_NAMESPACE, path = process.env.INNET_DTS_PATH || 'src/apiTypes.d.ts', } = useProps() || {};
|
|
10
10
|
const { docs } = useApi();
|
|
11
11
|
promises.writeFile(path, generateTypes(docs, namespace)).catch(e => {
|
|
12
12
|
console.error(e);
|
package/plugins/utils/dts/dts.js
CHANGED
|
@@ -10,7 +10,7 @@ var useApi = require('../../../hooks/useApi/useApi.js');
|
|
|
10
10
|
var generateTypes = require('../../../utils/generateTypes/generateTypes.js');
|
|
11
11
|
|
|
12
12
|
const dts = () => {
|
|
13
|
-
const { path = process.env.INNET_DTS_PATH || 'src/apiTypes.d.ts',
|
|
13
|
+
const { namespace = process.env.INNET_DTS_NAMESPACE, path = process.env.INNET_DTS_PATH || 'src/apiTypes.d.ts', } = jsx.useProps() || {};
|
|
14
14
|
const { docs } = useApi.useApi();
|
|
15
15
|
fs.promises.writeFile(path, generateTypes.generateTypes(docs, namespace)).catch(e => {
|
|
16
16
|
console.error(e);
|
|
@@ -2,7 +2,7 @@ import innet, { useHandler } from 'innet';
|
|
|
2
2
|
import { useProps, useChildren } from '@innet/jsx';
|
|
3
3
|
|
|
4
4
|
const env = () => {
|
|
5
|
-
const { of = 'NODE_ENV',
|
|
5
|
+
const { is, of = 'NODE_ENV', } = useProps();
|
|
6
6
|
if (Array.isArray(is) ? is.includes(process.env[of]) : process.env[of] === is) {
|
|
7
7
|
innet(useChildren(), useHandler());
|
|
8
8
|
}
|
package/plugins/utils/env/env.js
CHANGED
|
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
11
11
|
|
|
12
12
|
const env = () => {
|
|
13
|
-
const { of = 'NODE_ENV',
|
|
13
|
+
const { is, of = 'NODE_ENV', } = jsx.useProps();
|
|
14
14
|
if (Array.isArray(is) ? is.includes(process.env[of]) : process.env[of] === is) {
|
|
15
15
|
innet__default["default"](jsx.useChildren(), innet.useHandler());
|
|
16
16
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface ProtectionProps {
|
|
2
|
-
value?: string;
|
|
3
|
-
maxAge?: number;
|
|
4
|
-
excludeIp?: string | string[];
|
|
5
2
|
cookieKey?: string;
|
|
3
|
+
excludeIp?: string | string[];
|
|
4
|
+
maxAge?: number;
|
|
6
5
|
searchKey?: string;
|
|
6
|
+
value?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function protection(): void;
|
|
@@ -4,7 +4,7 @@ import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.
|
|
|
4
4
|
import { useAction } from '../../../hooks/useAction/useAction.es6.js';
|
|
5
5
|
|
|
6
6
|
function protection() {
|
|
7
|
-
const { maxAge = Number(process.env.INNET_PROTECTION_MAX_AGE) || 365 * 24 * 60 * 60,
|
|
7
|
+
const { cookieKey = process.env.INNET_PROTECTION_COOKIE_KEY || 'protection', excludeIp = process.env.INNET_PROTECTED_IP, maxAge = Number(process.env.INNET_PROTECTION_MAX_AGE) || 365 * 24 * 60 * 60, searchKey = process.env.INNET_PROTECTION_SEARCH_KEY || 'protection', value = process.env.INNET_PROTECTION, } = useProps() || {};
|
|
8
8
|
const children = useChildren();
|
|
9
9
|
if (!value)
|
|
10
10
|
return;
|
|
@@ -21,10 +21,10 @@ function protection() {
|
|
|
21
21
|
const { [searchKey]: searchProtection } = action.search;
|
|
22
22
|
if (searchProtection && searchProtection === value) {
|
|
23
23
|
action.setCookie(cookieKey, value, {
|
|
24
|
-
maxAge,
|
|
25
24
|
httpOnly: true,
|
|
26
|
-
|
|
25
|
+
maxAge,
|
|
27
26
|
path: '/',
|
|
27
|
+
secure: true,
|
|
28
28
|
});
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
@@ -8,7 +8,7 @@ var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js
|
|
|
8
8
|
var useAction = require('../../../hooks/useAction/useAction.js');
|
|
9
9
|
|
|
10
10
|
function protection() {
|
|
11
|
-
const { maxAge = Number(process.env.INNET_PROTECTION_MAX_AGE) || 365 * 24 * 60 * 60,
|
|
11
|
+
const { cookieKey = process.env.INNET_PROTECTION_COOKIE_KEY || 'protection', excludeIp = process.env.INNET_PROTECTED_IP, maxAge = Number(process.env.INNET_PROTECTION_MAX_AGE) || 365 * 24 * 60 * 60, searchKey = process.env.INNET_PROTECTION_SEARCH_KEY || 'protection', value = process.env.INNET_PROTECTION, } = jsx.useProps() || {};
|
|
12
12
|
const children = jsx.useChildren();
|
|
13
13
|
if (!value)
|
|
14
14
|
return;
|
|
@@ -25,10 +25,10 @@ function protection() {
|
|
|
25
25
|
const { [searchKey]: searchProtection } = action.search;
|
|
26
26
|
if (searchProtection && searchProtection === value) {
|
|
27
27
|
action.setCookie(cookieKey, value, {
|
|
28
|
-
maxAge,
|
|
29
28
|
httpOnly: true,
|
|
30
|
-
|
|
29
|
+
maxAge,
|
|
31
30
|
path: '/',
|
|
31
|
+
secure: true,
|
|
32
32
|
});
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
@@ -7,7 +7,7 @@ import { useAction } from '../../../hooks/useAction/useAction.es6.js';
|
|
|
7
7
|
|
|
8
8
|
const swagger = () => {
|
|
9
9
|
const { path = process.env.INNET_SWAGGER_PATH || '/swagger-ui', } = useProps() || {};
|
|
10
|
-
const { docs, prefix } = useApi();
|
|
10
|
+
const { docs, prefix, } = useApi();
|
|
11
11
|
let swaggerResponse;
|
|
12
12
|
useServerPlugin(() => {
|
|
13
13
|
const action = useAction();
|
|
@@ -11,7 +11,7 @@ var useAction = require('../../../hooks/useAction/useAction.js');
|
|
|
11
11
|
|
|
12
12
|
const swagger = () => {
|
|
13
13
|
const { path = process.env.INNET_SWAGGER_PATH || '/swagger-ui', } = jsx.useProps() || {};
|
|
14
|
-
const { docs, prefix } = useApi.useApi();
|
|
14
|
+
const { docs, prefix, } = useApi.useApi();
|
|
15
15
|
let swaggerResponse;
|
|
16
16
|
useServerPlugin.useServerPlugin(() => {
|
|
17
17
|
const action = useAction.useAction();
|