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

datx

Package Overview
Dependencies
Maintainers
11
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 1.0.1 to 1.0.2

2

dist/index.cjs.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var datxUtils=require("datx-utils"),mobx=require("mobx"),extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])})(e,t)};function __extends(e,t){function o(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __decorate(e,t,o,r){var n,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;0<=s;s--)(n=e[s])&&(a=(i<3?n(a):3<i?n(t,o,a):n(t,o))||a);return 3<i&&a&&Object.defineProperty(t,o,a),a}!function(e){e[e.CRATE=0]="CRATE",e[e.UPDATE=1]="UPDATE",e[e.REMOVE=2]="REMOVE"}(exports.PatchType||(exports.PatchType={}));var REGEX=/\$\{\s*([a-zA-Z0-9\-\_]+)\s*\}/g;function msg(e,t){for(var o=e,r=REGEX.exec(o);r;)o=o.replace(r[0],t[r[1]]),r=REGEX.exec(o);return o}function error(e,t){return void 0===t&&(t={}),new Error("[datx exception] "+msg(e,t))}var FieldType,UNDEFINED_TYPE="The type needs to be defined if the object is not an instance of the model.",UNDEFINED_MODEL="No model is defined for the type ${type}.",NOT_A_CLONE="The given model is not a clone.",REF_NEEDS_COLLECTION="The model needs to be in a collection to be referenceable",REF_SINGLE="The reference ${key} can't be an array of values.",REF_ARRAY="The reference ${key} must be an array of values.",NO_REFS="You should save this value as a reference.",BACK_REF_READ_ONLY="Back references are read only",ID_READONLY="Model ID can't be updated directly. Use the `updateModelId` helper function instead.",TYPE_READONLY="Model type can't be changed after initialization.",MODEL_SINGLE_COLLECTION="A model can be in a single collection at once",ID_REQUIRED="Model id is required (autoincrement is disabled)",WRONG_REF_TYPE="The new reference type doesn't match to the declared one.",MODEL_REQUIRED="The model type is a required parameter. Do you maybe have a circular dependency?",SORTED_NO_WRITE="New models can't be added directly to a sorted view list",UNIQUE_MODEL="The models in this view need to be unique",VIEW_NAME_TAKEN="The name is already taken",DECORATE_MODEL="This mixin can only decorate models";function reducePrototypeChain(e,t,o){for(var r=o,n=e;n;)r=t(r,n),n=Object.getPrototypeOf(n);return r}!function(e){e[e.ID=0]="ID",e[e.TYPE=1]="TYPE",e[e.DATA=2]="DATA"}(FieldType||(FieldType={})),function(e){e[e.TO_ONE=0]="TO_ONE",e[e.TO_MANY=1]="TO_MANY",e[e.TO_ONE_OR_MANY=2]="TO_ONE_OR_MANY"}(exports.ReferenceType||(exports.ReferenceType={}));var DATX_KEY=Symbol.for("datx metadata");function setMeta(e,t){Object.defineProperty(e,DATX_KEY,{enumerable:!1,value:t,writable:!1})}var DataStorage=function(){function e(){}return e.prototype.initModel=function(e){var t=mobx.observable({data:{},meta:{}});return setMeta(e,t),t},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,t){var o=this.__getModelData(e);mobx.set(o.data,t)},e.prototype.setModelDataKey=function(e,t,o){var r;this.setModelData(e,((r={})[t]=o,r))},e.prototype.getModelMeta=function(e){var t=e[DATX_KEY];return t?t.meta:this.setModelMeta(e,{})},e.prototype.getModelMetaKey=function(e,t){return this.getModelMeta(e)[t]},e.prototype.setModelMeta=function(e,t){var o=this.__getModelData(e);return mobx.set(o.meta,t),o.meta},e.prototype.setModelMetaKey=function(e,t,o){var r;this.setModelMeta(e,((r={})[t]=o,r))},e.prototype.setModelClassMetaKey=function(e,t,o){var r,n=e[DATX_KEY];n||setMeta(e,n={data:{},meta:{},references:{}}),Object.assign(n.meta,((r={})[t]=o,r))},e.prototype.getModelClassMetaKey=function(e,o){return reducePrototypeChain(e,function(e,t){return e||(t[DATX_KEY]||{meta:{}}).meta[o]||null},null)},e.prototype.addModelDefaultField=function(e,t,o){var r,n,i=e[DATX_KEY];i?Object.assign(i.data,((r={})[t]=o,r)):setMeta(e,{data:(n={},n[t]=o,n),meta:{},references:{}})},e.prototype.getModelDefaults=function(e){var t=reducePrototypeChain(e,function(e,t){return e.concat((t[DATX_KEY]||{data:[]}).data)},[]);return Object.assign.apply(Object,[{}].concat(t.reverse()))},e.prototype.addModelClassReference=function(e,t,o){var r,n;if(!o.model&&0!==o.model)throw error(MODEL_REQUIRED);var i=e[DATX_KEY];i?Object.assign(i.references,((r={})[t]=o,r)):setMeta(e,{data:{},meta:{},references:(n={},n[t]=o,n)})},e.prototype.getModelClassReferences=function(e){var t=reducePrototypeChain(e,function(e,t){return e.concat((t[DATX_KEY]||{references:{}}).references)},[]);return Object.assign.apply(Object,[{}].concat(t.reverse()))},e.prototype.getModelReferenceOptions=function(e,t){return this.getModelMetaKey(e,"refs")[t]},e.prototype.__getModelData=function(e){return e[DATX_KEY]||this.initModel(e)},e}(),storage=new DataStorage;function getModelType(e){return"function"==typeof e?e.type:"object"==typeof e?getModelMetaKey(e,"type")||e.constructor.type:e}function getModelId(e){return e instanceof PureModel?getModelMetaKey(e,"id"):e}function getModelCollection(e){return getModelMetaKey(e,"collection")}function cloneModel(e){var t=e.constructor,o=modelToJSON(e),r=o[datxUtils.META_FIELD]||{};r.originalId=r.id,delete r.id;var n=new t(o),i=getModelCollection(e);return i?i.add(n):datxUtils.warn("The model is not in the collection. Referencing the original model won't be possible"),n}function getOriginalModel(e){var t=getModelCollection(e),o=getModelMetaKey(e,"originalId");if(o){if(!t)throw error(REF_NEEDS_COLLECTION);return t.findOne(e,o)}throw error(NOT_A_CLONE)}var READ_ONLY_META=["fields","id","refs","type"];function updateModel(o,r){var e=storage.getModelClassMetaKey(o.constructor,"id")||"id",n=storage.getModelClassMetaKey(o.constructor,"type")||"type",t=Object.keys(r instanceof PureModel?modelToJSON(r):r);return mergeMeta(o,storage.getModelMeta(o),r[datxUtils.META_FIELD]),startAction(o),t.forEach(function(t){if(t!==datxUtils.META_FIELD&&t!==e&&t!==n)assignModel(o,t,r[t]);else if(t===datxUtils.META_FIELD){Object.keys(r[t]||{}).forEach(function(e){READ_ONLY_META.includes(e)||setModelMetaKey(o,e,r[t][e])})}}),endAction(o),o}function assignModel(e,t,o){if(!(e instanceof PureModel))throw error("The given parameter is not a valid model");var r=getModelMetaKey(e,"refs");if(!r)throw error("The given models is not initialized correctly");if(startAction(e),t in r)assignModelRef(e,t,o);else{if(o instanceof PureModel)throw endAction(e),error(NO_REFS,{key:t});assignModelField(e,t,o)}endAction(e)}function assignModelField(e,t,o){-1!==getModelMetaKey(e,"fields").indexOf(t)?e[t]=o:initModelField(e,t,o)}function assignModelRef(e,t,o){e[t]=o}function getMetaKeyFromRaw(e,t,o){if(datxUtils.META_FIELD in e&&"object"==typeof e[datxUtils.META_FIELD]&&void 0!==e[datxUtils.META_FIELD])return(e[datxUtils.META_FIELD]||{})[t];if(o){var r=storage.getModelClassMetaKey(o,t);return r&&e[r]}return e&&e[t]}function modelToJSON(e){var t,o=mobx.toJS(storage.getModelData(e)),r=Object.assign({},storage.getModelMeta(e));delete r.collection,delete r.patch;var n=mobx.toJS(r),i={};Object.keys(n.refs||{}).forEach(function(e){i[e]={model:getModelType(n.refs[e].model),type:n.refs[e].type}}),n.refs=i,delete n.collection;var a=Object.assign(o,((t={})[datxUtils.META_FIELD]=n,t)),s=e.constructor,d=storage.getModelClassMetaKey(s,"id"),l=storage.getModelClassMetaKey(s,"type");return n&&d&&(a[d]=n.id),n&&l&&(a[l]=n.type),a}function getModelMetaKey(e,t){return storage.getModelMetaKey(e,t)}function setModelMetaKey(e,t,o){storage.setModelMetaKey(e,t,o)}function getModelClassRefs(e){return storage.getModelClassReferences(e)}function isEmptyObject(e){return 0===Object.keys(e).length}function reverseAction(e){switch(e){case exports.PatchType.CRATE:return exports.PatchType.REMOVE;case exports.PatchType.REMOVE:return exports.PatchType.CRATE;default:return exports.PatchType.UPDATE}}function triggerAction(e,t){var o=__assign({},e,{model:{id:getModelId(t),type:getModelType(t)}}),r=[];"__patchListeners"in t&&r.push.apply(r,t.__patchListeners||[]);var n=getModelCollection(t);n&&"__patchListeners"in n&&r.push.apply(r,n.__patchListeners||[]),r.forEach(function(e){e(o)})}function startAction(e){var t=storage.getModelMetaKey(e,"patch")||{count:0,oldValue:{},newValue:{}};t.count++,storage.setModelMetaKey(e,"patch",t)}function updateAction(e,t,o){var r=storage.getModelMetaKey(e,"patch")||{count:0,oldValue:{},newValue:{}};e[t]!==o&&(t in r.oldValue||(r.oldValue[t]=e[t]),r.newValue[t]=o,storage.setModelMetaKey(e,"patch",r))}function endAction(e,t){void 0===t&&(t=exports.PatchType.UPDATE);var o=storage.getModelMetaKey(e,"patch")||{count:0,oldValue:{},newValue:{}};if(o.count--,0===o.count){var r=mobx.toJS(o.newValue),n=mobx.toJS(o.oldValue);isEmptyObject(r)&&isEmptyObject(n)||triggerAction({newValue:r,oldValue:n,patchType:t},e),storage.setModelMetaKey(e,"patch",{count:0,oldValue:{},newValue:{}})}else storage.setModelMetaKey(e,"patch",o)}function modelAddReference(e,t,o){var r=storage.getModelReferenceOptions(e,t),n=getModelId(o),i=storage.getModelDataKey(e,t);r.type===exports.ReferenceType.TO_ONE?storage.setModelDataKey(e,t,n):r.type===exports.ReferenceType.TO_MANY||mobx.isObservableArray(i)?i.push(n):storage.setModelDataKey(e,t,o)}function modelRemoveReference(e,t,o){var r=storage.getModelReferenceOptions(e,t),n=getModelId(o),i=storage.getModelDataKey(e,t);r.type===exports.ReferenceType.TO_ONE?storage.setModelDataKey(e,t,null):r.type===exports.ReferenceType.TO_MANY||mobx.isObservableArray(i)?i.remove(n):storage.setModelDataKey(e,t,null)}function ensureModel(o,r){return function(e){var t=e;if(!(e instanceof PureModel)&&"object"==typeof e){if(!r)throw error(REF_NEEDS_COLLECTION);t=r.add(e,o.model)}return getModelId(t)}}function partialRefUpdate(e,t,o){var r=storage.getModelReferenceOptions(e,t),n=storage.getModelDataKey(e,t),i=getModelCollection(e);if("splice"!==o.type)return n[o.index]=ensureModel(r,i)(o.newValue),null;var a=o.added.map(ensureModel(r,i));return n.splice.apply(n,[o.index,o.removedCount].concat(a)),null}function backRefSplice(t,e,o,r){var n=r.property;return o.added.forEach(function(e){modelAddReference(e,n,t)}),t[e].slice(o.index,o.index+o.removedCount).forEach(function(e){modelRemoveReference(e,n,t)}),null}function backRefChange(e,t,o,r){var n=r.property,i=e[t].length>o.index?e[t][o.index]:null;return o.newValue&&modelAddReference(o.newValue,n,e),i&&modelRemoveReference(i,n,e),datxUtils.warn("This shouldn't have happened. Please open an issue: https://github.com/infinum/datx/issues/new"),null}function partialBackRefUpdate(e,t,o){var r=storage.getModelReferenceOptions(e,t);return"splice"===o.type?backRefSplice(e,t,o,r):backRefChange(e,t,o,r)}function getField(e,t){return storage.getModelDataKey(e,t)}function updateField(e,t,o,r){if(r===FieldType.TYPE)throw error(TYPE_READONLY);if(r===FieldType.ID)throw error(ID_READONLY);startAction(e),t in getModelMetaKey(e,"refs")?updateRef(e,t,o):(updateAction(e,t,o),storage.setModelDataKey(e,t,o)),endAction(e)}function hasBackRef(e,t,o){return null!==e[t]&&void 0!==e[t]&&(e[t]instanceof PureModel?e[t]===o:-1!==e[t].indexOf(o))}function getBackRef(t,o,r){var e=getModelType(r.model),n=getModelCollection(t);if(!n)return null;var i=n.findAll(e).filter(function(e){return hasBackRef(e,r.property,t)}),a=mobx.observable.array(i,{deep:!1});return mobx.intercept(a,function(e){return partialBackRefUpdate(t,o,e)}),a}function getNormalRef(t,o,r){var e=storage.getModelDataKey(t,o),n=getModelCollection(t);if(!n)return null;var i=datxUtils.mapItems(e,function(e){return e?n.findOne(r.model,e):e});if(r.type!==exports.ReferenceType.TO_MANY||i instanceof Array||(i=[i]),i instanceof Array){var a=mobx.observable.array(i,{deep:!1});return mobx.intercept(a,function(e){return partialRefUpdate(t,o,e)}),a}return i}function getRef(e,t){var o=storage.getModelReferenceOptions(e,t);return"string"==typeof o.property?getBackRef(e,t,o):getNormalRef(e,t,o)}function validateRef(e,t,o){if(e.type===exports.ReferenceType.TO_ONE&&t)throw error(REF_SINGLE,{key:o});if(e.type===exports.ReferenceType.TO_MANY&&!t)throw error(REF_ARRAY,{key:o});if(e.property)throw error(BACK_REF_READ_ONLY)}function updateRef(o,e,t){var r=storage.getModelReferenceOptions(o,e),n=r.type===exports.ReferenceType.TO_MANY?t||[]:t,i=n instanceof Array||mobx.isObservableArray(n);validateRef(r,i,e);var a=getModelCollection(o);startAction(o);var s=datxUtils.mapItems(t,function(e){if(e&&a){if(e instanceof PureModel)if(getModelType(e)!==getModelType(r.model))throw endAction(o),error(WRONG_REF_TYPE);var t=a.findOne(r.model,e);return t||"object"!=typeof e||(t=a.add(e,r.model)),endAction(o),getModelId(t||e)}if(e instanceof PureModel)throw endAction(o),error(REF_NEEDS_COLLECTION);return e});r.type===exports.ReferenceType.TO_MANY&&(s=s||[]),updateAction(o,e,s),storage.setModelDataKey(o,e,s),endAction(o)}function getModelRefsByType(e,t){var o=getModelMetaKey(e,"refs");return Object.keys(o).filter(function(e){return!o[e].property}).filter(function(e){return getModelType(o[e].model)===t})}function updateModelReferences(e,n,i,t){var o=getModelCollection(e);o&&o.getAllModels().map(function(r){getModelRefsByType(r,t).forEach(function(e){var t=storage.getModelDataKey(r,e);if(t instanceof Array||mobx.isObservableArray(t)){var o=t.indexOf(i);-1!==o&&(t[o]=n)}else t===i&&storage.setModelDataKey(r,e,n)})})}function updateModelId(e,t){var o=getModelCollection(e),r=getModelId(e),n=getModelType(e);setModelMetaKey(e,"id",t);var i=e.constructor,a=storage.getModelClassMetaKey(i,"id");a&&setRefId(e,a,t),o&&o.__changeModelId(r,t,n),updateModelReferences(e,t,r,n)}function getRefId(e,t){return storage.getModelDataKey(e,t)}function setRefId(e,t,o){storage.setModelDataKey(e,t,o)}function initModelField(t,o,e,r){void 0===r&&(r=FieldType.DATA);var n=getModelMetaKey(t,"fields");r===FieldType.ID&&o in t&&storage.setModelDataKey(t,o,void 0),storage.setModelDataKey(t,o,e),updateAction(t,o,e),-1===n.indexOf(o)&&n.push(o),datxUtils.assignComputed(t,o,function(){return getField(t,o)},function(e){updateField(t,o,e,r)})}function initModelRef(t,o,e,r){var n=(getModelMetaKey(t,"refs")[o]=e).type===exports.ReferenceType.TO_MANY;storage.setModelDataKey(t,o,n?[]:void 0),updateAction(t,o,n?[]:void 0),datxUtils.assignComputed(t,o,function(){return getRef(t,o)},function(e){updateRef(t,o,e)}),e.property||void 0===r||(t[o]=r)}function prepareFields(e,t,o){var r=o.constructor,n=t.fields?t.fields.slice():[],i=storage.getModelClassReferences(r),a=Object.assign({},i,t.refs),s=storage.getModelDefaults(r);return Object.keys(e).concat(Object.keys(s)).forEach(function(e){e in a||-1!==n.indexOf(e)||n.push(e)}),{defaults:s,fields:n,refs:a}}function initModelData(n,i,r,a){var e=prepareFields(i,r,n),s=e.defaults,t=e.fields,d=e.refs,o=n.constructor,l=storage.getModelClassMetaKey(o,"id"),c=storage.getModelClassMetaKey(o,"type");t.forEach(function(e){var t=FieldType.DATA,o=i[e];void 0===o&&(o=s[e]),e===(l||"id")?(t=FieldType.ID,o=r.id):e===c&&(t=FieldType.TYPE,o=r.type),initModelField(n,e,o,t)}),!l||l in t||initModelField(n,l,r.id,FieldType.ID),Object.keys(d).forEach(function(e){var t=d[e],o=i[e]||s[e]||void 0,r=a?a.add(o,getModelType(t.model)):o;initModelRef(n,e,t,r)})}function initModelMeta(e,t,o){var r=e.constructor,n=storage.getModelClassMetaKey(r,"id")||"id",i=storage.getModelClassMetaKey(r,"type"),a=datxUtils.META_FIELD in t&&t[datxUtils.META_FIELD]||{},s=i&&t[i]||void 0!==a&&a.type||getModelType(e),d=n&&t[n]||void 0!==a&&a.id;if(!d){if(!r.enableAutoId)throw new Error(ID_REQUIRED);for(d=r.getAutoId();o&&o.findOne(s,d);)d=r.getAutoId()}var l={fields:[],id:d,refs:{},type:s},c=datxUtils.META_FIELD in t&&t[datxUtils.META_FIELD]?mergeMeta(e,l,t[datxUtils.META_FIELD]):storage.setModelMeta(e,l);return delete t[datxUtils.META_FIELD],Object.assign({},c)}function mergeMeta(e,t,o){var r;void 0===o&&(o={});var n={fields:[],refs:{}};n.fields=o.fields,(r=t.fields).push.apply(r,o.fields||[]),n.refs=o.refs,Object.assign(t.refs,o.refs||{});var i=["fields","refs","type","id"];Object.keys(o).forEach(function(e){-1===i.indexOf(e)&&(t[e]=o[e])});var a=storage.setModelMeta(e,t);return Object.assign({},a,n)}function initModel(e,t,o){var r=e.constructor,n=Object.assign({},r.preprocess(t,o));setModelMetaKey(e,"collection",o),initModelData(e,n,initModelMeta(e,n,o),o)}var PureModel=function(){function e(e,t){void 0===e&&(e={});var o=this.constructor;o.__datxInitProps&&o.__datxInitProps(),startAction(this),mobx.extendObservable(this,{}),initModel(this,e,t),endAction(this,exports.PatchType.CRATE)}return e.preprocess=function(e,t){return e},e.getAutoId=function(){return"number"==typeof this.autoIdValue?--this.autoIdValue:this.autoIdValue},e.toJSON=function(){return this.type},e.type=datxUtils.DEFAULT_TYPE,e.autoIdValue=0,e.enableAutoId=!0,e}();function initCollectionModel(e,t){return upsertModel(t,getMetaKeyFromRaw(t,"type"),e)}function upsertModel(e,t,o){var r;if(!t&&0!==t)throw error(UNDEFINED_TYPE);var n=o.constructor,i=n.types.find(function(e){return e.type===t});if(!i){var a=n.defaultModel;if(a)return new a(__assign({},e,((r={})[datxUtils.META_FIELD]=__assign({},e[datxUtils.META_FIELD]||{},{type:t}),r)),o);throw error(UNDEFINED_MODEL,{type:t})}var s=getMetaKeyFromRaw(e,"id",i),d=s&&o.findOne(t,s);return d?updateModel(d,e):new i(e,o)}function isSelectorFunction(e){return"function"==typeof e&&e!==PureModel&&!(e.prototype instanceof PureModel)}function initModels(t,e){return e.map(function(e){return initCollectionModel(t,e)})}var View=function(){function e(e,t,o,r,n){var i=this;void 0===r&&(r=[]),void 0===n&&(n=!1),this.__collection=t,this.unique=n,this.__models=mobx.observable.array([]),this.modelType=getModelType(e);var a=datxUtils.mapItems(r,function(e){return i.__getModel(e)||e}).filter(Boolean);this.__models.replace(a),this.sortMethod=o,mobx.reaction(function(){return 0<i.__models.filter(function(e){return i.__isIdentifier(e)}).filter(function(e){return i.__collection.findOne(i.modelType,e)}).length},this.__reMap.bind(this))}return Object.defineProperty(e.prototype,"length",{get:function(){return this.list.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"list",{get:function(){var t=this,e=this.__models.filter(function(e){return!t.__isIdentifier(e)}).filter(Boolean);if(this.sortMethod){var o="string"==typeof this.sortMethod?function(e){return e[t.sortMethod]}:this.sortMethod;e.sort(function(e,t){return o(e)-o(t)})}var r=mobx.observable.array(e,{deep:!1});return mobx.intercept(r,this.__partialListUpdate.bind(this)),r},enumerable:!0,configurable:!0}),e.prototype.toJSON=function(){return{modelType:this.modelType,models:this.__models.map(getModelId).slice(),unique:this.unique}},Object.defineProperty(e.prototype,"snapshot",{get:function(){return this.toJSON()},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this,o=datxUtils.mapItems(e,function(e){return t.__collection.add(e,t.modelType)});return datxUtils.mapItems(o,function(e){t.unique&&-1!==t.__models.indexOf(e)||t.__models.push(e)}),o},e.prototype.hasItem=function(e){var t=getModelId(e);return Boolean(this.__models.find(function(e){return getModelId(e)===t}))},e.prototype.remove=function(e){var t=this.__getModel(e);t&&this.__models.remove(t)},e.prototype.removeAll=function(){this.__models.replace([])},e.prototype.__getModel=function(e){return e instanceof PureModel?e:this.__collection.findOne(this.modelType,getModelId(e))},e.prototype.__isIdentifier=function(e){return"string"==typeof e||"number"==typeof e},e.prototype.__reMap=function(){for(var e=0;e<this.__models.length;e++)if(this.__isIdentifier(this.__models[e])){var t=this.__getModel(this.__models[e]);t&&(this.__models[e]=t)}},e.prototype.__partialListUpdate=function(e){var t,o=this;if("splice"===e.type){if(this.sortMethod&&0<e.added.length)throw error(SORTED_NO_WRITE);var r=e.added,n=this.__models.slice(e.index,e.removedCount);return this.unique&&r.forEach(function(e){if(-1!==o.__models.indexOf(e)&&-1===n.indexOf(e))throw error(UNIQUE_MODEL)}),(t=this.__models).splice.apply(t,[e.index,e.removedCount].concat(r)),null}if(this.sortMethod&&e.newValue)throw error(SORTED_NO_WRITE);var i=this.__getModel(e.newValue);if(i){var a=this.__models.indexOf(i);if(this.unique&&-1!==a&&a!==e.index)throw error(UNIQUE_MODEL);this.__models[e.index]=i}return null},__decorate([mobx.observable],e.prototype,"sortMethod",void 0),__decorate([mobx.computed],e.prototype,"length",null),__decorate([mobx.computed],e.prototype,"list",null),__decorate([mobx.computed],e.prototype,"snapshot",null),__decorate([mobx.action],e.prototype,"add",null),__decorate([mobx.action],e.prototype,"remove",null),__decorate([mobx.action],e.prototype,"removeAll",null),__decorate([mobx.action],e.prototype,"__reMap",null),__decorate([mobx.action],e.prototype,"__partialListUpdate",null),e}(),PureCollection=function(){function e(e){var r=this;void 0===e&&(e=[]),this.__data=mobx.observable.array([],{deep:!1}),this.__views=[],this.__dataMap={},this.__dataList={},mobx.extendObservable(this,{}),e instanceof Array?this.insert(e):e&&"models"in e&&this.insert(e.models);var n=this.constructor,i=e&&"views"in e?e.views:{};Object.keys(n.views).forEach(function(e){var t=n.views[e],o=i[e]||t;r.addView(e,o.modelType,{mixins:t.mixins,models:o.models||[],sortMethod:t.sortMethod,unique:o.unique})})}return e.prototype.insert=function(e){var t=initModels(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.findOne=function(e,t){return t instanceof PureModel?t:this.__findOneByType(e,t)},e.prototype.find=function(e,t){return t instanceof PureModel?t:isSelectorFunction(e)?this.__data.find(e)||null:this.__findByType(e,t)||null},e.prototype.filter=function(e){return this.__data.filter(e)},e.prototype.findAll=function(e){var t;if(e){var o=getModelType(e);return o in this.__dataList||mobx.set(this.__dataList,((t={})[o]=mobx.observable.array([]),t)),this.__dataList[o]}return this.__data},e.prototype.hasItem=function(e){var t=getModelId(e);return Boolean(this.findOne(e,t))},e.prototype.removeOne=function(e,t){var o=null;"object"==typeof e?o=e:t&&(o=this.findOne(e,t)),o&&this.__removeModel(o)},e.prototype.remove=function(e,t){var o="object"==typeof e?e:this.find(e,t);o&&this.__removeModel(o)},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(){var t=this,o={};return this.__views.forEach(function(e){o[e]=t[e].toJSON()}),{models:this.__data.map(modelToJSON),views:o}},Object.defineProperty(e.prototype,"snapshot",{get:function(){return this.toJSON()},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.__data.forEach(function(e){setModelMetaKey(e,"collection",void 0),triggerAction({oldValue:modelToJSON(e),patchType:exports.PatchType.REMOVE},e)}),this.__data.replace([]),this.__dataList=mobx.observable({},{},{deep:!1}),this.__dataMap=mobx.observable({},{},{deep:!1})},e.prototype.getAllModels=function(){return this.__data.slice()},e.prototype.addView=function(e,t,o){var r=void 0===o?{}:o,n=r.sortMethod,i=r.models,a=void 0===i?[]:i,s=r.unique,d=r.mixins;if(e in this&&this[e])throw error(VIEW_NAME_TAKEN);var l=d?d.reduce(function(e,t){return t(e)},View):View;return this.__views.push(e),this[e]=new l(t,this,n,a,s),this[e]},e.prototype.__addArray=function(e,t){var o=this;return e.filter(Boolean).map(function(e){return o.__addSingle(e,t)})},e.prototype.__addSingle=function(e,t){if(!e||"number"==typeof e||"string"==typeof e)return e;if(e instanceof PureModel)return this.hasItem(e)||this.__insertModel(e),e;if(!t&&0!==t)throw error(UNDEFINED_TYPE);var o=getModelType(t),r=upsertModel(e,o,this);return this.__insertModel(r,o),r},e.prototype.__insertModel=function(e,t,o){var r,n=this;if(e instanceof Array)e.forEach(function(e){n.__insertModel(e,t,o)});else{var i=getModelCollection(e);if(i&&i!==this)throw error(MODEL_SINGLE_COLLECTION);var a=t||getModelType(e),s=o||getModelId(e),d=a.toString(),l=this.findOne(a,s);l?updateModel(l,e):(this.__data.push(e),a in this.__dataList?this.__dataList[a].push(e):mobx.set(this.__dataList,d,mobx.observable.array([e],{deep:!1})),a in this.__dataMap?mobx.set(this.__dataMap[a],s.toString(),e):mobx.set(this.__dataMap,d,mobx.observable.object(((r={})[s]=e,r),{},{deep:!1})),setModelMetaKey(e,"collection",this),triggerAction({newValue:modelToJSON(e),patchType:exports.PatchType.CRATE},e))}},e.prototype.__removeModel=function(e,t,o){var r=this;if(e instanceof Array)e.forEach(function(e){r.__removeModel(e,t,o)});else{var n=t||getModelType(e),i=o||getModelId(e);triggerAction({oldValue:mobx.toJS(modelToJSON(e)),patchType:exports.PatchType.REMOVE},e),this.__data.remove(e),this.__dataList[n].remove(e),mobx.set(this.__dataMap[n],i.toString(),void 0),this.__data.forEach(function(o){var r=getModelMetaKey(o,"refs");Object.keys(r||{}).forEach(function(e){if(getModelType(r[e].model)===n){var t=getRefId(o,e);t instanceof Array?t.includes(i)&&setRefId(o,e,t.filter(function(e){return e!==i})):t===i&&setRefId(o,e,void 0)}})}),setModelMetaKey(e,"collection",void 0)}},e.prototype.__findOneByType=function(e,t){var o,r=getModelType(e),n=r.toString();return r in this.__dataMap?t in this.__dataMap[r]||mobx.set(this.__dataMap[r],t.toString(),null):mobx.set(this.__dataMap,n,mobx.observable.object(((o={})[t]=null,o),{},{deep:!1})),this.__dataMap[r][t]||null},e.prototype.__findByType=function(e,t){var o;datxUtils.deprecated("\n 'find' method with the type/id combo and the 'remove' function are deprecated.\n Please use 'findOne' and 'removeOne' instead.\n They will always return the exact model or null if there is no match.\n ");var r=getModelType(e),n=r.toString();return t?(r in this.__dataMap?t in this.__dataMap[r]||mobx.set(this.__dataMap[r],t.toString(),void 0):mobx.set(this.__dataMap,n,mobx.observable.object(((o={})[t]=void 0,o),{},{deep:!1})),this.__dataMap[r][t]):(r in this.__dataList||mobx.set(this.__dataList,n,mobx.observable.array([],{deep:!1})),this.__dataList[r].length?this.__dataList[r][0]:null)},e.prototype.__changeModelId=function(e,t,o){this.__dataMap[o][t]=this.__dataMap[o][e],delete this.__dataMap[o][e]},e.types=[],e.views={},e.defaultModel=PureModel,__decorate([mobx.observable.shallow],e.prototype,"__dataMap",void 0),__decorate([mobx.observable.shallow],e.prototype,"__dataList",void 0),__decorate([mobx.action],e.prototype,"insert",null),__decorate([mobx.action],e.prototype,"add",null),__decorate([mobx.action],e.prototype,"removeOne",null),__decorate([mobx.action],e.prototype,"remove",null),__decorate([mobx.action],e.prototype,"removeAll",null),__decorate([mobx.computed],e.prototype,"length",null),__decorate([mobx.action],e.prototype,"reset",null),e}();function isOfType(e,t){for(var o=e;o;){if(o===t)return!0;o=Object.getPrototypeOf(o)}return!1}function isModel(e){return isOfType(e,PureModel)}function isCollection(e){return isOfType(e,PureCollection)}function isView(e){return isOfType(e,View)}function inversePatch(e){var t=reverseAction(e.patchType);return{model:e.model,newValue:e.oldValue,oldValue:e.newValue,patchType:t}}function withPatches(e){if(isCollection(e))return function(r){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=r.apply(this,e)||this;return o.__patchListeners=[],Object.defineProperty(o,"__patchListeners",{enumerable:!1}),o}return __extends(e,r),e.prototype.applyPatch=function(e){var t=this.findOne(e.model.type,e.model.id);if(e.patchType===exports.PatchType.REMOVE)t&&this.removeOne(t);else if(e.patchType===exports.PatchType.UPDATE){if(!t||!e.newValue)throw error(t?"New patch value isn't set for an update patch":"The model should already exist for an update patch");updateModel(t,e.newValue)}else{if(t)throw error("The model shouldn't exist before a create patch");if(!e.newValue)throw error("New patch value isn't set for a create patch");this.add(e.newValue,e.model.type)}},e.prototype.undoPatch=function(e){this.applyPatch(inversePatch(e))},e.prototype.onPatch=function(t){var e=this;return this.__patchListeners.push(t),function(){e.__patchListeners=e.__patchListeners.filter(function(e){return e!==t})}},e}(e);if(isModel(e))return function(r){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=r.apply(this,e)||this;return o.__patchListeners=[],Object.defineProperty(o,"__patchListeners",{enumerable:!1}),o}return __extends(e,r),e.prototype.applyPatch=function(e){e.model.type===getModelType(this)&&e.model.id===getModelId(this)&&updateModel(this,e.newValue||{})},e.prototype.undoPatch=function(e){this.applyPatch(inversePatch(e))},e.prototype.onPatch=function(t){var e=this;return this.__patchListeners.push(t),function(){e.__patchListeners=e.__patchListeners.filter(function(e){return e!==t})}},e}(e);throw error("Only Models and Collections can be decorated with patches")}function withActions(e){var t=e;if(!isModel(e))throw error(DECORATE_MODEL);return function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.update=function(e){updateModel(this,e)},t.prototype.clone=function(){return cloneModel(this)},t.prototype.assign=function(e,t){assignModel(this,e,t)},t.prototype.addReference=function(e,t,o){initModelRef(this,e,o,t)},t.prototype.toJSON=function(){return modelToJSON(this)},t}(t)}function withMeta(e){var t=e;if(!isModel(t))throw error(DECORATE_MODEL);var n=function(){function e(e){this.__instance=e}return Object.defineProperty(e.prototype,"collection",{get:function(){return getModelCollection(this.__instance)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return getModelId(this.__instance)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"original",{get:function(){return getModelMetaKey(this.__instance,"originalId")?getOriginalModel(this.__instance):void 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refs",{get:function(){var t=this,e=getModelMetaKey(this.__instance,"refs")||{},o={};return Object.keys(e).forEach(function(e){o[e]=getRefId(t.__instance,e)}),o},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"snapshot",{get:function(){return modelToJSON(this.__instance)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return getModelType(this.__instance)},enumerable:!0,configurable:!0}),__decorate([mobx.computed],e.prototype,"collection",null),__decorate([mobx.computed],e.prototype,"id",null),__decorate([mobx.computed],e.prototype,"original",null),__decorate([mobx.computed],e.prototype,"refs",null),__decorate([mobx.computed],e.prototype,"snapshot",null),__decorate([mobx.computed],e.prototype,"type",null),e}();return function(r){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=r.apply(this,e)||this;return o.meta=new n(o),Object.defineProperty(o,"meta",{enumerable:!1}),o}return __extends(e,r),e}(t)}var Model=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.valueOf=function(){var e=this.meta.snapshot;return delete e[datxUtils.META_FIELD],__assign({},e,{meta:{id:this.meta.id,type:this.meta.type}})},t.prototype.toString=function(){return JSON.stringify(this.valueOf(),null,2)},t}(withPatches(withActions(withMeta(PureModel)))),Collection=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.defaultModel=Model,t}(withPatches(PureCollection)),CompatModel=function(o){function e(e,t){var r=o.call(this,e,t)||this;return datxUtils.deprecated("CompatModel is just a migration tool. Please move to Model or PureModel as soon as possible."),Object.keys(r.static.refs).forEach(function(e){if(!(e in getModelMetaKey(r,"refs"))){var t=r.static.refs[e],o=datxUtils.mapItems(r[e]||r.static.defaults[e],getModelId);datxUtils.assignComputed(r,e),initModelRef(r,e,"object"==typeof t?{model:t.model,property:t.property,type:exports.ReferenceType.TO_ONE_OR_MANY}:{model:t,type:exports.ReferenceType.TO_ONE_OR_MANY},o)}}),Object.keys(r.static.defaults).forEach(function(e){e in r.static.refs||e in r||initModelField(r,e,r.static.defaults[e])}),r}return __extends(e,o),e.__datxInitProps=function(){this.idAttribute&&storage.setModelClassMetaKey(this,"id",this.idAttribute),this.typeAttribute&&storage.setModelClassMetaKey(this,"type",this.typeAttribute)},e.prototype.getRecordId=function(){return datxUtils.deprecated("model.getRecordId is deprecated. Use getModelId() instead."),getModelId(this)},e.prototype.getRecordType=function(){return datxUtils.deprecated("model.getRecordType is deprecated. Use getModelType() instead."),getModelType(this)},e.prototype.assign=function(e,t){datxUtils.deprecated("model.assign is deprecated. Use assignModel() instead.");var o=FieldType.DATA,r=storage.getModelClassMetaKey(this.static,"id"),n=storage.getModelClassMetaKey(this.static,"type");return e===r?o=FieldType.ID:e===n&&(o=FieldType.TYPE),updateField(this,e,t,o),t},e.prototype.assignRef=function(e,t,o){if(datxUtils.deprecated("model.assignRef is deprecated. Use initModelRef() instead."),getModelMetaKey(this,"refs")[e])return this[e]=t;var r=o;if(r||(t instanceof Array||mobx.isObservableArray(t)?r=t.reduce(function(e,t){return e||getModelType(t)},null):t instanceof PureModel&&(r=getModelType(t))),!r)throw new Error("The type property is missing");return initModelRef(this,e,{model:r,type:exports.ReferenceType.TO_ONE_OR_MANY},t),this[e]},e.prototype.update=function(e){var t=this;datxUtils.deprecated("model.update is deprecated. Use updateModel() instead.");var o=Object.assign({},e);return Object.keys(o).forEach(function(e){"function"==typeof t[e]&&delete o[e]}),updateModel(this,o)},Object.defineProperty(e.prototype,"static",{get:function(){return datxUtils.deprecated("model.static is deprecated."),this.constructor},enumerable:!0,configurable:!0}),e.prototype.toJS=function(){return datxUtils.deprecated("model.toJS() is deprecated. Use modelToJSON() instead."),modelToJSON(this)},Object.defineProperty(e.prototype,"snapshot",{get:function(){return datxUtils.deprecated("model.snapshot is deprecated. Use modelToJSON() instead."),modelToJSON(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"__collection",{get:function(){return datxUtils.deprecated("model.__collection is deprecated. Use getModelCollection() instead."),getModelCollection(this)},enumerable:!0,configurable:!0}),e.refs={},e.defaults={},e.idAttribute="id",e.typeAttribute="__type__",e}(PureModel),CompatCollection=function(t){function e(e){var o=t.call(this,e)||this;return datxUtils.deprecated("CompatCollection is just a migration tool. Please move to Collection as soon as possible."),o.static.types.forEach(function(e){var t=getModelType(e);datxUtils.assignComputed(o,t.toString(),function(){return o.findAll(t)})}),o}return __extends(e,t),Object.defineProperty(e.prototype,"static",{get:function(){return datxUtils.deprecated("collection.static is deprecated."),this.constructor},enumerable:!0,configurable:!0}),e.prototype.toJS=function(){return datxUtils.deprecated("collection.toJS() is deprecated. Use collection.toJSON() instead"),this.toJSON()},e.types=[CompatModel],e}(Collection);function getClass(e){return"function"==typeof e?e:e.constructor}function prepareDecorator(e,t,o){o&&"initializer"in o&&(o.initializer=void 0)}function propFn(e,t,o){prepareDecorator(e,t,o),storage.addModelDefaultField(getClass(e),t)}var prop=Object.assign(propFn,{defaultValue:function(r){return function(e,t,o){prepareDecorator(e,t,o),storage.addModelDefaultField(getClass(e),t,r)}},toOne:function(r){return function(e,t,o){prepareDecorator(e,t,o),storage.addModelClassReference(getClass(e),t,{model:r,type:exports.ReferenceType.TO_ONE})}},toMany:function(r,n){return function(e,t,o){prepareDecorator(e,t,o),storage.addModelClassReference(getClass(e),t,{model:r,property:n,type:exports.ReferenceType.TO_MANY})}},toOneOrMany:function(r){return function(e,t,o){prepareDecorator(e,t,o),storage.addModelClassReference(getClass(e),t,{model:r,type:exports.ReferenceType.TO_ONE_OR_MANY})}},identifier:function(e,t,o){prepareDecorator(e,t,o),storage.addModelDefaultField(getClass(e),t),storage.setModelClassMetaKey(getClass(e),"id",t)},type:function(e,t,o){prepareDecorator(e,t,o),storage.addModelDefaultField(getClass(e),t),storage.setModelClassMetaKey(getClass(e),"type",t)}});function view(r,n){return void 0===n&&(n={}),function(e,t,o){prepareDecorator(e,t,o),Object.hasOwnProperty.call(e.constructor,"views")||(e.constructor.views={}),e.constructor.views[t]=__assign({modelType:r},n)}}function setupModel(e,t){var o=void 0===t?{fields:{}}:t,r=o.fields,n=o.references,i=o.type,a=o.idAttribute,s=o.typeAttribute,d=e;if(!isModel(d))throw error(DECORATE_MODEL);var l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(d);return i&&(l.type=i),a&&prop.identifier(l.prototype,a),s&&prop.type(l.prototype,s),r&&Object.keys(r).forEach(function(e){prop.defaultValue(r[e])(l.prototype,e)}),n&&Object.keys(n).forEach(function(e){var t=n[e],o=t.model,r=t.property;switch(n[e].type){case exports.ReferenceType.TO_ONE:return void prop.toOne(o)(l.prototype,e);case exports.ReferenceType.TO_MANY:return void prop.toMany(o,r)(l.prototype,e);default:return void prop.toOneOrMany(o)(l.prototype,e)}}),l}exports.Collection=Collection,exports.CompatCollection=CompatCollection,exports.CompatModel=CompatModel,exports.Model=Model,exports.PureCollection=PureCollection,exports.PureModel=PureModel,exports.View=View,exports.assignModel=assignModel,exports.cloneModel=cloneModel,exports.getModelClassRefs=getModelClassRefs,exports.getModelCollection=getModelCollection,exports.getModelId=getModelId,exports.getModelMetaKey=getModelMetaKey,exports.getModelType=getModelType,exports.getOriginalModel=getOriginalModel,exports.getRefId=getRefId,exports.initModelRef=initModelRef,exports.isCollection=isCollection,exports.isModel=isModel,exports.isView=isView,exports.modelToJSON=modelToJSON,exports.prop=prop,exports.setModelMetaKey=setModelMetaKey,exports.setRefId=setRefId,exports.setupModel=setupModel,exports.updateModel=updateModel,exports.updateModelId=updateModelId,exports.view=view,exports.withActions=withActions,exports.withMeta=withMeta,exports.withPatches=withPatches;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var datxUtils=require("datx-utils"),mobx=require("mobx"),extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])})(e,t)};function __extends(e,t){function o(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __decorate(e,t,o,r){var n,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;0<=s;s--)(n=e[s])&&(a=(i<3?n(a):3<i?n(t,o,a):n(t,o))||a);return 3<i&&a&&Object.defineProperty(t,o,a),a}!function(e){e[e.CRATE=0]="CRATE",e[e.UPDATE=1]="UPDATE",e[e.REMOVE=2]="REMOVE"}(exports.PatchType||(exports.PatchType={}));var REGEX=/\$\{\s*([a-zA-Z0-9\-\_]+)\s*\}/g;function msg(e,t){for(var o=e,r=REGEX.exec(o);r;)o=o.replace(r[0],t[r[1]]),r=REGEX.exec(o);return o}function error(e,t){return void 0===t&&(t={}),new Error("[datx exception] "+msg(e,t))}var FieldType,UNDEFINED_TYPE="The type needs to be defined if the object is not an instance of the model.",UNDEFINED_MODEL="No model is defined for the type ${type}.",NOT_A_CLONE="The given model is not a clone.",REF_NEEDS_COLLECTION="The model needs to be in a collection to be referenceable",REF_SINGLE="The reference ${key} can't be an array of values.",REF_ARRAY="The reference ${key} must be an array of values.",NO_REFS="You should save this value as a reference.",BACK_REF_READ_ONLY="Back references are read only",ID_READONLY="Model ID can't be updated directly. Use the `updateModelId` helper function instead.",TYPE_READONLY="Model type can't be changed after initialization.",MODEL_SINGLE_COLLECTION="A model can be in a single collection at once",ID_REQUIRED="Model id is required (autoincrement is disabled)",WRONG_REF_TYPE="The new reference type doesn't match to the declared one.",MODEL_REQUIRED="The model type is a required parameter. Do you maybe have a circular dependency?",SORTED_NO_WRITE="New models can't be added directly to a sorted view list",UNIQUE_MODEL="The models in this view need to be unique",VIEW_NAME_TAKEN="The name is already taken",DECORATE_MODEL="This mixin can only decorate models";function reducePrototypeChain(e,t,o){for(var r=o,n=e;n;)r=t(r,n),n=Object.getPrototypeOf(n);return r}!function(e){e[e.ID=0]="ID",e[e.TYPE=1]="TYPE",e[e.DATA=2]="DATA"}(FieldType=FieldType||{}),function(e){e[e.TO_ONE=0]="TO_ONE",e[e.TO_MANY=1]="TO_MANY",e[e.TO_ONE_OR_MANY=2]="TO_ONE_OR_MANY"}(exports.ReferenceType||(exports.ReferenceType={}));var DATX_KEY=Symbol.for("datx metadata");function setMeta(e,t){Object.defineProperty(e,DATX_KEY,{enumerable:!1,value:t,writable:!1})}var DataStorage=function(){function e(){}return e.prototype.initModel=function(e){var t=mobx.observable({data:{},meta:{}});return setMeta(e,t),t},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,t){var o=this.__getModelData(e);mobx.set(o.data,t)},e.prototype.setModelDataKey=function(e,t,o){var r;this.setModelData(e,((r={})[t]=o,r))},e.prototype.getModelMeta=function(e){var t=e[DATX_KEY];return t?t.meta:this.setModelMeta(e,{})},e.prototype.getModelMetaKey=function(e,t){return this.getModelMeta(e)[t]},e.prototype.setModelMeta=function(e,t){var o=this.__getModelData(e);return mobx.set(o.meta,t),o.meta},e.prototype.setModelMetaKey=function(e,t,o){var r;this.setModelMeta(e,((r={})[t]=o,r))},e.prototype.setModelClassMetaKey=function(e,t,o){var r,n=e[DATX_KEY];n||setMeta(e,n={data:{},meta:{},references:{}}),Object.assign(n.meta,((r={})[t]=o,r))},e.prototype.getModelClassMetaKey=function(e,o){return reducePrototypeChain(e,function(e,t){return e||(t[DATX_KEY]||{meta:{}}).meta[o]||null},null)},e.prototype.addModelDefaultField=function(e,t,o){var r,n,i=e[DATX_KEY];i?Object.assign(i.data,((r={})[t]=o,r)):setMeta(e,{data:(n={},n[t]=o,n),meta:{},references:{}})},e.prototype.getModelDefaults=function(e){var t=reducePrototypeChain(e,function(e,t){return e.concat((t[DATX_KEY]||{data:[]}).data)},[]);return Object.assign.apply(Object,[{}].concat(t.reverse()))},e.prototype.addModelClassReference=function(e,t,o){var r,n;if(!o.model&&0!==o.model)throw error(MODEL_REQUIRED);var i=e[DATX_KEY];i?Object.assign(i.references,((r={})[t]=o,r)):setMeta(e,{data:{},meta:{},references:(n={},n[t]=o,n)})},e.prototype.getModelClassReferences=function(e){var t=reducePrototypeChain(e,function(e,t){return e.concat((t[DATX_KEY]||{references:{}}).references)},[]);return Object.assign.apply(Object,[{}].concat(t.reverse()))},e.prototype.getModelReferenceOptions=function(e,t){return this.getModelMetaKey(e,"refs")[t]},e.prototype.__getModelData=function(e){return e[DATX_KEY]||this.initModel(e)},e}(),storage=new DataStorage;function getModelType(e){return"function"==typeof e?e.type:"object"==typeof e?getModelMetaKey(e,"type")||e.constructor.type:e}function getModelId(e){return e instanceof PureModel?getModelMetaKey(e,"id"):e}function getModelCollection(e){return getModelMetaKey(e,"collection")}function cloneModel(e){var t=e.constructor,o=modelToJSON(e),r=o[datxUtils.META_FIELD]||{};r.originalId=r.id,delete r.id;var n=new t(o),i=getModelCollection(e);return i?i.add(n):datxUtils.warn("The model is not in the collection. Referencing the original model won't be possible"),n}function getOriginalModel(e){var t=getModelCollection(e),o=getModelMetaKey(e,"originalId");if(o){if(!t)throw error(REF_NEEDS_COLLECTION);return t.findOne(e,o)}throw error(NOT_A_CLONE)}var READ_ONLY_META=["fields","id","refs","type"];function updateModel(o,r){var e=storage.getModelClassMetaKey(o.constructor,"id")||"id",n=storage.getModelClassMetaKey(o.constructor,"type")||"type",t=Object.keys(r instanceof PureModel?modelToJSON(r):r);return mergeMeta(o,storage.getModelMeta(o),r[datxUtils.META_FIELD]),startAction(o),t.forEach(function(t){if(t!==datxUtils.META_FIELD&&t!==e&&t!==n)assignModel(o,t,r[t]);else if(t===datxUtils.META_FIELD){Object.keys(r[t]||{}).forEach(function(e){READ_ONLY_META.includes(e)||setModelMetaKey(o,e,r[t][e])})}}),endAction(o),o}function assignModel(e,t,o){if(!(e instanceof PureModel))throw error("The given parameter is not a valid model");var r=getModelMetaKey(e,"refs");if(!r)throw error("The given models is not initialized correctly");if(startAction(e),t in r)assignModelRef(e,t,o);else{if(o instanceof PureModel)throw endAction(e),error(NO_REFS,{key:t});assignModelField(e,t,o)}endAction(e)}function assignModelField(e,t,o){-1!==getModelMetaKey(e,"fields").indexOf(t)?e[t]=o:initModelField(e,t,o)}function assignModelRef(e,t,o){e[t]=o}function getMetaKeyFromRaw(e,t,o){if(datxUtils.META_FIELD in e&&"object"==typeof e[datxUtils.META_FIELD]&&void 0!==e[datxUtils.META_FIELD])return(e[datxUtils.META_FIELD]||{})[t];if(o){var r=storage.getModelClassMetaKey(o,t);return r&&e[r]}return e&&e[t]}function modelToJSON(e){var t,o=mobx.toJS(storage.getModelData(e)),r=Object.assign({},storage.getModelMeta(e));delete r.collection,delete r.patch;var n=mobx.toJS(r),i={};Object.keys(n.refs||{}).forEach(function(e){i[e]={model:getModelType(n.refs[e].model),type:n.refs[e].type}}),n.refs=i,delete n.collection;var a=Object.assign(o,((t={})[datxUtils.META_FIELD]=n,t)),s=e.constructor,d=storage.getModelClassMetaKey(s,"id"),l=storage.getModelClassMetaKey(s,"type");return n&&d&&(a[d]=n.id),n&&l&&(a[l]=n.type),a}function getModelMetaKey(e,t){return storage.getModelMetaKey(e,t)}function setModelMetaKey(e,t,o){storage.setModelMetaKey(e,t,o)}function getModelClassRefs(e){return storage.getModelClassReferences(e)}function isEmptyObject(e){return 0===Object.keys(e).length}function reverseAction(e){switch(e){case exports.PatchType.CRATE:return exports.PatchType.REMOVE;case exports.PatchType.REMOVE:return exports.PatchType.CRATE;default:return exports.PatchType.UPDATE}}function triggerAction(e,t){var o=__assign({},e,{model:{id:getModelId(t),type:getModelType(t)}}),r=[];"__patchListeners"in t&&r.push.apply(r,t.__patchListeners||[]);var n=getModelCollection(t);n&&"__patchListeners"in n&&r.push.apply(r,n.__patchListeners||[]),r.forEach(function(e){e(o)})}function startAction(e){var t=storage.getModelMetaKey(e,"patch")||{count:0,oldValue:{},newValue:{}};t.count++,storage.setModelMetaKey(e,"patch",t)}function updateAction(e,t,o){var r=storage.getModelMetaKey(e,"patch")||{count:0,oldValue:{},newValue:{}};e[t]!==o&&(t in r.oldValue||(r.oldValue[t]=e[t]),r.newValue[t]=o,storage.setModelMetaKey(e,"patch",r))}function endAction(e,t){void 0===t&&(t=exports.PatchType.UPDATE);var o=storage.getModelMetaKey(e,"patch")||{count:0,oldValue:{},newValue:{}};if(o.count--,0===o.count){var r=mobx.toJS(o.newValue),n=mobx.toJS(o.oldValue);isEmptyObject(r)&&isEmptyObject(n)||triggerAction({newValue:r,oldValue:n,patchType:t},e),storage.setModelMetaKey(e,"patch",{count:0,oldValue:{},newValue:{}})}else storage.setModelMetaKey(e,"patch",o)}function modelAddReference(e,t,o){var r=storage.getModelReferenceOptions(e,t),n=getModelId(o),i=storage.getModelDataKey(e,t);r.type===exports.ReferenceType.TO_ONE?storage.setModelDataKey(e,t,n):r.type===exports.ReferenceType.TO_MANY||mobx.isObservableArray(i)?i.push(n):storage.setModelDataKey(e,t,o)}function modelRemoveReference(e,t,o){var r=storage.getModelReferenceOptions(e,t),n=getModelId(o),i=storage.getModelDataKey(e,t);r.type===exports.ReferenceType.TO_ONE?storage.setModelDataKey(e,t,null):r.type===exports.ReferenceType.TO_MANY||mobx.isObservableArray(i)?i.remove(n):storage.setModelDataKey(e,t,null)}function ensureModel(o,r){return function(e){var t=e;if(!(e instanceof PureModel)&&"object"==typeof e){if(!r)throw error(REF_NEEDS_COLLECTION);t=r.add(e,o.model)}return getModelId(t)}}function partialRefUpdate(e,t,o){var r=storage.getModelReferenceOptions(e,t),n=storage.getModelDataKey(e,t),i=getModelCollection(e);if("splice"!==o.type)return n[o.index]=ensureModel(r,i)(o.newValue),null;var a=o.added.map(ensureModel(r,i));return n.splice.apply(n,[o.index,o.removedCount].concat(a)),null}function backRefSplice(t,e,o,r){var n=r.property;return o.added.forEach(function(e){modelAddReference(e,n,t)}),t[e].slice(o.index,o.index+o.removedCount).forEach(function(e){modelRemoveReference(e,n,t)}),null}function backRefChange(e,t,o,r){var n=r.property,i=e[t].length>o.index?e[t][o.index]:null;return o.newValue&&modelAddReference(o.newValue,n,e),i&&modelRemoveReference(i,n,e),datxUtils.warn("This shouldn't have happened. Please open an issue: https://github.com/infinum/datx/issues/new"),null}function partialBackRefUpdate(e,t,o){var r=storage.getModelReferenceOptions(e,t);return"splice"===o.type?backRefSplice(e,t,o,r):backRefChange(e,t,o,r)}function getField(e,t){return storage.getModelDataKey(e,t)}function updateField(e,t,o,r){if(r===FieldType.TYPE)throw error(TYPE_READONLY);if(r===FieldType.ID)throw error(ID_READONLY);startAction(e),t in getModelMetaKey(e,"refs")?updateRef(e,t,o):(updateAction(e,t,o),storage.setModelDataKey(e,t,o)),endAction(e)}function hasBackRef(e,t,o){return null!==e[t]&&void 0!==e[t]&&(e[t]instanceof PureModel?e[t]===o:-1!==e[t].indexOf(o))}function getBackRef(t,o,r){var e=getModelType(r.model),n=getModelCollection(t);if(!n)return null;var i=n.findAll(e).filter(function(e){return hasBackRef(e,r.property,t)}),a=mobx.observable.array(i,{deep:!1});return mobx.intercept(a,function(e){return partialBackRefUpdate(t,o,e)}),a}function getNormalRef(t,o,r){var e=storage.getModelDataKey(t,o),n=getModelCollection(t);if(!n)return null;var i=datxUtils.mapItems(e,function(e){return e?n.findOne(r.model,e):e});if(r.type!==exports.ReferenceType.TO_MANY||i instanceof Array||(i=[i]),i instanceof Array){var a=mobx.observable.array(i,{deep:!1});return mobx.intercept(a,function(e){return partialRefUpdate(t,o,e)}),a}return i}function getRef(e,t){var o=storage.getModelReferenceOptions(e,t);return"string"==typeof o.property?getBackRef(e,t,o):getNormalRef(e,t,o)}function validateRef(e,t,o){if(e.type===exports.ReferenceType.TO_ONE&&t)throw error(REF_SINGLE,{key:o});if(e.type===exports.ReferenceType.TO_MANY&&!t)throw error(REF_ARRAY,{key:o});if(e.property)throw error(BACK_REF_READ_ONLY)}function updateRef(o,e,t){var r=storage.getModelReferenceOptions(o,e),n=r.type===exports.ReferenceType.TO_MANY?t||[]:t,i=n instanceof Array||mobx.isObservableArray(n);validateRef(r,i,e);var a=getModelCollection(o);startAction(o);var s=datxUtils.mapItems(t,function(e){if(e&&a){if(e instanceof PureModel)if(getModelType(e)!==getModelType(r.model))throw endAction(o),error(WRONG_REF_TYPE);var t=a.findOne(r.model,e);return t||"object"!=typeof e||(t=a.add(e,r.model)),endAction(o),getModelId(t||e)}if(e instanceof PureModel)throw endAction(o),error(REF_NEEDS_COLLECTION);return e});r.type===exports.ReferenceType.TO_MANY&&(s=s||[]),updateAction(o,e,s),storage.setModelDataKey(o,e,s),endAction(o)}function getModelRefsByType(e,t){var o=getModelMetaKey(e,"refs");return Object.keys(o).filter(function(e){return!o[e].property}).filter(function(e){return getModelType(o[e].model)===t})}function updateModelReferences(e,n,i,t){var o=getModelCollection(e);o&&o.getAllModels().map(function(r){getModelRefsByType(r,t).forEach(function(e){var t=storage.getModelDataKey(r,e);if(t instanceof Array||mobx.isObservableArray(t)){var o=t.indexOf(i);-1!==o&&(t[o]=n)}else t===i&&storage.setModelDataKey(r,e,n)})})}function updateModelId(e,t){var o=getModelCollection(e),r=getModelId(e),n=getModelType(e);setModelMetaKey(e,"id",t);var i=e.constructor,a=storage.getModelClassMetaKey(i,"id");a&&setRefId(e,a,t),o&&o.__changeModelId(r,t,n),updateModelReferences(e,t,r,n)}function getRefId(e,t){return storage.getModelDataKey(e,t)}function setRefId(e,t,o){storage.setModelDataKey(e,t,o)}function initModelField(t,o,e,r){void 0===r&&(r=FieldType.DATA);var n=getModelMetaKey(t,"fields");r===FieldType.ID&&o in t&&storage.setModelDataKey(t,o,void 0),storage.setModelDataKey(t,o,e),updateAction(t,o,e),-1===n.indexOf(o)&&n.push(o),datxUtils.assignComputed(t,o,function(){return getField(t,o)},function(e){updateField(t,o,e,r)})}function initModelRef(t,o,e,r){var n=(getModelMetaKey(t,"refs")[o]=e).type===exports.ReferenceType.TO_MANY;storage.setModelDataKey(t,o,n?[]:void 0),updateAction(t,o,n?[]:void 0),datxUtils.assignComputed(t,o,function(){return getRef(t,o)},function(e){updateRef(t,o,e)}),e.property||void 0===r||(t[o]=r)}function prepareFields(e,t,o){var r=o.constructor,n=t.fields?t.fields.slice():[],i=storage.getModelClassReferences(r),a=Object.assign({},i,t.refs),s=storage.getModelDefaults(r);return Object.keys(e).concat(Object.keys(s)).forEach(function(e){e in a||-1!==n.indexOf(e)||n.push(e)}),{defaults:s,fields:n,refs:a}}function initModelData(n,i,r,a){var e=prepareFields(i,r,n),s=e.defaults,t=e.fields,d=e.refs,o=n.constructor,l=storage.getModelClassMetaKey(o,"id"),c=storage.getModelClassMetaKey(o,"type");t.forEach(function(e){var t=FieldType.DATA,o=i[e];void 0===o&&(o=s[e]),e===(l||"id")?(t=FieldType.ID,o=r.id):e===c&&(t=FieldType.TYPE,o=r.type),initModelField(n,e,o,t)}),!l||l in t||initModelField(n,l,r.id,FieldType.ID),Object.keys(d).forEach(function(e){var t=d[e],o=i[e]||s[e]||void 0,r=a?a.add(o,getModelType(t.model)):o;initModelRef(n,e,t,r)})}function initModelMeta(e,t,o){var r=e.constructor,n=storage.getModelClassMetaKey(r,"id")||"id",i=storage.getModelClassMetaKey(r,"type"),a=datxUtils.META_FIELD in t&&t[datxUtils.META_FIELD]||{},s=i&&t[i]||a.type||getModelType(e),d=n&&t[n]||a.id;if(!d){if(!r.enableAutoId)throw new Error(ID_REQUIRED);for(d=r.getAutoId();o&&o.findOne(s,d);)d=r.getAutoId()}var l={fields:[],id:d,refs:{},type:s},c=datxUtils.META_FIELD in t&&t[datxUtils.META_FIELD]?mergeMeta(e,l,t[datxUtils.META_FIELD]):storage.setModelMeta(e,l);return delete t[datxUtils.META_FIELD],Object.assign({},c)}function mergeMeta(e,t,o){var r;void 0===o&&(o={});var n={fields:[],refs:{}};n.fields=o.fields,(r=t.fields).push.apply(r,o.fields||[]),n.refs=o.refs,Object.assign(t.refs,o.refs||{});var i=["fields","refs","type","id"];Object.keys(o).forEach(function(e){-1===i.indexOf(e)&&(t[e]=o[e])});var a=storage.setModelMeta(e,t);return Object.assign({},a,n)}function initModel(e,t,o){var r=e.constructor,n=Object.assign({},r.preprocess(t,o));setModelMetaKey(e,"collection",o),initModelData(e,n,initModelMeta(e,n,o),o)}var PureModel=function(){function e(e,t){void 0===e&&(e={});var o=this.constructor;o.__datxInitProps&&o.__datxInitProps(),startAction(this),mobx.extendObservable(this,{}),initModel(this,e,t),endAction(this,exports.PatchType.CRATE)}return e.preprocess=function(e,t){return e},e.getAutoId=function(){return"number"==typeof this.autoIdValue?--this.autoIdValue:this.autoIdValue},e.toJSON=function(){return this.type},e.type=datxUtils.DEFAULT_TYPE,e.autoIdValue=0,e.enableAutoId=!0,e}();function initCollectionModel(e,t){return upsertModel(t,getMetaKeyFromRaw(t,"type"),e)}function upsertModel(e,t,o){var r;if(!t&&0!==t)throw error(UNDEFINED_TYPE);var n=o.constructor,i=n.types.find(function(e){return e.type===t});if(!i){var a=n.defaultModel;if(a)return new a(__assign({},e,((r={})[datxUtils.META_FIELD]=__assign({},e[datxUtils.META_FIELD]||{},{type:t}),r)),o);throw error(UNDEFINED_MODEL,{type:t})}var s=getMetaKeyFromRaw(e,"id",i),d=s&&o.findOne(t,s);return d?updateModel(d,e):new i(e,o)}function isSelectorFunction(e){return"function"==typeof e&&e!==PureModel&&!(e.prototype instanceof PureModel)}function initModels(t,e){return e.map(function(e){return initCollectionModel(t,e)})}var View=function(){function e(e,t,o,r,n){var i=this;void 0===r&&(r=[]),void 0===n&&(n=!1),this.__collection=t,this.unique=n,this.__models=mobx.observable.array([]),this.modelType=getModelType(e);var a=datxUtils.mapItems(r,function(e){return i.__getModel(e)||e}).filter(Boolean);this.__models.replace(a),this.sortMethod=o,mobx.reaction(function(){return 0<i.__models.filter(function(e){return i.__isIdentifier(e)}).filter(function(e){return i.__collection.findOne(i.modelType,e)}).length},this.__reMap.bind(this))}return Object.defineProperty(e.prototype,"length",{get:function(){return this.list.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"list",{get:function(){var t=this,e=this.__models.filter(function(e){return!t.__isIdentifier(e)}).filter(Boolean);if(this.sortMethod){var o="string"==typeof this.sortMethod?function(e){return e[t.sortMethod]}:this.sortMethod;e.sort(function(e,t){return o(e)-o(t)})}var r=mobx.observable.array(e,{deep:!1});return mobx.intercept(r,this.__partialListUpdate.bind(this)),r},enumerable:!0,configurable:!0}),e.prototype.toJSON=function(){return{modelType:this.modelType,models:this.__models.map(getModelId).slice(),unique:this.unique}},Object.defineProperty(e.prototype,"snapshot",{get:function(){return this.toJSON()},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this,o=datxUtils.mapItems(e,function(e){return t.__collection.add(e,t.modelType)});return datxUtils.mapItems(o,function(e){t.unique&&-1!==t.__models.indexOf(e)||t.__models.push(e)}),o},e.prototype.hasItem=function(e){var t=getModelId(e);return Boolean(this.__models.find(function(e){return getModelId(e)===t}))},e.prototype.remove=function(e){var t=this.__getModel(e);t&&this.__models.remove(t)},e.prototype.removeAll=function(){this.__models.replace([])},e.prototype.__getModel=function(e){return e instanceof PureModel?e:this.__collection.findOne(this.modelType,getModelId(e))},e.prototype.__isIdentifier=function(e){return"string"==typeof e||"number"==typeof e},e.prototype.__reMap=function(){for(var e=0;e<this.__models.length;e++)if(this.__isIdentifier(this.__models[e])){var t=this.__getModel(this.__models[e]);t&&(this.__models[e]=t)}},e.prototype.__partialListUpdate=function(e){var t,o=this;if("splice"===e.type){if(this.sortMethod&&0<e.added.length)throw error(SORTED_NO_WRITE);var r=e.added,n=this.__models.slice(e.index,e.removedCount);return this.unique&&r.forEach(function(e){if(-1!==o.__models.indexOf(e)&&-1===n.indexOf(e))throw error(UNIQUE_MODEL)}),(t=this.__models).splice.apply(t,[e.index,e.removedCount].concat(r)),null}if(this.sortMethod&&e.newValue)throw error(SORTED_NO_WRITE);var i=this.__getModel(e.newValue);if(i){var a=this.__models.indexOf(i);if(this.unique&&-1!==a&&a!==e.index)throw error(UNIQUE_MODEL);this.__models[e.index]=i}return null},__decorate([mobx.observable],e.prototype,"sortMethod",void 0),__decorate([mobx.computed],e.prototype,"length",null),__decorate([mobx.computed],e.prototype,"list",null),__decorate([mobx.computed],e.prototype,"snapshot",null),__decorate([mobx.action],e.prototype,"add",null),__decorate([mobx.action],e.prototype,"remove",null),__decorate([mobx.action],e.prototype,"removeAll",null),__decorate([mobx.action],e.prototype,"__reMap",null),__decorate([mobx.action],e.prototype,"__partialListUpdate",null),e}(),PureCollection=function(){function e(e){var r=this;void 0===e&&(e=[]),this.__data=mobx.observable.array([],{deep:!1}),this.__views=[],this.__dataMap={},this.__dataList={},mobx.extendObservable(this,{}),e instanceof Array?this.insert(e):e&&"models"in e&&this.insert(e.models);var n=this.constructor,i=e&&"views"in e?e.views:{};Object.keys(n.views).forEach(function(e){var t=n.views[e],o=i[e]||t;r.addView(e,o.modelType,{mixins:t.mixins,models:o.models||[],sortMethod:t.sortMethod,unique:o.unique})})}return e.prototype.insert=function(e){var t=initModels(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.findOne=function(e,t){return t instanceof PureModel?t:this.__findOneByType(e,t)},e.prototype.find=function(e,t){return t instanceof PureModel?t:isSelectorFunction(e)?this.__data.find(e)||null:this.__findByType(e,t)||null},e.prototype.filter=function(e){return this.__data.filter(e)},e.prototype.findAll=function(e){var t;if(e){var o=getModelType(e);return o in this.__dataList||mobx.set(this.__dataList,((t={})[o]=mobx.observable.array([]),t)),this.__dataList[o]}return this.__data},e.prototype.hasItem=function(e){var t=getModelId(e);return Boolean(this.findOne(e,t))},e.prototype.removeOne=function(e,t){var o=null;"object"==typeof e?o=e:t&&(o=this.findOne(e,t)),o&&this.__removeModel(o)},e.prototype.remove=function(e,t){var o="object"==typeof e?e:this.find(e,t);o&&this.__removeModel(o)},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(){var t=this,o={};return this.__views.forEach(function(e){o[e]=t[e].toJSON()}),{models:this.__data.map(modelToJSON),views:o}},Object.defineProperty(e.prototype,"snapshot",{get:function(){return this.toJSON()},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.__data.forEach(function(e){setModelMetaKey(e,"collection",void 0),triggerAction({oldValue:modelToJSON(e),patchType:exports.PatchType.REMOVE},e)}),this.__data.replace([]),this.__dataList=mobx.observable({},{},{deep:!1}),this.__dataMap=mobx.observable({},{},{deep:!1})},e.prototype.getAllModels=function(){return this.__data.slice()},e.prototype.addView=function(e,t,o){var r=void 0===o?{}:o,n=r.sortMethod,i=r.models,a=void 0===i?[]:i,s=r.unique,d=r.mixins;if(e in this&&this[e])throw error(VIEW_NAME_TAKEN);var l=d?d.reduce(function(e,t){return t(e)},View):View;return this.__views.push(e),this[e]=new l(t,this,n,a,s),this[e]},e.prototype.__addArray=function(e,t){var o=this;return e.filter(Boolean).map(function(e){return o.__addSingle(e,t)})},e.prototype.__addSingle=function(e,t){if(!e||"number"==typeof e||"string"==typeof e)return e;if(e instanceof PureModel)return this.hasItem(e)||this.__insertModel(e),e;if(!t&&0!==t)throw error(UNDEFINED_TYPE);var o=getModelType(t),r=upsertModel(e,o,this);return this.__insertModel(r,o),r},e.prototype.__insertModel=function(e,t,o){var r,n=this;if(e instanceof Array)e.forEach(function(e){n.__insertModel(e,t,o)});else{var i=getModelCollection(e);if(i&&i!==this)throw error(MODEL_SINGLE_COLLECTION);var a=t||getModelType(e),s=o||getModelId(e),d=a.toString(),l=this.findOne(a,s);l?updateModel(l,e):(this.__data.push(e),a in this.__dataList?this.__dataList[a].push(e):mobx.set(this.__dataList,d,mobx.observable.array([e],{deep:!1})),a in this.__dataMap?mobx.set(this.__dataMap[a],s.toString(),e):mobx.set(this.__dataMap,d,mobx.observable.object(((r={})[s]=e,r),{},{deep:!1})),setModelMetaKey(e,"collection",this),triggerAction({newValue:modelToJSON(e),patchType:exports.PatchType.CRATE},e))}},e.prototype.__removeModel=function(e,t,o){var r=this;if(e instanceof Array)e.forEach(function(e){r.__removeModel(e,t,o)});else{var n=t||getModelType(e),i=o||getModelId(e);triggerAction({oldValue:mobx.toJS(modelToJSON(e)),patchType:exports.PatchType.REMOVE},e),this.__data.remove(e),this.__dataList[n].remove(e),mobx.set(this.__dataMap[n],i.toString(),void 0),this.__data.forEach(function(o){var r=getModelMetaKey(o,"refs");Object.keys(r||{}).forEach(function(e){if(getModelType(r[e].model)===n){var t=getRefId(o,e);t instanceof Array?t.includes(i)&&setRefId(o,e,t.filter(function(e){return e!==i})):t===i&&setRefId(o,e,void 0)}})}),setModelMetaKey(e,"collection",void 0)}},e.prototype.__findOneByType=function(e,t){var o,r=getModelType(e),n=r.toString();return r in this.__dataMap?t in this.__dataMap[r]||mobx.set(this.__dataMap[r],t.toString(),null):mobx.set(this.__dataMap,n,mobx.observable.object(((o={})[t]=null,o),{},{deep:!1})),this.__dataMap[r][t]||null},e.prototype.__findByType=function(e,t){var o;datxUtils.deprecated("\n 'find' method with the type/id combo and the 'remove' function are deprecated.\n Please use 'findOne' and 'removeOne' instead.\n They will always return the exact model or null if there is no match.\n ");var r=getModelType(e),n=r.toString();return t?(r in this.__dataMap?t in this.__dataMap[r]||mobx.set(this.__dataMap[r],t.toString(),void 0):mobx.set(this.__dataMap,n,mobx.observable.object(((o={})[t]=void 0,o),{},{deep:!1})),this.__dataMap[r][t]):(r in this.__dataList||mobx.set(this.__dataList,n,mobx.observable.array([],{deep:!1})),this.__dataList[r].length?this.__dataList[r][0]:null)},e.prototype.__changeModelId=function(e,t,o){this.__dataMap[o][t]=this.__dataMap[o][e],delete this.__dataMap[o][e]},e.types=[],e.views={},e.defaultModel=PureModel,__decorate([mobx.observable.shallow],e.prototype,"__dataMap",void 0),__decorate([mobx.observable.shallow],e.prototype,"__dataList",void 0),__decorate([mobx.action],e.prototype,"insert",null),__decorate([mobx.action],e.prototype,"add",null),__decorate([mobx.action],e.prototype,"removeOne",null),__decorate([mobx.action],e.prototype,"remove",null),__decorate([mobx.action],e.prototype,"removeAll",null),__decorate([mobx.computed],e.prototype,"length",null),__decorate([mobx.action],e.prototype,"reset",null),e}();function isOfType(e,t){for(var o=e;o;){if(o===t)return!0;o=Object.getPrototypeOf(o)}return!1}function isModel(e){return isOfType(e,PureModel)}function isCollection(e){return isOfType(e,PureCollection)}function isView(e){return isOfType(e,View)}function inversePatch(e){var t=reverseAction(e.patchType);return{model:e.model,newValue:e.oldValue,oldValue:e.newValue,patchType:t}}function withPatches(e){var r,n;if(isCollection(e))return __extends(o,n=e),o.prototype.applyPatch=function(e){var t=this.findOne(e.model.type,e.model.id);if(e.patchType===exports.PatchType.REMOVE)t&&this.removeOne(t);else if(e.patchType===exports.PatchType.UPDATE){if(!t||!e.newValue)throw error(t?"New patch value isn't set for an update patch":"The model should already exist for an update patch");updateModel(t,e.newValue)}else{if(t)throw error("The model shouldn't exist before a create patch");if(!e.newValue)throw error("New patch value isn't set for a create patch");this.add(e.newValue,e.model.type)}},o.prototype.undoPatch=function(e){this.applyPatch(inversePatch(e))},o.prototype.onPatch=function(t){var e=this;return this.__patchListeners.push(t),function(){e.__patchListeners=e.__patchListeners.filter(function(e){return e!==t})}},o;if(isModel(e))return __extends(t,r=e),t.prototype.applyPatch=function(e){e.model.type===getModelType(this)&&e.model.id===getModelId(this)&&updateModel(this,e.newValue||{})},t.prototype.undoPatch=function(e){this.applyPatch(inversePatch(e))},t.prototype.onPatch=function(t){var e=this;return this.__patchListeners.push(t),function(){e.__patchListeners=e.__patchListeners.filter(function(e){return e!==t})}},t;function t(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=r.apply(this,e)||this;return o.__patchListeners=[],Object.defineProperty(o,"__patchListeners",{enumerable:!1}),o}function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=n.apply(this,e)||this;return o.__patchListeners=[],Object.defineProperty(o,"__patchListeners",{enumerable:!1}),o}throw error("Only Models and Collections can be decorated with patches")}function withActions(e){var t,o=e;if(!isModel(e))throw error(DECORATE_MODEL);function r(){return null!==t&&t.apply(this,arguments)||this}return __extends(r,t=o),r.prototype.update=function(e){updateModel(this,e)},r.prototype.clone=function(){return cloneModel(this)},r.prototype.assign=function(e,t){assignModel(this,e,t)},r.prototype.addReference=function(e,t,o){initModelRef(this,e,o,t)},r.prototype.toJSON=function(){return modelToJSON(this)},r}function withMeta(e){var t=e;if(!isModel(t))throw error(DECORATE_MODEL);var r,n=(Object.defineProperty(o.prototype,"collection",{get:function(){return getModelCollection(this.__instance)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"id",{get:function(){return getModelId(this.__instance)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"original",{get:function(){return getModelMetaKey(this.__instance,"originalId")?getOriginalModel(this.__instance):void 0},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"refs",{get:function(){var t=this,e=getModelMetaKey(this.__instance,"refs")||{},o={};return Object.keys(e).forEach(function(e){o[e]=getRefId(t.__instance,e)}),o},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"snapshot",{get:function(){return modelToJSON(this.__instance)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"type",{get:function(){return getModelType(this.__instance)},enumerable:!0,configurable:!0}),__decorate([mobx.computed],o.prototype,"collection",null),__decorate([mobx.computed],o.prototype,"id",null),__decorate([mobx.computed],o.prototype,"original",null),__decorate([mobx.computed],o.prototype,"refs",null),__decorate([mobx.computed],o.prototype,"snapshot",null),__decorate([mobx.computed],o.prototype,"type",null),o);function o(e){this.__instance=e}function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=r.apply(this,e)||this;return o.meta=new n(o),Object.defineProperty(o,"meta",{enumerable:!1}),o}return __extends(i,r=t),i}var Model=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.valueOf=function(){var e=this.meta.snapshot;return delete e[datxUtils.META_FIELD],__assign({},e,{meta:{id:this.meta.id,type:this.meta.type}})},t.prototype.toString=function(){return JSON.stringify(this.valueOf(),null,2)},t}(withPatches(withActions(withMeta(PureModel)))),Collection=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.defaultModel=Model,t}(withPatches(PureCollection)),CompatModel=function(o){function e(e,t){var r=o.call(this,e,t)||this;return datxUtils.deprecated("CompatModel is just a migration tool. Please move to Model or PureModel as soon as possible."),Object.keys(r.static.refs).forEach(function(e){if(!(e in getModelMetaKey(r,"refs"))){var t=r.static.refs[e],o=datxUtils.mapItems(r[e]||r.static.defaults[e],getModelId);datxUtils.assignComputed(r,e),initModelRef(r,e,"object"==typeof t?{model:t.model,property:t.property,type:exports.ReferenceType.TO_ONE_OR_MANY}:{model:t,type:exports.ReferenceType.TO_ONE_OR_MANY},o)}}),Object.keys(r.static.defaults).forEach(function(e){e in r.static.refs||e in r||initModelField(r,e,r.static.defaults[e])}),r}return __extends(e,o),e.__datxInitProps=function(){this.idAttribute&&storage.setModelClassMetaKey(this,"id",this.idAttribute),this.typeAttribute&&storage.setModelClassMetaKey(this,"type",this.typeAttribute)},e.prototype.getRecordId=function(){return datxUtils.deprecated("model.getRecordId is deprecated. Use getModelId() instead."),getModelId(this)},e.prototype.getRecordType=function(){return datxUtils.deprecated("model.getRecordType is deprecated. Use getModelType() instead."),getModelType(this)},e.prototype.assign=function(e,t){datxUtils.deprecated("model.assign is deprecated. Use assignModel() instead.");var o=FieldType.DATA,r=storage.getModelClassMetaKey(this.static,"id"),n=storage.getModelClassMetaKey(this.static,"type");return e===r?o=FieldType.ID:e===n&&(o=FieldType.TYPE),updateField(this,e,t,o),t},e.prototype.assignRef=function(e,t,o){if(datxUtils.deprecated("model.assignRef is deprecated. Use initModelRef() instead."),getModelMetaKey(this,"refs")[e])return this[e]=t;var r=o;if(r||(t instanceof Array||mobx.isObservableArray(t)?r=t.reduce(function(e,t){return e||getModelType(t)},null):t instanceof PureModel&&(r=getModelType(t))),!r)throw new Error("The type property is missing");return initModelRef(this,e,{model:r,type:exports.ReferenceType.TO_ONE_OR_MANY},t),this[e]},e.prototype.update=function(e){var t=this;datxUtils.deprecated("model.update is deprecated. Use updateModel() instead.");var o=Object.assign({},e);return Object.keys(o).forEach(function(e){"function"==typeof t[e]&&delete o[e]}),updateModel(this,o)},Object.defineProperty(e.prototype,"static",{get:function(){return datxUtils.deprecated("model.static is deprecated."),this.constructor},enumerable:!0,configurable:!0}),e.prototype.toJS=function(){return datxUtils.deprecated("model.toJS() is deprecated. Use modelToJSON() instead."),modelToJSON(this)},Object.defineProperty(e.prototype,"snapshot",{get:function(){return datxUtils.deprecated("model.snapshot is deprecated. Use modelToJSON() instead."),modelToJSON(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"__collection",{get:function(){return datxUtils.deprecated("model.__collection is deprecated. Use getModelCollection() instead."),getModelCollection(this)},enumerable:!0,configurable:!0}),e.refs={},e.defaults={},e.idAttribute="id",e.typeAttribute="__type__",e}(PureModel),CompatCollection=function(t){function e(e){var o=t.call(this,e)||this;return datxUtils.deprecated("CompatCollection is just a migration tool. Please move to Collection as soon as possible."),o.static.types.forEach(function(e){var t=getModelType(e);datxUtils.assignComputed(o,t.toString(),function(){return o.findAll(t)})}),o}return __extends(e,t),Object.defineProperty(e.prototype,"static",{get:function(){return datxUtils.deprecated("collection.static is deprecated."),this.constructor},enumerable:!0,configurable:!0}),e.prototype.toJS=function(){return datxUtils.deprecated("collection.toJS() is deprecated. Use collection.toJSON() instead"),this.toJSON()},e.types=[CompatModel],e}(Collection);function getClass(e){return"function"==typeof e?e:e.constructor}function prepareDecorator(e,t,o){o&&"initializer"in o&&(o.initializer=void 0)}function propFn(e,t,o){prepareDecorator(e,t,o),storage.addModelDefaultField(getClass(e),t)}var prop=Object.assign(propFn,{defaultValue:function(r){return function(e,t,o){prepareDecorator(e,t,o),storage.addModelDefaultField(getClass(e),t,r)}},toOne:function(r){return function(e,t,o){prepareDecorator(e,t,o),storage.addModelClassReference(getClass(e),t,{model:r,type:exports.ReferenceType.TO_ONE})}},toMany:function(r,n){return function(e,t,o){prepareDecorator(e,t,o),storage.addModelClassReference(getClass(e),t,{model:r,property:n,type:exports.ReferenceType.TO_MANY})}},toOneOrMany:function(r){return function(e,t,o){prepareDecorator(e,t,o),storage.addModelClassReference(getClass(e),t,{model:r,type:exports.ReferenceType.TO_ONE_OR_MANY})}},identifier:function(e,t,o){prepareDecorator(e,t,o),storage.addModelDefaultField(getClass(e),t),storage.setModelClassMetaKey(getClass(e),"id",t)},type:function(e,t,o){prepareDecorator(e,t,o),storage.addModelDefaultField(getClass(e),t),storage.setModelClassMetaKey(getClass(e),"type",t)}});function view(r,n){return void 0===n&&(n={}),function(e,t,o){prepareDecorator(e,t,o),Object.hasOwnProperty.call(e.constructor,"views")||(e.constructor.views={}),e.constructor.views[t]=__assign({modelType:r},n)}}function setupModel(e,t){var o=void 0===t?{fields:{}}:t,r=o.fields,n=o.references,i=o.type,a=o.idAttribute,s=o.typeAttribute,d=e;if(!isModel(d))throw error(DECORATE_MODEL);var l,c=(__extends(p,l=d),p);function p(){return null!==l&&l.apply(this,arguments)||this}return i&&(c.type=i),a&&prop.identifier(c.prototype,a),s&&prop.type(c.prototype,s),r&&Object.keys(r).forEach(function(e){prop.defaultValue(r[e])(c.prototype,e)}),n&&Object.keys(n).forEach(function(e){var t=n[e],o=t.model,r=t.property;switch(n[e].type){case exports.ReferenceType.TO_ONE:return void prop.toOne(o)(c.prototype,e);case exports.ReferenceType.TO_MANY:return void prop.toMany(o,r)(c.prototype,e);default:return void prop.toOneOrMany(o)(c.prototype,e)}}),c}exports.Collection=Collection,exports.CompatCollection=CompatCollection,exports.CompatModel=CompatModel,exports.Model=Model,exports.PureCollection=PureCollection,exports.PureModel=PureModel,exports.View=View,exports.assignModel=assignModel,exports.cloneModel=cloneModel,exports.getModelClassRefs=getModelClassRefs,exports.getModelCollection=getModelCollection,exports.getModelId=getModelId,exports.getModelMetaKey=getModelMetaKey,exports.getModelType=getModelType,exports.getOriginalModel=getOriginalModel,exports.getRefId=getRefId,exports.initModelRef=initModelRef,exports.isCollection=isCollection,exports.isModel=isModel,exports.isView=isView,exports.modelToJSON=modelToJSON,exports.prop=prop,exports.setModelMetaKey=setModelMetaKey,exports.setRefId=setRefId,exports.setupModel=setupModel,exports.updateModel=updateModel,exports.updateModelId=updateModelId,exports.view=view,exports.withActions=withActions,exports.withMeta=withMeta,exports.withPatches=withPatches;
{
"name": "datx",
"version": "1.0.1",
"version": "1.0.2",
"description": "A MobX data store",

@@ -21,10 +21,10 @@ "main": "dist/index.cjs.js",

"@infinumjs/tslint-config": "^2.0.0-beta.6",
"@types/jest": "^24.0.11",
"@types/node": "^11.13.4",
"@types/jest": "^25.1.0",
"@types/node": "^14.0.0",
"jest": "^24.7.1",
"mobx": "^5.9.4",
"rollup": "^1.10.0",
"rollup-plugin-typescript2": "^0.20.1",
"rollup": "^2.0.0",
"rollup-plugin-typescript2": "^0.24.0",
"rollup-plugin-uglify": "^6.0.2",
"ts-jest": "^24.0.2",
"ts-jest": "^26.0.0",
"tslint": "^5.15.0",

@@ -66,5 +66,4 @@ "typescript": "^3.4.3"

"dependencies": {
"datx-utils": "^1.0.0"
},
"gitHead": "0ebef5a20cbee03b60cafb9746901b9aa3fec7e6"
"datx-utils": "^1.0.2"
}
}
# datx
[![Greenkeeper badge](https://badges.greenkeeper.io/infinum/datx.svg)](https://greenkeeper.io/)
DatX is an opinionated data store for use with the [MobX](https://mobx.js.org/) state management library. It features support for simple observable property definition, references to other models and first-class TypeScript support.

@@ -41,9 +43,10 @@

```
* [Installation](https://github.com/infinum/datx/wiki/Installation)
* [Defining models](https://github.com/infinum/datx/wiki/Defining-models)
* [References](https://github.com/infinum/datx/wiki/References)
* [Configuring the collection](https://github.com/infinum/datx/wiki/Configuring-the-collection)
* [Using the collection](https://github.com/infinum/datx/wiki/Using-the-collection)
* [Persisting data locally](https://github.com/infinum/datx/wiki/Persisting-data-locally)
* [Installation](https://datx.dev/docs/getting-started/installation)
* [Defining models](https://datx.dev/docs/getting-started/defining-models)
* [References](https://datx.dev/docs/getting-started/references)
* [Configuring the collection](https://datx.dev/docs/getting-started/configuring-the-collection)
* [Using the collection](https://datx.dev/docs/getting-started/using-the-collection)
* [Persisting data locally](https://datx.dev/docs/getting-started/persisting-data-locally)
### Polyfilling

@@ -57,11 +60,11 @@

[How to add the polyfills](https://github.com/infinum/datx/wiki/Troubleshooting#the-library-doesnt-work-in-internet-explorer-11).
[How to add the polyfills](https://datx.dev/docs/troubleshooting/known-issues#the-library-doesnt-work-in-internet-explorer-11).
## Concepts
The library contains two main classes - [`Model`](https://github.com/infinum/datx/wiki/Model) and [`Collection`](https://github.com/infinum/datx/wiki/Collection).
The library contains two main classes - [`Model`](https://datx.dev/docs/api-reference/model) and [`Collection`](https://datx.dev/docs/api-reference/collection).
A collection contains models of any kind (they should however be listed in the `types` property), while a model can be in a single collection (but doesn't need to be in any).
Models also include some useful [methods](https://github.com/infinum/datx/wiki/withActions) and [properties](https://github.com/infinum/datx/wiki/withMeta), but if they're in collision with your data/logic, you can use a [`PureModel`](https://github.com/infinum/datx/wiki/PureModel) class.
Models also include some useful [methods](https://datx.dev/docs/mixins/with-actions) and [properties](https://datx.dev/docs/mixins/with-meta), but if they're in collision with your data/logic, you can use a [`PureModel`](https://datx.dev/docs/api-reference/pure-model) class.

@@ -71,27 +74,27 @@ ## Mixins

Mixins are additional plugins that can enhance the regular models and collections. Available mixins:
* [`withActions`](https://github.com/infinum/datx/wiki/withActions) (model) - Adds some helper methods to the model - already included in the `Model` class, but not in the `PureModel` class
* [`withMeta`](https://github.com/infinum/datx/wiki/withMeta) (model) - Adds some helpful meta data to the model - already included in the `Model` class, but not in the `PureModel` class
* [`withPatches`](https://github.com/infinum/datx/wiki/withPatches) (model, collection) - Adds patch support to models and collections
* [`datx-jsonapi`](https://github.com/infinum/datx/wiki/Mixin-JSONAPI) (model, collection and view) - Adds the [JSON API](https://jsonapi.org/) features to the model, collection and view
* [`withActions`](https://datx.dev/docs/mixins/with-actions) (model) - Adds some helper methods to the model - already included in the `Model` class, but not in the `PureModel` class
* [`withMeta`](https://datx.dev/docs/mixins/with-meta) (model) - Adds some helpful meta data to the model - already included in the `Model` class, but not in the `PureModel` class
* [`withPatches`](https://datx.dev/docs/mixins/with-patches) (model, collection) - Adds patch support to models and collections
* [`datx-jsonapi`](https://datx.dev/docs/mixins/jsonapi-mixin) (model, collection and view) - Adds the [JSON API](https://jsonapi.org/) features to the model, collection and view
To check out what are the planed future mixins, check out [the issues](https://github.com/infinum/datx/labels/mixins).
Want to make your own mixin? Check out [the guide](https://github.com/infinum/datx/wiki/Building-your-own-mixin).
Want to make your own mixin? Check out [the guide](https://datx.dev/docs/mixins/building-your-own-mixin).
## API reference
* [Collection](https://github.com/infinum/datx/wiki/Collection)
* [Model](https://github.com/infinum/datx/wiki/Model)
* [View](https://github.com/infinum/datx/wiki/View)
* [prop](https://github.com/infinum/datx/wiki/prop)
* [PureModel](https://github.com/infinum/datx/wiki/PureModel)
* [CompatModel](https://github.com/infinum/datx/wiki/CompatModel)
* [CompatCollection](https://github.com/infinum/datx/wiki/CompatCollection)
* [Model utils](https://github.com/infinum/datx/wiki/Model-utils)
* [Lib utils](https://github.com/infinum/datx/wiki/Lib-utils)
* [TypeScript interfaces](https://github.com/infinum/datx/wiki/Interfaces)
* [Collection](https://datx.dev/docs/api-reference/collection)
* [Model](https://datx.dev/docs/api-reference/model)
* [View](https://datx.dev/docs/api-reference/view)
* [prop](https://datx.dev/docs/api-reference/prop)
* [PureModel](https://datx.dev/docs/api-reference/pure-model)
* [CompatModel](https://datx.dev/docs/migration-guide/compat-model)
* [CompatCollection](https://datx.dev/docs/migration-guide/compat-collection)
* [Model utils](https://datx.dev/docs/api-reference/model-utils)
* [Lib utils](https://datx.dev/docs/api-reference/lib-utils)
* [TypeScript interfaces](https://datx.dev/docs/api-reference/typescript-interfaces)
## Troubleshooting
Having issues with the library? Check out the [troubleshooting](https://github.com/infinum/datx/wiki/Troubleshooting) page or [open](https://github.com/infinum/datx/issues/new) an issue.
Having issues with the library? Check out the [troubleshooting](https://datx.dev/docs/troubleshooting/known-issues) page or [open](https://github.com/infinum/datx/issues/new) an issue.

@@ -102,7 +105,7 @@ ***

Package | npm version | dependency status | dev dependency status
--------|-------------|-------------------|----------------------
datx | [![npm version](https://badge.fury.io/js/datx.svg)](https://badge.fury.io/js/datx) | [![Dependency Status](https://david-dm.org/infinum/datx.svg?path=packages/datx)](https://david-dm.org/infinum/datx?path=packages/datx) | [![devDependency Status](https://david-dm.org/infinum/datx/dev-status.svg?path=packages/datx)](https://david-dm.org/infinum/datx?path=packages/datx#info=devDependencies)
datx-jsonapi | [![npm version](https://badge.fury.io/js/datx-jsonapi.svg)](https://badge.fury.io/js/datx-jsonapi) | [![Dependency Status](https://david-dm.org/infinum/datx.svg?path=packages/datx-jsonapi)](https://david-dm.org/infinum/datx?path=packages/datx-jsonapi) | [![devDependency Status](https://david-dm.org/infinum/datx/dev-status.svg?path=packages/datx-jsonapi)](https://david-dm.org/infinum/datx?path=packages/datx-jsonapi#info=devDependencies)
datx-utils | [![npm version](https://badge.fury.io/js/datx-utils.svg)](https://badge.fury.io/js/datx-utils) | [![Dependency Status](https://david-dm.org/infinum/datx.svg?path=packages/datx-utils)](https://david-dm.org/infinum/datx?path=packages/datx-utils) | [![devDependency Status](https://david-dm.org/infinum/datx/dev-status.svg?path=packages/datx-utils)](https://david-dm.org/infinum/datx?path=packages/datx-utils#info=devDependencies)
| Package | npm version | dependency status | dev dependency status |
| ------------ | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| datx | [![npm version](https://badge.fury.io/js/datx.svg)](https://badge.fury.io/js/datx) | [![Dependency Status](https://david-dm.org/infinum/datx.svg?path=packages/datx)](https://david-dm.org/infinum/datx?path=packages/datx) | [![devDependency Status](https://david-dm.org/infinum/datx/dev-status.svg?path=packages/datx)](https://david-dm.org/infinum/datx?path=packages/datx#info=devDependencies) |
| datx-jsonapi | [![npm version](https://badge.fury.io/js/datx-jsonapi.svg)](https://badge.fury.io/js/datx-jsonapi) | [![Dependency Status](https://david-dm.org/infinum/datx.svg?path=packages/datx-jsonapi)](https://david-dm.org/infinum/datx?path=packages/datx-jsonapi) | [![devDependency Status](https://david-dm.org/infinum/datx/dev-status.svg?path=packages/datx-jsonapi)](https://david-dm.org/infinum/datx?path=packages/datx-jsonapi#info=devDependencies) |
| datx-utils | [![npm version](https://badge.fury.io/js/datx-utils.svg)](https://badge.fury.io/js/datx-utils) | [![Dependency Status](https://david-dm.org/infinum/datx.svg?path=packages/datx-utils)](https://david-dm.org/infinum/datx?path=packages/datx-utils) | [![devDependency Status](https://david-dm.org/infinum/datx/dev-status.svg?path=packages/datx-utils)](https://david-dm.org/infinum/datx?path=packages/datx-utils#info=devDependencies) |

@@ -109,0 +112,0 @@ ## License

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc