Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-data

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-data - npm Package Compare versions

Comparing version 3.0.0-rc.7 to 3.0.0-rc.8

11

CHANGELOG.md

@@ -0,1 +1,12 @@

##### 3.0.0-rc.8 - 21 February 2017
###### Breaking changes
- #445
- The `strict` option has been removed from the `toJSON` methods. The methods now rely wholly on `Schema#pick` for strictness, and assumes the original `strict: false` behavior if no schema is defined.
- `Schema#pick` now copies properties not defined in the "properties" keyword if the "additionalProperties" keyword is present and truthy.
- Mappers are no longer given an empty schema if no schema is provided
###### Bug fixes
- #446 - fix(Collection): Add noValidate option to Collection#add, by @ivanvoznyakovsky
##### 3.0.0-rc.7 - 29 January 2017

@@ -2,0 +13,0 @@

10

package.json
{
"name": "js-data",
"description": "Robust, framework-agnostic in-memory data store.",
"version": "3.0.0-rc.7",
"version": "3.0.0-rc.8",
"homepage": "http://www.js-data.io",

@@ -63,9 +63,9 @@ "repository": {

"devDependencies": {
"babel-core": "6.22.1",
"babel-core": "6.23.1",
"babel-eslint": "7.1.1",
"babel-plugin-external-helpers": "6.22.0",
"babel-plugin-syntax-async-functions": "6.13.0",
"babel-plugin-transform-es2015-modules-umd": "6.22.0",
"babel-plugin-transform-es2015-modules-umd": "6.23.0",
"babel-plugin-transform-regenerator": "6.22.0",
"babel-polyfill": "6.22.0",
"babel-polyfill": "6.23.0",
"babel-preset-es2015": "6.22.0",

@@ -76,3 +76,3 @@ "chai": "3.5.0",

"jsdoc": "3.4.3",
"karma": "1.4.1",
"karma": "1.5.0",
"karma-babel-preprocessor": "6.0.1",

@@ -79,0 +79,0 @@ "karma-chai": "0.1.0",

<img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="96" height="96" />
# [js-data v3](http://www.js-data.io/) [![Slack][1]][2] [![NPM][3]][4] [![Downloads][5]][6] [![Coverage][7]][8]
# [js-data v3](http://www.js-data.io/) [![Slack][1]][2] [![NPM][3]][4] [![npm version](https://img.shields.io/badge/npm-v3.0.0--rc.8-yellow.svg?style=flat)](https://www.npmjs.org/package/js-data) [![Downloads][5]][6] [![Coverage][7]][8]

@@ -5,0 +5,0 @@ | __Browser tests__ | __Node.js tests__ |

import utils from './utils'
import Component from './Component'
import Query from './Query'
import Record from './Record'
import Index from '../lib/mindex/index'
const { noValidatePath } = Record
const DOMAIN = 'Collection'

@@ -215,2 +218,3 @@

* @param {boolean} [opts.commitOnMerge=true] See {@link Collection#commitOnMerge}.
* @param {boolean} [opts.noValidate] See {@link Record#noValidate}.
* @param {string} [opts.onConflict] See {@link Collection#onConflict}.

@@ -257,2 +261,10 @@ * @returns {(Object|Object[]|Record|Record[])} The added record or records.

const onConflict = opts.onConflict || this.onConflict
if (onConflict !== 'merge' && onConflict !== 'replace') {
throw utils.err(`${DOMAIN}#add`, 'opts.onConflict')(400, 'one of (merge, replace)', onConflict, true)
}
const existingNoValidate = existing._get(noValidatePath)
if (opts.noValidate) {
// Disable validation
existing._set(noValidatePath, true)
}
if (onConflict === 'merge') {

@@ -267,5 +279,7 @@ utils.deepMixIn(existing, record)

existing.set(record)
} else {
throw utils.err(`${DOMAIN}#add`, 'opts.onConflict')(400, 'one of (merge, replace)', onConflict, true)
}
if (opts.noValidate) {
// Restore previous `noValidate` value
existing._set(noValidatePath, existingNoValidate)
}
record = existing

@@ -272,0 +286,0 @@ if (opts.commitOnMerge && utils.isFunction(record.commit)) {

@@ -57,2 +57,3 @@ import utils from './utils'

* @name Component#_listeners
* @private
* @instance

@@ -59,0 +60,0 @@ * @since 3.0.0

@@ -595,3 +595,3 @@ import utils from './utils'

* @example
* import {Container} from 'js-data'
* import { Container } from 'js-data'
* import RethinkDBAdapter from 'js-data-rethinkdb'

@@ -609,5 +609,18 @@ * const store = new Container()

* const person = store.createRecord('person', { id: 1, name: 'John', foo: 'bar' })
* console.log(store.toJSON('person', person)) // {"id":1,"name":"John","foo":"bar"}
* console.log(store.toJSON('person', person), { strict: true }) // {"id":1,"name":"John"}
* // "foo" is stripped by toJSON()
* console.log(store.toJSON('person', person)) // {"id":1,"name":"John"}
*
* store.defineMapper('personRelaxed', {
* schema: {
* properties: {
* name: { type: 'string' },
* id: { type: 'string' }
* },
* additionalProperties: true
* }
* })
* const person2 = store.createRecord('personRelaxed', { id: 1, name: 'John', foo: 'bar' })
* // "foo" is not stripped by toJSON
* console.log(store.toJSON('personRelaxed', person2)) // {"id":1,"name":"John","foo":"bar"}
*
* @method Container#toJSON

@@ -614,0 +627,0 @@ * @param {string} name Name of the {@link Mapper} to target.

@@ -123,2 +123,4 @@ import utils, { safeSetLink } from './utils'

* initial properties.
* @param {boolean} [opts.validateOnSet=true] Whether to enable setter
* validation on properties after the Record has been initialized.
* @since 3.0.0

@@ -133,5 +135,3 @@ */

_set(creatingPath, true)
if (opts.noValidate) {
_set(noValidatePath, opts.noValidate === undefined ? true : opts.noValidate)
}
_set(noValidatePath, !!opts.noValidate)
_set(keepChangeHistoryPath, opts.keepChangeHistory === undefined ? (mapper ? mapper.keepChangeHistory : true) : opts.keepChangeHistory)

@@ -148,4 +148,9 @@

_set(creatingPath, false)
const validateOnSet = opts.validateOnSet === undefined ? (mapper ? mapper.validateOnSet : true) : opts.validateOnSet
_set(noValidatePath, !validateOnSet)
if (opts.validateOnSet !== undefined) {
_set(noValidatePath, !opts.validateOnSet)
} else if (mapper && mapper.validateOnSet !== undefined) {
_set(noValidatePath, !mapper.validateOnSet)
} else {
_set(noValidatePath, false)
}
_set(previousPath, mapper ? mapper.toJSON(props) : utils.plainCopy(props))

@@ -746,5 +751,5 @@ }

* @example <caption>Record#toJSON</caption>
* // Normally you would do: import {Container} from 'js-data'
* const JSData = require('js-data@3.0.0-rc.4')
* const {Container} = JSData
* // Normally you would do: import { Container } from 'js-data'
* const JSData = require('js-data@3.0.0-rc.8')
* const { Container } = JSData
* console.log('Using JSData v' + JSData.version.full)

@@ -765,8 +770,5 @@ * const store = new Container()

* console.log('user: ' + JSON.stringify(user.toJSON()))
* console.log('user: ' + JSON.stringify(user.toJSON({ strict: true })))
*
* @method Record#toJSON
* @param {Object} [opts] Configuration options.
* @param {boolean} [opts.strict] Whether to exclude properties that are not
* defined in {@link Mapper#schema}.
* @param {string[]} [opts.with] Array of relation names or relation fields

@@ -785,3 +787,3 @@ * to include in the representation. Only available as an option if the class

const json = {}
utils.forOwn(this, function (prop, key) {
utils.forOwn(this, (prop, key) => {
json[key] = utils.plainCopy(prop)

@@ -856,2 +858,7 @@ })

}
}, {
creatingPath,
noValidatePath,
keepChangeHistoryPath,
previousPath
})

@@ -858,0 +865,0 @@

@@ -516,3 +516,2 @@ import utils from './utils'

opts.prop = prop
// console.log(_schema)
errors = errors.concat(validate(value[prop], _schema, opts) || [])

@@ -654,6 +653,66 @@ validated.push(prop)

/**
* Validation keywords validated for any type:
*
* - `enum`
* - `type`
* - `allOf`
* - `anyOf`
* - `oneOf`
* - `not`
*
* @name Schema.ANY_OPS
* @type {string[]}
*/
const ANY_OPS = ['enum', 'type', 'allOf', 'anyOf', 'oneOf', 'not']
/**
* Validation keywords validated for array types:
*
* - `items`
* - `maxItems`
* - `minItems`
* - `uniqueItems`
*
* @name Schema.ARRAY_OPS
* @type {string[]}
*/
const ARRAY_OPS = ['items', 'maxItems', 'minItems', 'uniqueItems']
/**
* Validation keywords validated for numeric (number and integer) types:
*
* - `multipleOf`
* - `maximum`
* - `minimum`
*
* @name Schema.NUMERIC_OPS
* @type {string[]}
*/
const NUMERIC_OPS = ['multipleOf', 'maximum', 'minimum']
/**
* Validation keywords validated for object types:
*
* - `maxProperties`
* - `minProperties`
* - `required`
* - `properties`
* - `dependencies`
*
* @name Schema.OBJECT_OPS
* @type {string[]}
*/
const OBJECT_OPS = ['maxProperties', 'minProperties', 'required', 'properties', 'dependencies']
/**
* Validation keywords validated for string types:
*
* - `maxLength`
* - `minLength`
* - `pattern`
*
* @name Schema.STRING_OPS
* @type {string[]}
*/
const STRING_OPS = ['maxLength', 'minLength', 'pattern']

@@ -1064,3 +1123,3 @@

*
* @name Schema#validate
* @name Schema#apply
* @method

@@ -1133,4 +1192,5 @@ * @param {Object} target The prototype to which to apply this schema.

let copy = {}
if (this.properties) {
utils.forOwn(this.properties, (_definition, prop) => {
const properties = this.properties
if (properties) {
utils.forOwn(properties, (_definition, prop) => {
copy[prop] = _definition.pick(value[prop])

@@ -1142,2 +1202,10 @@ })

}
// Conditionally copy properties not defined in "properties"
if (this.additionalProperties) {
for (var key in value) {
if (!properties[key]) {
copy[key] = utils.plainCopy(value[key])
}
}
}
return copy

@@ -1144,0 +1212,0 @@ } else if (this.type === 'array') {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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