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

datx

Package Overview
Dependencies
Maintainers
8
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datx - npm Package Compare versions

Comparing version 0.9.9 to 0.9.10

.rpt2_cache/5ec044196783ab8edc8fa7a324204a9be03e4386/code/cache/3269f8abf7a9575d9ac26a37aa25ba5fe3e7f854

1

dist/errors.d.ts

@@ -15,3 +15,4 @@ export declare const UNDEFINED_TYPE = "The type needs to be defined if the object is not an instance of the model.";

export declare const WRONG_REF_TYPE = "The new reference type doesn't match to the declared one.";
export declare const MODEL_REQUIRED = "The model type is a required parameter. Do you maybe have a circular dependency?";
export declare const DECORATE_MODEL = "This mixin can only decorate models";
export declare const DECORATE_COLLECTION = "This mixin can only decorate collections";

5

dist/helpers/model/init.d.ts
import { IRawModel } from 'datx-utils';
import { FieldType } from '../../enums/FieldType';
import { IReferenceOptions } from '../../interfaces/IReferenceOptions';
import { IType } from '../../interfaces/IType';
import { TRefValue } from '../../interfaces/TRefValue';

@@ -13,3 +12,3 @@ import { PureCollection } from '../../PureCollection';

* @export
* @param {(PureModel|IType)} obj Model to which the reference should be added
* @param {PureModel} obj Model to which the reference should be added
* @param {string} key Model property where the reference will be defined

@@ -19,3 +18,3 @@ * @param {IReferenceOptions} options Reference options

