pict 1.0.141 → 1.0.143

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.
@@ -760,7 +760,8 @@ _this13.serviceTypes=[];// A map of instantiated services
760
760
  _this13.servicesMap={};// A map of the default instantiated service by type
761
761
  _this13.services={};// A map of class constructors for services
762
762
  _this13.serviceClasses={};// If we need extra service initialization capabilities
763
- _this13.extraServiceInitialization=false;// Initialization Phase 1: Set up the core utility services
763
+ _this13.extraServiceInitialization=false;// Set how noisy the system is about signaling complexity
764
+ _this13.LogNoisiness=0;// Initialization Phase 1: Set up the core utility services
764
765
  // These are things like power, water, and sewage. They are required for fable to run (e.g. logging, settings, etc)
765
766
  // Instantiate the default Settings Manager
766
767
  _this13.SettingsManager=new libFableSettings(pSettings);_this13.SettingsManager=_this13.SettingsManager;// Instantiate the UUID generator
@@ -804,9 +805,11 @@ if(this.servicesMap[pServiceType].hasOwnProperty(pServiceHash)){if(!this.hasOwnP
804
805
  function autoConstruct(pSettings){return new Fable(pSettings);}module.exports=Fable;module.exports["new"]=autoConstruct;module.exports.LogProviderBase=libFableLog.LogProviderBase;module.exports.ServiceProviderBase=libFableServiceBase;module.exports.CoreServiceProviderBase=libFableServiceBase.CoreServiceProviderBase;module.exports.precedent=libFableSettings.precedent;},{"./services/Fable-Service-Anticipate.js":51,"./services/Fable-Service-CSVParser.js":52,"./services/Fable-Service-DataFormat.js":53,"./services/Fable-Service-DataGeneration.js":55,"./services/Fable-Service-DateManipulation.js":56,"./services/Fable-Service-EnvironmentData.js":57,"./services/Fable-Service-FilePersistence.js":58,"./services/Fable-Service-MetaTemplate.js":59,"./services/Fable-Service-Operation.js":63,"./services/Fable-Service-RestClient.js":64,"./services/Fable-Service-Template.js":65,"./services/Fable-Service-Utility.js":66,"cachetrax":22,"fable-log":43,"fable-serviceproviderbase":44,"fable-settings":47,"fable-uuid":49,"manyfest":89}],51:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var FableServiceAnticipate=/*#__PURE__*/function(_libFableServiceBase){_inherits(FableServiceAnticipate,_libFableServiceBase);var _super9=_createSuper(FableServiceAnticipate);function FableServiceAnticipate(pFable,pOptions,pServiceHash){var _this14;_classCallCheck2(this,FableServiceAnticipate);_this14=_super9.call(this,pFable,pOptions,pServiceHash);_this14.serviceType='AsyncAnticipate';// The queue of operations waiting to run.
805
806
  _this14.operationQueue=[];_this14.erroredOperations=[];_this14.executingOperationCount=0;_this14.completedOperationCount=0;_this14.maxOperations=1;_this14.lastError=undefined;_this14.waitingFunctions=[];return _this14;}_createClass2(FableServiceAnticipate,[{key:"checkQueue",value:function checkQueue(){// This checks to see if we need to start any operations.
806
807
  if(this.operationQueue.length>0&&this.executingOperationCount<this.maxOperations){var tmpOperation=this.operationQueue.shift();this.executingOperationCount+=1;tmpOperation(this.buildAnticipatorCallback());}else if(this.waitingFunctions.length>0&&this.executingOperationCount<1){// If there are no operations left, and we have waiting functions, call them.
807
- for(var i=0;i<this.waitingFunctions.length;i++){this.log.trace('Calling waiting function.');this.waitingFunctions[i](this.lastError);}// Reset our state
808
+ for(var i=0;i<this.waitingFunctions.length;i++){//this.log.trace('Calling waiting function.')
809
+ this.waitingFunctions[i](this.lastError);}// Reset our state
808
810
  this.lastError=undefined;this.waitingFunctions=[];}}// Expects a function fAsynchronousFunction(fCallback)
809
- },{key:"anticipate",value:function anticipate(fAsynchronousFunction){this.log.trace('Adding a function...');this.operationQueue.push(fAsynchronousFunction);this.checkQueue();}},{key:"buildAnticipatorCallback",value:function buildAnticipatorCallback(){// This uses closure-scoped state to track the callback state
811
+ },{key:"anticipate",value:function anticipate(fAsynchronousFunction){//this.log.trace('Adding a function...')
812
+ this.operationQueue.push(fAsynchronousFunction);this.checkQueue();}},{key:"buildAnticipatorCallback",value:function buildAnticipatorCallback(){// This uses closure-scoped state to track the callback state
810
813
  var tmpCallbackState={Called:false,Error:undefined,OperationSet:this};return hoistedCallback;function hoistedCallback(pError){if(tmpCallbackState.Called){// If they call the callback twice, throw an error
811
814
  throw new Error("Anticipation async callback called twice...");}tmpCallbackState.Called=true;tmpCallbackState.error=pError;tmpCallbackState.OperationSet.executingOperationCount-=1;tmpCallbackState.OperationSet.completedOperationCount+=1;tmpCallbackState.OperationSet.checkQueue();}}},{key:"wait",value:function wait(fCallback){this.waitingFunctions.push(fCallback);this.checkQueue();}}]);return FableServiceAnticipate;}(libFableServiceBase);module.exports=FableServiceAnticipate;},{"fable-serviceproviderbase":44}],52:[function(require,module,exports){var libFableServiceProviderBase=require('fable-serviceproviderbase');/**
812
815
  * Parsing CSVs. Why? Because it's a thing that needs to be done.
@@ -1059,8 +1062,7 @@ return _this21.makeFolderRecursive(tmpParameters,fCallback);}else{console.log(pC
1059
1062
  * Precedent Meta-Templating
1060
1063
  * @author Steven Velozo <steven@velozo.com>
1061
1064
  * @description Process text stream trie and postfix tree, parsing out meta-template expression functions.
1062
- */var libWordTree=require("./Fable-Service-MetaTemplate/MetaTemplate-WordTree.js");var libStringParser=require("./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js");var FableServiceMetaTemplate=/*#__PURE__*/function(_libFableServiceBase5){_inherits(FableServiceMetaTemplate,_libFableServiceBase5);var _super16=_createSuper(FableServiceMetaTemplate);function FableServiceMetaTemplate(pFable,pOptions,pServiceHash){var _this22;_classCallCheck2(this,FableServiceMetaTemplate);_this22=_super16.call(this,pFable,pOptions,pServiceHash);_this22.serviceType='MetaTemplate';_this22.WordTree=new libWordTree();// In order to allow asynchronous template processing we need to use the async.eachLimit function
1063
- _this22.StringParser=new libStringParser(_this22.fable);_this22.ParseTree=_this22.WordTree.ParseTree;return _this22;}/**
1065
+ */var libWordTree=require("./Fable-Service-MetaTemplate/MetaTemplate-WordTree.js");var libStringParser=require("./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js");var FableServiceMetaTemplate=/*#__PURE__*/function(_libFableServiceBase5){_inherits(FableServiceMetaTemplate,_libFableServiceBase5);var _super16=_createSuper(FableServiceMetaTemplate);function FableServiceMetaTemplate(pFable,pOptions,pServiceHash){var _this22;_classCallCheck2(this,FableServiceMetaTemplate);_this22=_super16.call(this,pFable,pOptions,pServiceHash);_this22.serviceType='MetaTemplate';_this22.WordTree=new libWordTree();_this22.StringParser=new libStringParser(_this22.fable);_this22.ParseTree=_this22.WordTree.ParseTree;return _this22;}/**
1064
1066
  * Add a Pattern to the Parse Tree
1065
1067
  * @method addPattern
1066
1068
  * @param {Object} pTree - A node on the parse tree to push the characters into
@@ -1073,7 +1075,7 @@ _this22.StringParser=new libStringParser(_this22.fable);_this22.ParseTree=_this2
1073
1075
  * @param {string} pString - The string to parse
1074
1076
  * @param {object} pData - Data to pass in as the second argument
1075
1077
  * @return {string} The result from the parser
1076
- */},{key:"parseString",value:function parseString(pString,pData,fCallback){return this.StringParser.parseString(pString,this.ParseTree,pData,fCallback);}}]);return FableServiceMetaTemplate;}(libFableServiceBase);module.exports=FableServiceMetaTemplate;},{"./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js":60,"./Fable-Service-MetaTemplate/MetaTemplate-WordTree.js":61,"fable-serviceproviderbase":44}],60:[function(require,module,exports){/**
1078
+ */},{key:"parseString",value:function parseString(pString,pData,fCallback){if(this.LogNoisiness>4){this.fable.log.trace("Metatemplate parsing template string [".concat(pString,"] where the callback is a ").concat(_typeof(fCallback)),{TemplateData:pData});}return this.StringParser.parseString(pString,this.ParseTree,pData,fCallback);}}]);return FableServiceMetaTemplate;}(libFableServiceBase);module.exports=FableServiceMetaTemplate;},{"./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js":60,"./Fable-Service-MetaTemplate/MetaTemplate-WordTree.js":61,"fable-serviceproviderbase":44}],60:[function(require,module,exports){/**
1077
1079
  * String Parser
1078
1080
  * @author Steven Velozo <steven@velozo.com>
1079
1081
  * @description Parse a string, properly processing each matched token in the word tree.
@@ -3508,7 +3510,11 @@ var tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substr
3508
3510
  if(!tmpTemplateHash){_this58.log.warn("Pict: Template Render Async: TemplateHash not resolved for [".concat(tmpHash,"]"));return tmpCallback(new Error("Pict: Template Render Async: TemplateHash not resolved for [".concat(tmpHash,"]")),'');}if(!tmpAddressOfData){// No address was provided, just render the template with what this template has.
3509
3511
  // The async portion of this is a mind bender because of how entry can happen dynamically from templates
3510
3512
  return _this58.parseTemplateSetByHash(tmpTemplateHash,pData,function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}else{return _this58.parseTemplateSetByHash(tmpTemplateHash,_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfData),function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}};this.MetaTemplate.addPatternBoth('{~TS:','~}',fTemplateSetRender,fTemplateSetRenderAsync);this.MetaTemplate.addPatternBoth('{~TemplateSet:','~}',fTemplateSetRender,fTemplateSetRenderAsync);//{~Data:AppData.Some.Value.to.Render~}
3511
- var fDataRender=function fDataRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"]"));}var tmpValue=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return tmpValue;};this.MetaTemplate.addPattern('{~D:','~}',fDataRender);this.MetaTemplate.addPattern('{~Data:','~}',fDataRender);this.MetaTemplate.addPattern('{~Dollars:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"]"));}var tmpColumnData=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHash);return _this58.DataFormat.formatterDollars(tmpColumnData);});this.MetaTemplate.addPattern('{~Digits:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"]"));}var tmpColumnData=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHash);return _this58.DataFormat.formatterAddCommasToNumber(_this58.DataFormat.formatterRoundNumber(tmpColumnData,2));});// Output the date as a YYYY-MM-DD string
3513
+ var fDataRender=function fDataRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"]"));}var tmpValue=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return tmpValue;};this.MetaTemplate.addPattern('{~D:','~}',fDataRender);this.MetaTemplate.addPattern('{~Data:','~}',fDataRender);//<p>{~Join: - ^Record.d1^Record.d1~}</p>
3514
+ var fJoinDataRender=function fJoinDataRender(pHash,pData){var tmpHash=pHash;var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Join [fDataRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Join [fDataRender]::[".concat(tmpHash,"]"));}var tmpDataAddresses=tmpHash.split('^');if(tmpDataAddresses.length<2){return'';}// Get the separator string
3515
+ var tmpSeparator=tmpDataAddresses.shift();var tmpValueList=[];for(var i=0;i<tmpDataAddresses.length;i++){var tmpValue=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpDataAddresses[i]);if(tmpValue){tmpValueList.push(tmpValue);}}return tmpValueList.join(tmpSeparator);};this.MetaTemplate.addPattern('{~J:','~}',fJoinDataRender);this.MetaTemplate.addPattern('{~Join:','~}',fJoinDataRender);//<p>{~JoinUnique: - ^Record.d1^Record.d1~}</p>
3516
+ var fJoinUniqueDataRender=function fJoinUniqueDataRender(pHash,pData){var tmpHash=pHash;var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Join Unique [fDataRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Join Unique [fDataRender]::[".concat(tmpHash,"]"));}var tmpDataAddresses=tmpHash.split('^');if(tmpDataAddresses.length<2){return'';}// Get the separator string
3517
+ var tmpSeparator=tmpDataAddresses.shift();var tmpValueList=[];var tmpValueMap={};for(var i=0;i<tmpDataAddresses.length;i++){var tmpValue=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpDataAddresses[i]);if(tmpValue){if(!tmpValueMap.hasOwnProperty(tmpValue)){tmpValueMap[tmpValue]=true;tmpValueList.push(tmpValue);}}}return tmpValueList.join(tmpSeparator);};this.MetaTemplate.addPattern('{~JU:','~}',fJoinUniqueDataRender);this.MetaTemplate.addPattern('{~JoinUnique:','~}',fJoinUniqueDataRender);this.MetaTemplate.addPattern('{~Dollars:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"]"));}var tmpColumnData=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHash);return _this58.DataFormat.formatterDollars(tmpColumnData);});this.MetaTemplate.addPattern('{~Digits:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"]"));}var tmpColumnData=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHash);return _this58.DataFormat.formatterAddCommasToNumber(_this58.DataFormat.formatterRoundNumber(tmpColumnData,2));});// Output the date as a YYYY-MM-DD string
3512
3518
  this.MetaTemplate.addPattern('{~DateYMD:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};var tmpDateValue=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHash);if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fDateFormat]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fDateFormat]::[".concat(tmpHash,"]"));}// TODO: Modularize this
3513
3519
  var tmpDayJS=_this58.fable.Dates.dayJS.utc(tmpDateValue);try{// Try to cast the day to be a specific timezone if one is set for the app
3514
3520
  if(_this58.options.Timezone){tmpDayJS=tmpDayJS.tz(_this58.options.Timezone);}else{tmpDayJS=tmpDayJS.tz(_this58.fable.Dates.dayJS.tz.guess());}}catch(_unused){_this58.log.error("Error casting Document date ".concat(tmpSQLDateTime," to the Document timezone using tz in this.AppData.DocumentData.Timezone: [").concat(_this58.AppData.DocumentData.Timezone,"] .. casting to the browser guess which is [").concat(_this58.fable.Dates.dayJS.tz.guess(),"]."));// Day.js will try to guess the user's timezone for us