fable 3.0.115 → 3.0.116
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/debug/Harness.js +42 -14
- package/dist/fable.compatible.js +47 -31
- package/dist/fable.compatible.min.js +2 -2
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +34 -18
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/Fable.js +4 -2
- package/source/services/Fable-Service-DataGeneration.js +1 -1
- package/source/services/Fable-Service-Math.js +7 -7
- package/source/services/Fable-Service-Operation.js +23 -189
- package/source/services/Fable-Service-ProgressTime.js +154 -0
- package/source/services/Fable-Service-ProgressTracker.js +237 -0
- package/test/PregressTime_tests.js +110 -0
- package/test/ProgressTracker_tests.js +42 -0
package/debug/Harness.js
CHANGED
|
@@ -18,25 +18,53 @@ class SimpleService extends libFable.ServiceProviderBase
|
|
|
18
18
|
|
|
19
19
|
let testFable = new libFable({"Product": "FableDebugHarness"});
|
|
20
20
|
|
|
21
|
-
testFable.
|
|
21
|
+
let tmpProgressTracker = testFable.instantiateServiceProvider('ProgressTracker');
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
tmpProgressTracker.createProgressTracker('TestTracker', 10051);
|
|
24
24
|
|
|
25
|
+
//tmpProgressTracker.startProgressTracker('TestTracker');
|
|
25
26
|
|
|
26
|
-
testFable.
|
|
27
|
+
let tmpAnticipate = testFable.newAnticipate();
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
for (let i = 0; i < 11000; i++)
|
|
30
|
+
{
|
|
31
|
+
tmpAnticipate.anticipate(
|
|
32
|
+
function (fDone)
|
|
33
|
+
{
|
|
34
|
+
let tmpTracker = this.ProgressTracker.getProgressTracker('TestTracker');
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
setTimeout(
|
|
37
|
+
() =>
|
|
38
|
+
{
|
|
39
|
+
if (tmpTracker.PercentComplete < 100)
|
|
40
|
+
{
|
|
41
|
+
this.ProgressTracker.incrementProgressTracker('TestTracker', Math.floor(Math.random() * 10) + 10);
|
|
42
|
+
this.ProgressTracker.logProgressTrackerStatus('TestTracker');
|
|
43
|
+
}
|
|
44
|
+
return fDone();
|
|
45
|
+
}, Math.floor(Math.random() * 100) + 110);
|
|
46
|
+
}.bind(testFable));
|
|
47
|
+
}
|
|
31
48
|
|
|
32
|
-
testFable.
|
|
49
|
+
// testFable.addServiceType('SimpleService', SimpleService);
|
|
33
50
|
|
|
34
|
-
//
|
|
35
|
-
let tmpRestClient = testFable.instantiateServiceProvider('RestClient', {TraceLog: true}, 'RestClient-99');
|
|
51
|
+
// testFable.instantiateServiceProvider('SimpleService', {SomeOption: true}, 'SimpleService-123');
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
|
|
54
|
+
// testFable.servicesMap['SimpleService']['SimpleService-123'].doSomething();
|
|
55
|
+
|
|
56
|
+
// testFable.SimpleService.doSomething();
|
|
57
|
+
|
|
58
|
+
// console.log(`Initialized Service ${testFable.servicesMap['SimpleService']['SimpleService-123'].serviceType} as UUID ${testFable.servicesMap['SimpleService']['SimpleService-123'].UUID} with hash ${testFable.servicesMap['SimpleService']['SimpleService-123'].Hash}`);
|
|
59
|
+
|
|
60
|
+
// testFable.servicesMap['SimpleService']['SimpleService-123'].doSomething();
|
|
61
|
+
|
|
62
|
+
// // Instantiate the RestClient Service Provider
|
|
63
|
+
// let tmpRestClient = testFable.instantiateServiceProvider('RestClient', {TraceLog: true}, 'RestClient-99');
|
|
64
|
+
|
|
65
|
+
// // Download the wiktionary entry for dog!
|
|
66
|
+
// tmpRestClient.getJSON('https://en.wiktionary.org/w/api.php?action=parse&prop=wikitext&format=json&page=dog',
|
|
67
|
+
// (pError, pResponse, pBody)=>
|
|
68
|
+
// {
|
|
69
|
+
// testFable.log.info('Response received~', pBody);
|
|
70
|
+
// });
|
package/dist/fable.compatible.js
CHANGED
|
@@ -2840,7 +2840,7 @@ _this17.connectFable(_assertThisInitialized(_this17));// --> Bootstrapping of fa
|
|
|
2840
2840
|
// Initialization Phase 2: Map in the default services.
|
|
2841
2841
|
// They will then be available in the Default service provider set as well.
|
|
2842
2842
|
_this17.connectPreinitServiceProviderInstance(_this17.UUID);_this17.connectPreinitServiceProviderInstance(_this17.Logging);_this17.connectPreinitServiceProviderInstance(_this17.SettingsManager);// Initialize and instantiate the default baked-in Data Arithmatic service
|
|
2843
|
-
_this17.addAndInstantiateServiceType('EnvironmentData',require('./services/Fable-Service-EnvironmentData.js'));_this17.addServiceType('Template',require('./services/Fable-Service-Template.js'));_this17.addServiceType('MetaTemplate',require('./services/Fable-Service-MetaTemplate.js'));_this17.addServiceType('Anticipate',require('./services/Fable-Service-Anticipate.js'));_this17.addAndInstantiateServiceType('Dates',require('./services/Fable-Service-DateManipulation.js'));_this17.addAndInstantiateServiceType('DataFormat',require('./services/Fable-Service-DataFormat.js'));_this17.addAndInstantiateServiceType('DataGeneration',require('./services/Fable-Service-DataGeneration.js'));_this17.addAndInstantiateServiceType('Utility',require('./services/Fable-Service-Utility.js'));_this17.addAndInstantiateServiceType('Math',require('./services/Fable-Service-Math.js'));_this17.addServiceType('
|
|
2843
|
+
_this17.addAndInstantiateServiceType('EnvironmentData',require('./services/Fable-Service-EnvironmentData.js'));_this17.addServiceType('Template',require('./services/Fable-Service-Template.js'));_this17.addServiceType('MetaTemplate',require('./services/Fable-Service-MetaTemplate.js'));_this17.addServiceType('Anticipate',require('./services/Fable-Service-Anticipate.js'));_this17.addAndInstantiateServiceType('Dates',require('./services/Fable-Service-DateManipulation.js'));_this17.addAndInstantiateServiceType('DataFormat',require('./services/Fable-Service-DataFormat.js'));_this17.addAndInstantiateServiceType('DataGeneration',require('./services/Fable-Service-DataGeneration.js'));_this17.addAndInstantiateServiceType('Utility',require('./services/Fable-Service-Utility.js'));_this17.addAndInstantiateServiceType('Math',require('./services/Fable-Service-Math.js'));_this17.addServiceType('RestClient',require('./services/Fable-Service-RestClient.js'));_this17.addServiceType('Manifest',require('manyfest'));_this17.addServiceType('ObjectCache',require('cachetrax'));_this17.addServiceType('Operation',require('./services/Fable-Service-Operation.js'));_this17.addServiceType('ProgressTracker',require('./services/Fable-Service-ProgressTracker.js'));_this17.addAndInstantiateServiceType('ProgressTime',require('./services/Fable-Service-ProgressTime.js'));_this17.addServiceType('CSVParser',require('./services/Fable-Service-CSVParser.js'));_this17.addServiceType('FilePersistence',require('./services/Fable-Service-FilePersistence.js'));return _this17;}/* State Accessors */_createClass2(Fable,[{key:"isFable",get:function get(){return true;}},{key:"settings",get:function get(){return this.SettingsManager.settings;}},{key:"settingsManager",get:function get(){return this.SettingsManager;}// For backwards compatibility
|
|
2844
2844
|
},{key:"getUUID",value:function getUUID(){return this.UUID.getUUID();}},{key:"newAnticipate",value:function newAnticipate(){return this.instantiateServiceProviderWithoutRegistration('Anticipate');}/* Service Manager Methods */},{key:"addServiceType",value:function addServiceType(pServiceType,pServiceClass){if(this.servicesMap.hasOwnProperty(pServiceType)){// TODO: Check if any services are running?
|
|
2845
2845
|
this.log.warn("Adding a service type [".concat(pServiceType,"] that already exists."));}else{// Add the container for instantiated services to go in
|
|
2846
2846
|
this.servicesMap[pServiceType]={};// Add the type to the list of types
|
|
@@ -2867,7 +2867,7 @@ this.servicesMap[tmpServiceType][tmpServiceHash]=pServiceInstance;// If this is
|
|
|
2867
2867
|
if(!this.services.hasOwnProperty(tmpServiceType)){this.setDefaultServiceInstantiation(tmpServiceType,tmpServiceHash,false);}return pServiceInstance;}},{key:"setDefaultServiceInstantiation",value:function setDefaultServiceInstantiation(pServiceType,pServiceHash,pOverwriteService){// Overwrite services by default, unless told not to
|
|
2868
2868
|
var tmpOverwriteService=typeof pOverwriteService==='undefined'?true:pOverwriteService;// Make sure the service exists
|
|
2869
2869
|
if(this.servicesMap[pServiceType].hasOwnProperty(pServiceHash)){if(!this.hasOwnProperty(pServiceType)||tmpOverwriteService){this[pServiceType]=this.servicesMap[pServiceType][pServiceHash];}if(!this.services.hasOwnProperty(pServiceType)||tmpOverwriteService){this.services[pServiceType]=this.servicesMap[pServiceType][pServiceHash];}return true;}return false;}}]);return Fable;}(libFableServiceBase.CoreServiceProviderBase);// This is for backwards compatibility
|
|
2870
|
-
function autoConstruct(pSettings){return new Fable(pSettings);}module.exports=Fable;module.exports["new"]=autoConstruct;module.exports.LogProviderBase=libFableLog.LogProviderBase;module.exports.ServiceProviderBase=libFableServiceBase;module.exports.CoreServiceProviderBase=libFableServiceBase.CoreServiceProviderBase;module.exports.precedent=libFableSettings.precedent;},{"./services/Fable-Service-Anticipate.js":127,"./services/Fable-Service-CSVParser.js":128,"./services/Fable-Service-DataFormat.js":129,"./services/Fable-Service-DataGeneration.js":131,"./services/Fable-Service-DateManipulation.js":132,"./services/Fable-Service-EnvironmentData.js":133,"./services/Fable-Service-FilePersistence.js":134,"./services/Fable-Service-Math.js":135,"./services/Fable-Service-MetaTemplate.js":136,"./services/Fable-Service-Operation.js":140,"./services/Fable-Service-
|
|
2870
|
+
function autoConstruct(pSettings){return new Fable(pSettings);}module.exports=Fable;module.exports["new"]=autoConstruct;module.exports.LogProviderBase=libFableLog.LogProviderBase;module.exports.ServiceProviderBase=libFableServiceBase;module.exports.CoreServiceProviderBase=libFableServiceBase.CoreServiceProviderBase;module.exports.precedent=libFableSettings.precedent;},{"./services/Fable-Service-Anticipate.js":127,"./services/Fable-Service-CSVParser.js":128,"./services/Fable-Service-DataFormat.js":129,"./services/Fable-Service-DataGeneration.js":131,"./services/Fable-Service-DateManipulation.js":132,"./services/Fable-Service-EnvironmentData.js":133,"./services/Fable-Service-FilePersistence.js":134,"./services/Fable-Service-Math.js":135,"./services/Fable-Service-MetaTemplate.js":136,"./services/Fable-Service-Operation.js":140,"./services/Fable-Service-ProgressTime.js":141,"./services/Fable-Service-ProgressTracker.js":142,"./services/Fable-Service-RestClient.js":143,"./services/Fable-Service-Template.js":144,"./services/Fable-Service-Utility.js":145,"cachetrax":22,"fable-log":50,"fable-serviceproviderbase":51,"fable-settings":54,"fable-uuid":56,"manyfest":79}],127:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var FableServiceAnticipate=/*#__PURE__*/function(_libFableServiceBase){_inherits(FableServiceAnticipate,_libFableServiceBase);function FableServiceAnticipate(pFable,pOptions,pServiceHash){var _this18;_classCallCheck2(this,FableServiceAnticipate);_this18=_callSuper(this,FableServiceAnticipate,[pFable,pOptions,pServiceHash]);_this18.serviceType='AsyncAnticipate';// The queue of operations waiting to run.
|
|
2871
2871
|
_this18.operationQueue=[];_this18.erroredOperations=[];_this18.executingOperationCount=0;_this18.completedOperationCount=0;_this18.callDepth=0;_this18.maxOperations=1;_this18.lastError=undefined;_this18.waitingFunctions=[];return _this18;}_createClass2(FableServiceAnticipate,[{key:"checkQueue",value:function checkQueue(){// This could be combined with the last else if stanza but the logic for errors and non-errors would be blended and more complex to follow so keeping it unrolled.
|
|
2872
2872
|
if(this.lastError){// If there are no operations left, and we have waiting functions, call them.
|
|
2873
2873
|
for(var i=0;i<this.waitingFunctions.length;i++){//this.log.trace('Calling waiting function.')
|
|
@@ -3100,7 +3100,7 @@ return'';}if(tmpEnclosedValueEndIndex>0&&tmpEnclosedValueEndIndex>tmpEnclosedVal
|
|
|
3100
3100
|
if(tmpString[i]==tmpEnclosureStart){tmpEnclosureDepth++;if(tmpEnclosureDepth==1){tmpEnclosureCount++;if(tmpEnclosureIndexToRemove==tmpEnclosureCount-1){tmpMatchedEnclosureIndex=true;tmpEnclosureStartIndex=i;}}}else if(tmpString[i]==tmpEnclosureEnd){tmpEnclosureDepth--;if(tmpEnclosureDepth==0&&tmpMatchedEnclosureIndex&&tmpEnclosureEndIndex<=tmpEnclosureStartIndex){tmpEnclosureEndIndex=i;tmpMatchedEnclosureIndex=false;}}}if(tmpEnclosureCount<=tmpEnclosureIndexToRemove){return tmpString;}var tmpReturnString='';if(tmpEnclosureStartIndex>1){tmpReturnString=tmpString.substring(0,tmpEnclosureStartIndex);}if(tmpString.length>tmpEnclosureEndIndex+1&&tmpEnclosureEndIndex>tmpEnclosureStartIndex){tmpReturnString+=tmpString.substring(tmpEnclosureEndIndex+1);}return tmpReturnString;}}]);return DataFormat;}(libFableServiceProviderBase);module.exports=DataFormat;},{"fable-serviceproviderbase":51}],130:[function(require,module,exports){module.exports={"DefaultIntegerMinimum":0,"DefaultIntegerMaximum":9999999,"DefaultNumericStringLength":10,"MonthSet":["January","February","March","April","May","June","July","August","September","October","November","December"],"WeekDaySet":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"ColorSet":["Red","Orange","Yellow","Green","Blue","Indigo","Violet","Pink","Purple","Turquoise","Gold","Lime","Maroon","Navy","Coral","Teal","Brown","White","Black","Sky","Berry","Grey","Straw","Silver","Sapphire"],"SurNameSet":["Smith","Johnson","Williams","Brown","Jones","Miller","Davis","Garcia","Rodriguez","Wilson","Martinez","Anderson","Taylor","Thomas","Hernandez","Moore","Martin","Jackson","Thompson","White","Lopez","Lee","Gonzalez","Harris","Clark","Lewis","Robinson","Walker","Perez","Hall","Young","Allen","Sanchez","Wright","King","Scott","Green","Baker","Adams","Nelson","Hill","Ramirez","Campbell","Mitchell","Roberts","Carter","Phillips","Evans","Turner","Torres","Parker","Collins","Edwards","Stewart","Flores","Morris","Nguyen","Murphy","Rivera","Cook","Rogers","Morgan","Peterson","Cooper","Reed","Bailey","Bell","Gomez","Kelly","Howard","Ward","Cox","Diaz","Richardson","Wood","Watson","Brooks","Bennett","Gray","James","Reyes","Cruz","Hughes","Price","Myers","Long","Foster","Sanders","Ross","Morales","Powell","Sullivan","Russell","Ortiz","Jenkins","Gutierrez","Perry","Butler","Barnes","Fisher"],"NameSet":["Mary","Patricia","Jennifer","Linda","Elizabeth","Barbara","Susan","Jessica","Sarah","Karen","Lisa","Nancy","Betty","Sandra","Margaret","Ashley","Kimberly","Emily","Donna","Michelle","Carol","Amanda","Melissa","Deborah","Stephanie","Dorothy","Rebecca","Sharon","Laura","Cynthia","Amy","Kathleen","Angela","Shirley","Brenda","Emma","Anna","Pamela","Nicole","Samantha","Katherine","Christine","Helen","Debra","Rachel","Carolyn","Janet","Maria","Catherine","Heather","Diane","Olivia","Julie","Joyce","Victoria","Ruth","Virginia","Lauren","Kelly","Christina","Joan","Evelyn","Judith","Andrea","Hannah","Megan","Cheryl","Jacqueline","Martha","Madison","Teresa","Gloria","Sara","Janice","Ann","Kathryn","Abigail","Sophia","Frances","Jean","Alice","Judy","Isabella","Julia","Grace","Amber","Denise","Danielle","Marilyn","Beverly","Charlotte","Natalie","Theresa","Diana","Brittany","Doris","Kayla","Alexis","Lori","Marie","James","Robert","John","Michael","David","William","Richard","Joseph","Thomas","Christopher","Charles","Daniel","Matthew","Anthony","Mark","Donald","Steven","Andrew","Paul","Joshua","Kenneth","Kevin","Brian","George","Timothy","Ronald","Jason","Edward","Jeffrey","Ryan","Jacob","Gary","Nicholas","Eric","Jonathan","Stephen","Larry","Justin","Scott","Brandon","Benjamin","Samuel","Gregory","Alexander","Patrick","Frank","Raymond","Jack","Dennis","Jerry","Tyler","Aaron","Jose","Adam","Nathan","Henry","Zachary","Douglas","Peter","Kyle","Noah","Ethan","Jeremy","Walter","Christian","Keith","Roger","Terry","Austin","Sean","Gerald","Carl","Harold","Dylan","Arthur","Lawrence","Jordan","Jesse","Bryan","Billy","Bruce","Gabriel","Joe","Logan","Alan","Juan","Albert","Willie","Elijah","Wayne","Randy","Vincent","Mason","Roy","Ralph","Bobby","Russell","Bradley","Philip","Eugene"]};},{}],131:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var FableServiceDataGeneration=/*#__PURE__*/function(_libFableServiceBase2){_inherits(FableServiceDataGeneration,_libFableServiceBase2);function FableServiceDataGeneration(pFable,pOptions,pServiceHash){var _this21;_classCallCheck2(this,FableServiceDataGeneration);_this21=_callSuper(this,FableServiceDataGeneration,[pFable,pOptions,pServiceHash]);_this21.serviceType='DataGeneration';_this21.defaultData=require('./Fable-Service-DataGeneration-DefaultValues.json');return _this21;}// Return a random integer between pMinimum and pMaximum
|
|
3101
3101
|
_createClass2(FableServiceDataGeneration,[{key:"randomIntegerBetween",value:function randomIntegerBetween(pMinimum,pMaximum){return Math.floor(Math.random()*(pMaximum-pMinimum))+pMinimum;}// Return a random integer up to the passed-in maximum
|
|
3102
3102
|
},{key:"randomIntegerUpTo",value:function randomIntegerUpTo(pMaximum){return this.randomIntegerBetween(0,pMaximum);}// Return a random integer between 0 and 9999999
|
|
3103
|
-
},{key:"randomInteger",value:function randomInteger(){return Math.floor(Math.random()*this.defaultData.DefaultIntegerMaximum);}},{key:"randomNumericString",value:function randomNumericString(pLength,pMaxNumber){var tmpLength=typeof pLength==='undefined'?10:pLength;var tmpMaxNumber=typeof pMaxNumber==='undefined'?
|
|
3103
|
+
},{key:"randomInteger",value:function randomInteger(){return Math.floor(Math.random()*this.defaultData.DefaultIntegerMaximum);}},{key:"randomNumericString",value:function randomNumericString(pLength,pMaxNumber){var tmpLength=typeof pLength==='undefined'?10:pLength;var tmpMaxNumber=typeof pMaxNumber==='undefined'?9999999999:pMaxNumber;return this.services.DataFormat.stringPadStart(this.randomIntegerUpTo(tmpMaxNumber),pLength,'0');}},{key:"randomMonth",value:function randomMonth(){return this.defaultData.MonthSet[this.randomIntegerUpTo(this.defaultData.MonthSet.length-1)];}},{key:"randomDayOfWeek",value:function randomDayOfWeek(){return this.defaultData.WeekDaySet[this.randomIntegerUpTo(this.defaultData.WeekDaySet.length-1)];}},{key:"randomColor",value:function randomColor(){return this.defaultData.ColorSet[this.randomIntegerUpTo(this.defaultData.ColorSet.length-1)];}},{key:"randomName",value:function randomName(){return this.defaultData.NameSet[this.randomIntegerUpTo(this.defaultData.NameSet.length-1)];}},{key:"randomSurname",value:function randomSurname(){return this.defaultData.SurNameSet[this.randomIntegerUpTo(this.defaultData.SurNameSet.length-1)];}}]);return FableServiceDataGeneration;}(libFableServiceBase);module.exports=FableServiceDataGeneration;},{"./Fable-Service-DataGeneration-DefaultValues.json":130,"fable-serviceproviderbase":51}],132:[function(require,module,exports){var libFableServiceProviderBase=require('fable-serviceproviderbase');/**
|
|
3104
3104
|
* Date management a la Moment using days.js
|
|
3105
3105
|
*
|
|
3106
3106
|
* @class DateManipulation
|
|
@@ -3126,11 +3126,13 @@ if(tmpParameters.CurrentPathIndex>=tmpParameters.ActualPathParts.length){return
|
|
|
3126
3126
|
libFS.open(tmpParameters.CurrentPath+libPath.sep+tmpParameters.ActualPathParts[tmpParameters.CurrentPathIndex],'r',function(pError,pFileDescriptor){if(pFileDescriptor){libFS.closeSync(pFileDescriptor);}if(pError&&pError.code=='ENOENT'){/* Path doesn't exist, create it */libFS.mkdir(tmpParameters.CurrentPath+libPath.sep+tmpParameters.ActualPathParts[tmpParameters.CurrentPathIndex],tmpParameters.Mode,function(pCreateError){if(!pCreateError){// We have now created our folder and there was no error -- continue.
|
|
3127
3127
|
return _this25.makeFolderRecursive(tmpParameters,fCallback);}else if(pCreateError.code=='EEXIST'){// The folder exists -- our dev might be running this in parallel/async/whatnot.
|
|
3128
3128
|
return _this25.makeFolderRecursive(tmpParameters,fCallback);}else{console.log(pCreateError.code);return fCallback(pCreateError);}});}else{return _this25.makeFolderRecursive(tmpParameters,fCallback);}});}}]);return FableServiceFilePersistence;}(libFableServiceBase);module.exports=FableServiceFilePersistence;}).call(this);}).call(this,require('_process'));},{"_process":86,"fable-serviceproviderbase":51,"fs":19,"path":82,"readline":19}],135:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');/**
|
|
3129
|
-
* Arbitrary Precision Math Operations
|
|
3130
|
-
* @author Steven Velozo <steven@velozo.com>
|
|
3131
|
-
* @description Simple functions that perform arbitrary precision math operations and return string resultant values. Wraps big.js
|
|
3132
|
-
|
|
3133
|
-
|
|
3129
|
+
* Arbitrary Precision Math Operations
|
|
3130
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
3131
|
+
* @description Simple functions that perform arbitrary precision math operations and return string resultant values. Wraps big.js
|
|
3132
|
+
* @class FableServiceMath
|
|
3133
|
+
* @extends libFableServiceBase
|
|
3134
|
+
*/var FableServiceMath=/*#__PURE__*/function(_libFableServiceBase5){_inherits(FableServiceMath,_libFableServiceBase5);function FableServiceMath(pFable,pOptions,pServiceHash){var _this26;_classCallCheck2(this,FableServiceMath);_this26=_callSuper(this,FableServiceMath,[pFable,pOptions,pServiceHash]);_this26.serviceType='Math';return _this26;}/*
|
|
3135
|
+
Pass-through Rounding Method Constants
|
|
3134
3136
|
|
|
3135
3137
|
Property Value BigDecimal Equiv Description
|
|
3136
3138
|
---------- ----- ---------------- -----------
|
|
@@ -3281,30 +3283,44 @@ for(var i=0;i<pPatternStart.length;i++){tmpLeaf=this.addChild(tmpLeaf,pPatternSt
|
|
|
3281
3283
|
tmpLeaf.ParseAsync=fParserAsync;}}}]);return WordTree;}();module.exports=WordTree;},{}],139:[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":[]};},{}],140:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));var FableOperation=/*#__PURE__*/function(_libFableServiceBase7){_inherits(FableOperation,_libFableServiceBase7);function FableOperation(pFable,pOptions,pServiceHash){var _this30;_classCallCheck2(this,FableOperation);_this30=_callSuper(this,FableOperation,[pFable,pOptions,pServiceHash]);// Timestamps will just be the long ints
|
|
3282
3284
|
_this30.timeStamps={};// ProgressTrackers have an object format of: {Hash:'SomeHash',EndTime:UINT,CurrentTime:UINT,TotalCount:INT,CurrentCount:INT}
|
|
3283
3285
|
_this30.progressTrackers={};_this30.serviceType='PhasedOperation';_this30.state=JSON.parse(_OperationStatePrototypeString);_this30.stepMap={};_this30.stepFunctions={};// Match the service instantiation to the operation.
|
|
3284
|
-
_this30.state.Metadata.Hash=_this30.Hash;_this30.state.Metadata.UUID=_this30.UUID;_this30.state.Metadata.Name=typeof _this30.options.Name=='string'?_this30.options.Name:"Unnamed Operation ".concat(_this30.state.Metadata.UUID);_this30.name=_this30.state.Metadata.Name;_this30.log=_assertThisInitialized(_this30);return _this30;}_createClass2(FableOperation,[{key:"execute",value:function execute(fExecutionCompleteCallback){var _this31=this
|
|
3286
|
+
_this30.state.Metadata.Hash=_this30.Hash;_this30.state.Metadata.UUID=_this30.UUID;_this30.state.Metadata.Name=typeof _this30.options.Name=='string'?_this30.options.Name:"Unnamed Operation ".concat(_this30.state.Metadata.UUID);_this30.name=_this30.state.Metadata.Name;_this30.log=_assertThisInitialized(_this30);return _this30;}_createClass2(FableOperation,[{key:"execute",value:function execute(fExecutionCompleteCallback){var _this31=this;// TODO: Should the same operation be allowed to execute more than one time?
|
|
3287
|
+
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
|
|
3285
3288
|
tmpAnticipate.wait(function(pError){_this31.state.Status.TimeEnd=+new Date();return fExecutionCompleteCallback();});}/*
|
|
3286
3289
|
TODO: I've gone back and forth on whether this should be an object, JSON
|
|
3287
3290
|
object prototype, or set of functions here. Discuss with colleagues!
|
|
3288
|
-
*/},{key:"addStep",value:function addStep(
|
|
3289
|
-
tmpStep.
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
*
|
|
3294
|
-
|
|
3291
|
+
*/},{key:"addStep",value:function addStep(fStepFunction,pStepName,pStepDescription,pStepMetadata,pGUIDStep){var tmpStep={};// GUID is optional
|
|
3292
|
+
tmpStep.GUIDStep=typeof pGUIDStep!=='undefined'?pGUIDStep:"STEP-".concat(this.state.Steps.length,"-").concat(this.fable.DataGeneration.randomNumericString());// Name is optional
|
|
3293
|
+
tmpStep.Name=typeof pStepName!=='undefined'?pStepName:"Step [".concat(tmpStep.GUIDStep,"]");tmpStep.Description=typeof pStepDescription!=='undefined'?pStepDescription:"Step execution of ".concat(tmpStep.Name,".");tmpStep.Metadata=_typeof(pStepMetadata)==='object'?pStepMetadata:{};tmpStep.TimeStart=false;tmpStep.TimeEnd=false;// There is an array of steps, in the Operation State itself ... push a step there
|
|
3294
|
+
this.state.Steps.push(tmpStep);this.stepFunctions[tmpStep.GUIDStep]=fStepFunction;;this.stepMap[tmpStep.GUIDStep];this.state.Status.StepCount++;return tmpStep;}/**
|
|
3295
|
+
* Retrieves a step from the step map based on the provided GUID.
|
|
3296
|
+
* @param {string} pGUIDStep - The GUID of the step to retrieve.
|
|
3297
|
+
* @returns {object|boolean} - The step object if found, otherwise false.
|
|
3298
|
+
*/},{key:"getStep",value:function getStep(pGUIDStep){if(this.stepMap.hasOwnProperty(pGUIDStep)){return this.stepMap[pGUIDStep];}return false;}/**
|
|
3299
|
+
* Begins a step in the Fable service operation.
|
|
3300
|
+
* @param {string} pGUIDStep - The GUID of the step to begin.
|
|
3301
|
+
* @returns {object|boolean} - The step object if found, or `false` if not found.
|
|
3302
|
+
*/},{key:"beginStep",value:function beginStep(pGUIDStep){var tmpStep=this.getStep(pGUIDStep);if(tmpStep===false){return false;}tmpStep.TimeStart=+new Date();return tmpStep;}},{key:"endStep",value:function endStep(pGUIDStep){var tmpStep=this.getStep(pGUIDStep);if(tmpStep===false){return false;}tmpStep.TimeEnd=+new Date();return tmpStep;}},{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);}}]);return FableOperation;}(libFableServiceBase);module.exports=FableOperation;},{"./Fable-Service-Operation-DefaultSettings.js":139,"fable-serviceproviderbase":51}],141:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var FableServiceProgressTime=/*#__PURE__*/function(_libFableServiceBase8){_inherits(FableServiceProgressTime,_libFableServiceBase8);function FableServiceProgressTime(pFable,pOptions,pServiceHash){var _this32;_classCallCheck2(this,FableServiceProgressTime);_this32=_callSuper(this,FableServiceProgressTime,[pFable,pOptions,pServiceHash]);_this32.serviceType='ProgressTime';_this32.timeStamps={};return _this32;}_createClass2(FableServiceProgressTime,[{key:"formatTimeDuration",value:function formatTimeDuration(pTimeDurationInMilliseconds){var tmpTimeDuration=typeof pTimeDurationInMilliseconds=='number'?pTimeDurationInMilliseconds:0;var tmpTimeDurationString='';if(tmpTimeDuration>3600000){tmpTimeDurationString+=Math.floor(tmpTimeDuration/3600000)+'h ';tmpTimeDuration=tmpTimeDuration%3600000;}if(tmpTimeDuration>60000){tmpTimeDurationString+=Math.floor(tmpTimeDuration/60000)+'m ';tmpTimeDuration=tmpTimeDuration%60000;}if(tmpTimeDuration>1000){tmpTimeDurationString+=Math.floor(tmpTimeDuration/1000)+'s ';tmpTimeDuration=tmpTimeDuration%1000;}tmpTimeDurationString+=Math.round(tmpTimeDuration)+'ms';return tmpTimeDurationString;}},{key:"createTimeStamp",value:function createTimeStamp(pTimeStampHash){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';this.timeStamps[tmpTimeStampHash]=+new Date();return this.timeStamps[tmpTimeStampHash];}},{key:"getTimeStampValue",value:function getTimeStampValue(pTimeStampHash){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';return this.timeStamps.hasOwnProperty(tmpTimeStampHash)?this.timeStamps[tmpTimeStampHash]:-1;}},{key:"updateTimeStampValue",value:function updateTimeStampValue(pTimeStampHash,pReferenceTime){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';var tmpReferenceTime=false;// This function allows the user to pass in either a reference time in ms, or, a hash of a timestamp.
|
|
3303
|
+
if(typeof pReferenceTime=='string'){tmpReferenceTime=this.timeStamps.hasOwnProperty(tmpReference)?this.timeStamps[tmpReference]:false;}else if(typeof pReferenceTime=='number'){tmpReferenceTime=pReferenceTime;}else{tmpReferenceTime=+new Date();}if(this.timeStamps.hasOwnProperty(tmpTimeStampHash)&&tmpReferenceTime){this.timeStamps[tmpTimeStampHash]=tmpReferenceTime;return this.timeStamps[tmpTimeStampHash];}else{return-1;}}},{key:"removeTimeStamp",value:function removeTimeStamp(pTimeStampHash){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';if(this.timeStamps.hasOwnProperty(tmpTimeStampHash)){delete this.timeStamps[tmpTimeStampHash];return true;}else{return false;}}},{key:"getTimeStampDelta",value:function getTimeStampDelta(pTimeStampHash,pReferenceTime){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';var tmpReferenceTime=false;// This function allows the user to pass in either a reference time in ms, or, a hash of a timestamp.
|
|
3304
|
+
if(typeof pReferenceTime=='string'){tmpReferenceTime=this.timeStamps.hasOwnProperty(tmpReference)?this.timeStamps[tmpReference]:false;}else if(typeof pReferenceTime=='number'){tmpReferenceTime=pReferenceTime;}else{tmpReferenceTime=+new Date();}if(this.timeStamps.hasOwnProperty(tmpTimeStampHash)&&tmpReferenceTime){return tmpReferenceTime-this.timeStamps[tmpTimeStampHash];}else{return-1;}}},{key:"getDurationBetweenTimestamps",value:function getDurationBetweenTimestamps(pTimeStampHashStart,pTimeStampHashEnd){var tmpTimeStampHashStart=typeof pTimeStampHashStart=='string'?pTimeStampHashStart:'Default';var tmpTimeStampHashEnd=typeof pTimeStampHashEnd=='string'?pTimeStampHashEnd:'Default';if(this.timeStamps.hasOwnProperty(tmpTimeStampHashStart)&&this.timeStamps.hasOwnProperty(tmpTimeStampHashEnd)){return this.timeStamps[tmpTimeStampHashEnd]-this.timeStamps[tmpTimeStampHashStart];}else{return-1;}}},{key:"getTimeStampDeltaMessage",value:function getTimeStampDeltaMessage(pTimeStampHash,pMessage,pReferenceTime){var tmpTimeStampHash=typeof pTimeStampHash=='string'?pTimeStampHash:'Default';var tmpMessage=typeof pMessage!=='undefined'?pMessage:"Elapsed for ".concat(tmpTimeStampHash,": ");var tmpOperationTime=this.getTimeStampDelta(tmpTimeStampHash,pReferenceTime);return"".concat(tmpMessage," ").concat(this.formatTimeDuration(tmpOperationTime));}},{key:"logTimeStampDelta",value:function logTimeStampDelta(pTimeStampHash,pMessage,pReferenceTime){this.fable.log.info(this.getTimeStampDeltaMessage(pTimeStampHash,pMessage,pReferenceTime));}}]);return FableServiceProgressTime;}(libFableServiceBase);module.exports=FableServiceProgressTime;},{"fable-serviceproviderbase":51}],142:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var FableServiceProgressTracker=/*#__PURE__*/function(_libFableServiceBase9){_inherits(FableServiceProgressTracker,_libFableServiceBase9);function FableServiceProgressTracker(pFable,pOptions,pServiceHash){var _this33;_classCallCheck2(this,FableServiceProgressTracker);_this33=_callSuper(this,FableServiceProgressTracker,[pFable,pOptions,pServiceHash]);_this33.serviceType='ProgressTracker';_this33.progressTrackers={};// Create an internal PorgressTime service to track timestamps
|
|
3305
|
+
_this33.progressTimes=_this33.fable.instantiateServiceProviderWithoutRegistration('ProgressTime');// This timestamp is used and updated by *all* progress trackers.
|
|
3306
|
+
_this33.progressTimes.createTimeStamp('CurrentTime');return _this33;}_createClass2(FableServiceProgressTracker,[{key:"getProgressTracker",value:function getProgressTracker(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.fable.log.warn("Progress Tracker ".concat(tmpProgressTrackerHash," does not exist! Creating a new tracker..."));this.createProgressTracker(tmpProgressTrackerHash,100);}return this.progressTrackers[tmpProgressTrackerHash];}},{key:"createProgressTracker",value:function createProgressTracker(pProgressTrackerHash,pTotalOperations){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';var tmpTotalOperations=typeof pTotalOperations=='number'?pTotalOperations:100;var tmpProgressTracker={Hash:tmpProgressTrackerHash,StartTimeHash:"".concat(tmpProgressTrackerHash,"-Start"),StartTimeStamp:-1,CurrentTimeStamp:-1,EndTimeHash:"".concat(tmpProgressTrackerHash,"-End"),EndTimeStamp:-1,PercentComplete:-1,ElapsedTime:-1,AverageOperationTime:-1,EstimatedCompletionTime:-1,TotalCount:tmpTotalOperations,CurrentCount:-1};if(this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.fable.log.warn("Progress Tracker ".concat(tmpProgressTrackerHash," already exists! Overwriting with a new tracker..."));this.progressTimes.removeTimeStamp(tmpProgressTracker.StartTimeHash);this.progressTimes.removeTimeStamp(tmpProgressTracker.EndTimeHash);}this.progressTrackers[tmpProgressTrackerHash]=tmpProgressTracker;return tmpProgressTracker;}},{key:"startProgressTracker",value:function startProgressTracker(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';// This is the only method to lazily create Progress Trackers now
|
|
3307
|
+
if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.createProgressTracker(tmpProgressTrackerHash,100);}var tmpProgressTracker=this.progressTrackers[tmpProgressTrackerHash];this.progressTimes.createTimeStamp(this.progressTrackers[tmpProgressTrackerHash].StartTimeHash);tmpProgressTracker.StartTimeStamp=this.progressTimes.getTimeStampValue(this.progressTrackers[tmpProgressTrackerHash].StartTimeHash);return this.solveProgressTrackerStatus(tmpProgressTrackerHash);}},{key:"endProgressTracker",value:function endProgressTracker(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.fable.log.error("Attempted to end Progress Tracker ".concat(tmpProgressTrackerHash," that does not exist!"));return false;}this.progressTimes.createTimeStamp(this.progressTrackers[tmpProgressTrackerHash].EndTimeHash);tmpProgressTracker.EndTimeStamp=this.progressTimes.getTimeStampValue(this.progressTrackers[tmpProgressTrackerHash].EndTimeHash);return this.solveProgressTrackerStatus(tmpProgressTrackerHash);}},{key:"solveProgressTrackerStatus",value:function solveProgressTrackerStatus(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.fable.log.error("Attempted to solve Progress Tracker ".concat(tmpProgressTrackerHash," that does not exist!"));return false;}var tmpProgressTracker=this.progressTrackers[tmpProgressTrackerHash];if(tmpProgressTracker.TotalCount<1||isNaN(tmpProgressTracker.TotalCount)){this.fable.log.error("Progress Tracker ".concat(tmpProgressTracker.Hash," has an invalid total count of operations (").concat(tmpProgressTracker.TotalCount,"! Setting it to the default of 100..."));tmpProgressTracker.TotalCount=100;}// Compute the percentage of progress that is complete.
|
|
3308
|
+
if(tmpProgressTracker.CurrentCount<1){tmpProgressTracker.PercentComplete=0;return tmpProgressTracker;}else{tmpProgressTracker.PercentComplete=tmpProgressTracker.CurrentCount/tmpProgressTracker.TotalCount*100.0;}// Compute the average time per operation
|
|
3309
|
+
this.progressTimes.updateTimeStampValue('CurrentTime');tmpProgressTracker.CurrentTimeStamp=this.progressTimes.getTimeStampValue('CurrentTime');tmpProgressTracker.ElapsedTime=tmpProgressTracker.CurrentTimeStamp-tmpProgressTracker.StartTimeStamp;if(tmpProgressTracker.CurrentCount>0){tmpProgressTracker.AverageOperationTime=(tmpProgressTracker.CurrentTimeStamp-tmpProgressTracker.StartTimeStamp)/tmpProgressTracker.CurrentCount;}else{tmpProgressTracker.AverageOperationTime=-1;}// Compute the estimated completion
|
|
3310
|
+
if(tmpProgressTracker.AverageOperationTime>0){tmpProgressTracker.EstimatedCompletionTime=Math.max(tmpProgressTracker.TotalCount-tmpProgressTracker.CurrentCount,0)*tmpProgressTracker.AverageOperationTime;}else{tmpProgressTracker.EstimatedCompletionTime=-1;}return tmpProgressTracker;}},{key:"updateProgressTracker",value:function updateProgressTracker(pProgressTrackerHash,pCurrentOperations){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';var tmpCurrentOperations=parseInt(pCurrentOperations);if(isNaN(tmpCurrentOperations)){this.fable.log.warn("Attempted to update Progress Tracker ".concat(tmpProgressTrackerHash," with an invalid number of operations!"));return false;}if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.createProgressTracker(100,tmpProgressTrackerHash);}this.progressTrackers[tmpProgressTrackerHash].CurrentCount=tmpCurrentOperations;return this.solveProgressTrackerStatus(tmpProgressTrackerHash);}},{key:"incrementProgressTracker",value:function incrementProgressTracker(pProgressTrackerHash,pOperationIncrementAmount){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';var tmpOperationIncrementAmount=parseInt(pOperationIncrementAmount);if(isNaN(tmpOperationIncrementAmount)){tmpOperationIncrementAmount=1;}if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.fable.log.warn("Attempted to increment Progress Tracker ".concat(tmpProgressTrackerHash," but it did not exist."));return false;}if(this.progressTrackers[tmpProgressTrackerHash].StartTimeStamp<1){this.fable.log.warn("Attempted to increment Progress Tracker ".concat(tmpProgressTrackerHash," but it was not started.. starting now."));this.startProgressTracker(tmpProgressTrackerHash);}this.progressTrackers[tmpProgressTrackerHash].CurrentCount=this.progressTrackers[tmpProgressTrackerHash].CurrentCount+tmpOperationIncrementAmount;return this.solveProgressTrackerStatus(tmpProgressTrackerHash);}},{key:"logProgressTrackerStatus",value:function logProgressTrackerStatus(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';if(!this.progressTrackers.hasOwnProperty(tmpProgressTrackerHash)){this.fable.log.info(">> Progress Tracker ".concat(tmpProgressTrackerHash," does not exist! No stats to display."));}else{var _tmpProgressTracker=this.progressTrackers[tmpProgressTrackerHash];if(_tmpProgressTracker.CurrentCount<1){this.fable.log.info(">> Progress Tracker ".concat(_tmpProgressTracker.Hash," has no completed operations. ").concat(_tmpProgressTracker.CurrentTime,"ms have elapsed since it was started."));}else if(_tmpProgressTracker.EndTimeStamp<1){this.fable.log.info(">> Progress Tracker ".concat(_tmpProgressTracker.Hash," is ").concat(_tmpProgressTracker.PercentComplete.toFixed(3),"% completed - ").concat(_tmpProgressTracker.CurrentCount," / ").concat(_tmpProgressTracker.TotalCount," operations over ").concat(this.progressTimes.formatTimeDuration(_tmpProgressTracker.ElapsedTime)," (median ").concat(this.progressTimes.formatTimeDuration(_tmpProgressTracker.AverageOperationTime)," per). Estimated completion in ").concat(this.progressTimes.formatTimeDuration(_tmpProgressTracker.EstimatedCompletionTime)));}else{this.fable.log.info(">> Progress Tracker ".concat(_tmpProgressTracker.Hash," is done and completed ").concat(_tmpProgressTracker.CurrentCount," / ").concat(_tmpProgressTracker.TotalCount," operations in ").concat(_tmpProgressTracker.EndTime,"ms."));}}}}]);return FableServiceProgressTracker;}(libFableServiceBase);module.exports=FableServiceProgressTracker;},{"fable-serviceproviderbase":51}],143:[function(require,module,exports){(function(Buffer){(function(){var libFableServiceBase=require('fable-serviceproviderbase');var libSimpleGet=require('simple-get');var libCookie=require('cookie');var FableServiceRestClient=/*#__PURE__*/function(_libFableServiceBase10){_inherits(FableServiceRestClient,_libFableServiceBase10);function FableServiceRestClient(pFable,pOptions,pServiceHash){var _this34;_classCallCheck2(this,FableServiceRestClient);_this34=_callSuper(this,FableServiceRestClient,[pFable,pOptions,pServiceHash]);_this34.TraceLog=false;if(_this34.options.TraceLog||_this34.fable.TraceLog){_this34.TraceLog=true;}_this34.dataFormat=_this34.fable.services.DataFormat;_this34.serviceType='RestClient';_this34.cookie=false;// This is a function that can be overridden, to allow the management
|
|
3295
3311
|
// of the request options before they are passed to the request library.
|
|
3296
|
-
|
|
3312
|
+
_this34.prepareRequestOptions=function(pOptions){return pOptions;};return _this34;}_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.
|
|
3297
3313
|
pRequestOptions.headers.cookie=libCookie.serialize(tmpCookieKeys[0],tmpCookieObject[tmpCookieKeys[0]]);}}return pRequestOptions;}},{key:"preRequest",value:function preRequest(pOptions){// Validate the options object
|
|
3298
3314
|
var tmpOptions=this.prepareCookies(pOptions);// Prepend a string to the URL if it exists in the Fable Config
|
|
3299
|
-
if(this.fable.settings.hasOwnProperty('RestClientURLPrefix')){tmpOptions.url=this.fable.settings.RestClientURLPrefix+tmpOptions.url;}return this.prepareRequestOptions(tmpOptions);}},{key:"executeChunkedRequest",value:function executeChunkedRequest(pOptions,fCallback){var
|
|
3300
|
-
if(
|
|
3301
|
-
if(
|
|
3302
|
-
if(!tmpDataBuffer){tmpDataBuffer=Buffer.from(pChunk);}else{tmpDataBuffer=Buffer.concat([tmpDataBuffer,pChunk]);}});pResponse.on('end',function(){if(
|
|
3315
|
+
if(this.fable.settings.hasOwnProperty('RestClientURLPrefix')){tmpOptions.url=this.fable.settings.RestClientURLPrefix+tmpOptions.url;}return this.prepareRequestOptions(tmpOptions);}},{key:"executeChunkedRequest",value:function executeChunkedRequest(pOptions,fCallback){var _this35=this;var tmpOptions=this.preRequest(pOptions);tmpOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(tmpOptions.method," request to ").concat(tmpOptions.url," at ").concat(tmpOptions.RequestStartTime));}return libSimpleGet(tmpOptions,function(pError,pResponse){if(pError){return fCallback(pError,pResponse);}if(_this35.TraceLog){var tmpConnectTime=_this35.fable.log.getTimeStamp();_this35.fable.log.debug("--> ".concat(tmpOptions.method," connected in ").concat(_this35.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}var tmpData='';pResponse.on('data',function(pChunk){// For JSON, the chunk is the serialized object.
|
|
3316
|
+
if(_this35.TraceLog){var tmpChunkTime=_this35.fable.log.getTimeStamp();_this35.fable.log.debug("--> ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this35.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}tmpData+=pChunk;});pResponse.on('end',function(){if(_this35.TraceLog){var tmpCompletionTime=_this35.fable.log.getTimeStamp();_this35.fable.log.debug("==> ".concat(tmpOptions.method," completed data size ").concat(tmpData.length,"b received in ").concat(_this35.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,tmpData);});});}},{key:"executeChunkedRequestBinary",value:function executeChunkedRequestBinary(pOptions,fCallback){var _this36=this;var tmpOptions=this.preRequest(pOptions);tmpOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(tmpOptions.method," request to ").concat(tmpOptions.url," at ").concat(tmpOptions.RequestStartTime));}tmpOptions.json=false;tmpOptions.encoding=null;return libSimpleGet(tmpOptions,function(pError,pResponse){if(pError){return fCallback(pError,pResponse);}if(_this36.TraceLog){var tmpConnectTime=_this36.fable.log.getTimeStamp();_this36.fable.log.debug("--> ".concat(tmpOptions.method," connected in ").concat(_this36.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}var tmpDataBuffer=false;pResponse.on('data',function(pChunk){// For JSON, the chunk is the serialized object.
|
|
3317
|
+
if(_this36.TraceLog){var tmpChunkTime=_this36.fable.log.getTimeStamp();_this36.fable.log.debug("--> ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this36.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}// TODO: Potentially create a third option that streams this to a file? So it doesn't have to hold it all in memory.
|
|
3318
|
+
if(!tmpDataBuffer){tmpDataBuffer=Buffer.from(pChunk);}else{tmpDataBuffer=Buffer.concat([tmpDataBuffer,pChunk]);}});pResponse.on('end',function(){if(_this36.TraceLog){var tmpCompletionTime=_this36.fable.log.getTimeStamp();_this36.fable.log.debug("==> ".concat(tmpOptions.method," completed data size ").concat(tmpDataBuffer.length,"b received in ").concat(_this36.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,tmpDataBuffer);});});}},{key:"executeJSONRequest",value:function executeJSONRequest(pOptions,fCallback){var _this37=this;pOptions.json=true;var tmpOptions=this.preRequest(pOptions);if(!tmpOptions.hasOwnProperty('headers')){tmpOptions.headers={};}/* Automated headers break some APIs
|
|
3303
3319
|
if (!tmpOptions.headers.hasOwnProperty('Content-Type'))
|
|
3304
3320
|
{
|
|
3305
3321
|
tmpOptions.headers['Content-Type'] = 'application/json';
|
|
3306
3322
|
}
|
|
3307
|
-
*/tmpOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(tmpOptions.method," JSON request to ").concat(tmpOptions.url," at ").concat(tmpOptions.RequestStartTime));}return libSimpleGet(tmpOptions,function(pError,pResponse){if(pError){return fCallback(pError,pResponse);}if(
|
|
3323
|
+
*/tmpOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(tmpOptions.method," JSON request to ").concat(tmpOptions.url," at ").concat(tmpOptions.RequestStartTime));}return libSimpleGet(tmpOptions,function(pError,pResponse){if(pError){return fCallback(pError,pResponse);}if(_this37.TraceLog){var tmpConnectTime=_this37.fable.log.getTimeStamp();_this37.fable.log.debug("--> JSON ".concat(tmpOptions.method," connected in ").concat(_this37.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}var tmpJSONData='';pResponse.on('data',function(pChunk){if(_this37.TraceLog){var tmpChunkTime=_this37.fable.log.getTimeStamp();_this37.fable.log.debug("--> JSON ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this37.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}tmpJSONData+=pChunk;});pResponse.on('end',function(){if(_this37.TraceLog){var tmpCompletionTime=_this37.fable.log.getTimeStamp();_this37.fable.log.debug("==> JSON ".concat(tmpOptions.method," completed - received in ").concat(_this37.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,JSON.parse(tmpJSONData));});});}},{key:"getJSON",value:function getJSON(pOptionsOrURL,fCallback){var tmpRequestOptions=_typeof(pOptionsOrURL)=='object'?pOptionsOrURL:{};if(typeof pOptionsOrURL=='string'){tmpRequestOptions.url=pOptionsOrURL;}tmpRequestOptions.method='GET';return this.executeJSONRequest(tmpRequestOptions,fCallback);}},{key:"putJSON",value:function putJSON(pOptions,fCallback){if(_typeof(pOptions.body)!='object'){return fCallback(new Error("PUT JSON Error Invalid options object"));}pOptions.method='PUT';return this.executeJSONRequest(pOptions,fCallback);}},{key:"postJSON",value:function postJSON(pOptions,fCallback){if(_typeof(pOptions.body)!='object'){return fCallback(new Error("POST JSON Error Invalid options object"));}pOptions.method='POST';return this.executeJSONRequest(pOptions,fCallback);}},{key:"patchJSON",value:function patchJSON(pOptions,fCallback){if(_typeof(pOptions.body)!='object'){return fCallback(new Error("PATCH JSON Error Invalid options object"));}pOptions.method='PATCH';return this.executeJSONRequest(pOptions,fCallback);}},{key:"headJSON",value:function headJSON(pOptions,fCallback){if(_typeof(pOptions.body)!='object'){return fCallback(new Error("HEAD JSON Error Invalid options object"));}pOptions.method='HEAD';return this.executeJSONRequest(pOptions,fCallback);}},{key:"delJSON",value:function delJSON(pOptions,fCallback){pOptions.method='DELETE';return this.executeJSONRequest(pOptions,fCallback);}},{key:"getRawText",value:function getRawText(pOptionsOrURL,fCallback){var tmpRequestOptions=_typeof(pOptionsOrURL)=='object'?pOptionsOrURL:{};if(typeof pOptionsOrURL=='string'){tmpRequestOptions.url=pOptionsOrURL;}tmpRequestOptions.method='GET';return this.executeChunkedRequest(tmpRequestOptions,fCallback);}}]);return FableServiceRestClient;}(libFableServiceBase);module.exports=FableServiceRestClient;}).call(this);}).call(this,require("buffer").Buffer);},{"buffer":20,"cookie":27,"fable-serviceproviderbase":51,"simple-get":100}],144:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var FableServiceTemplate=/*#__PURE__*/function(_libFableServiceBase11){_inherits(FableServiceTemplate,_libFableServiceBase11);// Underscore and lodash have a behavior, _.template, which compiles a
|
|
3308
3324
|
// string-based template with code snippets into simple executable pieces,
|
|
3309
3325
|
// with the added twist of returning a precompiled function ready to go.
|
|
3310
3326
|
//
|
|
@@ -3313,19 +3329,19 @@ if(!tmpDataBuffer){tmpDataBuffer=Buffer.from(pChunk);}else{tmpDataBuffer=Buffer.
|
|
|
3313
3329
|
//
|
|
3314
3330
|
// This is an implementation of that.
|
|
3315
3331
|
// TODO: Make this use precedent, add configuration, add debugging.
|
|
3316
|
-
function FableServiceTemplate(pFable,pOptions,pServiceHash){var
|
|
3332
|
+
function FableServiceTemplate(pFable,pOptions,pServiceHash){var _this38;_classCallCheck2(this,FableServiceTemplate);_this38=_callSuper(this,FableServiceTemplate,[pFable,pOptions,pServiceHash]);_this38.serviceType='Template';// These are the exact regex's used in lodash/underscore
|
|
3317
3333
|
// TODO: Switch this to precedent
|
|
3318
|
-
|
|
3334
|
+
_this38.Matchers={Evaluate:/<%([\s\S]+?)%>/g,Interpolate:/<%=([\s\S]+?)%>/g,Escaper:/\\|'|\r|\n|\t|\u2028|\u2029/g,Unescaper:/\\(\\|'|r|n|t|u2028|u2029)/g,// This is how underscore does it, so we are keeping it for now.
|
|
3319
3335
|
GuaranteedNonMatch:/.^/};// This is a helper for the escaper and unescaper functions.
|
|
3320
3336
|
// Right now we are going to keep what underscore is doing, but, not forever.
|
|
3321
|
-
|
|
3337
|
+
_this38.templateEscapes={'\\':'\\',"'":"'",'r':'\r','\r':'r','n':'\n','\n':'n','t':'\t','\t':'t','u2028':"\u2028","\u2028":'u2028','u2029':"\u2029","\u2029":'u2029'};// This is defined as such to underscore that it is a dynamic programming
|
|
3322
3338
|
// function on this class.
|
|
3323
|
-
|
|
3339
|
+
_this38.renderFunction=false;_this38.templateString=false;return _this38;}_createClass2(FableServiceTemplate,[{key:"renderTemplate",value:function renderTemplate(pData){return this.renderFunction(pData);}},{key:"templateFunction",value:function templateFunction(pData){var fRenderTemplateBound=this.renderTemplate.bind(this);return fRenderTemplateBound;}},{key:"buildTemplateFunction",value:function buildTemplateFunction(pTemplateText,pData){var _this39=this;// For now this is being kept in a weird form ... this is to mimic the old
|
|
3324
3340
|
// underscore code until this is rewritten using precedent.
|
|
3325
|
-
this.TemplateSource="__p+='"+pTemplateText.replace(this.Matchers.Escaper,function(pMatch){return"\\".concat(
|
|
3341
|
+
this.TemplateSource="__p+='"+pTemplateText.replace(this.Matchers.Escaper,function(pMatch){return"\\".concat(_this39.templateEscapes[pMatch]);}).replace(this.Matchers.Interpolate||this.Matchers.GuaranteedNonMatch,function(pMatch,pCode){return"'+\n(".concat(decodeURIComponent(pCode),")+\n'");}).replace(this.Matchers.Evaluate||this.Matchers.GuaranteedNonMatch,function(pMatch,pCode){return"';\n".concat(decodeURIComponent(pCode),"\n;__p+='");})+"';\n";this.TemplateSource="with(pTemplateDataObject||{}){\n".concat(this.TemplateSource,"}\n");this.TemplateSource="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n".concat(this.TemplateSource,"return __p;\n");this.renderFunction=new Function('pTemplateDataObject',this.TemplateSource);if(typeof pData!='undefined'){return this.renderFunction(pData);}// Provide the compiled function source as a convenience for build time
|
|
3326
3342
|
// precompilation.
|
|
3327
|
-
this.TemplateSourceCompiled='function(obj){\n'+this.TemplateSource+'}';return this.templateFunction();}}]);return FableServiceTemplate;}(libFableServiceBase);module.exports=FableServiceTemplate;},{"fable-serviceproviderbase":51}],
|
|
3328
|
-
var libAsyncWaterfall=require('async.waterfall');var libAsyncEachLimit=require('async.eachlimit');var libBigNumber=require('big.js');var FableServiceUtility=/*#__PURE__*/function(
|
|
3343
|
+
this.TemplateSourceCompiled='function(obj){\n'+this.TemplateSource+'}';return this.templateFunction();}}]);return FableServiceTemplate;}(libFableServiceBase);module.exports=FableServiceTemplate;},{"fable-serviceproviderbase":51}],145:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');// TODO: These are still pretty big -- consider the smaller polyfills
|
|
3344
|
+
var libAsyncWaterfall=require('async.waterfall');var libAsyncEachLimit=require('async.eachlimit');var libBigNumber=require('big.js');var FableServiceUtility=/*#__PURE__*/function(_libFableServiceBase12){_inherits(FableServiceUtility,_libFableServiceBase12);// Underscore and lodash have a behavior, _.template, which compiles a
|
|
3329
3345
|
// string-based template with code snippets into simple executable pieces,
|
|
3330
3346
|
// with the added twist of returning a precompiled function ready to go.
|
|
3331
3347
|
//
|
|
@@ -3334,8 +3350,8 @@ var libAsyncWaterfall=require('async.waterfall');var libAsyncEachLimit=require('
|
|
|
3334
3350
|
//
|
|
3335
3351
|
// This is an implementation of that.
|
|
3336
3352
|
// TODO: Make this use precedent, add configuration, add debugging.
|
|
3337
|
-
function FableServiceUtility(pFable,pOptions,pServiceHash){var
|
|
3338
|
-
|
|
3353
|
+
function FableServiceUtility(pFable,pOptions,pServiceHash){var _this40;_classCallCheck2(this,FableServiceUtility);_this40=_callSuper(this,FableServiceUtility,[pFable,pOptions,pServiceHash]);_this40.templates={};// These two functions are used extensively throughout
|
|
3354
|
+
_this40.waterfall=libAsyncWaterfall;_this40.eachLimit=libAsyncEachLimit;_this40.bigNumber=libBigNumber;return _this40;}// Underscore and lodash have a behavior, _.extend, which merges objects.
|
|
3339
3355
|
// Now that es6 gives us this, use the native thingy.
|
|
3340
3356
|
// Nevermind, the native thing is not stable enough across environments
|
|
3341
3357
|
// Basic shallow copy
|