├── .gitignore ├── README.md ├── dist ├── filters.d.ts ├── index.d.ts ├── index.js ├── index.js.map └── models.d.ts ├── example ├── app.vue ├── index.js └── models │ ├── book.js │ ├── index.js │ └── user.js ├── nodemon.json ├── package.json ├── src ├── filters.ts ├── index.ts └── models.ts ├── tsconfig.json ├── tslint.json ├── vue.config.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode 3 | node_modules 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![NPM Version](https://badge.fury.io/js/vue-rawmodel.svg)](https://badge.fury.io/js/vue-rawmodel) [![Dependency Status](https://gemnasium.com/xpepermint/vue-rawmodel.svg)](https://gemnasium.com/xpepermint/vue-rawmodel) 2 | 3 | # [vue](https://vuejs.org)-[rawmodel](https://github.com/xpepermint/rawmodeljs) 4 | 5 | > RawModel.js plugin for Vue.js v2. Form validation has never been easier! 6 | 7 | This plugin integrates [RawModel.js](https://github.com/xpepermint/rawmodeljs) framework into your [Vue.js](https://vuejs.org) application. 8 | 9 | [RawModel.js](https://github.com/xpepermint/rawmodeljs) is a simple framework which provides a strongly-typed JavaScript object with support for validation and error handling. It has a rich API which significantly simplifies **server-side** and **client-side** data validation and manipulation. Because it's an unopinionated framework it flawlessly integrates with popular modules like [vuex](http://vuex.vuejs.org/en/index.html), [apollo-client](http://dev.apollodata.com) and other related libraries. 10 | 11 | [RawModel.js](https://github.com/xpepermint/rawmodeljs) together with [Vue.js](https://vuejs.org) represents a web framework on steroids. Thanks to its powerful and flexible model objects, a form validation has never been easier. This plugin brings even more elegant way to do form validation using `RawModel.js` and still leaves you freedom to customize and fine-tune the integration. 12 | 13 | Make sure you check [RawModel.js API](https://github.com/xpepermint/rawmodeljs) page for details about the framework. 14 | 15 | This is a light weight open source package for [Vue.js](https://vuejs.org) written with TypeScript. It's actively maintained and ready for production environments. The source code is available on [GitHub](https://github.com/xpepermint/vue-rawmodel) where you can also find our [issue tracker](https://github.com/xpepermint/vue-rawmodel/issues). 16 | 17 | ## Related Projects 18 | 19 | * [RawModel.js](https://github.com/xpepermint/rawmodeljs): Strongly-typed JavaScript object with support for validation and error handling. 20 | 21 | ## Installation 22 | 23 | Run the command below to install the package. 24 | 25 | ``` 26 | $ npm install --save vue-rawmodel rawmodel 27 | ``` 28 | 29 | This package uses promises thus you need to use [Promise polyfill](https://github.com/taylorhakes/promise-polyfill) when promises are not supported. 30 | 31 | When used with a module system, you must explicitly install `vue-rawmodel` via `Vue.use()`. 32 | 33 | ```js 34 | import Vue from 'vue'; 35 | import VueRawModel from 'vue-rawmodel'; 36 | 37 | Vue.use(VueRawModel); 38 | ``` 39 | 40 | ## Getting Started 41 | 42 | This package provides a special class called `ReactiveModel` which extends from `Model` class provided by [RawModel.js](https://github.com/xpepermint/rawmodeljs). You don't need to attach the plugin to Vue. ReactiveModel is completely independent thus you can use it directly. Below is an example of a simple reactive model called `User` with a single field `name`. 43 | 44 | ```js 45 | import {ReactiveModel} from 'vue-rawmodel'; 46 | 47 | class User extends ReactiveModel { 48 | constructor (data = {}) { 49 | super(data); // initializing parent class 50 | 51 | this.defineField('name', { // defining class property `name` 52 | type: 'String', // setting type casting 53 | validate: [ // field validations 54 | { // validator recipe 55 | validator: 'presence', // validator name 56 | message: 'is required' // validator error message 57 | } 58 | ] 59 | // check the API for all available options 60 | }); 61 | } 62 | } 63 | ``` 64 | 65 | We can optionally pass models to the root `Vue` instance as the `models` option. This will populate the `$models` property which is then injected into every child component. 66 | 67 | ```js 68 | const app = new Vue({ 69 | models: { User }, // [optional] injecting models into child components (later available as this.$models.User) 70 | ... 71 | }); 72 | ``` 73 | 74 | ## Form Example 75 | 76 | Object validation has been one of the incentives for creating [RawModel.js](https://github.com/xpepermint/rawmodeljs) framework. This plugin brings even more elegant way to do form validation. 77 | 78 | ```html 79 | 90 | 91 | 109 | ``` 110 | 111 | Use the `$populate()` method to reactively apply data to your model. 112 | 113 | ```js 114 | export default { 115 | ... 116 | created () { 117 | this.user.$populate({ 118 | name: 'John Smith' 119 | }); 120 | } 121 | } 122 | ``` 123 | 124 | Use Vue watchers to install real-time form validation. 125 | 126 | ```js 127 | export default { 128 | ... 129 | watch: { 130 | user: { 131 | handler: (user) => user.$validate({debounce: 300}), // reactively validate fields and display errors 132 | deep: true, // always required 133 | immediate: true // set this to validate immediately after the form is created 134 | } 135 | } 136 | } 137 | ``` 138 | 139 | Check the [RawModel.js API](https://github.com/xpepermint/rawmodeljs#api) page and this [package API section](#api) for details. 140 | 141 | ## API 142 | 143 | This plugin extends [RawModel.js](https://github.com/xpepermint/rawmodeljs) functionality, which help us write reactive code in Vue. If you don't need reactivity then you can use [RawModel.js](https://github.com/xpepermint/rawmodeljs) directly. 144 | 145 | ### ReactiveModel 146 | 147 | **ReactiveModel({vm, dataKey, parent, ...data})** 148 | 149 | > Abstract reactive class which represents a strongly-typed JavaScript object. This class extends from [Model](https://github.com/xpepermint/rawmodeljs#model-class) and adds new reactive capabilities. 150 | 151 | | Option | Type | Required | Default | Description 152 | |--------|------|----------|---------|------------ 153 | | vm | Vue | No | - | Vue VM instance. 154 | | dataKey | String | No | - | The name of the data key. 155 | | parent | Model | No | - | Parent model instance. 156 | | data | Object | No | - | Data for populating model fields. 157 | 158 | 159 | **ReactiveModel.prototype.$applyErrors(errors)**: ReactiveModel 160 | 161 | > A reactive alternative of method `applyErrors()` which deeply populates fields with the provided `errors` (useful for loading validation errors received from the server). 162 | 163 | | Option | Type | Required | Default | Description 164 | |--------|------|----------|---------|------------ 165 | | errors | Array | No | [] | An array of errors. 166 | 167 | **ReactiveModel.prototype.$clear()**: ReactiveModel 168 | 169 | > Reactive alternative of method `clear()` which sets all fileds to `null`. 170 | 171 | **ReactiveModel.prototype.$fake()**: ReactiveModel 172 | 173 | > Reactive alternative of method `fake()` which resets fields then sets fields to their fake values. 174 | 175 | **ReactiveModel.prototype.$forceUpdate ()**: ReactiveModel 176 | 177 | > Force the `vm` instance to re-render. 178 | 179 | **ReactiveModel.prototype.$handle (error, {quiet, debounce})**: Promise 180 | 181 | > Reactive alternative of method `handle()` which handles the error and throws an error if the error can not be handled. 182 | 183 | | Option | Type | Required | Default | Description 184 | |--------|------|----------|---------|------------ 185 | | error | Any | Yes | - | Error to be handled. 186 | | quiet | Boolean | No | true | When set to false, a handled validation error is thrown. This doesn't affect the unhandled errors (they are always thrown). 187 | | debounce | Boolean | 0 | - | Number of milliseconds to wait before running validations. 188 | 189 | **ReactiveModel.prototype.$invalidate ()**: ReactiveModel 190 | 191 | > Reactive alternative of method `invalidate()` which removes fields errors. 192 | 193 | **ReactiveModel.prototype.isReactive (): Boolean** 194 | 195 | > Returns `true` when reactive properties (`vm` and `dataKey`) are set. 196 | 197 | **ReactiveModel.prototype.$populate (data)**: ReactiveModel 198 | 199 | > Reactive alternative of method `populate()` which applies data to a model. 200 | 201 | | Option | Type | Required | Default | Description 202 | |--------|------|----------|---------|------------ 203 | | data | Object | Yes | - | Data object. 204 | 205 | **ReactiveModel.prototype.$rebuild ()**: ReactiveModel 206 | 207 | > Rebuilds model's reactivity system. 208 | 209 | **ReactiveModel.prototype.$reset ()**: ReactiveModel 210 | 211 | > Reactive alternative of method `reset()` which sets each model field to its default value. 212 | 213 | **ReactiveModel.prototype.$rollback ()**: ReactiveModel 214 | 215 | > Reactive alternative of method `rollback()` which sets each field to its initial value (value before last commit). 216 | 217 | **ReactiveModel.prototype.$validate({quiet, debounce})**: Promise(ReactiveModel) 218 | 219 | > Reactive alternative of method `validate()` which validates the model fields and throws a validation error if not all fields are valid unless the `quiet` is set to true. 220 | 221 | | Option | Type | Required | Default | Description 222 | |--------|------|----------|---------|------------ 223 | | quiet | Boolean | No | true | When set to `true`, a validation error is thrown. 224 | | debounce | Boolean | 0 | - | Number of milliseconds to wait before running validations. 225 | 226 | ### Filters 227 | 228 | **firstMessage** 229 | 230 | > Extracts the first error message from a list of errors. 231 | 232 | ## Example 233 | 234 | An example is available in the `./example` folder which you can run with the `npm run example` command. There is also [vue-example](https://github.com/xpepermint/vue-example) app available which you should take a look. 235 | 236 | ## Tutorials 237 | 238 | See [vue-js-cheatsheet](https://www.gitbook.com/book/xpepermint/vue-js-cheatsheet/) for more. 239 | 240 | ## License (MIT) 241 | 242 | ``` 243 | Copyright (c) 2016 Kristijan Sedlak 244 | 245 | Permission is hereby granted, free of charge, to any person obtaining a copy 246 | of this software and associated documentation files (the "Software"), to deal 247 | in the Software without restriction, including without limitation the rights 248 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 249 | copies of the Software, and to permit persons to whom the Software is 250 | furnished to do so, subject to the following conditions: 251 | 252 | The above copyright notice and this permission notice shall be included in 253 | all copies or substantial portions of the Software. 254 | 255 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 256 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 257 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 258 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 259 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 260 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 261 | THE SOFTWARE. 262 | ``` 263 | -------------------------------------------------------------------------------- /dist/filters.d.ts: -------------------------------------------------------------------------------- 1 | export declare function firstMessage(errors: any): any; 2 | -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | import { ReactiveModel } from './models'; 2 | export { ReactiveModel }; 3 | export default class VueRawModel { 4 | static install(Vue: any, options?: {}): void; 5 | } 6 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["src/indexTs"]=e():t["src/indexTs"]=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=106)}([function(t,e,r){"use strict";function n(t){return"undefined"==typeof t||void 0===t}function i(t){return null===t}function o(t){return t===1/0}function u(t){return!(n(t)||i(t)||s(t)&&isNaN(t)||o(t))}function a(t){return"string"==typeof t}function c(t){return"boolean"==typeof t}function s(t){return"number"==typeof t}function f(t){return!!s(t)&&t%1===0}function l(t){return s(t)&&isFinite(t)}function p(t){return!n(t)&&!i(t)&&t.constructor===Date&&f(t.getTime())}function h(t){return!n(t)&&!i(t)&&t.constructor===Object}function v(t){return Array.isArray(t)}function d(t){return n(t)||i(t)||s(t)&&isNaN(t)||a(t)&&""===t||v(t)&&0===t.length||h(t)&&0===Object.keys(t).length}function y(t){return!d(t)}function _(t){return"function"==typeof t}function b(t){return _(t)}function g(t){return y(t)&&t.constructor&&"Promise"===t.constructor.name}function m(t){return a(t)?t:n(t)||i(t)?null:m(t.toString())}function w(t){return c(t)?t:n(t)||i(t)?null:parseFloat(t)>0||o(t)||"1"===t||"true"===t||"yes"===t||"+"===t}function x(t){if(f(t))return t;if(n(t)||i(t))return null;if(l(t))return parseInt(t);var e=parseInt(t);return f(e)?e:w(t)?1:0}function j(t){if(l(t))return t;if(n(t)||i(t))return null;var e=parseFloat(t);return l(e)?e:w(t)?1:0}function O(t){return j(t)}function F(t){var e=p(t)?t:new Date(t),r=e.getTime(),n=y(t)&&f(r);return n?e:null}function E(t){return v(t)?t:n(t)||i(t)?null:u(t)?[t]:[]}function A(t,e){if(n(t)||i(t))return null;if(v(e))return E(t).map(function(t){return A(t,e[0])});if(_(e))return e(t);if(a(e)){var r={Any:function(e){return t},String:m,Boolean:w,Integer:x,Float:j,Number:O,Date:F}[e];if(r)return r(t);throw new Error("Unknown type "+name)}return t}e.isUndefined=n,e.isNull=i,e.isInfinite=o,e.isValue=u,e.isString=a,e.isBoolean=c,e.isNumber=s,e.isInteger=f,e.isFloat=l,e.isDate=p,e.isObject=h,e.isArray=v,e.isAbsent=d,e.isPresent=y,e.isFunction=_,e.isClass=b,e.isPromise=g,e.toString=m,e.toBoolean=w,e.toInteger=x,e.toFloat=j,e.toNumber=O,e.toDate=F,e.toArray=E,e.cast=A},function(t,e,r){var n=r(29)("wks"),i=r(32),o=r(2).Symbol,u="function"==typeof o,a=t.exports=function(t){return n[t]||(n[t]=u&&o[t]||(u?o:i)("Symbol."+t))};a.store=n},function(t,e){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,e,r){var n=r(11);t.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},function(t,e,r){var n=r(12),i=r(28);t.exports=r(6)?function(t,e,r){return n.f(t,e,i(1,r))}:function(t,e,r){return t[e]=r,t}},function(t,e){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,e,r){t.exports=!r(24)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports={}},function(t,e){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,e,r){var n=r(13);t.exports=function(t,e,r){if(n(t),void 0===e)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,i){return t.call(e,r,n,i)}}return function(){return t.apply(e,arguments)}}},function(t,e){var r={}.hasOwnProperty;t.exports=function(t,e){return r.call(t,e)}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,r){var n=r(3),i=r(50),o=r(71),u=Object.defineProperty;e.f=r(6)?Object.defineProperty:function(t,e,r){if(n(t),e=o(e,!0),n(r),i)try{return u(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[e]=r.value),t}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,r){var n=r(11),i=r(2).document,o=n(i)&&n(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,e,r){var n=r(12).f,i=r(10),o=r(1)("toStringTag");t.exports=function(t,e,r){t&&!i(t=r?t:t.prototype,o)&&n(t,o,{configurable:!0,value:e})}},function(t,e,r){var n=r(29)("keys"),i=r(32);t.exports=function(t){return n[t]||(n[t]=i(t))}},function(t,e){var r=Math.ceil,n=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?n:r)(t)}},function(t,e,r){var n=r(52),i=r(14);t.exports=function(t){return n(i(t))}},function(t,e,r){(function(t,r){function n(t,e){return t.set(e[0],e[1]),t}function i(t,e){return t.add(e),t}function o(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function u(t,e){for(var r=-1,n=t?t.length:0;++r-1}function A(t,e){var r=this.__data__,n=q(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}function k(t){var e=-1,r=t?t.length:0;for(this.clear();++e1?r[i-1]:void 0,u=i>2?r[2]:void 0;for(o=t.length>3&&"function"==typeof o?(i--,o):void 0,u&&wt(r[0],r[1],u)&&(o=i<3?void 0:o,i=1),e=Object(e);++n-1&&t%1==0&&t-1&&t%1==0&&t<=qt}function Mt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return!!t&&"object"==typeof t}function Ut(t){if(!Nt(t)||Ce.call(t)!=Yt||p(t))return!1;var e=He(t);if(null===e)return!0;var r=Ve.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ie.call(r)==ze}function Tt(t){return lt(t,Vt(t))}function It(t){return Pt(t)?C(t):Q(t)}function Vt(t){return Pt(t)?C(t,!0):X(t)}function zt(){return[]}function Ct(){return!1}var Lt=200,Rt="__lodash_hash_undefined__",qt=9007199254740991,Bt="[object Arguments]",Ht="[object Array]",Gt="[object Boolean]",Wt="[object Date]",Kt="[object Error]",Jt="[object Function]",Zt="[object GeneratorFunction]",Qt="[object Map]",Xt="[object Number]",Yt="[object Object]",te="[object Promise]",ee="[object RegExp]",re="[object Set]",ne="[object String]",ie="[object Symbol]",oe="[object WeakMap]",ue="[object ArrayBuffer]",ae="[object DataView]",ce="[object Float32Array]",se="[object Float64Array]",fe="[object Int8Array]",le="[object Int16Array]",pe="[object Int32Array]",he="[object Uint8Array]",ve="[object Uint8ClampedArray]",de="[object Uint16Array]",ye="[object Uint32Array]",_e=/[\\^$.*+?()[\]{}|]/g,be=/\w*$/,ge=/^\[object .+?Constructor\]$/,me=/^(?:0|[1-9]\d*)$/,we={};we[ce]=we[se]=we[fe]=we[le]=we[pe]=we[he]=we[ve]=we[de]=we[ye]=!0,we[Bt]=we[Ht]=we[ue]=we[Gt]=we[ae]=we[Wt]=we[Kt]=we[Jt]=we[Qt]=we[Xt]=we[Yt]=we[ee]=we[re]=we[ne]=we[oe]=!1;var xe={};xe[Bt]=xe[Ht]=xe[ue]=xe[ae]=xe[Gt]=xe[Wt]=xe[ce]=xe[se]=xe[fe]=xe[le]=xe[pe]=xe[Qt]=xe[Xt]=xe[Yt]=xe[ee]=xe[re]=xe[ne]=xe[ie]=xe[he]=xe[ve]=xe[de]=xe[ye]=!0,xe[Kt]=xe[Jt]=xe[oe]=!1;var je="object"==typeof t&&t&&t.Object===Object&&t,Oe="object"==typeof self&&self&&self.Object===Object&&self,Fe=je||Oe||Function("return this")(),Ee="object"==typeof e&&e&&!e.nodeType&&e,Ae=Ee&&"object"==typeof r&&r&&!r.nodeType&&r,ke=Ae&&Ae.exports===Ee,Pe=ke&&je.process,Se=function(){try{return Pe&&Pe.binding("util")}catch(t){}}(),$e=Se&&Se.isTypedArray,De=Array.prototype,Me=Function.prototype,Ne=Object.prototype,Ue=Fe["__core-js_shared__"],Te=function(){var t=/[^.]+$/.exec(Ue&&Ue.keys&&Ue.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Ie=Me.toString,Ve=Ne.hasOwnProperty,ze=Ie.call(Object),Ce=Ne.toString,Le=RegExp("^"+Ie.call(Ve).replace(_e,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Re=ke?Fe.Buffer:void 0,qe=Fe.Symbol,Be=Fe.Uint8Array,He=v(Object.getPrototypeOf,Object),Ge=Object.create,We=Ne.propertyIsEnumerable,Ke=De.splice,Je=Object.getOwnPropertySymbols,Ze=Re?Re.isBuffer:void 0,Qe=v(Object.keys,Object),Xe=Math.max,Ye=yt(Fe,"DataView"),tr=yt(Fe,"Map"),er=yt(Fe,"Promise"),rr=yt(Fe,"Set"),nr=yt(Fe,"WeakMap"),ir=yt(Object,"create"),or=Et(Ye),ur=Et(tr),ar=Et(er),cr=Et(rr),sr=Et(nr),fr=qe?qe.prototype:void 0,lr=fr?fr.valueOf:void 0;y.prototype.clear=_,y.prototype.delete=b,y.prototype.get=g,y.prototype.has=m,y.prototype.set=w,x.prototype.clear=j,x.prototype.delete=O,x.prototype.get=F,x.prototype.has=E,x.prototype.set=A,k.prototype.clear=P,k.prototype.delete=S,k.prototype.get=$,k.prototype.has=D,k.prototype.set=M,N.prototype.clear=U,N.prototype.delete=T,N.prototype.get=I,N.prototype.has=V,N.prototype.set=z;var pr=Je?v(Je,Object):zt,hr=K;(Ye&&hr(new Ye(new ArrayBuffer(1)))!=ae||tr&&hr(new tr)!=Qt||er&&hr(er.resolve())!=te||rr&&hr(new rr)!=re||nr&&hr(new nr)!=oe)&&(hr=function(t){var e=Ce.call(t),r=e==Yt?t.constructor:void 0,n=r?Et(r):void 0;if(n)switch(n){case or:return ae;case ur:return Qt;case ar:return te;case cr:return re;case sr:return oe}return e});var vr=Array.isArray,dr=Ze||Ct,yr=$e?f($e):Z,_r=ht(function(t,e,r){Y(t,e,r)});r.exports=_r}).call(e,r(41),r(42)(t))},function(t,e,r){var n=r(8),i=r(1)("toStringTag"),o="Arguments"==n(function(){return arguments}()),u=function(t,e){try{return t[e]}catch(t){}};t.exports=function(t){var e,r,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=u(e=Object(t),i))?r:o?n(e):"Object"==(a=n(e))&&"function"==typeof e.callee?"Arguments":a}},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e,r){var n=r(2),i=r(5),o=r(9),u=r(4),a="prototype",c=function(t,e,r){var s,f,l,p=t&c.F,h=t&c.G,v=t&c.S,d=t&c.P,y=t&c.B,_=t&c.W,b=h?i:i[e]||(i[e]={}),g=b[a],m=h?n:v?n[e]:(n[e]||{})[a];h&&(r=e);for(s in r)f=!p&&m&&void 0!==m[s],f&&s in b||(l=f?m[s]:r[s],b[s]=h&&"function"!=typeof m[s]?r[s]:y&&f?o(l,n):_&&m[s]==l?function(t){var e=function(e,r,n){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,r)}return new t(e,r,n)}return t.apply(this,arguments)};return e[a]=t[a],e}(l):d&&"function"==typeof l?o(Function.call,l):l,d&&((b.virtual||(b.virtual={}))[s]=l,t&c.R&&g&&!g[s]&&u(g,s,l)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,r){t.exports=r(2).document&&document.documentElement},function(t,e,r){"use strict";var n=r(27),i=r(23),o=r(65),u=r(4),a=r(10),c=r(7),s=r(55),f=r(16),l=r(61),p=r(1)("iterator"),h=!([].keys&&"next"in[].keys()),v="@@iterator",d="keys",y="values",_=function(){return this};t.exports=function(t,e,r,b,g,m,w){s(r,e,b);var x,j,O,F=function(t){if(!h&&t in P)return P[t];switch(t){case d:return function(){return new r(this,t)};case y:return function(){return new r(this,t)}}return function(){return new r(this,t)}},E=e+" Iterator",A=g==y,k=!1,P=t.prototype,S=P[p]||P[v]||g&&P[g],$=S||F(g),D=g?A?F("entries"):$:void 0,M="Array"==e?P.entries||S:S;if(M&&(O=l(M.call(new t)),O!==Object.prototype&&(f(O,E,!0),n||a(O,p)||u(O,p,_))),A&&S&&S.name!==y&&(k=!0,$=function(){return S.call(this)}),n&&!w||!h&&!k&&P[p]||u(P,p,$),c[e]=$,c[E]=_,g)if(x={values:A?$:F(y),keys:m?$:F(d),entries:D},w)for(j in x)j in P||o(P,j,x[j]);else i(i.P+i.F*(h||k),e,x);return x}},function(t,e){t.exports=!0},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,r){var n=r(2),i="__core-js_shared__",o=n[i]||(n[i]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,e,r){var n,i,o,u=r(9),a=r(51),c=r(25),s=r(15),f=r(2),l=f.process,p=f.setImmediate,h=f.clearImmediate,v=f.MessageChannel,d=0,y={},_="onreadystatechange",b=function(){var t=+this;if(y.hasOwnProperty(t)){var e=y[t];delete y[t],e()}},g=function(t){b.call(t.data)};p&&h||(p=function(t){for(var e=[],r=1;arguments.length>r;)e.push(arguments[r++]);return y[++d]=function(){a("function"==typeof t?t:Function(t),e)},n(d),d},h=function(t){delete y[t]},"process"==r(8)(l)?n=function(t){l.nextTick(u(b,t,1))}:v?(i=new v,o=i.port2,i.port1.onmessage=g,n=u(o.postMessage,o,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(n=function(t){f.postMessage(t+"","*")},f.addEventListener("message",g,!1)):n=_ in s("script")?function(t){c.appendChild(s("script"))[_]=function(){c.removeChild(this),b.call(t)}}:function(t){setTimeout(u(b,t,1),0)}),t.exports={set:p,clear:h}},function(t,e,r){var n=r(18),i=Math.min;t.exports=function(t){return t>0?i(n(t),9007199254740991):0}},function(t,e){var r=0,n=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+n).toString(36))}},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function u(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){t.done?i(t.value):new r(function(e){e(t.value)}).then(u,a)}c((n=n.apply(t,e)).next())})},i=this&&this.__generator||function(t,e){function r(t){return function(e){return n([t,e])}}function n(r){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(u=o[2&r[0]?"return":r[0]?"throw":"next"])&&!(u=u.call(o,r[1])).done)return u;switch(o=0,u&&(r=[0,u.value]),r[0]){case 0:case 1:u=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,o=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(u=a.trys,!(u=u.length>0&&u[u.length-1])&&(6===r[0]||2===r[0])){a=0;continue}if(3===r[0]&&(!u||r[1]>u[0]&&r[1]0||!!this.isNested()&&(!!o.isPresent(this.value)&&o.toArray(this.value).filter(function(t){return!!t}).some(function(t){return t.hasErrors()}))},t.prototype.isValid=function(){return!this.hasErrors()},t}();e.Field=f},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function u(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){t.done?i(t.value):new r(function(e){e(t.value)}).then(u,a)}c((n=n.apply(t,e)).next())})},i=this&&this.__generator||function(t,e){function r(t){return function(e){return n([t,e])}}function n(r){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(u=o[2&r[0]?"return":r[0]?"throw":"next"])&&!(u=u.call(o,r[1])).done)return u;switch(o=0,u&&(r=[0,u.value]),r[0]){case 0:case 1:u=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,o=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(u=a.trys,!(u=u.length>0&&u[u.length-1])&&(6===r[0]||2===r[0])){a=0;continue}if(3===r[0]&&(!u||r[1]>u[0]&&r[1]0})},t.prototype.applyErrors=function(t){var e=this;return void 0===t&&(t=[]),t.forEach(function(t){var r=e.getField.apply(e,t.path);r&&(r.errors=t.errors)}),this},t.prototype.hasErrors=function(){var t=this;return Object.keys(this._fields).some(function(e){return t._fields[e].hasErrors()})},t.prototype.isValid=function(){return!this.hasErrors()},t.prototype.invalidate=function(){var t=this;return Object.keys(this._fields).forEach(function(e){return t._fields[e].invalidate()}),this},t.prototype.clone=function(t){return void 0===t&&(t={}),this._createModel(a.merge({},this.serialize(),{parent:this.parent},t))},t}();e.Model=c},function(t,e,r){"use strict";function n(t){return JSON.parse(JSON.stringify(t))}var i=r(20);e.merge=i;var o=r(82);e.isEqual=o,e.serialize=n},function(t,e,r){"use strict";function n(t,e){void 0===e&&(e={});var r=e.values;return!!i.isArray(r)&&r.indexOf(t)!==-1}var i=r(0);e.arrayInclusion=n},function(t,e,r){"use strict";function n(t,e){void 0===e&&(e={});var r=e.requireTld,n=void 0===r||r,o=e.allowUnderscores,u=void 0!==o&&o,a=e.allowTrailingDot,c=void 0!==a&&a;if(!i.isString(t))return!1;c&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var s=t.split(".");if(n){var f=s.pop();if(!s.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(f))return!1}for(var l=void 0,p=0;p=0)return!1;l=l.replace(/_/g,"")}if(!/^[a-z\u00a1-\uffff0-9-]+$/i.test(l))return!1;if(/[\uff01-\uff5e]/.test(l))return!1;if("-"===l[0]||"-"===l[l.length-1])return!1}return!0}var i=r(0);e.stringFQDN=n},function(t,e,r){"use strict";function n(t){return!!i.isString(t)&&/^[0-9A-F]+$/i.test(t)}var i=r(0);e.stringHexadecimal=n},function(t,e,r){"use strict";function n(t,e){if(void 0===e&&(e={}),!i.isString(t))return!1;var r=e.seed;return t.indexOf(i.toString(r))>=0}var i=r(0);e.stringInclusion=n},function(t,e,r){"use strict";function n(t,e){if(void 0===e&&(e={}),!i.isString(t))return!1;var r=e.bytes,n=void 0!==r&&r,o=e.min,u=e.minOrEqual,a=e.max,c=e.maxOrEqual,s=n?encodeURI(t).split(/%..|./).length-1:t.length;return(!i.isNumber(o)||s>o)&&((!i.isNumber(u)||s>=u)&&((!i.isNumber(a)||sf;)if(a=c[f++],a!=a)return!0}else for(;s>f;f++)if((t||f in c)&&c[f]===r)return t||f||0;return!t&&-1}}},function(t,e,r){var n=r(9),i=r(54),o=r(53),u=r(3),a=r(31),c=r(72),s={},f={},e=t.exports=function(t,e,r,l,p){var h,v,d,y,_=p?function(){return t}:c(t),b=n(r,l,e?2:1),g=0;if("function"!=typeof _)throw TypeError(t+" is not iterable!");if(o(_)){for(h=a(t.length);h>g;g++)if(y=e?b(u(v=t[g])[0],v[1]):b(t[g]),y===s||y===f)return y}else for(d=_.call(t);!(v=d.next()).done;)if(y=i(d,b,v.value,e),y===s||y===f)return y};e.BREAK=s,e.RETURN=f},function(t,e,r){t.exports=!r(6)&&!r(24)(function(){return 7!=Object.defineProperty(r(15)("div"),"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t,e,r){var n=void 0===r;switch(e.length){case 0:return n?t():t.call(r);case 1:return n?t(e[0]):t.call(r,e[0]);case 2:return n?t(e[0],e[1]):t.call(r,e[0],e[1]);case 3:return n?t(e[0],e[1],e[2]):t.call(r,e[0],e[1],e[2]);case 4:return n?t(e[0],e[1],e[2],e[3]):t.call(r,e[0],e[1],e[2],e[3])}return t.apply(r,e)}},function(t,e,r){var n=r(8);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==n(t)?t.split(""):Object(t)}},function(t,e,r){var n=r(7),i=r(1)("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||o[i]===t)}},function(t,e,r){var n=r(3);t.exports=function(t,e,r,i){try{return i?e(n(r)[0],r[1]):e(r)}catch(e){var o=t.return;throw void 0!==o&&n(o.call(t)),e}}},function(t,e,r){"use strict";var n=r(59),i=r(28),o=r(16),u={};r(4)(u,r(1)("iterator"),function(){return this}),t.exports=function(t,e,r){t.prototype=n(u,{next:i(1,r)}),o(t,e+" Iterator")}},function(t,e,r){var n=r(1)("iterator"),i=!1;try{var o=[7][n]();o.return=function(){i=!0},Array.from(o,function(){throw 2})}catch(t){}t.exports=function(t,e){if(!e&&!i)return!1;var r=!1;try{var o=[7],u=o[n]();u.next=function(){return{done:r=!0}},o[n]=function(){return u},t(o)}catch(t){}return r}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e,r){var n=r(2),i=r(30).set,o=n.MutationObserver||n.WebKitMutationObserver,u=n.process,a=n.Promise,c="process"==r(8)(u);t.exports=function(){var t,e,r,s=function(){var n,i;for(c&&(n=u.domain)&&n.exit();t;){i=t.fn,t=t.next;try{i()}catch(n){throw t?r():e=void 0,n}}e=void 0,n&&n.enter()};if(c)r=function(){u.nextTick(s)};else if(o){var f=!0,l=document.createTextNode("");new o(s).observe(l,{characterData:!0}),r=function(){l.data=f=!f}}else if(a&&a.resolve){var p=a.resolve();r=function(){p.then(s)}}else r=function(){i.call(n,s)};return function(n){var i={fn:n,next:void 0};e&&(e.next=i),t||(t=i,r()),e=i}}},function(t,e,r){var n=r(3),i=r(60),o=r(22),u=r(17)("IE_PROTO"),a=function(){},c="prototype",s=function(){var t,e=r(15)("iframe"),n=o.length,i="<",u=">";for(e.style.display="none",r(25).appendChild(e),e.src="javascript:",t=e.contentWindow.document,t.open(),t.write(i+"script"+u+"document.F=Object"+i+"/script"+u),t.close(),s=t.F;n--;)delete s[c][o[n]];return s()};t.exports=Object.create||function(t,e){var r;return null!==t?(a[c]=n(t),r=new a,a[c]=null,r[u]=t):r=s(),void 0===e?r:i(r,e)}},function(t,e,r){var n=r(12),i=r(3),o=r(63);t.exports=r(6)?Object.defineProperties:function(t,e){i(t);for(var r,u=o(e),a=u.length,c=0;a>c;)n.f(t,r=u[c++],e[r]);return t}},function(t,e,r){var n=r(10),i=r(70),o=r(17)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),n(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,e,r){var n=r(10),i=r(19),o=r(48)(!1),u=r(17)("IE_PROTO");t.exports=function(t,e){var r,a=i(t),c=0,s=[];for(r in a)r!=u&&n(a,r)&&s.push(r);for(;e.length>c;)n(a,r=e[c++])&&(~o(s,r)||s.push(r));return s}},function(t,e,r){var n=r(62),i=r(22);t.exports=Object.keys||function(t){return n(t,i)}},function(t,e,r){var n=r(4);t.exports=function(t,e,r){for(var i in e)r&&t[i]?t[i]=e[i]:n(t,i,e[i]);return t}},function(t,e,r){t.exports=r(4)},function(t,e,r){"use strict";var n=r(2),i=r(5),o=r(12),u=r(6),a=r(1)("species");t.exports=function(t){var e="function"==typeof i[t]?i[t]:n[t];u&&e&&!e[a]&&o.f(e,a,{configurable:!0,get:function(){return this}})}},function(t,e,r){var n=r(3),i=r(13),o=r(1)("species");t.exports=function(t,e){var r,u=n(t).constructor;return void 0===u||void 0==(r=n(u)[o])?e:i(r)}},function(t,e,r){var n=r(18),i=r(14);t.exports=function(t){return function(e,r){var o,u,a=String(i(e)),c=n(r),s=a.length;return c<0||c>=s?t?"":void 0:(o=a.charCodeAt(c),o<55296||o>56319||c+1===s||(u=a.charCodeAt(c+1))<56320||u>57343?t?a.charAt(c):o:t?a.slice(c,c+2):(o-55296<<10)+(u-56320)+65536)}}},function(t,e,r){var n=r(18),i=Math.max,o=Math.min;t.exports=function(t,e){return t=n(t),t<0?i(t+e,0):o(t,e)}},function(t,e,r){var n=r(14);t.exports=function(t){return Object(n(t))}},function(t,e,r){var n=r(11);t.exports=function(t,e){if(!n(t))return t;var r,i;if(e&&"function"==typeof(r=t.toString)&&!n(i=r.call(t)))return i;if("function"==typeof(r=t.valueOf)&&!n(i=r.call(t)))return i;if(!e&&"function"==typeof(r=t.toString)&&!n(i=r.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,e,r){var n=r(21),i=r(1)("iterator"),o=r(7);t.exports=r(5).getIteratorMethod=function(t){if(void 0!=t)return t[i]||t["@@iterator"]||o[n(t)]}},function(t,e,r){"use strict";var n=r(46),i=r(57),o=r(7),u=r(19);t.exports=r(26)(Array,"Array",function(t,e){this._t=u(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,i(1)):"keys"==e?i(0,r):"values"==e?i(0,t[r]):i(0,[r,t[r]])},"values"),o.Arguments=o.Array,n("keys"),n("values"),n("entries")},function(t,e){},function(t,e,r){"use strict";var n,i,o,u=r(27),a=r(2),c=r(9),s=r(21),f=r(23),l=r(11),p=r(13),h=r(47),v=r(49),d=r(67),y=r(30).set,_=r(58)(),b="Promise",g=a.TypeError,m=a.process,w=a[b],m=a.process,x="process"==s(m),j=function(){},O=!!function(){try{var t=w.resolve(1),e=(t.constructor={})[r(1)("species")]=function(t){t(j,j)};return(x||"function"==typeof PromiseRejectionEvent)&&t.then(j)instanceof e}catch(t){}}(),F=function(t,e){return t===e||t===w&&e===o},E=function(t){var e;return!(!l(t)||"function"!=typeof(e=t.then))&&e},A=function(t){return F(w,t)?new k(t):new i(t)},k=i=function(t){var e,r;this.promise=new t(function(t,n){if(void 0!==e||void 0!==r)throw g("Bad Promise constructor");e=t,r=n}),this.resolve=p(e),this.reject=p(r)},P=function(t){try{t()}catch(t){return{error:t}}},S=function(t,e){if(!t._n){t._n=!0;var r=t._c;_(function(){for(var n=t._v,i=1==t._s,o=0,u=function(e){var r,o,u=i?e.ok:e.fail,a=e.resolve,c=e.reject,s=e.domain;try{u?(i||(2==t._h&&M(t),t._h=1),u===!0?r=n:(s&&s.enter(),r=u(n),s&&s.exit()),r===e.promise?c(g("Promise-chain cycle")):(o=E(r))?o.call(r,a,c):a(r)):c(n)}catch(t){c(t)}};r.length>o;)u(r[o++]);t._c=[],t._n=!1,e&&!t._h&&$(t)})}},$=function(t){y.call(a,function(){var e,r,n,i=t._v;if(D(t)&&(e=P(function(){x?m.emit("unhandledRejection",i,t):(r=a.onunhandledrejection)?r({promise:t,reason:i}):(n=a.console)&&n.error&&n.error("Unhandled promise rejection",i)}),t._h=x||D(t)?2:1),t._a=void 0,e)throw e.error})},D=function(t){if(1==t._h)return!1;for(var e,r=t._a||t._c,n=0;r.length>n;)if(e=r[n++],e.fail||!D(e.promise))return!1;return!0},M=function(t){y.call(a,function(){var e;x?m.emit("rejectionHandled",t):(e=a.onrejectionhandled)&&e({promise:t,reason:t._v})})},N=function(t){var e=this;e._d||(e._d=!0,e=e._w||e,e._v=t,e._s=2,e._a||(e._a=e._c.slice()),S(e,!0))},U=function(t){var e,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw g("Promise can't be resolved itself");(e=E(t))?_(function(){var n={_w:r,_d:!1};try{e.call(t,c(U,n,1),c(N,n,1))}catch(t){N.call(n,t)}}):(r._v=t,r._s=1,S(r,!1))}catch(t){N.call({_w:r,_d:!1},t)}}};O||(w=function(t){h(this,w,b,"_h"),p(t),n.call(this);try{t(c(U,this,1),c(N,this,1))}catch(t){N.call(this,t)}},n=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},n.prototype=r(64)(w.prototype,{then:function(t,e){var r=A(d(this,w));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=x?m.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&S(this,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),k=function(){var t=new n;this.promise=t,this.resolve=c(U,t,1),this.reject=c(N,t,1)}),f(f.G+f.W+f.F*!O,{Promise:w}),r(16)(w,b),r(66)(b),o=r(5)[b],f(f.S+f.F*!O,b,{reject:function(t){var e=A(this),r=e.reject;return r(t),e.promise}}),f(f.S+f.F*(u||!O),b,{resolve:function(t){if(t instanceof w&&F(t.constructor,this))return t;var e=A(this),r=e.resolve;return r(t),e.promise}}),f(f.S+f.F*!(O&&r(56)(function(t){w.all(t).catch(j)})),b,{all:function(t){var e=this,r=A(e),n=r.resolve,i=r.reject,o=P(function(){var r=[],o=0,u=1;v(t,!1,function(t){var a=o++,c=!1;r.push(void 0),u++,e.resolve(t).then(function(t){c||(c=!0,r[a]=t,--u||n(r))},i)}),--u||n(r)});return o&&i(o.error),r.promise},race:function(t){var e=this,r=A(e),n=r.reject,i=P(function(){v(t,!1,function(t){e.resolve(t).then(r.resolve,n)})});return i&&n(i.error),r.promise}})},function(t,e,r){"use strict";var n=r(68)(!0);r(26)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,r=this._i;return r>=e.length?{value:void 0,done:!0}:(t=n(e,r),this._i+=t.length,{value:t,done:!1})})},function(t,e,r){r(73);for(var n=r(2),i=r(4),o=r(7),u=r(1)("toStringTag"),a=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],c=0;c<5;c++){var s=a[c],f=n[s],l=f&&f.prototype;l&&!l[u]&&i(l,u,s),o[s]=o.Array}},function(t,e,r){"use strict";function n(t,e){if(void 0===e&&(e={}),!t||!e)return!1;var r=e.block;return!!r&&r.call(this,t,e)}e.block=n},function(t,e,r){"use strict";var n=r(78);e.block=n.block;var i=r(80);e.mongoUniqueness=i.mongoUniqueness},function(t,e,r){"use strict";function n(t,e){if(void 0===e&&(e={}),!t||!e)return!1;var r=t&&t.message&&0===t.message.indexOf("E11000 duplicate key error index:")&&("undefined"==typeof t.code||11e3===t.code);if(r){var n=t.message.split("$",2)[1].split(" ",2)[0];return e.indexName===n}return!1}e.mongoUniqueness=n},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function u(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){t.done?i(t.value):new r(function(e){e(t.value)}).then(u,a)}c((n=n.apply(t,e)).next())})},i=this&&this.__generator||function(t,e){function r(t){return function(e){return n([t,e])}}function n(r){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(u=o[2&r[0]?"return":r[0]?"throw":"next"])&&!(u=u.call(o,r[1])).done)return u;switch(o=0,u&&(r=[0,u.value]),r[0]){case 0:case 1:u=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,o=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(u=a.trys,!(u=u.length>0&&u[u.length-1])&&(6===r[0]||2===r[0])){a=0;continue}if(3===r[0]&&(!u||r[1]>u[0]&&r[1]-1}function x(t,e){var r=this.__data__,n=z(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}function j(t){var e=-1,r=t?t.length:0;for(this.clear();++ec))return!1;var f=u.get(t);if(f&&u.get(e))return f==e;var l=-1,p=!0,h=o&vt?new P:void 0;for(u.set(t,e),u.set(e,t);++l-1&&t%1==0&&t-1&&t%1==0&&t<=yt}function st(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function ft(t){return!!t&&"object"==typeof t}function lt(t){return it(t)?V(t):H(t)}var pt=200,ht="__lodash_hash_undefined__",vt=1,dt=2,yt=9007199254740991,_t="[object Arguments]",bt="[object Array]",gt="[object Boolean]",mt="[object Date]",wt="[object Error]",xt="[object Function]",jt="[object GeneratorFunction]",Ot="[object Map]",Ft="[object Number]",Et="[object Object]",At="[object Promise]",kt="[object RegExp]",Pt="[object Set]",St="[object String]",$t="[object Symbol]",Dt="[object WeakMap]",Mt="[object ArrayBuffer]",Nt="[object DataView]",Ut="[object Float32Array]",Tt="[object Float64Array]",It="[object Int8Array]",Vt="[object Int16Array]",zt="[object Int32Array]",Ct="[object Uint8Array]",Lt="[object Uint8ClampedArray]",Rt="[object Uint16Array]",qt="[object Uint32Array]",Bt=/[\\^$.*+?()[\]{}|]/g,Ht=/^\[object .+?Constructor\]$/,Gt=/^(?:0|[1-9]\d*)$/,Wt={};Wt[Ut]=Wt[Tt]=Wt[It]=Wt[Vt]=Wt[zt]=Wt[Ct]=Wt[Lt]=Wt[Rt]=Wt[qt]=!0,Wt[_t]=Wt[bt]=Wt[Mt]=Wt[gt]=Wt[Nt]=Wt[mt]=Wt[wt]=Wt[xt]=Wt[Ot]=Wt[Ft]=Wt[Et]=Wt[kt]=Wt[Pt]=Wt[St]=Wt[Dt]=!1;var Kt="object"==typeof t&&t&&t.Object===Object&&t,Jt="object"==typeof self&&self&&self.Object===Object&&self,Zt=Kt||Jt||Function("return this")(),Qt="object"==typeof e&&e&&!e.nodeType&&e,Xt=Qt&&"object"==typeof r&&r&&!r.nodeType&&r,Yt=Xt&&Xt.exports===Qt,te=Yt&&Kt.process,ee=function(){try{return te&&te.binding("util")}catch(t){}}(),re=ee&&ee.isTypedArray,ne=Array.prototype,ie=Function.prototype,oe=Object.prototype,ue=Zt["__core-js_shared__"],ae=function(){var t=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ce=ie.toString,se=oe.hasOwnProperty,fe=oe.toString,le=RegExp("^"+ce.call(se).replace(Bt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),pe=Zt.Symbol,he=Zt.Uint8Array,ve=oe.propertyIsEnumerable,de=ne.splice,ye=s(Object.keys,Object),_e=Z(Zt,"DataView"),be=Z(Zt,"Map"),ge=Z(Zt,"Promise"),me=Z(Zt,"Set"),we=Z(Zt,"WeakMap"),xe=Z(Object,"create"),je=et(_e),Oe=et(be),Fe=et(ge),Ee=et(me),Ae=et(we),ke=pe?pe.prototype:void 0,Pe=ke?ke.valueOf:void 0;l.prototype.clear=p,l.prototype.delete=h,l.prototype.get=v,l.prototype.has=d,l.prototype.set=y,_.prototype.clear=b,_.prototype.delete=g,_.prototype.get=m,_.prototype.has=w,_.prototype.set=x,j.prototype.clear=O,j.prototype.delete=F,j.prototype.get=E,j.prototype.has=A,j.prototype.set=k,P.prototype.add=P.prototype.push=S,P.prototype.has=$,D.prototype.clear=M,D.prototype.delete=N,D.prototype.get=U,D.prototype.has=T,D.prototype.set=I;var Se=C;(_e&&Se(new _e(new ArrayBuffer(1)))!=Nt||be&&Se(new be)!=Ot||ge&&Se(ge.resolve())!=At||me&&Se(new me)!=Pt||we&&Se(new we)!=Dt)&&(Se=function(t){var e=fe.call(t),r=e==Et?t.constructor:void 0,n=r?et(r):void 0;if(n)switch(n){case je:return Nt;case Oe:return Ot;case Fe:return At;case Ee:return Pt;case Ae:return Dt}return e});var $e=Array.isArray,De=re?o(re):B;r.exports=ut}).call(e,r(41),r(42)(t))},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function i(){var t=null;return function(e){var r,n=e.handler,i=e.time,o=void 0===i?0:i,a=new u.default(function(t){return r=t}).then(function(){return n.call?n():n});return t&&clearTimeout(t),t=setTimeout(function(){t=null,r()},o),a}}Object.defineProperty(e,"__esModule",{value:!0});var o=r(44),u=n(o);e.createDebouncer=i},function(t,e,r){"use strict";var n=r(34);e.Model=n.Model;var i=r(33);e.Field=i.Field},function(t,e,r){"use strict";function n(t){if(!Array.isArray(t)||0===t.length)return null;var e=t[0];return e.message?e.message:e}e.firstMessage=n},function(t,e,r){"use strict";var n=this&&this.__extends||function(t,e){function r(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)},i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function u(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){t.done?i(t.value):new r(function(e){e(t.value)}).then(u,a)}c((n=n.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){function r(t){return function(e){return n([t,e])}}function n(r){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(u=o[2&r[0]?"return":r[0]?"throw":"next"])&&!(u=u.call(o,r[1])).done)return u;switch(o=0,u&&(r=[0,u.value]),r[0]){case 0:case 1:u=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,o=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(u=a.trys,!(u=u.length>0&&u[u.length-1])&&(6===r[0]||2===r[0])){a=0;continue}if(3===r[0]&&(!u||r[1]>u[0]&&r[1]0&&u[u.length-1])&&(6===r[0]||2===r[0])){a=0;continue}if(3===r[0]&&(!u||r[1]>u[0]&&r[1]n)&&((!i.isNumber(o)||r>=o)&&((!i.isNumber(u)||rr)&&((!i.isNumber(n)||t>=n)&&((!i.isNumber(o)||t$/i,c=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,s=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,f=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,l=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;e.stringEmail=n},function(t,e,r){"use strict";function n(t,e){return void 0===e&&(e={}),!i.stringInclusion(t,e)}var i=r(39);e.stringExclusion=n},function(t,e,r){"use strict";function n(t){return!!i.isString(t)&&/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i.test(t)}var i=r(0);e.stringHexColor=n},function(t,e,r){"use strict";function n(t){if(!i.isString(t))return!1;try{var e=JSON.parse(t);return!!e&&"object"==typeof e}catch(t){}return!1}var i=r(0);e.stringJSON=n},function(t,e,r){"use strict";function n(t){return!!i.isString(t)&&t===t.toLowerCase()}var i=r(0);e.stringLowercase=n},function(t,e,r){"use strict";function n(t,e){if(void 0===e&&(e={}),!i.isString(t))return!1;var r=e.regexp;return r.test(t)}var i=r(0);e.stringMatch=n},function(t,e,r){"use strict";function n(t){return!!i.isString(t)&&t===t.toUpperCase()}var i=r(0);e.stringUppercase=n},function(t,e,r){"use strict";function n(t,e){if(void 0===e&&(e={}),!i.isString(t))return!1;var r=e.version;switch(r){case 1:return o.test(t);case 2:return u.test(t);case 3:return a.test(t);case 4:return c.test(t);case 5:return s.test(t)}return o.test(t)||u.test(t)||a.test(t)||c.test(t)||s.test(t)}var i=r(0),o=/^[0-9a-f]{8}-[0-9a-f]{4}-[1][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,u=/^[0-9a-f]{8}-[0-9a-f]{4}-[2][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,a=/^[0-9a-f]{8}-[0-9a-f]{4}-[3][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,c=/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,s=/^[0-9a-f]{8}-[0-9a-f]{4}-[5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;e.stringUUID=n},function(t,e,r){t.exports=r(43)}])}); 4 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/models.d.ts: -------------------------------------------------------------------------------- 1 | import { Model } from 'rawmodel'; 2 | export interface ReactiveModelRecipe { 3 | parent?: Model; 4 | vm?: any; 5 | dataKey?: string; 6 | [key: string]: any; 7 | } 8 | export declare class ReactiveModel extends Model { 9 | private _debounce; 10 | readonly vm: any; 11 | readonly dataKey: string; 12 | constructor(data?: ReactiveModelRecipe); 13 | isReactive(): boolean; 14 | $rebuild(): this; 15 | $forceUpdate(): this; 16 | $populate(data: any): this; 17 | $applyErrors(errors?: any[]): this; 18 | $clear(): this; 19 | $fake(): this; 20 | $handle(error: any, {debounce, quiet}?: { 21 | debounce?: number; 22 | quiet?: boolean; 23 | }): Promise; 24 | $invalidate(): this; 25 | $reset(): this; 26 | $rollback(): this; 27 | $validate({debounce, quiet}?: { 28 | debounce?: number; 29 | quiet?: boolean; 30 | }): Promise; 31 | } 32 | -------------------------------------------------------------------------------- /example/app.vue: -------------------------------------------------------------------------------- 1 | 43 | 44 | 105 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './app.vue'; 3 | import * as models from './models'; 4 | 5 | new Vue({ 6 | models, 7 | el: '#app', 8 | render: h => h(App) 9 | }); 10 | -------------------------------------------------------------------------------- /example/models/book.js: -------------------------------------------------------------------------------- 1 | import {ReactiveModel} from '../../'; 2 | 3 | export class Book extends ReactiveModel { 4 | 5 | constructor (data = {}) { 6 | super(data); 7 | 8 | this.defineField('title', { 9 | type: 'String', 10 | validate: [ 11 | { 12 | validator: 'presence', 13 | message: 'is required' 14 | } 15 | ] 16 | }); 17 | 18 | this.populate(data); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /example/models/index.js: -------------------------------------------------------------------------------- 1 | import * as Vue from 'vue'; 2 | import VueRawModel from '../../'; 3 | import {User} from './user'; 4 | import {Book} from './book'; 5 | 6 | Vue.use(VueRawModel); 7 | 8 | export { 9 | User, 10 | Book 11 | }; 12 | -------------------------------------------------------------------------------- /example/models/user.js: -------------------------------------------------------------------------------- 1 | import {ReactiveModel} from '../../'; 2 | import {Book} from './book'; 3 | 4 | export class User extends ReactiveModel { 5 | 6 | constructor (data = {}) { 7 | super(data); 8 | 9 | this.defineField('name', { // name property 10 | type: 'String', 11 | defaultValue: '', 12 | fakeValue: 'Faker Smith', 13 | validate: [ 14 | { 15 | validator: 'presence', 16 | message: 'is required' 17 | } 18 | ], 19 | handle: [ 20 | { 21 | handler: 'block', 22 | block () { return true; }, 23 | message: 'unknown error' 24 | } 25 | ] 26 | }); 27 | this.defineField('book', { // book property 28 | type: Book 29 | }); 30 | this.defineField('books', { // books property 31 | type: [Book] 32 | }); 33 | 34 | this.populate(data); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "ignore": ["dist/*"], 3 | "ext": "js,ts" 4 | } 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-rawmodel", 3 | "version": "1.2.2", 4 | "description": "RawModel.js plugin for Vue.js v2. Form validation has never been easier!", 5 | "main": "./dist/index.js", 6 | "types": "./dist/index.d.ts", 7 | "scripts": { 8 | "clean": "rm -Rf ./dist", 9 | "build": "npm run clean; vue build src/index.ts --prod --lib --config ./vue.config.js", 10 | "prepublish": "npm run build", 11 | "example": "vue build example/index.js" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/xpepermint/vue-rawmodel.git" 16 | }, 17 | "bugs": { 18 | "url": "https://github.com/xpepermint/vue-rawmodel/issues" 19 | }, 20 | "homepage": "https://github.com/xpepermint/vue-rawmodel#readme", 21 | "keywords": [ 22 | "vue", 23 | "vue.js", 24 | "orm", 25 | "odm", 26 | "map", 27 | "mapping", 28 | "context", 29 | "contextify", 30 | "rawmodel", 31 | "model", 32 | "modeling", 33 | "document", 34 | "class", 35 | "apollo", 36 | "graphql", 37 | "request", 38 | "storage", 39 | "structure", 40 | "structuring", 41 | "error", 42 | "errors", 43 | "handling", 44 | "handle", 45 | "valid", 46 | "validate", 47 | "validation", 48 | "validator", 49 | "validating", 50 | "form", 51 | "type", 52 | "cast", 53 | "casting", 54 | "history", 55 | "tracking", 56 | "change", 57 | "field", 58 | "fields" 59 | ], 60 | "author": "Kristijan Sedlak (Xpepermint)", 61 | "license": "MIT", 62 | "devDependencies": { 63 | "rawmodel": "^1.7.0", 64 | "ts-loader": "^2.0.0", 65 | "typescript": "^2.1.5", 66 | "vue": "^2.1.10", 67 | "vue-cli": "^2.8.0", 68 | "vue-template-compiler": "2.1.10" 69 | }, 70 | "peerDependencies": { 71 | "rawmodel": "^1.7.0" 72 | }, 73 | "dependencies": { 74 | "promised-debounce": "^0.4.2" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/filters.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Accepts an array of errors and returns the first error message. 3 | */ 4 | 5 | export function firstMessage (errors) { 6 | if ( 7 | !Array.isArray(errors) 8 | || errors.length === 0 9 | ) return null; 10 | 11 | let error = errors[0]; 12 | if (error.message) { 13 | return error.message; 14 | } 15 | else { 16 | return error; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import {ReactiveModel} from './models'; 2 | import * as filters from './filters'; 3 | 4 | /* 5 | * RawModel class. 6 | */ 7 | 8 | export {ReactiveModel} 9 | 10 | /* 11 | * RawModel plugin class. 12 | */ 13 | 14 | export default class VueRawModel { 15 | 16 | /* 17 | * Installs the Vue plugin. 18 | */ 19 | 20 | static install (Vue, options = {}) { 21 | Object.defineProperty(Vue.prototype, '$models', { // adding a global variable `$context` 22 | get () { return this.$root._models; } // returns the application context 23 | }); 24 | 25 | Vue.mixin({ 26 | filters, 27 | beforeCreate () { 28 | let models = this.$options.models; // retrieve context instance 29 | if (models) { // memorize the context instance so we can retrieve it in a root component 30 | this._models = models; 31 | } 32 | } 33 | }); 34 | } 35 | } 36 | 37 | /* 38 | * The plugin is automatically installed when loaded in browser (not as module). 39 | */ 40 | 41 | if (typeof window !== 'undefined' && !!window['Vue']) { 42 | window['Vue'].use(VueRawModel); 43 | } 44 | -------------------------------------------------------------------------------- /src/models.ts: -------------------------------------------------------------------------------- 1 | import {Model} from 'rawmodel'; 2 | import {createDebouncer} from 'promised-debounce'; 3 | 4 | /* 5 | * Model recipe interface. 6 | */ 7 | 8 | export interface ReactiveModelRecipe { 9 | parent?: Model; 10 | vm?: any; 11 | dataKey?: string; 12 | [key: string]: any; 13 | } 14 | 15 | /* 16 | * Reactive alternative of the Model which provides some new reactive methods. 17 | * Note that reactive methods are prefixed with the `$` sign. 18 | */ 19 | 20 | export class ReactiveModel extends Model { 21 | private _debounce: ({handler, time}) => any; 22 | readonly vm: any; 23 | readonly dataKey: string; 24 | 25 | /* 26 | * Class constructor. 27 | */ 28 | 29 | public constructor (data: ReactiveModelRecipe = {}) { 30 | super(data); 31 | 32 | Object.defineProperty(this, '_debounce', { 33 | value: createDebouncer() 34 | }); 35 | 36 | Object.defineProperty(this, 'vm', { 37 | get: () => data.vm 38 | }); 39 | Object.defineProperty(this, 'dataKey', { 40 | get: () => data.dataKey 41 | }); 42 | } 43 | 44 | /* 45 | * Returns `true` if reactive properties are set. 46 | */ 47 | 48 | public isReactive (): boolean { 49 | return !!this.vm && !!this.dataKey; 50 | } 51 | 52 | /* 53 | * Recreates reactivity on dataKey. 54 | */ 55 | 56 | public $rebuild (): this { 57 | if (this.isReactive()) { 58 | let {vm, dataKey} = this; 59 | return vm[dataKey] = this.clone({vm, dataKey}); 60 | } 61 | return this; 62 | } 63 | 64 | /* 65 | * Repaints the UI. 66 | */ 67 | 68 | public $forceUpdate (): this { 69 | if (this.isReactive()) { 70 | this.vm.$forceUpdate() 71 | } 72 | return this; 73 | } 74 | 75 | /* 76 | * Reactive alternative of method `populate()` which applies `data` to 77 | * model fields. 78 | */ 79 | 80 | public $populate (data): this { 81 | this.populate(data); 82 | return this.$rebuild(); 83 | } 84 | 85 | /* 86 | * Reactive alternative of method `applyErrors()` which sets fields errors. 87 | */ 88 | 89 | public $applyErrors (errors: any[] = []): this { 90 | this.applyErrors(errors); 91 | this.$forceUpdate(); 92 | return this; 93 | } 94 | 95 | /* 96 | * Reactive alternative of method `clear()` which sets all fileds to `null`. 97 | */ 98 | 99 | $clear (): this { 100 | this.clear(); 101 | this.$forceUpdate(); 102 | return this; 103 | } 104 | 105 | /* 106 | * Reactive alternative of method `fake()` which resets fields then sets fields 107 | * to their fake values. 108 | */ 109 | 110 | $fake (): this { 111 | this.fake(); 112 | this.$forceUpdate(); 113 | return this; 114 | } 115 | 116 | /* 117 | * Reactive alternative of method `handle()` which handles the error and throws 118 | * an error if the error can not be handled. 119 | */ 120 | 121 | async $handle (error: any, { 122 | debounce = 0, 123 | quiet = true 124 | }: { 125 | debounce?: number, 126 | quiet?: boolean 127 | } = {}): Promise { 128 | return this._debounce({ 129 | handler: () => { 130 | this.handle(error, {quiet}).then(() => this.$forceUpdate()); 131 | return this; 132 | }, 133 | time: debounce 134 | }); 135 | } 136 | 137 | /* 138 | * Reactive alternative of method `invalidate()` which removes fields errors. 139 | */ 140 | 141 | $invalidate (): this { 142 | this.invalidate(); 143 | this.$forceUpdate(); 144 | return this; 145 | } 146 | 147 | /* 148 | * Reactive alternative of method `reset()` which sets each model field to 149 | * its default value. 150 | */ 151 | 152 | $reset (): this { 153 | this.reset(); 154 | this.$forceUpdate(); 155 | return this; 156 | } 157 | 158 | /* 159 | * Reactive alternative of method `rollback()` which sets each field to its 160 | * initial value (value before last commit). 161 | */ 162 | 163 | $rollback (): this { 164 | this.rollback(); 165 | this.$forceUpdate(); 166 | return this; 167 | } 168 | 169 | /* 170 | * Reactive alternative of method `validate()` which validates the model 171 | * fields and throws a validation error if not all fields are valid when the 172 | * quiet is set to `false`. 173 | */ 174 | 175 | public $validate ({ 176 | debounce = 0, 177 | quiet = true 178 | }: { 179 | debounce?: number, 180 | quiet?: boolean 181 | } = {}): Promise { 182 | return this._debounce({ 183 | handler: () => { 184 | this.validate({quiet}).then(() => this.$forceUpdate()); 185 | return this; 186 | }, 187 | time: debounce 188 | }); 189 | } 190 | 191 | } 192 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es3", 5 | "noImplicitAny": false, 6 | "removeComments": true, 7 | "experimentalDecorators": true, 8 | "sourceMap": true, 9 | "outDir": "dist", 10 | "declaration": true, 11 | "lib": ["es2015.promise", "es2015.iterable", "es5", "dom.iterable"] 12 | }, 13 | "include": [ 14 | "src/**/*" 15 | ], 16 | "exclude": [ 17 | "node_modules", 18 | "**/*.spec.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "jsRules": { 3 | "class-name": true, 4 | "comment-format": [ 5 | true, 6 | "check-space" 7 | ], 8 | "indent": [ 9 | true, 10 | "spaces" 11 | ], 12 | "no-duplicate-variable": true, 13 | "no-eval": true, 14 | "no-trailing-whitespace": true, 15 | "no-unsafe-finally": true, 16 | "one-line": [ 17 | true, 18 | "check-open-brace", 19 | "check-whitespace" 20 | ], 21 | "quotemark": [ 22 | true, 23 | "double" 24 | ], 25 | "semicolon": [ 26 | true, 27 | "always" 28 | ], 29 | "triple-equals": [ 30 | true, 31 | "allow-null-check" 32 | ], 33 | "variable-name": [ 34 | true, 35 | "ban-keywords" 36 | ], 37 | "whitespace": [ 38 | true, 39 | "check-branch", 40 | "check-decl", 41 | "check-operator", 42 | "check-separator", 43 | "check-type" 44 | ] 45 | }, 46 | "rules": { 47 | "class-name": true, 48 | "comment-format": [ 49 | true, 50 | "check-space" 51 | ], 52 | "indent": [ 53 | true, 54 | "spaces" 55 | ], 56 | "no-eval": true, 57 | "no-internal-module": true, 58 | "no-trailing-whitespace": true, 59 | "no-unsafe-finally": true, 60 | "no-var-keyword": true, 61 | "one-line": [ 62 | true, 63 | "check-open-brace", 64 | "check-whitespace" 65 | ], 66 | "quotemark": [ 67 | true, 68 | "single" 69 | ], 70 | "semicolon": [ 71 | true, 72 | "always" 73 | ], 74 | "triple-equals": [ 75 | true, 76 | "allow-null-check" 77 | ], 78 | "typedef-whitespace": [ 79 | true, 80 | { 81 | "call-signature": "nospace", 82 | "index-signature": "nospace", 83 | "parameter": "nospace", 84 | "property-declaration": "nospace", 85 | "variable-declaration": "nospace" 86 | } 87 | ], 88 | "variable-name": [ 89 | true, 90 | "ban-keywords" 91 | ], 92 | "whitespace": [ 93 | true, 94 | "check-branch", 95 | "check-decl", 96 | "check-operator", 97 | "check-separator", 98 | "check-type" 99 | ] 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | webpack (defaults) { 4 | defaults.context = './src'; 5 | defaults.output.filename = './index.js'; 6 | defaults.resolve.extensions.push('.ts'); 7 | defaults.module.rules.push({ test: /\.ts?$/, loader: 'ts-loader' }); 8 | return defaults; 9 | } 10 | 11 | }; 12 | --------------------------------------------------------------------------------