*/
export declare function initModelRef(obj: PureModel | IType, key: string, options: IReferenceOptions, initialVal: TRefValue): void;
export declare function initModelRef(obj: PureModel, key: string, options: IReferenceOptions, initialVal: TRefValue): void;
export declare function initModel(model: PureModel, rawData: IRawModel, collection?: PureCollection): void;

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mobx"),require("datx-utils")):"function"==typeof define&&define.amd?define(["exports","mobx","datx-utils"],t):t(e.datx={},e.mobx,e.datxUtils)}(this,function(e,t,n){"use strict";var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function a(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}var i,s,c="The type needs to be defined if the object is not an instance of the model.",l="No model is defined for the type ${type}.",u="The given model is not a clone.",f="The model needs to be in a collection to be referenceable",d="The reference ${key} can't be an array of values.",p="The reference ${key} must be an array of values.",y="You should save this value as a reference.",h="Back references are read only",M="Model ID can't be updated directly. Use the `updateModelId` helper function instead.",_="Model type can't be changed after initialization.",v="Model id is required (autoincrement is disabled)",b="The new reference type doesn't match to the declared one.",O="This mixin can only decorate models";function g(e,t,n){for(var r=n,o=e;o;)r=t(r,o),o=Object.getPrototypeOf(o);return r}!function(e){e[e.ID=0]="ID",e[e.TYPE=1]="TYPE",e[e.DATA=2]="DATA"}(i||(i={})),(s=e.ReferenceType||(e.ReferenceType={}))[s.TO_ONE=0]="TO_ONE",s[s.TO_MANY=1]="TO_MANY",s[s.TO_ONE_OR_MANY=2]="TO_ONE_OR_MANY";var m=new(function(){function e(){this.modelData=new WeakMap,this.modelClassData=new WeakMap}return e.prototype.initModel=function(e){var n={data:{},meta:{}};return t.extendObservable(n),this.modelData.set(e,n),n},e.prototype.getModelData=function(e){return this.__getModelData(e).data},e.prototype.getModelDataKey=function(e,t){return this.__getModelData(e).data[t]},e.prototype.setModelData=function(e,n){var r=this.__getModelData(e);t.extendObservable(r.data,n)},e.prototype.setModelDataKey=function(e,t,n){var r;this.setModelData(e,((r={})[t]=n,r))},e.prototype.getModelMeta=function(e){return this.modelData.get(e).meta},e.prototype.getModelMetaKey=function(e,t){return this.getModelMeta(e)[t]},e.prototype.setModelMeta=function(e,n){var r=this.__getModelData(e);return t.extendObservable(r.meta,n),r.meta},e.prototype.setModelMetaKey=function(e,t,n){var r;this.setModelMeta(e,((r={})[t]=n,r))},e.prototype.setModelClassMetaKey=function(e,t,n){var r,o=this.modelClassData.get(e);Object.assign(o.meta,((r={})[t]=n,r))},e.prototype.getModelClassMetaKey=function(e,t){var n=this;return g(e,function(e,r){return e||(n.modelClassData.get(r)||{meta:{}}).meta[t]||null},null)},e.prototype.addModelDefaultField=function(e,t,n){var r,o,a=this.modelClassData.get(e);a?Object.assign(a.data,((r={})[t]=n,r)):this.modelClassData.set(e,{data:(o={},o[t]=n,o),meta:{},references:{}})},e.prototype.getModelDefaults=function(e){var t=this,n=g(e,function(e,n){return e.concat((t.modelClassData.get(n)||{data:[]}).data)},[]);return Object.assign.apply(Object,[{}].concat(n.reverse()))},e.prototype.addModelClassReference=function(e,t,n){var r,o,a=this.modelClassData.get(e);a?Object.assign(a.references,((r={})[t]=n,r)):this.modelClassData.set(e,{data:{},meta:{},references:(o={},o[t]=n,o)})},e.prototype.getModelClassReferences=function(e){var t=this,n=g(e,function(e,n){return e.concat((t.modelClassData.get(n)||{references:{}}).references)},[]);return Object.assign.apply(Object,[{}].concat(n.reverse()))},e.prototype.getModelReferenceOptions=function(e,t){return this.getModelMetaKey(e,"refs")[t]},e.prototype.__getModelData=function(e){return this.modelData.get(e)||this.initModel(e)},e.prototype.clear=function(){this.modelData=new WeakMap,this.modelClassData=new WeakMap},e}()),T=/\$\{\s*([a-zA-Z0-9\-\_]+)\s*\}/g;function A(e,t){return void 0===t&&(t={}),new Error(function(e,t){for(var n=T.exec(e);n;)e=e.replace(n[0],t[n[1]]),n=T.exec(e);return e}(e,t))}function D(e){return"function"==typeof e?e.type:"object"==typeof e?N(e,"type")||e.constructor.type:e}function E(e){return e instanceof H?N(e,"id"):e}function j(e){return N(e,"collection")}function R(e){var t=e.constructor,r=x(e),o=r[n.META_FIELD];o.originalId=o.id,delete o.id;var a=new t(r),i=j(e);return i&&i.add(a),a}function w(e){var t=j(e),n=N(e,"originalId");if(n){if(!t)throw A(f);return t.find(e,n)}throw A(u)}function I(e,t){var r=m.getModelClassMetaKey(e.constructor,"id")||"id",o=m.getModelClassMetaKey(e.constructor,"type")||"type";return Object.keys(t instanceof H?x(t):t).forEach(function(a){a!==n.META_FIELD&&a!==r&&a!==o&&K(e,a,t[a])}),e}function K(e,t,n){if(t in N(e,"refs"))!function(e,t,n){N(e,"refs");e[t]=n}(e,t,n);else{if(n instanceof H)throw A(y,{key:t});!function(e,t,n){-1!==N(e,"fields").indexOf(t)?e[t]=n:z(e,t,n)}(e,t,n)}}function C(e,t,r){if(n.META_FIELD in e&&"object"==typeof e[n.META_FIELD]&&void 0!==e[n.META_FIELD])return e[n.META_FIELD][t];if(r){var o=m.getModelClassMetaKey(r,t);return o&&e[o]}return e&&e[t]}function x(e){var r=t.toJS(m.getModelData(e)),o=Object.assign({},m.getModelMeta(e));delete o.collection;var a=t.toJS(o);delete a.collection;var i,s=Object.assign(r,((i={})[n.META_FIELD]=a,i)),c=e.constructor,l=m.getModelClassMetaKey(c,"id"),u=m.getModelClassMetaKey(c,"type");return a&&l&&(s[l]=a.id),a&&u&&(s[u]=a.type),s}function N(e,t){return m.getModelMetaKey(e,t)}function L(e,t,n){return m.setModelMetaKey(e,t,n)}function Y(n,r,o){var a=m.getModelReferenceOptions(n,r),i=E(o),s=m.getModelDataKey(n,r);a.type===e.ReferenceType.TO_ONE?m.setModelDataKey(n,r,i):a.type===e.ReferenceType.TO_MANY||t.isObservableArray(s)?s.push(i):m.setModelDataKey(n,r,o)}function k(n,r,o){var a=m.getModelReferenceOptions(n,r),i=E(o),s=m.getModelDataKey(n,r);a.type===e.ReferenceType.TO_ONE?m.setModelDataKey(n,r,null):a.type===e.ReferenceType.TO_MANY||t.isObservableArray(s)?s.remove(i):m.setModelDataKey(n,r,null)}function P(e,t){return function(n){var r=n;if(!(n instanceof H)&&"object"==typeof n){if(!t)throw new Error(f);r=t.add(n,e.model)}return E(r)}}function F(e,t,n){var r=m.getModelReferenceOptions(e,t);return"splice"===n.type?function(e,t,n,r){var o=r.property;return n.added.map(function(t){return Y(t,o,e)}),e[t].slice(n.index,n.index+n.removedCount).map(function(t){return k(t,o,e)}),null}(e,t,n,r):function(e,t,n,r){var o=r.property,a=e[t].length>n.index?e[t][n.index]:null;return n.newValue&&Y(n.newValue,o,e),a&&k(a,o,e),null}(e,t,n,r)}function S(e,t,n,r){if(r===i.TYPE)throw A(_);if(r===i.ID)throw A(M);t in N(e,"refs")?B(e,t,n):m.setModelDataKey(e,t,n)}function J(e,n,r){var o=D(r.model),a=j(e);if(!a)return null;var i=a.findAll(o).filter(function(t){return function(e,t,n){return null!==e[t]&&void 0!==e[t]&&(e[t]instanceof H?e[t]===n:-1!==e[t].indexOf(n))}(t,r.property,e)}),s=t.observable.shallowArray(i);return t.intercept(s,function(t){return F(e,n,t)}),s}function V(r,o,a){var i=m.getModelDataKey(r,o),s=j(r);if(!s)return null;var c=n.mapItems(i,function(e){return e?s.find(a.model,e):e});if(a.type!==e.ReferenceType.TO_MANY||c instanceof Array||(c=[c]),c instanceof Array){var l=t.observable.shallowArray(c);return t.intercept(l,function(e){return function(e,t,n){var r=m.getModelReferenceOptions(e,t),o=m.getModelDataKey(e,t),a=j(e);if("splice"===n.type){var i=n.added.map(P(r,a));return o.splice.apply(o,[n.index,n.removedCount].concat(i)),null}return o[n.index]=P(r,a)(n.newValue),null}(r,o,e)}),l}return c}function B(r,o,a){var i=m.getModelReferenceOptions(r,o),s=(i.type===e.ReferenceType.TO_MANY?n.mapItems(a,E):n.mapItems(a,E),i.type===e.ReferenceType.TO_MANY?a||[]:a),c=s instanceof Array||t.isObservableArray(s);!function(t,n,r){if(t.type===e.ReferenceType.TO_ONE&&n)throw A(d,{key:r});if(t.type===e.ReferenceType.TO_MANY&&!n)throw A(p,{key:r});if(t.property)throw A(h)}(i,c,o);var l=j(r),u=n.mapItems(a,function(e){if(e&&l){if(e instanceof H)if(D(e)!==D(i.model))throw new Error(b);var t=l.find(i.model,e);return t||"object"!=typeof e||(t=l.add(e,i.model)),E(t||e)}if(e instanceof H)throw A(f);return e});i.type===e.ReferenceType.TO_MANY&&(u=u||[]),!u||u instanceof Array&&u.length,m.setModelDataKey(r,o,u)}function W(e,n,r,o){var a=j(e);if(a)a.getAllModels().map(function(e){(function(e,t){var n=N(e,"refs");return Object.keys(n).filter(function(e){return!n[e].property}).filter(function(e){return D(n[e].model)===t})})(e,o).forEach(function(o){var a=m.getModelDataKey(e,o);if(a instanceof Array||t.isObservableArray(a)){var i=a.indexOf(r);-1!==i&&(a[i]=n)}else a===r&&m.setModelDataKey(e,o,n)})})}function $(e,t){return m.getModelDataKey(e,t)}function q(e,t,n){return m.setModelDataKey(e,t,n)}function z(e,n,r,o){void 0===o&&(o=i.DATA);var a,s=N(e,"fields");m.setModelDataKey(e,n,r),-1===s.indexOf(n)&&s.push(n),t.extendObservable(e,((a={})[n]=t.computed(function(){return function(e,t){return m.getModelDataKey(e,t)}(e,n)},function(t){return S(e,n,t,o)}),a))}function U(n,r,o,a){N(n,"refs")[r]=o;var i,s=o.type===e.ReferenceType.TO_MANY;m.setModelDataKey(n,r,s?[]:void 0),t.extendObservable(n,((i={})[r]=t.computed(function(){return function(e,t){var n=m.getModelReferenceOptions(e,t);return"string"==typeof n.property?J(e,t,n):V(e,t,n)}(n,r)},function(e){return B(n,r,e)}),i)),o.property||(n[r]=a)}function Z(e,t,n,r){var o=function(e,t,n){var r=n.constructor,o=t.fields.slice(),a=m.getModelClassReferences(r),i=Object.assign({},a,t.refs),s=m.getModelDefaults(r);return Object.keys(e).concat(Object.keys(s)).forEach(function(e){e in i||-1!==o.indexOf(e)||o.push(e)}),{defaults:s,fields:o,refs:i}}(t,n,e),a=o.defaults,s=o.fields,c=o.refs,l=e.constructor,u=m.getModelClassMetaKey(l,"id"),f=m.getModelClassMetaKey(l,"type");s.forEach(function(r){var o=i.DATA,s=t[r];void 0===s&&(s=a[r]),r===(u||"id")?(o=i.ID,s=n.id):r===f&&(o=i.TYPE,s=n.type),z(e,r,s,o)}),!u||u in s||z(e,u,n.id,i.ID),Object.keys(c).forEach(function(n){var o=c[n],i=t[n]||a[n]||void 0,s=r?r.add(i,D(o.model)):i;U(e,n,o,s)})}function G(e,t,r){var o=e.constructor,a=Object.assign({},o.preprocess(t));L(e,"collection",r);var i=function(e,t,r){var o=e.constructor,a=m.getModelClassMetaKey(o,"id")||"id",i=m.getModelClassMetaKey(o,"type"),s=i&&t[i]||D(e),c=a&&t[a];if(!c){if(!o.enableAutoId)throw new Error(v);for(c=o.getAutoId();r&&r.find(s,c);)c=o.getAutoId()}var l,u={fields:[],id:c,refs:{},type:s},f={fields:[],refs:{}};if(n.META_FIELD in t&&t[n.META_FIELD]){var d=t[n.META_FIELD];f.fields=d.fields,delete d.fields,f.refs=d.refs,delete d.refs,l=m.setModelMeta(e,Object.assign(u,d)),delete t[n.META_FIELD]}else l=m.setModelMeta(e,u);return Object.assign({},l,f)}(e,a,r);Z(e,a,i,r)}var H=function(){function e(e,t){void 0===e&&(e={}),G(this,e,t)}return e.preprocess=function(e){return e},e.getAutoId=function(){return"number"==typeof this.autoIdValue?--this.autoIdValue:this.autoIdValue},e.toJSON=function(){return this.type},e.type=n.DEFAULT_TYPE,e.autoIdValue=0,e.enableAutoId=!0,e}();function Q(e,t,n){if(!t&&0!==t)throw A(c);var r=n.constructor,o=r.types.find(function(e){return e.type===t})||r.defaultModel;if(!o)throw A(l,{type:t});var a=C(e,"id",o),i=a&&n.find(t,a);return i?I(i,e):new o(e,n)}function X(e,t){return t.map(function(t){return function(e,t){return Q(t,C(t,"type"),e)}(e,t)})}var ee=function(){function e(e){void 0===e&&(e=[]),this.__data=t.observable.shallowArray([]),this.__dataMap={},this.__dataList={},t.extendObservable(this),this.insert(e)}return e.prototype.insert=function(e){var t=X(this,e);return this.__insertModel(t),t},e.prototype.add=function(e,t){return e instanceof Array?this.__addArray(e,t):this.__addSingle(e,t)},e.prototype.find=function(e,t){return t instanceof H?t:"function"!=typeof(n=e)||n===H||n.prototype instanceof H?this.__findByType(e,t)||null:this.__data.find(e)||null;var n},e.prototype.filter=function(e){return this.__data.filter(e)},e.prototype.findAll=function(e){if(e){var n=D(e);return n in this.__dataList||t.extendObservable(this.__dataList,((r={})[n]=t.observable.array([]),r)),this.__dataList[n]}return this.__data;var r},e.prototype.hasItem=function(e){var t=E(e);return Boolean(this.find(e,t))},e.prototype.remove=function(e,t){var n="object"==typeof e?e:this.find(e,t);n&&this.__removeModel(n)},e.prototype.removeAll=function(e){this.__removeModel(this.findAll(e).slice())},Object.defineProperty(e.prototype,"length",{get:function(){return this.__data.length},enumerable:!0,configurable:!0}),e.prototype.toJSON=function(){return this.__data.map(x)},Object.defineProperty(e.prototype,"snapshot",{get:function(){return this.toJSON()},enumerable:!0,configurable:!0}),e.prototype.reset=function(){var e=this;this.__data.map(function(e){return L(e,"collection",void 0)}),this.__data.replace([]),Object.keys(this.__dataList).forEach(function(t){delete e.__dataList[t],delete e.__dataMap[t]})},e.prototype.getAllModels=function(){return this.__data.slice()},e.prototype.__addArray=function(e,t){var n=this;return e.filter(Boolean).map(function(e){return n.__addSingle(e,t)})},e.prototype.__addSingle=function(e,t){if(!e||"number"==typeof e||"string"==typeof e)return e;if(e instanceof H)return this.hasItem(e)||this.__insertModel(e),e;if(!t&&0!==t)throw A(c);var n=D(t),r=Q(e,n,this);return this.__insertModel(r,n),r},e.prototype.__insertModel=function(e,n,r){var o=this;if(e instanceof Array)return e.forEach(function(e){return o.__insertModel(e,n,r)});var a=j(e);if(a&&a!==this)throw A("A model can be in a single collection at once");var i,s,c,l,u=n||D(e),f=r||E(e),d=this.find(u,f);d?I(d,e):(this.__data.push(e),u in this.__dataList?this.__dataList[u].push(e):t.extendObservable(this.__dataList,((i={})[u]=t.observable.shallowArray([e]),i)),u in this.__dataMap?t.extendObservable(this.__dataMap[u],((s={})[f]=e,s)):t.extendObservable(this.__dataMap,((c={})[u]=t.observable.shallowObject(((l={})[f]=e,l)),c)),L(e,"collection",this))},e.prototype.__removeModel=function(e,n,r){var o=this;if(e instanceof Array)return e.forEach(function(e){return o.__removeModel(e,n,r)});var a,i=n||D(e),s=r||E(e);this.__data.remove(e),this.__dataList[i].remove(e),t.extendObservable(this.__dataMap[i],((a={})[s]=void 0,a)),L(e,"collection",void 0)},e.prototype.__findByType=function(e,n){var r,o,a,i,s=D(e);return n?(s in this.__dataMap?n in this.__dataMap[s]||t.extendObservable(this.__dataMap[s],((a={})[n]=void 0,a)):t.extendObservable(this.__dataMap,((r={})[s]=((o={})[n]=void 0,o),r)),this.__dataMap[s][n]):(s in this.__dataList||t.extendObservable(this.__dataList,((i={})[s]=t.observable.shallowArray([]),i)),this.__dataList[s].length?this.__dataList[s][0]:null)},e.prototype.__changeModelId=function(e,t,n){this.__dataMap[n][t]=this.__dataMap[n][e],delete this.__dataMap[n][e]},e.types=[],a([t.observable],e.prototype,"__dataMap",void 0),a([t.observable],e.prototype,"__dataList",void 0),a([t.action],e.prototype,"insert",null),a([t.action],e.prototype,"add",null),a([t.action],e.prototype,"remove",null),a([t.action],e.prototype,"removeAll",null),a([t.computed],e.prototype,"length",null),a([t.action],e.prototype,"reset",null),e}();function te(e,t){for(var n=e;n;){if(n===t)return!0;n=Object.getPrototypeOf(n)}return!1}function ne(e){return te(e,H)}function re(e){var t=e;if(!ne(e))throw A(O);return function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.update=function(e){I(this,e)},t.prototype.clone=function(){return R(this)},t.prototype.assign=function(e,t){K(this,e,t)},t.prototype.addReference=function(e,t,n){U(this,e,n,t)},t.prototype.toJSON=function(){return x(this)},t}(t)}function oe(e){var n=e;if(!ne(n))throw A(O);return function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return o(n,e),Object.defineProperty(n.prototype,"meta",{get:function(){var e=this,t=N(this,"refs"),n={};return Object.keys(t).forEach(function(t){n[t]=$(e,t)}),Object.freeze({collection:j(this),id:E(this),original:N(this,"originalId")&&w(this)||void 0,refs:n,snapshot:x(this),type:D(this)})},enumerable:!0,configurable:!0}),a([t.computed],n.prototype,"meta",null),n}(n)}var ae=re(oe(H)),ie=function(r){function a(t,o){var a=r.call(this,t,o)||this;return Object.keys(a.static.refs).forEach(function(t){if(!(t in N(a,"refs"))){var r=a.static.refs[t],o=n.mapItems(a[t]||a.static.defaults[t],E);U(a,t,"object"==typeof r?{model:r.model,property:r.property,type:e.ReferenceType.TO_ONE_OR_MANY}:{model:r,type:e.ReferenceType.TO_ONE_OR_MANY},o)}}),Object.keys(a.static.defaults).forEach(function(e){e in a.static.refs||e in a||z(a,e,a.static.defaults[e])}),a}return o(a,r),a.prototype.getRecordId=function(){return E(this)},a.prototype.getRecordType=function(){return D(this)},a.prototype.assign=function(e,t){var n=i.DATA,r=m.getModelClassMetaKey(this.static,"id"),o=m.getModelClassMetaKey(this.static,"type");return e===r?n=i.ID:e===o&&(n=i.TYPE),S(this,e,t,n),t},a.prototype.assignRef=function(n,r,o){if(N(this,"refs")[n])return this[n]=r;var a=o;if(a||(r instanceof Array||t.isObservableArray(r)?a=r.reduce(function(e,t){return e||D(t)},null):r instanceof H&&(a=D(r))),!a)throw new Error("The type property is missing");return U(this,n,{model:a,type:e.ReferenceType.TO_ONE_OR_MANY},r),this[n]},a.prototype.update=function(e){var t=this,n=Object.assign({},e);return Object.keys(n).forEach(function(e){"function"==typeof t[e]&&delete n[e]}),I(this,n)},Object.defineProperty(a.prototype,"static",{get:function(){return this.constructor},enumerable:!0,configurable:!0}),a.prototype.toJS=function(){return x(this)},Object.defineProperty(a.prototype,"snapshot",{get:function(){return x(this)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"__collection",{get:function(){return j(this)},enumerable:!0,configurable:!0}),a.refs={},a.defaults={},a}(H),se=function(e){function n(n){var r=e.call(this,n)||this,o={};return r.static.types.forEach(function(e){var n=D(e);o[n]=t.computed(function(){return r.findAll(n)})}),t.extendObservable(r,o),r}return o(n,e),Object.defineProperty(n.prototype,"static",{get:function(){return this.constructor},enumerable:!0,configurable:!0}),n.prototype.toJS=function(){return this.toJSON()},n.types=[ie],n}(ee);var ce=Object.assign(function(e,t){m.addModelDefaultField(e.constructor,t)},{defaultValue:function(e){return function(t,n){m.addModelDefaultField(t.constructor,n,e)}},toOne:function(t){return function(n,r){m.addModelClassReference(n.constructor,r,{model:t,type:e.ReferenceType.TO_ONE})}},toMany:function(t,n){return function(r,o){m.addModelClassReference(r.constructor,o,{model:t,property:n,type:e.ReferenceType.TO_MANY})}},toOneOrMany:function(t){return function(n,r){m.addModelClassReference(n.constructor,r,{model:t,type:e.ReferenceType.TO_ONE_OR_MANY})}},identifier:function(e,t){m.addModelDefaultField(e.constructor,t),m.setModelClassMetaKey(e.constructor,"id",t)},type:function(e,t){m.addModelDefaultField(e.constructor,t),m.setModelClassMetaKey(e.constructor,"type",t)}});e.prop=ce,e.Collection=ee,e.Model=ae,e.PureCollection=ee,e.PureModel=H,e.CompatCollection=se,e.CompatModel=ie,e.getRefId=$,e.setRefId=q,e.updateModelId=function(e,t){var n=j(e),r=E(e),o=D(e);L(e,"id",t);var a=e.constructor,i=m.getModelClassMetaKey(a,"id");i&&q(e,i,t),n&&n.__changeModelId(r,t,o),W(e,t,r,o)},e.initModelRef=U,e.assignModel=K,e.cloneModel=R,e.getModelCollection=j,e.getModelId=E,e.getModelMetaKey=N,e.getModelType=D,e.getOriginalModel=w,e.modelToJSON=x,e.setModelMetaKey=L,e.updateModel=I,e.isCollection=function(e){return te(e,ee)},e.isModel=ne,e.setupModel=function(t,n){var r=void 0===n?{fields:{}}:n,a=r.fields,i=r.references,s=r.type,c=r.idAttribute,l=r.typeAttribute,u=t;if(!ne(u))throw A(O);var f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t}(u);return s&&(f.type=s),c&&ce.identifier(f.prototype,c),l&&ce.type(f.prototype,l),a&&Object.keys(a).forEach(function(e){ce.defaultValue(a[e])(f.prototype,e)}),i&&Object.keys(i).forEach(function(t){var n=i[t],r=n.model,o=n.property;switch(i[t].type){case e.ReferenceType.TO_ONE:return ce.toOne(r)(f.prototype,t);case e.ReferenceType.TO_MANY:return ce.toMany(r,o)(f.prototype,t);default:return ce.toOneOrMany(r)(f.prototype,t)}}),f},e.withActions=re,e.withMeta=oe,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mobx"),require("datx-utils")):"function"==typeof define&&define.amd?define(["exports","mobx","datx-utils"],t):t(e.datx={},e.mobx,e.datxUtils)}(this,function(e,t,n){"use strict";var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var a,s,c="The type needs to be defined if the object is not an instance of the model.",u="No model is defined for the type ${type}.",f="The given model is not a clone.",l="The model needs to be in a collection to be referenceable",d="The reference ${key} can't be an array of values.",p="The reference ${key} must be an array of values.",y="You should save this value as a reference.",h="Back references are read only",M="Model ID can't be updated directly. Use the `updateModelId` helper function instead.",_="Model type can't be changed after initialization.",v="Model id is required (autoincrement is disabled)",g="The new reference type doesn't match to the declared one.",b="This mixin can only decorate models";!function(e){e[e.ID=0]="ID",e[e.TYPE=1]="TYPE",e[e.DATA=2]="DATA"}(a||(a={})),(s=e.ReferenceType||(e.ReferenceType={}))[s.TO_ONE=0]="TO_ONE",s[s.TO_MANY=1]="TO_MANY",s[s.TO_ONE_OR_MANY=2]="TO_ONE_OR_MANY";var O=/\$\{\s*([a-zA-Z0-9\-\_]+)\s*\}/g;function m(e,t){return void 0===t&&(t={}),new Error(function(e,t){for(var n=O.exec(e);n;)e=e.replace(n[0],t[n[1]]),n=O.exec(e);return e}(e,t))}function T(e,t,n){for(var r=n,o=e;o;)r=t(r,o),o=Object.getPrototypeOf(o);return r}var D=new(function(){function e(){this.modelData=new WeakMap,this.modelClassData=new WeakMap}return e.prototype.initModel=function(e){var n=t.observable({data:{},meta:{}});return this.modelData.set(e,n),n},e.prototype.getModelData=function(e){return this.__getModelData(e).data},e.prototype.getModelDataKey=function(e,t){return this.__getModelData(e).data[t]},e.prototype.setModelData=function(e,n){var r=this.__getModelData(e);t.set(r.data,n)},e.prototype.setModelDataKey=function(e,t,n){var r;this.setModelData(e,((r={})[t]=n,r))},e.prototype.getModelMeta=function(e){return this.modelData.get(e).meta},e.prototype.getModelMetaKey=function(e,t){return this.getModelMeta(e)[t]},e.prototype.setModelMeta=function(e,n){var r=this.__getModelData(e);return t.set(r.meta,n),r.meta},e.prototype.setModelMetaKey=function(e,t,n){var r;this.setModelMeta(e,((r={})[t]=n,r))},e.prototype.setModelClassMetaKey=function(e,t,n){var r,o=this.modelClassData.get(e);Object.assign(o.meta,((r={})[t]=n,r))},e.prototype.getModelClassMetaKey=function(e,t){var n=this;return T(e,function(e,r){return e||(n.modelClassData.get(r)||{meta:{}}).meta[t]||null},null)},e.prototype.addModelDefaultField=function(e,t,n){var r,o,i=this.modelClassData.get(e);i?Object.assign(i.data,((r={})[t]=n,r)):this.modelClassData.set(e,{data:(o={},o[t]=n,o),meta:{},references:{}})},e.prototype.getModelDefaults=function(e){var t=this,n=T(e,function(e,n){return e.concat((t.modelClassData.get(n)||{data:[]}).data)},[]);return Object.assign.apply(Object,[{}].concat(n.reverse()))},e.prototype.addModelClassReference=function(e,t,n){if(!n.model&&0!==n.model)throw m("The model type is a required parameter. Do you maybe have a circular dependency?");var r,o,i=this.modelClassData.get(e);i?Object.assign(i.references,((r={})[t]=n,r)):this.modelClassData.set(e,{data:{},meta:{},references:(o={},o[t]=n,o)})},e.prototype.getModelClassReferences=function(e){var t=this,n=T(e,function(e,n){return e.concat((t.modelClassData.get(n)||{references:{}}).references)},[]);return Object.assign.apply(Object,[{}].concat(n.reverse()))},e.prototype.getModelReferenceOptions=function(e,t){return this.getModelMetaKey(e,"refs")[t]},e.prototype.__getModelData=function(e){return this.modelData.get(e)||this.initModel(e)},e.prototype.clear=function(){this.modelData=new WeakMap,this.modelClassData=new WeakMap},e}());function A(e){return"function"==typeof e?e.type:"object"==typeof e?x(e,"type")||e.constructor.type:e}function E(e){return e instanceof H?x(e,"id"):e}function j(e){return x(e,"collection")}function R(e){var t=e.constructor,r=N(e),o=r[n.META_FIELD];o.originalId=o.id,delete o.id;var i=new t(r),a=j(e);return a&&a.add(i),i}function I(e){var t=j(e),n=x(e,"originalId");if(n){if(!t)throw m(l);return t.find(e,n)}throw m(f)}function w(e,t){var r=D.getModelClassMetaKey(e.constructor,"id")||"id",o=D.getModelClassMetaKey(e.constructor,"type")||"type";return Object.keys(t instanceof H?N(t):t).forEach(function(i){i!==n.META_FIELD&&i!==r&&i!==o&&C(e,i,t[i])}),e}function C(e,t,n){if(t in x(e,"refs"))!function(e,t,n){x(e,"refs");e[t]=n}(e,t,n);else{if(n instanceof H)throw m(y,{key:t});!function(e,t,n){-1!==x(e,"fields").indexOf(t)?e[t]=n:z(e,t,n)}(e,t,n)}}function K(e,t,r){if(n.META_FIELD in e&&"object"==typeof e[n.META_FIELD]&&void 0!==e[n.META_FIELD])return e[n.META_FIELD][t];if(r){var o=D.getModelClassMetaKey(r,t);return o&&e[o]}return e&&e[t]}function N(e){var r=t.toJS(D.getModelData(e)),o=Object.assign({},D.getModelMeta(e));delete o.collection;var i=t.toJS(o);delete i.collection;var a,s=Object.assign(r,((a={})[n.META_FIELD]=i,a)),c=e.constructor,u=D.getModelClassMetaKey(c,"id"),f=D.getModelClassMetaKey(c,"type");return i&&u&&(s[u]=i.id),i&&f&&(s[f]=i.type),s}function x(e,t){return D.getModelMetaKey(e,t)}function L(e,t,n){return D.setModelMetaKey(e,t,n)}function Y(n,r,o){var i=D.getModelReferenceOptions(n,r),a=E(o),s=D.getModelDataKey(n,r);i.type===e.ReferenceType.TO_ONE?D.setModelDataKey(n,r,a):i.type===e.ReferenceType.TO_MANY||t.isObservableArray(s)?s.push(a):D.setModelDataKey(n,r,o)}function P(n,r,o){var i=D.getModelReferenceOptions(n,r),a=E(o),s=D.getModelDataKey(n,r);i.type===e.ReferenceType.TO_ONE?D.setModelDataKey(n,r,null):i.type===e.ReferenceType.TO_MANY||t.isObservableArray(s)?s.remove(a):D.setModelDataKey(n,r,null)}function k(e,t){return function(n){var r=n;if(!(n instanceof H)&&"object"==typeof n){if(!t)throw new Error(l);r=t.add(n,e.model)}return E(r)}}function S(e,t,n){var r=D.getModelReferenceOptions(e,t);return"splice"===n.type?function(e,t,n,r){var o=r.property;return n.added.map(function(t){return Y(t,o,e)}),e[t].slice(n.index,n.index+n.removedCount).map(function(t){return P(t,o,e)}),null}(e,t,n,r):function(e,t,n,r){var o=r.property,i=e[t].length>n.index?e[t][n.index]:null;return n.newValue&&Y(n.newValue,o,e),i&&P(i,o,e),null}(e,t,n,r)}function F(e,t,n,r){if(r===a.TYPE)throw m(_);if(r===a.ID)throw m(M);t in x(e,"refs")?B(e,t,n):D.setModelDataKey(e,t,n)}function J(e,n,r){var o=A(r.model),i=j(e);if(!i)return null;var a=i.findAll(o).filter(function(t){return function(e,t,n){return null!==e[t]&&void 0!==e[t]&&(e[t]instanceof H?e[t]===n:-1!==e[t].indexOf(n))}(t,r.property,e)}),s=t.observable.array(a,{deep:!1});return t.intercept(s,function(t){return S(e,n,t)}),s}function V(r,o,i){var a=D.getModelDataKey(r,o),s=j(r);if(!s)return null;var c=n.mapItems(a,function(e){return e?s.find(i.model,e):e});if(i.type!==e.ReferenceType.TO_MANY||c instanceof Array||(c=[c]),c instanceof Array){var u=t.observable.array(c,{deep:!1});return t.intercept(u,function(e){return function(e,t,n){var r=D.getModelReferenceOptions(e,t),o=D.getModelDataKey(e,t),i=j(e);if("splice"===n.type){var a=n.added.map(k(r,i));return o.splice.apply(o,[n.index,n.removedCount].concat(a)),null}return o[n.index]=k(r,i)(n.newValue),null}(r,o,e)}),u}return c}function B(r,o,i){var a=D.getModelReferenceOptions(r,o),s=(a.type===e.ReferenceType.TO_MANY?n.mapItems(i,E):n.mapItems(i,E),a.type===e.ReferenceType.TO_MANY?i||[]:i),c=s instanceof Array||t.isObservableArray(s);!function(t,n,r){if(t.type===e.ReferenceType.TO_ONE&&n)throw m(d,{key:r});if(t.type===e.ReferenceType.TO_MANY&&!n)throw m(p,{key:r});if(t.property)throw m(h)}(a,c,o);var u=j(r),f=n.mapItems(i,function(e){if(e&&u){if(e instanceof H)if(A(e)!==A(a.model))throw new Error(g);var t=u.find(a.model,e);return t||"object"!=typeof e||(t=u.add(e,a.model)),E(t||e)}if(e instanceof H)throw m(l);return e});a.type===e.ReferenceType.TO_MANY&&(f=f||[]),!f||f instanceof Array&&f.length,D.setModelDataKey(r,o,f)}function q(e,n,r,o){var i=j(e);if(i)i.getAllModels().map(function(e){(function(e,t){var n=x(e,"refs");return Object.keys(n).filter(function(e){return!n[e].property}).filter(function(e){return A(n[e].model)===t})})(e,o).forEach(function(o){var i=D.getModelDataKey(e,o);if(i instanceof Array||t.isObservableArray(i)){var a=i.indexOf(r);-1!==a&&(i[a]=n)}else i===r&&D.setModelDataKey(e,o,n)})})}function W(e,t){return D.getModelDataKey(e,t)}function $(e,t,n){return D.setModelDataKey(e,t,n)}function z(e,t,r,o){void 0===o&&(o=a.DATA);var i=x(e,"fields");D.setModelDataKey(e,t,r),-1===i.indexOf(t)&&i.push(t),n.assignComputed(e,t,function(){return function(e,t){return D.getModelDataKey(e,t)}(e,t)},function(n){return F(e,t,n,o)})}function U(t,r,o,i){x(t,"refs")[r]=o;var a=o.type===e.ReferenceType.TO_MANY;D.setModelDataKey(t,r,a?[]:void 0),n.assignComputed(t,r,function(){return function(e,t){var n=D.getModelReferenceOptions(e,t);return"string"==typeof n.property?J(e,t,n):V(e,t,n)}(t,r)},function(e){return B(t,r,e)}),o.property||(t[r]=i)}function Z(e,t,n,r){var o=function(e,t,n){var r=n.constructor,o=t.fields.slice(),i=D.getModelClassReferences(r),a=Object.assign({},i,t.refs),s=D.getModelDefaults(r);return Object.keys(e).concat(Object.keys(s)).forEach(function(e){e in a||-1!==o.indexOf(e)||o.push(e)}),{defaults:s,fields:o,refs:a}}(t,n,e),i=o.defaults,s=o.fields,c=o.refs,u=e.constructor,f=D.getModelClassMetaKey(u,"id"),l=D.getModelClassMetaKey(u,"type");s.forEach(function(r){var o=a.DATA,s=t[r];void 0===s&&(s=i[r]),r===(f||"id")?(o=a.ID,s=n.id):r===l&&(o=a.TYPE,s=n.type),z(e,r,s,o)}),!f||f in s||z(e,f,n.id,a.ID),Object.keys(c).forEach(function(n){var o=c[n],a=t[n]||i[n]||void 0,s=r?r.add(a,A(o.model)):a;U(e,n,o,s)})}function G(e,t,r){var o=e.constructor,i=Object.assign({},o.preprocess(t));L(e,"collection",r);var a=function(e,t,r){var o=e.constructor,i=D.getModelClassMetaKey(o,"id")||"id",a=D.getModelClassMetaKey(o,"type"),s=a&&t[a]||A(e),c=i&&t[i];if(!c){if(!o.enableAutoId)throw new Error(v);for(c=o.getAutoId();r&&r.find(s,c);)c=o.getAutoId()}var u,f={fields:[],id:c,refs:{},type:s},l={fields:[],refs:{}};if(n.META_FIELD in t&&t[n.META_FIELD]){var d=t[n.META_FIELD];l.fields=d.fields,delete d.fields,l.refs=d.refs,delete d.refs,u=D.setModelMeta(e,Object.assign(f,d)),delete t[n.META_FIELD]}else u=D.setModelMeta(e,f);return Object.assign({},u,l)}(e,i,r);Z(e,i,a,r)}var H=function(){function e(e,n){void 0===e&&(e={}),t.extendObservable(this,{}),G(this,e,n)}return e.preprocess=function(e){return e},e.getAutoId=function(){return"number"==typeof this.autoIdValue?--this.autoIdValue:this.autoIdValue},e.toJSON=function(){return this.type},e.type=n.DEFAULT_TYPE,e.autoIdValue=0,e.enableAutoId=!0,e}();function Q(e,t,n){if(!t&&0!==t)throw m(c);var r=n.constructor,o=r.types.find(function(e){return e.type===t})||r.defaultModel;if(!o)throw m(u,{type:t});var i=K(e,"id",o),a=i&&n.find(t,i);return a?w(a,e):new o(e,n)}function X(e,t){return t.map(function(t){return function(e,t){return Q(t,K(t,"type"),e)}(e,t)})}var ee=function(){function e(e){void 0===e&&(e=[]),this.__data=t.observable.array([],{deep:!1}),this.__dataMap={},this.__dataList={},t.extendObservable(this,{}),this.insert(e)}return e.prototype.insert=function(e){var t=X(this,e);return this.__insertModel(t),t},e.prototype.add=function(e,t){return e instanceof Array?this.__addArray(e,t):this.__addSingle(e,t)},e.prototype.find=function(e,t){return t instanceof H?t:"function"!=typeof(n=e)||n===H||n.prototype instanceof H?this.__findByType(e,t)||null:this.__data.find(e)||null;var n},e.prototype.filter=function(e){return this.__data.filter(e)},e.prototype.findAll=function(e){if(e){var n=A(e);return n in this.__dataList||t.set(this.__dataList,((r={})[n]=t.observable.array([]),r)),this.__dataList[n]}return this.__data;var r},e.prototype.hasItem=function(e){var t=E(e);return Boolean(this.find(e,t))},e.prototype.remove=function(e,t){var n="object"==typeof e?e:this.find(e,t);n&&this.__removeModel(n)},e.prototype.removeAll=function(e){this.__removeModel(this.findAll(e).slice())},Object.defineProperty(e.prototype,"length",{get:function(){return this.__data.length},enumerable:!0,configurable:!0}),e.prototype.toJSON=function(){return this.__data.map(N)},Object.defineProperty(e.prototype,"snapshot",{get:function(){return this.toJSON()},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.__data.map(function(e){return L(e,"collection",void 0)}),this.__data.replace([]),this.__dataList=t.observable({}),this.__dataMap=t.observable({})},e.prototype.getAllModels=function(){return this.__data.slice()},e.prototype.__addArray=function(e,t){var n=this;return e.filter(Boolean).map(function(e){return n.__addSingle(e,t)})},e.prototype.__addSingle=function(e,t){if(!e||"number"==typeof e||"string"==typeof e)return e;if(e instanceof H)return this.hasItem(e)||this.__insertModel(e),e;if(!t&&0!==t)throw m(c);var n=A(t),r=Q(e,n,this);return this.__insertModel(r,n),r},e.prototype.__insertModel=function(e,n,r){var o=this;if(e instanceof Array)return e.forEach(function(e){return o.__insertModel(e,n,r)});var i=j(e);if(i&&i!==this)throw m("A model can be in a single collection at once");var a,s=n||A(e),c=r||E(e),u=s.toString(),f=this.find(s,c);f?w(f,e):(this.__data.push(e),s in this.__dataList?this.__dataList[s].push(e):t.set(this.__dataList,u,t.observable.array([e],{deep:!1})),s in this.__dataMap?t.set(this.__dataMap[s],c.toString(),e):t.set(this.__dataMap,u,t.observable.shallowObject(((a={})[c]=e,a))),L(e,"collection",this))},e.prototype.__removeModel=function(e,n,r){var o=this;if(e instanceof Array)return e.forEach(function(e){return o.__removeModel(e,n,r)});var i=n||A(e),a=r||E(e);this.__data.remove(e),this.__dataList[i].remove(e),t.set(this.__dataMap[i],a.toString(),void 0),L(e,"collection",void 0)},e.prototype.__findByType=function(e,n){var r,o=A(e),i=o.toString();return n?(o in this.__dataMap?n in this.__dataMap[o]||t.set(this.__dataMap[o],n.toString(),void 0):t.set(this.__dataMap,i,((r={})[n]=void 0,r)),this.__dataMap[o][n]):(o in this.__dataList||t.set(this.__dataList,i,t.observable.array([],{deep:!1})),this.__dataList[o].length?this.__dataList[o][0]:null)},e.prototype.__changeModelId=function(e,t,n){this.__dataMap[n][t]=this.__dataMap[n][e],delete this.__dataMap[n][e]},e.types=[],i([t.observable],e.prototype,"__dataMap",void 0),i([t.observable],e.prototype,"__dataList",void 0),i([t.action],e.prototype,"insert",null),i([t.action],e.prototype,"add",null),i([t.action],e.prototype,"remove",null),i([t.action],e.prototype,"removeAll",null),i([t.computed],e.prototype,"length",null),i([t.action],e.prototype,"reset",null),e}();function te(e,t){for(var n=e;n;){if(n===t)return!0;n=Object.getPrototypeOf(n)}return!1}function ne(e){return te(e,H)}function re(e){var t=e;if(!ne(e))throw m(b);return function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.update=function(e){w(this,e)},t.prototype.clone=function(){return R(this)},t.prototype.assign=function(e,t){C(this,e,t)},t.prototype.addReference=function(e,t,n){U(this,e,n,t)},t.prototype.toJSON=function(){return N(this)},t}(t)}function oe(e){var n=e;if(!ne(n))throw m(b);return function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return o(n,e),Object.defineProperty(n.prototype,"meta",{get:function(){var e=this,t=x(this,"refs"),n={};return Object.keys(t).forEach(function(t){n[t]=W(e,t)}),Object.freeze({collection:j(this),id:E(this),original:x(this,"originalId")&&I(this)||void 0,refs:n,snapshot:N(this),type:A(this)})},enumerable:!0,configurable:!0}),i([t.computed],n.prototype,"meta",null),n}(n)}var ie=re(oe(H)),ae=function(r){function i(t,o){var i=r.call(this,t,o)||this;return Object.keys(i.static.refs).forEach(function(t){if(!(t in x(i,"refs"))){var r=i.static.refs[t],o=n.mapItems(i[t]||i.static.defaults[t],E);delete i[t],U(i,t,"object"==typeof r?{model:r.model,property:r.property,type:e.ReferenceType.TO_ONE_OR_MANY}:{model:r,type:e.ReferenceType.TO_ONE_OR_MANY},o)}}),Object.keys(i.static.defaults).forEach(function(e){e in i.static.refs||e in i||z(i,e,i.static.defaults[e])}),i}return o(i,r),i.prototype.getRecordId=function(){return E(this)},i.prototype.getRecordType=function(){return A(this)},i.prototype.assign=function(e,t){var n=a.DATA,r=D.getModelClassMetaKey(this.static,"id"),o=D.getModelClassMetaKey(this.static,"type");return e===r?n=a.ID:e===o&&(n=a.TYPE),F(this,e,t,n),t},i.prototype.assignRef=function(n,r,o){if(x(this,"refs")[n])return this[n]=r;var i=o;if(i||(r instanceof Array||t.isObservableArray(r)?i=r.reduce(function(e,t){return e||A(t)},null):r instanceof H&&(i=A(r))),!i)throw new Error("The type property is missing");return U(this,n,{model:i,type:e.ReferenceType.TO_ONE_OR_MANY},r),this[n]},i.prototype.update=function(e){var t=this,n=Object.assign({},e);return Object.keys(n).forEach(function(e){"function"==typeof t[e]&&delete n[e]}),w(this,n)},Object.defineProperty(i.prototype,"static",{get:function(){return this.constructor},enumerable:!0,configurable:!0}),i.prototype.toJS=function(){return N(this)},Object.defineProperty(i.prototype,"snapshot",{get:function(){return N(this)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"__collection",{get:function(){return j(this)},enumerable:!0,configurable:!0}),i.refs={},i.defaults={},i}(H),se=function(e){function t(t){var r=e.call(this,t)||this;return r.static.types.forEach(function(e){var t=A(e);n.assignComputed(r,t.toString(),function(){return r.findAll(t)})}),r}return o(t,e),Object.defineProperty(t.prototype,"static",{get:function(){return this.constructor},enumerable:!0,configurable:!0}),t.prototype.toJS=function(){return this.toJSON()},t.types=[ae],t}(ee);var ce=Object.assign(function(e,t){D.addModelDefaultField(e.constructor,t)},{defaultValue:function(e){return function(t,n){D.addModelDefaultField(t.constructor,n,e)}},toOne:function(t){return function(n,r){D.addModelClassReference(n.constructor,r,{model:t,type:e.ReferenceType.TO_ONE})}},toMany:function(t,n){return function(r,o){D.addModelClassReference(r.constructor,o,{model:t,property:n,type:e.ReferenceType.TO_MANY})}},toOneOrMany:function(t){return function(n,r){D.addModelClassReference(n.constructor,r,{model:t,type:e.ReferenceType.TO_ONE_OR_MANY})}},identifier:function(e,t){D.addModelDefaultField(e.constructor,t),D.setModelClassMetaKey(e.constructor,"id",t)},type:function(e,t){D.addModelDefaultField(e.constructor,t),D.setModelClassMetaKey(e.constructor,"type",t)}});e.prop=ce,e.Collection=ee,e.Model=ie,e.PureCollection=ee,e.PureModel=H,e.CompatCollection=se,e.CompatModel=ae,e.getRefId=W,e.setRefId=$,e.updateModelId=function(e,t){var n=j(e),r=E(e),o=A(e);L(e,"id",t);var i=e.constructor,a=D.getModelClassMetaKey(i,"id");a&&$(e,a,t),n&&n.__changeModelId(r,t,o),q(e,t,r,o)},e.initModelRef=U,e.assignModel=C,e.cloneModel=R,e.getModelCollection=j,e.getModelId=E,e.getModelMetaKey=x,e.getModelType=A,e.getOriginalModel=I,e.modelToJSON=N,e.setModelMetaKey=L,e.updateModel=w,e.isCollection=function(e){return te(e,ee)},e.isModel=ne,e.setupModel=function(t,n){var r=void 0===n?{fields:{}}:n,i=r.fields,a=r.references,s=r.type,c=r.idAttribute,u=r.typeAttribute,f=t;if(!ne(f))throw m(b);var l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t}(f);return s&&(l.type=s),c&&ce.identifier(l.prototype,c),u&&ce.type(l.prototype,u),i&&Object.keys(i).forEach(function(e){ce.defaultValue(i[e])(l.prototype,e)}),a&&Object.keys(a).forEach(function(t){var n=a[t],r=n.model,o=n.property;switch(a[t].type){case e.ReferenceType.TO_ONE:return ce.toOne(r)(l.prototype,t);case e.ReferenceType.TO_MANY:return ce.toMany(r,o)(l.prototype,t);default:return ce.toOneOrMany(r)(l.prototype,t)}}),l},e.withActions=re,e.withMeta=oe,Object.defineProperty(e,"__esModule",{value:!0})});
import { IDictionary } from 'datx-utils';
import { IObservableObject } from 'mobx';
import { IReferenceOptions } from '../interfaces/IReferenceOptions';

