Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Jan 30, 2017
2 parents de3f487 + de70267 commit 096beb0
Show file tree
Hide file tree
Showing 31 changed files with 5,270 additions and 306 deletions.
9 changes: 9 additions & 0 deletions .babelrc
@@ -0,0 +1,9 @@
{
"presets": [
"es2015"
],
"plugins": [
"syntax-async-functions",
"transform-regenerator"
]
}
7 changes: 3 additions & 4 deletions .travis.yml
Expand Up @@ -2,13 +2,12 @@ sudo: false
language: node_js
node_js:
- "6"
- "5"
- "4"
cache:
yarn: true
directories:
- node_modules/
before_install:
- npm i -g npm
- npm i -g codecov nyc
- npm i -g nyc codecov
after_success:
- nyc report --reporter=lcov | codecov
- nyc report --reporter=lcov > coverage.lcov && codecov
2 changes: 2 additions & 0 deletions AUTHORS
Expand Up @@ -8,7 +8,9 @@
Alex <alexander.maznev@gmail.com>
antoinebrault <antoinebrault@gmail.com>
David Madner <david.madner@gmx.net>
Frans Krojegård <frans@krojegard.com>
InternalFX <bryan@internalfx.com>
Ivan Voznyakovsky <ivan.voznyakovsky@gmail.com>
Jason Dobry <jason.dobry@gmail.com>
Ken Børge Viktil <ken.borge.viktil@evry.com>
Kent C. Dodds <kent@doddsfamily.us>
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,16 @@
##### 3.0.0-rc.7 - 29 January 2017

###### Bug fixes
- #433 - `Collection#add` is missing a "silent" option

###### Backwards compatible changes
- Added a `emitRecordEvents` option to `Collection` which defaults to `true`

###### Other
- Moved Babel config from `package.json` to `.babelrc`
- Upgraded devDependencies
- Added a `yarn.lock` file

##### 3.0.0-rc.6 - 05 October 2016

###### Bug fixes
Expand Down
31 changes: 22 additions & 9 deletions circle.yml
@@ -1,17 +1,30 @@
machine:
node:
version: 6.9.1
environment:
YARN_VERSION: 0.18.1
PATH: "${PATH}:${HOME}/.yarn/bin:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"

general:
branches:
ignore:
- gh-pages
machine:
node:
version: 5.7.0

dependencies:
pre:
- npm i -g npm
- npm i -g codecov nyc
- |
if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
fi
- yarn global add nyc codecov
override:
- yarn install
cache_directories:
- ~/.yarn
- ~/.cache/yarn

