pict 1.0.142 → 1.0.144

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/README.md CHANGED
@@ -50,6 +50,56 @@ _(according to Wikipedia)_:
50
50
 
51
51
  ... and then a bunch of deviance
52
52
 
53
+ ## Setting up a View for testing:
54
+
55
+ Sometimes you want to unit test stuff, and don't want to load the whole module into a browser. Here is a way to do so:
56
+
57
+ ```js
58
+ // This library just sets up node to run like a browser.
59
+ // It isn't necessary but allows you to use jquery.
60
+ //const libBrowserEnv = require('browser-env')
61
+ //libBrowserEnv();
62
+
63
+ const Chai = require('chai');
64
+ const Expect = Chai.expect;
65
+
66
+ const libPict = require('pict');
67
+
68
+ const libMyPictView = require(`../source/Pict-View-Sourcecode.js`);
69
+
70
+ suite
71
+ (
72
+ 'PictView Basic',
73
+ () =>
74
+ {
75
+ setup(() => { });
76
+
77
+ suite
78
+ (
79
+ 'Basic Tests',
80
+ () =>
81
+ {
82
+ test(
83
+ 'Basic Initialization',
84
+ (fDone) =>
85
+ {
86
+ // Initialize pict
87
+ let _Pict = new libPict();
88
+ // Setup an "environment" which allows us to inspect the activity -- pict has built in EnvironmentObject and EnvironmentLog
89
+ let _PictEnvironment = new libPict.EnvironmentObject(_Pict);
90
+ // Add our view to pict now that the environment is set up
91
+ let _PictView = _Pict.addView({ Configurated:'Value' }, 'Pict-View-Name', libMyPictView);
92
+ // We might expect something more creative and unique to our view but this is a good start.
93
+ Expect(_PictView).to.be.an('object');
94
+ return fDone();
95
+ }
96
+ );
97
+ }
98
+ );
99
+ }
100
+ );
101
+ ```
102
+
53
103
 
54
104
  ## Luxury Code
55
105
 
@@ -89,11 +139,15 @@ bash terminal to the instance:
89
139
 
90
140
  The unit tests require a running API server with the retold-harness data in it. The
91
141
  luxury code docker image provides this for free, or you can use the scripts in the
92
- `retold-harness` folder to run them locally.
142
+ `retold-harness` folder to run them locally... find some folder on your machine you
143
+ want to run the harness from.
93
144
 
94
145
  ```shell
146
+ git clone https://github.com/stevenvelozo/retold-harness
147
+ cd retold-harness
95
148
  npm install
96
- npm run api-server-harness
149
+ npm run docker-dev-build
150
+ npm run docker-dev-run
97
151
  ```
98
152
 
99
153
  You can test that the service is running by executing the following curl command:
@@ -117,6 +171,7 @@ Which should return the following JSON:
117
171
  "Name": "John Green"
118
172
  }
119
173
  ```
174
+
120
175
  If you are into using paw files to play around with API endpoints, there is a fairly
121
176
  complete file in `retold-harness/model/bookstore-api-endpoint-exercises.paw` to
122
177
  navigate the meadow-endpoints.
@@ -125,10 +180,6 @@ It is annoying to keep the terminal running to have API endpoints. An easy and
125
180
  extremely, awesomely stable way to run it in the background within the docker container
126
181
  is through the tmux command.
127
182
 
128
- ```shell
129
- tmux
130
- npm run api-server-harness
131
- ```
132
183
 
133
184
  Then you can press [ctrl-b] and then [d] to detach from the tmux terminal. If you
134
185
  ever want to go back and watch the REST logs, or, restart the service, you can run
@@ -154,7 +205,3 @@ source maps.
154
205
  npm run build
155
206
  npm run build-compatible
156
207
  ```
