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

absync

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absync - npm Package Compare versions

Comparing version 2.7.1 to 2.7.2

6

dist/development/absync.concat.js

@@ -537,3 +537,3 @@ (function() {

self.httpInterface
.get( configuration.allowBrowserCache.sync ? configuration.entityUri : self.__uncached(
.get( self.allowBrowserCache.sync ? configuration.entityUri : self.__uncached(
configuration.entityUri ) )

@@ -551,3 +551,3 @@ .then( onSingleEntityReceived, onSingleEntityRetrievalFailure );

self.httpInterface
.get( configuration.allowBrowserCache.sync ? configuration.collectionUri : self.__uncached(
.get( self.allowBrowserCache.sync ? configuration.collectionUri : self.__uncached(
configuration.collectionUri ) )

@@ -709,3 +709,3 @@ .then( onCollectionReceived, onCollectionRetrievalFailure );

var request = self.httpInterface
.get( configuration.allowBrowserCache.request ? requestUri : self.__uncached( requestUri ) )
.get( self.allowBrowserCache.request ? requestUri : self.__uncached( requestUri ) )
.then( remoteRequestFromCache.bind( self, id ) );

@@ -712,0 +712,0 @@

@@ -267,3 +267,3 @@ (function() {

self.httpInterface
.get( configuration.allowBrowserCache.sync ? configuration.entityUri : self.__uncached(
.get( self.allowBrowserCache.sync ? configuration.entityUri : self.__uncached(
configuration.entityUri ) )

@@ -281,3 +281,3 @@ .then( onSingleEntityReceived, onSingleEntityRetrievalFailure );

self.httpInterface
.get( configuration.allowBrowserCache.sync ? configuration.collectionUri : self.__uncached(
.get( self.allowBrowserCache.sync ? configuration.collectionUri : self.__uncached(
configuration.collectionUri ) )

@@ -439,3 +439,3 @@ .then( onCollectionReceived, onCollectionRetrievalFailure );

var request = self.httpInterface
.get( configuration.allowBrowserCache.request ? requestUri : self.__uncached( requestUri ) )
.get( self.allowBrowserCache.request ? requestUri : self.__uncached( requestUri ) )
.then( remoteRequestFromCache.bind( self, id ) );

@@ -442,0 +442,0 @@

@@ -1,2 +0,2 @@

!function(){"use strict";angular.module("absync",[])}(),function(){"use strict";function e(e,r){return new t(e,r)}function t(e,t){var r=this;r.__provide=e,r.__absyncCache=t,r.__ioSocket=null,r.__registerLater=[],r.__collections={},r.__entities={}}function r(e){this.__absyncProvider=e}angular.module("absync").provider("absync",e),e.$inject=["$provide","absyncCache"],t.prototype.configure=function(e,t){var r=this,n=e.socket||e,i=io&&io.Socket&&n instanceof io.Socket;if("function"==typeof n)r.__ioSocket=n();else{if(!i)throw new Error("configure() expects input to be a function or a socket.io Socket instance.");r.__ioSocket=n}r.__registerLater.length&&(r.__registerLater.forEach(r.__registerListener.bind(r)),r.__registerLater=[]),r.debug=t||!1},t.prototype.__registerListener=function(e){var t=this;t.$get().__handleEntityEvent(e.eventName,e.callback)},t.prototype.collection=function(e,t){var r=this;if(r.__collections[e])throw new Error("A collection with the name '"+e+"' was already requested. Names for collections must be unique.");if(r.__entities[e])throw new Error("An entity with the name '"+e+"' was already requested. Names for collections must be unique and can't be shared with entities.");t.debug="undefined"==typeof t.debug?r.debug:t.debug,r.__collections[e]=r.__absyncCache(e,t),r.__provide.service(e,r.__collections[e])},t.prototype.entity=function(e,t){var r=this;if(r.__entities[e])throw new Error("An entity with the name '"+e+"' was already requested. Names for entities must be unique.");if(r.__collections[e])throw new Error("A collection with the name '"+e+"' was already requested. Names for entities must be unique and can't be shared with collections.");t.debug="undefined"==typeof t.debug?r.debug:t.debug,r.__entities[e]=r.__absyncCache(e,t),r.__provide.service(e,r.__entities[e])},t.prototype.$get=function(){return new r(this)},r.prototype.configure=function(e,t){var r=this.__absyncProvider;r.configure(e,t||!1)},r.prototype.on=function(e,t){var r=this.__absyncProvider,n=this;return r.__ioSocket?n.__handleEntityEvent(e,t):r.__registerLater.length>8192?null:(r.__registerLater.push({eventName:e,callback:t}),null)},r.prototype.__handleEntityEvent=function(e,t){var r=this.__absyncProvider;return r.__ioSocket.on(e,t),function(){r.__ioSocket.removeListener(e,t)}},r.prototype.emit=function(e,t,r){var n=this.__absyncProvider;if(!n.__ioSocket)throw new Error("socket.io is not initialized.");n.__ioSocket.emit(e,t,function(){r&&r.apply(n.__ioSocket,arguments)})}}(),function(){"use strict";function e(e,r){function n(n,i,o,a,c,s,l,h){var d=this,u=r.injector||i,y=u.has(r.model);if(!y)throw new Error("Unable to construct the '"+e+"' service, because the referenced model '"+r.model+"' is not available for injection.");var f="string"==typeof r.model?u.get(r.model):r.model,_=f.serialize||r.serialize||t,p=f.deserialize||r.deserialize||t;d.name=e,d.configuration=r,d.entityCache=r.collectionName?[]:{},d.__entityCacheRaw=null,d.enableRequestCache=!0,d.__requestCache={},d.allowBrowserCache=angular.merge({},{sync:!0,request:!0},r.allowBrowserCache),d.__uncached=h,d.__dataAvailableDeferred=a.defer(),d.__objectsAvailableDeferred=a.defer(),d.dataAvailable=d.__dataAvailableDeferred.promise,d.objectsAvailable=d.__objectsAvailableDeferred.promise,d.httpInterface=n,d.logInterface=r.debug?o:l,d.scope=c,d.q=a,d.logPrefix="absync:"+e.toLocaleUpperCase()+" ",d.forceEarlyCacheUpdate=!1,d.throwFailures=!1,d.serializer=_,d.deserializer=p,s.on(r.entityName,d.__onEntityOnWebsocket.bind(d)),r.collectionName&&s.on(r.collectionName,d.__onCollectionOnWebsocket.bind(d)),c.$on(r.entityName,d.__onEntityReceived.bind(d)),r.collectionName&&c.$on(r.collectionName,d.__onCollectionReceived.bind(d)),d.dataAvailable.then(d.__onDataAvailable.bind(d)),d.logInterface.info(d.logPrefix+"service was instantiated.")}function i(e){var t=this;if(e.data[r.entityName]){var n=t.deserializer(e.data[r.entityName]);return t.forceEarlyCacheUpdate&&t.__updateCacheWithEntity(n),n}throw new Error("The response from the server was not in the expected format. It should have a member named '"+r.entityName+"'.")}function o(e){var t=this;if(t.logInterface.error(t.logPrefix+"Unable to store entity on the server.",e),t.logInterface.error(e),t.scope.$emit("absyncError",e),t.throwFailures)throw e}return n.$inject=["$http","$injector","$log","$q","$rootScope","absync","absyncNoopLog","absyncUncachedFilter"],n.prototype.__onEntityOnWebsocket=function(e){var t=this;t.scope.$broadcast(r.entityName,e[r.entityName])},n.prototype.__onCollectionOnWebsocket=function(e){var t=this;t.scope.$broadcast(r.collectionName,e[r.collectionName])},n.prototype.__onDataAvailable=function(e){function t(e){n.entityCache.push(n.deserializer(e))}var n=this;if(Array.isArray(n.entityCache))e[r.collectionName].forEach(t),n.__objectsAvailableDeferred.resolve(n.entityCache),n.scope.$broadcast("collectionNew",{service:n,cache:n.entityCache});else{var i=n.deserializer(e[r.entityName]);n.__updateCacheWithEntity(i),n.__objectsAvailableDeferred.resolve(n.entityCache)}},n.prototype.__onEntityReceived=function(e,t){var r=this,n=t;1===Object.keys(n).length&&n.hasOwnProperty("id")?(r.logInterface.info(r.logPrefix+"Entity was deleted from the server. Updating cache…"),r.__removeEntityFromCache(n.id)):(r.logInterface.debug(r.logPrefix+"Entity was updated on the server. Updating cache…"),r.__updateCacheWithEntity(r.deserializer(n)))},n.prototype.__onCollectionReceived=function(e,t){function r(e){var t=n.deserializer(e);n.__updateCacheWithEntity(t)}var n=this,i=t;n.entityCache.length=0,i.forEach(r)},n.prototype.ensureLoaded=function(e){function t(e){if(!e.data[r.collectionName])throw new Error("The response from the server was not in the expected format. It should have a member named '"+r.collectionName+"'.");a.__entityCacheRaw=e.data,a.__dataAvailableDeferred.resolve(e.data)}function n(e){a.logInterface.error(a.logPrefix+"Unable to retrieve the collection from the server.",e),a.__entityCacheRaw=null,a.scope.$emit("absyncError",e),a.__dataAvailableDeferred.reject(e)}function i(e){if(!e.data[r.entityName])throw new Error("The response from the server was not in the expected format. It should have a member named '"+r.entityName+"'.");a.__entityCacheRaw=e.data,a.__dataAvailableDeferred.resolve(e.data)}function o(e){a.logInterface.error(a.logPrefix+"Unable to retrieve the entity from the server.",e),a.__entityCacheRaw=null,a.scope.$emit("absyncError",e),a.__dataAvailableDeferred.reject(e)}var a=this;if(e=e===!0,null===a.__entityCacheRaw||e)if(a.__entityCacheRaw=[],r.collectionName&&r.collectionUri)a.logInterface.info(a.logPrefix+"Retrieving '"+r.collectionName+"' collection…"),a.httpInterface.get(r.allowBrowserCache.sync?r.collectionUri:a.__uncached(r.collectionUri)).then(t,n);else{if(!r.entityName||!r.entityUri)return a.q.when([]);a.__entityCacheRaw={},a.httpInterface.get(r.allowBrowserCache.sync?r.entityUri:a.__uncached(r.entityUri)).then(i,o)}return a.q.all([a.dataAvailable,a.objectsAvailable]).then(function(){return a.entityCache})},n.prototype.sync=function(){var e=this;return e.ensureLoaded(!0)},n.prototype.read=function(e,t){function n(e){if(!e.data[r.entityName])throw new Error("The response from the server was not in the expected format. It should have a member named '"+r.entityName+"'.");var t=o.deserializer(e.data[r.entityName]);return o.__updateCacheWithEntity(t),t}function i(t){if(o.logInterface.error(o.logPrefix+"Unable to retrieve entity with ID '"+e+"' from the server.",t),o.scope.$emit("absyncError",t),o.throwFailures)throw t}var o=this;if(t=t===!0,o.logInterface.debug(o.logPrefix+"Requesting entity '"+e+"' (forceReload:"+t+")…"),!t)for(var a=0,c=o.entityCache[0];a<o.entityCache.length;++a,c=o.entityCache[a])if(c.id===e)return o.logInterface.debug(o.logPrefix+"Requested entity '"+e+"' is served from cache."),o.q.when(c);return o.logInterface.debug(o.logPrefix+"Requested entity '"+e+"' is fetched from backend."),o.__requestEntity(e).then(n,i)},n.prototype.__requestEntity=function(e){function t(e,t){return delete n.__requestCache[e],t}var n=this;if(n.enableRequestCache&&n.__requestCache&&n.__requestCache[e])return n.logInterface.debug(n.logPrefix+"Entity request '"+e+"' served from request cache."),n.__requestCache[e];var i=r.entityUri+(e?"/"+e:""),o=n.httpInterface.get(r.allowBrowserCache.request?i:n.__uncached(i)).then(t.bind(n,e));return n.enableRequestCache&&n.__requestCache&&(n.__requestCache[e]=o),o},n.prototype.update=function(e){var t=this,n=t.reduceComplex(e),a=t.serializer(n),c={};return c[r.entityName]=a,"undefined"!=typeof e.id?t.httpInterface.put(r.entityUri+"/"+e.id,c).then(i.bind(t),o.bind(t)):t.httpInterface.post(r.collectionUri,c).then(i.bind(t),o.bind(t))},n.prototype.patch=function(e){var t=this,n=t.reduceComplex(e),a=t.serializer(n),c={};if(c[r.entityName]=a,"undefined"!=typeof e.id)return t.httpInterface.patch(r.entityUri+"/"+e.id,c).then(i.bind(t),o.bind(t));throw new Error("Attempted to patch an entity that was never stored on the server.")},n.prototype.create=n.prototype.update,n.prototype["delete"]=function(e){function t(e){return i.__removeEntityFromCache(o)}function n(e){if(i.logInterface.error(e.data),i.scope.$emit("absyncError",e),i.throwFailures)throw e}var i=this,o=e.id;return i.httpInterface["delete"](r.entityUri+"/"+o).then(t)["catch"](n)},n.prototype.__updateCacheWithEntity=function(e){var t=this;if(t.logInterface.info(t.logPrefix+"Updating entity '"+(e.id||t.name)+"' in cache…",e),!Array.isArray(t.entityCache))return t.scope.$broadcast("beforeEntityUpdated",{service:t,cache:t.entityCache,entity:t.entityCache,updated:e}),"function"==typeof t.entityCache.copyFrom?t.entityCache.copyFrom(e):angular.extend(t.entityCache,e),void t.scope.$broadcast("entityUpdated",{service:t,cache:t.entityCache,entity:t.entityCache});for(var r=!1,n=0,i=t.entityCache[0];n<t.entityCache.length;++n,i=t.entityCache[n])if(i.id==e.id){t.scope.$broadcast("beforeEntityUpdated",{service:t,cache:t.entityCache,entity:t.entityCache[n],updated:e});var o=t.entityCache[n];"function"==typeof o.copyFrom?o.copyFrom(e):angular.extend(o,e),r=!0,t.scope.$broadcast("entityUpdated",{service:t,cache:t.entityCache,entity:t.entityCache[n]});break}r||(t.scope.$broadcast("beforeEntityNew",{service:t,cache:t.entityCache,entity:e}),t.entityCache.push(e),t.scope.$broadcast("entityNew",{service:t,cache:t.entityCache,entity:e}))},n.prototype.__removeEntityFromCache=function(e){for(var t=this,r=0,n=t.entityCache[0];r<t.entityCache.length;++r,n=t.entityCache[r])if(n.id==e){t.scope.$broadcast("beforeEntityRemoved",{service:t,cache:t.entityCache,entity:n}),t.entityCache.splice(r,1),t.scope.$broadcast("entityRemoved",{service:t,cache:t.entityCache,entity:n});break}},n.prototype.lookupTableById=function(){for(var e=this,t=[],r=0;r<e.entityCache.length;++r)t[e.entityCache[r].id]=e.entityCache[r];return t},n.prototype.reduceComplex=function(e,t){var r=this,n=t?[]:{};for(var i in e)e.hasOwnProperty(i)&&(Array.isArray(e[i])?n[i]=r.reduceComplex(e[i],!0):e[i]&&e[i].id?n[i]=e[i].id:n[i]=e[i]);return n},n.prototype.populateComplex=function(e,t,r,n){function i(i,o){function c(r){return e[t][o]=r,e}if("string"!=typeof e[t][o]){if(!n||"object"!=typeof e[t][o]||"string"!=typeof e[t][o].id)return a.q.when(!1);e[t][o]=e[t][o].id}return r.read(e[t][o]).then(c)}function o(r){e[t]=r}var a=this;if(Array.isArray(e[t])){var c=e[t].map(i);return a.q.all(c)}if("string"!=typeof e[t]){if(!n||"object"!=typeof e[t]||"string"!=typeof e[t].id)return a.q.when(!1);e[t]=e[t].id}return r.read(e[t]).then(o)},n}function t(e){return e}angular.module("absync").constant("absyncCache",e)}(),function(){"use strict";function e(){return t}function t(e,t,r,n,i,o,a,c,s,l){this.model=e,this.collectionUri=t,this.entityUri=r;var h=e.prototype.constructor.name.toLowerCase();this.collectionName=n||h+"s",this.entityName=i||h,this.deserialize=o||void 0,this.serialize=a||void 0,this.injector=c||void 0,this.debug=s||!1,this.allowBrowserCache=angular.merge({},{sync:!0,request:!0},l)}angular.module("absync").service("AbsyncServiceConfiguration",e)}(),function(){"use strict";angular.module("absync").constant("absyncNoopLog",{debug:angular.noop,info:angular.noop,error:angular.noop})}(),function(){"use strict";function e(){function e(e){if(!e)return e;var t=-1<e.indexOf("?")?"&":"?",r=(new Date).getTime();return e+t+"t"+r}return e}angular.module("absync").filter("absyncUncached",e)}();
!function(){"use strict";angular.module("absync",[])}(),function(){"use strict";function e(e,r){return new t(e,r)}function t(e,t){var r=this;r.__provide=e,r.__absyncCache=t,r.__ioSocket=null,r.__registerLater=[],r.__collections={},r.__entities={}}function r(e){this.__absyncProvider=e}angular.module("absync").provider("absync",e),e.$inject=["$provide","absyncCache"],t.prototype.configure=function(e,t){var r=this,n=e.socket||e,i=io&&io.Socket&&n instanceof io.Socket;if("function"==typeof n)r.__ioSocket=n();else{if(!i)throw new Error("configure() expects input to be a function or a socket.io Socket instance.");r.__ioSocket=n}r.__registerLater.length&&(r.__registerLater.forEach(r.__registerListener.bind(r)),r.__registerLater=[]),r.debug=t||!1},t.prototype.__registerListener=function(e){var t=this;t.$get().__handleEntityEvent(e.eventName,e.callback)},t.prototype.collection=function(e,t){var r=this;if(r.__collections[e])throw new Error("A collection with the name '"+e+"' was already requested. Names for collections must be unique.");if(r.__entities[e])throw new Error("An entity with the name '"+e+"' was already requested. Names for collections must be unique and can't be shared with entities.");t.debug="undefined"==typeof t.debug?r.debug:t.debug,r.__collections[e]=r.__absyncCache(e,t),r.__provide.service(e,r.__collections[e])},t.prototype.entity=function(e,t){var r=this;if(r.__entities[e])throw new Error("An entity with the name '"+e+"' was already requested. Names for entities must be unique.");if(r.__collections[e])throw new Error("A collection with the name '"+e+"' was already requested. Names for entities must be unique and can't be shared with collections.");t.debug="undefined"==typeof t.debug?r.debug:t.debug,r.__entities[e]=r.__absyncCache(e,t),r.__provide.service(e,r.__entities[e])},t.prototype.$get=function(){return new r(this)},r.prototype.configure=function(e,t){var r=this.__absyncProvider;r.configure(e,t||!1)},r.prototype.on=function(e,t){var r=this.__absyncProvider,n=this;return r.__ioSocket?n.__handleEntityEvent(e,t):r.__registerLater.length>8192?null:(r.__registerLater.push({eventName:e,callback:t}),null)},r.prototype.__handleEntityEvent=function(e,t){var r=this.__absyncProvider;return r.__ioSocket.on(e,t),function(){r.__ioSocket.removeListener(e,t)}},r.prototype.emit=function(e,t,r){var n=this.__absyncProvider;if(!n.__ioSocket)throw new Error("socket.io is not initialized.");n.__ioSocket.emit(e,t,function(){r&&r.apply(n.__ioSocket,arguments)})}}(),function(){"use strict";function e(e,r){function n(n,i,o,a,c,s,l,h){var d=this,u=r.injector||i,y=u.has(r.model);if(!y)throw new Error("Unable to construct the '"+e+"' service, because the referenced model '"+r.model+"' is not available for injection.");var f="string"==typeof r.model?u.get(r.model):r.model,_=f.serialize||r.serialize||t,p=f.deserialize||r.deserialize||t;d.name=e,d.configuration=r,d.entityCache=r.collectionName?[]:{},d.__entityCacheRaw=null,d.enableRequestCache=!0,d.__requestCache={},d.allowBrowserCache=angular.merge({},{sync:!0,request:!0},r.allowBrowserCache),d.__uncached=h,d.__dataAvailableDeferred=a.defer(),d.__objectsAvailableDeferred=a.defer(),d.dataAvailable=d.__dataAvailableDeferred.promise,d.objectsAvailable=d.__objectsAvailableDeferred.promise,d.httpInterface=n,d.logInterface=r.debug?o:l,d.scope=c,d.q=a,d.logPrefix="absync:"+e.toLocaleUpperCase()+" ",d.forceEarlyCacheUpdate=!1,d.throwFailures=!1,d.serializer=_,d.deserializer=p,s.on(r.entityName,d.__onEntityOnWebsocket.bind(d)),r.collectionName&&s.on(r.collectionName,d.__onCollectionOnWebsocket.bind(d)),c.$on(r.entityName,d.__onEntityReceived.bind(d)),r.collectionName&&c.$on(r.collectionName,d.__onCollectionReceived.bind(d)),d.dataAvailable.then(d.__onDataAvailable.bind(d)),d.logInterface.info(d.logPrefix+"service was instantiated.")}function i(e){var t=this;if(e.data[r.entityName]){var n=t.deserializer(e.data[r.entityName]);return t.forceEarlyCacheUpdate&&t.__updateCacheWithEntity(n),n}throw new Error("The response from the server was not in the expected format. It should have a member named '"+r.entityName+"'.")}function o(e){var t=this;if(t.logInterface.error(t.logPrefix+"Unable to store entity on the server.",e),t.logInterface.error(e),t.scope.$emit("absyncError",e),t.throwFailures)throw e}return n.$inject=["$http","$injector","$log","$q","$rootScope","absync","absyncNoopLog","absyncUncachedFilter"],n.prototype.__onEntityOnWebsocket=function(e){var t=this;t.scope.$broadcast(r.entityName,e[r.entityName])},n.prototype.__onCollectionOnWebsocket=function(e){var t=this;t.scope.$broadcast(r.collectionName,e[r.collectionName])},n.prototype.__onDataAvailable=function(e){function t(e){n.entityCache.push(n.deserializer(e))}var n=this;if(Array.isArray(n.entityCache))e[r.collectionName].forEach(t),n.__objectsAvailableDeferred.resolve(n.entityCache),n.scope.$broadcast("collectionNew",{service:n,cache:n.entityCache});else{var i=n.deserializer(e[r.entityName]);n.__updateCacheWithEntity(i),n.__objectsAvailableDeferred.resolve(n.entityCache)}},n.prototype.__onEntityReceived=function(e,t){var r=this,n=t;1===Object.keys(n).length&&n.hasOwnProperty("id")?(r.logInterface.info(r.logPrefix+"Entity was deleted from the server. Updating cache…"),r.__removeEntityFromCache(n.id)):(r.logInterface.debug(r.logPrefix+"Entity was updated on the server. Updating cache…"),r.__updateCacheWithEntity(r.deserializer(n)))},n.prototype.__onCollectionReceived=function(e,t){function r(e){var t=n.deserializer(e);n.__updateCacheWithEntity(t)}var n=this,i=t;n.entityCache.length=0,i.forEach(r)},n.prototype.ensureLoaded=function(e){function t(e){if(!e.data[r.collectionName])throw new Error("The response from the server was not in the expected format. It should have a member named '"+r.collectionName+"'.");a.__entityCacheRaw=e.data,a.__dataAvailableDeferred.resolve(e.data)}function n(e){a.logInterface.error(a.logPrefix+"Unable to retrieve the collection from the server.",e),a.__entityCacheRaw=null,a.scope.$emit("absyncError",e),a.__dataAvailableDeferred.reject(e)}function i(e){if(!e.data[r.entityName])throw new Error("The response from the server was not in the expected format. It should have a member named '"+r.entityName+"'.");a.__entityCacheRaw=e.data,a.__dataAvailableDeferred.resolve(e.data)}function o(e){a.logInterface.error(a.logPrefix+"Unable to retrieve the entity from the server.",e),a.__entityCacheRaw=null,a.scope.$emit("absyncError",e),a.__dataAvailableDeferred.reject(e)}var a=this;if(e=e===!0,null===a.__entityCacheRaw||e)if(a.__entityCacheRaw=[],r.collectionName&&r.collectionUri)a.logInterface.info(a.logPrefix+"Retrieving '"+r.collectionName+"' collection…"),a.httpInterface.get(a.allowBrowserCache.sync?r.collectionUri:a.__uncached(r.collectionUri)).then(t,n);else{if(!r.entityName||!r.entityUri)return a.q.when([]);a.__entityCacheRaw={},a.httpInterface.get(a.allowBrowserCache.sync?r.entityUri:a.__uncached(r.entityUri)).then(i,o)}return a.q.all([a.dataAvailable,a.objectsAvailable]).then(function(){return a.entityCache})},n.prototype.sync=function(){var e=this;return e.ensureLoaded(!0)},n.prototype.read=function(e,t){function n(e){if(!e.data[r.entityName])throw new Error("The response from the server was not in the expected format. It should have a member named '"+r.entityName+"'.");var t=o.deserializer(e.data[r.entityName]);return o.__updateCacheWithEntity(t),t}function i(t){if(o.logInterface.error(o.logPrefix+"Unable to retrieve entity with ID '"+e+"' from the server.",t),o.scope.$emit("absyncError",t),o.throwFailures)throw t}var o=this;if(t=t===!0,o.logInterface.debug(o.logPrefix+"Requesting entity '"+e+"' (forceReload:"+t+")…"),!t)for(var a=0,c=o.entityCache[0];a<o.entityCache.length;++a,c=o.entityCache[a])if(c.id===e)return o.logInterface.debug(o.logPrefix+"Requested entity '"+e+"' is served from cache."),o.q.when(c);return o.logInterface.debug(o.logPrefix+"Requested entity '"+e+"' is fetched from backend."),o.__requestEntity(e).then(n,i)},n.prototype.__requestEntity=function(e){function t(e,t){return delete n.__requestCache[e],t}var n=this;if(n.enableRequestCache&&n.__requestCache&&n.__requestCache[e])return n.logInterface.debug(n.logPrefix+"Entity request '"+e+"' served from request cache."),n.__requestCache[e];var i=r.entityUri+(e?"/"+e:""),o=n.httpInterface.get(n.allowBrowserCache.request?i:n.__uncached(i)).then(t.bind(n,e));return n.enableRequestCache&&n.__requestCache&&(n.__requestCache[e]=o),o},n.prototype.update=function(e){var t=this,n=t.reduceComplex(e),a=t.serializer(n),c={};return c[r.entityName]=a,"undefined"!=typeof e.id?t.httpInterface.put(r.entityUri+"/"+e.id,c).then(i.bind(t),o.bind(t)):t.httpInterface.post(r.collectionUri,c).then(i.bind(t),o.bind(t))},n.prototype.patch=function(e){var t=this,n=t.reduceComplex(e),a=t.serializer(n),c={};if(c[r.entityName]=a,"undefined"!=typeof e.id)return t.httpInterface.patch(r.entityUri+"/"+e.id,c).then(i.bind(t),o.bind(t));throw new Error("Attempted to patch an entity that was never stored on the server.")},n.prototype.create=n.prototype.update,n.prototype["delete"]=function(e){function t(e){return i.__removeEntityFromCache(o)}function n(e){if(i.logInterface.error(e.data),i.scope.$emit("absyncError",e),i.throwFailures)throw e}var i=this,o=e.id;return i.httpInterface["delete"](r.entityUri+"/"+o).then(t)["catch"](n)},n.prototype.__updateCacheWithEntity=function(e){var t=this;if(t.logInterface.info(t.logPrefix+"Updating entity '"+(e.id||t.name)+"' in cache…",e),!Array.isArray(t.entityCache))return t.scope.$broadcast("beforeEntityUpdated",{service:t,cache:t.entityCache,entity:t.entityCache,updated:e}),"function"==typeof t.entityCache.copyFrom?t.entityCache.copyFrom(e):angular.extend(t.entityCache,e),void t.scope.$broadcast("entityUpdated",{service:t,cache:t.entityCache,entity:t.entityCache});for(var r=!1,n=0,i=t.entityCache[0];n<t.entityCache.length;++n,i=t.entityCache[n])if(i.id==e.id){t.scope.$broadcast("beforeEntityUpdated",{service:t,cache:t.entityCache,entity:t.entityCache[n],updated:e});var o=t.entityCache[n];"function"==typeof o.copyFrom?o.copyFrom(e):angular.extend(o,e),r=!0,t.scope.$broadcast("entityUpdated",{service:t,cache:t.entityCache,entity:t.entityCache[n]});break}r||(t.scope.$broadcast("beforeEntityNew",{service:t,cache:t.entityCache,entity:e}),t.entityCache.push(e),t.scope.$broadcast("entityNew",{service:t,cache:t.entityCache,entity:e}))},n.prototype.__removeEntityFromCache=function(e){for(var t=this,r=0,n=t.entityCache[0];r<t.entityCache.length;++r,n=t.entityCache[r])if(n.id==e){t.scope.$broadcast("beforeEntityRemoved",{service:t,cache:t.entityCache,entity:n}),t.entityCache.splice(r,1),t.scope.$broadcast("entityRemoved",{service:t,cache:t.entityCache,entity:n});break}},n.prototype.lookupTableById=function(){for(var e=this,t=[],r=0;r<e.entityCache.length;++r)t[e.entityCache[r].id]=e.entityCache[r];return t},n.prototype.reduceComplex=function(e,t){var r=this,n=t?[]:{};for(var i in e)e.hasOwnProperty(i)&&(Array.isArray(e[i])?n[i]=r.reduceComplex(e[i],!0):e[i]&&e[i].id?n[i]=e[i].id:n[i]=e[i]);return n},n.prototype.populateComplex=function(e,t,r,n){function i(i,o){function c(r){return e[t][o]=r,e}if("string"!=typeof e[t][o]){if(!n||"object"!=typeof e[t][o]||"string"!=typeof e[t][o].id)return a.q.when(!1);e[t][o]=e[t][o].id}return r.read(e[t][o]).then(c)}function o(r){e[t]=r}var a=this;if(Array.isArray(e[t])){var c=e[t].map(i);return a.q.all(c)}if("string"!=typeof e[t]){if(!n||"object"!=typeof e[t]||"string"!=typeof e[t].id)return a.q.when(!1);e[t]=e[t].id}return r.read(e[t]).then(o)},n}function t(e){return e}angular.module("absync").constant("absyncCache",e)}(),function(){"use strict";function e(){return t}function t(e,t,r,n,i,o,a,c,s,l){this.model=e,this.collectionUri=t,this.entityUri=r;var h=e.prototype.constructor.name.toLowerCase();this.collectionName=n||h+"s",this.entityName=i||h,this.deserialize=o||void 0,this.serialize=a||void 0,this.injector=c||void 0,this.debug=s||!1,this.allowBrowserCache=angular.merge({},{sync:!0,request:!0},l)}angular.module("absync").service("AbsyncServiceConfiguration",e)}(),function(){"use strict";angular.module("absync").constant("absyncNoopLog",{debug:angular.noop,info:angular.noop,error:angular.noop})}(),function(){"use strict";function e(){function e(e){if(!e)return e;var t=-1<e.indexOf("?")?"&":"?",r=(new Date).getTime();return e+t+"t"+r}return e}angular.module("absync").filter("absyncUncached",e)}();
//# sourceMappingURL=maps/absync.concat.min.js.map
{
"name": "absync",
"version": "2.7.1",
"version": "2.7.2",
"description": "absync",

@@ -5,0 +5,0 @@ "main": "dist/development/absync.concat.js",

@@ -264,3 +264,3 @@ /* globals angular */

self.httpInterface
.get( configuration.allowBrowserCache.sync ? configuration.entityUri : self.__uncached(
.get( self.allowBrowserCache.sync ? configuration.entityUri : self.__uncached(
configuration.entityUri ) )

@@ -278,3 +278,3 @@ .then( onSingleEntityReceived, onSingleEntityRetrievalFailure );

self.httpInterface
.get( configuration.allowBrowserCache.sync ? configuration.collectionUri : self.__uncached(
.get( self.allowBrowserCache.sync ? configuration.collectionUri : self.__uncached(
configuration.collectionUri ) )

@@ -436,3 +436,3 @@ .then( onCollectionReceived, onCollectionRetrievalFailure );

var request = self.httpInterface
.get( configuration.allowBrowserCache.request ? requestUri : self.__uncached( requestUri ) )
.get( self.allowBrowserCache.request ? requestUri : self.__uncached( requestUri ) )
.then( remoteRequestFromCache.bind( self, id ) );

@@ -439,0 +439,0 @@

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