Comparing version 1.0.28 to 1.0.29
@@ -1,2 +0,2 @@ | ||
"use strict";function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,s=_getPrototypeOf(e);if(t){var n=_getPrototypeOf(this).constructor;r=Reflect.construct(s,arguments,n)}else r=s.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,_toPropertyKey(s.key),s)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!==_typeof(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}!function(e){if("object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Manyfest=e()}}((function(){return function e(t,r,s){function n(o,i){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!i&&c)return c(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[o]={exports:{}};t[o][0].call(f.exports,(function(e){return n(t[o][1][e]||e)}),f,f.exports,e,t,r,s)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(e,t,r){var s=function(){function e(t,r,s){_classCallCheck(this,e),"object"===_typeof(t)&&t.isFable?this.connectFable(t):this.fable=!1,this.fable?(this.UUID=t.getUUID(),this.options="object"===_typeof(r)?r:{}):(this.options="object"!==_typeof(t)||t.isFable?"object"===_typeof(r)?r:{}:t,this.UUID="CORE-SVC-".concat(Math.floor(89999*Math.random()+1e4))),this.serviceType="Unknown-".concat(this.UUID),this.Hash="string"==typeof s?s:this.fable||"string"!=typeof r?"".concat(this.UUID):r}return _createClass(e,[{key:"connectFable",value:function(e){if("object"!==_typeof(e)||!e.isFable){var t="Fable Service Provider Base: Cannot connect to Fable, invalid Fable object passed in. The pFable parameter was a [".concat(_typeof(e),"].}");return console.log(t),new Error(t)}return this.fable||(this.fable=e),this.log||(this.log=this.fable.Logging),this.services||(this.services=this.fable.services),this.servicesMap||(this.servicesMap=this.fable.servicesMap),!0}}]),e}();_defineProperty(s,"isFableService",!0),t.exports=s,t.exports.CoreServiceProviderBase=s},{}],2:[function(e,t,r){t.exports=function(e,t){return t.startsWith(e)&&t.endsWith(e)?t.substring(1,t.length-1):t}},{}],3:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.translationTable={}}return _createClass(e,[{key:"translationCount",value:function(){return Object.keys(this.translationTable).length}},{key:"addTranslation",value:function(e){var t=this;if("object"!=_typeof(e))return this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(_typeof(e))),!1;Object.keys(e).forEach((function(r){"string"!=typeof e[r]?t.logError("Hash translation addTranslation expected a translation destination hash for [".concat(r,"] to be a string but the referrant was a ").concat(_typeof(e[r]))):t.translationTable[r]=e[r]}))}},{key:"removeTranslationHash",value:function(e){this.translationTable.hasOwnProperty(e)&&delete this.translationTable[e]}},{key:"removeTranslation",value:function(e){var t=this;return"string"==typeof e?(this.removeTranslationHash(e),!0):"object"==_typeof(e)?(Object.keys(e).forEach((function(e){t.removeTranslation(e)})),!0):(this.logError("Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ".concat(_typeof(e))),!1)}},{key:"clearTranslations",value:function(){this.translationTable={}}},{key:"translate",value:function(e){return this.translationTable.hasOwnProperty(e)?this.translationTable[e]:e}}]),e}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],4:[function(e,t,r){t.exports=function(e,t){var r="string"==typeof e?e:"";console.log("[Manyfest] ".concat(r)),t&&console.log(JSON.stringify(t))}},{}],5:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s}return _createClass(e,[{key:"checkAddressExists",value:function(e,t){if("object"!=_typeof(e))return!1;if("string"!=typeof t)return!1;var r=t.indexOf(".");if(-1==r){var s=t.indexOf("["),n=t.indexOf("]");if(s>0&&n>s&&n-s>1){var a=t.substring(0,s).trim();if("object"!==_typeof(e[a]))return!1;var o=t.substring(s+1,n).trim(),i=parseInt(o,10);return Array.isArray(e[a])!=isNaN(i)&&(isNaN(i)?(o=this.cleanWrapCharacters('"',o),o=this.cleanWrapCharacters("`",o),o=this.cleanWrapCharacters("'",o),e[a].hasOwnProperty(o)):i in e[a])}return e.hasOwnProperty(t)}var c=t.substring(0,r),l=t.substring(r+1),f=c.indexOf("["),u=c.indexOf("]");if(f>0&&u>f&&u-f>1){var h=c.substring(0,f).trim(),p=c.substring(f+1,u).trim(),d=parseInt(p,10);return Array.isArray(e[h])!=isNaN(d)&&(isNaN(d)?(p=this.cleanWrapCharacters('"',p),p=this.cleanWrapCharacters("`",p),p=this.cleanWrapCharacters("'",p),this.checkAddressExists(e[h][p],l)):this.checkAddressExists(e[h][d],l))}return(!e.hasOwnProperty(c)||"object"===_typeof(e[c]))&&(e.hasOwnProperty(c)||(e[c]={}),this.checkAddressExists(e[c],l))}}]),e}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],6:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=e("../source/Manyfest-ParseConditionals.js"),o=function(){function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}return _createClass(e,[{key:"checkFilters",value:function(e,t){return a(this,e,t)}},{key:"deleteValueAtAddress",value:function(e,t,r){if("object"==_typeof(e)&&"string"==typeof t){var s="";"string"==typeof r&&(s=r);var n=t.indexOf(".");if(-1==n){var a=t.indexOf("["),o=t.indexOf("]"),i=t.indexOf("{}");if(a>0&&o>a&&o-a>1){var c=t.substring(0,a).trim();if("object"!==_typeof(e[c]))return!1;var l=t.substring(a+1,o).trim(),f=parseInt(l,10);return Array.isArray(e[c])!=isNaN(f)&&(isNaN(f)?(l=this.cleanWrapCharacters('"',l),l=this.cleanWrapCharacters("`",l),l=this.cleanWrapCharacters("'",l),delete e[c][l],!0):(delete e[c][f],!0))}if(a>0&&o>a&&o-a==1){var u=t.substring(0,a).trim();if(!Array.isArray(e[u]))return!1;for(var h=e[u],p=h.length-1;p>=0;p--){this.checkFilters(t,h[p])&&h.splice(p,1)}return!0}if(i>0){var d=t.substring(0,i).trim();return"object"==_typeof(e[d])&&(delete e[d],!0)}return delete e[t],!0}var y=t.substring(0,n),b=t.substring(n+1),g=y.indexOf("["),v=y.indexOf("]");if(g>0&&v>g&&v-g>1){var A=y.substring(0,g).trim(),j=y.substring(g+1,v).trim(),O=parseInt(j,10);return Array.isArray(e[A])!=isNaN(O)&&("object"==_typeof(e[A])&&(isNaN(O)?(j=this.cleanWrapCharacters('"',j),j=this.cleanWrapCharacters("`",j),j=this.cleanWrapCharacters("'",j),s="".concat(s).concat(s.length>0?".":"").concat(y),this.deleteValueAtAddress(e[A][j],b,s)):(s="".concat(s).concat(s.length>0?".":"").concat(y),this.deleteValueAtAddress(e[A][O],b,s))))}if(g>0&&v>g&&v-g==1){var _=t.substring(0,g).trim();if(!Array.isArray(e[_]))return!1;var m=e[_];s="".concat(s).concat(s.length>0?".":"").concat(_);for(var C={},k=0;k<m.length;k++){var T="".concat(s,"[").concat(k,"]"),w=this.deleteValueAtAddress(e[_][k],b,T);C["".concat(T,".").concat(b)]=w}return C}var D=t.indexOf("{}");if(D>0){var E=t.substring(0,D).trim();if("object"!=_typeof(e[E]))return!1;var x=e[E],P=Object.keys(x);s="".concat(s).concat(s.length>0?".":"").concat(E);for(var M={},V=0;V<P.length;V++){var N="".concat(s,".").concat(P[V]),S=this.deleteValueAtAddress(e[E][P[V]],b,N);this.checkFilters(t,S)&&(M["".concat(N,".").concat(b)]=S)}return M}return e.hasOwnProperty(y)&&"object"!==_typeof(e[y])?void 0:e.hasOwnProperty(y)?(s="".concat(s).concat(s.length>0?".":"").concat(y),this.deleteValueAtAddress(e[y],b,s)):(s="".concat(s).concat(s.length>0?".":"").concat(y),e[y]={},this.deleteValueAtAddress(e[y],b,s))}}}]),e}();t.exports=o},{"../source/Manyfest-ParseConditionals.js":10,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],7:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=e("../source/Manyfest-ParseConditionals.js"),o=function(){function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}return _createClass(e,[{key:"checkFilters",value:function(e,t){return a(this,e,t)}},{key:"getValueAtAddress",value:function(e,t,r,s){if("object"==_typeof(e)&&"string"==typeof t){var n="";"string"==typeof r&&(n=r);var a=void 0===s?e:s,o=t.indexOf(".");if(0==o){for(var i=n.split("."),c=0,l=0;l<t.length&&"."==t.charAt(l);l++)c++;var f=i.length-c;if(f<0)return;var u=t.slice(c);return f>0&&(u="".concat(i.slice(0,f).join("."),".").concat(u)),this.logInfo("Back-navigation detected. Recursing back to address [".concat(u,"]")),this.getValueAtAddress(a,u)}if(-1==o){var h=t.indexOf("["),p=t.indexOf("]"),d=t.indexOf("{}");if(h>0&&p>h&&p-h>1){var y=t.substring(0,h).trim();if("object"!==_typeof(e[y]))return;var b=t.substring(h+1,p).trim(),g=parseInt(b,10);if(Array.isArray(e[y])==isNaN(g))return;return isNaN(g)?(b=this.cleanWrapCharacters('"',b),b=this.cleanWrapCharacters("`",b),b=this.cleanWrapCharacters("'",b),e[y][b]):e[y][g]}if(h>0&&p>h&&p-h==1){var v=t.substring(0,h).trim();if(!Array.isArray(e[v]))return!1;for(var A=e[v],j=[],O=0;O<A.length;O++){this.checkFilters(t,A[O])&&j.push(A[O])}return j}if(d>0){var _=t.substring(0,d).trim();return"object"==_typeof(e[_])&&e[_]}return null!=_typeof(e[t])?e[t]:void 0}var m=t.substring(0,o),C=t.substring(o+1),k=m.indexOf("["),T=m.indexOf("]");if(k>0&&T>k&&T-k>1){var w=m.substring(0,k).trim(),D=m.substring(k+1,T).trim(),E=parseInt(D,10);if(Array.isArray(e[w])==isNaN(E))return;if("object"!=_typeof(e[w]))return;return isNaN(E)?(D=this.cleanWrapCharacters('"',D),D=this.cleanWrapCharacters("`",D),D=this.cleanWrapCharacters("'",D),n="".concat(n).concat(n.length>0?".":"").concat(m),this.getValueAtAddress(e[w][D],C,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(m),this.getValueAtAddress(e[w][E],C,n,a))}if(k>0&&T>k&&T-k==1){var x=t.substring(0,k).trim();if(!Array.isArray(e[x]))return!1;var P=e[x];n="".concat(n).concat(n.length>0?".":"").concat(x);for(var M={},V=0;V<P.length;V++){var N="".concat(n,"[").concat(V,"]"),S=this.getValueAtAddress(e[x][V],C,N,a);M["".concat(N,".").concat(C)]=S}return M}var H=t.indexOf("{}");if(H>0){var I=t.substring(0,H).trim();if("object"!=_typeof(e[I]))return!1;var W=e[I],R=Object.keys(W);n="".concat(n).concat(n.length>0?".":"").concat(I);for(var L={},F=0;F<R.length;F++){var J="".concat(n,".").concat(R[F]),U=this.getValueAtAddress(e[I][R[F]],C,J,a);this.checkFilters(t,U)&&(L["".concat(J,".").concat(C)]=U)}return L}return e.hasOwnProperty(m)&&"object"!==_typeof(e[m])?void 0:e.hasOwnProperty(m)?(n="".concat(n).concat(n.length>0?".":"").concat(m),this.getValueAtAddress(e[m],C,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(m),e[m]={},this.getValueAtAddress(e[m],C,n,a))}}}]),e}();t.exports=o},{"../source/Manyfest-ParseConditionals.js":10,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],8:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=function(){function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}return _createClass(e,[{key:"setValueAtAddress",value:function(e,t,r){if("object"!=_typeof(e))return!1;if("string"!=typeof t)return!1;var s=t.indexOf(".");if(-1==s){var n=t.indexOf("["),a=t.indexOf("]");if(n>0&&a>n&&a-n>1){var o=t.substring(0,n).trim();if("object"!==_typeof(e[o]))return!1;var i=t.substring(n+1,a).trim(),c=parseInt(i,10);return Array.isArray(e[o])!=isNaN(c)&&(isNaN(c)?(i=this.cleanWrapCharacters('"',i),i=this.cleanWrapCharacters("`",i),i=this.cleanWrapCharacters("'",i),e[o][i]=r,!0):(e[o][c]=r,!0))}return e[t]=r,!0}var l=t.substring(0,s),f=t.substring(s+1),u=l.indexOf("["),h=l.indexOf("]");if(u>0&&h>u&&h-u>1){var p=l.substring(0,u).trim(),d=l.substring(u+1,h).trim(),y=parseInt(d,10);return Array.isArray(e[p])!=isNaN(y)&&(isNaN(y)?(d=this.cleanWrapCharacters('"',d),d=this.cleanWrapCharacters("`",d),d=this.cleanWrapCharacters("'",d),this.setValueAtAddress(e[p][d],f,r)):this.setValueAtAddress(e[p][y],f,r))}return e.hasOwnProperty(l)&&"object"!==_typeof(e[l])?(e.hasOwnProperty("__ERROR")||(e.__ERROR={}),e.__ERROR[t]=r,!1):(e.hasOwnProperty(l)||(e[l]={}),this.setValueAtAddress(e[l],f,r))}}]),e}();t.exports=a},{"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],9:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s}return _createClass(e,[{key:"generateAddressses",value:function(e,t,r){var s="string"==typeof t?t:"",n="object"==_typeof(r)?r:{},a=_typeof(e),o={Address:s,Hash:s,Name:s,InSchema:!1};switch("object"==a&&null==e&&(a="null"),a){case"string":o.DataType="String",o.Default=e,n[s]=o;break;case"number":case"bigint":o.DataType="Number",o.Default=e,n[s]=o;break;case"undefined":case"null":o.DataType="Any",o.Default=e,n[s]=o;break;case"object":if(Array.isArray(e)){o.DataType="Array",""!=s&&(n[s]=o);for(var i=0;i<e.length;i++)this.generateAddressses(e[i],"".concat(s,"[").concat(i,"]"),n)}else{o.DataType="Object",""!=s&&(n[s]=o,s+=".");for(var c=Object.keys(e),l=0;l<c.length;l++)this.generateAddressses(e[c[l]],"".concat(s).concat(c[l]),n)}}return n}}]),e}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],10:[function(e,t,r){var s="<<~?",n="?~>>",a=function(e,t,r,s,n){switch(s){case"!=":return e.getValueAtAddress(t,r)!=n;case"<":return e.getValueAtAddress(t,r)<n;case">":return e.getValueAtAddress(t,r)>n;case"<=":return e.getValueAtAddress(t,r)<=n;case">=":return e.getValueAtAddress(t,r)>=n;case"===":return e.getValueAtAddress(t,r)===n;default:return e.getValueAtAddress(t,r)==n}};t.exports=function(e,t,r){for(var o=!0,i=t.indexOf(s);-1!=i;){var c=t.indexOf(n,i+4);if(-1!=c){var l=t.substring(i+4,c).split(","),f=l[0],u=l[1],h=l[2];o=o&&a(e,r,f,u,h),i=t.indexOf(s,c+4)}else i=-1}return o}},{}],11:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s}return _createClass(e,[{key:"resolveAddressMappings",value:function(e,t){if("object"!=_typeof(e))return this.logError("Attempted to resolve address mapping but the descriptor was not an object."),!1;if("object"!=_typeof(t))return!0;var r=Object.keys(e),s={};return r.forEach((function(t){e[t].hasOwnProperty("Hash")&&(s[e[t].Hash]=t)})),Object.keys(t).forEach((function(r){var n=t[r],a=!1,o=!1;e.hasOwnProperty(r)?a=r:s.hasOwnProperty(r)&&(a=s[r]),a?(o=e[a],delete e[a]):o={Hash:r},e[n]=o})),!0}},{key:"safeResolveAddressMappings",value:function(e,t){var r=JSON.parse(JSON.stringify(e));return this.resolveAddressMappings(r,t),r}},{key:"mergeAddressMappings",value:function(e,t){if("object"!=_typeof(t)||"object"!=_typeof(e))return this.logError("Attempted to merge two schema descriptors but both were not objects."),!1;var r=JSON.parse(JSON.stringify(t)),s=JSON.parse(JSON.stringify(e));return Object.keys(r).forEach((function(e){s.hasOwnProperty(e)||(s[e]=r[e])})),s}}]),e}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],12:[function(e,t,r){var s=e("fable-serviceproviderbase"),n=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-HashTranslation.js"),o=e("./Manyfest-ObjectAddress-CheckAddressExists.js"),i=e("./Manyfest-ObjectAddress-GetValue.js"),c=e("./Manyfest-ObjectAddress-SetValue.js"),l=e("./Manyfest-ObjectAddress-DeleteValue.js"),f=e("./Manyfest-ObjectAddressGeneration.js"),u=e("./Manyfest-SchemaManipulation.js"),h={Scope:"DEFAULT",Descriptors:{}},p=function(e){_inherits(r,e);var t=_createSuper(r);function r(e,s,h){var p;return _classCallCheck(this,r),(p=void 0===e?t.call(this,{}):t.call(this,e,s,h)).serviceType="Manifest",p.logInfo=n,p.logError=n,p.objectAddressCheckAddressExists=new o(p.logInfo,p.logError),p.objectAddressGetValue=new i(p.logInfo,p.logError),p.objectAddressSetValue=new c(p.logInfo,p.logError),p.objectAddressDeleteValue=new l(p.logInfo,p.logError),p.options.hasOwnProperty("defaultValues")||(p.options.defaultValues={String:"",Number:0,Float:0,Integer:0,Boolean:!1,Binary:0,DateTime:0,Array:[],Object:{},Null:null}),p.options.hasOwnProperty("strict")||(p.options.strict=!1),p.scope=void 0,p.elementAddresses=void 0,p.elementHashes=void 0,p.elementDescriptors=void 0,p.reset(),"object"===_typeof(p.options)&&p.loadManifest(p.options),p.schemaManipulations=new u(p.logInfo,p.logError),p.objectAddressGeneration=new f(p.logInfo,p.logError),p.hashTranslations=new a(p.logInfo,p.logError),_possibleConstructorReturn(p)}return _createClass(r,[{key:"reset",value:function(){this.scope="DEFAULT",this.elementAddresses=[],this.elementHashes={},this.elementDescriptors={}}},{key:"clone",value:function(){var e=JSON.parse(JSON.stringify(this.options)),t=new r(this.getManifest(),this.logInfo,this.logError,e);return t.hashTranslations.addTranslation(this.hashTranslations.translationTable),t}},{key:"deserialize",value:function(e){return this.loadManifest(JSON.parse(e))}},{key:"loadManifest",value:function(e){"object"!==_typeof(e)&&this.logError("(".concat(this.scope,") Error loading manifest; expecting an object but parameter was type ").concat(_typeof(e),"."));for(var t="object"==_typeof(e)?e:{},r=Object.keys(h),s=0;s<r.length;s++)t.hasOwnProperty(r[s])||(t[r[s]]=JSON.parse(JSON.stringify(h[r[s]])));if(t.hasOwnProperty("Scope")?"string"==typeof t.Scope?this.scope=t.Scope:this.logError("(".concat(this.scope,") Error loading scope from manifest; expecting a string but property was type ").concat(_typeof(t.Scope),"."),t):this.logError("(".concat(this.scope,') Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.'),t),t.hasOwnProperty("Descriptors"))if("object"===_typeof(t.Descriptors))for(var n=Object.keys(t.Descriptors),a=0;a<n.length;a++)this.addDescriptor(n[a],t.Descriptors[n[a]]);else this.logError("(".concat(this.scope,") Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ").concat(_typeof(t.Descriptors),"."),t);else this.logError("(".concat(this.scope,') Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.'),t);if(t.hasOwnProperty("HashTranslations")&&"object"===_typeof(t.HashTranslations))for(var o=0;o<t.HashTranslations.length;o++);}},{key:"serialize",value:function(){return JSON.stringify(this.getManifest())}},{key:"getManifest",value:function(){return{Scope:this.scope,Descriptors:JSON.parse(JSON.stringify(this.elementDescriptors)),HashTranslations:JSON.parse(JSON.stringify(this.hashTranslations.translationTable))}}},{key:"addDescriptor",value:function(e,t){return"object"===_typeof(t)?(t.hasOwnProperty("Address")||(t.Address=e),this.elementDescriptors.hasOwnProperty(e)||this.elementAddresses.push(e),this.elementDescriptors[e]=t,this.elementHashes[e]=e,t.hasOwnProperty("Hash")?this.elementHashes[t.Hash]=e:t.Hash=e,!0):(this.logError("(".concat(this.scope,") Error loading object descriptor for address '").concat(e,"' from manifest object. Expecting an object but property was type ").concat(_typeof(t),".")),!1)}},{key:"getDescriptorByHash",value:function(e){return this.getDescriptor(this.resolveHashAddress(e))}},{key:"getDescriptor",value:function(e){return this.elementDescriptors[e]}},{key:"eachDescriptor",value:function(e){for(var t=Object.keys(this.elementDescriptors),r=0;r<t.length;r++)e(this.elementDescriptors[t[r]])}},{key:"checkAddressExistsByHash",value:function(e,t){return this.checkAddressExists(e,this.resolveHashAddress(t))}},{key:"checkAddressExists",value:function(e,t){return this.objectAddressCheckAddressExists.checkAddressExists(e,t)}},{key:"resolveHashAddress",value:function(e){var t=this.elementHashes.hasOwnProperty(e),r=this.hashTranslations.translationTable.hasOwnProperty(e);return t&&!r?this.elementHashes[e]:r&&this.elementHashes.hasOwnProperty(this.hashTranslations.translate(e))?this.elementHashes[this.hashTranslations.translate(e)]:r?this.hashTranslations.translate(e):e}},{key:"getValueByHash",value:function(e,t){var r=this.getValueAtAddress(e,this.resolveHashAddress(t));return void 0===r&&(r=this.getDefaultValue(this.getDescriptorByHash(t))),r}},{key:"getValueAtAddress",value:function(e,t){var r=this.objectAddressGetValue.getValueAtAddress(e,t);return void 0===r&&(r=this.getDefaultValue(this.getDescriptor(t))),r}},{key:"setValueByHash",value:function(e,t,r){return this.setValueAtAddress(e,this.resolveHashAddress(t),r)}},{key:"setValueAtAddress",value:function(e,t,r){return this.objectAddressSetValue.setValueAtAddress(e,t,r)}},{key:"deleteValueByHash",value:function(e,t,r){return this.deleteValueAtAddress(e,this.resolveHashAddress(t),r)}},{key:"deleteValueAtAddress",value:function(e,t,r){return this.objectAddressDeleteValue.deleteValueAtAddress(e,t,r)}},{key:"validate",value:function(e){var t={Error:null,Errors:[],MissingElements:[]};"object"!==_typeof(e)&&(t.Error=!0,t.Errors.push("Expected passed in object to be type object but was passed in ".concat(_typeof(e))));for(var r=function(e,r){t.Error=!0,t.Errors.push('Element at address "'.concat(e,'" ').concat(r,"."))},s=0;s<this.elementAddresses.length;s++){var n=this.getDescriptor(this.elementAddresses[s]),a=this.checkAddressExists(e,n.Address),o=this.getValueAtAddress(e,n.Address);if(void 0!==o&&a||(t.MissingElements.push(n.Address),(n.Required||this.options.strict)&&r(n.Address,"is flagged REQUIRED but is not set in the object")),n.DataType){var i=_typeof(o);switch(n.DataType.toString().trim().toLowerCase()){case"string":"string"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"number":"number"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"integer":if("number"!=i)r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));else o.toString().indexOf(".")>-1&&r(n.Address,"has a DataType ".concat(n.DataType," but has a decimal point in the number."));break;case"float":"number"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"DateTime":"Invalid Date"==new Date(o).toString()&&r(n.Address,"has a DataType ".concat(n.DataType," but is not parsable as a Date by Javascript"));default:"string"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," (which auto-converted to String because it was unrecognized) but is of the type ").concat(i))}}}return t}},{key:"getDefaultValue",value:function(e){if("object"==_typeof(e)){if(e.hasOwnProperty("Default"))return e.Default;var t=e.hasOwnProperty("DataType")?e.DataType:"String";return this.options.defaultValues.hasOwnProperty(t)?this.options.defaultValues[t]:null}}},{key:"populateDefaults",value:function(e,t){return this.populateObject(e,t,(function(e){return e.hasOwnProperty("Default")}))}},{key:"populateObject",value:function(e,t,r){var s=this,n="object"===_typeof(e)?e:{},a=void 0!==t&&t,o="function"==typeof r?r:function(e){return!0};return this.elementAddresses.forEach((function(e){var t=s.getDescriptor(e);o(t)&&(!a&&s.checkAddressExists(n,e)||s.setValueAtAddress(n,e,s.getDefaultValue(t)))})),n}}]),r}(s);t.exports=p},{"./Manyfest-HashTranslation.js":3,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-CheckAddressExists.js":5,"./Manyfest-ObjectAddress-DeleteValue.js":6,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-SetValue.js":8,"./Manyfest-ObjectAddressGeneration.js":9,"./Manyfest-SchemaManipulation.js":11,"fable-serviceproviderbase":1}]},{},[12])(12)})); | ||
"use strict";function _callSuper(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,_toPropertyKey(s.key),s)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=_typeof(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}!function(e){if("object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Manyfest=e()}}((function(){return function e(t,r,s){function n(o,i){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!i&&c)return c(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[o]={exports:{}};t[o][0].call(f.exports,(function(e){return n(t[o][1][e]||e)}),f,f.exports,e,t,r,s)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(e,t,r){var s=function(){return _createClass((function e(t,r,s){_classCallCheck(this,e),"object"===_typeof(t)&&t.isFable?this.connectFable(t):this.fable=!1,this.fable?(this.UUID=t.getUUID(),this.options="object"===_typeof(r)?r:{}):(this.options="object"!==_typeof(t)||t.isFable?"object"===_typeof(r)?r:{}:t,this.UUID="CORE-SVC-".concat(Math.floor(89999*Math.random()+1e4))),this.serviceType="Unknown-".concat(this.UUID),this.Hash="string"==typeof s?s:this.fable||"string"!=typeof r?"".concat(this.UUID):r}),[{key:"connectFable",value:function(e){if("object"!==_typeof(e)||!e.isFable){var t="Fable Service Provider Base: Cannot connect to Fable, invalid Fable object passed in. The pFable parameter was a [".concat(_typeof(e),"].}");return console.log(t),new Error(t)}return this.fable||(this.fable=e),this.log||(this.log=this.fable.Logging),this.services||(this.services=this.fable.services),this.servicesMap||(this.servicesMap=this.fable.servicesMap),!0}}])}();_defineProperty(s,"isFableService",!0),t.exports=s,t.exports.CoreServiceProviderBase=s},{}],2:[function(e,t,r){t.exports=function(e,t){return t.startsWith(e)&&t.endsWith(e)?t.substring(1,t.length-1):t}},{}],3:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.translationTable={}}),[{key:"translationCount",value:function(){return Object.keys(this.translationTable).length}},{key:"addTranslation",value:function(e){var t=this;if("object"!=_typeof(e))return this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(_typeof(e))),!1;Object.keys(e).forEach((function(r){"string"!=typeof e[r]?t.logError("Hash translation addTranslation expected a translation destination hash for [".concat(r,"] to be a string but the referrant was a ").concat(_typeof(e[r]))):t.translationTable[r]=e[r]}))}},{key:"removeTranslationHash",value:function(e){this.translationTable.hasOwnProperty(e)&&delete this.translationTable[e]}},{key:"removeTranslation",value:function(e){var t=this;return"string"==typeof e?(this.removeTranslationHash(e),!0):"object"==_typeof(e)?(Object.keys(e).forEach((function(e){t.removeTranslation(e)})),!0):(this.logError("Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ".concat(_typeof(e))),!1)}},{key:"clearTranslations",value:function(){this.translationTable={}}},{key:"translate",value:function(e){return this.translationTable.hasOwnProperty(e)?this.translationTable[e]:e}}])}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],4:[function(e,t,r){t.exports=function(e,t){var r="string"==typeof e?e:"";console.log("[Manyfest] ".concat(r)),t&&console.log(JSON.stringify(t))}},{}],5:[function(e,t,r){e("./Manyfest-LogToConsole.js");var s=function(){return _createClass((function e(){_classCallCheck(this,e)}),[{key:"checkAddressExists",value:function(e,t){if("object"!=_typeof(e))return!1;if("string"!=typeof t)return!1;var r=t.indexOf(".");if(-1==r){var s=t.indexOf("["),n=t.indexOf("]");if(s>0&&n>s&&n-s>1){var a=t.substring(0,s).trim();if("object"!==_typeof(e[a]))return!1;var o=t.substring(s+1,n).trim(),i=parseInt(o,10);return Array.isArray(e[a])!=isNaN(i)&&(isNaN(i)?(o=this.cleanWrapCharacters('"',o),o=this.cleanWrapCharacters("`",o),o=this.cleanWrapCharacters("'",o),e[a].hasOwnProperty(o)):i in e[a])}return e.hasOwnProperty(t)}var c=t.substring(0,r),l=t.substring(r+1),f=c.indexOf("["),u=c.indexOf("]");if(f>0&&u>f&&u-f>1){var h=c.substring(0,f).trim(),p=c.substring(f+1,u).trim(),d=parseInt(p,10);return Array.isArray(e[h])!=isNaN(d)&&(isNaN(d)?(p=this.cleanWrapCharacters('"',p),p=this.cleanWrapCharacters("`",p),p=this.cleanWrapCharacters("'",p),this.checkAddressExists(e[h][p],l)):this.checkAddressExists(e[h][d],l))}return(!e.hasOwnProperty(c)||"object"===_typeof(e[c]))&&(e.hasOwnProperty(c)||(e[c]={}),this.checkAddressExists(e[c],l))}}])}();t.exports=s},{"./Manyfest-LogToConsole.js":4}],6:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=e("../source/Manyfest-ParseConditionals.js"),o=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}),[{key:"checkRecordFilters",value:function(e,t){return a(this,e,t)}},{key:"deleteValueAtAddress",value:function(e,t,r){if("object"==_typeof(e)&&"string"==typeof t){var s="";"string"==typeof r&&(s=r);var n=t.indexOf(".");if(-1==n){var a=t.indexOf("["),o=t.indexOf("]"),i=t.indexOf("{}");if(a>0&&o>a&&o-a>1){var c=t.substring(0,a).trim();if("object"!==_typeof(e[c]))return!1;var l=t.substring(a+1,o).trim(),f=parseInt(l,10);return Array.isArray(e[c])!=isNaN(f)&&(isNaN(f)?(l=this.cleanWrapCharacters('"',l),l=this.cleanWrapCharacters("`",l),l=this.cleanWrapCharacters("'",l),delete e[c][l],!0):(delete e[c][f],!0))}if(a>0&&o>a&&o-a==1){var u=t.substring(0,a).trim();if(!Array.isArray(e[u]))return!1;for(var h=e[u],p=h.length-1;p>=0;p--){this.checkRecordFilters(t,h[p])&&h.splice(p,1)}return!0}if(i>0){var d=t.substring(0,i).trim();return"object"==_typeof(e[d])&&(delete e[d],!0)}return delete e[t],!0}var y=t.substring(0,n),g=t.substring(n+1),b=y.indexOf("["),v=y.indexOf("]");if(b>0&&v>b&&v-b>1){var A=y.substring(0,b).trim(),j=y.substring(b+1,v).trim(),O=parseInt(j,10);return Array.isArray(e[A])!=isNaN(O)&&("object"==_typeof(e[A])&&(isNaN(O)?(j=this.cleanWrapCharacters('"',j),j=this.cleanWrapCharacters("`",j),j=this.cleanWrapCharacters("'",j),s="".concat(s).concat(s.length>0?".":"").concat(y),this.deleteValueAtAddress(e[A][j],g,s)):(s="".concat(s).concat(s.length>0?".":"").concat(y),this.deleteValueAtAddress(e[A][O],g,s))))}if(b>0&&v>b&&v-b==1){var _=t.substring(0,b).trim();if(!Array.isArray(e[_]))return!1;var m=e[_];s="".concat(s).concat(s.length>0?".":"").concat(_);for(var C={},T=0;T<m.length;T++){var k="".concat(s,"[").concat(T,"]"),E=this.deleteValueAtAddress(e[_][T],g,k);C["".concat(k,".").concat(g)]=E}return C}var w=t.indexOf("{}");if(w>0){var D=t.substring(0,w).trim();if("object"!=_typeof(e[D]))return!1;var x=e[D],P=Object.keys(x);s="".concat(s).concat(s.length>0?".":"").concat(D);for(var M={},N=0;N<P.length;N++){var V="".concat(s,".").concat(P[N]),S=this.deleteValueAtAddress(e[D][P[N]],g,V);this.checkRecordFilters(t,S)&&(M["".concat(V,".").concat(g)]=S)}return M}return e.hasOwnProperty(y)&&"object"!==_typeof(e[y])?void 0:e.hasOwnProperty(y)?(s="".concat(s).concat(s.length>0?".":"").concat(y),this.deleteValueAtAddress(e[y],g,s)):(s="".concat(s).concat(s.length>0?".":"").concat(y),e[y]={},this.deleteValueAtAddress(e[y],g,s))}}}])}();t.exports=o},{"../source/Manyfest-ParseConditionals.js":10,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],7:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=e("../source/Manyfest-ParseConditionals.js"),o=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}),[{key:"checkRecordFilters",value:function(e,t){return a(this,e,t)}},{key:"getValueAtAddress",value:function(e,t,r,s){if("object"==_typeof(e)&&"string"==typeof t){var n="";"string"==typeof r&&(n=r);var a=void 0===s?e:s,o=t.indexOf(".");if(0==o){for(var i=n.split("."),c=0,l=0;l<t.length&&"."==t.charAt(l);l++)c++;var f=i.length-c;if(f<0)return;var u=t.slice(c);return f>0&&(u="".concat(i.slice(0,f).join("."),".").concat(u)),this.logInfo("Back-navigation detected. Recursing back to address [".concat(u,"]")),this.getValueAtAddress(a,u)}if(-1==o){var h=t.indexOf("["),p=t.indexOf("]"),d=t.indexOf("{}");if(h>0&&p>h&&p-h>1){var y=t.substring(0,h).trim();if("object"!==_typeof(e[y]))return;var g=t.substring(h+1,p).trim(),b=parseInt(g,10);if(Array.isArray(e[y])==isNaN(b))return;return isNaN(b)?(g=this.cleanWrapCharacters('"',g),g=this.cleanWrapCharacters("`",g),g=this.cleanWrapCharacters("'",g),e[y][g]):e[y][b]}if(h>0&&p>h&&p-h==1){var v=t.substring(0,h).trim();if(!Array.isArray(e[v]))return!1;for(var A=e[v],j=[],O=0;O<A.length;O++){this.checkRecordFilters(t,A[O])&&j.push(A[O])}return j}if(d>0){var _=t.substring(0,d).trim();return"object"==_typeof(e[_])&&e[_]}return null!=_typeof(e[t])?e[t]:void 0}var m=t.substring(0,o),C=t.substring(o+1),T=m.indexOf("["),k=m.indexOf("]");if(T>0&&k>T&&k-T>1){var E=m.substring(0,T).trim(),w=m.substring(T+1,k).trim(),D=parseInt(w,10);if(Array.isArray(e[E])==isNaN(D))return;if("object"!=_typeof(e[E]))return;return isNaN(D)?(w=this.cleanWrapCharacters('"',w),w=this.cleanWrapCharacters("`",w),w=this.cleanWrapCharacters("'",w),n="".concat(n).concat(n.length>0?".":"").concat(m),this.getValueAtAddress(e[E][w],C,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(m),this.getValueAtAddress(e[E][D],C,n,a))}if(T>0&&k>T&&k-T==1){var x=t.substring(0,T).trim();if(!Array.isArray(e[x]))return!1;var P=e[x];n="".concat(n).concat(n.length>0?".":"").concat(x);for(var M={},N=0;N<P.length;N++){var V="".concat(n,"[").concat(N,"]"),S=this.getValueAtAddress(e[x][N],C,V,a);M["".concat(V,".").concat(C)]=S}return M}var H=t.indexOf("{}");if(H>0){var I=t.substring(0,H).trim();if("object"!=_typeof(e[I]))return!1;var W=e[I],R=Object.keys(W);n="".concat(n).concat(n.length>0?".":"").concat(I);for(var L={},F=0;F<R.length;F++){var J="".concat(n,".").concat(R[F]),U=this.getValueAtAddress(e[I][R[F]],C,J,a);this.checkRecordFilters(t,U)&&(L["".concat(J,".").concat(C)]=U)}return L}return e.hasOwnProperty(m)&&"object"!==_typeof(e[m])?void 0:e.hasOwnProperty(m)?(n="".concat(n).concat(n.length>0?".":"").concat(m),this.getValueAtAddress(e[m],C,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(m),e[m]={},this.getValueAtAddress(e[m],C,n,a))}}}])}();t.exports=o},{"../source/Manyfest-ParseConditionals.js":10,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],8:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}),[{key:"setValueAtAddress",value:function(e,t,r){if("object"!=_typeof(e))return!1;if("string"!=typeof t)return!1;var s=t.indexOf(".");if(-1==s){var n=t.indexOf("["),a=t.indexOf("]");if(n>0&&a>n&&a-n>1){var o=t.substring(0,n).trim();if("object"!==_typeof(e[o]))return!1;var i=t.substring(n+1,a).trim(),c=parseInt(i,10);return Array.isArray(e[o])!=isNaN(c)&&(isNaN(c)?(i=this.cleanWrapCharacters('"',i),i=this.cleanWrapCharacters("`",i),i=this.cleanWrapCharacters("'",i),e[o][i]=r,!0):(e[o][c]=r,!0))}return e[t]=r,!0}var l=t.substring(0,s),f=t.substring(s+1),u=l.indexOf("["),h=l.indexOf("]");if(u>0&&h>u&&h-u>1){var p=l.substring(0,u).trim(),d=l.substring(u+1,h).trim(),y=parseInt(d,10);return Array.isArray(e[p])!=isNaN(y)&&(isNaN(y)?(d=this.cleanWrapCharacters('"',d),d=this.cleanWrapCharacters("`",d),d=this.cleanWrapCharacters("'",d),this.setValueAtAddress(e[p][d],f,r)):this.setValueAtAddress(e[p][y],f,r))}return e.hasOwnProperty(l)&&"object"!==_typeof(e[l])?(e.hasOwnProperty("__ERROR")||(e.__ERROR={}),e.__ERROR[t]=r,!1):(e.hasOwnProperty(l)||(e[l]={}),this.setValueAtAddress(e[l],f,r))}}])}();t.exports=a},{"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],9:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s}),[{key:"generateAddressses",value:function(e,t,r){var s="string"==typeof t?t:"",n="object"==_typeof(r)?r:{},a=_typeof(e),o={Address:s,Hash:s,Name:s,InSchema:!1};switch("object"==a&&null==e&&(a="null"),a){case"string":o.DataType="String",o.Default=e,n[s]=o;break;case"number":case"bigint":o.DataType="Number",o.Default=e,n[s]=o;break;case"undefined":case"null":o.DataType="Any",o.Default=e,n[s]=o;break;case"object":if(Array.isArray(e)){o.DataType="Array",""!=s&&(n[s]=o);for(var i=0;i<e.length;i++)this.generateAddressses(e[i],"".concat(s,"[").concat(i,"]"),n)}else{o.DataType="Object",""!=s&&(n[s]=o,s+=".");for(var c=Object.keys(e),l=0;l<c.length;l++)this.generateAddressses(e[c[l]],"".concat(s).concat(c[l]),n)}}return n}}])}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],10:[function(e,t,r){var s="<<~?",n="?~>>",a=new(e("./Manyfest-ObjectAddress-CheckAddressExists.js")),o=function(e,t,r,s,n){switch(s){case"TRUE":return!0===e.getValueAtAddress(t,r);case"FALSE":case"FALSE":return!1===e.getValueAtAddress(t,r);case"LNGT":case"LENGTH_GREATER_THAN":switch(_typeof(_typeof(e.getValueAtAddress(t,r)))){case"string":case"object":return e.getValueAtAddress(t,r).length>n;default:return!1}break;case"LNLT":case"LENGTH_LESS_THAN":switch(_typeof(_typeof(e.getValueAtAddress(t,r)))){case"string":case"object":return e.getValueAtAddress(t,r).length<n;default:return!1}break;case"EX":case"EXISTS":return a.checkAddressExists(t,r);case"DNEX":case"DOES_NOT_EXIST":return!a.checkAddressExists(t,r);case"!=":return e.getValueAtAddress(t,r)!=n;case"<":return e.getValueAtAddress(t,r)<n;case">":return e.getValueAtAddress(t,r)>n;case"<=":return e.getValueAtAddress(t,r)<=n;case">=":return e.getValueAtAddress(t,r)>=n;case"===":return e.getValueAtAddress(t,r)===n;default:return e.getValueAtAddress(t,r)==n}};t.exports=function(e,t,r){for(var a=!0,i=t.indexOf(s);-1!=i;){var c=t.indexOf(n,i+4);if(-1!=c){var l=t.substring(i+4,c).split(","),f=l[0],u="EXISTS";l.length>1&&(u=l[1]);var h=!1;l.length>2&&(h=l[2]),a=a&&o(e,r,f,u,h),i=t.indexOf(s,c+4)}else i=-1}return a}},{"./Manyfest-ObjectAddress-CheckAddressExists.js":5}],11:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s}),[{key:"resolveAddressMappings",value:function(e,t){if("object"!=_typeof(e))return this.logError("Attempted to resolve address mapping but the descriptor was not an object."),!1;if("object"!=_typeof(t))return!0;var r=Object.keys(e),s={};return r.forEach((function(t){e[t].hasOwnProperty("Hash")&&(s[e[t].Hash]=t)})),Object.keys(t).forEach((function(r){var n=t[r],a=!1,o=!1;e.hasOwnProperty(r)?a=r:s.hasOwnProperty(r)&&(a=s[r]),a?(o=e[a],delete e[a]):o={Hash:r},e[n]=o})),!0}},{key:"safeResolveAddressMappings",value:function(e,t){var r=JSON.parse(JSON.stringify(e));return this.resolveAddressMappings(r,t),r}},{key:"mergeAddressMappings",value:function(e,t){if("object"!=_typeof(t)||"object"!=_typeof(e))return this.logError("Attempted to merge two schema descriptors but both were not objects."),!1;var r=JSON.parse(JSON.stringify(t)),s=JSON.parse(JSON.stringify(e));return Object.keys(r).forEach((function(e){s.hasOwnProperty(e)||(s[e]=r[e])})),s}}])}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],12:[function(e,t,r){var s=e("fable-serviceproviderbase"),n=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-HashTranslation.js"),o=e("./Manyfest-ObjectAddress-CheckAddressExists.js"),i=e("./Manyfest-ObjectAddress-GetValue.js"),c=e("./Manyfest-ObjectAddress-SetValue.js"),l=e("./Manyfest-ObjectAddress-DeleteValue.js"),f=e("./Manyfest-ObjectAddressGeneration.js"),u=e("./Manyfest-SchemaManipulation.js"),h={Scope:"DEFAULT",Descriptors:{}},p=function(e){function t(e,r,s){var h;return _classCallCheck(this,t),(h=_callSuper(this,t,void 0===e?[{}]:[e,r,s])).serviceType="Manifest",h.logInfo=n,h.logError=n,h.objectAddressCheckAddressExists=new o(h.logInfo,h.logError),h.objectAddressGetValue=new i(h.logInfo,h.logError),h.objectAddressSetValue=new c(h.logInfo,h.logError),h.objectAddressDeleteValue=new l(h.logInfo,h.logError),h.options.hasOwnProperty("defaultValues")||(h.options.defaultValues={String:"",Number:0,Float:0,Integer:0,Boolean:!1,Binary:0,DateTime:0,Array:[],Object:{},Null:null}),h.options.hasOwnProperty("strict")||(h.options.strict=!1),h.scope=void 0,h.elementAddresses=void 0,h.elementHashes=void 0,h.elementDescriptors=void 0,h.reset(),"object"===_typeof(h.options)&&h.loadManifest(h.options),h.schemaManipulations=new u(h.logInfo,h.logError),h.objectAddressGeneration=new f(h.logInfo,h.logError),h.hashTranslations=new a(h.logInfo,h.logError),_assertThisInitialized(h)}return _inherits(t,e),_createClass(t,[{key:"reset",value:function(){this.scope="DEFAULT",this.elementAddresses=[],this.elementHashes={},this.elementDescriptors={}}},{key:"clone",value:function(){var e=JSON.parse(JSON.stringify(this.options)),r=new t(this.getManifest(),this.logInfo,this.logError,e);return r.hashTranslations.addTranslation(this.hashTranslations.translationTable),r}},{key:"deserialize",value:function(e){return this.loadManifest(JSON.parse(e))}},{key:"loadManifest",value:function(e){"object"!==_typeof(e)&&this.logError("(".concat(this.scope,") Error loading manifest; expecting an object but parameter was type ").concat(_typeof(e),"."));for(var t="object"==_typeof(e)?e:{},r=Object.keys(h),s=0;s<r.length;s++)t.hasOwnProperty(r[s])||(t[r[s]]=JSON.parse(JSON.stringify(h[r[s]])));if(t.hasOwnProperty("Scope")?"string"==typeof t.Scope?this.scope=t.Scope:this.logError("(".concat(this.scope,") Error loading scope from manifest; expecting a string but property was type ").concat(_typeof(t.Scope),"."),t):this.logError("(".concat(this.scope,') Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.'),t),t.hasOwnProperty("Descriptors"))if("object"===_typeof(t.Descriptors))for(var n=Object.keys(t.Descriptors),a=0;a<n.length;a++)this.addDescriptor(n[a],t.Descriptors[n[a]]);else this.logError("(".concat(this.scope,") Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ").concat(_typeof(t.Descriptors),"."),t);else this.logError("(".concat(this.scope,') Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.'),t);if(t.hasOwnProperty("HashTranslations")&&"object"===_typeof(t.HashTranslations))for(var o=0;o<t.HashTranslations.length;o++);}},{key:"serialize",value:function(){return JSON.stringify(this.getManifest())}},{key:"getManifest",value:function(){return{Scope:this.scope,Descriptors:JSON.parse(JSON.stringify(this.elementDescriptors)),HashTranslations:JSON.parse(JSON.stringify(this.hashTranslations.translationTable))}}},{key:"addDescriptor",value:function(e,t){return"object"===_typeof(t)?(t.hasOwnProperty("Address")||(t.Address=e),this.elementDescriptors.hasOwnProperty(e)||this.elementAddresses.push(e),this.elementDescriptors[e]=t,this.elementHashes[e]=e,t.hasOwnProperty("Hash")?this.elementHashes[t.Hash]=e:t.Hash=e,!0):(this.logError("(".concat(this.scope,") Error loading object descriptor for address '").concat(e,"' from manifest object. Expecting an object but property was type ").concat(_typeof(t),".")),!1)}},{key:"getDescriptorByHash",value:function(e){return this.getDescriptor(this.resolveHashAddress(e))}},{key:"getDescriptor",value:function(e){return this.elementDescriptors[e]}},{key:"eachDescriptor",value:function(e){for(var t=Object.keys(this.elementDescriptors),r=0;r<t.length;r++)e(this.elementDescriptors[t[r]])}},{key:"checkAddressExistsByHash",value:function(e,t){return this.checkAddressExists(e,this.resolveHashAddress(t))}},{key:"checkAddressExists",value:function(e,t){return this.objectAddressCheckAddressExists.checkAddressExists(e,t)}},{key:"resolveHashAddress",value:function(e){var t=this.elementHashes.hasOwnProperty(e),r=this.hashTranslations.translationTable.hasOwnProperty(e);return t&&!r?this.elementHashes[e]:r&&this.elementHashes.hasOwnProperty(this.hashTranslations.translate(e))?this.elementHashes[this.hashTranslations.translate(e)]:r?this.hashTranslations.translate(e):e}},{key:"getValueByHash",value:function(e,t){var r=this.getValueAtAddress(e,this.resolveHashAddress(t));return void 0===r&&(r=this.getDefaultValue(this.getDescriptorByHash(t))),r}},{key:"getValueAtAddress",value:function(e,t){var r=this.objectAddressGetValue.getValueAtAddress(e,t);return void 0===r&&(r=this.getDefaultValue(this.getDescriptor(t))),r}},{key:"setValueByHash",value:function(e,t,r){return this.setValueAtAddress(e,this.resolveHashAddress(t),r)}},{key:"setValueAtAddress",value:function(e,t,r){return this.objectAddressSetValue.setValueAtAddress(e,t,r)}},{key:"deleteValueByHash",value:function(e,t,r){return this.deleteValueAtAddress(e,this.resolveHashAddress(t),r)}},{key:"deleteValueAtAddress",value:function(e,t,r){return this.objectAddressDeleteValue.deleteValueAtAddress(e,t,r)}},{key:"validate",value:function(e){var t={Error:null,Errors:[],MissingElements:[]};"object"!==_typeof(e)&&(t.Error=!0,t.Errors.push("Expected passed in object to be type object but was passed in ".concat(_typeof(e))));for(var r=function(e,r){t.Error=!0,t.Errors.push('Element at address "'.concat(e,'" ').concat(r,"."))},s=0;s<this.elementAddresses.length;s++){var n=this.getDescriptor(this.elementAddresses[s]),a=this.checkAddressExists(e,n.Address),o=this.getValueAtAddress(e,n.Address);if(void 0!==o&&a||(t.MissingElements.push(n.Address),(n.Required||this.options.strict)&&r(n.Address,"is flagged REQUIRED but is not set in the object")),n.DataType){var i=_typeof(o);switch(n.DataType.toString().trim().toLowerCase()){case"string":"string"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"number":"number"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"integer":if("number"!=i)r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));else o.toString().indexOf(".")>-1&&r(n.Address,"has a DataType ".concat(n.DataType," but has a decimal point in the number."));break;case"float":"number"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"DateTime":"Invalid Date"==new Date(o).toString()&&r(n.Address,"has a DataType ".concat(n.DataType," but is not parsable as a Date by Javascript"));default:"string"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," (which auto-converted to String because it was unrecognized) but is of the type ").concat(i))}}}return t}},{key:"getDefaultValue",value:function(e){if("object"==_typeof(e)){if(e.hasOwnProperty("Default"))return e.Default;var t=e.hasOwnProperty("DataType")?e.DataType:"String";return this.options.defaultValues.hasOwnProperty(t)?this.options.defaultValues[t]:null}}},{key:"populateDefaults",value:function(e,t){return this.populateObject(e,t,(function(e){return e.hasOwnProperty("Default")}))}},{key:"populateObject",value:function(e,t,r){var s=this,n="object"===_typeof(e)?e:{},a=void 0!==t&&t,o="function"==typeof r?r:function(e){return!0};return this.elementAddresses.forEach((function(e){var t=s.getDescriptor(e);o(t)&&(!a&&s.checkAddressExists(n,e)||s.setValueAtAddress(n,e,s.getDefaultValue(t)))})),n}}])}(s);t.exports=p},{"./Manyfest-HashTranslation.js":3,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-CheckAddressExists.js":5,"./Manyfest-ObjectAddress-DeleteValue.js":6,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-SetValue.js":8,"./Manyfest-ObjectAddressGeneration.js":9,"./Manyfest-SchemaManipulation.js":11,"fable-serviceproviderbase":1}]},{},[12])(12)})); | ||
//# sourceMappingURL=manyfest.compatible.min.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";function _defineProperty(e,t,s){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==typeof t?t:String(t)}function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var r=s.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Manyfest=e()}}((function(){return function e(t,s,r){function a(o,i){if(!s[o]){if(!t[o]){var c="function"==typeof require&&require;if(!i&&c)return c(o,!0);if(n)return n(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var h=s[o]={exports:{}};t[o][0].call(h.exports,(function(e){return a(t[o][1][e]||e)}),h,h.exports,e,t,s,r)}return s[o].exports}for(var n="function"==typeof require&&require,o=0;o<r.length;o++)a(r[o]);return a}({1:[function(e,t,s){class r{constructor(e,t,s){"object"==typeof e&&e.isFable?this.connectFable(e):this.fable=!1,this.fable?(this.UUID=e.getUUID(),this.options="object"==typeof t?t:{}):(this.options="object"!=typeof e||e.isFable?"object"==typeof t?t:{}:e,this.UUID="CORE-SVC-".concat(Math.floor(89999*Math.random()+1e4))),this.serviceType="Unknown-".concat(this.UUID),this.Hash="string"==typeof s?s:this.fable||"string"!=typeof t?"".concat(this.UUID):t}connectFable(e){if("object"!=typeof e||!e.isFable){let t="Fable Service Provider Base: Cannot connect to Fable, invalid Fable object passed in. The pFable parameter was a [".concat(typeof e,"].}");return console.log(t),new Error(t)}return this.fable||(this.fable=e),this.log||(this.log=this.fable.Logging),this.services||(this.services=this.fable.services),this.servicesMap||(this.servicesMap=this.fable.servicesMap),!0}}_defineProperty(r,"isFableService",!0),t.exports=r,t.exports.CoreServiceProviderBase=r},{}],2:[function(e,t,s){t.exports=(e,t)=>t.startsWith(e)&&t.endsWith(e)?t.substring(1,t.length-1):t},{}],3:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r,this.translationTable={}}translationCount(){return Object.keys(this.translationTable).length}addTranslation(e){if("object"!=typeof e)return this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(typeof e)),!1;Object.keys(e).forEach((t=>{"string"!=typeof e[t]?this.logError("Hash translation addTranslation expected a translation destination hash for [".concat(t,"] to be a string but the referrant was a ").concat(typeof e[t])):this.translationTable[t]=e[t]}))}removeTranslationHash(e){this.translationTable.hasOwnProperty(e)&&delete this.translationTable[e]}removeTranslation(e){if("string"==typeof e)return this.removeTranslationHash(e),!0;if("object"==typeof e){return Object.keys(e).forEach((e=>{this.removeTranslation(e)})),!0}return this.logError("Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ".concat(typeof e)),!1}clearTranslations(){this.translationTable={}}translate(e){return this.translationTable.hasOwnProperty(e)?this.translationTable[e]:e}}},{"./Manyfest-LogToConsole.js":4}],4:[function(e,t,s){t.exports=(e,t)=>{let s="string"==typeof e?e:"";console.log("[Manyfest] ".concat(s)),t&&console.log(JSON.stringify(t))}},{}],5:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r}checkAddressExists(e,t){if("object"!=typeof e)return!1;if("string"!=typeof t)return!1;let s=t.indexOf(".");if(-1==s){let s=t.indexOf("["),r=t.indexOf("]");if(s>0&&r>s&&r-s>1){let a=t.substring(0,s).trim();if("object"!=typeof e[a])return!1;let n=t.substring(s+1,r).trim(),o=parseInt(n,10);return Array.isArray(e[a])!=isNaN(o)&&(isNaN(o)?(n=this.cleanWrapCharacters('"',n),n=this.cleanWrapCharacters("`",n),n=this.cleanWrapCharacters("'",n),e[a].hasOwnProperty(n)):o in e[a])}return e.hasOwnProperty(t)}{let r=t.substring(0,s),a=t.substring(s+1),n=r.indexOf("["),o=r.indexOf("]");if(n>0&&o>n&&o-n>1){let t=r.substring(0,n).trim(),s=r.substring(n+1,o).trim(),i=parseInt(s,10);return Array.isArray(e[t])!=isNaN(i)&&(isNaN(i)?(s=this.cleanWrapCharacters('"',s),s=this.cleanWrapCharacters("`",s),s=this.cleanWrapCharacters("'",s),this.checkAddressExists(e[t][s],a)):this.checkAddressExists(e[t][i],a))}return(!e.hasOwnProperty(r)||"object"==typeof e[r])&&(e.hasOwnProperty(r)||(e[r]={}),this.checkAddressExists(e[r],a))}}}},{"./Manyfest-LogToConsole.js":4}],6:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-CleanWrapCharacters.js"),n=e("../source/Manyfest-ParseConditionals.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r,this.cleanWrapCharacters=a}checkFilters(e,t){return n(this,e,t)}deleteValueAtAddress(e,t,s){if("object"!=typeof e)return;if("string"!=typeof t)return;let r="";"string"==typeof s&&(r=s);let a=t.indexOf(".");if(-1==a){let s=t.indexOf("["),r=t.indexOf("]"),a=t.indexOf("{}");if(s>0&&r>s&&r-s>1){let a=t.substring(0,s).trim();if("object"!=typeof e[a])return!1;let n=t.substring(s+1,r).trim(),o=parseInt(n,10);return Array.isArray(e[a])!=isNaN(o)&&(isNaN(o)?(n=this.cleanWrapCharacters('"',n),n=this.cleanWrapCharacters("`",n),n=this.cleanWrapCharacters("'",n),delete e[a][n],!0):(delete e[a][o],!0))}if(s>0&&r>s&&r-s==1){let r=t.substring(0,s).trim();if(!Array.isArray(e[r]))return!1;let a=e[r];for(let e=a.length-1;e>=0;e--){this.checkFilters(t,a[e])&&a.splice(e,1)}return!0}if(a>0){let s=t.substring(0,a).trim();return"object"==typeof e[s]&&(delete e[s],!0)}return delete e[t],!0}{let s=t.substring(0,a),n=t.substring(a+1),o=s.indexOf("["),i=s.indexOf("]");if(o>0&&i>o&&i-o>1){let t=s.substring(0,o).trim(),a=s.substring(o+1,i).trim(),c=parseInt(a,10);return Array.isArray(e[t])!=isNaN(c)&&("object"==typeof e[t]&&(isNaN(c)?(a=this.cleanWrapCharacters('"',a),a=this.cleanWrapCharacters("`",a),a=this.cleanWrapCharacters("'",a),r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(e[t][a],n,r)):(r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(e[t][c],n,r))))}if(o>0&&i>o&&i-o==1){let s=t.substring(0,o).trim();if(!Array.isArray(e[s]))return!1;let a=e[s];r="".concat(r).concat(r.length>0?".":"").concat(s);let i={};for(let t=0;t<a.length;t++){let a="".concat(r,"[").concat(t,"]"),o=this.deleteValueAtAddress(e[s][t],n,a);i["".concat(a,".").concat(n)]=o}return i}let c=t.indexOf("{}");if(c>0){let s=t.substring(0,c).trim();if("object"!=typeof e[s])return!1;let a=e[s],o=Object.keys(a);r="".concat(r).concat(r.length>0?".":"").concat(s);let i={};for(let a=0;a<o.length;a++){let c="".concat(r,".").concat(o[a]),l=this.deleteValueAtAddress(e[s][o[a]],n,c);this.checkFilters(t,l)&&(i["".concat(c,".").concat(n)]=l)}return i}return e.hasOwnProperty(s)&&"object"!=typeof e[s]?void 0:e.hasOwnProperty(s)?(r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(e[s],n,r)):(r="".concat(r).concat(r.length>0?".":"").concat(s),e[s]={},this.deleteValueAtAddress(e[s],n,r))}}}},{"../source/Manyfest-ParseConditionals.js":10,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],7:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-CleanWrapCharacters.js"),n=e("../source/Manyfest-ParseConditionals.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r,this.cleanWrapCharacters=a}checkFilters(e,t){return n(this,e,t)}getValueAtAddress(e,t,s,r){if("object"!=typeof e)return;if("string"!=typeof t)return;let a="";"string"==typeof s&&(a=s);let n=void 0===r?e:r,o=t.indexOf(".");if(0==o){let e=a.split("."),s=0;for(let e=0;e<t.length&&"."==t.charAt(e);e++)s++;let r=e.length-s;if(r<0)return;{let a=t.slice(s);return r>0&&(a="".concat(e.slice(0,r).join("."),".").concat(a)),this.logInfo("Back-navigation detected. Recursing back to address [".concat(a,"]")),this.getValueAtAddress(n,a)}}if(-1==o){let s=t.indexOf("["),r=t.indexOf("]"),a=t.indexOf("{}");if(s>0&&r>s&&r-s>1){let a=t.substring(0,s).trim();if("object"!=typeof e[a])return;let n=t.substring(s+1,r).trim(),o=parseInt(n,10);if(Array.isArray(e[a])==isNaN(o))return;return isNaN(o)?(n=this.cleanWrapCharacters('"',n),n=this.cleanWrapCharacters("`",n),n=this.cleanWrapCharacters("'",n),e[a][n]):e[a][o]}if(s>0&&r>s&&r-s==1){let r=t.substring(0,s).trim();if(!Array.isArray(e[r]))return!1;let a=e[r],n=[];for(let e=0;e<a.length;e++){this.checkFilters(t,a[e])&&n.push(a[e])}return n}if(a>0){let s=t.substring(0,a).trim();return"object"==typeof e[s]&&e[s]}return null!=typeof e[t]?e[t]:void 0}{let s=t.substring(0,o),r=t.substring(o+1),i=s.indexOf("["),c=s.indexOf("]");if(i>0&&c>i&&c-i>1){let t=s.substring(0,i).trim(),o=s.substring(i+1,c).trim(),l=parseInt(o,10);if(Array.isArray(e[t])==isNaN(l))return;if("object"!=typeof e[t])return;return isNaN(l)?(o=this.cleanWrapCharacters('"',o),o=this.cleanWrapCharacters("`",o),o=this.cleanWrapCharacters("'",o),a="".concat(a).concat(a.length>0?".":"").concat(s),this.getValueAtAddress(e[t][o],r,a,n)):(a="".concat(a).concat(a.length>0?".":"").concat(s),this.getValueAtAddress(e[t][l],r,a,n))}if(i>0&&c>i&&c-i==1){let s=t.substring(0,i).trim();if(!Array.isArray(e[s]))return!1;let o=e[s];a="".concat(a).concat(a.length>0?".":"").concat(s);let c={};for(let t=0;t<o.length;t++){let o="".concat(a,"[").concat(t,"]"),i=this.getValueAtAddress(e[s][t],r,o,n);c["".concat(o,".").concat(r)]=i}return c}let l=t.indexOf("{}");if(l>0){let s=t.substring(0,l).trim();if("object"!=typeof e[s])return!1;let o=e[s],i=Object.keys(o);a="".concat(a).concat(a.length>0?".":"").concat(s);let c={};for(let o=0;o<i.length;o++){let l="".concat(a,".").concat(i[o]),h=this.getValueAtAddress(e[s][i[o]],r,l,n);this.checkFilters(t,h)&&(c["".concat(l,".").concat(r)]=h)}return c}return e.hasOwnProperty(s)&&"object"!=typeof e[s]?void 0:e.hasOwnProperty(s)?(a="".concat(a).concat(a.length>0?".":"").concat(s),this.getValueAtAddress(e[s],r,a,n)):(a="".concat(a).concat(a.length>0?".":"").concat(s),e[s]={},this.getValueAtAddress(e[s],r,a,n))}}}},{"../source/Manyfest-ParseConditionals.js":10,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],8:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-CleanWrapCharacters.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r,this.cleanWrapCharacters=a}setValueAtAddress(e,t,s){if("object"!=typeof e)return!1;if("string"!=typeof t)return!1;let r=t.indexOf(".");if(-1==r){let r=t.indexOf("["),a=t.indexOf("]");if(r>0&&a>r&&a-r>1){let n=t.substring(0,r).trim();if("object"!=typeof e[n])return!1;let o=t.substring(r+1,a).trim(),i=parseInt(o,10);return Array.isArray(e[n])!=isNaN(i)&&(isNaN(i)?(o=this.cleanWrapCharacters('"',o),o=this.cleanWrapCharacters("`",o),o=this.cleanWrapCharacters("'",o),e[n][o]=s,!0):(e[n][i]=s,!0))}return e[t]=s,!0}{let a=t.substring(0,r),n=t.substring(r+1),o=a.indexOf("["),i=a.indexOf("]");if(o>0&&i>o&&i-o>1){let t=a.substring(0,o).trim(),r=a.substring(o+1,i).trim(),c=parseInt(r,10);return Array.isArray(e[t])!=isNaN(c)&&(isNaN(c)?(r=this.cleanWrapCharacters('"',r),r=this.cleanWrapCharacters("`",r),r=this.cleanWrapCharacters("'",r),this.setValueAtAddress(e[t][r],n,s)):this.setValueAtAddress(e[t][c],n,s))}return e.hasOwnProperty(a)&&"object"!=typeof e[a]?(e.hasOwnProperty("__ERROR")||(e.__ERROR={}),e.__ERROR[t]=s,!1):(e.hasOwnProperty(a)||(e[a]={}),this.setValueAtAddress(e[a],n,s))}}}},{"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],9:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r}generateAddressses(e,t,s){let r="string"==typeof t?t:"",a="object"==typeof s?s:{},n=typeof e,o={Address:r,Hash:r,Name:r,InSchema:!1};switch("object"==n&&null==e&&(n="null"),n){case"string":o.DataType="String",o.Default=e,a[r]=o;break;case"number":case"bigint":o.DataType="Number",o.Default=e,a[r]=o;break;case"undefined":case"null":o.DataType="Any",o.Default=e,a[r]=o;break;case"object":if(Array.isArray(e)){o.DataType="Array",""!=r&&(a[r]=o);for(let t=0;t<e.length;t++)this.generateAddressses(e[t],"".concat(r,"[").concat(t,"]"),a)}else{o.DataType="Object",""!=r&&(a[r]=o,r+=".");let t=Object.keys(e);for(let s=0;s<t.length;s++)this.generateAddressses(e[t[s]],"".concat(r).concat(t[s]),a)}}return a}}},{"./Manyfest-LogToConsole.js":4}],10:[function(e,t,s){const r="<<~?",a="?~>>",n=(e,t,s,r,a)=>{switch(r){case"!=":return e.getValueAtAddress(t,s)!=a;case"<":return e.getValueAtAddress(t,s)<a;case">":return e.getValueAtAddress(t,s)>a;case"<=":return e.getValueAtAddress(t,s)<=a;case">=":return e.getValueAtAddress(t,s)>=a;case"===":return e.getValueAtAddress(t,s)===a;default:return e.getValueAtAddress(t,s)==a}};t.exports=(e,t,s)=>{let o=!0,i=t.indexOf(r);for(;-1!=i;){let c=t.indexOf(a,i+4);if(-1!=c){let a=t.substring(i+4,c).split(","),l=a[0],h=a[1],f=a[2];o=o&&n(e,s,l,h,f),i=t.indexOf(r,c+4)}else i=-1}return o}},{}],11:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r}resolveAddressMappings(e,t){if("object"!=typeof e)return this.logError("Attempted to resolve address mapping but the descriptor was not an object."),!1;if("object"!=typeof t)return!0;let s=Object.keys(e),r={};return s.forEach((t=>{e[t].hasOwnProperty("Hash")&&(r[e[t].Hash]=t)})),Object.keys(t).forEach((s=>{let a=t[s],n=!1,o=!1;e.hasOwnProperty(s)?n=s:r.hasOwnProperty(s)&&(n=r[s]),n?(o=e[n],delete e[n]):o={Hash:s},e[a]=o})),!0}safeResolveAddressMappings(e,t){let s=JSON.parse(JSON.stringify(e));return this.resolveAddressMappings(s,t),s}mergeAddressMappings(e,t){if("object"!=typeof t||"object"!=typeof e)return this.logError("Attempted to merge two schema descriptors but both were not objects."),!1;let s=JSON.parse(JSON.stringify(t)),r=JSON.parse(JSON.stringify(e));return Object.keys(s).forEach((e=>{r.hasOwnProperty(e)||(r[e]=s[e])})),r}}},{"./Manyfest-LogToConsole.js":4}],12:[function(e,t,s){const r=e("fable-serviceproviderbase");let a=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-HashTranslation.js"),o=e("./Manyfest-ObjectAddress-CheckAddressExists.js"),i=e("./Manyfest-ObjectAddress-GetValue.js"),c=e("./Manyfest-ObjectAddress-SetValue.js"),l=e("./Manyfest-ObjectAddress-DeleteValue.js"),h=e("./Manyfest-ObjectAddressGeneration.js"),f=e("./Manyfest-SchemaManipulation.js");const d={Scope:"DEFAULT",Descriptors:{}};class p extends r{constructor(e,t,s){void 0===e?super({}):super(e,t,s),this.serviceType="Manifest",this.logInfo=a,this.logError=a,this.objectAddressCheckAddressExists=new o(this.logInfo,this.logError),this.objectAddressGetValue=new i(this.logInfo,this.logError),this.objectAddressSetValue=new c(this.logInfo,this.logError),this.objectAddressDeleteValue=new l(this.logInfo,this.logError),this.options.hasOwnProperty("defaultValues")||(this.options.defaultValues={String:"",Number:0,Float:0,Integer:0,Boolean:!1,Binary:0,DateTime:0,Array:[],Object:{},Null:null}),this.options.hasOwnProperty("strict")||(this.options.strict=!1),this.scope=void 0,this.elementAddresses=void 0,this.elementHashes=void 0,this.elementDescriptors=void 0,this.reset(),"object"==typeof this.options&&this.loadManifest(this.options),this.schemaManipulations=new f(this.logInfo,this.logError),this.objectAddressGeneration=new h(this.logInfo,this.logError),this.hashTranslations=new n(this.logInfo,this.logError)}reset(){this.scope="DEFAULT",this.elementAddresses=[],this.elementHashes={},this.elementDescriptors={}}clone(){let e=JSON.parse(JSON.stringify(this.options)),t=new p(this.getManifest(),this.logInfo,this.logError,e);return t.hashTranslations.addTranslation(this.hashTranslations.translationTable),t}deserialize(e){return this.loadManifest(JSON.parse(e))}loadManifest(e){"object"!=typeof e&&this.logError("(".concat(this.scope,") Error loading manifest; expecting an object but parameter was type ").concat(typeof e,"."));let t="object"==typeof e?e:{},s=Object.keys(d);for(let e=0;e<s.length;e++)t.hasOwnProperty(s[e])||(t[s[e]]=JSON.parse(JSON.stringify(d[s[e]])));if(t.hasOwnProperty("Scope")?"string"==typeof t.Scope?this.scope=t.Scope:this.logError("(".concat(this.scope,") Error loading scope from manifest; expecting a string but property was type ").concat(typeof t.Scope,"."),t):this.logError("(".concat(this.scope,') Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.'),t),t.hasOwnProperty("Descriptors"))if("object"==typeof t.Descriptors){let e=Object.keys(t.Descriptors);for(let s=0;s<e.length;s++)this.addDescriptor(e[s],t.Descriptors[e[s]])}else this.logError("(".concat(this.scope,") Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ").concat(typeof t.Descriptors,"."),t);else this.logError("(".concat(this.scope,') Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.'),t);if(t.hasOwnProperty("HashTranslations")&&"object"==typeof t.HashTranslations)for(let e=0;e<t.HashTranslations.length;e++);}serialize(){return JSON.stringify(this.getManifest())}getManifest(){return{Scope:this.scope,Descriptors:JSON.parse(JSON.stringify(this.elementDescriptors)),HashTranslations:JSON.parse(JSON.stringify(this.hashTranslations.translationTable))}}addDescriptor(e,t){return"object"==typeof t?(t.hasOwnProperty("Address")||(t.Address=e),this.elementDescriptors.hasOwnProperty(e)||this.elementAddresses.push(e),this.elementDescriptors[e]=t,this.elementHashes[e]=e,t.hasOwnProperty("Hash")?this.elementHashes[t.Hash]=e:t.Hash=e,!0):(this.logError("(".concat(this.scope,") Error loading object descriptor for address '").concat(e,"' from manifest object. Expecting an object but property was type ").concat(typeof t,".")),!1)}getDescriptorByHash(e){return this.getDescriptor(this.resolveHashAddress(e))}getDescriptor(e){return this.elementDescriptors[e]}eachDescriptor(e){let t=Object.keys(this.elementDescriptors);for(let s=0;s<t.length;s++)e(this.elementDescriptors[t[s]])}checkAddressExistsByHash(e,t){return this.checkAddressExists(e,this.resolveHashAddress(t))}checkAddressExists(e,t){return this.objectAddressCheckAddressExists.checkAddressExists(e,t)}resolveHashAddress(e){let t,s=this.elementHashes.hasOwnProperty(e),r=this.hashTranslations.translationTable.hasOwnProperty(e);return t=s&&!r?this.elementHashes[e]:r&&this.elementHashes.hasOwnProperty(this.hashTranslations.translate(e))?this.elementHashes[this.hashTranslations.translate(e)]:r?this.hashTranslations.translate(e):e,t}getValueByHash(e,t){let s=this.getValueAtAddress(e,this.resolveHashAddress(t));return void 0===s&&(s=this.getDefaultValue(this.getDescriptorByHash(t))),s}getValueAtAddress(e,t){let s=this.objectAddressGetValue.getValueAtAddress(e,t);return void 0===s&&(s=this.getDefaultValue(this.getDescriptor(t))),s}setValueByHash(e,t,s){return this.setValueAtAddress(e,this.resolveHashAddress(t),s)}setValueAtAddress(e,t,s){return this.objectAddressSetValue.setValueAtAddress(e,t,s)}deleteValueByHash(e,t,s){return this.deleteValueAtAddress(e,this.resolveHashAddress(t),s)}deleteValueAtAddress(e,t,s){return this.objectAddressDeleteValue.deleteValueAtAddress(e,t,s)}validate(e){let t={Error:null,Errors:[],MissingElements:[]};"object"!=typeof e&&(t.Error=!0,t.Errors.push("Expected passed in object to be type object but was passed in ".concat(typeof e)));let s=(e,s)=>{t.Error=!0,t.Errors.push('Element at address "'.concat(e,'" ').concat(s,"."))};for(let r=0;r<this.elementAddresses.length;r++){let a=this.getDescriptor(this.elementAddresses[r]),n=this.checkAddressExists(e,a.Address),o=this.getValueAtAddress(e,a.Address);if(void 0!==o&&n||(t.MissingElements.push(a.Address),(a.Required||this.options.strict)&&s(a.Address,"is flagged REQUIRED but is not set in the object")),a.DataType){let e=typeof o;switch(a.DataType.toString().trim().toLowerCase()){case"string":"string"!=e&&s(a.Address,"has a DataType ".concat(a.DataType," but is of the type ").concat(e));break;case"number":"number"!=e&&s(a.Address,"has a DataType ".concat(a.DataType," but is of the type ").concat(e));break;case"integer":if("number"!=e)s(a.Address,"has a DataType ".concat(a.DataType," but is of the type ").concat(e));else{o.toString().indexOf(".")>-1&&s(a.Address,"has a DataType ".concat(a.DataType," but has a decimal point in the number."))}break;case"float":"number"!=e&&s(a.Address,"has a DataType ".concat(a.DataType," but is of the type ").concat(e));break;case"DateTime":"Invalid Date"==new Date(o).toString()&&s(a.Address,"has a DataType ".concat(a.DataType," but is not parsable as a Date by Javascript"));default:"string"!=e&&s(a.Address,"has a DataType ".concat(a.DataType," (which auto-converted to String because it was unrecognized) but is of the type ").concat(e))}}}return t}getDefaultValue(e){if("object"==typeof e){if(e.hasOwnProperty("Default"))return e.Default;{let t=e.hasOwnProperty("DataType")?e.DataType:"String";return this.options.defaultValues.hasOwnProperty(t)?this.options.defaultValues[t]:null}}}populateDefaults(e,t){return this.populateObject(e,t,(e=>e.hasOwnProperty("Default")))}populateObject(e,t,s){let r="object"==typeof e?e:{},a=void 0!==t&&t,n="function"==typeof s?s:e=>!0;return this.elementAddresses.forEach((e=>{let t=this.getDescriptor(e);n(t)&&(!a&&this.checkAddressExists(r,e)||this.setValueAtAddress(r,e,this.getDefaultValue(t)))})),r}}t.exports=p},{"./Manyfest-HashTranslation.js":3,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-CheckAddressExists.js":5,"./Manyfest-ObjectAddress-DeleteValue.js":6,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-SetValue.js":8,"./Manyfest-ObjectAddressGeneration.js":9,"./Manyfest-SchemaManipulation.js":11,"fable-serviceproviderbase":1}]},{},[12])(12)})); | ||
"use strict";function _defineProperty(e,t,s){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==typeof t?t:t+""}function _toPrimitive(e,t){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var r=s.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Manyfest=e()}}((function(){return function e(t,s,r){function a(o,i){if(!s[o]){if(!t[o]){var c="function"==typeof require&&require;if(!i&&c)return c(o,!0);if(n)return n(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var h=s[o]={exports:{}};t[o][0].call(h.exports,(function(e){return a(t[o][1][e]||e)}),h,h.exports,e,t,s,r)}return s[o].exports}for(var n="function"==typeof require&&require,o=0;o<r.length;o++)a(r[o]);return a}({1:[function(e,t,s){class r{constructor(e,t,s){"object"==typeof e&&e.isFable?this.connectFable(e):this.fable=!1,this.fable?(this.UUID=e.getUUID(),this.options="object"==typeof t?t:{}):(this.options="object"!=typeof e||e.isFable?"object"==typeof t?t:{}:e,this.UUID="CORE-SVC-".concat(Math.floor(89999*Math.random()+1e4))),this.serviceType="Unknown-".concat(this.UUID),this.Hash="string"==typeof s?s:this.fable||"string"!=typeof t?"".concat(this.UUID):t}connectFable(e){if("object"!=typeof e||!e.isFable){let t="Fable Service Provider Base: Cannot connect to Fable, invalid Fable object passed in. The pFable parameter was a [".concat(typeof e,"].}");return console.log(t),new Error(t)}return this.fable||(this.fable=e),this.log||(this.log=this.fable.Logging),this.services||(this.services=this.fable.services),this.servicesMap||(this.servicesMap=this.fable.servicesMap),!0}}_defineProperty(r,"isFableService",!0),t.exports=r,t.exports.CoreServiceProviderBase=r},{}],2:[function(e,t,s){t.exports=(e,t)=>t.startsWith(e)&&t.endsWith(e)?t.substring(1,t.length-1):t},{}],3:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r,this.translationTable={}}translationCount(){return Object.keys(this.translationTable).length}addTranslation(e){if("object"!=typeof e)return this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(typeof e)),!1;Object.keys(e).forEach((t=>{"string"!=typeof e[t]?this.logError("Hash translation addTranslation expected a translation destination hash for [".concat(t,"] to be a string but the referrant was a ").concat(typeof e[t])):this.translationTable[t]=e[t]}))}removeTranslationHash(e){this.translationTable.hasOwnProperty(e)&&delete this.translationTable[e]}removeTranslation(e){if("string"==typeof e)return this.removeTranslationHash(e),!0;if("object"==typeof e){return Object.keys(e).forEach((e=>{this.removeTranslation(e)})),!0}return this.logError("Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ".concat(typeof e)),!1}clearTranslations(){this.translationTable={}}translate(e){return this.translationTable.hasOwnProperty(e)?this.translationTable[e]:e}}},{"./Manyfest-LogToConsole.js":4}],4:[function(e,t,s){t.exports=(e,t)=>{let s="string"==typeof e?e:"";console.log("[Manyfest] ".concat(s)),t&&console.log(JSON.stringify(t))}},{}],5:[function(e,t,s){e("./Manyfest-LogToConsole.js");t.exports=class{constructor(){}checkAddressExists(e,t){if("object"!=typeof e)return!1;if("string"!=typeof t)return!1;let s=t.indexOf(".");if(-1==s){let s=t.indexOf("["),r=t.indexOf("]");if(s>0&&r>s&&r-s>1){let a=t.substring(0,s).trim();if("object"!=typeof e[a])return!1;let n=t.substring(s+1,r).trim(),o=parseInt(n,10);return Array.isArray(e[a])!=isNaN(o)&&(isNaN(o)?(n=this.cleanWrapCharacters('"',n),n=this.cleanWrapCharacters("`",n),n=this.cleanWrapCharacters("'",n),e[a].hasOwnProperty(n)):o in e[a])}return e.hasOwnProperty(t)}{let r=t.substring(0,s),a=t.substring(s+1),n=r.indexOf("["),o=r.indexOf("]");if(n>0&&o>n&&o-n>1){let t=r.substring(0,n).trim(),s=r.substring(n+1,o).trim(),i=parseInt(s,10);return Array.isArray(e[t])!=isNaN(i)&&(isNaN(i)?(s=this.cleanWrapCharacters('"',s),s=this.cleanWrapCharacters("`",s),s=this.cleanWrapCharacters("'",s),this.checkAddressExists(e[t][s],a)):this.checkAddressExists(e[t][i],a))}return(!e.hasOwnProperty(r)||"object"==typeof e[r])&&(e.hasOwnProperty(r)||(e[r]={}),this.checkAddressExists(e[r],a))}}}},{"./Manyfest-LogToConsole.js":4}],6:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-CleanWrapCharacters.js"),n=e("../source/Manyfest-ParseConditionals.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r,this.cleanWrapCharacters=a}checkRecordFilters(e,t){return n(this,e,t)}deleteValueAtAddress(e,t,s){if("object"!=typeof e)return;if("string"!=typeof t)return;let r="";"string"==typeof s&&(r=s);let a=t.indexOf(".");if(-1==a){let s=t.indexOf("["),r=t.indexOf("]"),a=t.indexOf("{}");if(s>0&&r>s&&r-s>1){let a=t.substring(0,s).trim();if("object"!=typeof e[a])return!1;let n=t.substring(s+1,r).trim(),o=parseInt(n,10);return Array.isArray(e[a])!=isNaN(o)&&(isNaN(o)?(n=this.cleanWrapCharacters('"',n),n=this.cleanWrapCharacters("`",n),n=this.cleanWrapCharacters("'",n),delete e[a][n],!0):(delete e[a][o],!0))}if(s>0&&r>s&&r-s==1){let r=t.substring(0,s).trim();if(!Array.isArray(e[r]))return!1;let a=e[r];for(let e=a.length-1;e>=0;e--){this.checkRecordFilters(t,a[e])&&a.splice(e,1)}return!0}if(a>0){let s=t.substring(0,a).trim();return"object"==typeof e[s]&&(delete e[s],!0)}return delete e[t],!0}{let s=t.substring(0,a),n=t.substring(a+1),o=s.indexOf("["),i=s.indexOf("]");if(o>0&&i>o&&i-o>1){let t=s.substring(0,o).trim(),a=s.substring(o+1,i).trim(),c=parseInt(a,10);return Array.isArray(e[t])!=isNaN(c)&&("object"==typeof e[t]&&(isNaN(c)?(a=this.cleanWrapCharacters('"',a),a=this.cleanWrapCharacters("`",a),a=this.cleanWrapCharacters("'",a),r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(e[t][a],n,r)):(r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(e[t][c],n,r))))}if(o>0&&i>o&&i-o==1){let s=t.substring(0,o).trim();if(!Array.isArray(e[s]))return!1;let a=e[s];r="".concat(r).concat(r.length>0?".":"").concat(s);let i={};for(let t=0;t<a.length;t++){let a="".concat(r,"[").concat(t,"]"),o=this.deleteValueAtAddress(e[s][t],n,a);i["".concat(a,".").concat(n)]=o}return i}let c=t.indexOf("{}");if(c>0){let s=t.substring(0,c).trim();if("object"!=typeof e[s])return!1;let a=e[s],o=Object.keys(a);r="".concat(r).concat(r.length>0?".":"").concat(s);let i={};for(let a=0;a<o.length;a++){let c="".concat(r,".").concat(o[a]),l=this.deleteValueAtAddress(e[s][o[a]],n,c);this.checkRecordFilters(t,l)&&(i["".concat(c,".").concat(n)]=l)}return i}return e.hasOwnProperty(s)&&"object"!=typeof e[s]?void 0:e.hasOwnProperty(s)?(r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(e[s],n,r)):(r="".concat(r).concat(r.length>0?".":"").concat(s),e[s]={},this.deleteValueAtAddress(e[s],n,r))}}}},{"../source/Manyfest-ParseConditionals.js":10,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],7:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-CleanWrapCharacters.js"),n=e("../source/Manyfest-ParseConditionals.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r,this.cleanWrapCharacters=a}checkRecordFilters(e,t){return n(this,e,t)}getValueAtAddress(e,t,s,r){if("object"!=typeof e)return;if("string"!=typeof t)return;let a="";"string"==typeof s&&(a=s);let n=void 0===r?e:r,o=t.indexOf(".");if(0==o){let e=a.split("."),s=0;for(let e=0;e<t.length&&"."==t.charAt(e);e++)s++;let r=e.length-s;if(r<0)return;{let a=t.slice(s);return r>0&&(a="".concat(e.slice(0,r).join("."),".").concat(a)),this.logInfo("Back-navigation detected. Recursing back to address [".concat(a,"]")),this.getValueAtAddress(n,a)}}if(-1==o){let s=t.indexOf("["),r=t.indexOf("]"),a=t.indexOf("{}");if(s>0&&r>s&&r-s>1){let a=t.substring(0,s).trim();if("object"!=typeof e[a])return;let n=t.substring(s+1,r).trim(),o=parseInt(n,10);if(Array.isArray(e[a])==isNaN(o))return;return isNaN(o)?(n=this.cleanWrapCharacters('"',n),n=this.cleanWrapCharacters("`",n),n=this.cleanWrapCharacters("'",n),e[a][n]):e[a][o]}if(s>0&&r>s&&r-s==1){let r=t.substring(0,s).trim();if(!Array.isArray(e[r]))return!1;let a=e[r],n=[];for(let e=0;e<a.length;e++){this.checkRecordFilters(t,a[e])&&n.push(a[e])}return n}if(a>0){let s=t.substring(0,a).trim();return"object"==typeof e[s]&&e[s]}return null!=typeof e[t]?e[t]:void 0}{let s=t.substring(0,o),r=t.substring(o+1),i=s.indexOf("["),c=s.indexOf("]");if(i>0&&c>i&&c-i>1){let t=s.substring(0,i).trim(),o=s.substring(i+1,c).trim(),l=parseInt(o,10);if(Array.isArray(e[t])==isNaN(l))return;if("object"!=typeof e[t])return;return isNaN(l)?(o=this.cleanWrapCharacters('"',o),o=this.cleanWrapCharacters("`",o),o=this.cleanWrapCharacters("'",o),a="".concat(a).concat(a.length>0?".":"").concat(s),this.getValueAtAddress(e[t][o],r,a,n)):(a="".concat(a).concat(a.length>0?".":"").concat(s),this.getValueAtAddress(e[t][l],r,a,n))}if(i>0&&c>i&&c-i==1){let s=t.substring(0,i).trim();if(!Array.isArray(e[s]))return!1;let o=e[s];a="".concat(a).concat(a.length>0?".":"").concat(s);let c={};for(let t=0;t<o.length;t++){let o="".concat(a,"[").concat(t,"]"),i=this.getValueAtAddress(e[s][t],r,o,n);c["".concat(o,".").concat(r)]=i}return c}let l=t.indexOf("{}");if(l>0){let s=t.substring(0,l).trim();if("object"!=typeof e[s])return!1;let o=e[s],i=Object.keys(o);a="".concat(a).concat(a.length>0?".":"").concat(s);let c={};for(let o=0;o<i.length;o++){let l="".concat(a,".").concat(i[o]),h=this.getValueAtAddress(e[s][i[o]],r,l,n);this.checkRecordFilters(t,h)&&(c["".concat(l,".").concat(r)]=h)}return c}return e.hasOwnProperty(s)&&"object"!=typeof e[s]?void 0:e.hasOwnProperty(s)?(a="".concat(a).concat(a.length>0?".":"").concat(s),this.getValueAtAddress(e[s],r,a,n)):(a="".concat(a).concat(a.length>0?".":"").concat(s),e[s]={},this.getValueAtAddress(e[s],r,a,n))}}}},{"../source/Manyfest-ParseConditionals.js":10,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],8:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-CleanWrapCharacters.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r,this.cleanWrapCharacters=a}setValueAtAddress(e,t,s){if("object"!=typeof e)return!1;if("string"!=typeof t)return!1;let r=t.indexOf(".");if(-1==r){let r=t.indexOf("["),a=t.indexOf("]");if(r>0&&a>r&&a-r>1){let n=t.substring(0,r).trim();if("object"!=typeof e[n])return!1;let o=t.substring(r+1,a).trim(),i=parseInt(o,10);return Array.isArray(e[n])!=isNaN(i)&&(isNaN(i)?(o=this.cleanWrapCharacters('"',o),o=this.cleanWrapCharacters("`",o),o=this.cleanWrapCharacters("'",o),e[n][o]=s,!0):(e[n][i]=s,!0))}return e[t]=s,!0}{let a=t.substring(0,r),n=t.substring(r+1),o=a.indexOf("["),i=a.indexOf("]");if(o>0&&i>o&&i-o>1){let t=a.substring(0,o).trim(),r=a.substring(o+1,i).trim(),c=parseInt(r,10);return Array.isArray(e[t])!=isNaN(c)&&(isNaN(c)?(r=this.cleanWrapCharacters('"',r),r=this.cleanWrapCharacters("`",r),r=this.cleanWrapCharacters("'",r),this.setValueAtAddress(e[t][r],n,s)):this.setValueAtAddress(e[t][c],n,s))}return e.hasOwnProperty(a)&&"object"!=typeof e[a]?(e.hasOwnProperty("__ERROR")||(e.__ERROR={}),e.__ERROR[t]=s,!1):(e.hasOwnProperty(a)||(e[a]={}),this.setValueAtAddress(e[a],n,s))}}}},{"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],9:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r}generateAddressses(e,t,s){let r="string"==typeof t?t:"",a="object"==typeof s?s:{},n=typeof e,o={Address:r,Hash:r,Name:r,InSchema:!1};switch("object"==n&&null==e&&(n="null"),n){case"string":o.DataType="String",o.Default=e,a[r]=o;break;case"number":case"bigint":o.DataType="Number",o.Default=e,a[r]=o;break;case"undefined":case"null":o.DataType="Any",o.Default=e,a[r]=o;break;case"object":if(Array.isArray(e)){o.DataType="Array",""!=r&&(a[r]=o);for(let t=0;t<e.length;t++)this.generateAddressses(e[t],"".concat(r,"[").concat(t,"]"),a)}else{o.DataType="Object",""!=r&&(a[r]=o,r+=".");let t=Object.keys(e);for(let s=0;s<t.length;s++)this.generateAddressses(e[t[s]],"".concat(r).concat(t[s]),a)}}return a}}},{"./Manyfest-LogToConsole.js":4}],10:[function(e,t,s){const r="<<~?",a="?~>>";let n=new(e("./Manyfest-ObjectAddress-CheckAddressExists.js"));const o=(e,t,s,r,a)=>{switch(r){case"TRUE":return!0===e.getValueAtAddress(t,s);case"FALSE":case"FALSE":return!1===e.getValueAtAddress(t,s);case"LNGT":case"LENGTH_GREATER_THAN":switch(typeof typeof e.getValueAtAddress(t,s)){case"string":case"object":return e.getValueAtAddress(t,s).length>a;default:return!1}break;case"LNLT":case"LENGTH_LESS_THAN":switch(typeof typeof e.getValueAtAddress(t,s)){case"string":case"object":return e.getValueAtAddress(t,s).length<a;default:return!1}break;case"EX":case"EXISTS":return n.checkAddressExists(t,s);case"DNEX":case"DOES_NOT_EXIST":return!n.checkAddressExists(t,s);case"!=":return e.getValueAtAddress(t,s)!=a;case"<":return e.getValueAtAddress(t,s)<a;case">":return e.getValueAtAddress(t,s)>a;case"<=":return e.getValueAtAddress(t,s)<=a;case">=":return e.getValueAtAddress(t,s)>=a;case"===":return e.getValueAtAddress(t,s)===a;default:return e.getValueAtAddress(t,s)==a}};t.exports=(e,t,s)=>{let n=!0,i=t.indexOf(r);for(;-1!=i;){let c=t.indexOf(a,i+4);if(-1!=c){let a=t.substring(i+4,c).split(","),l=a[0],h="EXISTS";a.length>1&&(h=a[1]);let d=!1;a.length>2&&(d=a[2]),n=n&&o(e,s,l,h,d),i=t.indexOf(r,c+4)}else i=-1}return n}},{"./Manyfest-ObjectAddress-CheckAddressExists.js":5}],11:[function(e,t,s){let r=e("./Manyfest-LogToConsole.js");t.exports=class{constructor(e,t){this.logInfo="function"==typeof e?e:r,this.logError="function"==typeof t?t:r}resolveAddressMappings(e,t){if("object"!=typeof e)return this.logError("Attempted to resolve address mapping but the descriptor was not an object."),!1;if("object"!=typeof t)return!0;let s=Object.keys(e),r={};return s.forEach((t=>{e[t].hasOwnProperty("Hash")&&(r[e[t].Hash]=t)})),Object.keys(t).forEach((s=>{let a=t[s],n=!1,o=!1;e.hasOwnProperty(s)?n=s:r.hasOwnProperty(s)&&(n=r[s]),n?(o=e[n],delete e[n]):o={Hash:s},e[a]=o})),!0}safeResolveAddressMappings(e,t){let s=JSON.parse(JSON.stringify(e));return this.resolveAddressMappings(s,t),s}mergeAddressMappings(e,t){if("object"!=typeof t||"object"!=typeof e)return this.logError("Attempted to merge two schema descriptors but both were not objects."),!1;let s=JSON.parse(JSON.stringify(t)),r=JSON.parse(JSON.stringify(e));return Object.keys(s).forEach((e=>{r.hasOwnProperty(e)||(r[e]=s[e])})),r}}},{"./Manyfest-LogToConsole.js":4}],12:[function(e,t,s){const r=e("fable-serviceproviderbase");let a=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-HashTranslation.js"),o=e("./Manyfest-ObjectAddress-CheckAddressExists.js"),i=e("./Manyfest-ObjectAddress-GetValue.js"),c=e("./Manyfest-ObjectAddress-SetValue.js"),l=e("./Manyfest-ObjectAddress-DeleteValue.js"),h=e("./Manyfest-ObjectAddressGeneration.js"),d=e("./Manyfest-SchemaManipulation.js");const f={Scope:"DEFAULT",Descriptors:{}};class p extends r{constructor(e,t,s){void 0===e?super({}):super(e,t,s),this.serviceType="Manifest",this.logInfo=a,this.logError=a,this.objectAddressCheckAddressExists=new o(this.logInfo,this.logError),this.objectAddressGetValue=new i(this.logInfo,this.logError),this.objectAddressSetValue=new c(this.logInfo,this.logError),this.objectAddressDeleteValue=new l(this.logInfo,this.logError),this.options.hasOwnProperty("defaultValues")||(this.options.defaultValues={String:"",Number:0,Float:0,Integer:0,Boolean:!1,Binary:0,DateTime:0,Array:[],Object:{},Null:null}),this.options.hasOwnProperty("strict")||(this.options.strict=!1),this.scope=void 0,this.elementAddresses=void 0,this.elementHashes=void 0,this.elementDescriptors=void 0,this.reset(),"object"==typeof this.options&&this.loadManifest(this.options),this.schemaManipulations=new d(this.logInfo,this.logError),this.objectAddressGeneration=new h(this.logInfo,this.logError),this.hashTranslations=new n(this.logInfo,this.logError)}reset(){this.scope="DEFAULT",this.elementAddresses=[],this.elementHashes={},this.elementDescriptors={}}clone(){let e=JSON.parse(JSON.stringify(this.options)),t=new p(this.getManifest(),this.logInfo,this.logError,e);return t.hashTranslations.addTranslation(this.hashTranslations.translationTable),t}deserialize(e){return this.loadManifest(JSON.parse(e))}loadManifest(e){"object"!=typeof e&&this.logError("(".concat(this.scope,") Error loading manifest; expecting an object but parameter was type ").concat(typeof e,"."));let t="object"==typeof e?e:{},s=Object.keys(f);for(let e=0;e<s.length;e++)t.hasOwnProperty(s[e])||(t[s[e]]=JSON.parse(JSON.stringify(f[s[e]])));if(t.hasOwnProperty("Scope")?"string"==typeof t.Scope?this.scope=t.Scope:this.logError("(".concat(this.scope,") Error loading scope from manifest; expecting a string but property was type ").concat(typeof t.Scope,"."),t):this.logError("(".concat(this.scope,') Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.'),t),t.hasOwnProperty("Descriptors"))if("object"==typeof t.Descriptors){let e=Object.keys(t.Descriptors);for(let s=0;s<e.length;s++)this.addDescriptor(e[s],t.Descriptors[e[s]])}else this.logError("(".concat(this.scope,") Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ").concat(typeof t.Descriptors,"."),t);else this.logError("(".concat(this.scope,') Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.'),t);if(t.hasOwnProperty("HashTranslations")&&"object"==typeof t.HashTranslations)for(let e=0;e<t.HashTranslations.length;e++);}serialize(){return JSON.stringify(this.getManifest())}getManifest(){return{Scope:this.scope,Descriptors:JSON.parse(JSON.stringify(this.elementDescriptors)),HashTranslations:JSON.parse(JSON.stringify(this.hashTranslations.translationTable))}}addDescriptor(e,t){return"object"==typeof t?(t.hasOwnProperty("Address")||(t.Address=e),this.elementDescriptors.hasOwnProperty(e)||this.elementAddresses.push(e),this.elementDescriptors[e]=t,this.elementHashes[e]=e,t.hasOwnProperty("Hash")?this.elementHashes[t.Hash]=e:t.Hash=e,!0):(this.logError("(".concat(this.scope,") Error loading object descriptor for address '").concat(e,"' from manifest object. Expecting an object but property was type ").concat(typeof t,".")),!1)}getDescriptorByHash(e){return this.getDescriptor(this.resolveHashAddress(e))}getDescriptor(e){return this.elementDescriptors[e]}eachDescriptor(e){let t=Object.keys(this.elementDescriptors);for(let s=0;s<t.length;s++)e(this.elementDescriptors[t[s]])}checkAddressExistsByHash(e,t){return this.checkAddressExists(e,this.resolveHashAddress(t))}checkAddressExists(e,t){return this.objectAddressCheckAddressExists.checkAddressExists(e,t)}resolveHashAddress(e){let t,s=this.elementHashes.hasOwnProperty(e),r=this.hashTranslations.translationTable.hasOwnProperty(e);return t=s&&!r?this.elementHashes[e]:r&&this.elementHashes.hasOwnProperty(this.hashTranslations.translate(e))?this.elementHashes[this.hashTranslations.translate(e)]:r?this.hashTranslations.translate(e):e,t}getValueByHash(e,t){let s=this.getValueAtAddress(e,this.resolveHashAddress(t));return void 0===s&&(s=this.getDefaultValue(this.getDescriptorByHash(t))),s}getValueAtAddress(e,t){let s=this.objectAddressGetValue.getValueAtAddress(e,t);return void 0===s&&(s=this.getDefaultValue(this.getDescriptor(t))),s}setValueByHash(e,t,s){return this.setValueAtAddress(e,this.resolveHashAddress(t),s)}setValueAtAddress(e,t,s){return this.objectAddressSetValue.setValueAtAddress(e,t,s)}deleteValueByHash(e,t,s){return this.deleteValueAtAddress(e,this.resolveHashAddress(t),s)}deleteValueAtAddress(e,t,s){return this.objectAddressDeleteValue.deleteValueAtAddress(e,t,s)}validate(e){let t={Error:null,Errors:[],MissingElements:[]};"object"!=typeof e&&(t.Error=!0,t.Errors.push("Expected passed in object to be type object but was passed in ".concat(typeof e)));let s=(e,s)=>{t.Error=!0,t.Errors.push('Element at address "'.concat(e,'" ').concat(s,"."))};for(let r=0;r<this.elementAddresses.length;r++){let a=this.getDescriptor(this.elementAddresses[r]),n=this.checkAddressExists(e,a.Address),o=this.getValueAtAddress(e,a.Address);if(void 0!==o&&n||(t.MissingElements.push(a.Address),(a.Required||this.options.strict)&&s(a.Address,"is flagged REQUIRED but is not set in the object")),a.DataType){let e=typeof o;switch(a.DataType.toString().trim().toLowerCase()){case"string":"string"!=e&&s(a.Address,"has a DataType ".concat(a.DataType," but is of the type ").concat(e));break;case"number":"number"!=e&&s(a.Address,"has a DataType ".concat(a.DataType," but is of the type ").concat(e));break;case"integer":if("number"!=e)s(a.Address,"has a DataType ".concat(a.DataType," but is of the type ").concat(e));else{o.toString().indexOf(".")>-1&&s(a.Address,"has a DataType ".concat(a.DataType," but has a decimal point in the number."))}break;case"float":"number"!=e&&s(a.Address,"has a DataType ".concat(a.DataType," but is of the type ").concat(e));break;case"DateTime":"Invalid Date"==new Date(o).toString()&&s(a.Address,"has a DataType ".concat(a.DataType," but is not parsable as a Date by Javascript"));default:"string"!=e&&s(a.Address,"has a DataType ".concat(a.DataType," (which auto-converted to String because it was unrecognized) but is of the type ").concat(e))}}}return t}getDefaultValue(e){if("object"==typeof e){if(e.hasOwnProperty("Default"))return e.Default;{let t=e.hasOwnProperty("DataType")?e.DataType:"String";return this.options.defaultValues.hasOwnProperty(t)?this.options.defaultValues[t]:null}}}populateDefaults(e,t){return this.populateObject(e,t,(e=>e.hasOwnProperty("Default")))}populateObject(e,t,s){let r="object"==typeof e?e:{},a=void 0!==t&&t,n="function"==typeof s?s:e=>!0;return this.elementAddresses.forEach((e=>{let t=this.getDescriptor(e);n(t)&&(!a&&this.checkAddressExists(r,e)||this.setValueAtAddress(r,e,this.getDefaultValue(t)))})),r}}t.exports=p},{"./Manyfest-HashTranslation.js":3,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-CheckAddressExists.js":5,"./Manyfest-ObjectAddress-DeleteValue.js":6,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-SetValue.js":8,"./Manyfest-ObjectAddressGeneration.js":9,"./Manyfest-SchemaManipulation.js":11,"fable-serviceproviderbase":1}]},{},[12])(12)})); | ||
//# sourceMappingURL=manyfest.min.js.map |
{ | ||
"name": "manyfest", | ||
"version": "1.0.28", | ||
"version": "1.0.29", | ||
"description": "JSON Object Manifest for Data Description and Parsing", | ||
@@ -47,6 +47,6 @@ "main": "source/Manyfest.js", | ||
"dependencies": { | ||
"fable-serviceproviderbase": "^3.0.12" | ||
"fable-serviceproviderbase": "^3.0.13" | ||
}, | ||
"devDependencies": { | ||
"quackage": "^1.0.25" | ||
"quackage": "^1.0.29" | ||
}, | ||
@@ -53,0 +53,0 @@ "author": "steven velozo <steven@velozo.com>", |
@@ -26,7 +26,4 @@ /** | ||
{ | ||
constructor(pInfoLog, pErrorLog) | ||
constructor() | ||
{ | ||
// Wire in logging | ||
this.logInfo = (typeof(pInfoLog) == 'function') ? pInfoLog : libSimpleLog; | ||
this.logError = (typeof(pErrorLog) == 'function') ? pErrorLog : libSimpleLog; | ||
} | ||
@@ -33,0 +30,0 @@ |
@@ -40,3 +40,3 @@ /** | ||
// TODO: Dry me | ||
checkFilters(pAddress, pRecord) | ||
checkRecordFilters(pAddress, pRecord) | ||
{ | ||
@@ -155,3 +155,3 @@ return fParseConditionals(this, pAddress, pRecord); | ||
// The filtering is complex but allows config-based metaprogramming directly from schema | ||
let tmpKeepRecord = this.checkFilters(pAddress, tmpInputArray[i]); | ||
let tmpKeepRecord = this.checkRecordFilters(pAddress, tmpInputArray[i]); | ||
if (tmpKeepRecord) | ||
@@ -324,3 +324,3 @@ { | ||
// The filtering is complex but allows config-based metaprogramming directly from schema | ||
let tmpKeepRecord = this.checkFilters(pAddress, tmpValue); | ||
let tmpKeepRecord = this.checkRecordFilters(pAddress, tmpValue); | ||
if (tmpKeepRecord) | ||
@@ -327,0 +327,0 @@ { |
@@ -39,3 +39,3 @@ /** | ||
checkFilters(pAddress, pRecord) | ||
checkRecordFilters(pAddress, pRecord) | ||
{ | ||
@@ -197,3 +197,3 @@ return fParseConditionals(this, pAddress, pRecord); | ||
// The filtering is complex but allows config-based metaprogramming directly from schema | ||
let tmpKeepRecord = this.checkFilters(pAddress, tmpInputArray[i]); | ||
let tmpKeepRecord = this.checkRecordFilters(pAddress, tmpInputArray[i]); | ||
if (tmpKeepRecord) | ||
@@ -371,3 +371,3 @@ { | ||
// The filtering is complex but allows config-based metaprogramming directly from schema | ||
let tmpKeepRecord = this.checkFilters(pAddress, tmpValue); | ||
let tmpKeepRecord = this.checkRecordFilters(pAddress, tmpValue); | ||
if (tmpKeepRecord) | ||
@@ -374,0 +374,0 @@ { |
@@ -20,2 +20,5 @@ // Given a string, parse out any conditional expressions and set whether or not to keep the record. | ||
// Ugh dependency injection. Can't wait to make these all fable services. | ||
let libObjectAddressCheckAddressExists = new (require('./Manyfest-ObjectAddress-CheckAddressExists.js'))(); | ||
// Test the condition of a value in a record | ||
@@ -26,2 +29,49 @@ const testCondition = (pManyfest, pRecord, pSearchAddress, pSearchComparator, pValue) => | ||
{ | ||
case 'TRUE': | ||
return (pManyfest.getValueAtAddress(pRecord, pSearchAddress) === true); | ||
break; | ||
case 'FALSE': | ||
return (pManyfest.getValueAtAddress(pRecord, pSearchAddress) === false); | ||
break; | ||
case 'LNGT': | ||
case 'LENGTH_GREATER_THAN': | ||
switch(typeof(typeof(pManyfest.getValueAtAddress(pRecord, pSearchAddress)))) | ||
{ | ||
case 'string': | ||
return (pManyfest.getValueAtAddress(pRecord, pSearchAddress).length > pValue); | ||
break; | ||
case 'object': | ||
return (pManyfest.getValueAtAddress(pRecord, pSearchAddress).length > pValue); | ||
break; | ||
default: | ||
return false; | ||
break; | ||
} | ||
break; | ||
case 'LNLT': | ||
case 'LENGTH_LESS_THAN': | ||
switch(typeof(typeof(pManyfest.getValueAtAddress(pRecord, pSearchAddress)))) | ||
{ | ||
case 'string': | ||
return (pManyfest.getValueAtAddress(pRecord, pSearchAddress).length < pValue); | ||
break; | ||
case 'object': | ||
return (pManyfest.getValueAtAddress(pRecord, pSearchAddress).length < pValue); | ||
break; | ||
default: | ||
return false; | ||
break; | ||
} | ||
break; | ||
case 'FALSE': | ||
return (pManyfest.getValueAtAddress(pRecord, pSearchAddress) === false); | ||
break; | ||
case 'EX': | ||
case 'EXISTS': | ||
return libObjectAddressCheckAddressExists.checkAddressExists(pRecord, pSearchAddress); | ||
break; | ||
case 'DNEX': | ||
case 'DOES_NOT_EXIST': | ||
return !libObjectAddressCheckAddressExists.checkAddressExists(pRecord, pSearchAddress); | ||
break; | ||
case '!=': | ||
@@ -60,3 +110,2 @@ return (pManyfest.getValueAtAddress(pRecord, pSearchAddress) != pValue); | ||
1. Enuerate start points | ||
2. Find stop points within each start point | ||
@@ -76,6 +125,19 @@ 3. Check the conditional | ||
// The address to search for | ||
let tmpSearchAddress = tmpMagicComparisonPatternSet[0]; | ||
let tmpSearchComparator = tmpMagicComparisonPatternSet[1]; | ||
let tmpSearchValue = tmpMagicComparisonPatternSet[2]; | ||
// The copmparison expression (EXISTS as default) | ||
let tmpSearchComparator = 'EXISTS'; | ||
if (tmpMagicComparisonPatternSet.length > 1) | ||
{ | ||
tmpSearchComparator = tmpMagicComparisonPatternSet[1]; | ||
} | ||
// The value to search for | ||
let tmpSearchValue = false; | ||
if (tmpMagicComparisonPatternSet.length > 2) | ||
{ | ||
tmpSearchValue = tmpMagicComparisonPatternSet[2]; | ||
} | ||
// Process the piece | ||
@@ -82,0 +144,0 @@ tmpKeepRecord = tmpKeepRecord && testCondition(pManyfest, pRecord, tmpSearchAddress, tmpSearchComparator, tmpSearchValue); |
@@ -130,3 +130,4 @@ { | ||
"format": "Item Tile", | ||
"rotation": "0" | ||
"rotation": "0", | ||
"thumbnail": true | ||
}, | ||
@@ -155,3 +156,4 @@ { | ||
"height": "480", | ||
"width": "640" | ||
"width": "640", | ||
"thumbnail": false | ||
}, | ||
@@ -158,0 +160,0 @@ { |
@@ -54,3 +54,3 @@ /** | ||
( | ||
'Magic filters should be magic.', | ||
'Magic filters should be able to process non equality filters.', | ||
(fTestComplete)=> | ||
@@ -63,2 +63,50 @@ { | ||
{ | ||
'files[]<<~?length,EXISTS?~>>': {Name:'Files With a length Property', Hash:'FilesWithLength'}, | ||
'files[]<<~?length,DNEX?~>>': {Name:'Files Without a length Property', Hash:'FilesWithoutLength'}, | ||
'files[]<<~?length,DNEX?~>><<~?source,==,original?~>>': {Name:'Original Files With a length Property', Hash:'OriginalFilesWithLength'}, | ||
'files[]<<~?thumbnail,EXISTS?~>>': {Name:'Thumbnail Bit is Explicitly Set', Hash:'ThumbnailExplicitlySet'}, | ||
'files[]<<~?thumbnail,TRUE?~>>': {Name:'Thumbnail Files', Hash:'ThumbnailFiles'}, | ||
'files[]<<~?thumbnail,FALSE?~>>': {Name:'Not Thumbnail Files', Hash:'NotThumbnailFiles'} | ||
} | ||
}); | ||
// Grab magic filtered thumbnails | ||
// Also, the "thumbnail" property was added to the data later ... it's not actually from archive.org but I wanted to test this feature. | ||
let tmpThumbnailFiles = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'ThumbnailFiles'); | ||
Expect(tmpThumbnailFiles).to.be.an('array'); | ||
Expect(tmpThumbnailFiles.length).to.equal(1); | ||
let tmpNotThumbnailFiles = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'NotThumbnailFiles'); | ||
Expect(tmpNotThumbnailFiles).to.be.an('array'); | ||
Expect(tmpNotThumbnailFiles.length).to.equal(1); | ||
let tmpFilesWithLength = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'FilesWithLength'); | ||
Expect(tmpFilesWithLength).to.be.an('array'); | ||
Expect(tmpFilesWithLength.length).to.equal(3); | ||
let tmpOGFilesWithLength = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'OriginalFilesWithLength'); | ||
Expect(tmpOGFilesWithLength).to.be.an('array'); | ||
Expect(tmpOGFilesWithLength.length).to.equal(2); | ||
let tmpFilesWithoutLength = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'FilesWithoutLength'); | ||
Expect(tmpFilesWithoutLength).to.be.an('array'); | ||
Expect(tmpFilesWithoutLength.length).to.equal(14); | ||
let tmpExplicitlyExists = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'ThumbnailExplicitlySet'); | ||
Expect(tmpExplicitlyExists).to.be.an('array'); | ||
Expect(tmpExplicitlyExists.length).to.equal(2); | ||
fTestComplete(); | ||
} | ||
); | ||
test | ||
( | ||
'Magic filters should be magic and process equality filters.', | ||
(fTestComplete)=> | ||
{ | ||
let _Manyfest = new libManyfest( | ||
{ | ||
Scope:'Archive.org', | ||
Descriptors: | ||
{ | ||
'files[]': {Name:'Files', Hash:'FileSet'}, | ||
@@ -65,0 +113,0 @@ 'files[]<<~?format,==,Thumbnail?~>>': {Name:'Thumbnail Files', Hash:'ThumbnailFiles'}, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
980489
8775