Comparing version 2.0.0-beta.1 to 2.0.0-beta.2
@@ -0,1 +1,5 @@ | ||
##### 2.0.0-beta.2 - 17 April 2015 | ||
Updated a dependency for better umd amd/r.js support | ||
##### 2.0.0-beta.1 - 17 April 2015 | ||
@@ -2,0 +6,0 @@ |
/*! | ||
* js-data | ||
* @version 2.0.0-beta.1 - Homepage <http://www.js-data.io/> | ||
* @version 2.0.0-beta.2 - Homepage <http://www.js-data.io/> | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
@@ -11,5 +11,4 @@ * @copyright (c) 2014-2015 Jason Dobry | ||
!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):"object"==typeof exports?exports.JSData=b():a.JSData=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){var d=c(1),e=c(2),f=c(3);a.exports={DS:d["default"],DSUtils:e["default"],DSErrors:f["default"],createStore:function(a){return new d["default"](a)},version:{full:"2.0.0-beta.1",major:parseInt("2",10),minor:parseInt("0",10),patch:parseInt("0",10),alpha:"false",beta:"1"}}},function(a,b,c){function d(a,b,c){c(null,b)}function e(a,b){return b}function f(a,b,c,d){var e=!0;a:for(;e;){k=l=m=void 0,e=!1;var f=a,g=b,h=c,j=d,k=f[g],l=i["default"].get(h,k[0]),m=i["default"].get(j,k[0]);if(i["default"]._s(l)&&(l=i["default"].upperCase(l)),i["default"]._s(m)&&(m=i["default"].upperCase(m)),"DESC"===k[1]){if(l>m)return-1;if(m>l)return 1;if(g<f.length-1){a=f,b=g+1,c=h,d=j,e=!0;continue a}return 0}if(m>l)return-1;if(l>m)return 1;if(!(g<f.length-1))return 0;a=f,b=g+1,c=h,d=j,e=!0}}var g=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),i=c(2),j=c(3),k=c(4),l=c(5),m=function(){function a(){g(this,a)}return h(a,[{key:"errorFn",value:function(a,b){if(this.error&&"function"==typeof this.error){try{throw"string"==typeof a?new Error(a):a}catch(c){a=c}this.error(this.name||null,a||null,b||null)}}}]),a}(),n=m.prototype;n.actions={},n.afterCreate=d,n.afterCreateInstance=e,n.afterDestroy=d,n.afterEject=e,n.afterInject=e,n.afterReap=e,n.afterUpdate=d,n.afterValidate=d,n.allowSimpleWhere=!0,n.basePath="",n.beforeCreate=d,n.beforeCreateInstance=e,n.beforeDestroy=d,n.beforeEject=e,n.beforeInject=e,n.beforeReap=e,n.beforeUpdate=d,n.beforeValidate=d,n.bypassCache=!1,n.cacheResponse=!!i["default"].w,n.defaultAdapter="http",n.debug=!0,n.eagerEject=!1,n.eagerInject=!1,n.endpoint="",n.error=console?function(a,b,c){return console["function"==typeof console.error?"error":"log"](a,b,c)}:!1,n.fallbackAdapters=["http"],n.findStrictCache=!1,n.idAttribute="id",n.ignoredChanges=[/\$/],n.ignoreMissing=!1,n.keepChangeHistory=!1,n.linkRelations=!0,n.log=console?function(a,b,c,d,e){return console["function"==typeof console.info?"info":"log"](a,b,c,d,e)}:!1,n.logFn=function(a,b,c,d){var e=this;e.debug&&e.log&&"function"==typeof e.log&&e.log(e.name||null,a||null,b||null,c||null,d||null)},n.maxAge=!1,n.notify=!!i["default"].w,n.reapAction=i["default"].w?"inject":"none",n.reapInterval=i["default"].w?3e4:!1,n.relationsEnumerable=!1,n.resetHistoryOnInject=!0,n.strategy="single",n.upsert=!!i["default"].w,n.useClass=!0,n.useFilter=!1,n.validate=d,n.defaultFilter=function(a,b,c,d){var e=a,g=null,h={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""};c=c||{},d=d||{},g=i["default"]._o(c.where)?c.where:{},d.allowSimpleWhere&&i["default"].forOwn(c,function(a,b){b in h||b in g||(g[b]={"==":a})}),i["default"].isEmpty(g)&&(g=null),g&&(e=i["default"].filter(e,function(a){var b=!0,c=!0;return i["default"].forOwn(g,function(d,e){i["default"]._s(d)?d={"===":d}:(i["default"]._n(d)||i["default"].isBoolean(d))&&(d={"==":d}),i["default"]._o(d)&&i["default"].forOwn(d,function(d,f){var g=void 0,h="|"===f[0],j=a[e];f=h?f.substr(1):f,"=="===f?g=j==d:"==="===f?g=j===d:"!="===f?g=j!=d:"!=="===f?g=j!==d:">"===f?g=j>d:">="===f?g=j>=d:"<"===f?g=d>j:"<="===f?g=d>=j:"isectEmpty"===f?g=!i["default"].intersection(j||[],d||[]).length:"isectNotEmpty"===f?g=i["default"].intersection(j||[],d||[]).length:"in"===f?g=i["default"]._s(d)?-1!==d.indexOf(j):i["default"].contains(d,j):"notIn"===f?g=i["default"]._s(d)?-1===d.indexOf(j):!i["default"].contains(d,j):"contains"===f?g=i["default"]._s(j)?-1!==j.indexOf(d):i["default"].contains(j,d):"notContains"===f&&(g=i["default"]._s(j)?-1===j.indexOf(d):!i["default"].contains(j,d)),void 0!==g&&(c=b?g:h?c||g:c&&g),b=!1})}),c}));var k=null;i["default"]._s(c.orderBy)?k=[[c.orderBy,"ASC"]]:i["default"]._a(c.orderBy)&&(k=c.orderBy),!k&&i["default"]._s(c.sort)?k=[[c.sort,"ASC"]]:!k&&i["default"]._a(c.sort)&&(k=c.sort),k&&!function(){var a=0;i["default"].forEach(k,function(a,c){if(i["default"]._s(a))k[c]=[a,"ASC"];else if(!i["default"]._a(a))throw new j["default"].IA('DS.filter("'+b+'"[, params][, options]): '+i["default"].toJson(a)+": Must be a string or an array!",{params:{"orderBy[i]":{actual:typeof a,expected:"string|array"}}})}),e=i["default"].sort(e,function(b,c){return f(k,a,b,c)})}();var l=i["default"]._n(c.limit)?c.limit:null,m=null;return i["default"]._n(c.skip)?m=c.skip:i["default"]._n(c.offset)&&(m=c.offset),l&&m?e=i["default"].slice(e,m,Math.min(e.length,m+l)):i["default"]._n(l)?e=i["default"].slice(e,0,Math.min(e.length,l)):i["default"]._n(m)&&(e=m<e.length?i["default"].slice(e,m):[]),e};var o=function(){function a(b){g(this,a);var c=this;b=b||{},c.store={},c.s=c.store,c.definitions={},c.defs=c.definitions,c.adapters={},c.defaults=new m,c.observe=i["default"].observe,i["default"].forOwn(b,function(a,b){c.defaults[b]=a})}return h(a,[{key:"getAdapter",value:function(a){var b=!1;a=a||{},i["default"]._s(a)&&(b=!0,a={adapter:a});var c=this.adapters[a.adapter];if(c)return c;if(b)throw new Error(""+a.adapter+" is not a registered adapter!");return this.adapters[a.defaultAdapter]}},{key:"registerAdapter",value:function(a,b,c){var d=this;c=c||{},i["default"].isFunction(b)?d.adapters[a]=new b(c):d.adapters[a]=b,c["default"]&&(d.defaults.defaultAdapter=a)}},{key:"is",value:function(a,b){var c=this.defs[a];if(!c)throw new j["default"].NER(a);return b instanceof c[c["class"]]}}]),a}(),p=o.prototype;p.getAdapter.shorthand=!1,p.registerAdapter.shorthand=!1,p.errors=j["default"],p.utils=i["default"],i["default"].deepMixIn(p,k["default"]),i["default"].deepMixIn(p,l["default"]),b["default"]=o},function(a,b,c){function d(a){var b={};a=a||this,a.on=function(a,c,d){b[a]=b[a]||[],b[a].push({f:c,c:d})},a.off=function(a,c){var d=b[a];if(d)if(c){for(var e=0;e<d.length;e++)if(d[e]===c){d.splice(e,1);break}}else d.splice(0,d.length);else b={}},a.emit=function(){for(var a=arguments.length,c=Array(a),d=0;a>d;d++)c[d]=arguments[d];var e=b[c.shift()]||[];if(e)for(var f=0;f<e.length;f++)e[f].f.apply(e[f].c,c)}}var e=c(3),f=c(7),g=c(8),h=c(9),i=c(13),j=c(10),k=c(14),l=c(18),m=c(11),n=c(15),o=c(12),p=c(19),q=c(16),r=c(17),s=c(6),t=void 0,u=Object.prototype,v=u.toString,w=void 0;try{w=Promise}catch(x){console.error("js-data requires a global Promise constructor!")}var y=Array.isArray||function(a){return"[object Array]"==v.call(a)||!1},z=function(a){return"[object RegExp]"==v.call(a)||!1},A=function(a){return a===!0||a===!1||a&&"object"==typeof a&&"[object Boolean]"==v.call(a)||!1},B=function(a){return"string"==typeof a||a&&"object"==typeof a&&"[object String]"==v.call(a)||!1},C=function(a){return"[object Object]"==v.call(a)||!1},D=function(a){return a&&"object"==typeof a&&"[object Date]"==v.call(a)||!1},E=function(a){var b=typeof a;return"number"==b||a&&"object"==b&&"[object Number]"==v.call(a)||!1},F=function(a){return"function"==typeof a||a&&"[object Function]"===v.call(a)||!1},G=function(a){return B(a)||E(a)},H=function(a){return new e["default"].IA('"'+a+'" must be a string or a number!')},I=function(a){return new e["default"].IA('"'+a+'" must be an object!')},J=function(a){return new e["default"].IA('"'+a+'" must be an array!')},K=function(a){if(null==a)return!0;if("string"==typeof a||y(a))return!a.length;if("object"!=typeof a)return!0;var b=function(){var b=!0;return i(a,function(){return b=!1,!1}),{v:b}}();return"object"==typeof b?b.v:void 0},L=function(a,b){if(!a||!b)return[];for(var c=[],d=void 0,e=0,f=a.length;f>e;e++)d=a[e],j(c,d)||j(b,d)&&c.push(d);return c},M=function(a,b,c){var d=[];return g(a,function(a,c,e){b(a,c,e)&&d.push(a)},c),d};try{t=window,t={}}catch(N){t=null}var O=["beforeValidate","validate","afterValidate","beforeCreate","afterCreate","beforeUpdate","afterUpdate","beforeDestroy","afterDestroy"],P=function(a,b){var c=void 0;if(!b||!b.length)return!1;for(c=0;c<b.length;c++)if(b[c]===a)return!0;return!1},Q=function(a){function b(b,c,d,e,f){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a,b,c,d,e){if(b){if(a===b)throw new Error("Cannot copy! Source and destination are identical.");if(c=c||[],d=d||[],C(a)){var f=c.indexOf(a);if(-1!==f)return d[f];c.push(a),d.push(b)}var h=void 0;if(y(a)){var i=void 0;for(b.length=0,i=0;i<a.length;i++)h=Q(a[i],null,c,d,e),C(a[i])&&(c.push(a[i]),d.push(h)),b.push(h)}else{y(b)?b.length=0:g(b,function(a,c){delete b[c]});for(var j in a)if(a.hasOwnProperty(j)){if(P(j,e))continue;h=Q(a[j],null,c,d,e),C(a[j])&&(c.push(a[j]),d.push(h)),b[j]=h}}}else b=a,a&&(y(a)?b=Q(a,[],c,d,e):D(a)?b=new Date(a.getTime()):z(a)?(b=new RegExp(a.source,a.toString().match(/[^\/]*$/)[0]),b.lastIndex=a.lastIndex):C(a)&&(b=Q(a,Object.create(Object.getPrototypeOf(a)),c,d,e)));return b}),R=function(a){function b(b,c){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a,b){if(a===b)return!0;if(null===a||null===b)return!1;if(a!==a&&b!==b)return!0;var c,d,e,f=typeof a,g=typeof b;if(f==g&&"object"==f){if(!y(a)){if(D(a))return D(b)?R(a.getTime(),b.getTime()):!1;if(z(a)&&z(b))return a.toString()==b.toString();if(y(b))return!1;e={};for(d in a)if("$"!==d.charAt(0)&&!F(a[d])){if(!R(a[d],b[d]))return!1;e[d]=!0}for(d in b)if(!e.hasOwnProperty(d)&&"$"!==d.charAt(0)&&void 0!==b[d]&&!F(b[d]))return!1;return!0}if(!y(b))return!1;if((c=a.length)==b.length){for(d=0;c>d;d++)if(!R(a[d],b[d]))return!1;return!0}}return!1}),S=function(a,b){return B(b)||E(b)?b:b&&a?b[a.idAttribute]||b:b},T=function(a,b){return a&&(B(b)||E(b))?a.index[b]||b:b},U=function(a){return null!=a&&""!==a},V=function(a,b){return b=b||"",M(a,U).join(b)},W=function(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=V(b,"/");return d.replace(/([^:\/]|^)\/{2,}/g,"$1/")};b["default"]={Promise:w,_:function(a,b){var c=this;if(b=b||{},b&&b.constructor===a.constructor)return b;if(!C(b))throw new e["default"].IA('"options" must be an object!');g(O,function(a){"function"==typeof b[a]&&-1===b[a].toString().indexOf("for (var _len = arg")&&(b[a]=c.promisify(b[a]))});var d=function(a){var b=this;i(a,function(a,c){b[c]=a})};return d.prototype=a,d.prototype.orig=function(){var a={};return i(this,function(b,c){a[c]=b}),a},new d(b)},_n:E,_s:B,_sn:G,_snErr:H,_o:C,_oErr:I,_a:y,_aErr:J,compute:function(a,b){var c=this,d=[];g(a.deps,function(a){d.push(q(c,a))}),r(c,b,a[a.length-1].apply(c,d))},contains:j,copy:Q,deepMixIn:k,diffObjectFromOldObject:s.diffObjectFromOldObject,BinaryHeap:f,equals:R,Events:d,filter:M,forEach:g,forOwn:i,fromJson:function(a){return B(a)?JSON.parse(a):a},get:q,intersection:L,isArray:y,isBoolean:A,isDate:D,isEmpty:K,isFunction:F,isObject:C,isNumber:E,isRegExp:z,isString:B,makePath:W,observe:s,pascalCase:l,pick:n,promisify:function(a,b){var c=this;if(a){if("function"!=typeof a)throw new Error("Can only promisify functions!");return function(){for(var d=arguments.length,e=Array(d),f=0;d>f;f++)e[f]=arguments[f];return new c.Promise(function(c,d){e.push(function(a,b){a?d(a):c(b)});try{var f=a.apply(b||this,e);f&&f.then&&f.then(c,d)}catch(g){d(g)}})}}},remove:m,set:r,slice:h,sort:o,toJson:JSON.stringify,updateTimestamp:function(a){var b="function"==typeof Date.now?Date.now():(new Date).getTime();return a&&a>=b?a+1:b},upperCase:p,removeCircular:function(a){return function b(a,c){var d=void 0,e=void 0;if(!("object"!=typeof a||null===a||a instanceof Boolean||a instanceof Date||a instanceof Number||a instanceof RegExp||a instanceof String)){for(var f=c.current,g=c.context;g;){if(g.current===f)return void 0;g=g.context}if(y(a))for(e=[],d=0;d<a.length;d+=1)e[d]=b(a[d],{context:c,current:a[d]});else e={},i(a,function(d,f){e[f]=b(a[f],{context:c,current:a[f]})});return e}return a}(a,{context:null,current:a})},resolveItem:T,resolveId:S,w:t,applyRelationGettersToTarget:function(a,b,c){this.forEach(b.relationList,function(d){var e=d.relation,f="boolean"==typeof d.enumerable?d.enumerable:!!b.relationsEnumerable;("boolean"==typeof d.link?d.link:!!b.linkRelations)&&(delete c[d.localField],"belongsTo"===d.type?Object.defineProperty(c,d.localField,{enumerable:f,get:function(){return this[d.localKey]?b.getResource(e).get(this[d.localKey]):void 0},set:function(){}}):"hasMany"===d.type?Object.defineProperty(c,d.localField,{enumerable:f,get:function(){var c={};return c[d.foreignKey]=this[b.idAttribute],c[d.foreignKey]?a.defaults.constructor.prototype.defaultFilter.call(a,a.s[e].collection,e,c,{allowSimpleWhere:!0}):void 0},set:function(){}}):"hasOne"===d.type&&(d.localKey?Object.defineProperty(c,d.localField,{enumerable:f,get:function(){return this[d.localKey]?b.getResource(e).get(this[d.localKey]):void 0},set:function(){}}):Object.defineProperty(c,d.localField,{enumerable:f,get:function(){var c={};c[d.foreignKey]=this[b.idAttribute];var f=c[d.foreignKey]?a.defaults.constructor.prototype.defaultFilter.call(a,a.s[e].collection,e,c,{allowSimpleWhere:!0}):[];return f.length?f[0]:void 0},set:function(){}})))})}}},function(a,b,c){var d=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},e=function(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(a.__proto__=b)},f=function(a){function b(c){d(this,b);var e=new a(e);return e.__proto__=b.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(e,e.constructor),e.type=e.constructor.name,e.message=c||"Illegal Argument!",e}return e(b,a),b}(Error),g=function(a){function b(c){d(this,b);var e=new a(e);return e.__proto__=b.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(e,e.constructor),e.type=e.constructor.name,e.message=c||"RuntimeError Error!",e}return e(b,a),b}(Error),h=function(a){function b(c){d(this,b);var e=new a(e);return e.__proto__=b.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(e,e.constructor),e.type=e.constructor.name,e.message=""+c+" is not a registered resource!",e}return e(b,a),b}(Error);b["default"]={IllegalArgumentError:f,IA:f,RuntimeError:g,R:g,NonexistentResourceError:h,NER:h}},function(a,b,c){function d(a){return!(e["default"].isEmpty(a.added)&&e["default"].isEmpty(a.removed)&&e["default"].isEmpty(a.changed))}var e=c(2),f=c(3),g=c(26),h=c(27),i=c(28),j=c(29),k=c(30),l=f["default"].NER,m=f["default"].IA,n=f["default"].R;b["default"]={changes:function(a,b,c){var d=this,f=d.defs[a];if(c=c||{},b=e["default"].resolveId(f,b),!f)throw new l(a);if(!e["default"]._sn(b))throw e["default"]._snErr("id");c=e["default"]._(f,c);var g=d.get(a,b);if(g){var h=function(){e["default"].w&&d.s[a].observers[b].deliver();var h=c.ignoredChanges||[];e["default"].forEach(f.relationFields,function(a){return h.push(a)});var i=e["default"].diffObjectFromOldObject(g,d.s[a].previousAttributes[b],e["default"].equals,h);return e["default"].forOwn(i,function(a,b){var c=[];e["default"].forOwn(a,function(a,b){e["default"].isFunction(a)||c.push(b)}),i[b]=e["default"].pick(i[b],c)}),e["default"].forEach(f.relationFields,function(a){delete i.added[a],delete i.removed[a],delete i.changed[a]}),{v:i}}();if("object"==typeof h)return h.v}},changeHistory:function(a,b){var c=this,d=c.defs[a],f=c.s[a];if(b=e["default"].resolveId(d,b),a&&!c.defs[a])throw new l(a);if(b&&!e["default"]._sn(b))throw e["default"]._snErr("id");if(d.keepChangeHistory){if(!a)return f.changeHistory;var g=c.get(a,b);if(g)return f.changeHistories[b]}else d.errorFn("changeHistory is disabled for this resource!")},compute:function(a,b){var c=this,d=c.defs[a];if(b=e["default"].resolveItem(c.s[a],b),!d)throw new l(a);if(!b)throw new n("Item not in the store!");if(!e["default"]._o(b)&&!e["default"]._sn(b))throw new m('"instance" must be an object, string or number!');return e["default"].forOwn(d.computed,function(a,c){e["default"].compute.call(b,a,c)}),b},createInstance:function(a,b,c){var d=this.defs[a],f=void 0;if(b=b||{},!d)throw new l(a);if(b&&!e["default"].isObject(b))throw new m('"attrs" must be an object!');c=e["default"]._(d,c),c.notify&&c.beforeCreateInstance(c,b);var g=d[d["class"]];return f=new g,e["default"].deepMixIn(f,b),d.computed&&this.compute(d.name,f),c.notify&&c.afterCreateInstance(c,f),f},defineResource:g["default"],digest:function(){this.observe.Platform.performMicrotaskCheckpoint()},eject:h["default"],ejectAll:i["default"],filter:j["default"],get:function(a,b,c){var d=this,f=d.defs[a];if(!f)throw new l(a);if(!e["default"]._sn(b))throw e["default"]._snErr("id");c=e["default"]._(f,c);var g=d.s[a].index[b];return g},getAll:function(a,b){var c=this,d=c.defs[a],f=c.s[a],g=[];if(!d)throw new l(a);if(b&&!e["default"]._a(b))throw e["default"]._aErr("ids");if(e["default"]._a(b))for(var h=b.length,i=0;h>i;i++)f.index[b[i]]&&g.push(f.index[b[i]]);else g=f.collection.slice();return g},hasChanges:function(a,b){var c=this,f=c.defs[a];if(b=e["default"].resolveId(f,b),!f)throw new l(a);if(!e["default"]._sn(b))throw e["default"]._snErr("id");return c.get(a,b)?d(c.changes(a,b)):!1},inject:k["default"],lastModified:function(a,b){var c=this.defs[a],d=this.s[a];if(b=e["default"].resolveId(c,b),!c)throw new l(a);return b?(b in d.modified||(d.modified[b]=0),d.modified[b]):d.collectionModified},lastSaved:function(a,b){var c=this.defs[a],d=this.s[a];if(b=e["default"].resolveId(c,b),!c)throw new l(a);return b in d.saved||(d.saved[b]=0),d.saved[b]},previous:function(a,b){var c=this,d=c.defs[a],f=c.s[a];if(b=e["default"].resolveId(d,b),!d)throw new l(a);if(!e["default"]._sn(b))throw e["default"]._snErr("id");return f.previousAttributes[b]?e["default"].copy(f.previousAttributes[b]):void 0}}},function(a,b,c){var d=c(31),e=c(32),f=c(33),g=c(34),h=c(35),i=c(36),j=c(37),k=c(38),l=c(39),m=c(40);b["default"]={create:d["default"],destroy:e["default"],destroyAll:f["default"],find:g["default"],findAll:h["default"],loadRelations:i["default"],reap:j["default"],refresh:function(a,b,c){var d=this,e=d.utils;return new e.Promise(function(f,g){var h=d.defs[a];b=e.resolveId(d.defs[a],b),h?e._sn(b)?(c=e._(h,c),c.bypassCache=!0,f(d.get(a,b))):g(e._snErr("id")):g(new d.errors.NER(a))}).then(function(e){return e?d.find(a,b,c):e})},save:k["default"],update:l["default"],updateAll:m["default"]}},function(a,b,c){!function(a){function b(){function a(a){b=a}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=[],c={},d=[];return Object.observe(c,a),Array.observe(d,a),c.id=1,c.id=2,delete c.id,d.push(1,2),d.length=0,Object.deliverChangeRecords(a),5!==b.length?!1:"add"!=b[0].type||"update"!=b[1].type||"delete"!=b[2].type||"splice"!=b[3].type||"splice"!=b[4].type?!1:(Object.unobserve(c,a),Array.unobserve(d,a),!0)}function c(b){for(var c=0;s>c&&b.check_();)c++;return p&&(a.dirtyCheckCycleCount=c),c>0}function d(a){for(var b in a)return!1;return!0}function e(a){return d(a.added)&&d(a.removed)&&d(a.changed)}function f(a,b){if(!b||!b.length)return!1;for(var c,d=0;d<b.length;d++)if("[object RegExp]"===Object.prototype.toString.call(b[d])&&b[d].test(a)||b[d]===a)return c=a;return!!c}function g(a,b,c,d){var e={},g={},h={};for(var i in b){var j=a[i];f(i,d)||void 0!==j&&(c?c(j,b[i]):j===b[i])||(i in a?(c?c(j,b[i]):j===b[i])||(h[i]=j):g[i]=void 0)}for(var i in a)i in b||f(i,d)||(e[i]=a[i]);return Array.isArray(a)&&a.length!==b.length&&(h.length=a.length),{added:e,removed:g,changed:h}}function h(){if(!t.length)return!1;for(var a=0;a<t.length;a++)t[a]();return t.length=0,!0}function i(){function a(a){b&&b.state_===x&&!d&&b.check_(a)}var b,c,d=!1,e=!0;return{open:function(c){if(b)throw Error("ObservedObject in use");e||Object.deliverChangeRecords(a),b=c,e=!1},observe:function(b,d){c=b,d?Array.observe(c,a):Object.observe(c,a)},deliver:function(b){d=b,Object.deliverChangeRecords(a),d=!1},close:function(){b=void 0,Object.unobserve(c,a),v.push(this)}}}function j(a,b,c){var d=v.pop()||i();return d.open(a),d.observe(b,c),d}function k(){this.state_=w,this.callback_=void 0,this.target_=void 0,this.directObserver_=void 0,this.value_=void 0,this.id_=z++}function l(a){k._allObserversCount++,B&&A.push(a)}function m(a){k._allObserversCount--}function n(a){k.call(this),this.value_=a,this.oldObject_=void 0}function o(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];E[g.type]?(g.name in c||(c[g.name]=g.oldValue),"update"!=g.type&&("add"!=g.type?g.name in d?(delete d[g.name],delete c[g.name]):e[g.name]=!0:g.name in e?delete e[g.name]:d[g.name]=!0)):(console.error("Unknown changeRecord type: "+g.type),console.error(g))}for(var h in d)d[h]=a[h];for(var h in e)e[h]=void 0;var i={};for(var h in c)if(!(h in d||h in e)){var j=a[h];c[h]!==j&&(i[h]=j)}return{added:d,removed:e,changed:i}}var p=a.testingExposeCycleCount,q=b(),r="__proto__"in{}?function(a){return a}:function(a){var b=a.__proto__;if(!b)return a;var c=Object.create(b);return Object.getOwnPropertyNames(a).forEach(function(b){Object.defineProperty(c,b,Object.getOwnPropertyDescriptor(a,b))}),c},s=1e3,t=[],u=q?function(){return function(a){return Promise.resolve().then(a)}}():function(){return function(a){t.push(a)}}(),v=[],w=0,x=1,y=2,z=1;k.prototype={open:function(a,b){if(this.state_!=w)throw Error("Observer has already been opened.");return l(this),this.callback_=a,this.target_=b,this.connect_(),this.state_=x,this.value_},close:function(){this.state_==x&&(m(this),this.disconnect_(),this.value_=void 0,this.callback_=void 0,this.target_=void 0,this.state_=y)},deliver:function(){this.state_==x&&c(this)},report_:function(a){try{this.callback_.apply(this.target_,a)}catch(b){k._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+(b.stack||b))}},discardChanges:function(){return this.check_(void 0,!0),this.value_}};var A,B=!q;k._allObserversCount=0,B&&(A=[]);var C=!1;a.Platform=a.Platform||{},a.Platform.performMicrotaskCheckpoint=function(){if(!C&&B){C=!0;var b,c,d=0;do{d++,c=A,A=[],b=!1;for(var e=0;e<c.length;e++){var f=c[e];f.state_==x&&(f.check_()&&(b=!0),A.push(f))}h()&&(b=!0)}while(s>d&&b);p&&(a.dirtyCheckCycleCount=d),C=!1}},B&&(a.Platform.clearObservers=function(){A=[]}),n.prototype=r({__proto__:k.prototype,arrayObserve:!1,connect_:function(a,b){q?this.directObserver_=j(this,this.value_,this.arrayObserve):this.oldObject_=this.copyObject(this.value_)},copyObject:function(a){var b=Array.isArray(a)?[]:{};for(var c in a)b[c]=a[c];return Array.isArray(a)&&(b.length=a.length),b},check_:function(a,b){var c,d;if(q){if(!a)return!1;d={},c=o(this.value_,a,d)}else d=this.oldObject_,c=g(this.value_,this.oldObject_);return e(c)?!1:(q||(this.oldObject_=this.copyObject(this.value_)),this.report_([c.added||{},c.removed||{},c.changed||{},function(a){return d[a]}]),!0)},disconnect_:function(){q?(this.directObserver_.close(),this.directObserver_=void 0):this.oldObject_=void 0},deliver:function(){this.state_==x&&(q?this.directObserver_.deliver(!1):c(this))},discardChanges:function(){return this.directObserver_?this.directObserver_.deliver(!0):this.oldObject_=this.copyObject(this.value_),this.value_}});var D={},E={add:!0,update:!0,"delete":!0};a.Observer=k,a.Observer.runEOM_=u,a.Observer.observerSentinel_=D,a.Observer.hasObjectObserve=q,a.diffObjectFromOldObject=g,a.ObjectObserver=n}(b)},function(a,b,c){!function(b,c){a.exports=c()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){function d(a,b,c){for(var d=a[c],e=b(d);c>0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}var e=function(){function a(a,b){for(var c in b){var d=b[c];d.configurable=!0,d.value&&(d.writable=!0)}Object.defineProperties(a,b)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},g=function(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}},h=function(){function a(b,c){if(f(this,a),b||(b=function(a){return a}),c||(c=function(a,b){return a===b}),"function"!=typeof b)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof c)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=b,this.compareFunc=c,this.heap=[]}return e(a,{push:{value:function(a){this.heap.push(a),d(this.heap,this.weightFunc,this.heap.length-1)}},peek:{value:function(){return this.heap[0]}},pop:{value:function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,g(this.heap,this.weightFunc,0)),a}},remove:{value:function(a){for(var b=this.heap.length,c=0;b>c;c++)if(this.compareFunc(this.heap[c],a)){var e=this.heap[c],f=this.heap.pop();return c!==b-1&&(this.heap[c]=f,d(this.heap,this.weightFunc,c),g(this.heap,this.weightFunc,c)),e}return null}},removeAll:{value:function(){this.heap=[]}},size:{value:function(){return this.heap.length}}}),a}();a.exports=h}])})},function(a,b,c){function d(a,b,c){if(null!=a)for(var d=-1,e=a.length;++d<e&&b.call(c,a[d],d,a)!==!1;);}a.exports=d},function(a,b,c){function d(a,b,c){var d=a.length;b=null==b?0:0>b?Math.max(d+b,0):Math.min(b,d),c=null==c?d:0>c?Math.max(d+c,0):Math.min(c,d);for(var e=[];c>b;)e.push(a[b++]);return e}a.exports=d},function(a,b,c){function d(a,b){return-1!==e(a,b)}var e=c(20);a.exports=d},function(a,b,c){function d(a,b){var c=e(a,b);-1!==c&&a.splice(c,1)}var e=c(20);a.exports=d},function(a,b,c){function d(a,b){if(null==a)return[];if(a.length<2)return a;null==b&&(b=e);var c,g,h;return c=~~(a.length/2),g=d(a.slice(0,c),b),h=d(a.slice(c,a.length),b),f(g,h,b)}function e(a,b){return b>a?-1:a>b?1:0}function f(a,b,c){for(var d=[];a.length&&b.length;)d.push(c(a[0],b[0])<=0?a.shift():b.shift());return a.length&&d.push.apply(d,a),b.length&&d.push.apply(d,b),d}a.exports=d},function(a,b,c){function d(a,b,c){f(a,function(d,f){return e(a,f)?b.call(c,a[f],f,a):void 0})}var e=c(21),f=c(22);a.exports=d},function(a,b,c){function d(a,b){for(var c,d=0,g=arguments.length;++d<g;)c=arguments[d],c&&f(c,e,a);return a}function e(a,b){var c=this[b];g(a)&&g(c)?d(c,a):this[b]=a}var f=c(13),g=c(23);a.exports=d},function(a,b,c){function d(a,b){for(var c,d="string"!=typeof arguments[1]?arguments[1]:e(arguments,1),f={},g=0;c=d[g++];)f[c]=a[c];return f}var e=c(9);a.exports=d},function(a,b,c){function d(a,b){for(var c=b.split("."),d=c.pop();b=c.shift();)if(a=a[b],null==a)return;return a[d]}c(24);a.exports=d},function(a,b,c){function d(a,b,c){var d=/^(.+)\.(.+)$/.exec(b);d?e(a,d[1])[d[2]]=c:a[b]=c}var e=c(25);a.exports=d},function(a,b,c){function d(a){return a=e(a),f(a).replace(/^[a-z]/,g)}var e=c(41),f=c(42),g=c(19);a.exports=d},function(a,b,c){function d(a){return a=e(a),a.toUpperCase()}var e=c(41);a.exports=d},function(a,b,c){function d(a,b,c){if(c=c||0,null==a)return-1;for(var d=a.length,e=0>c?d+c:c;d>e;){if(a[e]===b)return e;e++}return-1}a.exports=d},function(a,b,c){function d(a,b){return Object.prototype.hasOwnProperty.call(a,b)}a.exports=d},function(a,b,c){function d(){h=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],g=!0;for(var a in{toString:null})g=!1}function e(a,b,c){var e,j=0;null==g&&d();for(e in a)if(f(b,a,e,c)===!1)break;if(g)for(var k=a.constructor,l=!!k&&a===k.prototype;(e=h[j++])&&("constructor"===e&&(l||!i(a,e))||a[e]===Object.prototype[e]||f(b,a,e,c)!==!1););}function f(a,b,c,d){return a.call(d,b[c],c,b)}var g,h,i=c(21);a.exports=e},function(a,b,c){function d(a){return!!a&&"object"==typeof a&&a.constructor===Object}a.exports=d},function(a,b,c){function d(a){switch(typeof a){case"string":case"number":case"boolean":return!0}return null==a}a.exports=d},function(a,b,c){function d(a,b){return b?(e(b.split("."),function(b){a[b]||(a[b]={}),a=a[b]}),a):a}var e=c(8);a.exports=d},function(module,exports,__webpack_require__){function defineResource(definition){var _this=this,definitions=_this.defs;if(_DSUtils["default"]._s(definition)&&(definition={name:definition.replace(/\s/gi,"")}),!_DSUtils["default"]._o(definition))throw _DSUtils["default"]._oErr("definition");if(!_DSUtils["default"]._s(definition.name))throw new _DSErrors["default"].IA('"name" must be a string!');if(_this.s[definition.name])throw new _DSErrors["default"].R(""+definition.name+" is already registered!");try{var def,_class,_ret=function(){if(Resource.prototype=_this.defaults,definitions[definition.name]=new Resource(definition),def=definitions[definition.name],def.n=def.name,!_DSUtils["default"]._s(def.idAttribute))throw new _DSErrors["default"].IA('"idAttribute" must be a string!');def.relations&&(def.relationList=[],def.relationFields=[],_DSUtils["default"].forOwn(def.relations,function(a,b){_DSUtils["default"].forOwn(a,function(c,d){_DSUtils["default"]._a(c)||(a[d]=[c]),_DSUtils["default"].forEach(a[d],function(a){a.type=b,a.relation=d,a.name=def.n,def.relationList.push(a),a.localField&&def.relationFields.push(a.localField)})})}),def.relations.belongsTo&&_DSUtils["default"].forOwn(def.relations.belongsTo,function(a,b){_DSUtils["default"].forEach(a,function(a){a.parent&&(def.parent=b,def.parentKey=a.localKey,def.parentField=a.localField)})}),"function"==typeof Object.freeze&&(Object.freeze(def.relations),Object.freeze(def.relationList))),def.getResource=function(a){return _this.defs[a]},def.getEndpoint=function(a,b){b.params=b.params||{};var c=void 0,d=def.parentKey,e=b.hasOwnProperty("endpoint")?b.endpoint:def.endpoint,f=def.parentField,g=definitions[def.parent],h=b.params[d];if(h===!1||!d||!g)return h===!1&&delete b.params[d],e;if(delete b.params[d],_DSUtils["default"]._sn(a)?c=def.get(a):_DSUtils["default"]._o(a)&&(c=a),c&&(h=h||c[d]||(c[f]?c[f][g.idAttribute]:null)),!h)return e;var i=function(){delete b.endpoint;var a={};return _DSUtils["default"].forOwn(b,function(b,c){a[c]=b}),{v:_DSUtils["default"].makePath(g.getEndpoint(h,_DSUtils["default"]._(g,a)),h,e)}}();return"object"==typeof i?i.v:void 0},def.filter&&(def.defaultFilter=def.filter,delete def.filter),_class=def["class"]=_DSUtils["default"].pascalCase(def.name);try{"function"==typeof def.useClass?(eval("function "+_class+"() { def.useClass.call(this); }"),def[_class]=eval(_class),def[_class].prototype=function(a){function b(){}return b.prototype=a,new b}(def.useClass.prototype)):(eval("function "+_class+"() {}"),def[_class]=eval(_class))}catch(e){def[_class]=function(){}}def.methods&&_DSUtils["default"].deepMixIn(def[_class].prototype,def.methods),def[_class].prototype.set=function(a,b){return _DSUtils["default"].set(this,a,b),_this.compute(def.n,this),this},def[_class].prototype.get=function(a){return _DSUtils["default"].get(this,a)},_DSUtils["default"].applyRelationGettersToTarget(_this,def,def[_class].prototype),def.computed&&_DSUtils["default"].forOwn(def.computed,function(a,b){_DSUtils["default"].isFunction(a)&&(def.computed[b]=[a],a=def.computed[b]),def.methods&&b in def.methods&&def.errorFn('Computed property "'+b+'" conflicts with previously defined prototype method!');var c;if(1===a.length){var d=a[0].toString().match(/function.*?\(([\s\S]*?)\)/);c=d[1].split(","),def.computed[b]=c.concat(a),a=def.computed[b],c.length&&def.errorFn("Use the computed property array syntax for compatibility with minified code!"); | ||
}c=a.slice(0,a.length-1),_DSUtils["default"].forEach(c,function(a,b){c[b]=a.trim()}),a.deps=_DSUtils["default"].filter(c,function(a){return!!a})}),_DSUtils["default"].forEach(instanceMethods,function(a){def[_class].prototype["DS"+_DSUtils["default"].pascalCase(a)]=function(){for(var b=arguments.length,c=Array(b),d=0;b>d;d++)c[d]=arguments[d];return c.unshift(this[def.idAttribute]||this),c.unshift(def.n),_this[a].apply(_this,c)}}),def[_class].prototype.DSCreate=function(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return b.unshift(this),b.unshift(def.n),_this.create.apply(_this,b)},_this.s[def.n]={collection:[],expiresHeap:new _DSUtils["default"].BinaryHeap(function(a){return a.expires},function(a,b){return a.item===b}),completedQueries:{},queryData:{},pendingQueries:{},index:{},modified:{},saved:{},previousAttributes:{},observers:{},changeHistories:{},changeHistory:[],collectionModified:0},def.reapInterval&&setInterval(function(){return _this.reap(def.n,{isInterval:!0})},def.reapInterval);var fns=["registerAdapter","getAdapter","is"];for(key in _this)"function"==typeof _this[key]&&fns.push(key);_DSUtils["default"].forEach(fns,function(a){var b=a;_this[b].shorthand!==!1?def[b]=function(){for(var a=arguments.length,c=Array(a),d=0;a>d;d++)c[d]=arguments[d];return c.unshift(def.n),_this[b].apply(_this,c)}:def[b]=function(){for(var a=arguments.length,c=Array(a),d=0;a>d;d++)c[d]=arguments[d];return _this[b].apply(_this,c)}}),def.beforeValidate=_DSUtils["default"].promisify(def.beforeValidate),def.validate=_DSUtils["default"].promisify(def.validate),def.afterValidate=_DSUtils["default"].promisify(def.afterValidate),def.beforeCreate=_DSUtils["default"].promisify(def.beforeCreate),def.afterCreate=_DSUtils["default"].promisify(def.afterCreate),def.beforeUpdate=_DSUtils["default"].promisify(def.beforeUpdate),def.afterUpdate=_DSUtils["default"].promisify(def.afterUpdate),def.beforeDestroy=_DSUtils["default"].promisify(def.beforeDestroy),def.afterDestroy=_DSUtils["default"].promisify(def.afterDestroy);var defaultAdapter=void 0;return def.hasOwnProperty("defaultAdapter")&&(defaultAdapter=def.defaultAdapter),_DSUtils["default"].forOwn(def.actions,function(a,b){if(def[b]&&!def.actions[b])throw new Error('Cannot override existing method "'+b+'"!');def[b]=function(c,d){_DSUtils["default"]._o(c)&&(d=c),d=d||{};var e=_this.getAdapter(a.adapter||defaultAdapter||"http"),f=_DSUtils["default"].deepMixIn({},a);if(!d.hasOwnProperty("endpoint")&&f.endpoint&&(d.endpoint=f.endpoint),"function"==typeof d.getEndpoint)f.url=d.getEndpoint(def,d);else{var g=[d.basePath||e.defaults.basePath||def.basePath,def.getEndpoint(_DSUtils["default"]._sn(c)?c:null,d)];_DSUtils["default"]._sn(c)&&g.push(c),g.push(a.pathname||b),f.url=_DSUtils["default"].makePath.apply(null,g)}return f.method=f.method||"GET",_DSUtils["default"].deepMixIn(f,d),e.HTTP(f)}}),_DSUtils["default"].Events(def),{v:def}}();if("object"==typeof _ret)return _ret.v}catch(err){throw delete definitions[definition.name],delete _this.s[definition.name],err}}var _classCallCheck=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")};exports["default"]=defineResource;var _DSUtils=__webpack_require__(2),_DSErrors=__webpack_require__(3),Resource=function a(b){_classCallCheck(this,a),_DSUtils["default"].deepMixIn(this,b),"endpoint"in b?this.endpoint=b.endpoint:this.endpoint=this.name},instanceMethods=["compute","refresh","save","update","destroy","loadRelations","changeHistory","changes","hasChanges","lastModified","lastSaved","previous"]},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a],g=d.s[a],h=void 0,i=!1;if(b=e.resolveId(f,b),!f)throw new d.errors.NER(a);if(!e._sn(b))throw e._snErr("id");c=e._(f,c);for(var j=0;j<g.collection.length;j++)if(g.collection[j][f.idAttribute]==b){h=g.collection[j],g.expiresHeap.remove(h),i=!0;break}if(i){var k=function(){c.notify&&(f.beforeEject(c,h),f.emit("DS.beforeEject",f,h)),g.collection.splice(j,1),e.w&&g.observers[b].close(),delete g.observers[b],delete g.index[b],delete g.previousAttributes[b],delete g.completedQueries[b],delete g.pendingQueries[b],e.forEach(g.changeHistories[b],function(a){e.remove(g.changeHistory,a)});var a=[];return e.forOwn(g.queryData,function(b,c){b.$$injected&&e.remove(b,h),b.length||a.push(c)}),e.forEach(a,function(a){delete g.completedQueries[a],delete g.queryData[a]}),delete g.changeHistories[b],delete g.modified[b],delete g.saved[b],g.collectionModified=e.updateTimestamp(g.collectionModified),c.notify&&(f.afterEject(c,h),f.emit("DS.afterEject",f,h)),{v:h}}();if("object"==typeof k)return k.v}}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a];if(b=b||{},!f)throw new d.errors.NER(a);if(!e._o(b))throw e._oErr("params");var g=d.s[a],h=e.toJson(b),i=d.filter(f.n,b),j=[];return e.isEmpty(b)?g.completedQueries={}:delete g.completedQueries[h],e.forEach(i,function(a){a&&a[f.idAttribute]&&j.push(a[f.idAttribute])}),e.forEach(j,function(a){d.eject(f.n,a,c)}),g.collectionModified=e.updateTimestamp(g.collectionModified),i}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a];if(!f)throw new d.errors.NER(a);if(b&&!e._o(b))throw e._oErr("params");return b=b||{},c=e._(f,c),f.defaultFilter.call(d,d.s[a].collection,a,b,c)}b["default"]=d},function(a,b,c){function d(a,b,c){var d=b.n;return function(e,f,h,i,j){var k=this,l=void 0,m=i&&i(b.idAttribute)?i(b.idAttribute):k[b.idAttribute];if(g["default"].forEach(b.relationFields,function(a){delete e[a],delete f[a],delete h[a]}),(!g["default"].isEmpty(e)||!g["default"].isEmpty(f)||!g["default"].isEmpty(h)||j)&&(l=a.get(d,m),c.modified[m]=g["default"].updateTimestamp(c.modified[m]),c.collectionModified=g["default"].updateTimestamp(c.collectionModified),b.keepChangeHistory)){var n={resourceName:d,target:l,added:e,removed:f,changed:h,timestamp:c.modified[m]};c.changeHistories[m].push(n),c.changeHistory.push(n)}b.computed&&(l=l||a.get(d,m),g["default"].forOwn(b.computed,function(a,b){var c=!1;g["default"].forEach(a.deps,function(a){(a in e||a in f||a in h||!(b in l))&&(c=!0)}),c=c||!a.deps.length,c&&g["default"].compute.call(l,a,b)})),b.idAttribute in h&&b.errorFn('Doh! You just changed the primary key of an object! Your data for the "'+d+'" resource is now in an undefined (probably broken) state.')}}function e(a,b,c,f){var i=this,j=d(i,a,b,c,f),k=void 0;if(g["default"]._a(c)){k=[];for(var l=0;l<c.length;l++)k.push(e.call(i,a,b,c[l],f))}else{var m=a.computed,n=a.idAttribute;if(m&&m[n]&&!function(){var a=[];g["default"].forEach(m[n].deps,function(b){a.push(c[b])}),c[n]=m[n][m[n].length-1].apply(c,a)}(),!(n in c)){var o=new h["default"].R(""+a.n+'.inject: "attrs" must contain the property specified by "idAttribute"!');throw f.errorFn(o),o}try{g["default"].forEach(a.relationList,function(b){var d=b.relation,e=i.defs[d],j=c[b.localField];if(j){if(!e)throw new h["default"].R(""+a.n+" relation is defined but the resource is not!");if(g["default"]._a(j))!function(){var h=[];g["default"].forEach(j,function(g){if(g!==i.s[d].index[g[e.idAttribute]])try{var j=i.inject(d,g,f.orig());b.foreignKey&&(j[b.foreignKey]=c[a.idAttribute]),h.push(j)}catch(k){f.errorFn(k,"Failed to inject "+b.type+' relation: "'+d+'"!')}})}();else if(j!==i.s[d].index[j[e.idAttribute]])try{var k=i.inject(d,c[b.localField],f.orig());b.foreignKey&&(k[b.foreignKey]=c[a.idAttribute])}catch(l){f.errorFn(l,"Failed to inject "+b.type+' relation: "'+d+'"!')}}});var p=c[n],q=i.get(a.n,p),r=q?b.modified[p]:0;q?(g["default"].deepMixIn(q,c),a.resetHistoryOnInject&&(b.previousAttributes[p]=g["default"].copy(q,null,null,null,a.relationFields),b.changeHistories[p].length&&(g["default"].forEach(b.changeHistories[p],function(a){g["default"].remove(b.changeHistory,a)}),b.changeHistories[p].splice(0,b.changeHistories[p].length))),g["default"].w&&b.observers[p].deliver()):(q=c instanceof a[a["class"]]?c:new a[a["class"]],g["default"].forEach(a.relationList,function(a){delete c[a.localField]}),g["default"].deepMixIn(q,c),b.collection.push(q),b.changeHistories[p]=[],g["default"].w&&(b.observers[p]=new i.observe.ObjectObserver(q),b.observers[p].open(j,q)),b.index[p]=q,j.call(q,{},{},{},null,!0),b.previousAttributes[p]=g["default"].copy(q,null,null,null,a.relationFields)),b.modified[p]=r&&b.modified[p]===r?g["default"].updateTimestamp(b.modified[p]):b.modified[p],b.expiresHeap.remove(q);var s=(new Date).getTime();b.expiresHeap.push({item:q,timestamp:s,expires:a.maxAge?s+a.maxAge:Number.MAX_VALUE}),k=q}catch(t){f.errorFn(t,c)}}return k}function f(a,b,c){var d=this,f=d.defs[a],i=d.s[a],j=void 0;if(!f)throw new h["default"].NER(a);if(!g["default"]._o(b)&&!g["default"]._a(b))throw new h["default"].IA(""+a+'.inject: "attrs" must be an object or an array!');return c=g["default"]._(f,c),c.notify&&(c.beforeInject(c,b),f.emit("DS.beforeInject",f,b)),j=e.call(d,f,i,b,c),i.collectionModified=g["default"].updateTimestamp(i.collectionModified),c.notify&&(c.afterInject(c,j),f.emit("DS.afterInject",f,j)),j}b["default"]=f;var g=c(2),h=c(3)},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a];c=c||{},b=b||{};var g=void 0;if(f)if(e._o(b)){if(c=e._(f,c),c.upsert&&e._sn(b[f.idAttribute]))return d.update(a,b[f.idAttribute],b,c)}else g=e._oErr("attrs");else g=new d.errors.NER(a);return new e.Promise(function(a,c){g?c(g):a(b)}).then(function(a){return c.beforeValidate.call(a,c,a)}).then(function(a){return c.validate.call(a,c,a)}).then(function(a){return c.afterValidate.call(a,c,a)}).then(function(a){return c.beforeCreate.call(a,c,a)}).then(function(a){return c.notify&&f.emit("DS.beforeCreate",f,a),d.getAdapter(c).create(f,a,c)}).then(function(a){return c.afterCreate.call(a,c,a)}).then(function(b){if(c.notify&&f.emit("DS.afterCreate",f,b),c.cacheResponse){var g=d.inject(f.n,b,c.orig()),h=g[f.idAttribute],i=d.s[a];return i.completedQueries[h]=(new Date).getTime(),i.saved[h]=e.updateTimestamp(i.saved[h]),g}return d.createInstance(a,b,c)})}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a],g=void 0;return new e.Promise(function(h,i){b=e.resolveId(f,b),f?e._sn(b)?(g=d.get(a,b)||{id:b},c=e._(f,c),h(g)):i(e._snErr("id")):i(new d.errors.NER(a))}).then(function(a){return c.beforeDestroy.call(a,c,a)}).then(function(e){return c.notify&&f.emit("DS.beforeDestroy",f,e),c.eagerEject&&d.eject(a,b),d.getAdapter(c).destroy(f,b,c)}).then(function(){return c.afterDestroy.call(g,c,g)}).then(function(e){return c.notify&&f.emit("DS.afterDestroy",f,e),d.eject(a,b),b})["catch"](function(b){return c&&c.eagerEject&&g&&d.inject(a,g,{notify:!1}),e.Promise.reject(b)})}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a],g=void 0,h=void 0;return b=b||{},new e.Promise(function(g,h){f?e._o(b)?(c=e._(f,c),g()):h(e._oErr("attrs")):h(new d.errors.NER(a))}).then(function(){return h=d.defaults.defaultFilter.call(d,a,b),c.beforeDestroy(c,h)}).then(function(){return c.notify&&f.emit("DS.beforeDestroy",f,h),c.eagerEject&&(g=d.ejectAll(a,b)),d.getAdapter(c).destroyAll(f,b,c)}).then(function(){return c.afterDestroy(c,h)}).then(function(){return c.notify&&f.emit("DS.afterDestroy",f,h),g||d.ejectAll(a,b)})["catch"](function(b){return c&&c.eagerEject&&g&&d.inject(a,g,{notify:!1}),e.Promise.reject(b)})}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a],g=d.s[a];return new e.Promise(function(h,i){f?e._sn(b)?(c=e._(f,c),c.params&&(c.params=e.copy(c.params)),(c.bypassCache||!c.cacheResponse)&&delete g.completedQueries[b],(!c.findStrictCache||b in g.completedQueries)&&d.get(a,b)&&!c.bypassCache?h(d.get(a,b)):(delete g.completedQueries[b],h())):i(e._snErr("id")):i(new d.errors.NER(a))}).then(function(h){if(h)return h;if(!(b in g.pendingQueries)){var i=void 0,j=c.findStrategy||c.strategy;"fallback"===j?!function(){var a=function(g){return d.getAdapter((c.findFallbackAdapters||c.fallbackAdapters)[g]).find(f,b,c)["catch"](function(b){return g++,g<c.fallbackAdapters.length?a(g):e.Promise.reject(b)})};i=a(0)}():i=d.getAdapter(c).find(f,b,c),g.pendingQueries[b]=i.then(function(f){if(delete g.pendingQueries[b],c.cacheResponse){var h=d.inject(a,f,c.orig());return g.completedQueries[b]=(new Date).getTime(),g.saved[b]=e.updateTimestamp(g.saved[b]),h}return d.createInstance(a,f,c.orig())})}return g.pendingQueries[b]})["catch"](function(a){return g&&delete g.pendingQueries[b],e.Promise.reject(a)})}b["default"]=d},function(a,b,c){function d(a,b,c,d){var e=this,f=e.utils,g=e.s[b],h=e.defs[b].idAttribute,i=(new Date).getTime();a=a||[],delete g.pendingQueries[c],g.completedQueries[c]=i,g.collectionModified=f.updateTimestamp(g.collectionModified);var j=e.inject(b,a,d.orig());return f._a(j)?f.forEach(j,function(a){if(a){var b=a[h];b&&(g.completedQueries[b]=i,g.saved[b]=f.updateTimestamp(g.saved[b]))}}):(d.errorFn("response is expected to be an array!"),g.completedQueries[j[h]]=i),j}function e(a,b,c){var e=this,f=e.utils,g=e.defs[a],h=e.s[a],i=void 0;return new f.Promise(function(d,j){b=b||{},e.defs[a]?f._o(b)?(c=f._(g,c),i=f.toJson(b),c.params&&(c.params=f.copy(c.params)),(c.bypassCache||!c.cacheResponse)&&(delete h.completedQueries[i],delete h.queryData[i]),i in h.completedQueries?d(c.useFilter?e.filter(a,b,c.orig()):h.queryData[i]):d()):j(f._oErr("params")):j(new e.errors.NER(a))}).then(function(j){if(i in h.completedQueries)return j;if(!(i in h.pendingQueries)){var k=void 0,l=c.findAllStrategy||c.strategy;"fallback"===l?!function(){var a=function(d){return e.getAdapter((c.findAllFallbackAdapters||c.fallbackAdapters)[d]).findAll(g,b,c)["catch"](function(b){return d++,d<c.fallbackAdapters.length?a(d):f.Promise.reject(b)})};k=a(0)}():k=e.getAdapter(c).findAll(g,b,c),h.pendingQueries[i]=k.then(function(b){return delete h.pendingQueries[i],c.cacheResponse?(h.queryData[i]=d.call(e,b,a,i,c),h.queryData[i].$$injected=!0,h.queryData[i]):(f.forEach(b,function(d,f){b[f]=e.createInstance(a,d,c.orig())}),b)})}return h.pendingQueries[i]})["catch"](function(a){return h&&delete h.pendingQueries[i],f.Promise.reject(a)})}b["default"]=e},function(a,b,c){function d(a,b,c,d){var e=this,f=e.utils,g=e.errors,h=e.defs[a];return new f.Promise(function(i,j){f._sn(b)&&(b=e.get(a,b)),f._s(c)&&(c=[c]),h?f._o(b)?f._a(c)?!function(){var a=f._(h,d);a.hasOwnProperty("findBelongsTo")||(a.findBelongsTo=!0),a.hasOwnProperty("findHasMany")||(a.findHasMany=!0);var g=[];f.forEach(h.relationList,function(a){var i=a.relation,j=h.getResource(i),k=f._(j,d);if(f.contains(c,i)||f.contains(c,a.localField)){var l=void 0,m={};k.allowSimpleWhere?m[a.foreignKey]=b[h.idAttribute]:(m.where={},m.where[a.foreignKey]={"==":b[h.idAttribute]}),"hasMany"===a.type?l=e.findAll(i,m,k.orig()):"hasOne"===a.type?a.localKey&&b[a.localKey]?l=e.find(i,b[a.localKey],k.orig()):a.foreignKey&&(l=e.findAll(i,m,k.orig()).then(function(a){return a.length?a[0]:null})):b[a.localKey]&&(l=e.find(i,b[a.localKey],k.orig())),l&&g.push(l)}}),i(g)}():j(new g.IA('"relations" must be a string or an array!')):j(new g.IA('"instance(id)" must be a string, number or object!')):j(new g.NER(a))}).then(function(a){return f.Promise.all(a)}).then(function(){return b})}b["default"]=d},function(a,b,c){function d(a,b){var c=this,d=c.utils,e=c.defs[a],f=c.s[a];return new d.Promise(function(g,h){if(e){b=d._(e,b),b.hasOwnProperty("notify")||(b.notify=!1);for(var i=[],j=(new Date).getTime(),k=void 0;(k=f.expiresHeap.peek())&&k.expires<j;)i.push(k.item),delete k.item,f.expiresHeap.pop();g(i)}else h(new c.errors.NER(a))}).then(function(g){if((b.isInterval||b.notify)&&(e.beforeReap(b,g),e.emit("DS.beforeReap",e,g)),"inject"===b.reapAction)!function(){var a=(new Date).getTime();d.forEach(g,function(b){f.expiresHeap.push({item:b,timestamp:a,expires:e.maxAge?a+e.maxAge:Number.MAX_VALUE})})}();else if("eject"===b.reapAction)d.forEach(g,function(b){c.eject(a,b[e.idAttribute])});else if("refresh"===b.reapAction){var h=function(){var b=[];return d.forEach(g,function(d){b.push(c.refresh(a,d[e.idAttribute]))}),{v:d.Promise.all(b)}}();if("object"==typeof h)return h.v}return g}).then(function(a){return(b.isInterval||b.notify)&&(e.afterReap(b,a),e.emit("DS.afterReap",e,a)),a})}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.errors,g=d.defs[a],h=void 0,i=void 0;return new e.Promise(function(i,j){b=e.resolveId(g,b),g?e._sn(b)?d.get(a,b)?(h=d.get(a,b),c=e._(g,c),i(h)):j(new f.R('id "'+b+'" not found in cache!')):j(e._snErr("id")):j(new f.NER(a))}).then(function(a){return c.beforeValidate.call(a,c,a)}).then(function(a){return c.validate.call(a,c,a)}).then(function(a){return c.afterValidate.call(a,c,a)}).then(function(a){return c.beforeUpdate.call(a,c,a)}).then(function(f){if(c.notify&&g.emit("DS.beforeUpdate",g,f),c.changesOnly){var h=d.s[a];e.w&&h.observers[b].deliver();var j=[],k=d.changes(a,b);for(var l in k.added)j.push(l);for(l in k.changed)j.push(l);if(k=e.pick(f,j),e.isEmpty(k))return i=!0,f;f=k}return d.getAdapter(c).update(g,b,f,c)}).then(function(a){return c.afterUpdate.call(a,c,a)}).then(function(b){if(c.notify&&g.emit("DS.afterUpdate",g,b),i)return b;if(c.cacheResponse){var f=d.inject(g.n,b,c.orig()),h=d.s[a],j=f[g.idAttribute];return h.saved[j]=e.updateTimestamp(h.saved[j]),g.resetHistoryOnInject||(h.previousAttributes[j]=e.copy(f,null,null,null,g.relationFields)),f}return d.createInstance(a,b,c.orig())})}b["default"]=d},function(a,b,c){function d(a,b,c,d){var e=this,f=e.utils,g=e.errors,h=e.defs[a];return new f.Promise(function(e,i){b=f.resolveId(h,b),h?f._sn(b)?(d=f._(h,d),e(c)):i(f._snErr("id")):i(new g.NER(a))}).then(function(a){return d.beforeValidate.call(a,d,a)}).then(function(a){return d.validate.call(a,d,a)}).then(function(a){return d.afterValidate.call(a,d,a)}).then(function(a){return d.beforeUpdate.call(a,d,a)}).then(function(a){return d.notify&&h.emit("DS.beforeUpdate",h,a),e.getAdapter(d).update(h,b,a,d)}).then(function(a){return d.afterUpdate.call(a,d,a)}).then(function(b){if(d.notify&&h.emit("DS.afterUpdate",h,b),d.cacheResponse){var c=e.inject(h.n,b,d.orig()),g=e.s[a],i=c[h.idAttribute];return g.saved[i]=f.updateTimestamp(g.saved[i]),h.resetHistoryOnInject||(g.previousAttributes[i]=f.copy(c,null,null,null,h.relationFields)),c}return e.createInstance(a,b,d.orig())})}b["default"]=d},function(a,b,c){function d(a,b,c,d){var e=this,f=e.utils,g=e.errors,h=e.defs[a];return new f.Promise(function(c,e){h?(d=f._(h,d),c(b)):e(new g.NER(a))}).then(function(a){return d.beforeValidate.call(a,d,a)}).then(function(a){return d.validate.call(a,d,a)}).then(function(a){return d.afterValidate.call(a,d,a)}).then(function(a){return d.beforeUpdate.call(a,d,a)}).then(function(a){return d.notify&&h.emit("DS.beforeUpdate",h,a),e.getAdapter(d).updateAll(h,a,c,d)}).then(function(a){return d.afterUpdate.call(a,d,a)}).then(function(c){d.notify&&h.emit("DS.afterUpdate",h,b);var g=d.orig();if(d.cacheResponse){var i=function(){var b=e.inject(h.n,c,g),d=e.s[a];return f.forEach(b,function(a){var b=a[h.idAttribute];d.saved[b]=f.updateTimestamp(d.saved[b]),h.resetHistoryOnInject||(d.previousAttributes[b]=f.copy(a,null,null,null,h.relationFields))}),{v:b}}();if("object"==typeof i)return i.v}else{var j=function(){var b=[];return f.forEach(c,function(c){b.push(e.createInstance(a,c,g))}),{v:b}}();if("object"==typeof j)return j.v}})}b["default"]=d},function(a,b,c){function d(a){return null==a?"":a.toString()}a.exports=d},function(a,b,c){function d(a){return a=e(a),a=f(a),a=g(a).replace(/[\-_]/g," ").replace(/\s[a-z]/g,h).replace(/\s+/g,"").replace(/^[A-Z]/g,i)}var e=c(41),f=c(43),g=c(44),h=c(19),i=c(45);a.exports=d},function(a,b,c){function d(a){return a=e(a),a.search(/[\xC0-\xFF]/g)>-1&&(a=a.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),a}var e=c(41);a.exports=d},function(a,b,c){function d(a){return a=e(a),a.replace(f,"")}var e=c(41),f=/[^\x20\x2D0-9A-Z\x5Fa-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]/g;a.exports=d},function(a,b,c){function d(a){return a=e(a),a.toLowerCase()}var e=c(41);a.exports=d}])}); | ||
!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):"object"==typeof exports?exports.JSData=b():a.JSData=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){var d=c(1),e=c(2),f=c(3);a.exports={DS:d["default"],DSUtils:e["default"],DSErrors:f["default"],createStore:function(a){return new d["default"](a)},version:{full:"2.0.0-beta.2",major:parseInt("2",10),minor:parseInt("0",10),patch:parseInt("0",10),alpha:"false",beta:"2"}}},function(a,b,c){function d(a,b,c){c(null,b)}function e(a,b){return b}function f(a,b,c,d){var e=!0;a:for(;e;){k=l=m=void 0,e=!1;var f=a,g=b,h=c,j=d,k=f[g],l=i["default"].get(h,k[0]),m=i["default"].get(j,k[0]);if(i["default"]._s(l)&&(l=i["default"].upperCase(l)),i["default"]._s(m)&&(m=i["default"].upperCase(m)),"DESC"===k[1]){if(l>m)return-1;if(m>l)return 1;if(g<f.length-1){a=f,b=g+1,c=h,d=j,e=!0;continue a}return 0}if(m>l)return-1;if(l>m)return 1;if(!(g<f.length-1))return 0;a=f,b=g+1,c=h,d=j,e=!0}}var g=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),i=c(2),j=c(3),k=c(4),l=c(5),m=function(){function a(){g(this,a)}return h(a,[{key:"errorFn",value:function(a,b){if(this.error&&"function"==typeof this.error){try{throw"string"==typeof a?new Error(a):a}catch(c){a=c}this.error(this.name||null,a||null,b||null)}}}]),a}(),n=m.prototype;n.actions={},n.afterCreate=d,n.afterCreateInstance=e,n.afterDestroy=d,n.afterEject=e,n.afterInject=e,n.afterReap=e,n.afterUpdate=d,n.afterValidate=d,n.allowSimpleWhere=!0,n.basePath="",n.beforeCreate=d,n.beforeCreateInstance=e,n.beforeDestroy=d,n.beforeEject=e,n.beforeInject=e,n.beforeReap=e,n.beforeUpdate=d,n.beforeValidate=d,n.bypassCache=!1,n.cacheResponse=!!i["default"].w,n.defaultAdapter="http",n.debug=!0,n.eagerEject=!1,n.eagerInject=!1,n.endpoint="",n.error=console?function(a,b,c){return console["function"==typeof console.error?"error":"log"](a,b,c)}:!1,n.fallbackAdapters=["http"],n.findStrictCache=!1,n.idAttribute="id",n.ignoredChanges=[/\$/],n.ignoreMissing=!1,n.keepChangeHistory=!1,n.linkRelations=!0,n.log=console?function(a,b,c,d,e){return console["function"==typeof console.info?"info":"log"](a,b,c,d,e)}:!1,n.logFn=function(a,b,c,d){var e=this;e.debug&&e.log&&"function"==typeof e.log&&e.log(e.name||null,a||null,b||null,c||null,d||null)},n.maxAge=!1,n.notify=!!i["default"].w,n.reapAction=i["default"].w?"inject":"none",n.reapInterval=i["default"].w?3e4:!1,n.relationsEnumerable=!1,n.resetHistoryOnInject=!0,n.strategy="single",n.upsert=!!i["default"].w,n.useClass=!0,n.useFilter=!1,n.validate=d,n.defaultFilter=function(a,b,c,d){var e=a,g=null,h={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""};c=c||{},d=d||{},g=i["default"]._o(c.where)?c.where:{},d.allowSimpleWhere&&i["default"].forOwn(c,function(a,b){b in h||b in g||(g[b]={"==":a})}),i["default"].isEmpty(g)&&(g=null),g&&(e=i["default"].filter(e,function(a){var b=!0,c=!0;return i["default"].forOwn(g,function(d,e){i["default"]._s(d)?d={"===":d}:(i["default"]._n(d)||i["default"].isBoolean(d))&&(d={"==":d}),i["default"]._o(d)&&i["default"].forOwn(d,function(d,f){var g=void 0,h="|"===f[0],j=a[e];f=h?f.substr(1):f,"=="===f?g=j==d:"==="===f?g=j===d:"!="===f?g=j!=d:"!=="===f?g=j!==d:">"===f?g=j>d:">="===f?g=j>=d:"<"===f?g=d>j:"<="===f?g=d>=j:"isectEmpty"===f?g=!i["default"].intersection(j||[],d||[]).length:"isectNotEmpty"===f?g=i["default"].intersection(j||[],d||[]).length:"in"===f?g=i["default"]._s(d)?-1!==d.indexOf(j):i["default"].contains(d,j):"notIn"===f?g=i["default"]._s(d)?-1===d.indexOf(j):!i["default"].contains(d,j):"contains"===f?g=i["default"]._s(j)?-1!==j.indexOf(d):i["default"].contains(j,d):"notContains"===f&&(g=i["default"]._s(j)?-1===j.indexOf(d):!i["default"].contains(j,d)),void 0!==g&&(c=b?g:h?c||g:c&&g),b=!1})}),c}));var k=null;i["default"]._s(c.orderBy)?k=[[c.orderBy,"ASC"]]:i["default"]._a(c.orderBy)&&(k=c.orderBy),!k&&i["default"]._s(c.sort)?k=[[c.sort,"ASC"]]:!k&&i["default"]._a(c.sort)&&(k=c.sort),k&&!function(){var a=0;i["default"].forEach(k,function(a,c){if(i["default"]._s(a))k[c]=[a,"ASC"];else if(!i["default"]._a(a))throw new j["default"].IA('DS.filter("'+b+'"[, params][, options]): '+i["default"].toJson(a)+": Must be a string or an array!",{params:{"orderBy[i]":{actual:typeof a,expected:"string|array"}}})}),e=i["default"].sort(e,function(b,c){return f(k,a,b,c)})}();var l=i["default"]._n(c.limit)?c.limit:null,m=null;return i["default"]._n(c.skip)?m=c.skip:i["default"]._n(c.offset)&&(m=c.offset),l&&m?e=i["default"].slice(e,m,Math.min(e.length,m+l)):i["default"]._n(l)?e=i["default"].slice(e,0,Math.min(e.length,l)):i["default"]._n(m)&&(e=m<e.length?i["default"].slice(e,m):[]),e};var o=function(){function a(b){g(this,a);var c=this;b=b||{},c.store={},c.s=c.store,c.definitions={},c.defs=c.definitions,c.adapters={},c.defaults=new m,c.observe=i["default"].observe,i["default"].forOwn(b,function(a,b){c.defaults[b]=a})}return h(a,[{key:"getAdapter",value:function(a){var b=!1;a=a||{},i["default"]._s(a)&&(b=!0,a={adapter:a});var c=this.adapters[a.adapter];if(c)return c;if(b)throw new Error(""+a.adapter+" is not a registered adapter!");return this.adapters[a.defaultAdapter]}},{key:"registerAdapter",value:function(a,b,c){var d=this;c=c||{},i["default"].isFunction(b)?d.adapters[a]=new b(c):d.adapters[a]=b,c["default"]&&(d.defaults.defaultAdapter=a)}},{key:"is",value:function(a,b){var c=this.defs[a];if(!c)throw new j["default"].NER(a);return b instanceof c[c["class"]]}}]),a}(),p=o.prototype;p.getAdapter.shorthand=!1,p.registerAdapter.shorthand=!1,p.errors=j["default"],p.utils=i["default"],i["default"].deepMixIn(p,k["default"]),i["default"].deepMixIn(p,l["default"]),b["default"]=o},function(a,b,c){function d(a){var b={};a=a||this,a.on=function(a,c,d){b[a]=b[a]||[],b[a].push({f:c,c:d})},a.off=function(a,c){var d=b[a];if(d)if(c){for(var e=0;e<d.length;e++)if(d[e]===c){d.splice(e,1);break}}else d.splice(0,d.length);else b={}},a.emit=function(){for(var a=arguments.length,c=Array(a),d=0;a>d;d++)c[d]=arguments[d];var e=b[c.shift()]||[];if(e)for(var f=0;f<e.length;f++)e[f].f.apply(e[f].c,c)}}var e=c(3),f=c(7),g=c(8),h=c(9),i=c(13),j=c(10),k=c(14),l=c(18),m=c(11),n=c(15),o=c(12),p=c(19),q=c(16),r=c(17),s=c(6),t=void 0,u=Object.prototype,v=u.toString,w=void 0;try{w=Promise}catch(x){console.error("js-data requires a global Promise constructor!")}var y=Array.isArray||function(a){return"[object Array]"==v.call(a)||!1},z=function(a){return"[object RegExp]"==v.call(a)||!1},A=function(a){return a===!0||a===!1||a&&"object"==typeof a&&"[object Boolean]"==v.call(a)||!1},B=function(a){return"string"==typeof a||a&&"object"==typeof a&&"[object String]"==v.call(a)||!1},C=function(a){return"[object Object]"==v.call(a)||!1},D=function(a){return a&&"object"==typeof a&&"[object Date]"==v.call(a)||!1},E=function(a){var b=typeof a;return"number"==b||a&&"object"==b&&"[object Number]"==v.call(a)||!1},F=function(a){return"function"==typeof a||a&&"[object Function]"===v.call(a)||!1},G=function(a){return B(a)||E(a)},H=function(a){return new e["default"].IA('"'+a+'" must be a string or a number!')},I=function(a){return new e["default"].IA('"'+a+'" must be an object!')},J=function(a){return new e["default"].IA('"'+a+'" must be an array!')},K=function(a){if(null==a)return!0;if("string"==typeof a||y(a))return!a.length;if("object"!=typeof a)return!0;var b=function(){var b=!0;return i(a,function(){return b=!1,!1}),{v:b}}();return"object"==typeof b?b.v:void 0},L=function(a,b){if(!a||!b)return[];for(var c=[],d=void 0,e=0,f=a.length;f>e;e++)d=a[e],j(c,d)||j(b,d)&&c.push(d);return c},M=function(a,b,c){var d=[];return g(a,function(a,c,e){b(a,c,e)&&d.push(a)},c),d};try{t=window,t={}}catch(N){t=null}var O=["beforeValidate","validate","afterValidate","beforeCreate","afterCreate","beforeUpdate","afterUpdate","beforeDestroy","afterDestroy"],P=function(a,b){var c=void 0;if(!b||!b.length)return!1;for(c=0;c<b.length;c++)if(b[c]===a)return!0;return!1},Q=function(a){function b(b,c,d,e,f){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a,b,c,d,e){if(b){if(a===b)throw new Error("Cannot copy! Source and destination are identical.");if(c=c||[],d=d||[],C(a)){var f=c.indexOf(a);if(-1!==f)return d[f];c.push(a),d.push(b)}var h=void 0;if(y(a)){var i=void 0;for(b.length=0,i=0;i<a.length;i++)h=Q(a[i],null,c,d,e),C(a[i])&&(c.push(a[i]),d.push(h)),b.push(h)}else{y(b)?b.length=0:g(b,function(a,c){delete b[c]});for(var j in a)if(a.hasOwnProperty(j)){if(P(j,e))continue;h=Q(a[j],null,c,d,e),C(a[j])&&(c.push(a[j]),d.push(h)),b[j]=h}}}else b=a,a&&(y(a)?b=Q(a,[],c,d,e):D(a)?b=new Date(a.getTime()):z(a)?(b=new RegExp(a.source,a.toString().match(/[^\/]*$/)[0]),b.lastIndex=a.lastIndex):C(a)&&(b=Q(a,Object.create(Object.getPrototypeOf(a)),c,d,e)));return b}),R=function(a){function b(b,c){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a,b){if(a===b)return!0;if(null===a||null===b)return!1;if(a!==a&&b!==b)return!0;var c,d,e,f=typeof a,g=typeof b;if(f==g&&"object"==f){if(!y(a)){if(D(a))return D(b)?R(a.getTime(),b.getTime()):!1;if(z(a)&&z(b))return a.toString()==b.toString();if(y(b))return!1;e={};for(d in a)if("$"!==d.charAt(0)&&!F(a[d])){if(!R(a[d],b[d]))return!1;e[d]=!0}for(d in b)if(!e.hasOwnProperty(d)&&"$"!==d.charAt(0)&&void 0!==b[d]&&!F(b[d]))return!1;return!0}if(!y(b))return!1;if((c=a.length)==b.length){for(d=0;c>d;d++)if(!R(a[d],b[d]))return!1;return!0}}return!1}),S=function(a,b){return B(b)||E(b)?b:b&&a?b[a.idAttribute]||b:b},T=function(a,b){return a&&(B(b)||E(b))?a.index[b]||b:b},U=function(a){return null!=a&&""!==a},V=function(a,b){return b=b||"",M(a,U).join(b)},W=function(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=V(b,"/");return d.replace(/([^:\/]|^)\/{2,}/g,"$1/")};b["default"]={Promise:w,_:function(a,b){var c=this;if(b=b||{},b&&b.constructor===a.constructor)return b;if(!C(b))throw new e["default"].IA('"options" must be an object!');g(O,function(a){"function"==typeof b[a]&&-1===b[a].toString().indexOf("for (var _len = arg")&&(b[a]=c.promisify(b[a]))});var d=function(a){var b=this;i(a,function(a,c){b[c]=a})};return d.prototype=a,d.prototype.orig=function(){var a={};return i(this,function(b,c){a[c]=b}),a},new d(b)},_n:E,_s:B,_sn:G,_snErr:H,_o:C,_oErr:I,_a:y,_aErr:J,compute:function(a,b){var c=this,d=[];g(a.deps,function(a){d.push(q(c,a))}),r(c,b,a[a.length-1].apply(c,d))},contains:j,copy:Q,deepMixIn:k,diffObjectFromOldObject:s.diffObjectFromOldObject,BinaryHeap:f,equals:R,Events:d,filter:M,forEach:g,forOwn:i,fromJson:function(a){return B(a)?JSON.parse(a):a},get:q,intersection:L,isArray:y,isBoolean:A,isDate:D,isEmpty:K,isFunction:F,isObject:C,isNumber:E,isRegExp:z,isString:B,makePath:W,observe:s,pascalCase:l,pick:n,promisify:function(a,b){var c=this;if(a){if("function"!=typeof a)throw new Error("Can only promisify functions!");return function(){for(var d=arguments.length,e=Array(d),f=0;d>f;f++)e[f]=arguments[f];return new c.Promise(function(c,d){e.push(function(a,b){a?d(a):c(b)});try{var f=a.apply(b||this,e);f&&f.then&&f.then(c,d)}catch(g){d(g)}})}}},remove:m,set:r,slice:h,sort:o,toJson:JSON.stringify,updateTimestamp:function(a){var b="function"==typeof Date.now?Date.now():(new Date).getTime();return a&&a>=b?a+1:b},upperCase:p,removeCircular:function(a){return function b(a,c){var d=void 0,e=void 0;if(!("object"!=typeof a||null===a||a instanceof Boolean||a instanceof Date||a instanceof Number||a instanceof RegExp||a instanceof String)){for(var f=c.current,g=c.context;g;){if(g.current===f)return void 0;g=g.context}if(y(a))for(e=[],d=0;d<a.length;d+=1)e[d]=b(a[d],{context:c,current:a[d]});else e={},i(a,function(d,f){e[f]=b(a[f],{context:c,current:a[f]})});return e}return a}(a,{context:null,current:a})},resolveItem:T,resolveId:S,w:t,applyRelationGettersToTarget:function(a,b,c){this.forEach(b.relationList,function(d){var e=d.relation,f="boolean"==typeof d.enumerable?d.enumerable:!!b.relationsEnumerable;("boolean"==typeof d.link?d.link:!!b.linkRelations)&&(delete c[d.localField],"belongsTo"===d.type?Object.defineProperty(c,d.localField,{enumerable:f,get:function(){return this[d.localKey]?b.getResource(e).get(this[d.localKey]):void 0},set:function(){}}):"hasMany"===d.type?Object.defineProperty(c,d.localField,{enumerable:f,get:function(){var c={};return c[d.foreignKey]=this[b.idAttribute],c[d.foreignKey]?a.defaults.constructor.prototype.defaultFilter.call(a,a.s[e].collection,e,c,{allowSimpleWhere:!0}):void 0},set:function(){}}):"hasOne"===d.type&&(d.localKey?Object.defineProperty(c,d.localField,{enumerable:f,get:function(){return this[d.localKey]?b.getResource(e).get(this[d.localKey]):void 0},set:function(){}}):Object.defineProperty(c,d.localField,{enumerable:f,get:function(){var c={};c[d.foreignKey]=this[b.idAttribute];var f=c[d.foreignKey]?a.defaults.constructor.prototype.defaultFilter.call(a,a.s[e].collection,e,c,{allowSimpleWhere:!0}):[];return f.length?f[0]:void 0},set:function(){}})))})}}},function(a,b,c){var d=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},e=function(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(a.__proto__=b)},f=function(a){function b(c){d(this,b);var e=new a(e);return e.__proto__=b.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(e,e.constructor),e.type=e.constructor.name,e.message=c||"Illegal Argument!",e}return e(b,a),b}(Error),g=function(a){function b(c){d(this,b);var e=new a(e);return e.__proto__=b.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(e,e.constructor),e.type=e.constructor.name,e.message=c||"RuntimeError Error!",e}return e(b,a),b}(Error),h=function(a){function b(c){d(this,b);var e=new a(e);return e.__proto__=b.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(e,e.constructor),e.type=e.constructor.name,e.message=""+c+" is not a registered resource!",e}return e(b,a),b}(Error);b["default"]={IllegalArgumentError:f,IA:f,RuntimeError:g,R:g,NonexistentResourceError:h,NER:h}},function(a,b,c){function d(a){return!(e["default"].isEmpty(a.added)&&e["default"].isEmpty(a.removed)&&e["default"].isEmpty(a.changed))}var e=c(2),f=c(3),g=c(28),h=c(29),i=c(30),j=c(31),k=c(32),l=f["default"].NER,m=f["default"].IA,n=f["default"].R;b["default"]={changes:function(a,b,c){var d=this,f=d.defs[a];if(c=c||{},b=e["default"].resolveId(f,b),!f)throw new l(a);if(!e["default"]._sn(b))throw e["default"]._snErr("id");c=e["default"]._(f,c);var g=d.get(a,b);if(g){var h=function(){e["default"].w&&d.s[a].observers[b].deliver();var h=c.ignoredChanges||[];e["default"].forEach(f.relationFields,function(a){return h.push(a)});var i=e["default"].diffObjectFromOldObject(g,d.s[a].previousAttributes[b],e["default"].equals,h);return e["default"].forOwn(i,function(a,b){var c=[];e["default"].forOwn(a,function(a,b){e["default"].isFunction(a)||c.push(b)}),i[b]=e["default"].pick(i[b],c)}),e["default"].forEach(f.relationFields,function(a){delete i.added[a],delete i.removed[a],delete i.changed[a]}),{v:i}}();if("object"==typeof h)return h.v}},changeHistory:function(a,b){var c=this,d=c.defs[a],f=c.s[a];if(b=e["default"].resolveId(d,b),a&&!c.defs[a])throw new l(a);if(b&&!e["default"]._sn(b))throw e["default"]._snErr("id");if(d.keepChangeHistory){if(!a)return f.changeHistory;var g=c.get(a,b);if(g)return f.changeHistories[b]}else d.errorFn("changeHistory is disabled for this resource!")},compute:function(a,b){var c=this,d=c.defs[a];if(b=e["default"].resolveItem(c.s[a],b),!d)throw new l(a);if(!b)throw new n("Item not in the store!");if(!e["default"]._o(b)&&!e["default"]._sn(b))throw new m('"instance" must be an object, string or number!');return e["default"].forOwn(d.computed,function(a,c){e["default"].compute.call(b,a,c)}),b},createInstance:function(a,b,c){var d=this.defs[a],f=void 0;if(b=b||{},!d)throw new l(a);if(b&&!e["default"].isObject(b))throw new m('"attrs" must be an object!');c=e["default"]._(d,c),c.notify&&c.beforeCreateInstance(c,b);var g=d[d["class"]];return f=new g,e["default"].deepMixIn(f,b),d.computed&&this.compute(d.name,f),c.notify&&c.afterCreateInstance(c,f),f},defineResource:g["default"],digest:function(){this.observe.Platform.performMicrotaskCheckpoint()},eject:h["default"],ejectAll:i["default"],filter:j["default"],get:function(a,b,c){var d=this,f=d.defs[a];if(!f)throw new l(a);if(!e["default"]._sn(b))throw e["default"]._snErr("id");c=e["default"]._(f,c);var g=d.s[a].index[b];return g},getAll:function(a,b){var c=this,d=c.defs[a],f=c.s[a],g=[];if(!d)throw new l(a);if(b&&!e["default"]._a(b))throw e["default"]._aErr("ids");if(e["default"]._a(b))for(var h=b.length,i=0;h>i;i++)f.index[b[i]]&&g.push(f.index[b[i]]);else g=f.collection.slice();return g},hasChanges:function(a,b){var c=this,f=c.defs[a];if(b=e["default"].resolveId(f,b),!f)throw new l(a);if(!e["default"]._sn(b))throw e["default"]._snErr("id");return c.get(a,b)?d(c.changes(a,b)):!1},inject:k["default"],lastModified:function(a,b){var c=this.defs[a],d=this.s[a];if(b=e["default"].resolveId(c,b),!c)throw new l(a);return b?(b in d.modified||(d.modified[b]=0),d.modified[b]):d.collectionModified},lastSaved:function(a,b){var c=this.defs[a],d=this.s[a];if(b=e["default"].resolveId(c,b),!c)throw new l(a);return b in d.saved||(d.saved[b]=0),d.saved[b]},previous:function(a,b){var c=this,d=c.defs[a],f=c.s[a];if(b=e["default"].resolveId(d,b),!d)throw new l(a);if(!e["default"]._sn(b))throw e["default"]._snErr("id");return f.previousAttributes[b]?e["default"].copy(f.previousAttributes[b]):void 0}}},function(a,b,c){var d=c(33),e=c(34),f=c(35),g=c(36),h=c(37),i=c(38),j=c(39),k=c(40),l=c(41),m=c(42);b["default"]={create:d["default"],destroy:e["default"],destroyAll:f["default"],find:g["default"],findAll:h["default"],loadRelations:i["default"],reap:j["default"],refresh:function(a,b,c){var d=this,e=d.utils;return new e.Promise(function(f,g){var h=d.defs[a];b=e.resolveId(d.defs[a],b),h?e._sn(b)?(c=e._(h,c),c.bypassCache=!0,f(d.get(a,b))):g(e._snErr("id")):g(new d.errors.NER(a))}).then(function(e){return e?d.find(a,b,c):e})},save:k["default"],update:l["default"],updateAll:m["default"]}},function(a,b,c){!function(a){function b(){function a(a){b=a}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=[],c={},d=[];return Object.observe(c,a),Array.observe(d,a),c.id=1,c.id=2,delete c.id,d.push(1,2),d.length=0,Object.deliverChangeRecords(a),5!==b.length?!1:"add"!=b[0].type||"update"!=b[1].type||"delete"!=b[2].type||"splice"!=b[3].type||"splice"!=b[4].type?!1:(Object.unobserve(c,a),Array.unobserve(d,a),!0)}function c(b){for(var c=0;s>c&&b.check_();)c++;return p&&(a.dirtyCheckCycleCount=c),c>0}function d(a){for(var b in a)return!1;return!0}function e(a){return d(a.added)&&d(a.removed)&&d(a.changed)}function f(a,b){if(!b||!b.length)return!1;for(var c,d=0;d<b.length;d++)if("[object RegExp]"===Object.prototype.toString.call(b[d])&&b[d].test(a)||b[d]===a)return c=a;return!!c}function g(a,b,c,d){var e={},g={},h={};for(var i in b){var j=a[i];f(i,d)||void 0!==j&&(c?c(j,b[i]):j===b[i])||(i in a?(c?c(j,b[i]):j===b[i])||(h[i]=j):g[i]=void 0)}for(var i in a)i in b||f(i,d)||(e[i]=a[i]);return Array.isArray(a)&&a.length!==b.length&&(h.length=a.length),{added:e,removed:g,changed:h}}function h(){if(!t.length)return!1;for(var a=0;a<t.length;a++)t[a]();return t.length=0,!0}function i(){function a(a){b&&b.state_===x&&!d&&b.check_(a)}var b,c,d=!1,e=!0;return{open:function(c){if(b)throw Error("ObservedObject in use");e||Object.deliverChangeRecords(a),b=c,e=!1},observe:function(b,d){c=b,d?Array.observe(c,a):Object.observe(c,a)},deliver:function(b){d=b,Object.deliverChangeRecords(a),d=!1},close:function(){b=void 0,Object.unobserve(c,a),v.push(this)}}}function j(a,b,c){var d=v.pop()||i();return d.open(a),d.observe(b,c),d}function k(){this.state_=w,this.callback_=void 0,this.target_=void 0,this.directObserver_=void 0,this.value_=void 0,this.id_=z++}function l(a){k._allObserversCount++,B&&A.push(a)}function m(a){k._allObserversCount--}function n(a){k.call(this),this.value_=a,this.oldObject_=void 0}function o(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];E[g.type]?(g.name in c||(c[g.name]=g.oldValue),"update"!=g.type&&("add"!=g.type?g.name in d?(delete d[g.name],delete c[g.name]):e[g.name]=!0:g.name in e?delete e[g.name]:d[g.name]=!0)):(console.error("Unknown changeRecord type: "+g.type),console.error(g))}for(var h in d)d[h]=a[h];for(var h in e)e[h]=void 0;var i={};for(var h in c)if(!(h in d||h in e)){var j=a[h];c[h]!==j&&(i[h]=j)}return{added:d,removed:e,changed:i}}var p=a.testingExposeCycleCount,q=b(),r="__proto__"in{}?function(a){return a}:function(a){var b=a.__proto__;if(!b)return a;var c=Object.create(b);return Object.getOwnPropertyNames(a).forEach(function(b){Object.defineProperty(c,b,Object.getOwnPropertyDescriptor(a,b))}),c},s=1e3,t=[],u=q?function(){return function(a){return Promise.resolve().then(a)}}():function(){return function(a){t.push(a)}}(),v=[],w=0,x=1,y=2,z=1;k.prototype={open:function(a,b){if(this.state_!=w)throw Error("Observer has already been opened.");return l(this),this.callback_=a,this.target_=b,this.connect_(),this.state_=x,this.value_},close:function(){this.state_==x&&(m(this),this.disconnect_(),this.value_=void 0,this.callback_=void 0,this.target_=void 0,this.state_=y)},deliver:function(){this.state_==x&&c(this)},report_:function(a){try{this.callback_.apply(this.target_,a)}catch(b){k._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+(b.stack||b))}},discardChanges:function(){return this.check_(void 0,!0),this.value_}};var A,B=!q;k._allObserversCount=0,B&&(A=[]);var C=!1;a.Platform=a.Platform||{},a.Platform.performMicrotaskCheckpoint=function(){if(!C&&B){C=!0;var b,c,d=0;do{d++,c=A,A=[],b=!1;for(var e=0;e<c.length;e++){var f=c[e];f.state_==x&&(f.check_()&&(b=!0),A.push(f))}h()&&(b=!0)}while(s>d&&b);p&&(a.dirtyCheckCycleCount=d),C=!1}},B&&(a.Platform.clearObservers=function(){A=[]}),n.prototype=r({__proto__:k.prototype,arrayObserve:!1,connect_:function(a,b){q?this.directObserver_=j(this,this.value_,this.arrayObserve):this.oldObject_=this.copyObject(this.value_)},copyObject:function(a){var b=Array.isArray(a)?[]:{};for(var c in a)b[c]=a[c];return Array.isArray(a)&&(b.length=a.length),b},check_:function(a,b){var c,d;if(q){if(!a)return!1;d={},c=o(this.value_,a,d)}else d=this.oldObject_,c=g(this.value_,this.oldObject_);return e(c)?!1:(q||(this.oldObject_=this.copyObject(this.value_)),this.report_([c.added||{},c.removed||{},c.changed||{},function(a){return d[a]}]),!0)},disconnect_:function(){q?(this.directObserver_.close(),this.directObserver_=void 0):this.oldObject_=void 0},deliver:function(){this.state_==x&&(q?this.directObserver_.deliver(!1):c(this))},discardChanges:function(){return this.directObserver_?this.directObserver_.deliver(!0):this.oldObject_=this.copyObject(this.value_),this.value_}});var D={},E={add:!0,update:!0,"delete":!0};a.Observer=k,a.Observer.runEOM_=u,a.Observer.observerSentinel_=D,a.Observer.hasObjectObserve=q,a.diffObjectFromOldObject=g,a.ObjectObserver=n}(b)},function(a,b,c){!function(b,c){a.exports=c()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){function d(a,b,c){for(var d=a[c],e=b(d);c>0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}var e=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(b,"__esModule",{value:!0});var g=function(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}},h=function(){function a(b,c){if(e(this,a),b||(b=function(a){return a}),c||(c=function(a,b){return a===b}),"function"!=typeof b)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof c)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=b,this.compareFunc=c,this.heap=[]}return f(a,[{key:"push",value:function(a){this.heap.push(a),d(this.heap,this.weightFunc,this.heap.length-1)}},{key:"peek",value:function(){return this.heap[0]}},{key:"pop",value:function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,g(this.heap,this.weightFunc,0)),a}},{key:"remove",value:function(a){for(var b=this.heap.length,c=0;b>c;c++)if(this.compareFunc(this.heap[c],a)){var e=this.heap[c],f=this.heap.pop();return c!==b-1&&(this.heap[c]=f,d(this.heap,this.weightFunc,c),g(this.heap,this.weightFunc,c)),e}return null}},{key:"removeAll",value:function(){this.heap=[]}},{key:"size",value:function(){return this.heap.length}}]),a}();b["default"]=h,a.exports=b["default"]}])})},function(a,b,c){function d(a,b,c){if(null!=a)for(var d=-1,e=a.length;++d<e&&b.call(c,a[d],d,a)!==!1;);}a.exports=d},function(a,b,c){function d(a,b,c){var d=a.length;b=null==b?0:0>b?Math.max(d+b,0):Math.min(b,d),c=null==c?d:0>c?Math.max(d+c,0):Math.min(c,d);for(var e=[];c>b;)e.push(a[b++]);return e}a.exports=d},function(a,b,c){function d(a,b){return-1!==e(a,b)}var e=c(20);a.exports=d},function(a,b,c){function d(a,b){var c=e(a,b);-1!==c&&a.splice(c,1)}var e=c(20);a.exports=d},function(a,b,c){function d(a,b){if(null==a)return[];if(a.length<2)return a;null==b&&(b=e);var c,g,h;return c=~~(a.length/2),g=d(a.slice(0,c),b),h=d(a.slice(c,a.length),b),f(g,h,b)}function e(a,b){return b>a?-1:a>b?1:0}function f(a,b,c){for(var d=[];a.length&&b.length;)d.push(c(a[0],b[0])<=0?a.shift():b.shift());return a.length&&d.push.apply(d,a),b.length&&d.push.apply(d,b),d}a.exports=d},function(a,b,c){function d(a,b,c){f(a,function(d,f){return e(a,f)?b.call(c,a[f],f,a):void 0})}var e=c(21),f=c(22);a.exports=d},function(a,b,c){function d(a,b){for(var c,d=0,g=arguments.length;++d<g;)c=arguments[d],c&&f(c,e,a);return a}function e(a,b){var c=this[b];g(a)&&g(c)?d(c,a):this[b]=a}var f=c(13),g=c(23);a.exports=d},function(a,b,c){function d(a,b){for(var c,d="string"!=typeof arguments[1]?arguments[1]:e(arguments,1),f={},g=0;c=d[g++];)f[c]=a[c];return f}var e=c(9);a.exports=d},function(a,b,c){function d(a,b){for(var c=b.split("."),d=c.pop();b=c.shift();)if(a=a[b],null==a)return;return a[d]}c(24);a.exports=d},function(a,b,c){function d(a,b,c){var d=/^(.+)\.(.+)$/.exec(b);d?e(a,d[1])[d[2]]=c:a[b]=c}var e=c(25);a.exports=d},function(a,b,c){function d(a){return a=e(a),f(a).replace(/^[a-z]/,g)}var e=c(26),f=c(27),g=c(19);a.exports=d},function(a,b,c){function d(a){return a=e(a),a.toUpperCase()}var e=c(26);a.exports=d},function(a,b,c){function d(a,b,c){if(c=c||0,null==a)return-1;for(var d=a.length,e=0>c?d+c:c;d>e;){if(a[e]===b)return e;e++}return-1}a.exports=d},function(a,b,c){function d(a,b){return Object.prototype.hasOwnProperty.call(a,b)}a.exports=d},function(a,b,c){function d(){h=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],g=!0;for(var a in{toString:null})g=!1}function e(a,b,c){var e,j=0;null==g&&d();for(e in a)if(f(b,a,e,c)===!1)break;if(g)for(var k=a.constructor,l=!!k&&a===k.prototype;(e=h[j++])&&("constructor"===e&&(l||!i(a,e))||a[e]===Object.prototype[e]||f(b,a,e,c)!==!1););}function f(a,b,c,d){return a.call(d,b[c],c,b)}var g,h,i=c(21);a.exports=e},function(a,b,c){function d(a){return!!a&&"object"==typeof a&&a.constructor===Object}a.exports=d},function(a,b,c){function d(a){switch(typeof a){case"string":case"number":case"boolean":return!0}return null==a}a.exports=d},function(a,b,c){function d(a,b){return b?(e(b.split("."),function(b){a[b]||(a[b]={}),a=a[b]}),a):a}var e=c(8);a.exports=d},function(a,b,c){function d(a){return null==a?"":a.toString()}a.exports=d},function(a,b,c){function d(a){return a=e(a),a=f(a),a=g(a).replace(/[\-_]/g," ").replace(/\s[a-z]/g,h).replace(/\s+/g,"").replace(/^[A-Z]/g,i)}var e=c(26),f=c(43),g=c(44),h=c(19),i=c(45);a.exports=d},function(module,exports,__webpack_require__){function defineResource(definition){var _this=this,definitions=_this.defs;if(_DSUtils["default"]._s(definition)&&(definition={name:definition.replace(/\s/gi,"")}),!_DSUtils["default"]._o(definition))throw _DSUtils["default"]._oErr("definition");if(!_DSUtils["default"]._s(definition.name))throw new _DSErrors["default"].IA('"name" must be a string!');if(_this.s[definition.name])throw new _DSErrors["default"].R(""+definition.name+" is already registered!");try{var def,_class,_ret=function(){if(Resource.prototype=_this.defaults,definitions[definition.name]=new Resource(definition),def=definitions[definition.name],def.n=def.name,!_DSUtils["default"]._s(def.idAttribute))throw new _DSErrors["default"].IA('"idAttribute" must be a string!');def.relations&&(def.relationList=[],def.relationFields=[],_DSUtils["default"].forOwn(def.relations,function(a,b){_DSUtils["default"].forOwn(a,function(c,d){_DSUtils["default"]._a(c)||(a[d]=[c]),_DSUtils["default"].forEach(a[d],function(a){a.type=b,a.relation=d,a.name=def.n,def.relationList.push(a),a.localField&&def.relationFields.push(a.localField)})})}),def.relations.belongsTo&&_DSUtils["default"].forOwn(def.relations.belongsTo,function(a,b){_DSUtils["default"].forEach(a,function(a){a.parent&&(def.parent=b,def.parentKey=a.localKey,def.parentField=a.localField)})}),"function"==typeof Object.freeze&&(Object.freeze(def.relations),Object.freeze(def.relationList))),def.getResource=function(a){return _this.defs[a]},def.getEndpoint=function(a,b){b.params=b.params||{};var c=void 0,d=def.parentKey,e=b.hasOwnProperty("endpoint")?b.endpoint:def.endpoint,f=def.parentField,g=definitions[def.parent],h=b.params[d];if(h===!1||!d||!g)return h===!1&&delete b.params[d],e;if(delete b.params[d],_DSUtils["default"]._sn(a)?c=def.get(a):_DSUtils["default"]._o(a)&&(c=a),c&&(h=h||c[d]||(c[f]?c[f][g.idAttribute]:null)),!h)return e;var i=function(){delete b.endpoint;var a={};return _DSUtils["default"].forOwn(b,function(b,c){a[c]=b}),{v:_DSUtils["default"].makePath(g.getEndpoint(h,_DSUtils["default"]._(g,a)),h,e)}}();return"object"==typeof i?i.v:void 0},def.filter&&(def.defaultFilter=def.filter,delete def.filter),_class=def["class"]=_DSUtils["default"].pascalCase(def.name);try{"function"==typeof def.useClass?(eval("function "+_class+"() { def.useClass.call(this); }"),def[_class]=eval(_class),def[_class].prototype=function(a){function b(){}return b.prototype=a,new b}(def.useClass.prototype)):(eval("function "+_class+"() {}"),def[_class]=eval(_class))}catch(e){def[_class]=function(){}}def.methods&&_DSUtils["default"].deepMixIn(def[_class].prototype,def.methods),def[_class].prototype.set=function(a,b){return _DSUtils["default"].set(this,a,b),_this.compute(def.n,this),this},def[_class].prototype.get=function(a){return _DSUtils["default"].get(this,a)},_DSUtils["default"].applyRelationGettersToTarget(_this,def,def[_class].prototype),def.computed&&_DSUtils["default"].forOwn(def.computed,function(a,b){ | ||
_DSUtils["default"].isFunction(a)&&(def.computed[b]=[a],a=def.computed[b]),def.methods&&b in def.methods&&def.errorFn('Computed property "'+b+'" conflicts with previously defined prototype method!');var c;if(1===a.length){var d=a[0].toString().match(/function.*?\(([\s\S]*?)\)/);c=d[1].split(","),def.computed[b]=c.concat(a),a=def.computed[b],c.length&&def.errorFn("Use the computed property array syntax for compatibility with minified code!")}c=a.slice(0,a.length-1),_DSUtils["default"].forEach(c,function(a,b){c[b]=a.trim()}),a.deps=_DSUtils["default"].filter(c,function(a){return!!a})}),_DSUtils["default"].forEach(instanceMethods,function(a){def[_class].prototype["DS"+_DSUtils["default"].pascalCase(a)]=function(){for(var b=arguments.length,c=Array(b),d=0;b>d;d++)c[d]=arguments[d];return c.unshift(this[def.idAttribute]||this),c.unshift(def.n),_this[a].apply(_this,c)}}),def[_class].prototype.DSCreate=function(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return b.unshift(this),b.unshift(def.n),_this.create.apply(_this,b)},_this.s[def.n]={collection:[],expiresHeap:new _DSUtils["default"].BinaryHeap(function(a){return a.expires},function(a,b){return a.item===b}),completedQueries:{},queryData:{},pendingQueries:{},index:{},modified:{},saved:{},previousAttributes:{},observers:{},changeHistories:{},changeHistory:[],collectionModified:0},def.reapInterval&&setInterval(function(){return _this.reap(def.n,{isInterval:!0})},def.reapInterval);var fns=["registerAdapter","getAdapter","is"];for(key in _this)"function"==typeof _this[key]&&fns.push(key);_DSUtils["default"].forEach(fns,function(a){var b=a;_this[b].shorthand!==!1?def[b]=function(){for(var a=arguments.length,c=Array(a),d=0;a>d;d++)c[d]=arguments[d];return c.unshift(def.n),_this[b].apply(_this,c)}:def[b]=function(){for(var a=arguments.length,c=Array(a),d=0;a>d;d++)c[d]=arguments[d];return _this[b].apply(_this,c)}}),def.beforeValidate=_DSUtils["default"].promisify(def.beforeValidate),def.validate=_DSUtils["default"].promisify(def.validate),def.afterValidate=_DSUtils["default"].promisify(def.afterValidate),def.beforeCreate=_DSUtils["default"].promisify(def.beforeCreate),def.afterCreate=_DSUtils["default"].promisify(def.afterCreate),def.beforeUpdate=_DSUtils["default"].promisify(def.beforeUpdate),def.afterUpdate=_DSUtils["default"].promisify(def.afterUpdate),def.beforeDestroy=_DSUtils["default"].promisify(def.beforeDestroy),def.afterDestroy=_DSUtils["default"].promisify(def.afterDestroy);var defaultAdapter=void 0;return def.hasOwnProperty("defaultAdapter")&&(defaultAdapter=def.defaultAdapter),_DSUtils["default"].forOwn(def.actions,function(a,b){if(def[b]&&!def.actions[b])throw new Error('Cannot override existing method "'+b+'"!');def[b]=function(c,d){_DSUtils["default"]._o(c)&&(d=c),d=d||{};var e=_this.getAdapter(a.adapter||defaultAdapter||"http"),f=_DSUtils["default"].deepMixIn({},a);if(!d.hasOwnProperty("endpoint")&&f.endpoint&&(d.endpoint=f.endpoint),"function"==typeof d.getEndpoint)f.url=d.getEndpoint(def,d);else{var g=[d.basePath||e.defaults.basePath||def.basePath,def.getEndpoint(_DSUtils["default"]._sn(c)?c:null,d)];_DSUtils["default"]._sn(c)&&g.push(c),g.push(a.pathname||b),f.url=_DSUtils["default"].makePath.apply(null,g)}return f.method=f.method||"GET",_DSUtils["default"].deepMixIn(f,d),e.HTTP(f)}}),_DSUtils["default"].Events(def),{v:def}}();if("object"==typeof _ret)return _ret.v}catch(err){throw delete definitions[definition.name],delete _this.s[definition.name],err}}var _classCallCheck=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")};exports["default"]=defineResource;var _DSUtils=__webpack_require__(2),_DSErrors=__webpack_require__(3),Resource=function a(b){_classCallCheck(this,a),_DSUtils["default"].deepMixIn(this,b),"endpoint"in b?this.endpoint=b.endpoint:this.endpoint=this.name},instanceMethods=["compute","refresh","save","update","destroy","loadRelations","changeHistory","changes","hasChanges","lastModified","lastSaved","previous"]},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a],g=d.s[a],h=void 0,i=!1;if(b=e.resolveId(f,b),!f)throw new d.errors.NER(a);if(!e._sn(b))throw e._snErr("id");c=e._(f,c);for(var j=0;j<g.collection.length;j++)if(g.collection[j][f.idAttribute]==b){h=g.collection[j],g.expiresHeap.remove(h),i=!0;break}if(i){var k=function(){c.notify&&(f.beforeEject(c,h),f.emit("DS.beforeEject",f,h)),g.collection.splice(j,1),e.w&&g.observers[b].close(),delete g.observers[b],delete g.index[b],delete g.previousAttributes[b],delete g.completedQueries[b],delete g.pendingQueries[b],e.forEach(g.changeHistories[b],function(a){e.remove(g.changeHistory,a)});var a=[];return e.forOwn(g.queryData,function(b,c){b.$$injected&&e.remove(b,h),b.length||a.push(c)}),e.forEach(a,function(a){delete g.completedQueries[a],delete g.queryData[a]}),delete g.changeHistories[b],delete g.modified[b],delete g.saved[b],g.collectionModified=e.updateTimestamp(g.collectionModified),c.notify&&(f.afterEject(c,h),f.emit("DS.afterEject",f,h)),{v:h}}();if("object"==typeof k)return k.v}}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a];if(b=b||{},!f)throw new d.errors.NER(a);if(!e._o(b))throw e._oErr("params");var g=d.s[a],h=e.toJson(b),i=d.filter(f.n,b),j=[];return e.isEmpty(b)?g.completedQueries={}:delete g.completedQueries[h],e.forEach(i,function(a){a&&a[f.idAttribute]&&j.push(a[f.idAttribute])}),e.forEach(j,function(a){d.eject(f.n,a,c)}),g.collectionModified=e.updateTimestamp(g.collectionModified),i}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a];if(!f)throw new d.errors.NER(a);if(b&&!e._o(b))throw e._oErr("params");return b=b||{},c=e._(f,c),f.defaultFilter.call(d,d.s[a].collection,a,b,c)}b["default"]=d},function(a,b,c){function d(a,b,c){var d=b.n;return function(e,f,h,i,j){var k=this,l=void 0,m=i&&i(b.idAttribute)?i(b.idAttribute):k[b.idAttribute];if(g["default"].forEach(b.relationFields,function(a){delete e[a],delete f[a],delete h[a]}),(!g["default"].isEmpty(e)||!g["default"].isEmpty(f)||!g["default"].isEmpty(h)||j)&&(l=a.get(d,m),c.modified[m]=g["default"].updateTimestamp(c.modified[m]),c.collectionModified=g["default"].updateTimestamp(c.collectionModified),b.keepChangeHistory)){var n={resourceName:d,target:l,added:e,removed:f,changed:h,timestamp:c.modified[m]};c.changeHistories[m].push(n),c.changeHistory.push(n)}b.computed&&(l=l||a.get(d,m),g["default"].forOwn(b.computed,function(a,b){var c=!1;g["default"].forEach(a.deps,function(a){(a in e||a in f||a in h||!(b in l))&&(c=!0)}),c=c||!a.deps.length,c&&g["default"].compute.call(l,a,b)})),b.idAttribute in h&&b.errorFn('Doh! You just changed the primary key of an object! Your data for the "'+d+'" resource is now in an undefined (probably broken) state.')}}function e(a,b,c,f){var i=this,j=d(i,a,b,c,f),k=void 0;if(g["default"]._a(c)){k=[];for(var l=0;l<c.length;l++)k.push(e.call(i,a,b,c[l],f))}else{var m=a.computed,n=a.idAttribute;if(m&&m[n]&&!function(){var a=[];g["default"].forEach(m[n].deps,function(b){a.push(c[b])}),c[n]=m[n][m[n].length-1].apply(c,a)}(),!(n in c)){var o=new h["default"].R(""+a.n+'.inject: "attrs" must contain the property specified by "idAttribute"!');throw f.errorFn(o),o}try{g["default"].forEach(a.relationList,function(b){var d=b.relation,e=i.defs[d],j=c[b.localField];if(j){if(!e)throw new h["default"].R(""+a.n+" relation is defined but the resource is not!");if(g["default"]._a(j))!function(){var h=[];g["default"].forEach(j,function(g){if(g!==i.s[d].index[g[e.idAttribute]])try{var j=i.inject(d,g,f.orig());b.foreignKey&&(j[b.foreignKey]=c[a.idAttribute]),h.push(j)}catch(k){f.errorFn(k,"Failed to inject "+b.type+' relation: "'+d+'"!')}})}();else if(j!==i.s[d].index[j[e.idAttribute]])try{var k=i.inject(d,c[b.localField],f.orig());b.foreignKey&&(k[b.foreignKey]=c[a.idAttribute])}catch(l){f.errorFn(l,"Failed to inject "+b.type+' relation: "'+d+'"!')}}});var p=c[n],q=i.get(a.n,p),r=q?b.modified[p]:0;q?(g["default"].deepMixIn(q,c),a.resetHistoryOnInject&&(b.previousAttributes[p]=g["default"].copy(q,null,null,null,a.relationFields),b.changeHistories[p].length&&(g["default"].forEach(b.changeHistories[p],function(a){g["default"].remove(b.changeHistory,a)}),b.changeHistories[p].splice(0,b.changeHistories[p].length))),g["default"].w&&b.observers[p].deliver()):(q=c instanceof a[a["class"]]?c:new a[a["class"]],g["default"].forEach(a.relationList,function(a){delete c[a.localField]}),g["default"].deepMixIn(q,c),b.collection.push(q),b.changeHistories[p]=[],g["default"].w&&(b.observers[p]=new i.observe.ObjectObserver(q),b.observers[p].open(j,q)),b.index[p]=q,j.call(q,{},{},{},null,!0),b.previousAttributes[p]=g["default"].copy(q,null,null,null,a.relationFields)),b.modified[p]=r&&b.modified[p]===r?g["default"].updateTimestamp(b.modified[p]):b.modified[p],b.expiresHeap.remove(q);var s=(new Date).getTime();b.expiresHeap.push({item:q,timestamp:s,expires:a.maxAge?s+a.maxAge:Number.MAX_VALUE}),k=q}catch(t){f.errorFn(t,c)}}return k}function f(a,b,c){var d=this,f=d.defs[a],i=d.s[a],j=void 0;if(!f)throw new h["default"].NER(a);if(!g["default"]._o(b)&&!g["default"]._a(b))throw new h["default"].IA(""+a+'.inject: "attrs" must be an object or an array!');return c=g["default"]._(f,c),c.notify&&(c.beforeInject(c,b),f.emit("DS.beforeInject",f,b)),j=e.call(d,f,i,b,c),i.collectionModified=g["default"].updateTimestamp(i.collectionModified),c.notify&&(c.afterInject(c,j),f.emit("DS.afterInject",f,j)),j}b["default"]=f;var g=c(2),h=c(3)},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a];c=c||{},b=b||{};var g=void 0;if(f)if(e._o(b)){if(c=e._(f,c),c.upsert&&e._sn(b[f.idAttribute]))return d.update(a,b[f.idAttribute],b,c)}else g=e._oErr("attrs");else g=new d.errors.NER(a);return new e.Promise(function(a,c){g?c(g):a(b)}).then(function(a){return c.beforeValidate.call(a,c,a)}).then(function(a){return c.validate.call(a,c,a)}).then(function(a){return c.afterValidate.call(a,c,a)}).then(function(a){return c.beforeCreate.call(a,c,a)}).then(function(a){return c.notify&&f.emit("DS.beforeCreate",f,a),d.getAdapter(c).create(f,a,c)}).then(function(a){return c.afterCreate.call(a,c,a)}).then(function(b){if(c.notify&&f.emit("DS.afterCreate",f,b),c.cacheResponse){var g=d.inject(f.n,b,c.orig()),h=g[f.idAttribute],i=d.s[a];return i.completedQueries[h]=(new Date).getTime(),i.saved[h]=e.updateTimestamp(i.saved[h]),g}return d.createInstance(a,b,c)})}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a],g=void 0;return new e.Promise(function(h,i){b=e.resolveId(f,b),f?e._sn(b)?(g=d.get(a,b)||{id:b},c=e._(f,c),h(g)):i(e._snErr("id")):i(new d.errors.NER(a))}).then(function(a){return c.beforeDestroy.call(a,c,a)}).then(function(e){return c.notify&&f.emit("DS.beforeDestroy",f,e),c.eagerEject&&d.eject(a,b),d.getAdapter(c).destroy(f,b,c)}).then(function(){return c.afterDestroy.call(g,c,g)}).then(function(e){return c.notify&&f.emit("DS.afterDestroy",f,e),d.eject(a,b),b})["catch"](function(b){return c&&c.eagerEject&&g&&d.inject(a,g,{notify:!1}),e.Promise.reject(b)})}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a],g=void 0,h=void 0;return b=b||{},new e.Promise(function(g,h){f?e._o(b)?(c=e._(f,c),g()):h(e._oErr("attrs")):h(new d.errors.NER(a))}).then(function(){return h=d.defaults.defaultFilter.call(d,a,b),c.beforeDestroy(c,h)}).then(function(){return c.notify&&f.emit("DS.beforeDestroy",f,h),c.eagerEject&&(g=d.ejectAll(a,b)),d.getAdapter(c).destroyAll(f,b,c)}).then(function(){return c.afterDestroy(c,h)}).then(function(){return c.notify&&f.emit("DS.afterDestroy",f,h),g||d.ejectAll(a,b)})["catch"](function(b){return c&&c.eagerEject&&g&&d.inject(a,g,{notify:!1}),e.Promise.reject(b)})}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.defs[a],g=d.s[a];return new e.Promise(function(h,i){f?e._sn(b)?(c=e._(f,c),c.params&&(c.params=e.copy(c.params)),(c.bypassCache||!c.cacheResponse)&&delete g.completedQueries[b],(!c.findStrictCache||b in g.completedQueries)&&d.get(a,b)&&!c.bypassCache?h(d.get(a,b)):(delete g.completedQueries[b],h())):i(e._snErr("id")):i(new d.errors.NER(a))}).then(function(h){if(h)return h;if(!(b in g.pendingQueries)){var i=void 0,j=c.findStrategy||c.strategy;"fallback"===j?!function(){var a=function(g){return d.getAdapter((c.findFallbackAdapters||c.fallbackAdapters)[g]).find(f,b,c)["catch"](function(b){return g++,g<c.fallbackAdapters.length?a(g):e.Promise.reject(b)})};i=a(0)}():i=d.getAdapter(c).find(f,b,c),g.pendingQueries[b]=i.then(function(f){if(delete g.pendingQueries[b],c.cacheResponse){var h=d.inject(a,f,c.orig());return g.completedQueries[b]=(new Date).getTime(),g.saved[b]=e.updateTimestamp(g.saved[b]),h}return d.createInstance(a,f,c.orig())})}return g.pendingQueries[b]})["catch"](function(a){return g&&delete g.pendingQueries[b],e.Promise.reject(a)})}b["default"]=d},function(a,b,c){function d(a,b,c,d){var e=this,f=e.utils,g=e.s[b],h=e.defs[b].idAttribute,i=(new Date).getTime();a=a||[],delete g.pendingQueries[c],g.completedQueries[c]=i,g.collectionModified=f.updateTimestamp(g.collectionModified);var j=e.inject(b,a,d.orig());return f._a(j)?f.forEach(j,function(a){if(a){var b=a[h];b&&(g.completedQueries[b]=i,g.saved[b]=f.updateTimestamp(g.saved[b]))}}):(d.errorFn("response is expected to be an array!"),g.completedQueries[j[h]]=i),j}function e(a,b,c){var e=this,f=e.utils,g=e.defs[a],h=e.s[a],i=void 0;return new f.Promise(function(d,j){b=b||{},e.defs[a]?f._o(b)?(c=f._(g,c),i=f.toJson(b),c.params&&(c.params=f.copy(c.params)),(c.bypassCache||!c.cacheResponse)&&(delete h.completedQueries[i],delete h.queryData[i]),i in h.completedQueries?d(c.useFilter?e.filter(a,b,c.orig()):h.queryData[i]):d()):j(f._oErr("params")):j(new e.errors.NER(a))}).then(function(j){if(i in h.completedQueries)return j;if(!(i in h.pendingQueries)){var k=void 0,l=c.findAllStrategy||c.strategy;"fallback"===l?!function(){var a=function(d){return e.getAdapter((c.findAllFallbackAdapters||c.fallbackAdapters)[d]).findAll(g,b,c)["catch"](function(b){return d++,d<c.fallbackAdapters.length?a(d):f.Promise.reject(b)})};k=a(0)}():k=e.getAdapter(c).findAll(g,b,c),h.pendingQueries[i]=k.then(function(b){return delete h.pendingQueries[i],c.cacheResponse?(h.queryData[i]=d.call(e,b,a,i,c),h.queryData[i].$$injected=!0,h.queryData[i]):(f.forEach(b,function(d,f){b[f]=e.createInstance(a,d,c.orig())}),b)})}return h.pendingQueries[i]})["catch"](function(a){return h&&delete h.pendingQueries[i],f.Promise.reject(a)})}b["default"]=e},function(a,b,c){function d(a,b,c,d){var e=this,f=e.utils,g=e.errors,h=e.defs[a];return new f.Promise(function(i,j){f._sn(b)&&(b=e.get(a,b)),f._s(c)&&(c=[c]),h?f._o(b)?f._a(c)?!function(){var a=f._(h,d);a.hasOwnProperty("findBelongsTo")||(a.findBelongsTo=!0),a.hasOwnProperty("findHasMany")||(a.findHasMany=!0);var g=[];f.forEach(h.relationList,function(a){var i=a.relation,j=h.getResource(i),k=f._(j,d);if(f.contains(c,i)||f.contains(c,a.localField)){var l=void 0,m={};k.allowSimpleWhere?m[a.foreignKey]=b[h.idAttribute]:(m.where={},m.where[a.foreignKey]={"==":b[h.idAttribute]}),"hasMany"===a.type?l=e.findAll(i,m,k.orig()):"hasOne"===a.type?a.localKey&&b[a.localKey]?l=e.find(i,b[a.localKey],k.orig()):a.foreignKey&&(l=e.findAll(i,m,k.orig()).then(function(a){return a.length?a[0]:null})):b[a.localKey]&&(l=e.find(i,b[a.localKey],k.orig())),l&&g.push(l)}}),i(g)}():j(new g.IA('"relations" must be a string or an array!')):j(new g.IA('"instance(id)" must be a string, number or object!')):j(new g.NER(a))}).then(function(a){return f.Promise.all(a)}).then(function(){return b})}b["default"]=d},function(a,b,c){function d(a,b){var c=this,d=c.utils,e=c.defs[a],f=c.s[a];return new d.Promise(function(g,h){if(e){b=d._(e,b),b.hasOwnProperty("notify")||(b.notify=!1);for(var i=[],j=(new Date).getTime(),k=void 0;(k=f.expiresHeap.peek())&&k.expires<j;)i.push(k.item),delete k.item,f.expiresHeap.pop();g(i)}else h(new c.errors.NER(a))}).then(function(g){if((b.isInterval||b.notify)&&(e.beforeReap(b,g),e.emit("DS.beforeReap",e,g)),"inject"===b.reapAction)!function(){var a=(new Date).getTime();d.forEach(g,function(b){f.expiresHeap.push({item:b,timestamp:a,expires:e.maxAge?a+e.maxAge:Number.MAX_VALUE})})}();else if("eject"===b.reapAction)d.forEach(g,function(b){c.eject(a,b[e.idAttribute])});else if("refresh"===b.reapAction){var h=function(){var b=[];return d.forEach(g,function(d){b.push(c.refresh(a,d[e.idAttribute]))}),{v:d.Promise.all(b)}}();if("object"==typeof h)return h.v}return g}).then(function(a){return(b.isInterval||b.notify)&&(e.afterReap(b,a),e.emit("DS.afterReap",e,a)),a})}b["default"]=d},function(a,b,c){function d(a,b,c){var d=this,e=d.utils,f=d.errors,g=d.defs[a],h=void 0,i=void 0;return new e.Promise(function(i,j){b=e.resolveId(g,b),g?e._sn(b)?d.get(a,b)?(h=d.get(a,b),c=e._(g,c),i(h)):j(new f.R('id "'+b+'" not found in cache!')):j(e._snErr("id")):j(new f.NER(a))}).then(function(a){return c.beforeValidate.call(a,c,a)}).then(function(a){return c.validate.call(a,c,a)}).then(function(a){return c.afterValidate.call(a,c,a)}).then(function(a){return c.beforeUpdate.call(a,c,a)}).then(function(f){if(c.notify&&g.emit("DS.beforeUpdate",g,f),c.changesOnly){var h=d.s[a];e.w&&h.observers[b].deliver();var j=[],k=d.changes(a,b);for(var l in k.added)j.push(l);for(l in k.changed)j.push(l);if(k=e.pick(f,j),e.isEmpty(k))return i=!0,f;f=k}return d.getAdapter(c).update(g,b,f,c)}).then(function(a){return c.afterUpdate.call(a,c,a)}).then(function(b){if(c.notify&&g.emit("DS.afterUpdate",g,b),i)return b;if(c.cacheResponse){var f=d.inject(g.n,b,c.orig()),h=d.s[a],j=f[g.idAttribute];return h.saved[j]=e.updateTimestamp(h.saved[j]),g.resetHistoryOnInject||(h.previousAttributes[j]=e.copy(f,null,null,null,g.relationFields)),f}return d.createInstance(a,b,c.orig())})}b["default"]=d},function(a,b,c){function d(a,b,c,d){var e=this,f=e.utils,g=e.errors,h=e.defs[a];return new f.Promise(function(e,i){b=f.resolveId(h,b),h?f._sn(b)?(d=f._(h,d),e(c)):i(f._snErr("id")):i(new g.NER(a))}).then(function(a){return d.beforeValidate.call(a,d,a)}).then(function(a){return d.validate.call(a,d,a)}).then(function(a){return d.afterValidate.call(a,d,a)}).then(function(a){return d.beforeUpdate.call(a,d,a)}).then(function(a){return d.notify&&h.emit("DS.beforeUpdate",h,a),e.getAdapter(d).update(h,b,a,d)}).then(function(a){return d.afterUpdate.call(a,d,a)}).then(function(b){if(d.notify&&h.emit("DS.afterUpdate",h,b),d.cacheResponse){var c=e.inject(h.n,b,d.orig()),g=e.s[a],i=c[h.idAttribute];return g.saved[i]=f.updateTimestamp(g.saved[i]),h.resetHistoryOnInject||(g.previousAttributes[i]=f.copy(c,null,null,null,h.relationFields)),c}return e.createInstance(a,b,d.orig())})}b["default"]=d},function(a,b,c){function d(a,b,c,d){var e=this,f=e.utils,g=e.errors,h=e.defs[a];return new f.Promise(function(c,e){h?(d=f._(h,d),c(b)):e(new g.NER(a))}).then(function(a){return d.beforeValidate.call(a,d,a)}).then(function(a){return d.validate.call(a,d,a)}).then(function(a){return d.afterValidate.call(a,d,a)}).then(function(a){return d.beforeUpdate.call(a,d,a)}).then(function(a){return d.notify&&h.emit("DS.beforeUpdate",h,a),e.getAdapter(d).updateAll(h,a,c,d)}).then(function(a){return d.afterUpdate.call(a,d,a)}).then(function(c){d.notify&&h.emit("DS.afterUpdate",h,b);var g=d.orig();if(d.cacheResponse){var i=function(){var b=e.inject(h.n,c,g),d=e.s[a];return f.forEach(b,function(a){var b=a[h.idAttribute];d.saved[b]=f.updateTimestamp(d.saved[b]),h.resetHistoryOnInject||(d.previousAttributes[b]=f.copy(a,null,null,null,h.relationFields))}),{v:b}}();if("object"==typeof i)return i.v}else{var j=function(){var b=[];return f.forEach(c,function(c){b.push(e.createInstance(a,c,g))}),{v:b}}();if("object"==typeof j)return j.v}})}b["default"]=d},function(a,b,c){function d(a){return a=e(a),a.search(/[\xC0-\xFF]/g)>-1&&(a=a.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),a}var e=c(26);a.exports=d},function(a,b,c){function d(a){return a=e(a),a.replace(f,"")}var e=c(26),f=/[^\x20\x2D0-9A-Z\x5Fa-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]/g;a.exports=d},function(a,b,c){function d(a){return a=e(a),a.toLowerCase()}var e=c(26);a.exports=d}])}); | ||
//# sourceMappingURL=js-data.min.map |
{ | ||
"name": "js-data", | ||
"description": "Robust, framework-agnostic in-memory data store.", | ||
"version": "2.0.0-beta.1", | ||
"version": "2.0.0-beta.2", | ||
"homepage": "http://www.js-data.io", | ||
@@ -53,4 +53,2 @@ "repository": { | ||
"jit-grunt": "0.9.1", | ||
"js-data-http": "2.0.0-beta.1", | ||
"js-data-localstorage": "2.0.0-beta.1", | ||
"jshint": "2.7.0", | ||
@@ -76,5 +74,5 @@ "jshint-loader": "0.8.3", | ||
"dependencies": { | ||
"yabh": "1.0.0", | ||
"yabh": "1.0.1", | ||
"mout": "0.11.0" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
421852
27
7878
+ Addedyabh@1.0.1(transitive)
- Removedyabh@1.0.0(transitive)
Updatedyabh@1.0.1