manyfest 1.0.28 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/manyfest.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
6
  (function (f) {
7
7
  if (typeof exports === "object" && typeof module !== "undefined") {
8
8
  module.exports = f();
@@ -263,11 +263,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
263
263
  * @class ManyfestObjectAddressResolverCheckAddressExists
264
264
  */
265
265
  class ManyfestObjectAddressResolverCheckAddressExists {
266
- constructor(pInfoLog, pErrorLog) {
267
- // Wire in logging
268
- this.logInfo = typeof pInfoLog == 'function' ? pInfoLog : libSimpleLog;
269
- this.logError = typeof pErrorLog == 'function' ? pErrorLog : libSimpleLog;
270
- }
266
+ constructor() {}
271
267
 
272
268
  // Check if an address exists.
273
269
  //
@@ -466,7 +462,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
466
462
  }
467
463
 
468
464
  // TODO: Dry me
469
- checkFilters(pAddress, pRecord) {
465
+ checkRecordFilters(pAddress, pRecord) {
470
466
  return fParseConditionals(this, pAddress, pRecord);
471
467
  }
472
468
 
@@ -565,7 +561,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
565
561
  // Count from the end to the beginning so splice doesn't %&%#$ up the array
566
562
  for (let i = tmpInputArray.length - 1; i >= 0; i--) {
567
563
  // The filtering is complex but allows config-based metaprogramming directly from schema
568
- let tmpKeepRecord = this.checkFilters(pAddress, tmpInputArray[i]);
564
+ let tmpKeepRecord = this.checkRecordFilters(pAddress, tmpInputArray[i]);
569
565
  if (tmpKeepRecord) {
570
566
  // Delete elements end to beginning
571
567
  tmpInputArray.splice(i, 1);
@@ -705,7 +701,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
705
701
  let tmpValue = this.deleteValueAtAddress(pObject[tmpObjectPropertyName][tmpObjectPropertyKeys[i]], tmpNewAddress, tmpPropertyParentAddress);
706
702
 
707
703
  // The filtering is complex but allows config-based metaprogramming directly from schema
708
- let tmpKeepRecord = this.checkFilters(pAddress, tmpValue);
704
+ let tmpKeepRecord = this.checkRecordFilters(pAddress, tmpValue);
709
705
  if (tmpKeepRecord) {
710
706
  tmpContainerObject["".concat(tmpPropertyParentAddress, ".").concat(tmpNewAddress)] = tmpValue;
711
707
  }
@@ -774,7 +770,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
774
770
  this.logError = typeof pErrorLog == 'function' ? pErrorLog : libSimpleLog;
775
771
  this.cleanWrapCharacters = fCleanWrapCharacters;
776
772
  }
777
- checkFilters(pAddress, pRecord) {
773
+ checkRecordFilters(pAddress, pRecord) {
778
774
  return fParseConditionals(this, pAddress, pRecord);
779
775
  }
780
776
 
@@ -906,7 +902,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
906
902
  let tmpOutputArray = [];
907
903
  for (let i = 0; i < tmpInputArray.length; i++) {
908
904
  // The filtering is complex but allows config-based metaprogramming directly from schema
909
- let tmpKeepRecord = this.checkFilters(pAddress, tmpInputArray[i]);
905
+ let tmpKeepRecord = this.checkRecordFilters(pAddress, tmpInputArray[i]);
910
906
  if (tmpKeepRecord) {
911
907
  tmpOutputArray.push(tmpInputArray[i]);
912
908
  }
@@ -1047,7 +1043,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
1047
1043
  let tmpValue = this.getValueAtAddress(pObject[tmpObjectPropertyName][tmpObjectPropertyKeys[i]], tmpNewAddress, tmpPropertyParentAddress, tmpRootObject);
1048
1044
 
1049
1045
  // The filtering is complex but allows config-based metaprogramming directly from schema
1050
- let tmpKeepRecord = this.checkFilters(pAddress, tmpValue);
1046
+ let tmpKeepRecord = this.checkRecordFilters(pAddress, tmpValue);
1051
1047
  if (tmpKeepRecord) {
1052
1048
  tmpContainerObject["".concat(tmpPropertyParentAddress, ".").concat(tmpNewAddress)] = tmpValue;
1053
1049
  }
@@ -1398,9 +1394,57 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
1398
1394
  const _ConditionalStanzaEnd = '?~>>';
1399
1395
  const _ConditionalStanzaEndLength = _ConditionalStanzaEnd.length;
1400
1396
 
1397
+ // Ugh dependency injection. Can't wait to make these all fable services.
1398
+ let libObjectAddressCheckAddressExists = new (require('./Manyfest-ObjectAddress-CheckAddressExists.js'))();
1399
+
1401
1400
  // Test the condition of a value in a record
1402
1401
  const testCondition = (pManyfest, pRecord, pSearchAddress, pSearchComparator, pValue) => {
1403
1402
  switch (pSearchComparator) {
1403
+ case 'TRUE':
1404
+ return pManyfest.getValueAtAddress(pRecord, pSearchAddress) === true;
1405
+ break;
1406
+ case 'FALSE':
1407
+ return pManyfest.getValueAtAddress(pRecord, pSearchAddress) === false;
1408
+ break;
1409
+ case 'LNGT':
1410
+ case 'LENGTH_GREATER_THAN':
1411
+ switch (typeof typeof pManyfest.getValueAtAddress(pRecord, pSearchAddress)) {
1412
+ case 'string':
1413
+ return pManyfest.getValueAtAddress(pRecord, pSearchAddress).length > pValue;
1414
+ break;
1415
+ case 'object':
1416
+ return pManyfest.getValueAtAddress(pRecord, pSearchAddress).length > pValue;
1417
+ break;
1418
+ default:
1419
+ return false;
1420
+ break;
1421
+ }
1422
+ break;
1423
+ case 'LNLT':
1424
+ case 'LENGTH_LESS_THAN':
1425
+ switch (typeof typeof pManyfest.getValueAtAddress(pRecord, pSearchAddress)) {
1426
+ case 'string':
1427
+ return pManyfest.getValueAtAddress(pRecord, pSearchAddress).length < pValue;
1428
+ break;
1429
+ case 'object':
1430
+ return pManyfest.getValueAtAddress(pRecord, pSearchAddress).length < pValue;
1431
+ break;
1432
+ default:
1433
+ return false;
1434
+ break;
1435
+ }
1436
+ break;
1437
+ case 'FALSE':
1438
+ return pManyfest.getValueAtAddress(pRecord, pSearchAddress) === false;
1439
+ break;
1440
+ case 'EX':
1441
+ case 'EXISTS':
1442
+ return libObjectAddressCheckAddressExists.checkAddressExists(pRecord, pSearchAddress);
1443
+ break;
1444
+ case 'DNEX':
1445
+ case 'DOES_NOT_EXIST':
1446
+ return !libObjectAddressCheckAddressExists.checkAddressExists(pRecord, pSearchAddress);
1447
+ break;
1404
1448
  case '!=':
1405
1449
  return pManyfest.getValueAtAddress(pRecord, pSearchAddress) != pValue;
1406
1450
  break;
@@ -1431,7 +1475,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
1431
1475
  /*
1432
1476
  Algorithm is simple:
1433
1477
  1. Enuerate start points
1434
- 2. Find stop points within each start point
1478
+ 2. Find stop points within each start point
1435
1479
  3. Check the conditional
1436
1480
  */
1437
1481
 
@@ -1440,9 +1484,21 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
1440
1484
  let tmpStopIndex = pAddress.indexOf(_ConditionalStanzaEnd, tmpStartIndex + _ConditionalStanzaStartLength);
1441
1485
  if (tmpStopIndex != -1) {
1442
1486
  let tmpMagicComparisonPatternSet = pAddress.substring(tmpStartIndex + _ConditionalStanzaStartLength, tmpStopIndex).split(',');
1487
+
1488
+ // The address to search for
1443
1489
  let tmpSearchAddress = tmpMagicComparisonPatternSet[0];
1444
- let tmpSearchComparator = tmpMagicComparisonPatternSet[1];
1445
- let tmpSearchValue = tmpMagicComparisonPatternSet[2];
1490
+
1491
+ // The copmparison expression (EXISTS as default)
1492
+ let tmpSearchComparator = 'EXISTS';
1493
+ if (tmpMagicComparisonPatternSet.length > 1) {
1494
+ tmpSearchComparator = tmpMagicComparisonPatternSet[1];
1495
+ }
1496
+
1497
+ // The value to search for
1498
+ let tmpSearchValue = false;
1499
+ if (tmpMagicComparisonPatternSet.length > 2) {
1500
+ tmpSearchValue = tmpMagicComparisonPatternSet[2];
1501
+ }
1446
1502
 
1447
1503
  // Process the piece
1448
1504
  tmpKeepRecord = tmpKeepRecord && testCondition(pManyfest, pRecord, tmpSearchAddress, tmpSearchComparator, tmpSearchValue);
@@ -1454,7 +1510,9 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
1454
1510
  return tmpKeepRecord;
1455
1511
  };
1456
1512
  module.exports = parseConditionals;
1457
- }, {}],
1513
+ }, {
1514
+ "./Manyfest-ObjectAddress-CheckAddressExists.js": 5
1515
+ }],
1458
1516
  11: [function (require, module, exports) {
1459
1517
  /**
1460
1518
  * @author <steven@velozo.com>
@@ -1,2 +1,2 @@
1
- "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)}));
1
+ "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)}));
2
2
  //# sourceMappingURL=manyfest.min.js.map