@jaysalvat/smart-model
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -6,3 +6,3 @@ | ||
* https://github.com/jaysalvat/smart-model | ||
* @version 0.2.7 built 2021-02-19 20:58:43 | ||
* @version 0.2.9 built 2021-02-19 21:35:08 | ||
* @license ISC | ||
@@ -9,0 +9,0 @@ * @author Jay Salvat http://jaysalvat.com |
@@ -1,2 +0,2 @@ | ||
/*! SmartModel v0.2.7 */ | ||
/*! SmartModel v0.2.9 */ | ||
function e(e){return void 0===e}function t(t){return""===t||null===t||e(t)}function r(e){return"function"==typeof e}function n(e){return e?JSON.parse(JSON.stringify(e)):e}function o(e){return[].concat([],e)}function s(e,r,n){const s=[];return e.required&&t(n)?(s.push({message:`Invalid value 'required' on property '${r}'`,code:"required"}),s):(void 0===n||(!e.type||!e.required&&t(n)||o(e.type).some((e=>function(e,t){return typeof e==typeof t()||e instanceof t}(n,e)))||s.push({message:`Invalid type '${typeof n}' on property '${r}'`,code:"type"}),e.rule&&Object.keys(e.rule).forEach((t=>{(0,e.rule[t])(n)&&s.push({message:`Invalid value '${t}' on property '${r}'`,code:t})}))),s)}class c extends Error{constructor(e){super(e.message),Object.assign(this,e)}}class u extends class{constructor(e={},t={}){return new Proxy(this,{set(r,o,u){const i=n(r[o]),f=(a=u,p=i,!(JSON.stringify(a)===JSON.stringify(p)));var a,p;const l=e[o];function d(t,n){return Reflect.apply(t,r,n||[o,u,i,e])}if(!l)return t.strict||(r[o]=u),!0;if(d(r.onBeforeSet),f&&d(r.onBeforeUpdate),l.transform&&(u=d(l.transform,[u,e])),t.exceptions){const e=s(l,o,u);e.length&&e.forEach((e=>{throw new c({message:e.message,property:o,code:e.code})}))}return r[o]=u,d(r.onSet),f&&d(r.onUpdate),!0},get(t,n){const o=e[n];let s=t[n];if(!o)return t[n];function c(r,o){return Reflect.apply(r,t,o||[n,s,e])}return c(t.onBeforeGet),r(o)&&(s=c(o,[t,e])),r(o.format)&&(s=c(o.format,[s,e])),c(t.onGet),s},deleteProperty(t,r){const o=n(t[r]);function s(n,s){return Reflect.apply(n,t,s||[r,o,e])}if(e[r].required)throw new c({message:`Invalid delete on required propery ${r}`,property:r,code:"required"});return s(t.onBeforeDelete),Reflect.deleteProperty(t,r),s(t.onDelete),s(t.onUpdate),!0}})}}{constructor(t={},r={},n={}){super(t,n),Object.keys(t).forEach((n=>{e(r[n])&&(t[n].default?this[n]=t[n].default:this[n]=r[n])})),this.feed(r)}feed(e){Object.keys(e).forEach((t=>{this[t]=e[t]}))}onBeforeGet(){}onBeforeSet(){}onBeforeUpdate(){}onDelete(){}onGet(){}onBeforeDelete(){}onSet(){}onUpdate(){}}u.settings={strict:!1,exceptions:!0},u.create=function(e,t,r,n){r=Object.assign({},u.settings,r);const c={[e]:class extends u{constructor(e){super(t,e,r)}}}[e];return c.checkErrors=function(e,r){const n={};return Object.keys(t).forEach((c=>{let u=s(t[c],c,e[c]);u.length&&(r&&(u=u.filter((e=>!o(r).includes(e.code)))),u.length&&(n[c]=u))})),!!Object.keys(n).length&&n},c.hydrate=function(e){return t=e,Array.isArray(t)?e.map((e=>new c(e))):new c(e);var t},Object.assign(c.prototype,n),c};export default u; |
@@ -6,3 +6,3 @@ | ||
* https://github.com/jaysalvat/smart-model | ||
* @version 0.2.7 built 2021-02-19 20:58:43 | ||
* @version 0.2.9 built 2021-02-19 21:35:08 | ||
* @license ISC | ||
@@ -9,0 +9,0 @@ * @author Jay Salvat http://jaysalvat.com |
@@ -1,2 +0,2 @@ | ||
/*! SmartModel v0.2.7 */ | ||
/*! SmartModel v0.2.9 */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SmartModel={})}(this,(function(e){"use strict";function t(e){return void 0===e}function r(e){return""===e||null===e||t(e)}function n(e){return"function"==typeof e}function o(e){return e?JSON.parse(JSON.stringify(e)):e}function s(e){return[].concat([],e)}function c(e,t,n){const o=[];return e.required&&r(n)?(o.push({message:`Invalid value 'required' on property '${t}'`,code:"required"}),o):(void 0===n||(!e.type||!e.required&&r(n)||s(e.type).some((e=>function(e,t){return typeof e==typeof t()||e instanceof t}(n,e)))||o.push({message:`Invalid type '${typeof n}' on property '${t}'`,code:"type"}),e.rule&&Object.keys(e.rule).forEach((r=>{(0,e.rule[r])(n)&&o.push({message:`Invalid value '${r}' on property '${t}'`,code:r})}))),o)}class i extends Error{constructor(e){super(e.message),Object.assign(this,e)}}class u extends class{constructor(e={},t={}){return new Proxy(this,{set(r,n,s){const u=o(r[n]),f=(a=s,p=u,!(JSON.stringify(a)===JSON.stringify(p)));var a,p;const d=e[n];function l(t,o){return Reflect.apply(t,r,o||[n,s,u,e])}if(!d)return t.strict||(r[n]=s),!0;if(l(r.onBeforeSet),f&&l(r.onBeforeUpdate),d.transform&&(s=l(d.transform,[s,e])),t.exceptions){const e=c(d,n,s);e.length&&e.forEach((e=>{throw new i({message:e.message,property:n,code:e.code})}))}return r[n]=s,l(r.onSet),f&&l(r.onUpdate),!0},get(t,r){const o=e[r];let s=t[r];if(!o)return t[r];function c(n,o){return Reflect.apply(n,t,o||[r,s,e])}return c(t.onBeforeGet),n(o)&&(s=c(o,[t,e])),n(o.format)&&(s=c(o.format,[s,e])),c(t.onGet),s},deleteProperty(t,r){const n=o(t[r]);function s(o,s){return Reflect.apply(o,t,s||[r,n,e])}if(e[r].required)throw new i({message:`Invalid delete on required propery ${r}`,property:r,code:"required"});return s(t.onBeforeDelete),Reflect.deleteProperty(t,r),s(t.onDelete),s(t.onUpdate),!0}})}}{constructor(e={},r={},n={}){super(e,n),Object.keys(e).forEach((n=>{t(r[n])&&(e[n].default?this[n]=e[n].default:this[n]=r[n])})),this.feed(r)}feed(e){Object.keys(e).forEach((t=>{this[t]=e[t]}))}onBeforeGet(){}onBeforeSet(){}onBeforeUpdate(){}onDelete(){}onGet(){}onBeforeDelete(){}onSet(){}onUpdate(){}}u.settings={strict:!1,exceptions:!0},u.create=function(e,t,r,n){r=Object.assign({},u.settings,r);const o={[e]:class extends u{constructor(e){super(t,e,r)}}}[e];return o.checkErrors=function(e,r){const n={};return Object.keys(t).forEach((o=>{let i=c(t[o],o,e[o]);i.length&&(r&&(i=i.filter((e=>!s(r).includes(e.code)))),i.length&&(n[o]=i))})),!!Object.keys(n).length&&n},o.hydrate=function(e){return t=e,Array.isArray(t)?e.map((e=>new o(e))):new o(e);var t},Object.assign(o.prototype,n),o},e.default=u,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@jaysalvat/smart-model", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": "Javascript object model", | ||
@@ -5,0 +5,0 @@ "main": "./build/smart-model.umd.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49399
23
1309