@@ -10,3 +11,3 @@ import { PureModel } from '../PureModel';

meta: {};
};
} & IObservableObject;
getModelData(model: PureModel): IDictionary<any>;

@@ -13,0 +14,0 @@ getModelDataKey(model: PureModel, key: string): any;

{
"name": "datx",
"version": "0.9.9",
"version": "0.9.10",
"description": "A MobX data store",

@@ -20,16 +20,15 @@ "main": "dist/index.js",

"@infinumjs/tslint-config": "^1.1.1",
"@types/jest": "^22.1.2",
"@types/node": "^9.4.4",
"jest": "^22.2.2",
"mobx": "^3.5.1",
"mobx-collection-store": "^2.0.0",
"rollup": "^0.56.2",
"rollup-plugin-typescript2": "^0.11.1",
"@types/jest": "^22.2.0",
"@types/node": "^9.4.7",
"jest": "^22.4.2",
"mobx": "^4.1.0",
"rollup": "^0.57.1",
"rollup-plugin-typescript2": "^0.12.0",
"rollup-plugin-uglify": "^3.0.0",
"ts-jest": "^22.0.3",
"ts-jest": "^22.4.1",
"tslint": "^5.9.1",
"typescript": "^2.7.1"
"typescript": "^2.7.2"
},
"peerDependencies": {
"mobx": "^3.5.1"
"mobx": "^4.1.0"
},

@@ -51,3 +50,2 @@ "scripts": {

],
"mapCoverage": true,
"moduleFileExtensions": [

@@ -63,4 +61,4 @@ "ts",

"dependencies": {
"datx-utils": "^0.9.7"
"datx-utils": "^0.9.10"
}
}

@@ -17,3 +17,3 @@ {

],
"module": "commonjs",
"module": "esnext",
"noImplicitAny": false,

@@ -20,0 +20,0 @@ "noImplicitReturns": true,

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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc