@innet/server 2.0.0-beta.7 → 2.0.0-beta.9

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/index.es6.js CHANGED
@@ -86,6 +86,7 @@ export { once } from './utils/decorators/once/once.es6.js';
86
86
  export { generateSchemaTypes, generateTypes } from './utils/generateTypes/generateTypes.es6.js';
87
87
  export { getEndpoint } from './utils/getEndpoint/getEndpoint.es6.js';
88
88
  export { getOrAdd } from './utils/getOrAdd/getOrAdd.es6.js';
89
+ export { getSafeSchema } from './utils/getSafeSchema/getSafeSchema.es6.js';
89
90
  export { httpOnStart } from './utils/httpOnStart/httpOnStart.es6.js';
90
91
  export { parseBody } from './utils/parseBody/parseBody.es6.js';
91
92
  export { parseFormBody } from './utils/parseFormBody/parseFormBody.es6.js';
package/index.js CHANGED
@@ -90,6 +90,7 @@ var once = require('./utils/decorators/once/once.js');
90
90
  var generateTypes = require('./utils/generateTypes/generateTypes.js');
91
91
  var getEndpoint = require('./utils/getEndpoint/getEndpoint.js');
92
92
  var getOrAdd = require('./utils/getOrAdd/getOrAdd.js');
93
+ var getSafeSchema = require('./utils/getSafeSchema/getSafeSchema.js');
93
94
  var httpOnStart = require('./utils/httpOnStart/httpOnStart.js');
94
95
  var parseBody = require('./utils/parseBody/parseBody.js');
95
96
  var parseFormBody = require('./utils/parseFormBody/parseFormBody.js');
@@ -240,6 +241,7 @@ exports.generateSchemaTypes = generateTypes.generateSchemaTypes;
240
241
  exports.generateTypes = generateTypes.generateTypes;
241
242
  exports.getEndpoint = getEndpoint.getEndpoint;
242
243
  exports.getOrAdd = getOrAdd.getOrAdd;
244
+ exports.getSafeSchema = getSafeSchema.getSafeSchema;
243
245
  exports.httpOnStart = httpOnStart.httpOnStart;
244
246
  exports.parseBody = parseBody.parseBody;
245
247
  exports.parseFormBody = parseFormBody.parseFormBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innet/server",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-beta.9",
4
4
  "description": "Create server-side application with innet",
5
5
  "main": "index.js",
6
6
  "module": "index.es6.js",
@@ -53,7 +53,6 @@
53
53
  "string_decoder": "^1.3.0",
54
54
  "tslib": "^2.8.1",
55
55
  "uuid": "^13.0.0",
56
- "watch-state": "^3.6.2",
57
- "youch": "^4.1.0"
56
+ "watch-state": "^3.6.2"
58
57
  }
59
58
  }
@@ -2,6 +2,7 @@ import { useNewHandler, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import '../../../utils/index.es6.js';
5
+ import { getSafeSchema } from '../../../utils/getSafeSchema/getSafeSchema.es6.js';
5
6
  import { useObjectSchemaContext } from '../../../hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js';
6
7
  import { schemaContext } from '../../../hooks/useSchemaContext/useSchemaContext.es6.js';
7
8
  import { useObjectRule, objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es6.js';
@@ -11,7 +12,7 @@ import { required } from '../../../utils/rules/required/required.es6.js';
11
12
  const field = () => {
12
13
  const handler = useNewHandler();
13
14
  const { children, deprecated, key, optional, readOnly, writeOnly, } = useProps();
14
- const schema = useObjectSchemaContext();
15
+ const schema = getSafeSchema(useObjectSchemaContext());
15
16
  if (!schema.properties) {
16
17
  schema.properties = {};
17
18
  }
@@ -6,6 +6,7 @@ var innet = require('innet');
6
6
  var jsx = require('@innet/jsx');
7
7
  require('../../../hooks/index.js');
8
8
  require('../../../utils/index.js');
9
+ var getSafeSchema = require('../../../utils/getSafeSchema/getSafeSchema.js');
9
10
  var useObjectSchemaContext = require('../../../hooks/useObjectSchemaContext/useObjectSchemaContext.js');
10
11
  var useSchemaContext = require('../../../hooks/useSchemaContext/useSchemaContext.js');
11
12
  var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
@@ -15,7 +16,7 @@ var required = require('../../../utils/rules/required/required.js');
15
16
  const field = () => {
16
17
  const handler = innet.useNewHandler();
17
18
  const { children, deprecated, key, optional, readOnly, writeOnly, } = jsx.useProps();
18
- const schema = useObjectSchemaContext.useObjectSchemaContext();
19
+ const schema = getSafeSchema.getSafeSchema(useObjectSchemaContext.useObjectSchemaContext());
19
20
  if (!schema.properties) {
20
21
  schema.properties = {};
21
22
  }
@@ -15,6 +15,7 @@ import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
15
15
  import { useRule, ruleContext } from '../../../hooks/useRule/useRule.es6.js';
16
16
  import { objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es6.js';
17
17
  import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
18
+ import { getSafeSchema } from '../../../utils/getSafeSchema/getSafeSchema.es6.js';
18
19
 
19
20
  const object = () => {
20
21
  useBlock('path');
@@ -53,8 +54,9 @@ const object = () => {
53
54
  parentRuleContext.reset(handler);
54
55
  innet(children, handler);
55
56
  useEffect(() => {
56
- if (!Object.keys(schema.additionalProperties).length) {
57
- delete schema.additionalProperties;
57
+ const safeSchema = getSafeSchema(schema);
58
+ if (!Object.keys(safeSchema.additionalProperties).length) {
59
+ delete safeSchema.additionalProperties;
58
60
  }
59
61
  });
60
62
  }
@@ -19,6 +19,7 @@ var pipe = require('../../../utils/rules/pipe/pipe.js');
19
19
  var useRule = require('../../../hooks/useRule/useRule.js');
20
20
  var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
21
21
  var useEffect = require('../../../hooks/useEffect/useEffect.js');
22
+ var getSafeSchema = require('../../../utils/getSafeSchema/getSafeSchema.js');
22
23
 
23
24
  const object = () => {
24
25
  useBlock.useBlock('path');
@@ -57,8 +58,9 @@ const object = () => {
57
58
  useParentRule.parentRuleContext.reset(handler);
58
59
  innet.innet(children, handler);
59
60
  useEffect.useEffect(() => {
60
- if (!Object.keys(schema.additionalProperties).length) {
61
- delete schema.additionalProperties;
61
+ const safeSchema = getSafeSchema.getSafeSchema(schema);
62
+ if (!Object.keys(safeSchema.additionalProperties).length) {
63
+ delete safeSchema.additionalProperties;
62
64
  }
63
65
  });
64
66
  }
@@ -0,0 +1,2 @@
1
+ import { type SchemaObject } from '../../types';
2
+ export declare function getSafeSchema(schema: SchemaObject): SchemaObject;
@@ -0,0 +1,5 @@
1
+ function getSafeSchema(schema) {
2
+ return 'oneOf' in schema ? schema.oneOf[0] : schema;
3
+ }
4
+
5
+ export { getSafeSchema };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function getSafeSchema(schema) {
6
+ return 'oneOf' in schema ? schema.oneOf[0] : schema;
7
+ }
8
+
9
+ exports.getSafeSchema = getSafeSchema;
@@ -0,0 +1 @@
1
+ export * from './getSafeSchema';
@@ -0,0 +1 @@
1
+ export { getSafeSchema } from './getSafeSchema.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var getSafeSchema = require('./getSafeSchema.js');
6
+
7
+
8
+
9
+ exports.getSafeSchema = getSafeSchema.getSafeSchema;
package/utils/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './decorators';
5
5
  export * from './generateTypes';
6
6
  export * from './getEndpoint';
7
7
  export * from './getOrAdd';
8
+ export * from './getSafeSchema';
8
9
  export * from './httpOnStart';
9
10
  export * from './parseBody';
10
11
  export * from './parseFormBody';
@@ -5,6 +5,7 @@ import './decorators/index.es6.js';
5
5
  import './generateTypes/index.es6.js';
6
6
  import './getEndpoint/index.es6.js';
7
7
  import './getOrAdd/index.es6.js';
8
+ import './getSafeSchema/index.es6.js';
8
9
  import './httpOnStart/index.es6.js';
9
10
  import './parseBody/index.es6.js';
10
11
  import './parseFormBody/index.es6.js';
package/utils/index.js CHANGED
@@ -7,6 +7,7 @@ require('./decorators/index.js');
7
7
  require('./generateTypes/index.js');
8
8
  require('./getEndpoint/index.js');
9
9
  require('./getOrAdd/index.js');
10
+ require('./getSafeSchema/index.js');
10
11
  require('./httpOnStart/index.js');
11
12
  require('./parseBody/index.js');
12
13
  require('./parseFormBody/index.js');