@innet/server 2.0.0-beta.1 → 2.0.0-beta.2

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.
Files changed (110) hide show
  1. package/README.md +22 -0
  2. package/handler/handler.d.ts +1 -7
  3. package/handler/handler.es6.js +1 -4
  4. package/handler/handler.js +0 -3
  5. package/hooks/useHeaders/useHeaders.d.ts +0 -1
  6. package/hooks/useNewSchema/useNewSchema.es6.js +1 -1
  7. package/hooks/useNewSchema/useNewSchema.js +1 -1
  8. package/hooks/useRequest/useRequest.d.ts +0 -1
  9. package/hooks/useResponse/useResponse.d.ts +0 -1
  10. package/hooks/useSchemaType/useSchemaType.es6.js +17 -9
  11. package/hooks/useSchemaType/useSchemaType.js +17 -9
  12. package/hooks/useServer/useServer.d.ts +0 -2
  13. package/index.es6.js +0 -1
  14. package/index.js +0 -1
  15. package/package.json +15 -15
  16. package/plugins/handler/serverFn/serverFn.es6.js +1 -1
  17. package/plugins/handler/serverFn/serverFn.js +1 -1
  18. package/plugins/main/api/api.es6.js +73 -73
  19. package/plugins/main/api/api.js +73 -73
  20. package/plugins/main/endpoint/endpoint.d.ts +5 -0
  21. package/plugins/main/endpoint/endpoint.es6.js +4 -4
  22. package/plugins/main/endpoint/endpoint.js +4 -4
  23. package/plugins/main/host/host.es6.js +3 -1
  24. package/plugins/main/host/host.js +3 -1
  25. package/plugins/main/param/param.es6.js +2 -3
  26. package/plugins/main/param/param.js +2 -3
  27. package/plugins/main/response/response.es6.js +10 -3
  28. package/plugins/main/response/response.js +10 -3
  29. package/plugins/main/server/server.d.ts +0 -1
  30. package/plugins/main/server/server.es6.js +6 -9
  31. package/plugins/main/server/server.js +6 -9
  32. package/plugins/main/variable/variable.es6.js +3 -4
  33. package/plugins/main/variable/variable.js +3 -4
  34. package/plugins/request/cookie/cookie.d.ts +2 -2
  35. package/plugins/request/cookie/cookie.es6.js +1 -2
  36. package/plugins/request/cookie/cookie.js +1 -2
  37. package/plugins/request/error/error.es6.js +1 -2
  38. package/plugins/request/error/error.js +1 -2
  39. package/plugins/request/file/file.es6.js +1 -2
  40. package/plugins/request/file/file.js +1 -2
  41. package/plugins/request/proxy/proxy.d.ts +0 -1
  42. package/plugins/schema/array/array.es6.js +1 -2
  43. package/plugins/schema/array/array.js +1 -2
  44. package/plugins/schema/date/date.es6.js +8 -4
  45. package/plugins/schema/date/date.js +8 -4
  46. package/plugins/schema/integer/integer.es6.js +8 -3
  47. package/plugins/schema/integer/integer.js +8 -3
  48. package/plugins/schema/number/number.es6.js +1 -2
  49. package/plugins/schema/number/number.js +1 -2
  50. package/plugins/schema/object/object.es6.js +1 -2
  51. package/plugins/schema/object/object.js +1 -2
  52. package/plugins/schema/string/string.es6.js +1 -2
  53. package/plugins/schema/string/string.js +1 -2
  54. package/plugins/schema/tuple/tuple.es6.js +1 -2
  55. package/plugins/schema/tuple/tuple.js +1 -2
  56. package/plugins/schema/uuid/uuid.es6.js +5 -3
  57. package/plugins/schema/uuid/uuid.js +5 -3
  58. package/utils/action/Action.d.ts +4 -5
  59. package/utils/action/Action.es6.js +14 -16
  60. package/utils/action/Action.js +13 -15
  61. package/utils/parseBody/parseBody.d.ts +0 -1
  62. package/utils/parseBody/parseBody.es6.js +13 -16
  63. package/utils/parseBody/parseBody.js +13 -16
  64. package/utils/parseFormBody/parseFormBody.d.ts +0 -1
  65. package/utils/parseFormBody/parseFormBody.es6.js +41 -41
  66. package/utils/parseFormBody/parseFormBody.js +41 -41
  67. package/utils/parseSearch/parseSearch.es6.js +4 -1
  68. package/utils/parseSearch/parseSearch.js +4 -1
  69. package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
  70. package/utils/rules/arrayOf/arrayOf.js +1 -1
  71. package/utils/rules/bin/bin.es6.js +4 -1
  72. package/utils/rules/bin/bin.js +4 -1
  73. package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
  74. package/utils/rules/binaryAccept/binaryAccept.js +5 -2
  75. package/utils/rules/dateTo/dateTo.es6.js +4 -1
  76. package/utils/rules/dateTo/dateTo.js +4 -1
  77. package/utils/rules/helpers.es6.js +4 -1
  78. package/utils/rules/helpers.js +4 -1
  79. package/utils/rules/int/int.es6.js +17 -4
  80. package/utils/rules/int/int.js +17 -4
  81. package/utils/rules/max/max.es6.js +9 -3
  82. package/utils/rules/max/max.js +9 -3
  83. package/utils/rules/maxBin/maxBin.es6.js +5 -2
  84. package/utils/rules/maxBin/maxBin.js +5 -2
  85. package/utils/rules/maxDate/maxDate.es6.js +5 -1
  86. package/utils/rules/maxDate/maxDate.js +5 -1
  87. package/utils/rules/maxLength/maxLength.es6.js +5 -2
  88. package/utils/rules/maxLength/maxLength.js +5 -2
  89. package/utils/rules/min/min.es6.js +9 -3
  90. package/utils/rules/min/min.js +9 -3
  91. package/utils/rules/minBin/minBin.es6.js +5 -2
  92. package/utils/rules/minBin/minBin.js +5 -2
  93. package/utils/rules/minDate/minDate.es6.js +5 -1
  94. package/utils/rules/minDate/minDate.js +5 -1
  95. package/utils/rules/minLength/minLength.es6.js +5 -2
  96. package/utils/rules/minLength/minLength.js +5 -2
  97. package/utils/rules/num/num.es6.js +4 -1
  98. package/utils/rules/num/num.js +4 -1
  99. package/utils/rules/objectOf/objectOf.es6.js +6 -3
  100. package/utils/rules/objectOf/objectOf.js +6 -3
  101. package/utils/rules/pattern/pattern.es6.js +6 -2
  102. package/utils/rules/pattern/pattern.js +6 -2
  103. package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
  104. package/utils/rules/tupleOf/tupleOf.js +1 -1
  105. package/utils/rules/values/values.es6.js +5 -2
  106. package/utils/rules/values/values.js +5 -2
  107. package/utils/stringifySearch/stringifySearch.es6.js +4 -1
  108. package/utils/stringifySearch/stringifySearch.js +4 -1
  109. package/_virtual/_rollup-plugin-process-env.es6.js +0 -10
  110. 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 _a = useProps(), { children } = _a, props = __rest(_a, ["children"]);
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 _a = jsx.useProps(), { children } = _a, props = tslib.__rest(_a, ["children"]);
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 _a = useProps() || {}, { default: defaultValue, example, examples, max, min, values: values$1 } = _a, props = __rest(_a, ["default", "example", "examples", "max", "min", "values"]);
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', 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(),
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()), values: stringValues }));
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 _a = jsx.useProps() || {}, { default: defaultValue, example, examples, max, min, values: values$1 } = _a, props = tslib.__rest(_a, ["default", "example", "examples", "max", "min", "values"]);
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', 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(),
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()), values: stringValues }));
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 _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
- 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) }));
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 _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
- 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) }));
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 _a = useProps() || {}, { max: max$1, min: min$1 } = _a, props = __rest(_a, ["max", "min"]);
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 _a = jsx.useProps() || {}, { max: max$1, min: min$1 } = _a, props = tslib.__rest(_a, ["max", "min"]);
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 _a = useProps(), { children } = _a, props = __rest(_a, ["children"]);
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 _a = jsx.useProps(), { children } = _a, props = tslib.__rest(_a, ["children"]);
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 _a = useProps() || {}, { max, min, pattern: pattern$1, patternId } = _a, props = __rest(_a, ["max", "min", "pattern", "patternId"]);
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 _a = jsx.useProps() || {}, { max, min, pattern: pattern$1, patternId } = _a, props = tslib.__rest(_a, ["max", "min", "pattern", "patternId"]);
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 _a = useProps(), { children } = _a, props = __rest(_a, ["children"]);
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 _a = jsx.useProps(), { children } = _a, props = tslib.__rest(_a, ["children"]);
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 _a = useProps(), { default: defaultValue } = _a, props = __rest(_a, ["default"]);
16
- const schema = useSchemaType('string', Object.assign(Object.assign({}, props), { default: defaultValue === 'new' ? undefined : defaultValue }));
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 _a = jsx.useProps(), { default: defaultValue } = _a, props = tslib.__rest(_a, ["default"]);
20
- const schema = useSchemaType.useSchemaType('string', Object.assign(Object.assign({}, props), { default: defaultValue === 'new' ? undefined : defaultValue }));
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') {
@@ -1,5 +1,4 @@
1
- /// <reference types="node" />
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?: CookieSerializeOptions): void;
17
+ setCookie(name: string, value?: string, options?: SerializeOptions): void;
19
18
  get bodyType(): BodyType | undefined;
20
19
  get clientIp(): string | null;
21
- get cookies(): Record<string, string>;
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(): Record<string, string>;
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, __awaiter, __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate } from 'tslib';
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
- return __awaiter(this, void 0, void 0, function* () {
34
- if (!this.bodyType) {
35
- return;
36
- }
37
- if (this.bodyType === 'multipart/form-data') {
38
- this.body = yield parseFormBody(this.req);
39
- }
40
- if (this.bodyType === 'application/x-www-form-urlencoded') {
41
- this.body = parseSearch(yield parseBody(this.req));
42
- }
43
- if (this.bodyType === 'application/json') {
44
- this.body = JSON.parse(yield parseBody(this.req));
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');
@@ -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
- return tslib.__awaiter(this, void 0, void 0, function* () {
42
- if (!this.bodyType) {
43
- return;
44
- }
45
- if (this.bodyType === 'multipart/form-data') {
46
- this.body = yield parseFormBody.parseFormBody(this.req);
47
- }
48
- if (this.bodyType === 'application/x-www-form-urlencoded') {
49
- this.body = parseSearch.parseSearch(yield parseBody.parseBody(this.req));
50
- }
51
- if (this.bodyType === 'application/json') {
52
- this.body = JSON.parse(yield parseBody.parseBody(this.req));
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,3 +1,2 @@
1
- /// <reference types="node" />
2
1
  import type http from 'http';
3
2
  export declare function parseBody(req: http.IncomingMessage): Promise<string>;
@@ -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 __awaiter(this, void 0, void 0, function* () {
6
- return yield new Promise((resolve, reject) => {
7
- const decoder = new StringDecoder('utf-8');
8
- let buffer = '';
9
- req.on('data', chunk => {
10
- buffer += decoder.write(chunk);
11
- });
12
- req.on('end', () => {
13
- buffer += decoder.end();
14
- resolve(buffer);
15
- });
16
- req.on('error', err => {
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 tslib.__awaiter(this, void 0, void 0, function* () {
10
- return yield new Promise((resolve, reject) => {
11
- const decoder = new node_string_decoder.StringDecoder('utf-8');
12
- let buffer = '';
13
- req.on('data', chunk => {
14
- buffer += decoder.write(chunk);
15
- });
16
- req.on('end', () => {
17
- buffer += decoder.end();
18
- resolve(buffer);
19
- });
20
- req.on('error', err => {
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,3 +1,2 @@
1
- /// <reference types="node" />
2
1
  import type http from 'http';
3
2
  export declare function parseFormBody(req: http.IncomingMessage): Promise<object>;
@@ -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 __awaiter(this, void 0, void 0, function* () {
10
- return yield new Promise((resolve, reject) => {
11
- const form = new Form();
12
- form.parse(req, (error, fields, files) => {
13
- if (error) {
14
- reject(error);
15
- return;
16
- }
17
- let query = '';
18
- const queryFiles = [];
19
- for (const key in fields) {
20
- for (const value of fields[key]) {
21
- if (query) {
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
- for (const key in files) {
28
- const values = files[key];
29
- for (const value of values) {
30
- if (query) {
31
- query += '&';
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
- resolve(parseSearch(query, {
41
- decoder(value, decoder, charset, type) {
42
- if (type === 'key') {
43
- return decoder(value, decoder, charset);
44
- }
45
- if (value.startsWith('=')) {
46
- return queryFiles[Number(value.slice(1))];
47
- }
48
- return value.replaceAll('%26', '=');
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
  }