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

angular-data

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-data - npm Package Compare versions

Comparing version 1.4.2 to 1.4.3

circle.yml

8

CHANGELOG.md

@@ -0,1 +1,9 @@

##### 1.4.3 - 30 November 2014
###### Backwards compatible bug fixes
- #253 - Injecting an item with relationships a second time breaks relationships
###### Backwards compatible bug fixes
- Fixed "allowSimpleWhere" default not being set
##### 1.4.2 - 18 November 2014

@@ -2,0 +10,0 @@

12

package.json
{
"name": "angular-data",
"description": "Data store for Angular.js.",
"version": "1.4.2",
"version": "1.4.3",
"homepage": "http://angular-data.pseudobry.com",

@@ -30,4 +30,6 @@ "repository": {

"grunt-contrib-watch": "0.6.1",
"grunt-docular": "0.1.4",
"grunt-karma": "0.9.0",
"grunt-karma-coveralls": "2.5.2",
"jit-grunt": "0.9.0",
"karma": "0.12.24",

@@ -37,11 +39,9 @@ "karma-chai": "0.1.0",

"karma-coverage": "0.2.6",
"karma-script-launcher": "0.1.0",
"karma-firefox-launcher": "0.1.3",
"karma-mocha": "0.1.9",
"karma-phantomjs-launcher": "0.1.4",
"karma-mocha": "0.1.9",
"karma-script-launcher": "0.1.0",
"karma-sinon": "1.0.3",
"karma-spec-reporter": "0.0.13",
"time-grunt": "1.0.0",
"jit-grunt": "0.9.0",
"grunt-docular": "0.1.4"
"time-grunt": "1.0.0"
},

@@ -48,0 +48,0 @@ "scripts": {

@@ -11,3 +11,3 @@ ## angular-data [![Stories in Backlog](https://badge.waffle.io/jmdobry/angular-data.svg?label=backlog&title=Backlog)](http://waffle.io/jmdobry/angular-data) [![Stories in Ready](https://badge.waffle.io/jmdobry/angular-data.svg?label=ready&title=Ready)](http://waffle.io/jmdobry/angular-data) [![Stories in progress](https://badge.waffle.io/jmdobry/angular-data.svg?label=in%20progress&title=In%20Progress)](http://waffle.io/jmdobry/angular-data)

__Latest Release:__ [1.4.2](https://github.com/jmdobry/angular-data/releases/tag/1.4.2)
__Latest Release:__ [1.4.3](https://github.com/jmdobry/angular-data/releases/tag/1.4.3)

@@ -14,0 +14,0 @@ Angular-data is finally 1.0.!

@@ -8,23 +8,5 @@ var observe = require('../../../lib/observe-js/observe-js');

function _injectRelations(definition, injected, options) {
var DS = this;
DS.utils.forEach(definition.relationList, function (def) {
var relationName = def.relation;
var relationDef = DS.definitions[relationName];
if (injected[def.localField]) {
if (!relationDef) {
throw new DS.errors.R(definition.name + 'relation is defined but the resource is not!');
}
try {
injected[def.localField] = DS.inject(relationName, injected[def.localField], options);
} catch (err) {
DS.$log.error(errorPrefix(definition.name) + 'Failed to inject ' + def.type + ' relation: "' + relationName + '"!', err);
}
}
});
}
function _inject(definition, resource, attrs, options) {
var DS = this;
var DSUtils = DS.utils;
var $log = DS.$log;

@@ -37,3 +19,3 @@

DS.utils.forEach(definition.relationFields, function (field) {
DSUtils.forEach(definition.relationFields, function (field) {
delete added[field];

@@ -44,6 +26,6 @@ delete removed[field];

if (!DS.utils.isEmpty(added) || !DS.utils.isEmpty(removed) || !DS.utils.isEmpty(changed) || firstTime) {
if (!DSUtils.isEmpty(added) || !DSUtils.isEmpty(removed) || !DSUtils.isEmpty(changed) || firstTime) {
item = DS.get(definition.name, innerId);
resource.modified[innerId] = DS.utils.updateTimestamp(resource.modified[innerId]);
resource.collectionModified = DS.utils.updateTimestamp(resource.collectionModified);
resource.modified[innerId] = DSUtils.updateTimestamp(resource.modified[innerId]);
resource.collectionModified = DSUtils.updateTimestamp(resource.collectionModified);
if (definition.keepChangeHistory) {

@@ -65,3 +47,3 @@ var changeRecord = {

item = item || DS.get(definition.name, innerId);
DS.utils.forEach(definition.computed, function (fn, field) {
DSUtils.forEach(definition.computed, function (fn, field) {
var compute = false;

@@ -83,3 +65,3 @@ // check if required fields changed

item = item || DS.get(definition.name, innerId);
DS.utils.forEach(definition.relationList, function (def) {
DSUtils.forEach(definition.relationList, function (def) {
if (item[def.localField] && (def.localKey in added || def.localKey in removed || def.localKey in changed)) {

@@ -99,3 +81,3 @@ DS.link(definition.name, item[definition.idAttribute], [def.relation]);

var injected;
if (DS.utils.isArray(attrs)) {
if (DSUtils.isArray(attrs)) {
injected = [];

@@ -122,2 +104,41 @@ for (var i = 0; i < attrs.length; i++) {

try {
DSUtils.forEach(definition.relationList, function (def) {
var relationName = def.relation;
var relationDef = DS.definitions[relationName];
var toInject = attrs[def.localField];
if (toInject) {
if (!relationDef) {
throw new DS.errors.R(definition.name + 'relation is defined but the resource is not!');
}
if (DSUtils.isArray(toInject)) {
var items = [];
DSUtils.forEach(toInject, function (toInjectItem) {
if (toInjectItem !== DS.store[relationName][toInjectItem[relationDef.idAttribute]]) {
try {
var injectedItem = DS.inject(relationName, toInjectItem, options);
if (def.foreignKey) {
injectedItem[def.foreignKey] = attrs[definition.idAttribute];
}
items.push(injectedItem);
} catch (err) {
DS.$log.error(errorPrefix(definition.name) + 'Failed to inject ' + def.type + ' relation: "' + relationName + '"!', err);
}
}
});
attrs[def.localField] = items;
} else {
if (toInject !== DS.store[relationName][toInject[relationDef.idAttribute]]) {
try {
attrs[def.localField] = DS.inject(relationName, attrs[def.localField], options);
if (def.foreignKey) {
attrs[def.localField][def.foreignKey] = attrs[definition.idAttribute];
}
} catch (err) {
DS.$log.error(errorPrefix(definition.name) + 'Failed to inject ' + def.type + ' relation: "' + relationName + '"!', err);
}
}
}
}
});
definition.beforeInject(definition.name, attrs);

@@ -140,4 +161,4 @@ var id = attrs[idA];

DS.utils.deepMixIn(item, attrs);
DS.utils.deepMixIn(resource.previousAttributes[id], attrs);
DSUtils.deepMixIn(item, attrs);
DSUtils.deepMixIn(resource.previousAttributes[id], attrs);

@@ -152,14 +173,10 @@ resource.collection.push(item);

_react.call(item, {}, {}, {}, null, true);
if (definition.relations) {
_injectRelations.call(DS, definition, item, options);
}
} else {
DS.utils.deepMixIn(item, attrs);
DSUtils.deepMixIn(item, attrs);
if (definition.resetHistoryOnInject) {
resource.previousAttributes[id] = {};
DS.utils.deepMixIn(resource.previousAttributes[id], attrs);
DSUtils.deepMixIn(resource.previousAttributes[id], attrs);
if (resource.changeHistories[id].length) {
DS.utils.forEach(resource.changeHistories[id], function (changeRecord) {
DS.utils.remove(resource.changeHistory, changeRecord);
DSUtils.forEach(resource.changeHistories[id], function (changeRecord) {
DSUtils.remove(resource.changeHistory, changeRecord);
});

@@ -176,4 +193,5 @@ resource.changeHistories[id].splice(0, resource.changeHistories[id].length);

}
resource.saved[id] = DS.utils.updateTimestamp(resource.saved[id]);
resource.modified[id] = initialLastModified && resource.modified[id] === initialLastModified ? DS.utils.updateTimestamp(resource.modified[id]) : resource.modified[id];
resource.saved[id] = DSUtils.updateTimestamp(resource.saved[id]);
resource.modified[id] = initialLastModified && resource.modified[id] === initialLastModified ? DSUtils.updateTimestamp(resource.modified[id]) : resource.modified[id];
definition.afterInject(definition.name, item);

@@ -259,2 +277,3 @@ injected = item;

function inject(resourceName, attrs, options) {
console.log('inject', resourceName, attrs);
var DS = this;

@@ -292,3 +311,5 @@ var IA = DS.errors.IA;

if (options.linkInverse) {
console.log(options);
if (options.linkInverse && typeof options.linkInverse === 'boolean') {
console.log('linkInverse', typeof options.linkInverse, options.linkInverse);
if (DS.utils.isArray(injected)) {

@@ -303,2 +324,4 @@ if (injected.length) {

console.log(injected);
if (DS.utils.isArray(injected)) {

@@ -316,3 +339,2 @@ DS.utils.forEach(injected, function (injectedI) {

return injected;

@@ -319,0 +341,0 @@ }

@@ -71,2 +71,3 @@ function errorPrefix(resourceName) {

function link(resourceName, id, relations) {
console.log('link', resourceName, id);
var DS = this;

@@ -98,2 +99,4 @@ var IA = DS.errors.IA;

console.log('linked', linked);
return linked;

@@ -100,0 +103,0 @@ }

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

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

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