New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

uniforms-bridge-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniforms-bridge-json-schema - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

6

JSONSchemaBridge.js

@@ -76,4 +76,8 @@ "use strict";

value: function getError(name, error) {
var nameParts = (0, _joinName["default"])(null, name);
var rootName = (0, _joinName["default"])(nameParts.slice(0, -1));
var baseName = nameParts[nameParts.length - 1];
return error && error.details && error.details.find && error.details.find(function (detail) {
return detail.dataPath && detail.dataPath.substring(1) === name;
var path = detail.dataPath.substring(1);
return name === path || rootName === path && baseName === detail.params.missingProperty;
});

@@ -80,0 +84,0 @@ }

6

package.json
{
"name": "uniforms-bridge-json-schema",
"version": "2.1.0",
"version": "2.2.0",
"license": "MIT",

@@ -25,5 +25,5 @@ "main": "index.js",

"lodash": "^4.0.0",
"uniforms": "^2.1.0"
"uniforms": "^2.2.0"
},
"gitHead": "ed5f34e3b80e3c9b1702d7b19642f9c10e8ada05"
"gitHead": "b8b570ad583f100f133e1f1ac8d6d6c67439c498"
}
// @flow
import './register';
export {default as JSONSchemaBridge} from './JSONSchemaBridge';
export { default as JSONSchemaBridge } from './JSONSchemaBridge';

@@ -18,3 +18,7 @@ import invariant from 'invariant';

invariant(resolvedReference, 'Reference not found in schema: "%s"', referance);
invariant(
resolvedReference,
'Reference not found in schema: "%s"',
referance
);

@@ -30,3 +34,3 @@ return resolvedReference;

if (schema.$ref) {
return {...schema, ...resolveRef(schema.$ref, schema)};
return { ...schema, ...resolveRef(schema.$ref, schema) };
}

@@ -51,2 +55,6 @@

getError(name, error) {
const nameParts = joinName(null, name);
const rootName = joinName(nameParts.slice(0, -1));
const baseName = nameParts[nameParts.length - 1];
return (

@@ -56,3 +64,9 @@ error &&

error.details.find &&
error.details.find(detail => detail.dataPath && detail.dataPath.substring(1) === name)
error.details.find(detail => {
const path = detail.dataPath.substring(1);
return (
name === path ||
(rootName === path && baseName === detail.params.missingProperty)
);
})
);

@@ -70,3 +84,6 @@ }

if (Array.isArray(error.details)) {
return error.details.reduce((acc, {message}) => acc.concat(message), []);
return error.details.reduce(
(acc, { message }) => acc.concat(message),
[]
);
}

@@ -83,3 +100,7 @@

const previous = joinName(array.slice(0, nextIndex));
const isRequired = (definition.required || (this._compiledSchema[previous] || {}).required || []).includes(next);
const isRequired = (
definition.required ||
(this._compiledSchema[previous] || {}).required ||
[]
).includes(next);

@@ -90,11 +111,27 @@ const _key = joinName(previous, next);

