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.3 to 1.5.1

19

CHANGELOG.md

@@ -0,1 +1,17 @@

##### 1.5.1 - 02 December 2014
###### Backwards compatible API changes
- #259 - Added the "contains", "notContains", "|contains", and "|notContains" operators
###### Backwards compatible bug fixes
- #258 - No changes detected on nested fields
##### 1.5.0 - 01 December 2014
###### Backwards compatible API changes
- Added DSHttpAdapter.getPath and DSLocalStorageAdapter.getPath
###### Backwards compatible bug fixes
- Removed console.logs left over from a previous commit
##### 1.4.3 - 30 November 2014

@@ -6,5 +22,2 @@

###### Backwards compatible bug fixes
- Fixed "allowSimpleWhere" default not being set
##### 1.4.2 - 18 November 2014

@@ -11,0 +24,0 @@

4

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

@@ -50,4 +50,4 @@ "repository": {

"dependencies": {
"mout": "0.10.0"
"mout": "0.11.0"
}
}

@@ -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.3](https://github.com/jmdobry/angular-data/releases/tag/1.4.3)
__Latest Release:__ [1.5.1](https://github.com/jmdobry/angular-data/releases/tag/1.5.1)

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

@@ -73,2 +73,32 @@ /**

/**
* @doc method
* @id DSHttpAdapter.methods:getPath
* @name getPath
* @description
* Return the path that would be used by this adapter for a given operation.
*
* ## Signature:
* ```js
* DSHttpAdapter.getPath(method, resourceConfig, id|attrs|params, options))
* ```
*
* @param {string} method The name of the method .
* @param {object} resourceConfig The object returned by DS.defineResource.
* @param {string|object} id|attrs|params The id, attrs, or params that you would pass into the method.
* @param {object} options Configuration options.
* @returns {string} The path.
*/
function getPath(method, resourceConfig, id, options) {
options = options || {};
var args = [
options.baseUrl || resourceConfig.baseUrl,
resourceConfig.getEndpoint((DSUtils.isString(id) || DSUtils.isNumber(id) || method === 'create') ? id : null, options)
];
if (method === 'find' || method === 'update' || method === 'destroy') {
args.push(id);
}
return DSUtils.makePath.apply(DSUtils, args);
}
/**
* @doc interface

@@ -91,2 +121,4 @@ * @id DSHttpAdapter

getPath: getPath,
/**

@@ -255,3 +287,3 @@ * @doc method

return this.GET(
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id),
getPath('find', resourceConfig, id, options),
options

@@ -293,3 +325,3 @@ );

return this.GET(
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(null, options)),
getPath('findAll', resourceConfig, params, options),
options

@@ -326,3 +358,3 @@ );

return this.POST(
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(attrs, options)),
getPath('create', resourceConfig, attrs, options),
attrs,

@@ -361,3 +393,3 @@ options

return this.PUT(
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id),
getPath('update', resourceConfig, id, options),
attrs,

@@ -401,3 +433,3 @@ options

return this.PUT(
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(null, options)),
getPath('updateAll', resourceConfig, attrs, options),
attrs,

@@ -435,3 +467,3 @@ options

return this.DEL(
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id),
getPath('destroy', resourceConfig, id, options),
options

@@ -473,3 +505,3 @@ );

return this.DEL(
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(null, options)),
getPath('destroyAll', resourceConfig, params, options),
options

@@ -476,0 +508,0 @@ );

@@ -11,2 +11,32 @@ /*!

/**
* @doc method
* @id DSLocalStorageAdapter.methods:getPath
* @name getPath
* @description
* Return the path that would be used by this adapter for a given operation.
*
* ## Signature:
* ```js
* DSLocalStorageAdapter.getPath(method, resourceConfig, id|attrs|params, options))
* ```
*
* @param {string} method The name of the method .
* @param {object} resourceConfig The object returned by DS.defineResource.
* @param {string|object} id|attrs|params The id, attrs, or params that you would pass into the method.
* @param {object} options Configuration options.
* @returns {string} The path.
*/
function getPath(method, resourceConfig, id, options) {
options = options || {};
var args = [
options.baseUrl || resourceConfig.baseUrl,
resourceConfig.getEndpoint((DSUtils.isString(id) || DSUtils.isNumber(id) || method === 'create') ? id : null, options)
];
if (method === 'find' || method === 'update' || method === 'destroy') {
args.push(id);
}
return DSUtils.makePath.apply(DSUtils, args);
}
/**
* @doc interface

@@ -161,3 +191,3 @@ * @id DSLocalStorageAdapter

options = options || {};
return this.GET(DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint, id)).then(function (item) {
return this.GET(getPath('find', resourceConfig, id, options)).then(function (item) {
if (!item) {

@@ -201,3 +231,3 @@ return $q.reject(new Error('Not Found!'));

DSUtils.forEach(ids, function (id) {
var itemJson = localStorage.getItem(DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id));
var itemJson = localStorage.getItem(getPath('find', resourceConfig, id, options));
if (itemJson) {

@@ -245,11 +275,15 @@ items.push(DSUtils.fromJson(itemJson));

var _this = this;
attrs[resourceConfig.idAttribute] = attrs[resourceConfig.idAttribute] || DSUtils.guid();
var id = attrs[resourceConfig.idAttribute];
options = options || {};
return this.PUT(
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(attrs, options), attrs[resourceConfig.idAttribute]),
attrs
).then(function (item) {
_this.ensureId(item[resourceConfig.idAttribute], resourceConfig.name, options);
return item;
});
return _this.GET(getPath('find', resourceConfig, id, options)).then(function (item) {
if (item) {
DSUtils.deepMixIn(item, attrs);
} else {
attrs[resourceConfig.idAttribute] = id = id || DSUtils.guid();
}
return _this.PUT(getPath('update', resourceConfig, id, options), item || attrs);
}).then(function (item) {
_this.ensureId(item[resourceConfig.idAttribute], resourceConfig.name, options);
return item;
});
},

@@ -292,5 +326,9 @@

var _this = this;
return _this.find(resourceConfig, id, options).then(function (item) {
return _this.GET(getPath('find', resourceConfig, id, options)).then(function (item) {
item = item || {};
DSUtils.deepMixIn(item, attrs);
return _this.PUT(DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id), item);
return _this.PUT(getPath('update', resourceConfig, id, options), item);
}).then(function (item) {
_this.ensureId(item[resourceConfig.idAttribute], resourceConfig.name, options);
return item;
});

@@ -364,3 +402,3 @@ },

options = options || {};
return this.DEL(DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id));
return this.DEL(getPath('destroy', resourceConfig, id, options));
},

@@ -367,0 +405,0 @@

@@ -99,60 +99,51 @@ var observe = require('../../lib/observe-js/observe-js');

if (DSUtils.isObject(clause)) {
DSUtils.forEach(clause, function (val, op) {
DSUtils.forEach(clause, function (term, op) {
var expr;
var isOr = op[0] === '|';
var val = attrs[field];
op = isOr ? op.substr(1) : op;
if (op === '==') {
keep = first ? (attrs[field] == val) : keep && (attrs[field] == val);
expr = val == term;
} else if (op === '===') {
keep = first ? (attrs[field] === val) : keep && (attrs[field] === val);
expr = val === term;
} else if (op === '!=') {
keep = first ? (attrs[field] != val) : keep && (attrs[field] != val);
expr = val != term;
} else if (op === '!==') {
keep = first ? (attrs[field] !== val) : keep && (attrs[field] !== val);
expr = val !== term;
} else if (op === '>') {
keep = first ? (attrs[field] > val) : keep && (attrs[field] > val);
expr = val > term;
} else if (op === '>=') {
keep = first ? (attrs[field] >= val) : keep && (attrs[field] >= val);
expr = val >= term;
} else if (op === '<') {
keep = first ? (attrs[field] < val) : keep && (attrs[field] < val);
expr = val < term;
} else if (op === '<=') {
keep = first ? (attrs[field] <= val) : keep && (attrs[field] <= val);
expr = val <= term;
} else if (op === 'in') {
if (DSUtils.isString(val)) {
keep = first ? val.indexOf(attrs[field]) !== -1 : keep && val.indexOf(attrs[field]) !== -1;
if (DSUtils.isString(term)) {
expr = term.indexOf(val) !== -1;
} else {
keep = first ? DSUtils.contains(val, attrs[field]) : keep && DSUtils.contains(val, attrs[field]);
expr = DSUtils.contains(term, val);
}
} else if (op === 'notIn') {
if (DSUtils.isString(val)) {
keep = first ? val.indexOf(attrs[field]) === -1 : keep && val.indexOf(attrs[field]) === -1;
if (DSUtils.isString(term)) {
expr = term.indexOf(val) === -1;
} else {
keep = first ? !DSUtils.contains(val, attrs[field]) : keep && !DSUtils.contains(val, attrs[field]);
expr = !DSUtils.contains(term, val);
}
} else if (op === '|==') {
keep = first ? (attrs[field] == val) : keep || (attrs[field] == val);
} else if (op === '|===') {
keep = first ? (attrs[field] === val) : keep || (attrs[field] === val);
} else if (op === '|!=') {
keep = first ? (attrs[field] != val) : keep || (attrs[field] != val);
} else if (op === '|!==') {
keep = first ? (attrs[field] !== val) : keep || (attrs[field] !== val);
} else if (op === '|>') {
keep = first ? (attrs[field] > val) : keep || (attrs[field] > val);
} else if (op === '|>=') {
keep = first ? (attrs[field] >= val) : keep || (attrs[field] >= val);
} else if (op === '|<') {
keep = first ? (attrs[field] < val) : keep || (attrs[field] < val);
} else if (op === '|<=') {
keep = first ? (attrs[field] <= val) : keep || (attrs[field] <= val);
} else if (op === '|in') {
if (DSUtils.isString(val)) {
keep = first ? val.indexOf(attrs[field]) !== -1 : keep || val.indexOf(attrs[field]) !== -1;
} else if (op === 'contains') {
if (DSUtils.isString(term)) {
expr = (val || '').indexOf(term) !== -1;
} else {
keep = first ? DSUtils.contains(val, attrs[field]) : keep || DSUtils.contains(val, attrs[field]);
expr = DSUtils.contains(val, term);
}
} else if (op === '|notIn') {
if (DSUtils.isString(val)) {
keep = first ? val.indexOf(attrs[field]) === -1 : keep || val.indexOf(attrs[field]) === -1;
} else if (op === 'notContains') {
if (DSUtils.isString(term)) {
expr = (val || '').indexOf(term) === -1;
} else {
keep = first ? !DSUtils.contains(val, attrs[field]) : keep || !DSUtils.contains(val, attrs[field]);
expr = !DSUtils.contains(val, term);
}
}
if (expr !== undefined) {
keep = first ? expr : (isOr ? keep || expr : keep && expr);
}
first = false;

@@ -159,0 +150,0 @@ });

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

}
resource.previousAttributes[id] = {};
resource.previousAttributes[id] = angular.copy(attrs);
DSUtils.deepMixIn(item, attrs);
DSUtils.deepMixIn(resource.previousAttributes[id], attrs);

@@ -268,3 +267,2 @@ resource.collection.push(item);

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

@@ -302,5 +300,3 @@ var IA = DS.errors.IA;

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

@@ -315,4 +311,2 @@ if (injected.length) {

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

@@ -319,0 +313,0 @@ DS.utils.forEach(injected, function (injectedI) {

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

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

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

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

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

@@ -61,2 +61,3 @@ var DSErrors = require('./errors');

var isRegExp = require('mout/lang/isRegExp');
var deepEquals = angular.equals;

@@ -91,2 +92,3 @@ function isBlacklisted(prop, blacklist) {

deepMixIn: require('mout/object/deepMixIn'),
deepEquals: deepEquals,
mixIn: require('mout/object/mixIn'),

@@ -105,2 +107,3 @@ forEach: angular.forEach,

guid: require('mout/random/guid'),
copy: angular.copy,
keys: require('mout/object/keys'),

@@ -180,3 +183,3 @@ _: function (parent, options) {

if (newValue !== undefined && newValue === oldObject[prop]) {
if (newValue !== undefined && deepEquals(newValue, oldObject[prop])) {
continue;

@@ -190,3 +193,3 @@ }

if (newValue !== oldObject[prop]) {
if (!deepEquals(newValue, oldObject[prop])) {
changed[prop] = newValue;

@@ -193,0 +196,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