Comparing version 2.8.2 to 3.0.0-alpha.1
@@ -0,1 +1,25 @@ | ||
##### 3.0.0-alpha.1 - 12 December 2015 | ||
###### Breaking API changes | ||
- js-data now requires full ES5 compatibility from the runtime. The developer | ||
can add es5-shim for older browsers. | ||
- `DS` is now just a container for `Model` classes. It no longer stores data or | ||
metadata. | ||
- Settings are no longer inherited via the prototype. A base Model can be | ||
created which the remaining Models can extend. | ||
- A `Model` is essentially a constructor function, which can be used to create | ||
instance of the Model. A Model has static methods like `find` and `create`. The | ||
prototype of a Model defines behavior for instances of the Model. Models can be | ||
defined using ES6 class syntax. A Model must be "initialized" in order to be | ||
able to store data. A Model is automatically initialized if a schema is defined | ||
for the Model, or if the Model is created using the `.extend` method, or the | ||
legacy `DS#defineResource` or `DS#defineModel` methods. | ||
###### Other | ||
- As this is an alpha build of a complete rewrite from scratch, there is still a | ||
lot of work to be done. Some features from 2.x may not have been implemented yet | ||
and there are probably bugs. If you're willing to experiment with 3.x, your | ||
feedback is appreciated. | ||
- 3.0.0-alpha.1 gzipped is approximately 40% smaller than 2.8.2 gzipped. | ||
##### 2.8.2 - 04 November 2015 | ||
@@ -2,0 +26,0 @@ |
/*! | ||
* js-data | ||
* @version 2.8.2 - Homepage <http://www.js-data.io/> | ||
* @version 3.0.0-alpha.1 - Homepage <http://www.js-data.io/> | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
@@ -10,4 +10,4 @@ * @copyright (c) 2014-2015 Jason Dobry | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JSData=t():e.JSData=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var n=r(1),i=r(2),o=r(3);e.exports={DS:n.default,DSUtils:i.default,DSErrors:o.default,createStore:function(e){return new n.default(e)},version:{full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"}}},function(e,t,r){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,r){r(null,t)}function o(e,t){return t}function a(e,t,r,n){var i=!0;e:for(;i;){var o=e,a=t,u=r,s=n;f=c=d=void 0,i=!1;var f=o[a],c=l.default.get(u,f[0]),d=l.default.get(s,f[0]);if(l.default._s(c)&&(c=l.default.upperCase(c)),l.default._s(d)&&(d=l.default.upperCase(d)),"DESC"===f[1]){if(c>d)return-1;if(d>c)return 1;if(a<o.length-1){e=o,t=a+1,r=u,n=s,i=!0;continue e}return 0}if(d>c)return-1;if(c>d)return 1;if(!(a<o.length-1))return 0;e=o,t=a+1,r=u,n=s,i=!0}}function u(e){return e.replace(g,"\\$1")}function s(e,t){return new RegExp("^"+u(e).replace(y,".*").replace(b,".")+"$",t)}function f(e,t){l.default.forOwn(t,function(t,r){e[r]=t,e[r].before=function(t){var n=e[r];e[r]=function(){for(var e=arguments.length,r=Array(e),i=0;e>i;i++)r[i]=arguments[i];return n.apply(this,t.apply(this,r)||r)}}})}var c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(2),d=r(3),p=r(30),h=r(36),v=function(){function e(){n(this,e)}return c(e,[{key:"errorFn",value:function(e,t){if(this.error&&"function"==typeof this.error){try{throw"string"==typeof e?new Error(e):e}catch(t){e=t}this.error(this.name||null,e||null,t||null)}}}]),e}(),m=v.prototype;m.actions={},m.afterCreate=i,m.afterCreateCollection=o,m.afterCreateInstance=o,m.afterDestroy=i,m.afterEject=o,m.afterFind=i,m.afterFindAll=i,m.afterInject=o,m.afterLoadRelations=i,m.afterReap=o,m.afterUpdate=i,m.afterValidate=i,m.allowSimpleWhere=!0,m.basePath="",m.beforeCreate=i,m.beforeCreateCollection=o,m.beforeCreateInstance=o,m.beforeDestroy=i,m.beforeEject=o,m.beforeInject=o,m.beforeReap=o,m.beforeUpdate=i,m.beforeValidate=i,m.bypassCache=!1,m.cacheResponse=!!l.default.w,m.csp=!1,m.clearEmptyQueries=!0,m.computed={},m.defaultAdapter="http",m.debug=!1,m.defaultValues={},m.eagerEject=!1,m.eagerInject=!1,m.endpoint="",m.error=console?function(e,t,r){return console["function"==typeof console.error?"error":"log"](e,t,r)}:!1,m.errorHandler=function(){return l.default.Promise.reject(arguments[0])},m.fallbackAdapters=["http"],m.findStrictCache=!1,m.idAttribute="id",m.ignoredChanges=[/\$/],m.instanceEvents=!!l.default.w,m.keepChangeHistory=!1,m.linkRelations=!!l.default.w,m.log=console?function(e,t,r,n,i){return console["function"==typeof console.info?"info":"log"](e,t,r,n,i)}:!1,m.logFn=function(e,t,r,n){var i=this;i.debug&&i.log&&"function"==typeof i.log&&i.log(i.name||null,e||null,t||null,r||null,n||null)},m.maxAge=!1,m.methods={},m.notify=!!l.default.w,m.omit=[],m.onConflict="merge",m.reapAction=l.default.w?"inject":"none",m.reapInterval=l.default.w?3e4:!1,m.relationsEnumerable=!1,m.resetHistoryOnInject=!0,m.returnMeta=!1,m.scopes={},m.strategy="single",m.upsert=!!l.default.w,m.useClass=!0,m.useFilter=!1,m.validate=i,m.watchChanges=!!l.default.w;var g=/([.*+?^=!:${}()|[\]\/\\])/g,y=/%/g,b=/_/g;m.defaultFilter=function(e,t,r,n){var i=e,o=null,u={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""};r=r||{},n=n||{},o=l.default._o(r.where)?r.where:{},n.allowSimpleWhere&&l.default.forOwn(r,function(e,t){t in u||t in o||(o[t]={"==":e})}),l.default.isEmpty(o)&&(o=null),o&&(i=l.default.filter(i,function(e){var t=!0,r=!0;return l.default.forOwn(o,function(n,i){l.default._o(n)||(n={"==":n}),l.default.forOwn(n,function(n,o){var a=void 0,u="|"===o[0],f=l.default.get(e,i);o=u?o.substr(1):o,"=="===o?a=f==n:"==="===o?a=f===n:"!="===o?a=f!=n:"!=="===o?a=f!==n:">"===o?a=f>n:">="===o?a=f>=n:"<"===o?a=n>f:"<="===o?a=n>=f:"isectEmpty"===o?a=!l.default.intersection(f||[],n||[]).length:"isectNotEmpty"===o?a=l.default.intersection(f||[],n||[]).length:"in"===o?a=l.default._s(n)?-1!==n.indexOf(f):l.default.contains(n,f):"notIn"===o?a=l.default._s(n)?-1===n.indexOf(f):!l.default.contains(n,f):0===o.indexOf("like")?a=null!==s(n,o.substr(4)).exec(f):0===o.indexOf("notLike")?a=null===s(n,o.substr(7)).exec(f):"contains"===o?a=l.default._s(f)?-1!==f.indexOf(n):l.default.contains(f,n):"notContains"===o&&(a=l.default._s(f)?-1===f.indexOf(n):!l.default.contains(f,n)),void 0!==a&&(r=t?a:u?r||a:r&&a),t=!1})}),r}));var f=null;l.default._s(r.orderBy)?f=[[r.orderBy,"ASC"]]:l.default._a(r.orderBy)&&(f=r.orderBy),!f&&l.default._s(r.sort)?f=[[r.sort,"ASC"]]:!f&&l.default._a(r.sort)&&(f=r.sort),f&&!function(){var e=0;l.default.forEach(f,function(e,r){if(l.default._s(e))f[r]=[e,"ASC"];else if(!l.default._a(e))throw new d.default.IA('DS.filter("'+t+'"[, params][, options]): '+l.default.toJson(e)+": Must be a string or an array!",{params:{"orderBy[i]":{actual:typeof e,expected:"string|array"}}})}),i=l.default.sort(i,function(t,r){return a(f,e,t,r)})}();var c=l.default._n(r.limit)?r.limit:null,p=null;return l.default._n(r.skip)?p=r.skip:l.default._n(r.offset)&&(p=r.offset),c&&p?i=l.default.slice(i,p,Math.min(i.length,p+c)):l.default._n(c)?i=l.default.slice(i,0,Math.min(i.length,c)):l.default._n(p)&&(i=p<i.length?l.default.slice(i,p):[]),i===e?i.slice():i};var _=function(){function e(t){n(this,e);var r=this;t=t||{},r.store={},r.definitions={},r.adapters={},r.defaults=new v,r.observe=l.default.observe,l.default.forOwn(t,function(e,t){"omit"===t?r.defaults.omit=e.concat(v.prototype.omit):r.defaults[t]=e});var i=l.default.Promise;i&&!i.prototype.spread&&(i.prototype.spread=function(e){return this.then(function(t){return e.apply(this,t)})}),l.default.Events(r)}return c(e,[{key:"getAdapterName",value:function(e){var t=!1;if(e=e||{},l.default._s(e)&&(t=!0,e={adapter:e}),this.adapters[e.adapter])return e.adapter;if(t)throw new Error(e.adapter+" is not a registered adapter!");return e.defaultAdapter}},{key:"getAdapter",value:function(e){return e=e||{},this.adapters[this.getAdapterName(e)]}},{key:"registerAdapter",value:function(e,t,r){var n=this;r=r||{},l.default.isFunction(t)?n.adapters[e]=new t(r):n.adapters[e]=t,r.default&&(n.defaults.defaultAdapter=e)}},{key:"is",value:function(e,t){var r=this.definitions[e];if(!r)throw new d.default.NER(e);return t instanceof r[r.class]}},{key:"clear",value:function(){var e=this,t={};return l.default.forOwn(this.definitions,function(r){var n=r.name;t[n]=r.ejectAll(),e.store[n].completedQueries={},e.store[n].queryData={}}),t}},{key:"errorFn",value:function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];var n=t[t.length-1],i=this.defaults.errorHandler,o=n?n.errorHandler:i;return o=o||i,function(e){return o.apply(void 0,[e].concat(t))}}}]),e}(),w=_.prototype;w.getAdapterName.shorthand=!1,w.getAdapter.shorthand=!1,w.registerAdapter.shorthand=!1,w.errors=d.default,w.utils=l.default,f(w,p.default),f(w,h.default),t.default=_},function(e,t,r){function n(e){return"[object Array]"===B.call(e)||!1}function i(e){return"[object RegExp]"===B.call(e)||!1}function o(e){return"string"==typeof e||e&&"object"==typeof e&&"[object String]"===B.call(e)||!1}function a(e){return"[object Object]"===B.call(e)||!1}function u(e){return e&&"object"==typeof e&&"[object Date]"===B.call(e)||!1}function s(e){var t=typeof e;return"number"===t||e&&"object"===t&&"[object Number]"===B.call(e)||!1}function f(e){return"function"==typeof e||e&&"[object Function]"===B.call(e)||!1}function c(e){return o(e)||s(e)}function l(e){return new E.default.IA('"'+e+'" must be a string or a number!')}function d(e){return new E.default.IA('"'+e+'" must be an object!')}function p(e){return new E.default.IA('"'+e+'" must be an array!')}function h(e){if(null==e)return!0;if("string"==typeof e||L(e))return!e.length;if("object"==typeof e){var t=!0;return D(e,function(){return t=!1,!1}),t}return!0}function v(e,t){if(!e||!t)return[];for(var r=[],n=void 0,i=0,o=e.length;o>i;i++)n=e[i],S(r,n)||S(t,n)&&r.push(n);return r}function m(e,t,r){var n=[];return C(e,function(e,r,i){t(e,r,i)&&n.push(e)},r),n}function g(e){var t={};e=e||this,Object.defineProperties(e,{on:{value:function(e,r,n){t[e]=t[e]||[],t[e].push({f:r,c:n})}},off:{value:function(e,r){var n=t[e];if(n)if(r){for(var i=0;i<n.length;i++)if(n[i].f===r){n.splice(i,1);break}}else n.splice(0,n.length);else t={}}},emit:{value:function(){for(var e=arguments.length,r=Array(e),n=0;e>n;n++)r[n]=arguments[n];var i=t[r.shift()]||[];if(i)for(var o=0;o<i.length;o++)i[o].f.apply(i[o].c,r)}}})}function y(e,t,r,n,o){if(t){if(e===t)throw new Error("Cannot copy! Source and destination are identical.");if(r=r||[],n=n||[],a(e)){var s=r.indexOf(e);if(-1!==s)return n[s];r.push(e),n.push(t)}var f=void 0;if(L(e)){var c=void 0;for(t.length=0,c=0;c<e.length;c++)f=y(e[c],null,r,n,o),a(e[c])&&(r.push(e[c]),n.push(f)),t.push(f)}else{L(t)?t.length=0:C(t,function(e,r){delete t[r]});for(var l in e)if(e.hasOwnProperty(l)){if(z(l,o))continue;f=y(e[l],null,r,n,o),a(e[l])&&(r.push(e[l]),n.push(f)),t[l]=f}}}else t=e,e&&(L(e)?t=y(e,[],r,n,o):u(e)?t=new Date(e.getTime()):i(e)?(t=new RegExp(e.source,e.toString().match(/[^\/]*$/)[0]),t.lastIndex=e.lastIndex):a(e)&&(t=y(e,Object.create(Object.getPrototypeOf(e)),r,n,o)));return t}function b(e,t){var r=!0;e:for(;r;){var n=e,o=t;if(l=d=a=s=c=void 0,r=!1,n===o)return!0;if(null===n||null===o)return!1;if(n!==n&&o!==o)return!0;var a,s,c,l=typeof n,d=typeof o;if(l==d&&"object"==l){if(!L(n)){if(u(n)){if(!u(o))return!1;e=n.getTime(),t=o.getTime(),r=!0;continue e}if(i(n)&&i(o))return n.toString()==o.toString();if(L(o))return!1;c={};for(s in n)if("$"!==s.charAt(0)&&!f(n[s])){if(!b(n[s],o[s]))return!1;c[s]=!0}for(s in o)if(!c.hasOwnProperty(s)&&"$"!==s.charAt(0)&&void 0!==o[s]&&!f(o[s]))return!1;return!0}if(!L(o))return!1;if((a=n.length)===o.length){for(s=0;a>s;s++)if(!b(n[s],o[s]))return!1;return!0}}return!1}}function _(e,t){return o(t)||s(t)?t:t&&e?t[e.idAttribute]||t:t}function w(e,t){return e&&(o(t)||s(t))?e.index[t]||t:t}function A(e){return null!=e&&""!==e}function x(e,t){return t=t||"",m(e,A).join(t)}function j(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];var n=x(t,"/");return n.replace(/([^:\/]|^)\/{2,}/g,"$1/")}var E=r(3),O=r(4),C=r(5),F=r(6),D=r(7),S=r(10),k=r(12),R=r(14),I=r(21),P=r(22),N=r(23),T=r(24),H=r(19),Q=r(25),M=r(27),U=r(29),K=void 0,V=void 0,q=void 0,$=Object.prototype,B=$.toString;try{V=Promise}catch(e){console.error("js-data requires a global Promise constructor!")}try{q=window.File}catch(e){q=function(){}}var L=Array.isArray||n;try{K=window,K={}}catch(e){K=null}var J=["beforeValidate","validate","afterValidate","beforeCreate","afterCreate","beforeUpdate","afterUpdate","beforeDestroy","afterDestroy"],z=U.isBlacklisted;t.default={Promise:V,_:function(e,t){var r=this;if(e=e||{},t=t||{},t&&t.constructor===e.constructor)return t;if(!a(t))throw new E.default.IA('"options" must be an object!');C(J,function(e){"function"==typeof t[e]&&-1===t[e].toString().indexOf("for (var _len = arg")&&(t[e]=r.promisify(t[e]))});var n=function(e){var t=this;D(e,function(e,r){t[r]=e})};return n.prototype=e,n.prototype.orig=function(){var e={};return D(this,function(t,r){e[r]=t}),e},new n(t)},_n:s,_s:o,_sn:c,_snErr:l,_o:a,_oErr:d,_a:L,_aErr:p,applyScope:function(e,t,r){var n=r.scope,i=y(t);n?o(n)&&(n=[n]):n=[],n.unshift("defaultScope"),C(n,function(n){var i=r.scopes[n];"function"==typeof i?k(t,i(e)):i&&k(t,i)}),k(t,i)},compute:function(e,t){var r=this,n=[];a(e)||(C(e.deps,function(e){n.push(Q(r,e))}),M(r,t,e[e.length-1].apply(r,n)))},contains:S,copy:y,deepMixIn:k,diffObjectFromOldObject:U.diffObjectFromOldObject,BinaryHeap:O,equals:b,Events:g,filter:m,fillIn:function(e,t){return D(t,function(t,r){r in e||(e[r]=t)}),e},forEach:C,forOwn:D,fromJson:function(e){return o(e)?JSON.parse(e):e},get:Q,intersection:v,isArray:L,isBlacklisted:z,isEmpty:h,isFunction:f,isObject:a,isNumber:s,isString:o,keys:N,makePath:j,observe:U,omit:function(e,t){var r=[];return D(e,function(e,n){z(n,t)&&r.push(n)}),C(r,function(t){delete e[t]}),e},pascalCase:R,pick:P,promisify:function(e,t){var r=this;if(e){if("function"!=typeof e)throw new Error("Can only promisify functions!");return function(){for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return new r.Promise(function(r,n){i.push(function(e,t){e?n(e):r(t)});try{var o=e.apply(t||this,i);o&&o.then&&o.then(r,n)}catch(e){n(e)}})}}},remove:I,set:M,slice:F,sort:T,toJson:JSON.stringify,updateTimestamp:function(e){var t="function"==typeof Date.now?Date.now():(new Date).getTime();return e&&e>=t?e+1:t},upperCase:H,removeCircular:function(e){return function e(t,r){var n=void 0,i=void 0;if(!("object"!=typeof t||null===t||t instanceof Boolean||t instanceof Date||t instanceof Number||t instanceof RegExp||t instanceof String||q&&t instanceof q)){for(var o=r.cur,a=r.ctx;a;){if(a.cur===o)return void 0;a=a.ctx}if(L(t))for(i=[],n=0;n<t.length;n+=1)i[n]=e(t[n],{ctx:r,cur:t[n]});else i={},D(t,function(n,o){i[o]=e(t[o],{ctx:r,cur:t[o]})});return i}return t}(e,{ctx:null,cur:e})},resolveItem:w,resolveId:_,respond:function(e,t,r){return"array"===r.returnMeta?[e,t]:"object"===r.returnMeta?{response:e,meta:t}:e},w:K,applyRelationGettersToTarget:function(e,t,r){this.forEach(t.relationList,function(n){var i=n.relation,o=n.localField,a=n.localKey,u=n.foreignKey,s=n.localKeys,f=n.foreignKeys,c="boolean"==typeof n.enumerable?n.enumerable:!!t.relationsEnumerable;if("boolean"==typeof n.link?n.link:!!t.linkRelations){delete r[o];var l={enumerable:c};"belongsTo"===n.type?(l.get=function(){var e=Q(this,a),r=!(!e&&0!==e);return r?t.getResource(i).get(e):void 0},l.set=function(e){return e&&M(this,a,Q(e,t.getResource(i).idAttribute)),Q(this,o)}):"hasMany"===n.type?(l.get=function(){var r={};if(u)return r[u]=this[t.idAttribute],t.getResource(i).defaultFilter.call(e,e.store[i].collection,i,r,{allowSimpleWhere:!0});if(s){var n=Q(this,s)||[];return t.getResource(i).getAll(L(n)?n:N(n))}return f?(M(r,"where."+f+".contains",this[t.idAttribute]),t.getResource(i).defaultFilter.call(e,e.store[i].collection,i,r)):void 0},l.set=function(e){var r=this;return e&&e.length&&!function(){var n=Q(r,t.idAttribute);u?C(e,function(e){M(e,u,n)}):s?!function(){var n=[];C(e,function(e){n.push(Q(e,t.getResource(i).idAttribute))}),M(r,s,n)}():f&&C(e,function(e){var t=Q(e,f);t?S(t,n)||t.push(n):M(e,f,[n])})}(),Q(this,o)}):"hasOne"===n.type&&(a?(l.get=function(){var e=Q(this,a),r=!(!e&&0!==e);return r?t.getResource(i).get(e):void 0},l.set=function(e){return e&&M(this,a,Q(e,t.getResource(i).idAttribute)),Q(this,o)}):(l.get=function(){var r={};r[u]=this[t.idAttribute];var n=r[u]?t.getResource(i).defaultFilter.call(e,e.store[i].collection,i,r,{allowSimpleWhere:!0}):[];return n.length?n[0]:void 0},l.set=function(e){return e&&M(e,u,Q(this,t.idAttribute)),Q(this,o)})),n.get&&!function(){var e=l.get;l.get=function(){var r=this;return n.get(t,n,this,function(){for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return e.apply(r,n)})}}(),Object.defineProperty(r,o,l)}})}}},function(e,t){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(e,t,r){for(var n=!0;n;){var i=e,o=t,a=r;u=f=s=void 0,n=!1,null===i&&(i=Function.prototype);var u=Object.getOwnPropertyDescriptor(i,o);if(void 0!==u){if("value"in u)return u.value;var s=u.get;return void 0===s?void 0:s.call(a)}var f=Object.getPrototypeOf(i);if(null===f)return void 0;e=f,t=o,r=a,n=!0}},o=function(e){function t(e){r(this,t),i(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=e}return n(t,e),t}(Error),a=function(e){function t(e){r(this,t),i(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=e}return n(t,e),t}(Error),u=function(e){function t(e){r(this,t),i(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=e+" is not a registered resource!"}return n(t,e),t}(Error);t.default={IllegalArgumentError:o,IA:o,RuntimeError:a,R:a,NonexistentResourceError:u,NER:u}},function(e,t,r){!function(t,r){e.exports=r()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){function n(e,t,r){for(var n=e[r],i=t(n);r>0;){var o=Math.floor((r+1)/2)-1,a=e[o];if(i>=t(a))break;e[o]=n,e[r]=a,r=o}}function i(e,t){if(e||(e=function(e){return e}),t||(t=function(e,t){return e===t}),"function"!=typeof e)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof t)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=e,this.compareFunc=t,this.heap=[]}var o=function(e,t,r){for(var n=e.length,i=e[r],o=t(i);;){var a=2*(r+1),u=a-1,s=null;if(n>u){var f=e[u],c=t(f);o>c&&(s=u)}if(n>a){var l=e[a],d=t(l);d<(null===s?o:t(e[u]))&&(s=a)}if(null===s)break;e[r]=e[s],e[s]=i,r=s}},a=i.prototype;a.push=function(e){this.heap.push(e),n(this.heap,this.weightFunc,this.heap.length-1)},a.peek=function(){return this.heap[0]},a.pop=function(){var e=this.heap[0],t=this.heap.pop();return this.heap.length>0&&(this.heap[0]=t,o(this.heap,this.weightFunc,0)),e},a.remove=function(e){for(var t=this.heap.length,r=0;t>r;r++)if(this.compareFunc(this.heap[r],e)){var i=this.heap[r],a=this.heap.pop();return r!==t-1&&(this.heap[r]=a,n(this.heap,this.weightFunc,r),o(this.heap,this.weightFunc,r)),i}return null},a.removeAll=function(){this.heap=[]},a.size=function(){return this.heap.length},e.exports=i}])})},function(e,t){function r(e,t,r){if(null!=e)for(var n=-1,i=e.length;++n<i&&t.call(r,e[n],n,e)!==!1;);}e.exports=r},function(e,t){function r(e,t,r){var n=e.length;t=null==t?0:0>t?Math.max(n+t,0):Math.min(t,n),r=null==r?n:0>r?Math.max(n+r,0):Math.min(r,n);for(var i=[];r>t;)i.push(e[t++]);return i}e.exports=r},function(e,t,r){function n(e,t,r){o(e,function(n,o){return i(e,o)?t.call(r,e[o],o,e):void 0})}var i=r(8),o=r(9);e.exports=n},function(e,t){function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=r},function(e,t,r){function n(){u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=!0;for(var e in{toString:null})a=!1}function i(e,t,r){var i,f=0;null==a&&n();for(i in e)if(o(t,e,i,r)===!1)break;if(a)for(var c=e.constructor,l=!!c&&e===c.prototype;(i=u[f++])&&("constructor"===i&&(l||!s(e,i))||e[i]===Object.prototype[i]||o(t,e,i,r)!==!1););}function o(e,t,r,n){return e.call(n,t[r],r,t)}var a,u,s=r(8);e.exports=i},function(e,t,r){function n(e,t){return-1!==i(e,t)}var i=r(11);e.exports=n},function(e,t){function r(e,t,r){if(r=r||0,null==e)return-1;for(var n=e.length,i=0>r?n+r:r;n>i;){if(e[i]===t)return i;i++}return-1}e.exports=r},function(e,t,r){function n(e,t){for(var r,n=0,a=arguments.length;++n<a;)r=arguments[n],r&&o(r,i,e);return e}function i(e,t){var r=this[t];a(e)&&a(r)?n(r,e):this[t]=e}var o=r(7),a=r(13);e.exports=n},function(e,t){function r(e){return!!e&&"object"==typeof e&&e.constructor===Object}e.exports=r},function(e,t,r){function n(e){return e=i(e),o(e).replace(/^[a-z]/,a)}var i=r(15),o=r(16),a=r(19);e.exports=n},function(e,t){function r(e){return null==e?"":e.toString()}e.exports=r},function(e,t,r){function n(e){return e=i(e),e=o(e),e=a(e).replace(/[\-_]/g," ").replace(/\s[a-z]/g,u).replace(/\s+/g,"").replace(/^[A-Z]/g,s)}var i=r(15),o=r(17),a=r(18),u=r(19),s=r(20);e.exports=n},function(e,t,r){function n(e){return e=i(e),e.search(/[\xC0-\xFF]/g)>-1&&(e=e.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")),e}var i=r(15);e.exports=n},function(e,t,r){function n(e){return e=i(e),e.replace(o,"")}var i=r(15),o=/[^\x20\x2D0-9A-Z\x5Fa-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]/g;e.exports=n},function(e,t,r){function n(e){return e=i(e),e.toUpperCase()}var i=r(15);e.exports=n},function(e,t,r){function n(e){return e=i(e),e.toLowerCase()}var i=r(15);e.exports=n},function(e,t,r){function n(e,t){var r=i(e,t);-1!==r&&e.splice(r,1)}var i=r(11);e.exports=n},function(e,t,r){function n(e,t){for(var r,n="string"!=typeof arguments[1]?arguments[1]:i(arguments,1),o={},a=0;r=n[a++];)o[r]=e[r];return o}var i=r(6);e.exports=n},function(e,t,r){var n=r(7),i=Object.keys||function(e){var t=[];return n(e,function(e,r){t.push(r)}),t};e.exports=i},function(e,t){function r(e,t){if(null==e)return[];if(e.length<2)return e;null==t&&(t=n);var o,a,u;return o=~~(e.length/2),a=r(e.slice(0,o),t),u=r(e.slice(o,e.length),t),i(a,u,t)}function n(e,t){return t>e?-1:e>t?1:0}function i(e,t,r){for(var n=[];e.length&&t.length;)r(e[0],t[0])<=0?n.push(e.shift()):n.push(t.shift());return e.length&&n.push.apply(n,e),t.length&&n.push.apply(n,t),n}e.exports=r},function(e,t,r){function n(e,t){for(var r=t.split("."),n=r.pop();t=r.shift();)if(e=e[t],null==e)return;return e[n]}r(26);e.exports=n},function(e,t){function r(e){switch(typeof e){case"string":case"number":case"boolean":return!0}return null==e}e.exports=r},function(e,t,r){function n(e,t,r){var n=/^(.+)\.(.+)$/.exec(t);n?i(e,n[1])[n[2]]=r:e[t]=r}var i=r(28);e.exports=n},function(e,t,r){function n(e,t){return t?(i(t.split("."),function(t){e[t]||(e[t]={}),e=e[t]}),e):e}var i=r(5);e.exports=n},function(e,t){!function(e){function t(){function e(e){t=e}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var t=[],r={},n=[];return Object.observe(r,e),Array.observe(n,e),r.id=1,r.id=2,delete r.id,n.push(1,2),n.length=0,Object.deliverChangeRecords(e),5!==t.length?!1:"add"!=t[0].type||"update"!=t[1].type||"delete"!=t[2].type||"splice"!=t[3].type||"splice"!=t[4].type?!1:(Object.unobserve(r,e),Array.unobserve(n,e),!0)}function r(t){for(var r=0;y>r&&t.check_();)r++;return v&&(e.dirtyCheckCycleCount=r),r>0}function n(e){for(var t in e)return!1;return!0}function i(e){return n(e.added)&&n(e.removed)&&n(e.changed)}function o(e,t){if(!t||!t.length)return!1;for(var r,n=0;n<t.length;n++)if("[object RegExp]"===Object.prototype.toString.call(t[n])&&t[n].test(e)||t[n]===e)return r=e;return!!r}function a(e,t,r,n){var i={},a={},u={};for(var s in t){var f=e[s];o(s,n)||void 0!==f&&(r?r(f,t[s]):f===t[s])||(s in e?(r?r(f,t[s]):f===t[s])||(u[s]=f):a[s]=void 0)}for(var s in e)s in t||o(s,n)||(i[s]=e[s]);return Array.isArray(e)&&e.length!==t.length&&(u.length=e.length),{added:i,removed:a,changed:u}}function u(){if(!b.length)return!1;for(var e=0;e<b.length;e++)b[e]();return b.length=0,!0}function s(){function e(e){t&&t.state_===x&&!n&&t.check_(e)}var t,r,n=!1,i=!0;return{open:function(r){if(t)throw Error("ObservedObject in use");i||Object.deliverChangeRecords(e),t=r,i=!1},observe:function(t,n){r=t,n?Array.observe(r,e):Object.observe(r,e)},deliver:function(t){n=t,Object.deliverChangeRecords(e),n=!1},close:function(){t=void 0,Object.unobserve(r,e),w.push(this)}}}function f(e,t,r){var n=w.pop()||s();return n.open(e),n.observe(t,r),n}function c(){this.state_=A,this.callback_=void 0,this.target_=void 0,this.directObserver_=void 0,this.value_=void 0,this.id_=E++}function l(e){c._allObserversCount++,C&&O.push(e)}function d(e){c._allObserversCount--}function p(e){c.call(this),this.value_=e,this.oldObject_=void 0}function h(e,t,r){for(var n={},i={},o=0;o<t.length;o++){var a=t[o];S[a.type]?(a.name in r||(r[a.name]=a.oldValue),"update"!=a.type&&("add"!=a.type?a.name in n?(delete n[a.name],delete r[a.name]):i[a.name]=!0:a.name in i?delete i[a.name]:n[a.name]=!0)):(console.error("Unknown changeRecord type: "+a.type),console.error(a))}for(var u in n)n[u]=e[u];for(var u in i)i[u]=void 0;var s={};for(var u in r)if(!(u in n||u in i)){var f=e[u];r[u]!==f&&(s[u]=f)}return{added:n,removed:i,changed:s}}var v=e.testingExposeCycleCount,m=t(),g="__proto__"in{}?function(e){return e}:function(e){var t=e.__proto__;if(!t)return e;var r=Object.create(t);return Object.getOwnPropertyNames(e).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))}),r},y=1e3,b=[],_=m?function(){return function(e){return Promise.resolve().then(e)}}():function(){return function(e){b.push(e)}}(),w=[],A=0,x=1,j=2,E=1;c.prototype={open:function(e,t){if(this.state_!=A)throw Error("Observer has already been opened.");return l(this),this.callback_=e,this.target_=t,this.connect_(),this.state_=x,this.value_},close:function(){this.state_==x&&(d(this),this.disconnect_(),this.value_=void 0,this.callback_=void 0,this.target_=void 0,this.state_=j)},deliver:function(){this.state_==x&&r(this)},report_:function(e){try{this.callback_.apply(this.target_,e)}catch(e){c._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+(e.stack||e))}},discardChanges:function(){return this.check_(void 0,!0),this.value_}};var O,C=!m;c._allObserversCount=0,C&&(O=[]);var F=!1;e.Platform=e.Platform||{},e.Platform.performMicrotaskCheckpoint=function(){if(!F&&C){F=!0;var t,r,n=0;do{n++,r=O,O=[],t=!1;for(var i=0;i<r.length;i++){var o=r[i];o.state_==x&&(o.check_()&&(t=!0),O.push(o))}u()&&(t=!0)}while(y>n&&t);v&&(e.dirtyCheckCycleCount=n),F=!1}},C&&(e.Platform.clearObservers=function(){O=[]}),p.prototype=g({__proto__:c.prototype,arrayObserve:!1,connect_:function(e,t){m?this.directObserver_=f(this,this.value_,this.arrayObserve):this.oldObject_=this.copyObject(this.value_)},copyObject:function(e){var t=Array.isArray(e)?[]:{};for(var r in e)t[r]=e[r];return Array.isArray(e)&&(t.length=e.length),t},check_:function(e,t){var r,n;if(m){if(!e)return!1;n={},r=h(this.value_,e,n)}else n=this.oldObject_,r=a(this.value_,this.oldObject_);return i(r)?!1:(m||(this.oldObject_=this.copyObject(this.value_)),this.report_([r.added||{},r.removed||{},r.changed||{},function(e){return n[e]}]),!0)},disconnect_:function(){m?(this.directObserver_.close(),this.directObserver_=void 0):this.oldObject_=void 0},deliver:function(){this.state_==x&&(m?this.directObserver_.deliver(!1):r(this))},discardChanges:function(){return this.directObserver_?this.directObserver_.deliver(!0):this.oldObject_=this.copyObject(this.value_),this.value_}});var D={},S={add:!0,update:!0,delete:!0};e.Observer=c,e.isBlacklisted=o,e.Observer.runEOM_=_,e.Observer.observerSentinel_=D,e.Observer.hasObjectObserve=m,e.diffObjectFromOldObject=a,e.ObjectObserver=p}(t)},function(e,t,r){function n(e){return!(o.default.isEmpty(e.added)&&o.default.isEmpty(e.removed)&&o.default.isEmpty(e.changed))}function i(e,t,r,n){var i=this,a=i.definitions[t];if(n=n||{},r=o.default.resolveId(a,r),!a)throw new u(t);if(!o.default._sn(r))throw o.default._snErr("id");return r=r===c?void 0:r,n=o.default._(a,n),{_this:i,definition:a,_resourceName:t,_id:r,_options:n}}var o=r(2),a=r(3),u=a.default.NER,s=a.default.IA,f=a.default.R,c="DS_"+(new Date).getTime();t.default={changes:function(e,t,r){var n=i.call(this,"changes",e,t,r),a=n._this,u=n.definition,s=n._resourceName,f=n._id,c=n._options,l=u.get(f);if(l){var d=function(){var e=a.store[s].observers[f];e&&"function"==typeof e&&e.deliver();var t=c.ignoredChanges||[];o.default.forEach(u.relationFields,function(e){o.default.contains(t,e)||t.push(e)});var r=o.default.diffObjectFromOldObject(l,a.store[s].previousAttributes[f],o.default.equals,t);return o.default.forOwn(r,function(e,t){var n=[];o.default.forOwn(e,function(e,t){o.default.isFunction(e)||n.push(t)}),r[t]=o.default.pick(r[t],n)}),o.default.forEach(u.relationFields,function(e){delete r.added[e],delete r.removed[e],delete r.changed[e]}),{v:r}}();if("object"==typeof d)return d.v}},changeHistory:function(e,t){var r=i.call(this,"changeHistory",e,t||c),n=r._this,o=r.definition,a=r._resourceName,u=r._id,s=n.store[a];if(o.keepChangeHistory){if(!a)return s.changeHistory;var f=o.get(u);if(f)return s.changeHistories[u]}else o.errorFn("changeHistory is disabled for this resource!")},commit:function(e,t){var r=i.call(this,"commit",e,t),n=r._this,a=r.definition,u=r._resourceName,s=r._id,f=n.store[u],c=n.store[u].index[s];return c&&(f.previousAttributes[s]=o.default.copy(c,null,null,null,a.relationFields)),f.changeHistories[s].length&&(o.default.forEach(f.changeHistories[s],function(e){o.default.remove(f.changeHistory,e)}),f.changeHistories[s].splice(0,f.changeHistories[s].length)),c},compute:function(e,t){var r=this,n=r.definitions[e];if(t=o.default.resolveItem(r.store[e],t),!n)throw new u(e);if(!t)throw new f("Item not in the store!");if(!o.default._o(t)&&!o.default._sn(t))throw new s('"instance" must be an object, string or number!');return o.default.forOwn(n.computed,function(e,r){o.default.compute.call(t,e,r)}),t},createInstance:function(e,t,r){var n=this.definitions[e],i=void 0;if(t=t||{},!n)throw new u(e);if(t&&!o.default.isObject(t))throw new s('"attrs" must be an object!');r=o.default._(n,r),r.beforeCreateInstance(r,t);var a=n[n.class];return i=new a,n.instanceEvents&&o.default.Events(i),r.defaultValues&&o.default.deepMixIn(i,r.defaultValues),o.default.deepMixIn(i,t),n.computed&&n.compute(i),r.afterCreateInstance(r,i),i},createCollection:function(e,t,r,n){var i=this,a=i.definitions[e];if(t=t||[],r=r||{},!a)throw new u(e);if(t&&!o.default.isArray(t))throw new s('"arr" must be an array!');return n=o.default._(a,n),n.beforeCreateCollection(n,t),Object.defineProperties(t,{fetch:{value:function(t,r){var n=this;return n.params=t||n.params,a.findAll(n.params,r).then(function(t){return t===n?n:(t.unshift(n.length),t.unshift(0),n.splice.apply(n,t),t.shift(),t.shift(),t.$$injected&&(i.store[e].queryData[o.default.toJson(n.params)]=n,n.$$injected=!0),n)})}},params:{value:r,writable:!0},resourceName:{value:e}}),n.afterCreateCollection(n,t),t},defineResource:r(31),digest:function(){this.observe.Platform.performMicrotaskCheckpoint()},eject:r(32),ejectAll:r(33),filter:r(34),get:function(e,t){var r=i.call(this,"get",e,t),n=r._this,o=r._resourceName,a=r._id;return n.store[o].index[a]},getAll:function(e,t){var r=this,n=r.definitions[e],i=r.store[e],a=[];if(!n)throw new u(e);if(t&&!o.default._a(t))throw o.default._aErr("ids");if(o.default._a(t))for(var s=t.length,f=0;s>f;f++)i.index[t[f]]&&a.push(i.index[t[f]]);else a=i.collection.slice();return a},hasChanges:function(e,t){var r=i.call(this,"hasChanges",e,t),o=r.definition,a=r._id;return o.get(a)?n(o.changes(a)):!1},inject:r(35),lastModified:function(e,t){var r=i.call(this,"lastModified",e,t||c),n=r._this,o=r._resourceName,a=r._id,u=n.store[o]; | ||
return a?(a in u.modified||(u.modified[a]=0),u.modified[a]):u.collectionModified},lastSaved:function(e,t){var r=i.call(this,"lastSaved",e,t||c),n=r._this,o=r._resourceName,a=r._id,u=n.store[o];return a in u.saved||(u.saved[a]=0),u.saved[a]},previous:function(e,t){var r=i.call(this,"previous",e,t),n=r._this,a=r._resourceName,u=r._id,s=n.store[a];return s.previousAttributes[u]?o.default.copy(s.previousAttributes[u]):void 0},revert:function(e,t,r){var n=i.call(this,"revert",e,t,r),a=n._this,u=n.definition,s=n._resourceName,f=n._id,c=n._options,l=c.preserve||[],d={};if(0===l.length)d=a.previous(s,f);else{var p=function(){var e=u.get(t),r=a.previous(s,f);return e?void o.default.forOwn(e,function(t,n){o.default.contains(l,n)?d[n]=e[n]:d[n]=r[n]}):{v:void 0}}();if("object"==typeof p)return p.v}return u.inject(d,{onConflict:"replace"})}}},function(e,t,r){var n=r(2),i=r(3),o=["compute","eject","refresh","save","update","destroy","loadRelations","changeHistory","changes","commit","hasChanges","lastModified","lastSaved","previous","revert"];e.exports=function(e){function t(t){this.defaultValues={},this.methods={},this.computed={},this.scopes={},this.actions={},n.default.deepMixIn(this,t);var i=r.defaults;e.extends&&a[e.extends]&&(i=a[e.extends]),n.default.fillIn(this.defaultValues,i.defaultValues),n.default.fillIn(this.methods,i.methods),n.default.fillIn(this.computed,i.computed),n.default.fillIn(this.scopes,i.scopes),n.default.fillIn(this.actions,i.actions),this.endpoint="endpoint"in t?t.endpoint:this.name}var r=this,a=r.definitions;if(n.default._s(e)&&(e={name:e.replace(/\s/gi,"")}),!n.default._o(e))throw n.default._oErr("definition");if(!n.default._s(e.name))throw new i.default.IA('"name" must be a string!');if(a[e.name])throw new i.default.R(e.name+" is already registered!");try{var u,s,f=function(){if(e.extends&&a[e.extends]?t.prototype=a[e.extends]:t.prototype=r.defaults,a[e.name]=new t(e),u=a[e.name],u.getResource=function(e){return r.definitions[e]},!n.default._s(u.idAttribute))throw new i.default.IA('"idAttribute" must be a string!');u.relations&&(u.relationList=[],u.relationFields=[],n.default.forOwn(u.relations,function(e,t){n.default.forOwn(e,function(r,i){n.default._a(r)||(e[i]=[r]),n.default.forEach(e[i],function(e){e.type=t,e.relation=i,e.name=u.name,u.relationList.push(e),e.localField&&u.relationFields.push(e.localField)})})}),u.relations.belongsTo&&n.default.forOwn(u.relations.belongsTo,function(e,t){n.default.forEach(e,function(e){e.parent&&(u.parent=t,u.parentKey=e.localKey,u.parentField=e.localField)})}),"function"==typeof Object.freeze&&(Object.freeze(u.relations),Object.freeze(u.relationList))),s=u.class=n.default.pascalCase(u.name);try{"function"==typeof u.useClass?(u.csp?u[s]=function(){u.useClass.call(this)}:u[s]=new Function("def","return function "+s+"() { def.useClass.call(this); }")(u),u[s].prototype=function(e){function t(){}return t.prototype=e,new t}(u.useClass.prototype)):u.csp?u[s]=function(){}:u[s]=new Function("return function "+s+"() {}")()}catch(e){u[s]=function(){}}n.default.forOwn(u.methods,function(e,t){u[s].prototype[t]=e}),u[s].prototype.set=function(e,t){var r=this;return n.default.set(this,e,t),u.compute(this),u.instanceEvents&&setTimeout(function(){r.emit("DS.change",u,r)},0),u.handleChange(this),this},u[s].prototype.get=function(e){return n.default.get(this,e)},n.default.applyRelationGettersToTarget(r,u,u[s].prototype);var f=null;u.hasOwnProperty("omit")?f=r.defaults.omit:(f=u.omit,u.omit=[]),u.omit=u.omit.concat(f||[]),n.default.forOwn(u.computed,function(e,t){if(n.default.isFunction(e)&&(u.computed[t]=[e],e=u.computed[t]),u.methods&&t in u.methods&&u.errorFn('Computed property "'+t+'" conflicts with previously defined prototype method!'),u.omit.push(t),n.default.isArray(e)){var r;if(1===e.length){var i=e[0].toString().match(/function.*?\(([\s\S]*?)\)/);r=i[1].split(","),r=n.default.filter(r,function(e){return e}),u.computed[t]=r.concat(e),e=u.computed[t],r.length&&u.errorFn("Use the computed property array syntax for compatibility with minified code!")}r=e.slice(0,e.length-1),n.default.forEach(r,function(e,t){r[t]=e.trim()}),e.deps=n.default.filter(r,function(e){return!!e})}else n.default.isObject(e)&&Object.defineProperty(u[s].prototype,t,e)}),n.default.forEach(o,function(e){u[s].prototype["DS"+n.default.pascalCase(e)]=function(){for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return n.unshift(this[u.idAttribute]||this),n.unshift(u.name),r[e].apply(r,n)}}),u[s].prototype.DSCreate=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return t.unshift(this),t.unshift(u.name),r.create.apply(r,t)},r.store[u.name]={collection:[],expiresHeap:new n.default.BinaryHeap(function(e){return e.expires},function(e,t){return e.item===t}),completedQueries:{},queryData:{},pendingQueries:{},index:{},modified:{},saved:{},previousAttributes:{},observers:{},changeHistories:{},changeHistory:[],collectionModified:0};var c=r.store[u.name];u.reapInterval&&setInterval(function(){return u.reap()},u.reapInterval);var l=["registerAdapter","getAdapterName","getAdapter","is","!clear"];for(var d in r)"function"==typeof r[d]&&l.push(d);n.default.forEach(l,function(e){var t=e;"!"!==t[0]&&(r[t].shorthand!==!1?(u[t]=function(){for(var e=arguments.length,n=Array(e),i=0;e>i;i++)n[i]=arguments[i];return n.unshift(u.name),r[t].apply(r,n)},u[t].before=function(e){var r=u[t];u[t]=function(){for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return r.apply(u,e.apply(u,n)||n)}}):u[t]=function(){for(var e=arguments.length,n=Array(e),i=0;e>i;i++)n[i]=arguments[i];return r[t].apply(r,n)})}),u.beforeValidate=n.default.promisify(u.beforeValidate),u.validate=n.default.promisify(u.validate),u.afterValidate=n.default.promisify(u.afterValidate),u.beforeCreate=n.default.promisify(u.beforeCreate),u.afterCreate=n.default.promisify(u.afterCreate),u.afterFind=n.default.promisify(u.afterFind),u.afterFindAll=n.default.promisify(u.afterFindAll),u.afterLoadRelations=n.default.promisify(u.afterLoadRelations),u.beforeUpdate=n.default.promisify(u.beforeUpdate),u.afterUpdate=n.default.promisify(u.afterUpdate),u.beforeDestroy=n.default.promisify(u.beforeDestroy),u.afterDestroy=n.default.promisify(u.afterDestroy);var p=void 0;return u.hasOwnProperty("defaultAdapter")&&(p=u.defaultAdapter),n.default.forOwn(u.actions,function(e,t){if(u[t]&&!u.actions[t])throw new Error('Cannot override existing method "'+t+'"!');e.request=e.request||function(e){return e},e.response=e.response||function(e){return e},e.responseError=e.responseError||function(e){return n.default.Promise.reject(e)},u[t]=function(r,i){n.default._o(r)&&(i=r),i=i||{};var o=u.getAdapter(e.adapter||p||"http"),a=n.default.deepMixIn({},e);if(!i.hasOwnProperty("endpoint")&&a.endpoint&&(i.endpoint=a.endpoint),"function"==typeof i.getEndpoint)a.url=i.getEndpoint(u,i);else{var s=[i.basePath||u.basePath||o.defaults.basePath,o.getEndpoint(u,n.default._sn(r)?r:null,i)];n.default._sn(r)&&s.push(r),s.push(e.pathname||t),a.url=n.default.makePath.apply(null,s)}return a.method=a.method||"GET",a.resourceName=u.name,n.default.deepMixIn(a,i),new n.default.Promise(function(e){return e(a)}).then(i.request||e.request).then(function(e){return o.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.resourceName=u.name),e}).then(i.response||e.response,i.responseError||e.responseError)}}),n.default.Events(u),u.handleChange=function(e){c.collectionModified=n.default.updateTimestamp(c.collectionModified),u.notify&&setTimeout(function(){u.emit("DS.change",u,e)},0)},{v:u}}();if("object"==typeof f)return f.v}catch(t){throw r.defaults.errorFn(t),delete a[e.name],delete r.store[e.name],t}}},function(e,t){e.exports=function(e,t,r){var n=this,i=n.utils,o=n.definitions[e],a=n.store[e],u=void 0,s=!1;if(t=i.resolveId(o,t),!o)throw new n.errors.NER(e);if(!i._sn(t))throw i._snErr("id");r=i._(o,r);for(var f=0;f<a.collection.length;f++)if(a.collection[f][o.idAttribute]==t){u=a.collection[f],a.expiresHeap.remove(u),s=!0;break}if(s){var c=function(){o.beforeEject(r,u),r.notify&&o.emit("DS.beforeEject",o,u);var e=[];return i.forOwn(a.queryData,function(t,n){t.$$injected&&i.remove(t,u),!t.length&&r.clearEmptyQueries&&e.push(n)}),i.forEach(a.changeHistories[t],function(e){i.remove(a.changeHistory,e)}),i.forEach(e,function(e){delete a.completedQueries[e],delete a.queryData[e]}),a.observers[t]&&"function"==typeof a.observers[t].close&&a.observers[t].close(),delete a.observers[t],delete a.index[t],delete a.previousAttributes[t],delete a.completedQueries[t],delete a.pendingQueries[t],delete a.changeHistories[t],delete a.modified[t],delete a.saved[t],o.instanceEvents&&u.off&&u.off(),a.collection.splice(f,1),o.handleChange(u),o.afterEject(r,u),r.notify&&o.emit("DS.afterEject",o,u),{v:u}}();if("object"==typeof c)return c.v}}},function(e,t){e.exports=function(e,t,r){var n=this,i=n.utils,o=n.definitions[e];if(t=t||{},!o)throw new n.errors.NER(e);if(!i._o(t))throw i._oErr("params");r=i._(o,r),i.applyScope(o,t,r);var a=n.store[e],u=i.toJson(t),s=o.filter(t);return i.isEmpty(t)?a.completedQueries={}:delete a.completedQueries[u],i.forEach(s,function(e){e&&e[o.idAttribute]&&o.eject(e[o.idAttribute],r)}),o.handleChange(s),s}},function(e,t){e.exports=function(e,t,r){var n=this,i=n.utils,o=n.definitions[e];if(!o)throw new n.errors.NER(e);if(t&&!i._o(t))throw i._oErr("params");return t=t||{},r=i._(o,r),i.applyScope(o,t,r),o.defaultFilter.call(n,n.store[e].collection,e,t,r)}},function(e,t,r){function n(e,t){var r=this,n=e.name;return function(i,a,u,s,f){var c=this,l=void 0,d=s&&s(e.idAttribute)?s(e.idAttribute):c[e.idAttribute];if(o.default.forEach(e.relationFields,function(e){delete i[e],delete a[e],delete u[e]}),(!o.default.isEmpty(i)||!o.default.isEmpty(a)||!o.default.isEmpty(u)||f)&&(l=r.get(n,d),t.modified[d]=o.default.updateTimestamp(t.modified[d]),l&&e.instanceEvents&&setTimeout(function(){l.emit("DS.change",e,l)},0),e.handleChange(l),e.keepChangeHistory)){var p={resourceName:n,target:l,added:i,removed:a,changed:u,timestamp:t.modified[d]};t.changeHistories[d].push(p),t.changeHistory.push(p)}e.computed&&(l=l||r.get(n,d),o.default.forOwn(e.computed,function(e,t){if(!o.default._o(e)){var r=!1;o.default.forEach(e.deps,function(e){(e in i||e in a||e in u||!(t in l))&&(r=!0)}),r=r||!e.deps.length,r&&o.default.compute.call(l,e,t)}})),e.idAttribute in u&&e.errorFn('Doh! You just changed the primary key of an object! Your data for the "'+n+'" resource is now in an undefined (probably broken) state.')}}function i(e,t,r,u){var s=this,f=void 0;if(o.default._a(r)){f=[];for(var c=0;c<r.length;c++)f.push(i.call(s,e,t,r[c],u))}else{var l=e.computed,d=e.idAttribute;if(l&&l[d]&&!function(){var e=[];o.default.forEach(l[d].deps,function(t){e.push(r[t])}),r[d]=l[d][l[d].length-1].apply(r,e)}(),!(d in r)){var p=new a.default.R(e.name+'.inject: "attrs" must contain the property specified by "idAttribute"!');throw u.errorFn(p),p}try{!function(){o.default.forEach(e.relationList,function(t){var n=t.relation,i=s.definitions[n],f=r[t.localField];if("function"==typeof t.inject)t.inject(e,t,r);else if(f&&t.inject!==!1){if(!i)throw new a.default.R(e.name+" relation is defined but the resource is not!");if(o.default._a(f))!function(){var a=[];o.default.forEach(f,function(f){if(f!==s.store[n].index[f[i.idAttribute]])try{var c=i.inject(f,u.orig());t.foreignKey&&o.default.set(c,t.foreignKey,r[e.idAttribute]),a.push(c)}catch(e){u.errorFn(e,"Failed to inject "+t.type+' relation: "'+n+'"!')}})}();else if(f!==s.store[n].index[f[i.idAttribute]])try{var c=i.inject(r[t.localField],u.orig());t.foreignKey&&o.default.set(c,t.foreignKey,r[e.idAttribute])}catch(e){u.errorFn(e,"Failed to inject "+t.type+' relation: "'+n+'"!')}}});var i=r[d],c=e.get(i),l=c?t.modified[i]:0;if(c)"merge"===u.onConflict?o.default.deepMixIn(c,r):"replace"===u.onConflict&&(o.default.forOwn(c,function(t,n){n!==e.idAttribute&&(r.hasOwnProperty(n)||delete c[n])}),o.default.forOwn(r,function(t,r){r!==e.idAttribute&&(c[r]=t)})),e.resetHistoryOnInject&&s.commit(e.name,i),t.observers[i]&&"function"==typeof t.observers[i]&&t.observers[i].deliver();else{c=r instanceof e[e.class]?r:new e[e.class],e.instanceEvents&&"function"!=typeof c.emit&&o.default.Events(c),o.default.forEach(e.relationList,function(t){("boolean"==typeof t.link?t.link:!!e.linkRelations)&&delete r[t.localField]}),o.default.deepMixIn(c,r),t.collection.push(c),t.changeHistories[i]=[];var p=n.call(s,e,t);e.watchChanges&&(t.observers[i]=new s.observe.ObjectObserver(c),t.observers[i].open(p,c)),t.index[i]=c,p.call(c,{},{},{},null,!0),t.previousAttributes[i]=o.default.copy(c,null,null,null,e.relationFields)}t.modified[i]=l&&t.modified[i]===l?o.default.updateTimestamp(t.modified[i]):t.modified[i],t.expiresHeap.remove(c);var h=(new Date).getTime();t.expiresHeap.push({item:c,timestamp:h,expires:e.maxAge?h+e.maxAge:Number.MAX_VALUE}),f=c}()}catch(e){u.errorFn(e,r)}}return f}var o=r(2),a=r(3);e.exports=function(e,t,r){var n=this,u=n.definitions[e],s=n.store[e],f=void 0;if(!u)throw new a.default.NER(e);if(!o.default._o(t)&&!o.default._a(t))throw new a.default.IA(e+'.inject: "attrs" must be an object or an array!');return r=o.default._(u,r),r.beforeInject(r,t),r.notify&&u.emit("DS.beforeInject",u,t),f=i.call(n,u,s,t,r),u.handleChange(f),r.afterInject(r,f),r.notify&&u.emit("DS.afterInject",u,f),f}},function(e,t,r){t.default={create:r(37),destroy:r(38),destroyAll:r(39),find:r(40),findAll:r(41),loadRelations:r(42),reap:r(43),refresh:function(e,t,r){var n=this,i=n.utils;return new i.Promise(function(o,a){var u=n.definitions[e];t=i.resolveId(n.definitions[e],t),u?i._sn(t)?(r=i._(u,r),r.bypassCache=!0,o(n.get(e,t))):a(i._snErr("id")):a(new n.errors.NER(e))}).then(function(i){return i?n.find(e,t,r):i}).catch(n.errorFn("refresh",e,t,r))},refreshAll:function(e,t,r){var n=this,i=n.utils,o=n.definitions[e];return t=t||{},new i.Promise(function(a,u){o?i._o(t)?(r=i._(o,r),r.bypassCache=!0,a(n.filter(e,t,r))):u(i._oErr("params")):u(new n.errors.NER(e))}).then(function(a){return r.bypassCache=!0,n.findAll(e,t,r).then(function(e){return i.forEach(a,function(t){-1===e.indexOf(t)&&o.eject(t)}),e})}).catch(n.errorFn("refreshAll",e,t,r))},save:r(44),update:r(45),updateAll:r(46)}},function(e,t){e.exports=function(e,t,r){var n=this,i=n.utils,o=n.definitions[e],a=void 0;r=r||{},t=t||{};var u=void 0;if(o)if(i._o(t)){if(r=i._(o,r),r.upsert&&i._sn(t[o.idAttribute]))return n.update(e,t[o.idAttribute],t,r)}else u=i._oErr("attrs");else u=new n.errors.NER(e);return new i.Promise(function(e,r){u?r(u):e(t)}).then(function(e){return r.beforeValidate.call(e,r,e)}).then(function(e){return r.validate.call(e,r,e)}).then(function(e){return r.afterValidate.call(e,r,e)}).then(function(e){return r.beforeCreate.call(e,r,e)}).then(function(e){return r.notify&&o.emit("DS.beforeCreate",o,e),a=n.getAdapterName(r),n.adapters[a].create(o,i.omit(e,r.omit),r)}).then(function(e){return r.afterCreate.call(e,r,e)}).then(function(t){if(r.notify&&o.emit("DS.afterCreate",o,t),r.cacheResponse){var a=n.inject(o.name,t,r.orig()),u=a[o.idAttribute],s=n.store[e];return s.completedQueries[u]=(new Date).getTime(),s.saved[u]=i.updateTimestamp(s.saved[u]),a}return n.createInstance(e,t,r)}).then(function(e){return i.respond(e,{adapter:a},r)}).catch(n.errorFn("create",e,t,r))}},function(e,t){e.exports=function(e,t,r){var n=this,i=n.utils,o=n.definitions[e],a=void 0,u=void 0;return new i.Promise(function(u,s){t=i.resolveId(o,t),o?i._sn(t)?(a=o.get(t)||{id:t},r=i._(o,r),u(a)):s(i._snErr("id")):s(new n.errors.NER(e))}).then(function(e){return r.beforeDestroy.call(e,r,e)}).then(function(e){return r.notify&&o.emit("DS.beforeDestroy",o,e),r.eagerEject&&o.eject(t),u=o.getAdapter(r),u.destroy(o,t,r)}).then(function(){return r.afterDestroy.call(a,r,a)}).then(function(e){return r.notify&&o.emit("DS.afterDestroy",o,e),o.eject(t),i.respond(t,{adapter:u},r)}).catch(function(i){return r&&r.eagerEject&&a&&o.inject(a,{notify:!1}),n.errorFn("destroy",e,t,r)(i)})}},function(e,t){e.exports=function(e,t,r){var n=this,i=n.utils,o=n.definitions[e],a=void 0,u=void 0,s=void 0;return t=t||{},new i.Promise(function(a,u){o?i._o(t)?(r=i._(o,r),i.applyScope(o,t,r),a()):u(i._oErr("attrs")):u(new n.errors.NER(e))}).then(function(){return u=o.defaultFilter.call(n,e,t),r.beforeDestroy(r,u)}).then(function(){return r.notify&&o.emit("DS.beforeDestroy",o,u),r.eagerEject&&(a=o.ejectAll(t)),s=o.getAdapterName(r),n.adapters[s].destroyAll(o,t,r)}).then(function(){return r.afterDestroy(r,u)}).then(function(){return r.notify&&o.emit("DS.afterDestroy",o,u),a||o.ejectAll(t)}).then(function(e){return i.respond(e,{adapter:s},r)}).catch(function(i){return r&&r.eagerEject&&a&&o.inject(a,{notify:!1}),n.errorFn("destroyAll",e,t,r)(i)})}},function(e,t){e.exports=function(e,t,r){var n=this,i=n.utils,o=n.definitions[e],a=n.store[e],u=void 0;return new i.Promise(function(u,s){if(o)if(i._sn(t)){r=i._(o,r),r.params&&(r.params=i.copy(r.params)),(r.bypassCache||!r.cacheResponse)&&delete a.completedQueries[t];var f=r.maxAge&&t in a.completedQueries&&a.completedQueries[t]+r.maxAge<(new Date).getTime();r.findStrictCache&&!(t in a.completedQueries)||!o.get(t)||r.bypassCache||f?(delete a.completedQueries[t],u()):u(o.get(t))}else s(i._snErr("id"));else s(new n.errors.NER(e))}).then(function(e){if(e)return e;if(!(t in a.pendingQueries)){var s=void 0,f=r.findStrategy||r.strategy;if("fallback"===f){var c=function e(a){return u=o.getAdapterName((r.findFallbackAdapters||r.fallbackAdapters)[a]),n.adapters[u].find(o,t,r).catch(function(t){return a++,a<r.fallbackAdapters.length?e(a):i.Promise.reject(t)})};s=c(0)}else u=o.getAdapterName(r),s=n.adapters[u].find(o,t,r);a.pendingQueries[t]=s.then(function(e){return r.afterFind.call(e,r,e)}).then(function(e){if(delete a.pendingQueries[t],r.cacheResponse){var n=o.inject(e,r.orig());return a.completedQueries[t]=(new Date).getTime(),a.saved[t]=i.updateTimestamp(a.saved[t]),n}return o.createInstance(e,r.orig())})}return a.pendingQueries[t]}).then(function(e){return i.respond(e,{adapter:u},r)}).catch(function(i){return a&&delete a.pendingQueries[t],n.errorFn("find",e,t,r)(i)})}},function(e,t){function r(e,t,r,n){var i=this,o=i.utils,a=i.definitions[t],u=i.store[t],s=i.definitions[t].idAttribute,f=(new Date).getTime();e=e||[],delete u.pendingQueries[r],u.completedQueries[r]=f;var c=a.inject(e,n.orig());return o._a(c)?o.forEach(c,function(e){if(e){var t=e[s];t&&(u.completedQueries[t]=f,u.saved[t]=o.updateTimestamp(u.saved[t]))}}):(n.errorFn("response is expected to be an array!"),u.completedQueries[c[s]]=f),c}e.exports=function(e,t,n){var i=this,o=i.utils,a=i.definitions[e],u=i.store[e],s=void 0,f=void 0;return new o.Promise(function(r,f){if(t=t||{},i.definitions[e])if(o._o(t)){n=o._(a,n),s=o.toJson(t),n.params&&(n.params=o.copy(n.params)),o.applyScope(a,t,n),(n.bypassCache||!n.cacheResponse)&&(delete u.completedQueries[s],delete u.queryData[s]);var c=n.maxAge&&s in u.completedQueries&&u.completedQueries[s]+n.maxAge<(new Date).getTime();s in u.completedQueries&&!c?r(n.useFilter?n.localKeys?a.getAll(n.localKeys,n.orig()):a.filter(t,n.orig()):u.queryData[s]):r()}else f(o._oErr("params"));else f(new i.errors.NER(e))}).then(function(c){if(c)return c;if(!(s in u.pendingQueries)){var l=void 0,d=n.findAllStrategy||n.strategy;if("fallback"===d){var p=function e(r){return f=a.getAdapterName((n.findAllFallbackAdapters||n.fallbackAdapters)[r]),i.adapters[f].findAll(a,t,n).catch(function(t){return r++,r<n.fallbackAdapters.length?e(r):o.Promise.reject(t)})};l=p(0)}else f=a.getAdapterName(n),l=i.adapters[f].findAll(a,t,n);u.pendingQueries[s]=l.then(function(e){return n.afterFindAll.call(e,n,e)}).then(function(t){return delete u.pendingQueries[s],n.cacheResponse?(u.queryData[s]=r.call(i,t,e,s,n),u.queryData[s].$$injected=!0,u.queryData[s]):(o.forEach(t,function(e,r){t[r]=a.createInstance(e,n.orig())}),t)})}return u.pendingQueries[s]}).then(function(e){return o.respond(e,{adapter:f},n)}).catch(function(r){return u&&delete u.pendingQueries[s],i.errorFn("findAll",e,t,n)(r)})}},function(e,t){function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}e.exports=function(e,t,n,i){var o=this,a=o.utils,u=o.errors,s=o.definitions[e],f=void 0;return new a.Promise(function(o,c){a._sn(t)&&(t=s.get(t)),a._s(n)&&(n=[n]),n=n||[],s?a._o(t)?a._a(n)?!function(){f=a._(s,i);var e=[];a.forEach(s.relationList,function(o){var u=o.relation,c=s.getResource(u),l=a._(c,i);if(!n.length||a.contains(n,u)||a.contains(n,o.localField)){var d=void 0,p={};l.allowSimpleWhere?p[o.foreignKey]=t[s.idAttribute]:(p.where={},p.where[o.foreignKey]={"==":t[s.idAttribute]});var h=l.orig(),v=o.localKey?a.get(t,o.localKey):null,m=!(!v&&0!==v);if("function"==typeof o.load)d=o.load(s,o,t,h);else if("hasMany"===o.type){if(o.localKeys){delete p[o.foreignKey];var g=a.get(t,o.localKeys)||[];g=a._a(g)?g:a.keys(g),p.where=r({},c.idAttribute,{in:g}),h.localKeys=g}else o.foreignKeys&&(delete p[o.foreignKey],p.where=r({},o.foreignKeys,{contains:t[s.idAttribute]}));d=c.findAll(p,h)}else"hasOne"===o.type?o.localKey&&m?d=c.find(v,h):o.foreignKey&&(d=c.findAll(p,h).then(function(e){return e.length?e[0]:null})):m&&(d=c.find(v,h));d&&(f.linkRelations||(d=d.then(function(e){t[o.localField]=e})),e.push(d))}}),o(e)}():c(new u.IA('"relations" must be a string or an array!')):c(new u.IA('"instance(id)" must be a string, number or object!')):c(new u.NER(e))}).then(function(e){return a.Promise.all(e)}).then(function(){return f.afterLoadRelations.call(t,f,t)}).catch(o.errorFn("loadRelations",e,t,n,i))}},function(e,t){e.exports=function(e,t){var r=this,n=r.utils,i=r.definitions[e],o=r.store[e];return new n.Promise(function(a,u){if(i){t=n._(i,t),t.hasOwnProperty("notify")||(t.notify=!1);for(var s=[],f=(new Date).getTime(),c=void 0;(c=o.expiresHeap.peek())&&c.expires<f;)s.push(c.item),delete c.item,o.expiresHeap.pop();a(s)}else u(new r.errors.NER(e))}).then(function(e){if(e.length&&(i.beforeReap(t,e),t.notify&&i.emit("DS.beforeReap",i,e)),"inject"===t.reapAction)!function(){var t=(new Date).getTime();n.forEach(e,function(e){o.expiresHeap.push({item:e,timestamp:t,expires:i.maxAge?t+i.maxAge:Number.MAX_VALUE})})}();else if("eject"===t.reapAction)n.forEach(e,function(e){i.eject(e[i.idAttribute])});else if("refresh"===t.reapAction){var r=function(){var t=[];return n.forEach(e,function(e){t.push(i.refresh(e[i.idAttribute]))}),{v:n.Promise.all(t)}}();if("object"==typeof r)return r.v}return e}).then(function(e){return e.length&&(i.afterReap(t,e),t.notify&&i.emit("DS.afterReap",i,e)),e}).catch(r.errorFn("reap",e,t))}},function(e,t){e.exports=function(e,t,r){var n=this,i=n.utils,o=n.errors,a=n.definitions[e],u=n.store[e],s=void 0,f=void 0,c=void 0;return new i.Promise(function(n,u){t=i.resolveId(a,t),a?i._sn(t)?a.get(t)?(s=a.get(t),r=i._(a,r),n(s)):u(new o.R('id "'+t+'" not found in cache!')):u(i._snErr("id")):u(new o.NER(e))}).then(function(e){return r.beforeValidate.call(e,r,e)}).then(function(e){return r.validate.call(e,r,e)}).then(function(e){return r.afterValidate.call(e,r,e)}).then(function(e){return r.beforeUpdate.call(e,r,e)}).then(function(e){if(r.notify&&a.emit("DS.beforeUpdate",a,e),r.changesOnly){u.observers[t]&&"function"==typeof u.observers[t]&&u.observers[t].deliver();var o=[],s=a.changes(t);for(var l in s.added)o.push(l);for(l in s.changed)o.push(l);if(s=i.pick(e,o),i.isEmpty(s))return f=!0,e;e=s}return c=a.getAdapterName(r),n.adapters[c].update(a,t,i.omit(e,r.omit),r)}).then(function(e){return r.afterUpdate.call(e,r,e)}).then(function(e){if(r.notify&&a.emit("DS.afterUpdate",a,e),f)return e;if(r.cacheResponse){var t=a.inject(e,r.orig()),n=t[a.idAttribute];return u.saved[n]=i.updateTimestamp(u.saved[n]),a.resetHistoryOnInject||(u.previousAttributes[n]=i.copy(t,null,null,null,a.relationFields)),t}return a.createInstance(e,r.orig())}).then(function(e){return i.respond(e,{adapter:c},r)}).catch(n.errorFn("save",e,t,r))}},function(e,t){e.exports=function(e,t,r,n){var i=this,o=i.utils,a=i.errors,u=i.definitions[e],s=void 0;return new o.Promise(function(i,s){t=o.resolveId(u,t),u?o._sn(t)?(n=o._(u,n),i(r)):s(o._snErr("id")):s(new a.NER(e))}).then(function(e){return n.beforeValidate.call(e,n,e)}).then(function(e){return n.validate.call(e,n,e)}).then(function(e){return n.afterValidate.call(e,n,e)}).then(function(e){return n.beforeUpdate.call(e,n,e)}).then(function(e){return n.notify&&u.emit("DS.beforeUpdate",u,e),s=u.getAdapterName(n),i.adapters[s].update(u,t,o.omit(e,n.omit),n)}).then(function(e){return n.afterUpdate.call(e,n,e)}).then(function(t){if(n.notify&&u.emit("DS.afterUpdate",u,t),n.cacheResponse){var r=u.inject(t,n.orig()),a=i.store[e],s=r[u.idAttribute];return a.saved[s]=o.updateTimestamp(a.saved[s]),u.resetHistoryOnInject||(a.previousAttributes[s]=o.copy(r,null,null,null,u.relationFields)),r}return u.createInstance(t,n.orig())}).then(function(e){return o.respond(e,{adapter:s},n)}).catch(i.errorFn("update",e,t,r,n))}},function(e,t){e.exports=function(e,t,r,n){var i=this,o=i.utils,a=i.errors,u=i.definitions[e],s=void 0;return new o.Promise(function(i,s){u?(n=o._(u,n),o.applyScope(u,r,n),i(t)):s(new a.NER(e))}).then(function(e){return n.beforeValidate.call(e,n,e)}).then(function(e){return n.validate.call(e,n,e)}).then(function(e){return n.afterValidate.call(e,n,e)}).then(function(e){return n.beforeUpdate.call(e,n,e)}).then(function(e){return n.notify&&u.emit("DS.beforeUpdate",u,e),s=u.getAdapterName(n),i.adapters[s].updateAll(u,o.omit(e,n.omit),r,n)}).then(function(e){return n.afterUpdate.call(e,n,e)}).then(function(r){n.notify&&u.emit("DS.afterUpdate",u,t);var a=n.orig();if(n.cacheResponse){var s=function(){var t=u.inject(r,a),n=i.store[e];return o.forEach(t,function(e){var t=e[u.idAttribute];n.saved[t]=o.updateTimestamp(n.saved[t]),u.resetHistoryOnInject||(n.previousAttributes[t]=o.copy(e,null,null,null,u.relationFields))}),{v:t}}();if("object"==typeof s)return s.v}else{var f=function(){var e=[];return o.forEach(r,function(t){e.push(u.createInstance(t,a))}),{v:e}}();if("object"==typeof f)return f.v}}).then(function(e){return o.respond(e,{adapter:s},n)}).catch(i.errorFn("updateAll",e,t,r,n))}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JSData=t():e.JSData=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.utils=void 0;var i=n(1),o=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})};for(var a in i){o(a)}var u=n(15),s=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})};for(var c in u){s(c)}var f=n(4),l=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})};for(var d in f){l(d)}var h=n(16),v=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})};for(var p in h){v(p)}var g=n(11),y=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return g[e]}})};for(var m in g){y(m)}var b=n(3),A=r(b);Promise.prototype.spread||(Promise.prototype.spread=function(e){return this.then(function(t){return e.apply(this,t)})}),t.utils=A;t.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"}},function(e,t,n){"use strict";function r(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function i(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=arguments.length<=1||void 0===arguments[1]?"id":arguments[1];if(!(0,a.isArray)(e))throw new TypeError("new Collection([data]): data: Expected array. Found "+("undefined"==typeof e?"undefined":r(e)));this.idAttribute=t,this.index=new s.Index([t],t),this.indexes={},e.forEach(this.index.insertRecord,this.index)}Object.defineProperty(t,"__esModule",{value:!0}),t.Collection=i;var o=n(2),a=n(3),u=n(4),s=n(13);t.Query=o.Query,(0,u.configure)({createIndex:function(e,t){(0,a.isString)(e)&&void 0===t&&(t=[e]);var n=this.indexes[e]=new s.Index(t,this.idAttribute);return this.index.visitAll(n.insertRecord,n),this},query:function(){return new o.Query(this)},between:function(){var e;return(e=this.query()).between.apply(e,arguments).run()},get:function(){var e;return(e=this.query()).get.apply(e,arguments).run()},getAll:function(){var e;return(e=this.query()).getAll.apply(e,arguments).run()},filter:function(e){return this.query().filter(e).run()},skip:function(e){return this.query().skip(e).run()},limit:function(e){return this.query().limit(e).run()},forEach:function(e,t){this.index.visitAll(e,t)},map:function(e,t){var n=[];return this.index.visitAll(function(r){n.push(e.call(t,r))}),n},insert:function(e){this.index.insertRecord(e),(0,a.forOwn)(this.indexes,function(t,n){t.insertRecord(e)})},update:function(e){this.index.updateRecord(e),(0,a.forOwn)(this.indexes,function(t,n){t.updateRecord(e)})},remove:function(e){this.index.removeRecord(e),(0,a.forOwn)(this.indexes,function(t,n){t.removeRecord(e)})},insertRecord:function(e,t){t||(t={});var n=t.index?this.indexes[t.index]:this.index;n.insertRecord(e)},updateRecord:function(e,t){t||(t={});var n=t.index?this.indexes[t.index]:this.index;n.updateRecord(e)},removeRecord:function(e,t){t||(t={});var n=t.index?this.indexes[t.index]:this.index;n.removeRecord(e)}})(i.prototype)},function(e,t,n){"use strict";function r(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function i(e){this.collection=e}function o(e,t,n,r){var i=e[t],a=(0,c.get)(n,i[0]),u=(0,c.get)(r,i[0]);return a&&(0,c.isString)(a)&&(a=a.toUpperCase()),u&&(0,c.isString)(u)&&(u=u.toUpperCase()),"DESC"===i[1]?a>u?-1:u>a?1:t<e.length-1?o(e,t+1,n,r):0:u>a?-1:a>u?1:t<e.length-1?o(e,t+1,n,r):0}function a(e){return e.replace(d,"\\$1")}function u(e,t){return new RegExp("^"+a(e).replace(h,".*").replace(v,".")+"$",t)}function s(e,t,n){switch(t){case"==":return e==n;case"===":return e===n;case"!=":return e!=n;case"!==":return e!==n;case">":return e>n;case">=":return e>=n;case"<":return n>e;case"<=":return n>=e;case"isectEmpty":return!(0,c.intersection)(e||[],n||[]).length;case"isectNotEmpty":return(0,c.intersection)(e||[],n||[]).length;case"in":return-1!==n.indexOf(e);case"notIn":return-1===n.indexOf(e);case"contains":return-1!==e.indexOf(n);case"notContains":return-1===e.indexOf(n);default:if(0===t.indexOf("like"))return null!==u(n,t.substr(4)).exec(e);if(0===t.indexOf("notLike"))return null===u(n,t.substr(7)).exec(e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.Query=i;var c=n(3),f=n(4),l={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""},d=/([.*+?^=!:${}()|[\]\/\\])/g,h=/%/g,v=/_/g;(0,f.configure)({getData:function(){return this.data||(this.data=this.collection.index.getAll()),this.data},between:function(e,t,n){n||(n={});var r=this.collection,i=n.index?r.indexes[n.index]:r.index;if(this.data)throw new Error("Cannot access index after first operation!");return this.data=i.between(e,t,n),this},get:function(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=arguments[1];if(t||(t={}),this.data)throw new Error("Cannot access index after first operation!");if(e&&!(0,c.isArray)(e)&&(e=[e]),!e.length)return this.getData(),this;var n=this.collection,r=t.index?n.indexes[t.index]:n.index;return this.data=r.get(e),this},getAll:function(){var e=this,t={};if(this.data)throw new Error("Cannot access index after first operation!");for(var n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];if(!r.length||1===r.length&&(0,c.isObject)(r[0]))return this.getData(),this;r.length&&(0,c.isObject)(r[r.length-1])&&(t=r[r.length-1],r.pop());var o=this.collection,a=t.index?o.indexes[t.index]:o.index;return this.data=[],r.forEach(function(t){e.data=e.data.concat(a.get(t))}),this},filter:function(e,t){var n=this;return e||(e={}),this.getData(),(0,c.isObject)(e)?!function(){var t={};(0,c.isObject)(e.where)&&(t=e.where),(0,c.forOwn)(e,function(e,n){n in l||n in t||(t[n]={"==":e})});var r=[],i=[],a=[];(0,c.forOwn)(t,function(e,t){(0,c.isObject)(e)||(e={"==":e}),(0,c.forOwn)(e,function(e,n){r.push(t),i.push(n),a.push(e)})}),r.length&&!function(){var e=void 0,t=r.length;n.data=n.data.filter(function(n){var o=!0,u=!0;for(e=0;t>e;e++){var f=i[e],l="|"===f.charAt(0);f=l?f.substr(1):f;var d=s((0,c.get)(n,r[e]),f,a[e]);void 0!==d&&(u=o?d:l?u||d:u&&d),o=!1}return u})}();var u=e.orderBy||e.sort;(0,c.isString)(u)&&(u=[[u,"ASC"]]),(0,c.isArray)(u)||(u=null),u&&!function(){var e=0;u.forEach(function(e,t){(0,c.isString)(e)&&(u[t]=[e,"ASC"])}),n.data.sort(function(t,n){return o(u,e,t,n)})}(),(0,c.isNumber)(e.skip)?n.skip(e.skip):(0,c.isNumber)(e.offset)&&n.skip(e.offset),(0,c.isNumber)(e.limit)&&n.limit(e.limit)}():(0,c.isFunction)(e)&&(this.data=this.data.filter(e,t)),this},skip:function(e){if(!(0,c.isNumber)(e))throw new TypeError("skip: Expected number but found "+("undefined"==typeof e?"undefined":r(e))+"!");var t=this.getData();return e<t.length?this.data=t.slice(e):this.data=[],this},limit:function(e){if(!(0,c.isNumber)(e))throw new TypeError("limit: Expected number but found "+("undefined"==typeof e?"undefined":r(e))+"!");var t=this.getData();return this.data=t.slice(0,Math.min(t.length,e)),this},forEach:function(e,t){return this.getData().forEach(e,t),this},map:function(e,t){return this.data=this.getData().map(e,t),this},run:function(){var e=this.data;return this.data=null,this.params=null,e}})(i.prototype)},function(e,t){"use strict";function n(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function r(e){return"[object Object]"===toString.call(e)||!1}function i(e){return!!e&&"object"===("undefined"==typeof e?"undefined":n(e))&&e.constructor===Object}function o(e){return"[object RegExp]"===toString.call(e)||!1}function a(e){return"string"==typeof e||e&&"object"===("undefined"==typeof e?"undefined":n(e))&&"[object String]"===toString.call(e)||!1}function u(e){return e&&"object"===("undefined"==typeof e?"undefined":n(e))&&"[object Date]"===toString.call(e)||!1}function s(e){var t="undefined"==typeof e?"undefined":n(e);return"number"===t||e&&"object"===t&&"[object Number]"===toString.call(e)||!1}function c(e){return"[object Boolean]"===toString.call(e)}function f(e){return"function"==typeof e||e&&"[object Function]"===toString.call(e)||!1}function l(e){return a(e)||s(e)}function d(e,t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;return e[r]}function h(e,t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;delete e[r]}function v(e,t){if(!t)return e;var n=t.split(".");return n.forEach(function(t){e[t]||(e[t]={}),e=e[t]}),e}function p(e,t,n){if(r(t))g(t,function(t,n){p(e,n,t)});else{var i=R.exec(t);i?v(e,i[1])[i[2]]=n:e[t]=n}}function g(e,t,n){var r=Object.keys(e),i=r.length,o=void 0;for(o=0;i>o;o++)t.call(n,e[r[o]],r[o],e)}function y(e,t){return t&&g(t,function(e,t){var n=this[t];i(e)&&i(n)?y(n,e):this[t]=e},e),e}function m(e){return Promise.resolve(e)}function b(e){return Promise.reject(e)}function A(e,t){for(var n in e){var r=e[n];void 0!==t[n]||f(r)||(t[n]=r)}}function x(e,t){if(!e||!t)return[];var n=[],r=void 0,i=void 0,o=e.length;for(i=0;o>i;i++)r=e[i],-1===n.indexOf(r)&&-1!==t.indexOf(r)&&n.push(r);return n}function O(e,t){g(t,function(t,n){void 0===e[n]&&(e[n]=t)})}function w(e,t){if(!t||!t.length)return!1;for(var n=void 0,r=0;r<t.length;r++)if("[object RegExp]"===Object.prototype.toString.call(t[r])&&t[r].test(e)||t[r]===e)return n=e;return!!n}function j(e,t){var n=[];return g(e,function(e,r){w(r,t)&&n.push(r)}),n.forEach(function(t){delete e[t]}),e}function k(e){return a(e)?JSON.parse(e):e}function _(e,t,n,i,a){if(t){if(e===t)throw new Error("Cannot copy! Source and destination are identical.");if(n=n||[],i=i||[],r(e)){var s=n.indexOf(e);if(-1!==s)return i[s];n.push(e),i.push(t)}var c=void 0;if(I(e)){var f=void 0;for(t.length=0,f=0;f<e.length;f++)c=_(e[f],null,n,i,a),r(e[f])&&(n.push(e[f]),i.push(c)),t.push(c)}else{I(t)?t.length=0:g(t,function(e,n){delete t[n]});for(var l in e)if(e.hasOwnProperty(l)){if(w(l,a))continue;c=_(e[l],null,n,i,a),r(e[l])&&(n.push(e[l]),i.push(c)),t[l]=c}}}else t=e,e&&(I(e)?t=_(e,[],n,i,a):u(e)?t=new Date(e.getTime()):o(e)?(t=new RegExp(e.source,e.toString().match(/[^\/]*$/)[0]),t.lastIndex=e.lastIndex):r(e)&&(t=_(e,Object.create(Object.getPrototypeOf(e)),n,i,a)));return t}function E(e,t,n){return""+t.toUpperCase()+n.toLowerCase()}function S(e){return e.replace(N,"").replace(D,E)}function P(e){return e.split(F).map(S).join("")}function M(e){return e=P(e),e?e.charAt(0).toLowerCase()+e.slice(1):e}function C(e,t,n){e=e||this;var r={};t||n||(t=function(){return r},n=function(e){r=e}),Object.defineProperties(e,{on:{value:function(e,r,i){t.call(this)||n.call(this,{});var o=t.call(this);o[e]=o[e]||[],o[e].push({f:r,c:i})}},off:{value:function(e,r){var i=t.call(this),o=i[e];if(o)if(r){for(var a=0;a<o.length;a++)if(o[a].f===r){o.splice(a,1);break}}else o.splice(0,o.length);else n.call(this,{})}},emit:{value:function(){for(var e=t.call(this),n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=e[r.shift()]||[];if(o)for(var a=0;a<o.length;a++)o[a].f.apply(o[a].c,r)}}})}Object.defineProperty(t,"__esModule",{value:!0}),t.isObject=r,t.isRegExp=o,t.isString=a,t.isDate=u,t.isNumber=s,t.isBoolean=c,t.isFunction=f,t.isSorN=l,t.get=d,t.unset=h,t.set=p,t.forOwn=g,t.deepMixIn=y,t.resolve=m,t.reject=b,t._=A,t.intersection=x,t.fillIn=O,t.isBlacklisted=w,t.omit=j,t.fromJson=k,t.copy=_,t.pascalCase=P,t.camelCase=M,t.Events=C;var I=t.isArray=Array.isArray,R=/^(.+)\.(.+)$/,F=(t.toJson=JSON.stringify,/\s+/),N=/[^A-Za-z]/g,D=/(\w)(\w*)/g},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5),i=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})};for(var o in r){i(o)}var a=n(6),u=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})};for(var s in a){u(s)}var c=n(7),f=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})};for(var l in c){f(l)}var d=n(8),h=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}})};for(var v in d){h(v)}var p=n(9),g=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})};for(var y in p){g(y)}var m=n(10),b=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return m[e]}})};for(var A in m){b(A)}var x=n(12),O=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return x[e]}})};for(var w in x){O(w)}t.DECORATORS="FIXME"},function(e,t,n){"use strict";function r(e,t,n){n||(n={});var r=n.localField=n.localField||t.name.toLowerCase(),i=n.localKey=n.localKey||t.name.toLowerCase()+"_id",a={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){var e=(0,o.get)(this,i);return void 0!==e?t.get(e):void 0},set:function(e){return(0,o.set)(this,i,e[t.idAttribute]),(0,o.get)(this,r)}};return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete a.get,delete a.set,a.writable=!0),n.get&&!function(){var r=a.get;a.get=function(){var i=this;return n.get(e,t,this,r?function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.apply(i,t)}:void 0)}}(),n.set&&!function(){var r=a.set;a.set=function(i){var o=this;return n.set(e,t,this,i,r?function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.apply(o,t)}:void 0)}}(),Object.defineProperty(e.prototype,r,a),e.relationList||(e.relationList=[]),e.relationFields||(e.relationFields=[]),n.type="belongsTo",n.name=e.name,n.relation=t.name,n.Relation=t,e.relationList.push(n),e.relationFields.push(r),e.data().createIndex(i),e}function i(e,t){return function(n){return r(n,e,t)}}Object.defineProperty(t,"__esModule",{value:!0}),t.belongsTo=i;var o=n(3)},function(e,t,n){"use strict";function r(e){var t=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return e=e||{},function(n){return(0,i.forOwn)(e,function(e,r){(void 0===n[r]||t)&&(n[r]=(0,i.copy)(e))}),n}}Object.defineProperty(t,"__esModule",{value:!0}),t.configure=r;var i=n(3)},function(e,t,n){"use strict";function r(e,t,n){n||(n={});var r=n.localField||(0,o.camelCase)(t.name)+"Collection",i=n.foreignKey,a=n.localKeys,u=n.foreignKeys;i||a||u||(i=n.foreignKey=(0,o.camelCase)(e.name)+"Id"),i&&t.data().createIndex(i);var s={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){var n={};if(i)return t.getAll((0,o.get)(this,e.idAttribute),{index:i});if(a){var r=(0,o.get)(this,a)||[],s=(0,o.isArray)(r)?r:Object.keys(r);return t.getAll.apply(t,s)}return u?((0,o.set)(n,"where."+u+".contains",(0,o.get)(this,e.idAttribute)),t.filter(n)):void 0},set:function(n){var s=this;return n&&n.length&&!function(){var r=(0,o.get)(s,e.idAttribute);i?n.forEach(function(e){(0,o.set)(e,i,r)}):a?!function(){var e=[];n.forEach(function(n){e.push((0,o.get)(n,t.idAttribute))}),(0,o.set)(s,a,e)}():u&&n.forEach(function(e){var t=(0,o.get)(e,u);t?-1===t.indexOf(r)&&t.push(r):(0,o.set)(e,u,[r])})}(),(0,o.get)(this,r)}};return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete s.get,delete s.set,s.writable=!0),n.get&&!function(){var r=s.get;s.get=function(){var i=this;return n.get(e,t,this,r?function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.apply(i,t)}:void 0)}}(),n.set&&!function(){var r=s.set;s.set=function(i){var o=this;return n.set(e,t,this,i,r?function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.apply(o,t)}:void 0)}}(),Object.defineProperty(e.prototype,r,s),e.relationList||(e.relationList=[]),e.relationFields||(e.relationFields=[]),n.type="hasMany",n.name=e.name,n.relation=t.name,n.Relation=t,e.relationList.push(n),e.relationFields.push(r),e}function i(e,t){return function(n){return r(n,e,t)}}Object.defineProperty(t,"__esModule",{value:!0}),t.hasMany=i;var o=n(3)},function(e,t,n){"use strict";function r(e,t,n){n||(n={});var r=n.localField=n.localField||(0,o.camelCase)(t.name),i=n.foreignKey=n.foreignKey||(0,o.camelCase)(e.name)+"Id",a={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){var n=t.getAll((0,o.get)(this,e.idAttribute),{index:i});return n&&n.length?n[0]:void 0},set:function(t){return(0,o.set)(t,i,(0,o.get)(this,e.idAttribute)),(0,o.get)(this,r)}};return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete a.get,delete a.set),n.get&&!function(){var r=a.get;a.get=function(){var i=this;return n.get(e,t,this,r?function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.apply(i,t)}:void 0)}}(),n.set&&!function(){var r=a.set;a.set=function(i){var o=this;return n.set(e,t,this,i,r?function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.apply(o,t)}:void 0)}}(),Object.defineProperty(e.prototype,r,a),e.relationList||(e.relationList=[]),e.relationFields||(e.relationFields=[]),n.type="hasOne",n.name=e.name,n.relation=t.name,n.Relation=t,e.relationList.push(n),e.relationFields.push(r),e.data().createIndex(i),e}function i(e,t){return function(n){return r(n,e,t)}}Object.defineProperty(t,"__esModule",{value:!0}),t.hasOne=i;var o=n(3)},function(e,t,n){"use strict";function r(e){return e+": Schemas are not inheritable, did you forget to define a schema?"}function i(e){return e||(e={}),function(e){var t=new o.Collection([],e.idAttribute);e.data=function(){if(this.data===Object.getPrototypeOf(this).data)throw new Error(r(this.name));return t}}}Object.defineProperty(t,"__esModule",{value:!0}),t.initialize=i;var o=n(1)},function(e,t,n){"use strict";function r(e,t,n){var r={enumerable:void 0!==n.enumerable?n.enumerable:!0,configurable:void 0!==n.configurable?n.configurable:!0};return r.get=function(){return this._get("props."+t)},r.set=function(r){var i=this,u=this._get,s=this._set,c=this._unset;if(!u("noValidate")){var f=(0,a.validate)(n,r);if(f)throw new Error(f.join(", "))}return n.track&&!u("creating")&&!function(){var e=u("changing"),n=u("previous."+t),a=u("props."+t),f=u("changed");e||(f=[]),a!==r&&f.push(t),n!==r?s("changes."+t,r):c("changes."+t),!e&&f.length&&(s("changed",f),s("changing",!0),s("eventId",setTimeout(function(){c("changed"),c("eventId"),c("changing");var e=void 0;for(e=0;e<f.length;e++)i.emit("change:"+f[e],i,(0,o.get)(i,f[e]));i.emit("change",i,u("changes"))},0)))}(),s("props."+t,r),u("$")&&n.indexed&&e.data().updateRecord(this,{index:t}),r},n.indexed&&e.createIndex(t),n.get&&(r.get?!function(){var e=r.get;r.get=function(){return n.get.call(this,e)}}():r.get=n.get),n.set&&(r.set?!function(){var e=r.set;r.set=function(t){return n.set.call(this,t,e)}}():r.set=n.set),r}function i(e){return e||(e={}),function(t){try{t.data()}catch(n){(0,s.initialize)(e)(t)}return t.schema||(t.schema={}),(0,u.configure)(t.schema,e),(0,o.forOwn)(e,function(e,n){var i=r(t,n,e);i.writable||Object.defineProperty(t.prototype,n,i)}),t}}Object.defineProperty(t,"__esModule",{value:!0}),t.setSchema=i;var o=n(3),a=n(11),u=n(6),s=n(9)},function(e,t,n){"use strict";function r(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function i(e,t){var n=[];return(0,o.forOwn)(e,function(e,r){var i=u[r];if(i){var o=i(e,t);o&&n.push(o)}}),n.length?n:void 0}Object.defineProperty(t,"__esModule",{value:!0}),t.rules=void 0,t.validate=i;var o=n(3),a={array:o.isArray,boolean:o.isBoolean,integer:o.isNumber,number:o.isNumber,null:function(e){return null===e},object:o.isObject,string:o.isString},u=t.rules={type:function(e,t){if(void 0!==t){(0,o.isString)(e)&&(e=[e]);var n=e.map(function(n){var r=a[n];return r?r(t)?void 0:1:"type: Unknown type "+e});return-1!==n.indexOf(void 0)?void 0:"type: Expected: "+e.join(" or ")+". Actual: "+("undefined"==typeof t?"undefined":r(t))}},anyOf:function(e,t){var n=!1,r=[];return e.forEach(function(e){var o=i(e,t);o?r=r.concat(o):n=!0}),n?void 0:r},allOf:function(e,t){var n=[];return e.forEach(function(e){n=n.concat(i(e,t)||[])}),n.length?void 0:n},oneOf:function(e,t){var n=!1,r=[];return e.forEach(function(e){var o=i(e,t);if(o)r=r.concat(o);else{if(n)return r=["more than one schema validated"],n=!1,!1;n=!0}}),n?void 0:r}}},function(e,t,n){"use strict";function r(e,t,n){return n||(n={}),function(r){r.adapters&&r.adapters===Object.getPrototypeOf(r).adapters&&(r.adapters={},(0,i.fillIn)(r.adapters,Object.getPrototypeOf(r).adapters)),r.adapters[e]=t,(n===!0||n.default)&&(r.defaultAdapter=e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.registerAdapter=r;var i=n(3)},function(e,t,n){"use strict";function r(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=arguments[1];if(!(0,i.isArray)(e))throw new Error("fieldList must be an array.");this.fieldList=e,this.idAttribute=t,this.isIndex=!0,this.keys=[],this.values=[]}Object.defineProperty(t,"__esModule",{value:!0}),t.Index=r;var i=n(3),o=n(4),a=n(14);(0,o.configure)({set:function(e,t){(0,i.isArray)(e)||(e=[e]);var n=e.shift()||null,o=(0,a.binarySearch)(this.keys,n);if(0===e.length)if(o.found){var u=(0,a.binarySearch)(this.values[o.index],t,this.idAttribute);u.found||(0,a.insertAt)(this.values[o.index],u.index,t)}else(0,a.insertAt)(this.keys,o.index,n),(0,a.insertAt)(this.values,o.index,[t]);else if(o.found)this.values[o.index].set(e,t);else{(0,a.insertAt)(this.keys,o.index,n);var s=new r([],this.idAttribute);s.set(e,t),(0,a.insertAt)(this.values,o.index,s)}},get:function(e){(0,i.isArray)(e)||(e=[e]);var t=e.shift()||null,n=(0,a.binarySearch)(this.keys,t);return 0===e.length?n.found?this.values[n.index].isIndex?this.values[n.index].getAll():this.values[n.index]:[]:n.found?this.values[n.index].get(e):[]},getAll:function(){var e=[];return this.values.forEach(function(t){e=t.isIndex?e.concat(t.getAll()):e.concat(t)}),e},visitAll:function(e,t){this.values.forEach(function(n){n.isIndex?n.visitAll(e,t):n.forEach(e,t)})},query:function(e){var t=void 0,n=void 0;if(e[">"]?(t=e[">"],e.leftInclusive=!1):e[">="]&&(t=e[">="],e.leftInclusive=!0),e["<"]?(n=e["<"],e.rightInclusive=!1):e["<="]&&(n=e["<="],e.rightInclusive=!0),t.length!==n.length)throw new Error("Key arrays must be same length");return this.between(t,n,(0,i.omit)(e,[">",">=","<","<="]))},between:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];(0,i.isArray)(e)||(e=[e]),(0,i.isArray)(t)||(t=[t]),(0,i.fillIn)(n,{leftInclusive:!0,rightInclusive:!1,limit:void 0,offset:0});var r=this._between(e,t,n);return n.limit?r.slice(n.offset,n.limit+n.offset):r.slice(n.offset)},_between:function(e,t,n){var r=[],o=e.shift(),u=t.shift(),s=void 0;if(s=void 0!==o?(0,a.binarySearch)(this.keys,o):{found:!1,index:0},0===e.length){s.found&&n.leftInclusive===!1&&(s.index+=1);for(var c=s.index;c<this.keys.length;c+=1){if(void 0!==u)if(n.rightInclusive){if(this.keys[c]>u)break}else if(this.keys[c]>=u)break;if(r=this.values[c].isIndex?r.concat(this.values[c].getAll()):r.concat(this.values[c]),n.limit&&r.length>=n.limit+n.offset)break}}else for(var c=s.index;c<this.keys.length;c+=1){var f=this.keys[c];if(f>u)break;if(r=this.values[c].isIndex?f===o?r.concat(this.values[c]._between((0,i.copy)(e),t.map(function(){}),n)):f===u?r.concat(this.values[c]._between(e.map(function(){}),(0,i.copy)(t),n)):r.concat(this.values[c].getAll()):r.concat(this.values[c]),n.limit&&r.length>=n.limit+n.offset)break}return n.limit?r.slice(0,n.limit+n.offset):r},remove:function(e,t){(0,i.isArray)(e)||(e=[e]);var n=e.shift(),r=(0,a.binarySearch)(this.keys,n);if(0===e.length){if(r.found){var o=(0,a.binarySearch)(this.values[r.index],t,this.idAttribute);o.found&&((0,a.removeAt)(this.values[r.index],o.index),0===this.values[r.index].length&&((0,a.removeAt)(this.keys,r.index),(0,a.removeAt)(this.values,r.index)))}}else r.found&&this.values[r.index].delete(e,t)},clear:function(){this.keys=[],this.values=[]},insertRecord:function(e){var t=this.fieldList.map(function(t){return e[t]||null});this.set(t,e)},removeRecord:function(e){var t=this.fieldList.map(function(t){return e[t]||null});this.remove(t,e)},updateRecord:function(e){this.removeRecord(e),this.insertRecord(e)}})(r.prototype)},function(e,t){"use strict";function n(e,t,n){return e===t?0:(n&&(e=e[n],t=t[n]),null===e&&null===t?0:null===e?-1:null===t?1:t>e?-1:e>t?1:0)}function r(e,t,n){return e.splice(t,0,n),e}function i(e,t){return e.splice(t,1),e}function o(e,t,r){for(var i=0,o=e.length,a=void 0,u=void 0;o>i;){if(u=(i+o)/2|0,a=n(t,e[u],r),0===a)return{found:!0,index:u};0>a?o=u:i=u+1}return{found:!1,index:o}}Object.defineProperty(t,"__esModule",{value:!0}),t.sort=n,t.insertAt=r,t.removeAt=i,t.binarySearch=o},function(e,t,n){"use strict";function r(e){e||(e={}),this.definitions={}}Object.defineProperty(t,"__esModule",{value:!0}),t.DS=r;var i=n(4),o=n(3),a=n(16);(0,i.configure)({clear:function(){var e={};return(0,o.forOwn)(this.definitions,function(t){var n=t.name;e[n]=t.ejectAll()}),e},defineModel:function(e){var t=a.Model.extend(e.methods||{},e);return this.definitions[t.name]=t,t}})(r.prototype),r.prototype.defineResource=r.prototype.defineModel,(0,o.forOwn)(a.Model,function(e,t){(0,o.isFunction)(e)&&(r.prototype[t]=function(e){var n;if(!this.definitions[e])throw new Error(e+" is not a registered Model!");for(var r=arguments.length,i=Array(r>1?r-1:0),o=1;r>o;o++)i[o-1]=arguments[o];return(n=this.definitions[e])[t].apply(n,i)})})},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;var f=n(3),l=r(f),d=n(4),h=n(11),v=r(h),p=l.resolve,g=!1;try{g=!!window}catch(e){}var y=function(e,t,n,r){return n.raw?(t.adapter=r,n.autoInject&&(t.data=e.inject(t.data)),t):(n.autoInject&&(t=e.inject(t)),t)},m=function e(){s(this,e)},b=t.Model=function(e){function t(e,n){s(this,t);var r=a(this,Object.getPrototypeOf(t).call(this));e||(e={}),n||(n={});var i={};return Object.defineProperties(r,{_get:{value:function(e){return l.get(i,e)}},_set:{value:function(e,t){return l.set(i,e,t)}},_unset:{value:function(e){return l.unset(i,e)}}}),r._set("creating",!0),n.noValidate&&r._set("noValidate",!0),(0,d.configure)(e)(r),r._unset("creating"),r._unset("noValidate"),r._set("previous",l.copy(e)),r}return u(t,e),c(t,[{key:"schema",value:function(e){var t=this.constructor.schema;return e?t[e]:t}},{key:"validate",value:function(e,t){var n=[],r=this.schema();if(e)if(l.isString(e)){var i=r[e];i&&(n=v.validate(i,t)||[])}else l.forOwn(r,function(t,r){n=n.concat(v.validate(t,l.get(e,r))||[])});else e=this;return n.length?n:void 0}},{key:"create",value:function(e){return this.constructor.create(this,e)}},{key:"save",value:function(e){var t=this.constructor,n=t.getAdapterName(e);return t.getAdapter(n).update(t,l.get(this,t.idAttribute),this,e)}},{key:"destroy",value:function(e){var t=this.constructor;return t.destroy(l.get(this,t.idAttribute),e)}},{key:"get",value:function(e){return l.get(this,e)}},{key:"set",value:function(e,t,n){return n||(n={}),l.set(this,e,t)}},{key:"toJSON",value:function(e){var n=this;e||(e={});var r=this.constructor,i=this;return this instanceof t&&(i={},l.set(i,this),r&&r.relationList&&e.with&&(l.isString(e.with)&&(e.with=[e.with]),r.relationList.forEach(function(t){var r=void 0;-1!==e.with.indexOf(t.relation)?r=t.relation:-1!==e.with.indexOf(t.localField)&&(r=t.localField),r&&!function(){var o={with:e.with.slice()};o.with.splice(o.with.indexOf(r),1),o.with.forEach(function(e,t){e&&0===e.indexOf(r)&&e.length>=r.length&&"."===e[r.length]?o.with[t]=e.substr(r.length+1):o.with[t]=""});var a=l.get(n,t.localField);a&&(l.isArray(a)?l.set(i,t.localField,a.map(function(e){return t.Relation.prototype.toJSON.call(e,o)})):l.set(i,t.localField,t.Relation.prototype.toJSON.call(a,o)))}()}))),i}}],[{key:"data",value:function(){throw new Error(this.name+".data(): Did you forget to define a schema?")}},{key:"createIndex",value:function(e,t){this.data().createIndex(e,t)}},{key:"createInstance",value:function(e){var t=this;return e instanceof t?e:new t(e)}},{key:"is",value:function(e){return e instanceof this}},{key:"inject",value:function(e,t){t||(t={});var n=this,r=!1,i=n.data(),a=n.idAttribute,u=n.relationList||[];return l.isArray(e)||(e=[e],r=!0),e.forEach(function(e){u.forEach(function(t){var r=t.Relation,i=l.get(e,t.localField);if(l.isFunction(t.inject))t.inject(n,t,e);else if(i&&t.inject!==!1)if(l.isArray(i))i.forEach(function(n){if(n!==r.get(l.get(n,r.idAttribute)))try{t.foreignKey&&l.set(n,t.foreignKey,l.get(e,a)),r.inject(n)}catch(e){throw new Error("Failed to inject "+t.type+' relation: "'+t.relation+'"!')}}),t.localKeys&&l.set(i,t.localKeys,i.map(function(e){return l.get(e,r.idAttribute)}));else if(i!==r.get(r.idAttribute))try{t.localKey&&l.set(e,t.localKey,l.get(i,r.idAttribute)),t.foreignKey&&l.set(i,t.foreignKey,l.get(e,a)),r.inject(i)}catch(e){throw new Error("Failed to inject "+t.type+' relation: "'+t.relation+'"!')}("boolean"==typeof t.link?t.link:!!n.linkRelations)&&l.unset(e,t.localField)})}),e=e.map(function(e){var r=l.get(e,a);if(!r)throw new TypeError("User#"+a+": Expected string or number, found "+("undefined"==typeof r?"undefined":o(r))+"!");var u=n.get(r);if(u){var s=t.onConflict||n.onConflict;"merge"===s?l.deepMixIn(u,e):"replace"===s&&(l.forOwn(u,function(t,n){n===a||e.hasOwnProperty(n)||delete u[n]}),u.set(e)),e=u}else e=n.createInstance(e),e._set("$",!0),i.index.insertRecord(e);return l.forOwn(i.indexes,function(t){t.updateRecord(e)}),e}),r?e.length?e[0]:void 0:e}},{key:"eject",value:function(e){var t=this.get(e);return t&&(t._unset("$"),this.data().remove(t)),t}},{key:"ejectAll",value:function(e){var t=this.filter(e),n=this.data();return t.forEach(function(e){n.remove(e)}),t}},{key:"get",value:function(e){var t=this.data().get(e);return t.length?t[0]:void 0}},{key:"between",value:function(){var e;return(e=this.data()).between.apply(e,arguments)}},{key:"getAll",value:function(){var e;return(e=this.data()).getAll.apply(e,arguments)}},{key:"filter",value:function(e){return this.data().filter(e)}},{key:"query",value:function(){return this.data().query()}},{key:"getAdapter",value:function(e){var t=this.getAdapterName(e);if(!t)throw new ReferenceError(t+" not found!");return this.adapters[t]}},{key:"getAdapterName",value:function(e){ | ||
return e||(e={}),l.isString(e)&&(e={adapter:e}),e.adapter||e.defaultAdapter}},{key:"beforeCreate",value:function(){}},{key:"create",value:function(e,t){var n=this,r=void 0;return e||(e={}),t||(t={}),l._(this,t),t.op="create",t.upsert&&l.get(e,this.idAttribute)?this.update(l.get(e,this.idAttribute),e,t):p(this.beforeCreate(e,t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).create(n,n.prototype.toJSON.call(e,t),t)}).then(function(e){return p(n.afterCreate(e,t)).then(function(){return y(n,e,t,r)})})}},{key:"afterCreate",value:function(){}},{key:"beforeCreateMany",value:function(){}},{key:"createMany",value:function(e,t){var n=this,r=void 0;if(e||(e=[]),t||(t={}),l._(this,t),t.op="createMany",t.upsert){var i=function(){var r=!0;return e.forEach(function(e){r=r&&l.get(e,n.idAttribute)}),r?{v:n.updateMany(e,t)}:void 0}();if("object"===("undefined"==typeof i?"undefined":o(i)))return i.v}return p(this.beforeCreateMany(e,t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).createMany(n,e.map(function(e){return n.prototype.toJSON.call(e,t)}),t)}).then(function(e){return p(n.afterCreateMany(e,t)).then(function(){return y(n,e,t,r)})})}},{key:"afterCreateMany",value:function(){}},{key:"beforeFind",value:function(){}},{key:"find",value:function(e,t){var n=this,r=void 0;return t||(t={}),l._(this,t),t.op="find",p(this.beforeFind(e,t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).find(n,e,t)}).then(function(e){return p(n.afterFind(e,t)).then(function(){return y(n,e,t,r)})})}},{key:"afterFind",value:function(){}},{key:"beforeFindAll",value:function(){}},{key:"findAll",value:function(e,t){var n=this,r=void 0;return e||(e={}),t||(t={}),l._(this,t),t.op="findAll",p(this.beforeFindAll(e,t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).findAll(n,e,t)}).then(function(e){return p(n.afterFindAll(e,t)).then(function(){return y(n,e,t,r)})})}},{key:"afterFindAll",value:function(){}},{key:"beforeUpdate",value:function(){}},{key:"update",value:function(e,t,n){var r=this,i=void 0;return t||(t={}),n||(n={}),l._(this,n),n.op="update",p(this.beforeUpdate(e,t,n)).then(function(){return i=r.getAdapterName(n),r.getAdapter(i).update(r,e,r.prototype.toJSON.call(t,n),n)}).then(function(t){return p(r.afterUpdate(e,t,n)).then(function(){return y(r,t,n,i)})})}},{key:"afterUpdate",value:function(){}},{key:"beforeUpdateMany",value:function(){}},{key:"updateMany",value:function(e,t){var n=this,r=void 0;return e||(e=[]),t||(t={}),l._(this,t),t.op="updateMany",p(this.beforeUpdateMany(e,t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).updateMany(n,e.map(function(e){return n.prototype.toJSON.call(e,t)}),t)}).then(function(e){return p(n.afterUpdateMany(e,t)).then(function(){return y(n,e,t,r)})})}},{key:"afterUpdateMany",value:function(){}},{key:"beforeUpdateAll",value:function(){}},{key:"updateAll",value:function(e,t,n){var r=this,i=void 0;return e||(e={}),t||(t={}),n||(n={}),l._(this,n),n.op="updateAll",p(this.beforeUpdateAll(e,t,n)).then(function(){return i=r.getAdapterName(n),r.getAdapter(i).updateAll(r,e,t,n)}).then(function(t){return p(r.afterUpdateAll(e,t,n)).then(function(){return y(r,t,n,i)})})}},{key:"afterUpdateAll",value:function(){}},{key:"beforeDestroy",value:function(){}},{key:"destroy",value:function(e,t){var n=this,r=void 0;return t||(t={}),l._(this,t),t.op="destroy",p(this.beforeDestroy(e,t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).destroy(n,e,t)}).then(function(i){return p(n.afterDestroy(e,t)).then(function(){return t.raw?(i.adapter=r,t.autoEject&&(i.data=n.eject(e,t)),i):(t.autoEject&&(i=n.eject(e,t)),i)})})}},{key:"afterDestroy",value:function(){}},{key:"beforeDestroyAll",value:function(){}},{key:"destroyAll",value:function(e,t){var n=this,r=void 0;return e||(e={}),t||(t={}),l._(this,t),t.op="destroyAll",p(this.beforeDestroyAll(e,t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).destroyAll(n,e,t)}).then(function(i){return p(n.afterDestroyAll(e,t)).then(function(){return t.raw?(i.adapter=r,t.autoEject&&(i.data=n.ejectAll(e,t)),i):(t.autoEject&&(i=n.ejectAll(e,t)),i)})})}},{key:"afterDestroyAll",value:function(){}},{key:"belongsTo",value:function(e,t){return(0,d.belongsTo)(e,t)(this)}},{key:"hasMany",value:function(e,t){return(0,d.hasMany)(e,t)(this)}},{key:"hasOne",value:function(e,t){return(0,d.hasOne)(e,t)(this)}},{key:"initialize",value:function(e){return(0,d.initialize)(e)(this)}},{key:"setSchema",value:function(e){return(0,d.setSchema)(e)(this)}},{key:"configure",value:function(e){return(0,d.configure)(e)(this)}},{key:"registerAdapter",value:function(e,t,n){return(0,d.registerAdapter)(e,t,n)(this)}},{key:"extend",value:function(e,t){var n=void 0,r=this;e=e||{},t=t||{};var c=t.schema||i({},t.idAttribute,{}),f=e.initialize;if(delete e.initialize,c[t.idAttribute]=c[t.idAttribute]||{},e.hasOwnProperty("constructor"))n=e.constructor,delete e.constructor;else{if(!t.name)throw new TypeError("name: Expected string, found "+o(t.name)+"!");if(t.csp)n=function(){s(this,n);for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];var i=a(this,Object.getPrototypeOf(n).apply(this,t));return f&&f.apply(this,t),i};else{var h=l.pascalCase(t.name),v="return function "+h+"() {\n _classCallCheck(this, "+h+")\n var _this = _possibleConstructorReturn(this, Object.getPrototypeOf("+h+").apply(this, arguments));\n if (initialize) {\n initialize.apply(this, arguments)\n }\n return _this\n }";n=new Function("_classCallCheck","_possibleConstructorReturn","Parent","initialize",v)(s,a,r,f)}}return t.shortname=t.shortname||l.camelCase(n.name||t.name),delete t.name,u(n,r),(0,d.configure)(e)(n.prototype),(0,d.configure)(t)(n),(0,d.setSchema)(c)(n),n}}]),t}(m);(0,d.configure)({adapters:{},autoEject:!0,autoInject:g,bypassCache:!1,csp:!1,defaultAdapter:"http",eagerEject:!1,idAttribute:"id",linkRelations:g,onConflict:"merge",relationsEnumerable:!1,raw:!1,strategy:"single",upsert:!0,useFilter:!0})(b),l.Events(b.prototype,function(){return this._get("events")},function(e){this._set("events",e)})}])}); | ||
//# sourceMappingURL=dist/js-data.min.map |
{ | ||
"name": "js-data", | ||
"description": "Robust, framework-agnostic in-memory data store.", | ||
"version": "2.8.2", | ||
"version": "3.0.0-alpha.1", | ||
"homepage": "http://www.js-data.io", | ||
@@ -10,7 +10,3 @@ "repository": { | ||
}, | ||
"author": { | ||
"name": "Jason Dobry", | ||
"url": "http://www.pseudobry.com", | ||
"email": "jason.dobry@gmail.com" | ||
}, | ||
"author": "Jason Dobry <jason.dobry@gmail.com> (http://www.pseudobry.com)", | ||
"license": "MIT", | ||
@@ -24,7 +20,2 @@ "main": "./dist/js-data-debug.js", | ||
"rest", | ||
"angular", | ||
"ember", | ||
"backbone", | ||
"react", | ||
"firebase", | ||
"datastore", | ||
@@ -37,35 +28,23 @@ "store", | ||
], | ||
"devDependencies": { | ||
"babel-core": "5.8.25", | ||
"babel-eslint": "4.1.3", | ||
"babel-loader": "5.3.2", | ||
"chai": "3.4.0", | ||
"codacy-coverage": "1.1.3", | ||
"coveralls": "2.11.4", | ||
"es6-promise": "3.0.2", | ||
"karma": "0.13.14", | ||
"karma-browserstack-launcher": "0.1.6", | ||
"karma-chai": "0.1.0", | ||
"karma-chrome-launcher": "0.2.1", | ||
"karma-coverage": "0.5.3", | ||
"karma-firefox-launcher": "0.1.6", | ||
"karma-junit-reporter": "0.3.8", | ||
"karma-mocha": "0.2.0", | ||
"karma-phantomjs-launcher": "0.2.1", | ||
"karma-sinon": "1.0.4", | ||
"mocha": "2.3.3", | ||
"mout": "0.11.0", | ||
"phantomjs": "1.9.18", | ||
"sinon": "1.17.2", | ||
"standard": "5.3.1", | ||
"uglify-js": "2.5.0", | ||
"webpack": "1.12.2", | ||
"yabh": "1.1.0" | ||
}, | ||
"standard": { | ||
"parser": "babel-eslint" | ||
"parser": "babel-eslint", | ||
"globals": [ | ||
"__callCheck__", | ||
"__get__", | ||
"__inherits__", | ||
"__possibleConstructorReturn__", | ||
"describe", | ||
"it", | ||
"sinon", | ||
"before", | ||
"after", | ||
"beforeEach", | ||
"afterEach" | ||
] | ||
}, | ||
"scripts": { | ||
"lint": "standard src/**/*.js", | ||
"bundle": "webpack --config webpack.config.js --colors", | ||
"lint": "standard src/**/*.js test/**/*.js", | ||
"webpack": "webpack --config webpack.config.js", | ||
"helpers": "node scripts/helpers.js", | ||
"watch": "npm run webpack -- --watch", | ||
"min": "uglifyjs dist/js-data.js -o dist/js-data.min.js --source-map dist/js-data.min.map -v -m -c --screw-ie8", | ||
@@ -76,8 +55,30 @@ "debug": "node scripts/debug.js", | ||
"gzip": "echo gzipped size: $(cat dist/js-data.min.js | gzip -f9 | wc -c)kb", | ||
"build": "npm run lint && npm run bundle && npm run debug && npm run min && npm run version && npm run banner && npm run gzip", | ||
"build": "npm run lint && npm run webpack && npm run debug && npm run min && npm run version && npm run banner", | ||
"karma": "karma start", | ||
"mocha": "mocha --timeout 20000 --reporter dot mocha.start.js test/both/* test/both/datastore/* test/both/datastore/async_methods/* test/both/datastore/sync_methods/*", | ||
"test": "npm run build && npm run mocha && npm run karma", | ||
"ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true && cat ./coverage/PhantomJS*/lcov.info | codacy-coverage || true" | ||
} | ||
"mocha": "mocha -t 20000 -R spec -r source-map-support/register mocha.start.js", | ||
"cover": "istanbul cover -x dist/js-data-tests.js --hook-run-in-context node_modules/mocha/bin/_mocha -- -t 20000 -R dot -r source-map-support/register mocha.start.js", | ||
"test": "npm run build && npm run cover", | ||
"ci": "npm test && cat coverage/lcov.info | coveralls || true && cat ./coverage/lcov.info | codacy-coverage || true" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "6.3.17", | ||
"babel-eslint": "4.1.6", | ||
"babel-loader": "6.2.0", | ||
"babel-plugin-syntax-async-functions": "6.3.13", | ||
"babel-plugin-transform-regenerator": "6.3.13", | ||
"babel-polyfill": "6.3.14", | ||
"babel-preset-es2015": "6.3.13", | ||
"babel-preset-stage-0": "6.3.13", | ||
"chai": "3.4.1", | ||
"codacy-coverage": "1.1.3", | ||
"coveralls": "2.11.6", | ||
"istanbul": "0.4.1", | ||
"mocha": "2.3.4", | ||
"sinon": "1.17.2", | ||
"source-map-support": "0.4.0", | ||
"standard": "5.4.1", | ||
"uglify-js": "2.6.1", | ||
"webpack": "1.12.9" | ||
}, | ||
"dependencies": {} | ||
} |
213
README.md
@@ -11,3 +11,3 @@ <img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="64" height="64" /> | ||
The most commonly used adapter is the [http adapter][http], which is perfect for | ||
communicating with your RESTful backend. [localStorage][3], [localForage][4], | ||
connecting your frontend to your backend. [localStorage][3], [localForage][4], | ||
[firebase][5] and [other adapters][6] are already available. On the server you | ||
@@ -18,14 +18,10 @@ could hook up to the [SQL adapter (Postgres/MySQL/MariaDB/SQLite3)][7] and add | ||
Unlike some libraries, JSData does not require the use of getters and setters, | ||
and doesn't decorate your data with a bunch of cruft. JSData's internal change | ||
detection (via [observe-js][10] or `Object.observe` in supporting browsers) | ||
allows for powerful use cases and an easy avenue for implementing your own | ||
[3-way data-binding][11]. | ||
Unlike some libraries, JSData does not require the use of getter and setter | ||
functions, and doesn't decorate your data with a bunch of cruft. | ||
Supporting relations, computed properties, support for Node and the Browser, | ||
model lifecycle control and a slew of other features, JSData is the tool for | ||
[giving your data the respect it deserves][12]. | ||
Supporting relations, Node.js and the Browser, model lifecycle control and a | ||
slew of other features, JSData is the tool for [giving your data the respect it deserves][12]. | ||
Written in ES6 and built for modern web development, JSData will save you | ||
thousands of lines of code _and_ make you cooler. | ||
thousands of lines of code. | ||
@@ -49,101 +45,154 @@ Support is handled via the [Slack channel][slack] or the [Mailing List][ml]. | ||
If you can't polyfill the environment, then configure JSData to use a specific | ||
`Promise` constructor directly: `JSData.DSUtils.Promise = MyPromiseLib;`. | ||
This direct configuration method is useful for telling JSData to use the | ||
Bluebird library or Angular's `$q`, etc. | ||
### Quick Start | ||
`bower install --save js-data js-data-http` or `npm install --save js-data js-data-http`. | ||
Load `js-data-http.js` after `js-data.js`. See [installation instructions][inst] | ||
for making js-data part of your r.js/browserify/webpack build. | ||
##### For use in a Browser | ||
`npm install --save js-data js-data-http` or `bower install --save js-data js-data-http`. | ||
(You may also substitute `js-data-http` for any one of the other client-side adapters.) | ||
##### For use in Node.js | ||
`npm install --save js-data axios js-data-http-node` | ||
(You may also substitute `js-data-http-node` for any one of the other server-side adapters.) | ||
See [installation instructions][inst] for making js-data part of your | ||
r.js/browserify/webpack build. | ||
__ES7:__ | ||
```js | ||
// you can also require "js-data" if you're using AMD/CommonJS | ||
// e.g. var JSData = require('js-data'); var DSHttpAdapter = require('js-data-http'); | ||
var store = new JSData.DS(); | ||
import {Model, registerAdapter} from 'js-data' | ||
import DSHttpAdapter from 'js-data-http' | ||
// register and use http by default for async operations | ||
store.registerAdapter('http', new DSHttpAdapter(), { default: true }); | ||
async function showExample() { | ||
// "User" will use an http adapter by default | ||
@registerAdapter('http', new DSHttpAdapter(), { default: true }) | ||
class User extends Model {} | ||
// simplest model definition, just pass the name instead of an options hash | ||
// this is the same as "store.defineResource({ name: 'user' })" | ||
var User = store.defineResource('user'); | ||
// Allow "User" to store data | ||
User.initialize() | ||
// Usually you'll define a resource by passing options | ||
var Comment = store.defineResource({ | ||
name: 'comment', | ||
relations: { | ||
belongsTo: { | ||
user: { | ||
// "join" field, name of field on a comment | ||
// that is the primary key of the parent user | ||
localKey: 'userId', | ||
let user = await User.find(1) | ||
// name of the field on the comment where the | ||
// parent user will be attached to the comment | ||
// by js-data | ||
localField: 'user' | ||
} | ||
} | ||
} | ||
}); | ||
console.log(user) // { id: 1, name: 'John' } | ||
console.log(user instanceof User) // true | ||
var user; | ||
// The user instance is stored in User now | ||
console.log(User.get(user.id)) // { id: 1, name: 'John' } | ||
console.log(user === User.get(user.id)) // true | ||
// No need for another GET request, will resolve immediately | ||
// See http://www.js-data.io/docs/dsfind | ||
user = await User.find(user.id) | ||
console.log(user === User.get(user.id)) // true | ||
// PUT /user/1 {name:"Johnny"} | ||
// See http://www.js-data.io/docs/dsupdate | ||
user = await User.update(user.id, { name: 'Johnny' }) | ||
// The user instance stored in User has been updated | ||
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' } | ||
console.log(user === User.get(user.id)) // true | ||
await User.destroy(user.id) | ||
// The user instance no longer stored in User | ||
console.log(User.get(1)) // undefined | ||
} | ||
showExample() | ||
``` | ||
__ES6:__ | ||
```js | ||
import {Model, registerAdapter} from 'js-data' | ||
import DSHttpAdapter from 'js-data-http' | ||
function* showExample() { | ||
class User extends Model {} | ||
// "User" will use an http adapter by default | ||
User.setAdapter('http', new DSHttpAdapter(), { default: true }) | ||
// Allow "User" to store data | ||
User.initialize() | ||
let user = yield User.find(1) | ||
console.log(user) // { id: 1, name: 'John' } | ||
console.log(user instanceof User) // true | ||
// The user instance is stored in User now | ||
console.log(User.get(user.id)) // { id: 1, name: 'John' } | ||
console.log(user === User.get(user.id)) // true | ||
// No need for another GET request, will resolve immediately | ||
// See http://www.js-data.io/docs/dsfind | ||
user = yield User.find(user.id) | ||
console.log(user === User.get(user.id)) // true | ||
// PUT /user/1 {name:"Johnny"} | ||
// See http://www.js-data.io/docs/dsupdate | ||
user = yield User.update(user.id, { name: 'Johnny' }) | ||
// The user instance stored in User has been updated | ||
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' } | ||
console.log(user === User.get(user.id)) // true | ||
yield User.destroy(user.id) | ||
// The user instance no longer stored in User | ||
console.log(User.get(1)) // undefined | ||
} | ||
showExample() | ||
``` | ||
__ES5:__ | ||
```js | ||
var User = JSData.Model.extend({}, { name: 'User' }) | ||
// register and use http by default for async operations | ||
User.registerAdapter('http', new DSHttpAdapter(), { default: true }); | ||
// Example CRUD operations with default configuration | ||
// See http://www.js-data.io/docs/dsfind | ||
User.find(1) | ||
.then(function (_user) { | ||
_user; // { id: 1, name: 'John' } | ||
.then(function (user) { | ||
console.log(user) // { id: 1, name: 'John' } | ||
console.log(user instanceof User) // true | ||
// See http://www.js-data.io/docs/dsis | ||
User.is(_user); // true | ||
Comment.is(_user); // false | ||
// The user instance is stored in User now | ||
console.log(User.get(user.id)) // { id: 1, name: 'John' } | ||
console.log(user === User.get(user.id)) // true | ||
// The user is in the store now | ||
// See http://www.js-data.io/docs/dsget | ||
User.get(_user.id); // { id: 1, name: 'John' } | ||
user = _user; | ||
// No need for another GET request, will resolve immediately | ||
// See http://www.js-data.io/docs/dsfind | ||
return User.find(1); | ||
return User.find(user.id) | ||
}) | ||
.then(function (_user) { | ||
user === _user; // true | ||
.then(function (user) { | ||
console.log(user === User.get(user.id)) // true | ||
// PUT /user/1 {name:"Johnny"} | ||
// See http://www.js-data.io/docs/dsupdate | ||
return User.update(user.id, { name: 'Johnny' }); | ||
return User.update(user.id, { name: 'Johnny' }) | ||
}) | ||
.then(function (_user) { | ||
// identity mapping at play | ||
user === _user; // true | ||
user === User.get(_user.id); // true | ||
.then(function (user) { | ||
// The user instance stored in User has been updated | ||
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' } | ||
console.log(user === User.get(user.id)) // true | ||
user; // { id: 1, name: 'Johnny' } | ||
user.name = 'Billy'; | ||
// PUT /user/1 {id:1,name:"Billy"} | ||
// See http://www.js-data.io/docs/dssave | ||
return User.save(1); | ||
}) | ||
.then(function (_user) { | ||
// identity mapping at play | ||
user === _user; // true | ||
user === User.get(_user.id); // true | ||
user; // { id: 1, name: 'Johnny' } | ||
// DELETE /user/1 | ||
// See http://www.js-data.io/docs/dsdestroy | ||
return User.destroy(1); | ||
return User.destroy(user.id) | ||
}) | ||
.then(function () { | ||
// The user has also been removed from the in-memory store | ||
User.get(1); // undefined | ||
}); | ||
// The user instance no longer stored in User | ||
console.log(User.get(1)) // undefined | ||
}) | ||
``` | ||
@@ -150,0 +199,0 @@ |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
18
0
328
0
493430
11
6567
1