fable 3.0.79 → 3.0.81
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/fable.compatible.js +18 -5
- package/dist/fable.compatible.min.js +2 -2
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +18 -5
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/services/Fable-Service-DataFormat.js +18 -0
- package/source/services/Fable-Service-Operation.js +194 -0
- package/source/services/Fable-Service-Utility.js +5 -1
- package/test/DataFormat-StringDateFormatting_tests.js +28 -0
- package/test/Utility_tests.js +1 -0
package/dist/fable.compatible.js
CHANGED
|
@@ -3034,7 +3034,7 @@ return'';}else{var tmpPadLength=pTargetLength-pString.length;if(tmpPadLength>tmp
|
|
|
3034
3034
|
* @param {number} pTimeEnd
|
|
3035
3035
|
* @returns {string} - HH:MM:SS.mmm
|
|
3036
3036
|
*/},{key:"formatTimeDelta",value:function formatTimeDelta(pTimeStart,pTimeEnd){if(typeof pTimeStart!='number'||typeof pTimeEnd!='number'){return'';}return this.formatTimeSpan(pTimeEnd-pTimeStart);}// THE FOLLOWING TERRIBLE FUNCTIONS ARE FOR QT / WKHTMLTOPDF when luxon and moment don't work so well
|
|
3037
|
-
},{key:"getMonthFromDate",value:function getMonthFromDate(pJavascriptDate){var tmpMonths=["January","February","March","April","May","June","July","August","September","October","November","December"];return tmpMonths[pJavascriptDate.getMonth()];}},{key:"getMonthAbbreviatedFromDate",value:function getMonthAbbreviatedFromDate(pJavascriptDate){var tmpMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return tmpMonths[pJavascriptDate.getMonth()];}},{key:"formatSortableStringFromDate",value:function formatSortableStringFromDate(pDate){return pDate.getFullYear()+this.stringPadStart(pDate.getMonth(),2,'0')+this.stringPadStart(pDate.getDate(),2,'0');}/*************************************************************************
|
|
3037
|
+
},{key:"getMonthFromDate",value:function getMonthFromDate(pJavascriptDate){var tmpMonths=["January","February","March","April","May","June","July","August","September","October","November","December"];return tmpMonths[pJavascriptDate.getMonth()];}},{key:"getMonthAbbreviatedFromDate",value:function getMonthAbbreviatedFromDate(pJavascriptDate){var tmpMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return tmpMonths[pJavascriptDate.getMonth()];}},{key:"formatMonthDayYearFromDate",value:function formatMonthDayYearFromDate(pJavascriptDate,pStrict){var tmpStrict=typeof pStrict!=='undefined'?pStrict:false;var tmpMonth=pJavascriptDate.getMonth()+1;var tmpDay=pJavascriptDate.getDate();var tmpYear=pJavascriptDate.getFullYear();if(tmpStrict){tmpMonth=this.stringPadStart(tmpMonth,2,'0');tmpDay=this.stringPadStart(tmpDay,2,'0');tmpYear=this.stringPadStart(tmpYear,4,'0');}return"".concat(tmpMonth,"/").concat(tmpDay,"/").concat(tmpYear);}},{key:"formatSortableStringFromDate",value:function formatSortableStringFromDate(pDate){return pDate.getFullYear()+this.stringPadStart(pDate.getMonth(),2,'0')+this.stringPadStart(pDate.getDate(),2,'0');}/*************************************************************************
|
|
3038
3038
|
* String Tokenization Functions
|
|
3039
3039
|
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /**
|
|
3040
3040
|
* Return the string before the matched substring.
|
|
@@ -3236,8 +3236,20 @@ for(var i=0;i<pPatternStart.length;i++){tmpLeaf=this.addChild(tmpLeaf,pPatternSt
|
|
|
3236
3236
|
* @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
|
|
3237
3237
|
* @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.
|
|
3238
3238
|
* @return {bool} True if adding the pattern was successful
|
|
3239
|
-
*/},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,fParser){var tmpLeaf=this.addPattern(pPatternStart,pPatternEnd,fParser);if(tmpLeaf){tmpLeaf.isAsync=true;}}}]);return WordTree;}();module.exports=WordTree;},{}],120:[function(require,module,exports){module.exports={"Metadata":{"UUID":false,"Hash":false,"Title":"","Summary":"","Version":0},"Status":{"Completed":false,"CompletionProgress":0,"CompletionTimeElapsed":0,"Steps":1,"StepsCompleted":0,"StartTime":0,"EndTime":0},"Errors":[],"Log":[]};},{}],121:[function(require,module,exports){var libFableServiceBase=require('../Fable-ServiceManager.js').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 _this28;_classCallCheck2(this,FableOperation);_this28=_super17.call(this,pFable,pOptions,pServiceHash)
|
|
3240
|
-
_this28.
|
|
3239
|
+
*/},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,fParser){var tmpLeaf=this.addPattern(pPatternStart,pPatternEnd,fParser);if(tmpLeaf){tmpLeaf.isAsync=true;}}}]);return WordTree;}();module.exports=WordTree;},{}],120:[function(require,module,exports){module.exports={"Metadata":{"UUID":false,"Hash":false,"Title":"","Summary":"","Version":0},"Status":{"Completed":false,"CompletionProgress":0,"CompletionTimeElapsed":0,"Steps":1,"StepsCompleted":0,"StartTime":0,"EndTime":0},"Errors":[],"Log":[]};},{}],121:[function(require,module,exports){var libFableServiceBase=require('../Fable-ServiceManager.js').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 _this28;_classCallCheck2(this,FableOperation);_this28=_super17.call(this,pFable,pOptions,pServiceHash);// Timestamps will just be the long ints
|
|
3240
|
+
_this28.timeStamps={};// ProgressTrackers have an object format of: {Hash:'SomeHash',EndTime:UINT,CurrentTime:UINT,TotalCount:INT,CurrentCount:INT}
|
|
3241
|
+
_this28.progressTrackers={};_this28.serviceType='PhasedOperation';_this28.state=JSON.parse(_OperationStatePrototypeString);// Match the service instantiation to the operation.
|
|
3242
|
+
_this28.state.Metadata.Hash=_this28.Hash;_this28.state.Metadata.UUID=_this28.UUID;_this28.name=typeof _this28.options.Name=='string'?_this28.options.Name:"Unnamed Operation ".concat(_this28.state.Metadata.UUID);_this28.log=_assertThisInitialized(_this28);return _this28;}_createClass2(FableOperation,[{key:"writeOperationLog",value:function writeOperationLog(pLogLevel,pLogText,pLogObject){this.state.Log.push("".concat(new Date().toUTCString()," [").concat(pLogLevel,"]: ").concat(pLogText));if(_typeof(pLogObject)=='object'){this.state.Log.push(JSON.stringify(pLogObject));}}},{key:"writeOperationErrors",value:function writeOperationErrors(pLogText,pLogObject){this.state.Errors.push("".concat(pLogText));if(_typeof(pLogObject)=='object'){this.state.Errors.push(JSON.stringify(pLogObject));}}},{key:"trace",value:function trace(pLogText,pLogObject){this.writeOperationLog('TRACE',pLogText,pLogObject);this.fable.log.trace(pLogText,pLogObject);}},{key:"debug",value:function debug(pLogText,pLogObject){this.writeOperationLog('DEBUG',pLogText,pLogObject);this.fable.log.debug(pLogText,pLogObject);}},{key:"info",value:function info(pLogText,pLogObject){this.writeOperationLog('INFO',pLogText,pLogObject);this.fable.log.info(pLogText,pLogObject);}},{key:"warn",value:function warn(pLogText,pLogObject){this.writeOperationLog('WARN',pLogText,pLogObject);this.fable.log.warn(pLogText,pLogObject);}},{key:"error",value:function error(pLogText,pLogObject){this.writeOperationLog('ERROR',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.error(pLogText,pLogObject);}},{key:"fatal",value:function fatal(pLogText,pLogObject){this.writeOperationLog('FATAL',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.fatal(pLogText,pLogObject);}/************************************************************************
|
|
3243
|
+
* BEGINNING OF --> Telemetry Helpers
|
|
3244
|
+
*/},{key:"createTimeStamp",value:function createTimeStamp(pTimeStampHash){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';this.timeStamps[tmpTimeStampHash]=+new Date();return this.timeStamps[tmpTimeStampHash];}},{key:"getTimeDelta",value:function getTimeDelta(pTimeStampHash){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';if(this.timeStamps.hasOwnProperty(tmpTimeStampHash)){var tmpEndTime=+new Date();return tmpEndTime-this.timeStamps[tmpTimeStampHash];}else{return-1;}}},{key:"logTimeDelta",value:function logTimeDelta(pTimeStampHash,pMessage){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';var tmpMessage=typeof pMessage!=='undefined'?pMessage:"Elapsed for ".concat(tmpTimeStampHash,": ");var tmpOperationTime=this.getTimeDelta(pTimeStampHash);this.info(tmpMessage+' ('+tmpOperationTime+'ms)');return tmpOperationTime;}},{key:"createProgressTracker",value:function createProgressTracker(pTotalOperations,pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'DefaultProgressTracker';var tmpTotalOperations=typeof pTotalOperations=='number'?pTotalOperations:100;var tmpProgressTracker={Hash:tmpProgressTrackerHash,StartTime:this.createTimeStamp(tmpProgressTrackerHash),EndTime:0,CurrentTime:0,PercentComplete:-1,AverageOperationTime:-1,EstimatedCompletionTime:-1,TotalCount:tmpTotalOperations,CurrentCount:-1};this.progressTrackers[tmpProgressTrackerHash]=tmpProgressTracker;return tmpProgressTracker;}},{key:"solveProgressTrackerStatus",value:function solveProgressTrackerStatus(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'DefaultProgressTracker';if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.createProgressTracker(100,tmpProgressTrackerHash);}var tmpProgressTracker=this.progressTrackers[tmpProgressTrackerHash];tmpProgressTracker.CurrentTime=this.getTimeDelta(tmpProgressTracker.Hash);if(tmpProgressTracker.CurrentCount>0&&tmpProgressTracker.TotalCount>0){tmpProgressTracker.PercentComplete=tmpProgressTracker.CurrentCount/tmpProgressTracker.TotalCount*100.0;}if(tmpProgressTracker.CurrentCount>0&&tmpProgressTracker.CurrentTime>0){tmpProgressTracker.AverageOperationTime=tmpProgressTracker.CurrentTime/tmpProgressTracker.CurrentCount;}if(tmpProgressTracker.CurrentCount<tmpProgressTracker.TotalCount&&tmpProgressTracker.AverageOperationTime>0){tmpProgressTracker.EstimatedCompletionTime=(tmpProgressTracker.TotalCount-tmpProgressTracker.CurrentCount)*tmpProgressTracker.AverageOperationTime;}}},{key:"updateProgressTrackerStatus",value:function updateProgressTrackerStatus(pProgressTrackerHash,pCurrentOperations){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'DefaultProgressTracker';var tmpCurrentOperations=parseInt(pCurrentOperations);if(isNaN(tmpCurrentOperations)){return false;}if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.createProgressTracker(100,tmpProgressTrackerHash);}this.progressTrackers[tmpProgressTrackerHash].CurrentCount=tmpCurrentOperations;this.progressTrackers[tmpProgressTrackerHash].CurrentTime=this.getTimeDelta(tmpProgressTrackerHash);this.solveProgressTrackerStatus(tmpProgressTrackerHash);return this.progressTrackers[tmpProgressTrackerHash];}},{key:"incrementProgressTrackerStatus",value:function incrementProgressTrackerStatus(pProgressTrackerHash,pIncrementSize){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'DefaultProgressTracker';var tmpIncrementSize=parseInt(pIncrementSize);if(isNaN(tmpIncrementSize)){return false;}if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.createProgressTracker(100,tmpProgressTrackerHash);}this.progressTrackers[tmpProgressTrackerHash].CurrentCount=this.progressTrackers[tmpProgressTrackerHash].CurrentCount+tmpIncrementSize;this.progressTrackers[tmpProgressTrackerHash].CurrentTime=this.getTimeDelta(tmpProgressTrackerHash);this.solveProgressTrackerStatus(tmpProgressTrackerHash);return this.progressTrackers[tmpProgressTrackerHash];}},{key:"setProgressTrackerEndTime",value:function setProgressTrackerEndTime(pProgressTrackerHash,pCurrentOperations){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'DefaultProgressTracker';var tmpCurrentOperations=parseInt(pCurrentOperations);if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){return false;}if(!isNaN(tmpCurrentOperations)){this.updateProgressTrackerStatus(tmpProgressTrackerHash,tmpCurrentOperations);}this.progressTrackers[tmpProgressTrackerHash].EndTime=this.getTimeDelta(tmpProgressTrackerHash);this.solveProgressTrackerStatus(tmpProgressTrackerHash);return this.progressTrackers[tmpProgressTrackerHash];}},{key:"printProgressTrackerStatus",value:function printProgressTrackerStatus(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'DefaultProgressTracker';if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.info(">> Progress Tracker ".concat(tmpProgressTrackerHash," does not exist! No stats to display."));}else{var tmpProgressTracker=this.progressTrackers[tmpProgressTrackerHash];if(tmpProgressTracker.CurrentCount<1){this.info(">> Progress Tracker ".concat(tmpProgressTracker.Hash," has no completed operations. ").concat(tmpProgressTracker.CurrentTime,"ms have elapsed since it was started."));}else if(tmpProgressTracker.EndTime<1){this.info(">> Progress Tracker ".concat(tmpProgressTracker.Hash," is ").concat(tmpProgressTracker.PercentComplete.toFixed(3),"% completed - ").concat(tmpProgressTracker.CurrentCount," / ").concat(tmpProgressTracker.TotalCount," operations over ").concat(tmpProgressTracker.CurrentTime,"ms (median ").concat(tmpProgressTracker.AverageOperationTime.toFixed(3)," per). Estimated completion in ").concat(tmpProgressTracker.EstimatedCompletionTime.toFixed(0),"ms or ").concat((tmpProgressTracker.EstimatedCompletionTime/1000/60).toFixed(2),"minutes"));}else{this.info(">> Progress Tracker ".concat(tmpProgressTracker.Hash," is done and completed ").concat(tmpProgressTracker.CurrentCount," / ").concat(tmpProgressTracker.TotalCount," operations in ").concat(tmpProgressTracker.EndTime,"ms."));}}}// logMemoryResourcesUsed()
|
|
3245
|
+
// {
|
|
3246
|
+
//
|
|
3247
|
+
// const tmpResourcesUsed = process.memoryUsage().heapUsed / 1024 / 1024;
|
|
3248
|
+
// this.info(`Memory usage at ${Math.round(tmpResourcesUsed * 100) / 100} MB`);
|
|
3249
|
+
// }
|
|
3250
|
+
/*
|
|
3251
|
+
* END OF --> Logging and Telemetry Helpers
|
|
3252
|
+
************************************************************************/}]);return FableOperation;}(libFableServiceBase);module.exports=FableOperation;},{"../Fable-ServiceManager.js":108,"./Fable-Service-Operation-DefaultSettings.js":120}],122:[function(require,module,exports){(function(Buffer){(function(){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;var libSimpleGet=require('simple-get');var libCookie=require('cookie');var FableServiceRestClient=/*#__PURE__*/function(_libFableServiceBase7){_inherits(FableServiceRestClient,_libFableServiceBase7);var _super18=_createSuper(FableServiceRestClient);function FableServiceRestClient(pFable,pOptions,pServiceHash){var _this29;_classCallCheck2(this,FableServiceRestClient);_this29=_super18.call(this,pFable,pOptions,pServiceHash);_this29.TraceLog=false;if(_this29.options.TraceLog||_this29.fable.TraceLog){_this29.TraceLog=true;}_this29.dataFormat=_this29.fable.services.DataFormat;_this29.serviceType='RestClient';_this29.cookie=false;// This is a function that can be overridden, to allow the management
|
|
3241
3253
|
// of the request options before they are passed to the request library.
|
|
3242
3254
|
_this29.prepareRequestOptions=function(pOptions){return pOptions;};return _this29;}_createClass2(FableServiceRestClient,[{key:"simpleGet",get:function get(){return libSimpleGet;}},{key:"prepareCookies",value:function prepareCookies(pRequestOptions){if(this.cookie){var tmpCookieObject=this.cookie;if(!pRequestOptions.hasOwnProperty('headers')){pRequestOptions.headers={};}var tmpCookieKeys=Object.keys(tmpCookieObject);if(tmpCookieKeys.length>0){// Only grab the first for now.
|
|
3243
3255
|
pRequestOptions.headers.cookie=libCookie.serialize(tmpCookieKeys[0],tmpCookieObject[tmpCookieKeys[0]]);}}return pRequestOptions;}},{key:"preRequest",value:function preRequest(pOptions){// Validate the options object
|
|
@@ -3308,13 +3320,14 @@ var tmpChunkSize=typeof pChunkSize=='number'?pChunkSize:0;var tmpChunkCache=type
|
|
|
3308
3320
|
var tmpDateParts=pISOString.split(/\D+/);// Set up a date object with the current time.
|
|
3309
3321
|
var tmpReturnDate=new Date();// Track the number of hours we need to adjust the date by based on the timezone.
|
|
3310
3322
|
var tmpTimeZoneOffsetInHours=0;// Track the number of minutes we need to adjust the date by based on the timezone.
|
|
3311
|
-
var tmpTimeZoneOffsetInMinutes=0;//
|
|
3323
|
+
var tmpTimeZoneOffsetInMinutes=0;// This fixes an inconsistency with constructing the date programmatically.
|
|
3324
|
+
tmpReturnDate.setUTCDate(1);// Manually parse the parts of the string and set each part for the
|
|
3312
3325
|
// date. Note: Using the UTC versions of these functions is necessary
|
|
3313
3326
|
// because we're manually adjusting for time zones stored in the
|
|
3314
3327
|
// string.
|
|
3315
3328
|
tmpReturnDate.setUTCFullYear(parseInt(tmpDateParts[0]));// The month numbers are one "off" from what normal humans would expect
|
|
3316
3329
|
// because January == 0.
|
|
3317
|
-
tmpReturnDate.setUTCMonth(parseInt(tmpDateParts[1]-1)
|
|
3330
|
+
tmpReturnDate.setUTCMonth(parseInt(tmpDateParts[1])-1);tmpReturnDate.setUTCDate(parseInt(tmpDateParts[2]));// Set the time parts of the date object.
|
|
3318
3331
|
tmpReturnDate.setUTCHours(parseInt(tmpDateParts[3]));tmpReturnDate.setUTCMinutes(parseInt(tmpDateParts[4]));tmpReturnDate.setUTCSeconds(parseInt(tmpDateParts[5]));tmpReturnDate.setUTCMilliseconds(parseInt(tmpDateParts[6]));// If there's a value for either the hours or minutes offset.
|
|
3319
3332
|
if(tmpDateParts[7]||tmpDateParts[8]){// If there's a value for the minutes offset.
|
|
3320
3333
|
if(tmpDateParts[8]){// Convert the minutes value into an hours value.
|