@innet/server 2.0.0-beta.1 → 2.0.0-beta.3
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 +22 -0
- package/handler/handler.d.ts +1 -7
- package/handler/handler.es6.js +1 -4
- package/handler/handler.js +0 -3
- 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.es6.js +0 -1
- package/index.js +0 -1
- package/package.json +15 -15
- package/plugins/handler/serverFn/serverFn.es6.js +1 -1
- package/plugins/handler/serverFn/serverFn.js +1 -1
- package/plugins/main/api/api.es6.js +73 -73
- package/plugins/main/api/api.js +73 -73
- package/plugins/main/endpoint/endpoint.d.ts +5 -0
- package/plugins/main/endpoint/endpoint.es6.js +4 -4
- package/plugins/main/endpoint/endpoint.js +4 -4
- package/plugins/main/host/host.es6.js +3 -1
- package/plugins/main/host/host.js +3 -1
- package/plugins/main/param/param.es6.js +2 -3
- package/plugins/main/param/param.js +2 -3
- package/plugins/main/response/response.es6.js +10 -3
- package/plugins/main/response/response.js +10 -3
- package/plugins/main/server/server.d.ts +0 -1
- package/plugins/main/server/server.es6.js +6 -9
- package/plugins/main/server/server.js +6 -9
- package/plugins/main/variable/variable.es6.js +3 -4
- package/plugins/main/variable/variable.js +3 -4
- 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 +1 -2
- package/plugins/request/file/file.js +1 -2
- package/plugins/request/proxy/proxy.d.ts +0 -1
- package/plugins/schema/array/array.es6.js +1 -2
- package/plugins/schema/array/array.js +1 -2
- package/plugins/schema/date/date.es6.js +8 -4
- package/plugins/schema/date/date.js +8 -4
- package/plugins/schema/integer/integer.es6.js +8 -3
- package/plugins/schema/integer/integer.js +8 -3
- package/plugins/schema/number/number.es6.js +1 -2
- package/plugins/schema/number/number.js +1 -2
- package/plugins/schema/object/object.es6.js +1 -2
- package/plugins/schema/object/object.js +1 -2
- package/plugins/schema/string/string.es6.js +1 -2
- package/plugins/schema/string/string.js +1 -2
- package/plugins/schema/tuple/tuple.es6.js +1 -2
- package/plugins/schema/tuple/tuple.js +1 -2
- package/plugins/schema/uuid/uuid.es6.js +5 -3
- package/plugins/schema/uuid/uuid.js +5 -3
- 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/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/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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import innet, { useNewHandler } from 'innet';
|
|
3
2
|
import { useContext, useProps } from '@innet/jsx';
|
|
4
3
|
import { callHandler } from '@innet/utils';
|
|
@@ -19,7 +18,7 @@ const array = () => {
|
|
|
19
18
|
useBlock('path');
|
|
20
19
|
const setRule = useContext(ruleContext);
|
|
21
20
|
const handler = useNewHandler();
|
|
22
|
-
const
|
|
21
|
+
const { children, ...props } = useProps();
|
|
23
22
|
const schema = useSchemaType('array', props);
|
|
24
23
|
const fieldSchema = {};
|
|
25
24
|
handler[schemaContext.key] = fieldSchema;
|
|
@@ -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 utils = require('@innet/utils');
|
|
@@ -27,7 +26,7 @@ const array = () => {
|
|
|
27
26
|
useBlock.useBlock('path');
|
|
28
27
|
const setRule = jsx.useContext(useRule.ruleContext);
|
|
29
28
|
const handler = innet.useNewHandler();
|
|
30
|
-
const
|
|
29
|
+
const { children, ...props } = jsx.useProps();
|
|
31
30
|
const schema = useSchemaType.useSchemaType('array', props);
|
|
32
31
|
const fieldSchema = {};
|
|
33
32
|
handler[useSchemaContext.schemaContext.key] = fieldSchema;
|
|
@@ -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));
|
|
@@ -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,8 +12,14 @@ 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',
|
|
15
|
+
const { default: defaultValue, example, examples, format = 'int32', max: max$1, min: min$1, values: values$1, ...props } = useProps() || {};
|
|
16
|
+
const schema = useSchemaType('integer', {
|
|
17
|
+
...props,
|
|
18
|
+
default: defaultValue !== undefined ? Number(defaultValue) : undefined,
|
|
19
|
+
example: example !== undefined ? Number(example) : undefined,
|
|
20
|
+
examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
|
|
21
|
+
values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number),
|
|
22
|
+
});
|
|
18
23
|
// @ts-expect-error: FIXME
|
|
19
24
|
schema.format = format;
|
|
20
25
|
// @ts-expect-error: FIXME
|
|
@@ -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,8 +16,14 @@ 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',
|
|
19
|
+
const { default: defaultValue, example, examples, format = 'int32', max: max$1, min: min$1, values: values$1, ...props } = jsx.useProps() || {};
|
|
20
|
+
const schema = useSchemaType.useSchemaType('integer', {
|
|
21
|
+
...props,
|
|
22
|
+
default: defaultValue !== undefined ? Number(defaultValue) : undefined,
|
|
23
|
+
example: example !== undefined ? Number(example) : undefined,
|
|
24
|
+
examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
|
|
25
|
+
values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number),
|
|
26
|
+
});
|
|
22
27
|
// @ts-expect-error: FIXME
|
|
23
28
|
schema.format = format;
|
|
24
29
|
// @ts-expect-error: FIXME
|
|
@@ -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';
|
|
@@ -14,7 +13,7 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
|
14
13
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
15
14
|
|
|
16
15
|
const number = () => {
|
|
17
|
-
const
|
|
16
|
+
const { max: max$1, min: min$1, ...props } = useProps() || {};
|
|
18
17
|
const schema = useSchemaType('number', props);
|
|
19
18
|
// @ts-expect-error: FIXME
|
|
20
19
|
schema.minimum = min$1;
|
|
@@ -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');
|
|
@@ -18,7 +17,7 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
18
17
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
19
18
|
|
|
20
19
|
const number = () => {
|
|
21
|
-
const
|
|
20
|
+
const { max: max$1, min: min$1, ...props } = jsx.useProps() || {};
|
|
22
21
|
const schema = useSchemaType.useSchemaType('number', props);
|
|
23
22
|
// @ts-expect-error: FIXME
|
|
24
23
|
schema.minimum = min$1;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import innet, { useNewHandler } from 'innet';
|
|
3
2
|
import { useProps } from '@innet/jsx';
|
|
4
3
|
import { callHandler } from '@innet/utils';
|
|
@@ -19,7 +18,7 @@ import { objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es
|
|
|
19
18
|
|
|
20
19
|
const object = () => {
|
|
21
20
|
useBlock('path');
|
|
22
|
-
const
|
|
21
|
+
const { children, ...props } = useProps();
|
|
23
22
|
const { refRules } = useApi();
|
|
24
23
|
const schema = useSchemaType('object', props);
|
|
25
24
|
const handler = useNewHandler();
|
|
@@ -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 utils = require('@innet/utils');
|
|
@@ -27,7 +26,7 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
|
27
26
|
|
|
28
27
|
const object = () => {
|
|
29
28
|
useBlock.useBlock('path');
|
|
30
|
-
const
|
|
29
|
+
const { children, ...props } = jsx.useProps();
|
|
31
30
|
const { refRules } = useApi.useApi();
|
|
32
31
|
const schema = useSchemaType.useSchemaType('object', props);
|
|
33
32
|
const handler = innet.useNewHandler();
|
|
@@ -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';
|
|
@@ -15,7 +14,7 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
|
15
14
|
import { useParentRule } from '../../../hooks/useParentRule/useParentRule.es6.js';
|
|
16
15
|
|
|
17
16
|
const string = () => {
|
|
18
|
-
const
|
|
17
|
+
const { max, min, pattern: pattern$1, patternId, ...props } = useProps() || {};
|
|
19
18
|
const { refRules } = useApi();
|
|
20
19
|
const schema = useSchemaType('string', props);
|
|
21
20
|
if (schema) {
|
|
@@ -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');
|
|
@@ -19,7 +18,7 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
19
18
|
var useParentRule = require('../../../hooks/useParentRule/useParentRule.js');
|
|
20
19
|
|
|
21
20
|
const string = () => {
|
|
22
|
-
const
|
|
21
|
+
const { max, min, pattern: pattern$1, patternId, ...props } = jsx.useProps() || {};
|
|
23
22
|
const { refRules } = useApi.useApi();
|
|
24
23
|
const schema = useSchemaType.useSchemaType('string', props);
|
|
25
24
|
if (schema) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import innet, { useNewHandler } from 'innet';
|
|
3
2
|
import { useProps } from '@innet/jsx';
|
|
4
3
|
import { callHandler } from '@innet/utils';
|
|
@@ -18,7 +17,7 @@ import { required } from '../../../utils/rules/required/required.es6.js';
|
|
|
18
17
|
const tuple = () => {
|
|
19
18
|
useBlock('path');
|
|
20
19
|
const handler = useNewHandler();
|
|
21
|
-
const
|
|
20
|
+
const { children, ...props } = useProps();
|
|
22
21
|
const schema = useSchemaType('array', props);
|
|
23
22
|
if (schema) {
|
|
24
23
|
const schemas = [];
|
|
@@ -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 utils = require('@innet/utils');
|
|
@@ -26,7 +25,7 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
|
26
25
|
const tuple = () => {
|
|
27
26
|
useBlock.useBlock('path');
|
|
28
27
|
const handler = innet.useNewHandler();
|
|
29
|
-
const
|
|
28
|
+
const { children, ...props } = jsx.useProps();
|
|
30
29
|
const schema = useSchemaType.useSchemaType('array', props);
|
|
31
30
|
if (schema) {
|
|
32
31
|
const schemas = [];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import { useProps } from '@innet/jsx';
|
|
3
2
|
import { v4 } from 'uuid';
|
|
4
3
|
import '../../../hooks/index.es6.js';
|
|
@@ -12,8 +11,11 @@ import { optional } from '../../../utils/rules/optional/optional.es6.js';
|
|
|
12
11
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
13
12
|
|
|
14
13
|
const uuid = () => {
|
|
15
|
-
const
|
|
16
|
-
const schema = useSchemaType('string',
|
|
14
|
+
const { default: defaultValue, ...props } = useProps();
|
|
15
|
+
const schema = useSchemaType('string', {
|
|
16
|
+
...props,
|
|
17
|
+
default: defaultValue === 'new' ? undefined : defaultValue,
|
|
18
|
+
});
|
|
17
19
|
// @ts-expect-error: FIXME
|
|
18
20
|
schema.format = 'uuid';
|
|
19
21
|
if (defaultValue === 'new') {
|
|
@@ -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
|
var uuid$1 = require('uuid');
|
|
8
7
|
require('../../../hooks/index.js');
|
|
@@ -16,8 +15,11 @@ var optional = require('../../../utils/rules/optional/optional.js');
|
|
|
16
15
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
17
16
|
|
|
18
17
|
const uuid = () => {
|
|
19
|
-
const
|
|
20
|
-
const schema = useSchemaType.useSchemaType('string',
|
|
18
|
+
const { default: defaultValue, ...props } = jsx.useProps();
|
|
19
|
+
const schema = useSchemaType.useSchemaType('string', {
|
|
20
|
+
...props,
|
|
21
|
+
default: defaultValue === 'new' ? undefined : defaultValue,
|
|
22
|
+
});
|
|
21
23
|
// @ts-expect-error: FIXME
|
|
22
24
|
schema.format = 'uuid';
|
|
23
25
|
if (defaultValue === 'new') {
|
package/utils/action/Action.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { type CookieSerializeOptions } from 'cookie';
|
|
1
|
+
import { type Cookies, type SerializeOptions } from 'cookie';
|
|
3
2
|
import { type IncomingHttpHeaders, type IncomingMessage, type ServerResponse } from 'http';
|
|
4
3
|
import { type ParsedQs } from 'qs';
|
|
5
4
|
import { type BodyType } from '../../types';
|
|
@@ -15,14 +14,14 @@ export declare class Action {
|
|
|
15
14
|
body?: object;
|
|
16
15
|
constructor(req: IncomingMessage, res: ServerResponse);
|
|
17
16
|
parseBody(): Promise<void>;
|
|
18
|
-
setCookie(name: string, value?: string, options?:
|
|
17
|
+
setCookie(name: string, value?: string, options?: SerializeOptions): void;
|
|
19
18
|
get bodyType(): BodyType | undefined;
|
|
20
19
|
get clientIp(): string | null;
|
|
21
|
-
get cookies():
|
|
20
|
+
get cookies(): Cookies;
|
|
22
21
|
set cookies(value: Record<string, string>);
|
|
23
22
|
get headers(): IncomingHttpHeaders;
|
|
24
23
|
set headers(value: IncomingHttpHeaders);
|
|
25
|
-
get originCookies():
|
|
24
|
+
get originCookies(): Cookies;
|
|
26
25
|
get originHeaders(): IncomingHttpHeaders;
|
|
27
26
|
get originSearch(): ParsedQs;
|
|
28
27
|
get parsedUrl(): ParsedUrl;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __runInitializers,
|
|
1
|
+
import { __runInitializers, __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate } from 'tslib';
|
|
2
2
|
import cookieLib from 'cookie';
|
|
3
3
|
import { getClientIp } from 'request-ip';
|
|
4
4
|
import '../decorators/index.es6.js';
|
|
@@ -29,21 +29,19 @@ let Action = (() => {
|
|
|
29
29
|
_Action_headers.set(this, {});
|
|
30
30
|
_Action_search.set(this, void 0);
|
|
31
31
|
}
|
|
32
|
-
parseBody() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
});
|
|
32
|
+
async parseBody() {
|
|
33
|
+
if (!this.bodyType) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (this.bodyType === 'multipart/form-data') {
|
|
37
|
+
this.body = await parseFormBody(this.req);
|
|
38
|
+
}
|
|
39
|
+
if (this.bodyType === 'application/x-www-form-urlencoded') {
|
|
40
|
+
this.body = parseSearch(await parseBody(this.req));
|
|
41
|
+
}
|
|
42
|
+
if (this.bodyType === 'application/json') {
|
|
43
|
+
this.body = JSON.parse(await parseBody(this.req));
|
|
44
|
+
}
|
|
47
45
|
}
|
|
48
46
|
setCookie(name, value, options) {
|
|
49
47
|
let cookies = this.res.getHeader('Set-Cookie');
|
package/utils/action/Action.js
CHANGED
|
@@ -37,21 +37,19 @@ let Action = (() => {
|
|
|
37
37
|
_Action_headers.set(this, {});
|
|
38
38
|
_Action_search.set(this, void 0);
|
|
39
39
|
}
|
|
40
|
-
parseBody() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
});
|
|
40
|
+
async parseBody() {
|
|
41
|
+
if (!this.bodyType) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (this.bodyType === 'multipart/form-data') {
|
|
45
|
+
this.body = await parseFormBody.parseFormBody(this.req);
|
|
46
|
+
}
|
|
47
|
+
if (this.bodyType === 'application/x-www-form-urlencoded') {
|
|
48
|
+
this.body = parseSearch.parseSearch(await parseBody.parseBody(this.req));
|
|
49
|
+
}
|
|
50
|
+
if (this.bodyType === 'application/json') {
|
|
51
|
+
this.body = JSON.parse(await parseBody.parseBody(this.req));
|
|
52
|
+
}
|
|
55
53
|
}
|
|
56
54
|
setCookie(name, value, options) {
|
|
57
55
|
let cookies = this.res.getHeader('Set-Cookie');
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
1
|
import { StringDecoder } from 'node:string_decoder';
|
|
3
2
|
|
|
4
|
-
function parseBody(req) {
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
reject(err);
|
|
18
|
-
});
|
|
3
|
+
async function parseBody(req) {
|
|
4
|
+
return await new Promise((resolve, reject) => {
|
|
5
|
+
const decoder = new StringDecoder('utf-8');
|
|
6
|
+
let buffer = '';
|
|
7
|
+
req.on('data', chunk => {
|
|
8
|
+
buffer += decoder.write(chunk);
|
|
9
|
+
});
|
|
10
|
+
req.on('end', () => {
|
|
11
|
+
buffer += decoder.end();
|
|
12
|
+
resolve(buffer);
|
|
13
|
+
});
|
|
14
|
+
req.on('error', err => {
|
|
15
|
+
reject(err);
|
|
19
16
|
});
|
|
20
17
|
});
|
|
21
18
|
}
|
|
@@ -2,24 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var node_string_decoder = require('node:string_decoder');
|
|
7
6
|
|
|
8
|
-
function parseBody(req) {
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
reject(err);
|
|
22
|
-
});
|
|
7
|
+
async function parseBody(req) {
|
|
8
|
+
return await new Promise((resolve, reject) => {
|
|
9
|
+
const decoder = new node_string_decoder.StringDecoder('utf-8');
|
|
10
|
+
let buffer = '';
|
|
11
|
+
req.on('data', chunk => {
|
|
12
|
+
buffer += decoder.write(chunk);
|
|
13
|
+
});
|
|
14
|
+
req.on('end', () => {
|
|
15
|
+
buffer += decoder.end();
|
|
16
|
+
resolve(buffer);
|
|
17
|
+
});
|
|
18
|
+
req.on('error', err => {
|
|
19
|
+
reject(err);
|
|
23
20
|
});
|
|
24
21
|
});
|
|
25
22
|
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { __awaiter, __rest } from 'tslib';
|
|
2
1
|
import { Form } from 'multiparty';
|
|
3
2
|
import '../FileData/index.es6.js';
|
|
4
3
|
import '../parseSearch/index.es6.js';
|
|
5
4
|
import { Bin } from '../FileData/Bin.es6.js';
|
|
6
5
|
import { parseSearch } from '../parseSearch/parseSearch.es6.js';
|
|
7
6
|
|
|
8
|
-
function parseFormBody(req) {
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
query += '&';
|
|
23
|
-
}
|
|
24
|
-
query += `${key}=${value.replaceAll('=', '%26')}`;
|
|
7
|
+
async function parseFormBody(req) {
|
|
8
|
+
return await new Promise((resolve, reject) => {
|
|
9
|
+
const form = new Form();
|
|
10
|
+
form.parse(req, (error, fields, files) => {
|
|
11
|
+
if (error) {
|
|
12
|
+
reject(error);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let query = '';
|
|
16
|
+
const queryFiles = [];
|
|
17
|
+
for (const key in fields) {
|
|
18
|
+
for (const value of fields[key]) {
|
|
19
|
+
if (query) {
|
|
20
|
+
query += '&';
|
|
25
21
|
}
|
|
22
|
+
query += `${key}=${value.replaceAll('=', '%26')}`;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
query += `${key}==${queryFiles.length}`;
|
|
34
|
-
const { headers } = value, options = __rest(value, ["headers"]);
|
|
35
|
-
options.type = headers['content-type'];
|
|
36
|
-
options.disposition = headers['content-disposition'];
|
|
37
|
-
queryFiles.push(new Bin(options));
|
|
24
|
+
}
|
|
25
|
+
for (const key in files) {
|
|
26
|
+
const values = files[key];
|
|
27
|
+
for (const value of values) {
|
|
28
|
+
if (query) {
|
|
29
|
+
query += '&';
|
|
38
30
|
}
|
|
31
|
+
query += `${key}==${queryFiles.length}`;
|
|
32
|
+
const { headers, ...options } = value;
|
|
33
|
+
const binOptions = {
|
|
34
|
+
...options,
|
|
35
|
+
disposition: headers['content-disposition'],
|
|
36
|
+
type: headers['content-type'],
|
|
37
|
+
};
|
|
38
|
+
queryFiles.push(new Bin(binOptions));
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
});
|
|
40
|
+
}
|
|
41
|
+
resolve(parseSearch(query, {
|
|
42
|
+
decoder(value, decoder, charset, type) {
|
|
43
|
+
if (type === 'key') {
|
|
44
|
+
return decoder(value, decoder, charset);
|
|
45
|
+
}
|
|
46
|
+
if (value.startsWith('=')) {
|
|
47
|
+
return queryFiles[Number(value.slice(1))];
|
|
48
|
+
}
|
|
49
|
+
return value.replaceAll('%26', '=');
|
|
50
|
+
},
|
|
51
|
+
}));
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
}
|