pict 1.0.131 → 1.0.133
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/pict.compatible.js +66 -41
- package/dist/pict.compatible.min.js +2 -2
- package/dist/pict.compatible.min.js.map +1 -1
- package/dist/pict.js +49 -24
- package/dist/pict.min.js +2 -2
- package/dist/pict.min.js.map +1 -1
- package/package.json +3 -3
- package/source/Pict-Meadow-EntityProvider.js +9 -10
- package/source/Pict.js +259 -36
- package/test/Pict_template_tests.js +342 -231
package/dist/pict.compatible.js
CHANGED
|
@@ -1065,7 +1065,7 @@ _this22.StringParser=new libStringParser(_this22.fable.services.Utility.eachLimi
|
|
|
1065
1065
|
* @param {string} pPattern - The string to add to the tree
|
|
1066
1066
|
* @param {number} pIndex - callback function
|
|
1067
1067
|
* @return {bool} True if adding the pattern was successful
|
|
1068
|
-
*/_createClass2(FableServiceMetaTemplate,[{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,pParser){return this.WordTree.addPattern(pPatternStart,pPatternEnd,pParser);}},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,pParserPromise){return this.WordTree.addPatternAsync(pPatternStart,pPatternEnd,pParserPromise);}/**
|
|
1068
|
+
*/_createClass2(FableServiceMetaTemplate,[{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,pParser){return this.WordTree.addPattern(pPatternStart,pPatternEnd,pParser);}},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,pParserPromise){return this.WordTree.addPatternAsync(pPatternStart,pPatternEnd,pParserPromise);}},{key:"addPatternBoth",value:function addPatternBoth(pPatternStart,pPatternEnd,pParser,pParserPromise){return this.WordTree.addPatternBoth(pPatternStart,pPatternEnd,pParser,pParserPromise);}/**
|
|
1069
1069
|
* Parse a string with the existing parse tree
|
|
1070
1070
|
* @method parseString
|
|
1071
1071
|
* @param {string} pString - The string to parse
|
|
@@ -1108,12 +1108,12 @@ if(pParserState.PatternMatch){// If the pattern is still matching the start and
|
|
|
1108
1108
|
if(!pParserState.StartPatternMatchComplete&&pParserState.Pattern.hasOwnProperty(pCharacter)){pParserState.Pattern=pParserState.Pattern[pCharacter];this.appendOutputBuffer(pCharacter,pParserState);}else if(pParserState.EndPatternMatchBegan){if(pParserState.Pattern.PatternEnd.hasOwnProperty(pCharacter)){// This leaf has a PatternEnd tree, so we will wait until that end is met.
|
|
1109
1109
|
pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// Flush the output buffer.
|
|
1110
1110
|
this.appendOutputBuffer(pCharacter,pParserState);// If this last character is the end of the pattern, parse it.
|
|
1111
|
-
if(pParserState.Pattern.hasOwnProperty('Parse')){// Run the function
|
|
1112
|
-
pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData);return this.resetOutputBuffer(pParserState);}}else if(pParserState.PatternStartNode.PatternEnd.hasOwnProperty(pCharacter)){// We broke out of the end -- see if this is a new start of the end.
|
|
1111
|
+
if(pParserState.Pattern.hasOwnProperty('Parse')&&(!pParserState.Pattern.isAsync||pParserState.Pattern.isBoth)){// Run the function
|
|
1112
|
+
pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData);return this.resetOutputBuffer(pParserState);}else{console.log("MetaTemplate: The pattern ".concat(pParserState.Pattern.PatternStartString," is asynchronous and cannot be used in a synchronous parser."));return this.resetOutputBuffer(pParserState);}}else if(pParserState.PatternStartNode.PatternEnd.hasOwnProperty(pCharacter)){// We broke out of the end -- see if this is a new start of the end.
|
|
1113
1113
|
pParserState.Pattern=pParserState.PatternStartNode.PatternEnd[pCharacter];this.appendOutputBuffer(pCharacter,pParserState);}else{pParserState.EndPatternMatchBegan=false;this.appendOutputBuffer(pCharacter,pParserState);}}else if(pParserState.Pattern.hasOwnProperty('PatternEnd')){if(!pParserState.StartPatternMatchComplete){pParserState.StartPatternMatchComplete=true;pParserState.PatternStartNode=pParserState.Pattern;}this.appendOutputBuffer(pCharacter,pParserState);if(pParserState.Pattern.PatternEnd.hasOwnProperty(pCharacter)){// This is the first character of the end pattern.
|
|
1114
1114
|
pParserState.EndPatternMatchBegan=true;// This leaf has a PatternEnd tree, so we will wait until that end is met.
|
|
1115
1115
|
pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// If this last character is the end of the pattern, parse it.
|
|
1116
|
-
if(pParserState.Pattern.hasOwnProperty('Parse')){if(pParserState.Pattern.isAsync){
|
|
1116
|
+
if(pParserState.Pattern.hasOwnProperty('Parse')){if(pParserState.Pattern.isAsync&&!pParserState.Pattern.isBoth){console.log("MetaTemplate: The pattern ".concat(pParserState.Pattern.PatternStartString," is asynchronous and cannot be used in a synchronous parser."));this.resetOutputBuffer(pParserState);}else{// Run the t*mplate function
|
|
1117
1117
|
pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData);return this.resetOutputBuffer(pParserState);}}}}else{// We are in a pattern start but didn't match one; reset and start trying again from this character.
|
|
1118
1118
|
this.resetOutputBuffer(pParserState);}}// If we aren't in a pattern match or pattern, and this isn't the start of a new pattern (RAW mode)....
|
|
1119
1119
|
if(!pParserState.PatternMatch){// This may be the start of a new pattern....
|
|
@@ -1131,8 +1131,9 @@ pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// Flush the ou
|
|
|
1131
1131
|
this.appendOutputBuffer(pCharacter,pParserState);// If this last character is the end of the pattern, parse it.
|
|
1132
1132
|
if(pParserState.Pattern.hasOwnProperty('Parse')){// ... this is the end of a pattern, cut off the end tag and parse it.
|
|
1133
1133
|
// Trim the start and end tags off the output buffer now
|
|
1134
|
-
if(pParserState.Pattern.isAsync){// Run the function
|
|
1135
|
-
return pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,function(pError,pAsyncOutput){if(pError){console.log("Precedent ERROR: Async template error happened parsing ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd,": ").concat(pError));}pParserState.OutputBuffer=pAsyncOutput;_this23.resetOutputBuffer(pParserState);return fCallback();});}else{// Run the
|
|
1134
|
+
if(pParserState.Pattern.isAsync&&!pParserState.Pattern.isBoth){// Run the function
|
|
1135
|
+
return pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,function(pError,pAsyncOutput){if(pError){console.log("Precedent ERROR: Async template error happened parsing ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd,": ").concat(pError));}pParserState.OutputBuffer=pAsyncOutput;_this23.resetOutputBuffer(pParserState);return fCallback();});}else if(pParserState.Pattern.isAsync&&pParserState.Pattern.isBoth){// Run the function when both async and non async were provided with the pattern
|
|
1136
|
+
return pParserState.Pattern.ParseAsync(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,function(pError,pAsyncOutput){if(pError){console.log("Precedent ERROR: Async template error happened parsing ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd,": ").concat(pError));}pParserState.OutputBuffer=pAsyncOutput;_this23.resetOutputBuffer(pParserState);return fCallback();});}else{// Run the t*mplate function
|
|
1136
1137
|
pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData);this.resetOutputBuffer(pParserState);return fCallback();}}}else if(pParserState.PatternStartNode.PatternEnd.hasOwnProperty(pCharacter)){// We broke out of the end -- see if this is a new start of the end.
|
|
1137
1138
|
pParserState.Pattern=pParserState.PatternStartNode.PatternEnd[pCharacter];this.appendOutputBuffer(pCharacter,pParserState);}else{pParserState.EndPatternMatchBegan=false;this.appendOutputBuffer(pCharacter,pParserState);}}else if(pParserState.Pattern.hasOwnProperty('PatternEnd')){if(!pParserState.StartPatternMatchComplete){pParserState.StartPatternMatchComplete=true;pParserState.PatternStartNode=pParserState.Pattern;}this.appendOutputBuffer(pCharacter,pParserState);if(pParserState.Pattern.PatternEnd.hasOwnProperty(pCharacter)){// This is the first character of the end pattern.
|
|
1138
1139
|
pParserState.EndPatternMatchBegan=true;// This leaf has a PatternEnd tree, so we will wait until that end is met.
|
|
@@ -1183,12 +1184,19 @@ _this24.flushOutputBuffer(_tmpParserState);fCallback(pError,_tmpParserState.Outp
|
|
|
1183
1184
|
* @return {bool} True if adding the pattern was successful
|
|
1184
1185
|
*/},{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,fParser){if(pPatternStart.length<1){return false;}if(typeof pPatternEnd==='string'&&pPatternEnd.length<1){return false;}var tmpLeaf=this.ParseTree;// Add the tree of leaves iteratively
|
|
1185
1186
|
for(var i=0;i<pPatternStart.length;i++){tmpLeaf=this.addChild(tmpLeaf,pPatternStart[i],i);}if(!tmpLeaf.hasOwnProperty('PatternEnd')){tmpLeaf.PatternEnd={};}var tmpPatternEnd=typeof pPatternEnd==='string'?pPatternEnd:pPatternStart;for(var _i3=0;_i3<tmpPatternEnd.length;_i3++){tmpLeaf=this.addEndChild(tmpLeaf,tmpPatternEnd[_i3],_i3);}tmpLeaf.PatternStartString=pPatternStart;tmpLeaf.PatternEndString=tmpPatternEnd;tmpLeaf.Parse=typeof fParser==='function'?fParser:typeof fParser==='string'?function(){return fParser;}:function(pData){return pData;};return tmpLeaf;}/** Add a Pattern to the Parse Tree
|
|
1186
|
-
* @method
|
|
1187
|
+
* @method addPatternAsync
|
|
1188
|
+
* @param {Object} pPatternStart - The starting string for the pattern (e.g. "${")
|
|
1189
|
+
* @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
|
|
1190
|
+
* @param {function} fParserAsync - The function to parse if this is the matched pattern, once the Pattern End is met. If this is a string, a simple replacement occurs.
|
|
1191
|
+
* @return {bool} True if adding the pattern was successful
|
|
1192
|
+
*/},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,fParserAsync){var tmpLeaf=this.addPattern(pPatternStart,pPatternEnd,fParserAsync);if(tmpLeaf){tmpLeaf.isAsync=true;}}/** Add a Pattern to the Parse Tree
|
|
1193
|
+
* @method addPatternBoth
|
|
1187
1194
|
* @param {Object} pPatternStart - The starting string for the pattern (e.g. "${")
|
|
1188
1195
|
* @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
|
|
1189
1196
|
* @param {function} fParser - The function to parse if this is the matched pattern, once the Pattern End is met. If this is a string, a simple replacement occurs.
|
|
1190
1197
|
* @return {bool} True if adding the pattern was successful
|
|
1191
|
-
*/},{key:"
|
|
1198
|
+
*/},{key:"addPatternBoth",value:function addPatternBoth(pPatternStart,pPatternEnd,fParser,fParserAsync){var tmpLeaf=this.addPattern(pPatternStart,pPatternEnd,fParser);if(tmpLeaf){tmpLeaf.isAsync=true;tmpLeaf.isBoth=true;// When a leaf has both async and non-async versions of the functions, we store the async in fParserAsync.
|
|
1199
|
+
tmpLeaf.ParseAsync=fParserAsync;}}}]);return WordTree;}();module.exports=WordTree;},{}],61:[function(require,module,exports){module.exports={"Metadata":{"UUID":false,"Hash":false,"Name":"","Summary":"","Version":0},"Status":{"Completed":false,"CompletionProgress":0,"CompletionTimeElapsed":0,"TimeStart":0,"TimeEnd":0},"Steps":[],"Errors":[],"Log":[]};},{}],62:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));var FableOperation=/*#__PURE__*/function(_libFableServiceBase6){_inherits(FableOperation,_libFableServiceBase6);var _super17=_createSuper(FableOperation);function FableOperation(pFable,pOptions,pServiceHash){var _this25;_classCallCheck2(this,FableOperation);_this25=_super17.call(this,pFable,pOptions,pServiceHash);// Timestamps will just be the long ints
|
|
1192
1200
|
_this25.timeStamps={};// ProgressTrackers have an object format of: {Hash:'SomeHash',EndTime:UINT,CurrentTime:UINT,TotalCount:INT,CurrentCount:INT}
|
|
1193
1201
|
_this25.progressTrackers={};_this25.serviceType='PhasedOperation';_this25.state=JSON.parse(_OperationStatePrototypeString);_this25.stepMap={};_this25.stepFunctions={};// Match the service instantiation to the operation.
|
|
1194
1202
|
_this25.state.Metadata.Hash=_this25.Hash;_this25.state.Metadata.UUID=_this25.UUID;_this25.state.Metadata.Name=typeof _this25.options.Name=='string'?_this25.options.Name:"Unnamed Operation ".concat(_this25.state.Metadata.UUID);_this25.name=_this25.state.Metadata.Name;_this25.log=_assertThisInitialized(_this25);return _this25;}_createClass2(FableOperation,[{key:"execute",value:function execute(fExecutionCompleteCallback){var _this26=this;if(this.state.Status.TimeStart){return fExecutionCompleteCallback(new Error("Operation [".concat(this.state.Metadata.UUID,"] ").concat(this.state.Metadata.Name," has already been executed!")));}this.state.Status.TimeStart=+new Date();var tmpAnticipate=this.fable.instantiateServiceProviderWithoutRegistration('Anticipate');for(var i=0;i<this.state.Steps;i++){tmpAnticipate.anticipate(this.stepFunctions[this.state.Steps[i].GUIDStep].bind(this));}// Wait for the anticipation to complete
|
|
@@ -3444,19 +3452,19 @@ var tmpTargetElement=window.jQuery(pAddress);tmpTargetElement.removeClass(pClass
|
|
|
3444
3452
|
}}]);return PictContentAssignment;}(libFableServiceBase);module.exports=PictContentAssignment;},{"fable":49}],136:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictDataProvider=/*#__PURE__*/function(_libFableServiceBase14){_inherits(PictDataProvider,_libFableServiceBase14);var _super26=_createSuper(PictDataProvider);function PictDataProvider(pFable,pOptions,pServiceHash){var _this52;_classCallCheck2(this,PictDataProvider);_this52=_super26.call(this,pFable,pOptions,pServiceHash);_this52.serviceType='PictDataProvider';return _this52;}_createClass2(PictDataProvider,[{key:"getDataByAddress",value:function getDataByAddress(pAddress,pData){var tmpData=typeof pData==='undefined'?{}:pData;return this.fable.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},pAddress);}}]);return PictDataProvider;}(libFableServiceBase);module.exports=PictDataProvider;},{"fable":49}],137:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictMeadowEntityProvider=/*#__PURE__*/function(_libFableServiceBase15){_inherits(PictMeadowEntityProvider,_libFableServiceBase15);var _super27=_createSuper(PictMeadowEntityProvider);function PictMeadowEntityProvider(pFable,pOptions,pServiceHash){var _this53;_classCallCheck2(this,PictMeadowEntityProvider);_this53=_super27.call(this,pFable,pOptions,pServiceHash);_this53.serviceType='PictMeadowProvider';if(_this53.fable.settings.PictDefaultURLPrefix){_this53.options.urlPrefix=_this53.fable.settings.PictDefaultURLPrefix;}else if(!_this53.options.urlPrefix){_this53.options.urlPrefix='/1.0/';}if(_this53.fable.settings.PictDefaultDownloadBatchSize){_this53.options.downloadBatchSize=_this53.fable.settings.PictDefaultDownloadBatchSize;}else if(!_this53.options.downloadBatchSize){_this53.options.downloadBatchSize=100;}_this53.restClient=_this53.fable.instantiateServiceProviderWithoutRegistration('RestClient');_this53.cache={};_this53.prepareRequestOptions=function(pOptions){return pOptions;};return _this53;}_createClass2(PictMeadowEntityProvider,[{key:"initializeCache",value:function initializeCache(pEntity){// This should not be happening as often as it's happening.
|
|
3445
3453
|
if(!this.cache.hasOwnProperty(pEntity)){this.cache[pEntity]=this.fable.instantiateServiceProviderWithoutRegistration('ObjectCache');// TODO: Make this a configuration?
|
|
3446
3454
|
// For now cache for 30 seconds.
|
|
3447
|
-
this.cache[pEntity].maxAge=30000;this.cache[pEntity].maxLength=10000;this.fable.Bundle[pEntity]=this.cache[pEntity].RecordMap;}}},{key:"getEntity",value:function getEntity(pEntity,pIDRecord,fCallback){
|
|
3448
|
-
this.cache[pEntity].prune(function(){var tmpPossibleRecord=
|
|
3455
|
+
this.cache[pEntity].maxAge=30000;this.cache[pEntity].maxLength=10000;this.fable.Bundle[pEntity]=this.cache[pEntity].RecordMap;}}},{key:"getEntity",value:function getEntity(pEntity,pIDRecord,fCallback){this.initializeCache(pEntity);// Discard anything from the cache that has expired or is over size.
|
|
3456
|
+
this.cache[pEntity].prune(function(){var _this54=this;var tmpPossibleRecord=this.cache[pEntity].read(pIDRecord);if(tmpPossibleRecord){return fCallback(null,tmpPossibleRecord);}var tmpOptions={url:"".concat(this.options.urlPrefix).concat(pEntity,"/").concat(pIDRecord)};tmpOptions=this.prepareRequestOptions(tmpOptions);return this.restClient.getJSON(tmpOptions,function(pError,pResponse,pBody){if(pBody){_this54.cache[pEntity].put(pBody,pIDRecord);}return fCallback(pError,pBody);});}.bind(this));}},{key:"getEntitySetPage",value:function getEntitySetPage(pEntity,pMeadowFilterExpression,pRecordStartCursor,pRecordCount,fCallback){var tmpURL="".concat(this.options.urlPrefix).concat(pEntity,"s/FilteredTo/").concat(pMeadowFilterExpression,"/").concat(pRecordStartCursor,"/").concat(pRecordCount);return this.restClient.getJSON(tmpURL,function(pDownloadError,pDownloadResponse,pDownloadBody){return fCallback(pDownloadError,pDownloadBody);}.bind(this));}},{key:"getEntitySetRecordCount",value:function getEntitySetRecordCount(pEntity,pMeadowFilterExpression,fCallback){var tmpURL="".concat(this.options.urlPrefix).concat(pEntity,"s/Count/FilteredTo/").concat(pMeadowFilterExpression);return this.restClient.getJSON(tmpURL,function(pError,pResponse,pBody){if(pError){this.log.error("Error getting entity count of [".concat(pEntity,"] filtered to [").concat(pMeadowFilterExpression,"] from url [").concat(tmpURL,"]: ").concat(pError));return fCallback(pError);}var tmpRecordCount=0;if(pBody.Count){tmpRecordCount=pBody.Count;}return fCallback(pError,tmpRecordCount);}.bind(this));}},{key:"getEntitySet",value:function getEntitySet(pEntity,pMeadowFilterExpression,fCallback){// TODO: Should we test for too many record IDs here by string length in pMeadowFilterExpression?
|
|
3449
3457
|
// FBL~ID${pDestinationEntity}~INN~${tmpIDRecordsCommaSeparated}
|
|
3450
3458
|
// If the list is mega-long we can parse it and break it into chunks.
|
|
3451
3459
|
this.initializeCache(pEntity);// Discard anything from the cache that has expired or is over size.
|
|
3452
|
-
this.cache[pEntity].prune(function(){return
|
|
3453
|
-
tmpDownloadURIFragments.push("".concat(
|
|
3454
|
-
|
|
3455
|
-
return fDownloadCallback(pDownloadError);});},function(pFullDownloadError){return fCallback(pFullDownloadError,tmpEntitySet);});});});}}]);return PictMeadowEntityProvider;}(libFableServiceBase);module.exports=PictMeadowEntityProvider;},{"fable":49}],138:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictTemplateProvider=/*#__PURE__*/function(_libFableServiceBase16){_inherits(PictTemplateProvider,_libFableServiceBase16);var _super28=_createSuper(PictTemplateProvider);function PictTemplateProvider(pFable,pOptions,pServiceHash){var
|
|
3460
|
+
this.cache[pEntity].prune(function(){var _this55=this;return this.getEntitySetRecordCount(pEntity,pMeadowFilterExpression,function(pRecordCountError,pRecordCount){if(pRecordCountError){return fCallback(pRecordCountError);}var tmpRecordCount=pRecordCount;if(isNaN(pRecordCount)){_this55.log.error("Entity count did not return a number for [".concat(pEntity,"] filtered to [").concat(pMeadowFilterExpression,"]... something is fatally wrong from the server accessed in getEntitySet call."));return fCallback(new Error('Entity count did not return a number in getEntitySet.'));}var tmpDownloadURIFragments=[];var tmpDownloadBatchSize=_this55.options.downloadBatchSize;for(var i=0;i<tmpRecordCount/tmpDownloadBatchSize;i++){// Generate each of the URI fragments to download
|
|
3461
|
+
tmpDownloadURIFragments.push("".concat(_this55.options.urlPrefix).concat(pEntity,"s/FilteredTo/").concat(pMeadowFilterExpression,"/").concat(i*tmpDownloadBatchSize,"/").concat(tmpDownloadBatchSize));}var tmpEntitySet=[];// Now run these in series (it's possible to parallelize the requests but they would not be in server order)
|
|
3462
|
+
_this55.fable.Utility.eachLimit(tmpDownloadURIFragments,1,function(pURIFragment,fDownloadCallback){_this55.restClient.getJSON(pURIFragment,function(pDownloadError,pDownloadResponse,pDownloadBody){tmpEntitySet=tmpEntitySet.concat(pDownloadBody);// Should we be caching each record?
|
|
3463
|
+
return fDownloadCallback(pDownloadError);});},function(pFullDownloadError){return fCallback(pFullDownloadError,tmpEntitySet);});});}.bind(this));}}]);return PictMeadowEntityProvider;}(libFableServiceBase);module.exports=PictMeadowEntityProvider;},{"fable":49}],138:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictTemplateProvider=/*#__PURE__*/function(_libFableServiceBase16){_inherits(PictTemplateProvider,_libFableServiceBase16);var _super28=_createSuper(PictTemplateProvider);function PictTemplateProvider(pFable,pOptions,pServiceHash){var _this56;_classCallCheck2(this,PictTemplateProvider);_this56=_super28.call(this,pFable,pOptions,pServiceHash);_this56.serviceType='PictTemplateProvider';_this56.templates={};_this56.templateSources={};// Default templates are stored by prefix.
|
|
3456
3464
|
// The longest prefix match is used.
|
|
3457
3465
|
// Case sensitive.
|
|
3458
|
-
|
|
3459
|
-
|
|
3466
|
+
_this56.defaultTemplates=[];// This function can be overloaded to load templates from a database, in a page or other source.
|
|
3467
|
+
_this56.loadTemplateFunction=function(pTemplateHash){return false;};return _this56;}_createClass2(PictTemplateProvider,[{key:"addTemplate",value:function addTemplate(pTemplateHash,pTemplate,pTemplateSource){this.templates[pTemplateHash]=pTemplate;if(typeof pTemplateSource=='string'){this.templateSources[pTemplateHash]=pTemplateSource;}else{this.templateSources[pTemplateHash]="Direct addTemplate('".concat(pTemplateHash,"') function load into PictTemplateProvider [").concat(this.UUID,"]::[").concat(this.Hash,"]");}}},{key:"addDefaultTemplate",value:function addDefaultTemplate(pPrefix,pPostfix,pTemplate,pSource){var tmpSource=typeof pSource=='string'?pSource:"Direct addDefaultTemplate('".concat(pPrefix,"','").concat(pPostfix,"',..) function load into PictTemplateProvider [").concat(this.UUID,"]::[").concat(this.Hash,"]");var tmpDefaultTemplate={prefix:pPrefix,postfix:pPostfix,template:pTemplate,source:tmpSource};if(typeof pTemplate!='string'){this.log.error('PictTemplateProvider.addDefaultTemplate: pTemplate is not a string.');}this.defaultTemplates.push(tmpDefaultTemplate);}},{key:"checkDefaultTemplateHash",value:function checkDefaultTemplateHash(pTemplateHash){/*
|
|
3460
3468
|
* Default templates are managed by postfix and prefix. The use case is things like titles, headers, list
|
|
3461
3469
|
* wrappers, rows, etc.
|
|
3462
3470
|
*
|
|
@@ -3470,11 +3478,11 @@ _this57.loadTemplateFunction=function(pTemplateHash){return false;};return _this
|
|
|
3470
3478
|
if(!this.templates.hasOwnProperty(pTemplateHash)){this.loadTemplate(pTemplateHash);}// If the loading function fails, try to load it from the default templates
|
|
3471
3479
|
if(!this.templates.hasOwnProperty(pTemplateHash)){this.checkDefaultTemplateHash(pTemplateHash);}if(this.templates.hasOwnProperty(pTemplateHash)){return this.templates[pTemplateHash];}else{return false;}}},{key:"loadTemplate",value:function loadTemplate(pTemplateHash){var tmpTemplate=this.loadTemplateFunction(pTemplateHash);if(tmpTemplate){this.templates[pTemplateHash]=tmpTemplate.template;this.templateSources[pTemplateHash]="Loaded in loadTemplate('".concat(pTemplateHash,"') function by PictTemplateProvider [").concat(this.UUID,"]::[").concat(this.Hash,"] from [").concat(tmpTemplate.source,"]");}return tmpTemplate;}}]);return PictTemplateProvider;}(libFableServiceBase);module.exports=PictTemplateProvider;},{"fable":49}],139:[function(require,module,exports){/**
|
|
3472
3480
|
* @author <steven@velozo.com>
|
|
3473
|
-
*/var libFable=require('fable');var Pict=/*#__PURE__*/function(_libFable){_inherits(Pict,_libFable);var _super29=_createSuper(Pict);function Pict(pSettings){var
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
if(
|
|
3477
|
-
|
|
3481
|
+
*/var libFable=require('fable');var Pict=/*#__PURE__*/function(_libFable){_inherits(Pict,_libFable);var _super29=_createSuper(Pict);function Pict(pSettings){var _this57;_classCallCheck2(this,Pict);_this57=_super29.call(this,pSettings);_this57.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");// The templateProvider provides a basic key->template mapping with default fallback capabilities
|
|
3482
|
+
_this57.addAndInstantiateServiceType('TemplateProvider',require('./Pict-Template-Provider.js'));_this57.addAndInstantiateServiceType('EntityProvider',require('./Pict-Meadow-EntityProvider.js'));_this57.addAndInstantiateServiceType('DataProvider',require('./Pict-DataProvider.js'));_this57.addAndInstantiateServiceType('ContentAssignment',require('./Pict-Content-Assignment.js'));_this57.addAndInstantiateServiceType('CSSMap',require('./Pict-CSS.js'));_this57.instantiateServiceProvider('MetaTemplate');_this57.instantiateServiceProvider('DataGeneration');_this57.manifest=_this57.instantiateServiceProvider('Manifest');_this57.AppData={};_this57.Bundle={};// Log noisness goes from 0 - 5, where 5 is show me everything.
|
|
3483
|
+
_this57.LogNoisiness=0;// Load manifest sets
|
|
3484
|
+
if(_this57.settings.Manifests){_this57.loadManifestSet(_this57.settings.Manifests);}_this57._DefaultPictTemplatesInitialized=false;_this57.initializePictTemplateEngine();_this57.addServiceType('PictView',require('pict-view'));_this57.addServiceType('PictApplication',require('pict-application'));// Expose the named views directly, through a convenience accessor
|
|
3485
|
+
_this57.views=_this57.servicesMap.PictView;return _this57;}// Load manifests in as Hashed services
|
|
3478
3486
|
_createClass2(Pict,[{key:"loadManifestSet",value:function loadManifestSet(pManifestSet){if(_typeof(pManifestSet)!='object'){this.log.warn("PICT [".concat(this.UUID,"] could not load Manifest Set; pManifestSet was not an object."));return false;}var tmpManifestKeys=Object.keys(pManifestSet);if(tmpManifestKeys.length>0){for(var i=0;i<tmpManifestKeys.length;i++){// Load each manifest
|
|
3479
3487
|
var tmpManifestKey=tmpManifestKeys[i];this.instantiateServiceProvider('Manifest',pManifestSet[tmpManifestKey],tmpManifestKey);}}}// Just passing an options will construct one for us.
|
|
3480
3488
|
// Passing a hash will set the hash.
|
|
@@ -3484,7 +3492,7 @@ if(pViewPrototype.hasOwnProperty('default_configuration')){tmpOptions=this.fable
|
|
|
3484
3492
|
// Passing a hash will set the hash.
|
|
3485
3493
|
// Passing a prototype will use that!
|
|
3486
3494
|
},{key:"addApplication",value:function addApplication(pApplicationHash,pOptions,pApplicationPrototype){var tmpOptions=_typeof(pOptions)=='object'?pOptions:{};var tmpApplicationHash=typeof pApplicationHash=='string'?pApplicationHash:this.fable.getUUID();if(typeof pApplicationPrototype!='undefined'){// If the prototype has a default_configuration, it will be merged with options.
|
|
3487
|
-
if(pApplicationPrototype.hasOwnProperty('default_configuration')){tmpOptions=this.fable.Utility.extend({},pApplicationPrototype.default_configuration,tmpOptions);}return this.instantiateServiceProviderFromPrototype('PictApplication',tmpOptions,tmpApplicationHash,pApplicationPrototype);}else{return this.instantiateServiceProvider('PictApplication',tmpOptions,tmpApplicationHash);}}},{key:"initializePictTemplateEngine",value:function initializePictTemplateEngine(){var
|
|
3495
|
+
if(pApplicationPrototype.hasOwnProperty('default_configuration')){tmpOptions=this.fable.Utility.extend({},pApplicationPrototype.default_configuration,tmpOptions);}return this.instantiateServiceProviderFromPrototype('PictApplication',tmpOptions,tmpApplicationHash,pApplicationPrototype);}else{return this.instantiateServiceProvider('PictApplication',tmpOptions,tmpApplicationHash);}}},{key:"initializePictTemplateEngine",value:function initializePictTemplateEngine(){var _this58=this;/*
|
|
3488
3496
|
*
|
|
3489
3497
|
* To stave off madness, these are inefficient for now. The wkhtmltopdf renderer leaves much to be desired
|
|
3490
3498
|
* in the way of feedback with regards to javascript compatibility.
|
|
@@ -3492,27 +3500,44 @@ if(pApplicationPrototype.hasOwnProperty('default_configuration')){tmpOptions=thi
|
|
|
3492
3500
|
*/if(!this._DefaultPictTemplatesInitialized){// Expects one of the following:
|
|
3493
3501
|
// {~E:Book^AppData.Some.Address.IDBook^Render-Book-Template~}
|
|
3494
3502
|
// ...meaning GET BOOK with IDBook FROM AppData.Some.Address.IDBook and render it to Render-Book-Template
|
|
3495
|
-
var fEntityRender=function fEntityRender(pHash,pData,fCallback){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(
|
|
3496
|
-
var tmpAddressParts=tmpHash.split('^');if(tmpAddressParts.length<2){
|
|
3497
|
-
tmpEntityID=
|
|
3498
|
-
if(!tmpEntity||!tmpEntityID){
|
|
3499
|
-
|
|
3500
|
-
if(tmpEntityTemplate){return
|
|
3501
|
-
var
|
|
3502
|
-
var tmpHashParts=tmpHash.split('|');// For now just check truthiness
|
|
3503
|
-
if(_this59.manifest.getValueByHash({AppData:_this59.AppData,Bundle:_this59.Bundle,Record:tmpData},tmpHashParts[0])){return tmpHashParts[1];}else{return'';}};this.MetaTemplate.addPattern('{~NotEmpty:','~}',fNotEmptyRender);this.MetaTemplate.addPattern('{~NE:','~}',fNotEmptyRender);// {~T:Template:AddressOfData~}
|
|
3504
|
-
var fTemplateRender=function fTemplateRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this59.LogNoisiness>4){_this59.log.trace("PICT Template [fTemplateRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this59.LogNoisiness>0){_this59.log.trace("PICT Template [fTemplateRender]::[".concat(tmpHash,"]"));}var tmpTemplateHash=false;var tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
|
|
3503
|
+
var fEntityRender=function fEntityRender(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 [fEntityRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT Template [fEntityRender]::[".concat(tmpHash,"]"));}var tmpEntity=false;var tmpEntityID=false;var tmpEntityTemplate=false;// This expression requires 2 parts -- a third is optional, and, if present, is the template to render to.
|
|
3504
|
+
var tmpAddressParts=tmpHash.split('^');if(tmpAddressParts.length<2){_this58.log.warn("Pict: Entity Render: Entity or entity ID not resolved for [".concat(tmpHash,"]"));return tmpCallback(Error("Pict: Entity Render: Entity or entity ID not resolved for [".concat(tmpHash,"]")),'');}tmpEntity=tmpAddressParts[0].trim();tmpEntityID=tmpAddressParts[1].trim();tmpEntityTemplate=tmpAddressParts[2].trim();if(!isNaN(tmpEntityID)){tmpEntityID=parseInt(tmpEntityID);}else{// This is an address, so we need to get the value at the address
|
|
3505
|
+
tmpEntityID=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpEntityID);}// No Entity or EntityID
|
|
3506
|
+
if(!tmpEntity||!tmpEntityID){_this58.log.warn("Pict: Entity Render: Entity or entity ID not resolved for [".concat(tmpHash,"] Entity: ").concat(tmpEntity," ID: ").concat(tmpEntityID));return tmpCallback(Error("Pict: Entity Render: Entity or entity ID not resolved for [".concat(tmpHash,"] Entity: ").concat(tmpEntity," ID: ").concat(tmpEntityID)),'');}_this58.log.trace("Pict: Entity Render: Entity [".concat(tmpEntity,"] with ID [").concat(tmpEntityID,"] as template [").concat(tmpEntityTemplate,"] from [").concat(tmpHash,"]"));// Now try to get the entity
|
|
3507
|
+
_this58.EntityProvider.getEntity(tmpEntity,tmpEntityID,function(pError,pRecord){if(pError){this.log.error("Pict: Entity Render: Error getting entity [".concat(tmpEntity,"] with ID [").concat(tmpEntityID,"] for [").concat(tmpHash,"]: ").concat(pError),pError);return tmpCallback(pError,'');}// Now render the template
|
|
3508
|
+
if(tmpEntityTemplate){return this.parseTemplateByHash(tmpEntityTemplate,pRecord,tmpCallback);}else{return tmpCallback(null,'');}}.bind(_this58));};this.MetaTemplate.addPatternAsync('{~E:','~}',fEntityRender);this.MetaTemplate.addPatternAsync('{~Entity:','~}',fEntityRender);// {~T:Template:AddressOfData~}
|
|
3509
|
+
var fTemplateRender=function fTemplateRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fTemplateRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT Template [fTemplateRender]::[".concat(tmpHash,"]"));}var tmpTemplateHash=false;var tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
|
|
3505
3510
|
var tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
|
|
3506
|
-
if(!tmpTemplateHash){
|
|
3507
|
-
return
|
|
3508
|
-
var fTemplateSetRender=function fTemplateSetRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this59.LogNoisiness>4){_this59.log.trace("PICT Template [fTemplateSetRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this59.LogNoisiness>0){_this59.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)
|
|
3511
|
+
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.
|
|
3512
|
+
return _this58.parseTemplateByHash(tmpTemplateHash,pData);}else{return _this58.parseTemplateByHash(tmpTemplateHash,_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpAddressOfData));}};var fTemplateRenderAsync=function fTemplateRenderAsync(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 [fTemplateRenderAsync]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>0){_this58.log.trace("PICT Template [fTemplateRenderAsync]::[".concat(tmpHash,"]"));}var tmpTemplateHash=false;var tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
|
|
3509
3513
|
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){
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
var
|
|
3515
|
-
if(!
|
|
3514
|
+
if(!tmpTemplateHash){_this58.log.warn("Pict: Template Render Async: TemplateHash not resolved for [".concat(tmpHash,"]"));return"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.
|
|
3515
|
+
// The async portion of this is a mind bender because of how entry can happen dynamically from templates
|
|
3516
|
+
return _this58.parseTemplateByHash(tmpTemplateHash,pData,function(pError,pValue){if(pError){return tmpCallback(pError,'');}return tmpCallback(null,pValue);});}else{return _this58.parseTemplateByHash(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('{~T:','~}',fTemplateRender,fTemplateRenderAsync);this.MetaTemplate.addPatternBoth('{~Template:','~}',fTemplateRender,fTemplateRenderAsync);// {~TS:Template:AddressOfDataSet~}
|
|
3517
|
+
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)
|
|
3518
|
+
var tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
|
|
3519
|
+
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.
|
|
3520
|
+
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)
|
|
3521
|
+
var tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
|
|
3522
|
+
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.
|
|
3523
|
+
// The async portion of this is a mind bender because of how entry can happen dynamically from templates
|
|
3524
|
+
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~}
|
|
3525
|
+
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
|
|
3526
|
+
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
|
|
3527
|
+
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
|
|
3528
|
+
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
|
|
3529
|
+
tmpDayJS=tmpDayJS.tz(_this58.fable.Dates.dayJS.tz.guess());}return tmpDayJS.format('YYYY-MM-DD');});// Output the date as a YYYY-MM-DD string
|
|
3530
|
+
// Takes in the format as the second parameter: {~DateYMD:AppData.Some.Date^YYYY-MM-DD~}
|
|
3531
|
+
this.MetaTemplate.addPattern('{~DateFormat:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};var tmpDateValueSet=tmpHash.split('^');if(tmpDateValueSet.length<2){_this58.log.error("PICT Template [fDateFormat]::[".concat(tmpHash,"] did not have a valid format string and date."));return'';}var tmpDateValue=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpDateValueSet[0]);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
|
|
3532
|
+
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
|
|
3533
|
+
if(_this58.options.Timezone){tmpDayJS=tmpDayJS.tz(_this58.options.Timezone);}else{tmpDayJS=tmpDayJS.tz(_this58.fable.Dates.dayJS.tz.guess());}}catch(_unused2){_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
|
|
3534
|
+
tmpDayJS=tmpDayJS.tz(_this58.fable.Dates.dayJS.tz.guess());}return tmpDayJS.format(tmpDateValueSet[1]);});// {NE~Some.Address|If the left value is truthy, render this value.~}
|
|
3535
|
+
var fNotEmptyRender=function fNotEmptyRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fNotEmptyRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>2){_this58.log.trace("PICT Template [fNotEmptyRender]::[".concat(tmpHash,"]"));}// Should switch this to indexOf so pipes can be in the content.
|
|
3536
|
+
var tmpHashParts=tmpHash.split('|');// For now just check truthiness
|
|
3537
|
+
if(_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHashParts[0])){return tmpHashParts[1];}else{return'';}};this.MetaTemplate.addPattern('{~NotEmpty:','~}',fNotEmptyRender);this.MetaTemplate.addPattern('{~NE:','~}',fNotEmptyRender);var fRandomNumberString=function fRandomNumberString(pHash,pData){var tmpHash=pHash.trim();if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fRandomNumberString]::[".concat(tmpHash,"]"));}var tmpStringLength=4;var tmpMaxNumber=9999;if(tmpHash.length>0){var tmpHashParts=tmpHash.split(',');if(tmpHashParts.length>0){tmpStringLength=parseInt(tmpHashParts[0]);}if(tmpHashParts.length>1){tmpMaxNumber=parseInt(tmpHashParts[1]);}}return _this58.DataGeneration.randomNumericString(tmpStringLength,tmpMaxNumber);};this.MetaTemplate.addPattern('{~RandomNumberString:','~}',fRandomNumberString);this.MetaTemplate.addPattern('{~RNS:','~}',fRandomNumberString);var fRandomNumber=function fRandomNumber(pHash,pData){var tmpHash=pHash.trim();if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fRandomNumber]::[".concat(tmpHash,"]"));}var tmpMinimumNumber=0;var tmpMaxNumber=9999999;if(tmpHash.length>0){var tmpHashParts=tmpHash.split(',');if(tmpHashParts.length>0){tmpMinimumNumber=parseInt(tmpHashParts[0]);}if(tmpHashParts.length>1){tmpMaxNumber=parseInt(tmpHashParts[1]);}}return _this58.DataGeneration.randomIntegerBetween(tmpMinimumNumber,tmpMaxNumber);};this.MetaTemplate.addPattern('{~RandomNumber:','~}',fRandomNumber);this.MetaTemplate.addPattern('{~RN:','~}',fRandomNumber);var fPascalCaseIdentifier=function fPascalCaseIdentifier(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this58.LogNoisiness>4){_this58.log.trace("PICT Template [fPascalCaseIdentifier]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this58.LogNoisiness>3){_this58.log.trace("PICT Template [fPascalCaseIdentifier]::[".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 _this58.DataFormat.cleanNonAlphaCharacters(_this58.DataFormat.capitalizeEachWord(tmpValue));};this.MetaTemplate.addPattern('{~PascalCaseIdentifier:','~}',fPascalCaseIdentifier);var fLogValue=function fLogValue(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};var tmpValue=_this58.manifest.getValueByHash({AppData:_this58.AppData,Bundle:_this58.Bundle,Record:tmpData},tmpHash);var tmpValueType=_typeof(tmpValue);if(tmpValue==null||tmpValueType=='undefined'){_this58.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is ").concat(tmpValueType,"."));}else if(tmpValueType=='object'){_this58.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is an obect."),tmpValue);}else{_this58.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is a ").concat(tmpValueType," = [").concat(tmpValue,"]"));}return'';};this.MetaTemplate.addPattern('{~LogValue:','~}',fLogValue);this.MetaTemplate.addPattern('{~LV:','~}',fLogValue);var fLogStatement=function fLogStatement(pHash,pData){var tmpHash=pHash.trim();_this58.log.trace("PICT Template Log Message: ".concat(tmpHash));return'';};this.MetaTemplate.addPattern('{~LogStatement:','~}',fLogStatement);this.MetaTemplate.addPattern('{~LS:','~}',fLogStatement);var fBreakpoint=function fBreakpoint(pHash,pData){var tmpHash=pHash.trim();var tmpError=new Error("PICT Template Breakpoint: ".concat(tmpHash));_this58.log.trace("PICT Template Breakpoint: ".concat(tmpHash),tmpError.stack);debugger;return'';};this.MetaTemplate.addPattern('{~Breakpoint','~}',fBreakpoint);this._DefaultPictTemplatesInitialized=true;}}},{key:"parseTemplate",value:function parseTemplate(pTemplateString,pData,fCallback){var tmpData=_typeof(pData)==='object'?pData:{};return this.MetaTemplate.parseString(pTemplateString,tmpData,fCallback);}},{key:"parseTemplateByHash",value:function parseTemplateByHash(pTemplateHash,pData,fCallback){var tmpTemplateString=this.TemplateProvider.getTemplate(pTemplateHash);// TODO: Unsure if returning empty is always the right behavior -- if it isn't we will use config to set the behavior
|
|
3538
|
+
if(!tmpTemplateString){tmpTemplateString='';}return this.parseTemplate(tmpTemplateString,pData,fCallback);}},{key:"parseTemplateSet",value:function parseTemplateSet(pTemplateString,pDataSet,fCallback){var _this59=this;// TODO: This will need streaming -- for now janky old string append does the trick
|
|
3539
|
+
var tmpValue='';if(typeof fCallback=='function'){if(Array.isArray(pDataSet)||_typeof(pDataSet)=='object'){this.Utility.eachLimit(pDataSet,1,function(pRecord,fRecordTemplateCallback){return _this59.parseTemplate(pTemplateString,pRecord,function(pError,pTemplateResult){tmpValue+=pTemplateResult;return fRecordTemplateCallback();});},function(pError){return fCallback(pError,tmpValue);});}else{return fCallback(Error('Pict: Template Set: pDataSet is not an array or object.'),'');}}else{if(Array.isArray(pDataSet)||_typeof(pDataSet)=='object'){if(Array.isArray(pDataSet)){for(var i=0;i<pDataSet.length;i++){tmpValue+=this.parseTemplate(pTemplateString,pDataSet[i]);}}else{var tmpKeys=Object.keys(pDataSet);for(var _i23=0;_i23<tmpKeys.length;_i23++){tmpValue+=this.parseTemplate(pTemplateString,pDataSet[tmpKeys[_i23]]);}}return tmpValue;}else{return'';}}}},{key:"parseTemplateSetByHash",value:function parseTemplateSetByHash(pTemplateHash,pDataSet,fCallback){var tmpTemplateString=this.TemplateProvider.getTemplate(pTemplateHash);// TODO: Unsure if returning empty is always the right behavior -- if it isn't we will use config to set the behavior
|
|
3540
|
+
if(!tmpTemplateString){tmpTemplateString='';}return this.parseTemplateSet(tmpTemplateString,pDataSet,fCallback);}}]);return Pict;}(libFable);;module.exports=Pict;module.exports.PictApplicationClass=require('pict-application');module.exports.PictViewClass=require('pict-view');module.exports.EnvironmentLog=require('./environments/Pict-Environment-Log.js');module.exports.EnvironmentObject=require('./environments/Pict-Environment-Object.js');// This is to help understand the type of enivironement we're executing in
|
|
3516
3541
|
module.exports.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");},{"./Pict-CSS.js":134,"./Pict-Content-Assignment.js":135,"./Pict-DataProvider.js":136,"./Pict-Meadow-EntityProvider.js":137,"./Pict-Template-Provider.js":138,"./environments/Pict-Environment-Log.js":140,"./environments/Pict-Environment-Object.js":141,"fable":49,"pict-application":90,"pict-view":91}],140:[function(require,module,exports){/**
|
|
3517
3542
|
* Pict browser shim loader
|
|
3518
3543
|
* @author <steven@velozo.com>
|