157
-
158
- ## A Manifesto for Anti-Frameworks in Service of Patterns
159
-
160
- (more to come)
@@ -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
@@ -1061,8 +1062,7 @@ return _this21.makeFolderRecursive(tmpParameters,fCallback);}else{console.log(pC
1061
1062
  * Precedent Meta-Templating
1062
1063
  * @author Steven Velozo <steven@velozo.com>
1063
1064
  * @description Process text stream trie and postfix tree, parsing out meta-template expression functions.
1064
- */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
1065
- _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;}/**
1066
1066
  * Add a Pattern to the Parse Tree
1067
1067
  * @method addPattern
1068
1068
  * @param {Object} pTree - A node on the parse tree to push the characters into
@@ -1075,7 +1075,7 @@ _this22.StringParser=new libStringParser(_this22.fable);_this22.ParseTree=_this2
1075
1075
  * @param {string} pString - The string to parse
1076
1076
  * @param {object} pData - Data to pass in as the second argument
1077
1077
  * @return {string} The result from the parser
1078
- */},{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){/**
1079
1079
  * String Parser
1080
1080
  * @author Steven Velozo <steven@velozo.com>
1081
1081
  * @description Parse a string, properly processing each matched token in the word tree.
@@ -3505,12 +3505,39 @@ return _this58.parseTemplateByHash(tmpTemplateHash,pData,function(pError,pValue)
3505
3505
  var fTemplateSetRender=function fTemplateSetRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fTemplateSetRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT Template [fTemplateSetRender]::[".concat(tmpHash,"]"));}var tmpTemplateHash=false;var tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
3506
3506
  var tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
3507
3507
  if(!tmpTemplateHash){_this58.log.warn("Pict: Template Render: TemplateHash not resolved for [".concat(tmpHash,"]"));return"Pict: Template Render: TemplateHash not resolved for [".concat(tmpHash,"]");}if(!tmpAddressOfData){// No address was provided, just render the template with what this template has.
3508
- return _this58.parseTemplateSetByHash(tmpTemplateHash,pData);}else{return _this58.parseTemplateSetByHash(tmpTemplateHash,_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfData));}};var fTemplateSetRenderAsync=function fTemplateSetRenderAsync(pHash,pData,fCallback){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};var tmpCallback=typeof fCallback==='function'?fCallback:function(){return'';};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fTemplateSetRenderAsync]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT Template [fTemplateSetRenderAsync]::[".concat(tmpHash,"]"));}var tmpTemplateHash=false;var tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
3509
- var tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
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.
3508
+ return _this58.parseTemplateSetByHash(tmpTemplateHash,pData);}else{return _this58.parseTemplateSetByHash(tmpTemplateHash,_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfData));}};var fTemplateSetRenderAsync=function fTemplateSetRenderAsync(pHash,pData,fCallback){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};var tmpCallback=typeof fCallback==='function'?fCallback:function(){return'';};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fTemplateSetRenderAsync]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT Template [fTemplateSetRenderAsync]::[".concat(tmpHash,"]"));}var tmpTemplateFromMapHash=false;var tmpAddressOfData=false;// This is a 3 part hash with the map address and the key address both
3509
+ var tmpTemplateHashPart=tmpHash.split(':');if(tmpTemplateHashPart.length<2){_this58.log.trace("PICT TemplateFromMap [fTemplateRenderAsync]::[".concat(tmpHash,"] failed because there were not three stanzas in the expression [").concat(pHash,"]"));return fCallback(null,'');}tmpTemplateFromMapHash=tmpTemplateHashPart[0];tmpAddressOfData=tmpTemplateHashPart[1];// No TemplateFromMap hash
3510
+ if(!tmpTemplateFromMapHash){_this58.log.warn("Pict: TemplateFromMap Render Async: TemplateFromMapHash not resolved for [".concat(tmpHash,"]"));return fCallback(null,'');}// Now resolve the data
3511
+ tmpData=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfData);if(!tmpData){// No address was provided, just render the template with what this template has.
3511
3512
  // The async portion of this is a mind bender because of how entry can happen dynamically from templates
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~}
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);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
+ return _this58.parseTemplateSetByHash(tmpTemplateFromMapHash,pData,function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}else{return _this58.parseTemplateSetByHash(tmpTemplateFromMapHash,tmpData,function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}};this.MetaTemplate.addPatternBoth('{~TS:','~}',fTemplateSetRender,fTemplateSetRenderAsync);this.MetaTemplate.addPatternBoth('{~TemplateSet:','~}',fTemplateSetRender,fTemplateSetRenderAsync);// Refactor: #### DRY PROBLEM Too much dry needing fixed at this point
3514
+ // {~T:TemplateFromMap:AddressOfData~}
3515
+ var fTemplateFromMapRender=function fTemplateFromMapRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapRender]::[".concat(tmpHash,"]"));}var tmpTemplateFromMapHash=false;var tmpAddressOfMap=false;var tmpAddressOfKey=false;// This is a 3 part hash with the map address and the key address both
3516
+ var tmpTemplateHashPart=tmpHash.split(':');if(tmpTemplateHashPart.length<3){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapRenderAsync]::[".concat(tmpHash,"] failed because there were not three stanzas in the expression [").concat(pHash,"]"));return'';}tmpTemplateFromMapHash=tmpTemplateHashPart[0];tmpAddressOfMap=tmpTemplateHashPart[1];tmpAddressOfKey=tmpTemplateHashPart[2];// No TemplateFromMap hash
3517
+ if(!tmpTemplateFromMapHash){_this58.log.warn("Pict: TemplateFromMap Render: TemplateFromMapHash not resolved for [".concat(tmpHash,"]"));return'';}// Now resolve the data
3518
+ var tmpMap=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfMap);var tmpKey=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfKey);if(!tmpMap){_this58.log.warn("Pict: TemplateFromMap Render: Map not resolved for [".concat(tmpHash,"]"));return'';}tmpData=tmpMap[tmpKey];if(!tmpData){// No address was provided, just render the TemplateFromMap with what this TemplateFromMap has.
3519
+ return _this58.parseTemplateByHash(tmpTemplateFromMapHash,pData);}else{return _this58.parseTemplateByHash(tmpTemplateFromMapHash,tmpData);}};var fTemplateFromMapRenderAsync=function fTemplateFromMapRenderAsync(pHash,pData,fCallback){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};var tmpCallback=typeof fCallback==='function'?fCallback:function(){return'';};if(_this58.LogNoisiness>4){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapRenderAsync]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapRenderAsync]::[".concat(tmpHash,"]"));}var tmpTemplateFromMapHash=false;var tmpAddressOfMap=false;var tmpAddressOfKey=false;// This is a 3 part hash with the map address and the key address both
3520
+ var tmpTemplateHashPart=tmpHash.split(':');if(tmpTemplateHashPart.length<3){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapRenderAsync]::[".concat(tmpHash,"] failed because there were not three stanzas in the expression [").concat(pHash,"]"));return fCallback(null,'');}tmpTemplateFromMapHash=tmpTemplateHashPart[0];tmpAddressOfMap=tmpTemplateHashPart[1];tmpAddressOfKey=tmpTemplateHashPart[2];// No TemplateFromMap hash
3521
+ if(!tmpTemplateFromMapHash){_this58.log.warn("Pict: TemplateFromMap Render Async: TemplateFromMapHash not resolved for [".concat(tmpHash,"]"));return fCallback(null,'');}// Now resolve the data
3522
+ var tmpMap=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfMap);var tmpKey=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfKey);if(!tmpMap){_this58.log.warn("Pict: TemplateFromMap Render: Map not resolved for [".concat(tmpHash,"]"));return fCallback(null,'');}tmpData=tmpMap[tmpKey];if(!tmpData){// No address was provided, just render the TemplateFromMap with what this TemplateFromMap has.
3523
+ // The async portion of this is a mind bender because of how entry can happen dynamically from TemplateFromMaps
3524
+ return _this58.parseTemplateByHash(tmpTemplateFromMapHash,pData,function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}else{return _this58.parseTemplateByHash(tmpTemplateFromMapHash,tmpData,function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}};this.MetaTemplate.addPatternBoth('{~TFM:','~}',fTemplateFromMapRender,fTemplateFromMapRenderAsync);this.MetaTemplate.addPatternBoth('{~TemplateFromMap:','~}',fTemplateFromMapRender,fTemplateFromMapRenderAsync);// {~TS:TemplateFromMap:AddressOfDataSet~}
3525
+ var fTemplateFromMapSetRender=function fTemplateFromMapSetRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapSetRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapSetRender]::[".concat(tmpHash,"]"));}var tmpTemplateFromMapHash=false;var tmpAddressOfMap=false;var tmpAddressOfKey=false;// This is a 3 part hash with the map address and the key address both
3526
+ var tmpTemplateHashPart=tmpHash.split(':');if(tmpTemplateHashPart.length<3){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapRenderAsync]::[".concat(tmpHash,"] failed because there were not three stanzas in the expression [").concat(pHash,"]"));return fCallback(null,'');}tmpTemplateFromMapHash=tmpTemplateHashPart[0];tmpAddressOfMap=tmpTemplateHashPart[1];tmpAddressOfKey=tmpTemplateHashPart[2];// No TemplateFromMap hash
3527
+ if(!tmpTemplateFromMapHash){_this58.log.warn("Pict: TemplateFromMap Render Async: TemplateFromMapHash not resolved for [".concat(tmpHash,"]"));return fCallback(null,'');}// Now resolve the data
3528
+ var tmpMap=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfMap);var tmpKey=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfKey);if(!tmpMap){_this58.log.warn("Pict: TemplateFromMap Render: Map not resolved for [".concat(tmpHash,"]"));return'';}tmpData=tmpMap[tmpKey];if(!tmpData){// No address was provided, just render the TemplateFromMap with what this TemplateFromMap has.
3529
+ return _this58.parseTemplateSetByHash(tmpTemplateFromMapHash,pData);}else{return _this58.parseTemplateSetByHash(tmpTemplateFromMapHash,tmpData);}};var fTemplateFromMapSetRenderAsync=function fTemplateFromMapSetRenderAsync(pHash,pData,fCallback){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};var tmpCallback=typeof fCallback==='function'?fCallback:function(){return'';};if(_this58.LogNoisiness>4){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapSetRenderAsync]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapSetRenderAsync]::[".concat(tmpHash,"]"));}var tmpTemplateFromMapHash=false;var tmpAddressOfMap=false;var tmpAddressOfKey=false;// This is a 3 part hash with the map address and the key address both
3530
+ var tmpTemplateHashPart=tmpHash.split(':');if(tmpTemplateHashPart.length<3){_this58.log.trace("PICT TemplateFromMap [fTemplateFromMapRenderAsync]::[".concat(tmpHash,"] failed because there were not three stanzas in the expression [").concat(pHash,"]"));return fCallback(null,'');}tmpTemplateFromMapHash=tmpTemplateHashPart[0];tmpAddressOfMap=tmpTemplateHashPart[1];tmpAddressOfKey=tmpTemplateHashPart[2];// No TemplateFromMap hash
3531
+ if(!tmpTemplateFromMapHash){_this58.log.warn("Pict: TemplateFromMapSet Render Async: TemplateFromMapHash not resolved for [".concat(tmpHash,"]"));return fCallback(null,'');}// Now resolve the data
3532
+ var tmpMap=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfMap);var tmpKey=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfKey);if(!tmpMap){_this58.log.warn("Pict: TemplateFromMapSet Render: Map not resolved for [".concat(tmpHash,"]"));return fCallback(null,'');}tmpData=tmpMap[tmpKey];if(!tmpData){// No address was provided, just render the TemplateFromMap with what this TemplateFromMap has.
3533
+ // The async portion of this is a mind bender because of how entry can happen dynamically from TemplateFromMaps
3534
+ return _this58.parseTemplateSetByHash(tmpTemplateFromMapHash,pData,function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}else{return _this58.parseTemplateSetByHash(tmpTemplateFromMapHash,tmpData,function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}};this.MetaTemplate.addPatternBoth('{~TSFM:','~}',fTemplateFromMapSetRender,fTemplateFromMapSetRenderAsync);this.MetaTemplate.addPatternBoth('{~TemplateSetFromMap:','~}',fTemplateFromMapSetRender,fTemplateFromMapSetRenderAsync);// Refactor: #### END OF DRY PROBLEM
3535
+ //{~Data:AppData.Some.Value.to.Render~}
3536
+ 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='';if(tmpHash!=null){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>
3537
+ 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
3538
+ 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>
3539
+ 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
3540
+ 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
3514
3541
  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
3515
3542
  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
3516
3543
  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