test:
override:
- yarn test
post:
- nyc report --reporter=lcov | codecov
general:
artifacts:
- "dist"
- nyc report --reporter=lcov > coverage.lcov && codecov
47 changes: 26 additions & 21 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "js-data",
"description": "Robust, framework-agnostic in-memory data store.",
"version": "3.0.0-rc.6",
"version": "3.0.0-rc.7",
"homepage": "http://www.js-data.io",
"repository": {
"type": "git",
Expand All @@ -18,7 +18,8 @@
"src/",
"AUTHORS",
"CONTRIBUTORS",
"typings.json"
"typings.json",
"yarn.lock"
],
"keywords": [
"orm",
Expand All @@ -42,18 +43,9 @@
"it"
]
},
"babel": {
"presets": [
"es2015"
],
"plugins": [
"syntax-async-functions",
"transform-regenerator"
]
},
"scripts": {
"doc": "jsdoc -c conf.json src && node scripts/cleanup.js",
"lint": "repo-tools lint src/**/*.js test/**/*.js scripts/*.js lib/**/*.js *.config.js",
"lint": "standard 'src/**/*.js' 'test/**/*.js' 'scripts/*.js' 'lib/**/*.js' '*.config.js'",
"bundle:es5": "rollup src/index.js -c -o dist/js-data.js -m dist/js-data.js.map -f umd",
"bundle:next": "rollup src/index.js -c -o dist/js-data.es2015.js -m dist/js-data.es2015.js.map -f es",
"bundle": "npm run bundle:es5 && npm run bundle:next && repo-tools write-version dist/js-data.js dist/js-data.es2015.js",
Expand All @@ -68,20 +60,33 @@
"release": "npm test && npm run doc && repo-tools updates && repo-tools changelog && repo-tools authors"
},
"devDependencies": {
"babel-plugin-external-helpers": "^6.8.0",
"babel-core": "6.22.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.12.0",
"babel-plugin-transform-regenerator": "6.16.1",
"js-data-repo-tools": "0.5.7",
"karma": "1.3.0",
"babel-plugin-transform-es2015-modules-umd": "6.22.0",
"babel-plugin-transform-regenerator": "6.22.0",
"babel-polyfill": "6.22.0",
"babel-preset-es2015": "6.22.0",
"chai": "3.5.0",
"ink-docstrap": "git+https://github.com/js-data/docstrap.git#cfbe45fa313e1628c493076d5e15d2b855dfbf2c",
"js-data-repo-tools": "1.0.0",
"jsdoc": "3.4.3",
"karma": "1.4.1",
"karma-babel-preprocessor": "6.0.1",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.0.0",
"karma-mocha": "1.2.0",
"karma-mocha": "1.3.0",
"karma-phantomjs-launcher": "1.0.2",
"karma-sauce-launcher": "1.0.0",
"karma-sauce-launcher": "1.1.0",
"karma-sinon": "1.0.5",
"phantomjs-prebuilt": "2.1.13",
"uglify-js": "2.7.3"
"mocha": "3.2.0",
"nyc": "10.1.2",
"phantomjs-prebuilt": "2.1.14",
"rollup": "0.41.4",
"rollup-plugin-babel": "2.7.1",
"sinon": "1.17.7",
"standard": "8.6.0",
"uglify-js": "2.7.5"
}
}
9 changes: 7 additions & 2 deletions rollup.config.js
Expand Up @@ -6,12 +6,17 @@ export default {
plugins: [
babel({
babelrc: false,
plugins: [
'external-helpers'
],
presets: [
[
'es2015', { 'modules': false }
'es2015',
{
modules: false
}
]
],
plugins: ['external-helpers'],
exclude: 'node_modules/**'
})
]
Expand Down
17 changes: 15 additions & 2 deletions src/Collection.js
Expand Up @@ -16,6 +16,15 @@ const COLLECTION_DEFAULTS = {
*/
commitOnMerge: true,

/**
* Whether record events should bubble up and be emitted by the collection.
*
* @name Collection#emitRecordEvents
* @type {boolean}
* @default true
*/
emitRecordEvents: true,

/**
* Field to be used as the unique identifier for records in this collection.
* Defaults to `"id"` unless {@link Collection#mapper} is set, in which case
Expand Down Expand Up @@ -183,7 +192,9 @@ export default Component.extend({
* @param {...*} [arg] Args passed to {@link Collection#emit}.
*/
_onRecordEvent (...args) {
this.emit(...args)
if (this.emitRecordEvents) {
this.emit(...args)
}
},

/**
Expand Down Expand Up @@ -277,7 +288,9 @@ export default Component.extend({
})
// Finally, return the inserted data
const result = singular ? records[0] : records
this.emit('add', result)
if (!opts.silent) {
this.emit('add', result)
}
return this.afterAdd(records, opts, result) || result
},

Expand Down
2 changes: 0 additions & 2 deletions src/DataStore.js
Expand Up @@ -8,8 +8,6 @@ import {
import SimpleStore from './SimpleStore'
import LinkedCollection from './LinkedCollection'

const DOMAIN = 'DataStore'

const DATASTORE_DEFAULTS = {
/**
* Whether in-memory relations should be unlinked from records after they are
Expand Down
2 changes: 1 addition & 1 deletion src/Query.js
Expand Up @@ -15,7 +15,7 @@ const reserved = {
}

// Used by our JavaScript implementation of the LIKE operator
const escapeRegExp = /([.*+?^=!:${}()|[\]\/\\])/g
const escapeRegExp = /([.*+?^=!:${}()|[\]/\\])/g
const percentRegExp = /%/g
const underscoreRegExp = /_/g
const escape = function (pattern) {
Expand Down
7 changes: 3 additions & 4 deletions src/Record.js
Expand Up @@ -2,7 +2,6 @@ import utils, { safeSetLink } from './utils'
import Component from './Component'
import Settable from './Settable'
import {
belongsToType,
hasManyType,
hasOneType
} from './decorators'
Expand Down Expand Up @@ -401,7 +400,7 @@ export default Component.extend({
return !this._mapper().validate(this, opts)
},

removeInverseRelation(currentParent, id, inverseDef, idAttribute) {
removeInverseRelation (currentParent, id, inverseDef, idAttribute) {
if (inverseDef.type === hasOneType) {
safeSetLink(currentParent, inverseDef.localField, undefined)
} else if (inverseDef.type === hasManyType) {
Expand All @@ -415,7 +414,7 @@ export default Component.extend({
}
},

setupInverseRelation(record, id, inverseDef, idAttribute) {
setupInverseRelation (record, id, inverseDef, idAttribute) {
// Update (set) inverse relation
if (inverseDef.type === hasOneType) {
// e.g. someUser.profile = profile
Expand Down Expand Up @@ -649,7 +648,7 @@ export default Component.extend({
* session.skill_level = 'beginner'
*
* // Update the record in the database
* return user.save()
* return session.save()
* })
*
* @method Record#save
Expand Down
32 changes: 16 additions & 16 deletions src/Schema.js
Expand Up @@ -484,12 +484,16 @@ const validationKeywords = {
*/
properties (value, schema, opts) {
opts || (opts = {})

if (utils.isArray(value)) {
return
}

// Can be a boolean or an object
// Technically the default is an "empty schema", but here "true" is
// functionally the same
const additionalProperties = schema.additionalProperties === undefined ? true : schema.additionalProperties
// "s": The property set of the instance to validate.
const toValidate = {}
const validated = []
// "p": The property set from "properties".
// Default is an object
const properties = schema.properties || {}
Expand All @@ -498,28 +502,24 @@ const validationKeywords = {
const patternProperties = schema.patternProperties || {}
let errors = []

// Collect set "s"
utils.forOwn(value, function (_value, prop) {
toValidate[prop] = undefined
})
// Remove from "s" all elements of "p", if any.
utils.forOwn(properties || {}, function (_schema, prop) {
utils.forOwn(properties, function (_schema, prop) {
opts.prop = prop
errors = errors.concat(validate(value[prop], _schema, opts) || [])
delete toValidate[prop]
validated.push(prop)
})
// For each regex in "pp", remove all elements of "s" which this regex
// matches.

const toValidate = utils.omit(value, validated)
utils.forOwn(patternProperties, function (_schema, pattern) {
utils.forOwn(toValidate, function (undef, prop) {
if (prop.match(pattern)) {
opts.prop = prop
// console.log(_schema)
errors = errors.concat(validate(value[prop], _schema, opts) || [])
delete toValidate[prop]
validated.push(prop)
}
})
})
const keys = Object.keys(toValidate)
const keys = Object.keys(utils.omit(value, validated))
// If "s" is not empty, validation fails
if (additionalProperties === false) {
if (keys.length) {
Expand Down Expand Up @@ -852,7 +852,7 @@ const makeDescriptor = function (prop, schema, opts) {
this.emit('change:' + changed[i], this, utils.get(this, changed[i]))
}

const changes = utils.diffObjects({ [prop] : value }, { [prop] : current })
const changes = utils.diffObjects({ [prop]: value }, { [prop]: current })

if (_get(keepChangeHistoryPath)) {
const changeRecord = utils.plainCopy(changes)
Expand Down Expand Up @@ -1027,7 +1027,8 @@ function Schema (definition) {
// TODO: schema validation
utils.fillIn(this, definition)

if (this.type === 'object' && this.properties) {
if (this.type === 'object') {
this.properties = this.properties || {}
utils.forOwn(this.properties, (_definition, prop) => {
if (!(_definition instanceof Schema)) {
this.properties[prop] = new Schema(_definition)
Expand Down Expand Up @@ -1224,4 +1225,3 @@ export default Component.extend({
* @returns {Constructor} Subclass of this Schema class.
* @since 3.0.0
*/

6 changes: 4 additions & 2 deletions src/SimpleStore.js
@@ -1,4 +1,4 @@
import utils, { safeSetLink, safeSetProp } from './utils'
import utils from './utils'

import {
belongsToType,
Expand Down Expand Up @@ -1284,6 +1284,7 @@ const props = {
* @param {string} name Name of the {@link Mapper} to target.
* @param {(string|number)} id Passed to {@link Mapper#find}.
* @param {Object} [opts] Passed to {@link Mapper#find}.
* @param {boolean} [opts.force] Bypass cacheFind
* @param {boolean|Function} [opts.usePendingFind] See {@link SimpleStore#usePendingFind}
* @returns {Promise} Resolves with the result, if any.
* @since 3.0.0
Expand Down Expand Up @@ -1395,6 +1396,7 @@ const props = {
* @param {string} name Name of the {@link Mapper} to target.
* @param {Object} [query] Passed to {@link Mapper.findAll}.
* @param {Object} [opts] Passed to {@link Mapper.findAll}.
* @param {boolean} [opts.force] Bypass cacheFindAll
* @param {boolean|Function} [opts.usePendingFindAll] See {@link SimpleStore#usePendingFindAll}
* @returns {Promise} Resolves with the result, if any.
* @since 3.0.0
Expand Down Expand Up @@ -1792,7 +1794,7 @@ const props = {
*/
updateAll (name, props, query, opts) {
opts || (opts = {})
return Container.prototype.updateAll.call(this, name, query, props, opts)
return Container.prototype.updateAll.call(this, name, props, query, opts)
.then((result) => this._end(name, result, opts))
},

Expand Down

0 comments on commit 096beb0

Please sign in to comment.