if (next === '$' || next === '' + parseInt(next, 10)) {
invariant(definition.type === 'array', 'Field not found in schema: "%s"', name);
definition = Array.isArray(definition.items) ? definition.items[parseInt(next, 10)] : definition.items;
invariant(
definition.type === 'array',
'Field not found in schema: "%s"',
name
);
definition = Array.isArray(definition.items)
? definition.items[parseInt(next, 10)]
: definition.items;
} else if (definition.type === 'object') {
invariant(definition.properties, 'Field properties not found in schema: "%s"', name);
invariant(
definition.properties,
'Field properties not found in schema: "%s"',
name
);
definition = definition.properties[next];
} else {
const [{properties: combinedDefinition = {}} = {}] = ['allOf', 'anyOf', 'oneOf']
const [{ properties: combinedDefinition = {} } = {}] = [
'allOf',
'anyOf',
'oneOf'
]
.filter(key => definition[key])
.map(key => definition[key].find(({properties = {}}) => properties[next]));
.map(key =>
definition[key].find(({ properties = {} }) => properties[next])
);

@@ -113,3 +150,5 @@ definition = combinedDefinition[next];

.forEach(key => {
_definition[key] = definition[key].map(def => (def.$ref ? resolveRef(def.$ref, this.schema) : def));
_definition[key] = definition[key].map(def =>
def.$ref ? resolveRef(def.$ref, this.schema) : def
);
});

@@ -129,3 +168,3 @@

.reduce(
([_properties, _required], {properties, required}) => [
([_properties, _required], { properties, required }) => [
Object.assign(_properties, properties),

@@ -141,3 +180,3 @@ _required.concat(required)

this._compiledSchema[_key] = Object.assign(_definition, {isRequired});
this._compiledSchema[_key] = Object.assign(_definition, { isRequired });

@@ -149,4 +188,7 @@ return definition;

getInitialValue(name, props = {}) {
const {default: _default, type: _type} = this.getField(name);
const {default: defaultValue = _default, type = _type} = this._compiledSchema[name];
const { default: _default, type: _type } = this.getField(name);
const {
default: defaultValue = _default,
type = _type
} = this._compiledSchema[name];

@@ -167,7 +209,16 @@ if (type === 'array') {

getProps(name, {label = true, options: opts, placeholder, ...props} = {}) {
const {title: _title, enum: _enum, type: _type, options: _options, uniforms} = this.getField(name);
const {enum: allowedValues = _enum, options = _options, type: fieldType = _type, isRequired} = this._compiledSchema[
name
];
getProps(name, { label = true, options: opts, placeholder, ...props } = {}) {
const {
title: _title,
enum: _enum,
type: _type,
options: _options,
uniforms
} = this.getField(name);
const {
enum: allowedValues = _enum,
options = _options,
type: fieldType = _type,
isRequired
} = this._compiledSchema[name];

@@ -178,3 +229,4 @@ const [fieldName] = joinName(null, name)

const fieldNameCapitalized = fieldName.charAt(0).toUpperCase() + fieldName.slice(1).toLowerCase();
const fieldNameCapitalized =
fieldName.charAt(0).toUpperCase() + fieldName.slice(1).toLowerCase();
const labelContent = _title ? _title : fieldNameCapitalized;

@@ -184,3 +236,3 @@

allowedValues,
...(fieldType === 'number' ? {decimal: true} : {}),
...(fieldType === 'number' ? { decimal: true } : {}),
options: opts || options,

@@ -197,3 +249,4 @@ label: label === true ? labelContent : label || '',

} else {
ready.transform = value => ready.options.find(option => option.value === value).label;
ready.transform = value =>
ready.options.find(option => option.value === value).label;
ready.allowedValues = ready.options.map(option => option.value);

@@ -219,4 +272,7 @@ }

const {type: _type, properties: _properties} = this.getField(name);
const {type: fieldType = _type, properties: fieldProperties = _properties} = this._compiledSchema[name];
const { type: _type, properties: _properties } = this.getField(name);
const {
type: fieldType = _type,
properties: fieldProperties = _properties
} = this._compiledSchema[name];

@@ -231,4 +287,4 @@ if (fieldType === 'object') {

getType(name) {
const {type: _type, format: fieldFormat} = this.getField(name);
const {type: fieldType = _type} = this._compiledSchema[name];
const { type: _type, format: fieldFormat } = this.getField(name);
const { type: fieldType = _type } = this._compiledSchema[name];

@@ -243,3 +299,7 @@ if (fieldFormat === 'date-time') return Date;

invariant(fieldType !== 'null', 'Field "%s" can not be represented as a type null', name);
invariant(
fieldType !== 'null',
'Field "%s" can not be represented as a type null',
name
);

@@ -246,0 +306,0 @@ return fieldType;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc