fable 3.0.135 → 3.0.137
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 +154 -72
- package/dist/fable.compatible.min.js +2 -2
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +123 -41
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/example_applications/mathematical_playground/.vscode/launch.json +17 -0
- package/example_applications/mathematical_playground/Math-Solver-Harness.js +31 -34
- package/package.json +2 -2
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer.js +0 -1
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Linter.js +0 -1
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Messaging.js +159 -0
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Postfix.js +7 -4
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-SolvePostfixedExpression.js +16 -7
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ValueMarshal.js +146 -0
- package/source/services/Fable-Service-ExpressionParser.js +77 -127
package/dist/fable.compatible.js
CHANGED
|
@@ -919,10 +919,15 @@ if(!_typeof(pObject[_tmpFunctionAddress])=='function'){// The address suggests i
|
|
|
919
919
|
return false;}// Now see if the function has arguments.
|
|
920
920
|
// Implementation notes: * ARGUMENTS MUST SHARE THE SAME ROOT OBJECT CONTEXT *
|
|
921
921
|
var tmpFunctionArguments=_MockFable.DataFormat.stringGetSegments(_MockFable.DataFormat.stringGetEnclosureValueByIndex(tmpSubObjectName.substring(_tmpFunctionAddress.length),0),',');if(tmpFunctionArguments.length==0||tmpFunctionArguments[0]==''){// No arguments... just call the function (bound to the scope of the object it is contained withing)
|
|
922
|
-
return this.checkAddressExists(pObject[_tmpFunctionAddress].apply(pObject),tmpNewAddress,tmpRootObject);}
|
|
922
|
+
if(_tmpFunctionAddress in pObject){try{return this.checkAddressExists(pObject[_tmpFunctionAddress].apply(pObject),tmpNewAddress,tmpRootObject);}catch(pError){// The function call failed, so the address doesn't exist
|
|
923
|
+
libSimpleLog.log("Error calling function ".concat(_tmpFunctionAddress," (address [").concat(pAddress,"]): ").concat(pError.message));return false;}}else{// The function doesn't exist, so the address doesn't exist
|
|
924
|
+
libSimpleLog.log("Function ".concat(_tmpFunctionAddress," does not exist (address [").concat(pAddress,"])"));return false;}}else{var tmpArgumentValues=[];var _tmpRootObject=typeof pRootObject=='undefined'?pObject:pRootObject;// Now get the value for each argument
|
|
923
925
|
for(var i=0;i<tmpFunctionArguments.length;i++){// Resolve the values for each subsequent entry
|
|
924
926
|
// NOTE: This is where the resolves get really tricky. Recursion within recursion. Programming gom jabbar, yo.
|
|
925
|
-
tmpArgumentValues.push(this.getObjectValueClass.getValueAtAddress(_tmpRootObject,tmpFunctionArguments[i]));}return this.checkAddressExists(pObject[
|
|
927
|
+
tmpArgumentValues.push(this.getObjectValueClass.getValueAtAddress(_tmpRootObject,tmpFunctionArguments[i]));}//return this.checkAddressExists(pObject[tmpFunctionAddress].apply(pObject, tmpArgumentValues), tmpNewAddress, tmpRootObject);
|
|
928
|
+
if(_tmpFunctionAddress in pObject){try{return this.checkAddressExists(pObject[_tmpFunctionAddress].apply(pObject,tmpArgumentValues),tmpNewAddress,_tmpRootObject);}catch(pError){// The function call failed, so the address doesn't exist
|
|
929
|
+
libSimpleLog.log("Error calling function ".concat(_tmpFunctionAddress," (address [").concat(pAddress,"]): ").concat(pError.message));return false;}}else{// The function doesn't exist, so the address doesn't exist
|
|
930
|
+
libSimpleLog.log("Function ".concat(_tmpFunctionAddress," does not exist (address [").concat(pAddress,"])"));return false;}}}// Boxed elements look like this:
|
|
926
931
|
// MyValues[42]
|
|
927
932
|
// MyValues['Color']
|
|
928
933
|
// MyValues["Weight"]
|
|
@@ -1147,12 +1152,16 @@ if(tmpFunctionStartIndex>0// 2) The end bracket is after the start bracket
|
|
|
1147
1152
|
return false;}// Now see if the function has arguments.
|
|
1148
1153
|
// Implementation notes: * ARGUMENTS MUST SHARE THE SAME ROOT OBJECT CONTEXT *
|
|
1149
1154
|
var tmpFunctionArguments=_MockFable.DataFormat.stringGetSegments(_MockFable.DataFormat.stringGetEnclosureValueByIndex(pAddress.substring(tmpFunctionAddress.length),0),',');if(tmpFunctionArguments.length==0||tmpFunctionArguments[0]==''){// No arguments... just call the function (bound to the scope of the object it is contained withing)
|
|
1150
|
-
return pObject[tmpFunctionAddress].apply(pObject);}
|
|
1155
|
+
if(tmpFunctionAddress in pObject){try{return pObject[tmpFunctionAddress].apply(pObject);}catch(pError){// The function call failed, so the address doesn't exist
|
|
1156
|
+
console.log("Error in getValueAtAddress calling function ".concat(tmpFunctionAddress," (address [").concat(pAddress,"]): ").concat(pError.message));return false;}}else{// The function doesn't exist, so the address doesn't exist
|
|
1157
|
+
console.log("Function ".concat(tmpFunctionAddress," does not exist (address [").concat(pAddress,"])"));return false;}}else{var tmpArgumentValues=[];var _tmpRootObject2=typeof pRootObject=='undefined'?pObject:pRootObject;// Now get the value for each argument
|
|
1151
1158
|
for(var _i4=0;_i4<tmpFunctionArguments.length;_i4++){// Resolve the values for each subsequent entry
|
|
1152
1159
|
// Check if the argument value is a string literal or a reference to an address
|
|
1153
1160
|
if(tmpFunctionArguments[_i4].length>=2&&(tmpFunctionArguments[_i4].charAt(0)=='"'||tmpFunctionArguments[_i4].charAt(0)=="'"||tmpFunctionArguments[_i4].charAt(0)=="`")&&(tmpFunctionArguments[_i4].charAt(tmpFunctionArguments[_i4].length-1)=='"'||tmpFunctionArguments[_i4].charAt(tmpFunctionArguments[_i4].length-1)=="'"||tmpFunctionArguments[_i4].charAt(tmpFunctionArguments[_i4].length-1)=="`")){// This is a string literal
|
|
1154
1161
|
tmpArgumentValues.push(tmpFunctionArguments[_i4].substring(1,tmpFunctionArguments[_i4].length-1));}else{// This is a hash address
|
|
1155
|
-
tmpArgumentValues.push(this.getValueAtAddress(_tmpRootObject2,tmpFunctionArguments[_i4]));}}return pObject[tmpFunctionAddress].apply(pObject,tmpArgumentValues);}
|
|
1162
|
+
tmpArgumentValues.push(this.getValueAtAddress(_tmpRootObject2,tmpFunctionArguments[_i4]));}}if(tmpFunctionAddress in pObject){try{return pObject[tmpFunctionAddress].apply(pObject,tmpArgumentValues);}catch(pError){// The function call failed, so the address doesn't exist
|
|
1163
|
+
console.log("Error in getValueAtAddress calling function ".concat(tmpFunctionAddress," (address [").concat(pAddress,"]): ").concat(pError.message));return false;}}else{// The function doesn't exist, so the address doesn't exist
|
|
1164
|
+
console.log("Function ".concat(tmpFunctionAddress," does not exist (address [").concat(pAddress,"])"));return false;}}}// Boxed elements look like this:
|
|
1156
1165
|
// MyValues[10]
|
|
1157
1166
|
// MyValues['Name']
|
|
1158
1167
|
// MyValues["Age"]
|
|
@@ -1210,12 +1219,16 @@ if(_tmpFunctionStartIndex2>0// 2) The end bracket is after the start bracket
|
|
|
1210
1219
|
return false;}// Now see if the function has arguments.
|
|
1211
1220
|
// Implementation notes: * ARGUMENTS MUST SHARE THE SAME ROOT OBJECT CONTEXT *
|
|
1212
1221
|
var _tmpFunctionArguments=_MockFable.DataFormat.stringGetSegments(_MockFable.DataFormat.stringGetEnclosureValueByIndex(tmpSubObjectName.substring(_tmpFunctionAddress2.length),0),',');if(_tmpFunctionArguments.length==0||_tmpFunctionArguments[0]==''){// No arguments... just call the function (bound to the scope of the object it is contained withing)
|
|
1213
|
-
return this.getValueAtAddress(pObject[_tmpFunctionAddress2].apply(pObject),tmpNewAddress,tmpParentAddress,tmpRootObject);}
|
|
1222
|
+
if(_tmpFunctionAddress2 in pObject){try{return this.getValueAtAddress(pObject[_tmpFunctionAddress2].apply(pObject),tmpNewAddress,tmpParentAddress,tmpRootObject);}catch(pError){// The function call failed, so the address doesn't exist
|
|
1223
|
+
console.log("Error in getValueAtAddress calling function ".concat(_tmpFunctionAddress2," (address [").concat(pAddress,"]): ").concat(pError.message));return false;}}else{// The function doesn't exist, so the address doesn't exist
|
|
1224
|
+
console.log("Function ".concat(_tmpFunctionAddress2," does not exist (address [").concat(pAddress,"])"));return false;}}else{var _tmpArgumentValues=[];var _tmpRootObject3=typeof pRootObject=='undefined'?pObject:pRootObject;// Now get the value for each argument
|
|
1214
1225
|
for(var _i6=0;_i6<_tmpFunctionArguments.length;_i6++){// Resolve the values for each subsequent entry
|
|
1215
1226
|
// Check if the argument value is a string literal or a reference to an address
|
|
1216
1227
|
if(_tmpFunctionArguments[_i6].length>=2&&(_tmpFunctionArguments[_i6].charAt(0)=='"'||_tmpFunctionArguments[_i6].charAt(0)=="'"||_tmpFunctionArguments[_i6].charAt(0)=="`")&&(_tmpFunctionArguments[_i6].charAt(_tmpFunctionArguments[_i6].length-1)=='"'||_tmpFunctionArguments[_i6].charAt(_tmpFunctionArguments[_i6].length-1)=="'"||_tmpFunctionArguments[_i6].charAt(_tmpFunctionArguments[_i6].length-1)=="`")){// This is a string literal
|
|
1217
1228
|
_tmpArgumentValues.push(_tmpFunctionArguments[_i6].substring(1,_tmpFunctionArguments[_i6].length-1));}else{// This is a hash address
|
|
1218
|
-
_tmpArgumentValues.push(this.getValueAtAddress(_tmpRootObject3,_tmpFunctionArguments[_i6]));}}return this.getValueAtAddress(pObject[_tmpFunctionAddress2].apply(pObject,_tmpArgumentValues),tmpNewAddress,tmpParentAddress,_tmpRootObject3);}
|
|
1229
|
+
_tmpArgumentValues.push(this.getValueAtAddress(_tmpRootObject3,_tmpFunctionArguments[_i6]));}}if(_tmpFunctionAddress2 in pObject){try{return this.getValueAtAddress(pObject[_tmpFunctionAddress2].apply(pObject,_tmpArgumentValues),tmpNewAddress,tmpParentAddress,_tmpRootObject3);}catch(pError){// The function call failed, so the address doesn't exist
|
|
1230
|
+
console.log("Error in getValueAtAddress calling function ".concat(_tmpFunctionAddress2," (address [").concat(pAddress,"]): ").concat(pError.message));return false;}}else{// The function doesn't exist, so the address doesn't exist
|
|
1231
|
+
console.log("Function ".concat(_tmpFunctionAddress2," does not exist (address [").concat(pAddress,"])"));return false;}}}// Boxed elements look like this:
|
|
1219
1232
|
// MyValues[42]
|
|
1220
1233
|
// MyValues['Color']
|
|
1221
1234
|
// MyValues["Weight"]
|
|
@@ -3050,7 +3063,7 @@ this.servicesMap[tmpServiceType][tmpServiceHash]=pServiceInstance;// If this is
|
|
|
3050
3063
|
if(!(tmpServiceType in this.services)){this.setDefaultServiceInstantiation(tmpServiceType,tmpServiceHash,false);}return pServiceInstance;}},{key:"setDefaultServiceInstantiation",value:function setDefaultServiceInstantiation(pServiceType,pServiceHash,pOverwriteService){// Overwrite services by default, unless told not to
|
|
3051
3064
|
var tmpOverwriteService=typeof pOverwriteService==='undefined'?true:pOverwriteService;// Make sure the service exists
|
|
3052
3065
|
if(pServiceHash in this.servicesMap[pServiceType]){if(!(pServiceType in this)||tmpOverwriteService){this[pServiceType]=this.servicesMap[pServiceType][pServiceHash];}if(!(pServiceType in this.services)||tmpOverwriteService){this.services[pServiceType]=this.servicesMap[pServiceType][pServiceHash];}return true;}return false;}}]);return Fable;}(libFableServiceBase.CoreServiceProviderBase);// This is for backwards compatibility
|
|
3053
|
-
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":128,"./services/Fable-Service-CSVParser.js":129,"./services/Fable-Service-DataFormat.js":130,"./services/Fable-Service-DataGeneration.js":132,"./services/Fable-Service-DateManipulation.js":133,"./services/Fable-Service-EnvironmentData.js":134,"./services/Fable-Service-ExpressionParser.js":135,"./services/Fable-Service-FilePersistence.js":
|
|
3066
|
+
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":128,"./services/Fable-Service-CSVParser.js":129,"./services/Fable-Service-DataFormat.js":130,"./services/Fable-Service-DataGeneration.js":132,"./services/Fable-Service-DateManipulation.js":133,"./services/Fable-Service-EnvironmentData.js":134,"./services/Fable-Service-ExpressionParser.js":135,"./services/Fable-Service-FilePersistence.js":145,"./services/Fable-Service-Math.js":146,"./services/Fable-Service-MetaTemplate.js":147,"./services/Fable-Service-Operation.js":151,"./services/Fable-Service-ProgressTime.js":152,"./services/Fable-Service-ProgressTrackerSet.js":154,"./services/Fable-Service-RestClient.js":155,"./services/Fable-Service-Template.js":156,"./services/Fable-Service-Utility.js":157,"cachetrax":22,"fable-log":50,"fable-serviceproviderbase":51,"fable-settings":54,"fable-uuid":56,"manyfest":80}],128:[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.
|
|
3054
3067
|
_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.
|
|
3055
3068
|
if(this.lastError){// If there are no operations left, and we have waiting functions, call them.
|
|
3056
3069
|
for(var i=0;i<this.waitingFunctions.length;i++){//this.log.trace('Calling waiting function.')
|
|
@@ -3359,7 +3372,7 @@ return _this22;}return _createClass2(DateManipulation);}(libFableServiceProvider
|
|
|
3359
3372
|
* Learned a lot from this npm package: https://www.npmjs.com/package/math-expression-evaluator
|
|
3360
3373
|
* And its related code at github: https://github.com/bugwheels94/math-expression-evaluator
|
|
3361
3374
|
*
|
|
3362
|
-
* There were two problems with the codebase...
|
|
3375
|
+
* There were two problems with the codebase above...
|
|
3363
3376
|
*
|
|
3364
3377
|
* First, the code was very unreadable and determining it was correct or extending it
|
|
3365
3378
|
* was out of the question.
|
|
@@ -3367,20 +3380,57 @@ return _this22;}return _createClass2(DateManipulation);}(libFableServiceProvider
|
|
|
3367
3380
|
* Second, and this is a larger issue, is that we need the expressions to be parsed as
|
|
3368
3381
|
* arbitrary precision. When I determined that extending the library to use string-based
|
|
3369
3382
|
* numbers and an arbitrary precision library as the back-end would have taken a significantly
|
|
3370
|
-
* longer amount of time than just writing the parser from scratch
|
|
3371
|
-
*/var FableServiceExpressionParser=/*#__PURE__*/function(_libFableServiceBase4){_inherits(FableServiceExpressionParser,_libFableServiceBase4)
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3383
|
+
* longer amount of time than just writing the parser from scratch... et voila.
|
|
3384
|
+
*/var FableServiceExpressionParser=/*#__PURE__*/function(_libFableServiceBase4){_inherits(FableServiceExpressionParser,_libFableServiceBase4);/**
|
|
3385
|
+
* Constructs a new instance of the ExpressionParser service.
|
|
3386
|
+
* @param {Object} pFable - The Fable object.
|
|
3387
|
+
* @param {Object} pOptions - The options for the service.
|
|
3388
|
+
* @param {string} pServiceHash - The hash of the service.
|
|
3389
|
+
*/function FableServiceExpressionParser(pFable,pOptions,pServiceHash){var _this24;_classCallCheck2(this,FableServiceExpressionParser);_this24=_callSuper(this,FableServiceExpressionParser,[pFable,pOptions,pServiceHash]);// The configuration for tokens that the solver recognizes, with precedence and friendly names.
|
|
3390
|
+
_this24.tokenMap=require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-TokenMap.json');// This precedence is higher than defined in our token map. We could make this value dynamic
|
|
3391
|
+
_this24.tokenMaxPrecedence=10;// The configuration for which functions are available to the solver.
|
|
3392
|
+
_this24.functionMap=require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-FunctionMap.json');_this24.serviceType='ExpressionParser';// These are sub-services for the tokenizer, linter, compiler, marshaler and solver.
|
|
3393
|
+
_this24.fable.addServiceTypeIfNotExists('ExpressionParser-Tokenizer',require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer.js'));_this24.fable.addServiceTypeIfNotExists('ExpressionParser-Linter',require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Linter.js'));_this24.fable.addServiceTypeIfNotExists('ExpressionParser-Postfix',require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Postfix.js'));_this24.fable.addServiceTypeIfNotExists('ExpressionParser-ValueMarshal',require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ValueMarshal.js'));_this24.fable.addServiceTypeIfNotExists('ExpressionParser-Solver',require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-SolvePostfixedExpression.js'));// And the sub-service for the friendly user messaging
|
|
3394
|
+
_this24.fable.addServiceTypeIfNotExists('ExpressionParser-Messaging',require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Messaging.js'));// This code instantitates these fable services to child objects of this service, but does not pollute the main fable with them.
|
|
3395
|
+
_this24.Tokenizer=_this24.fable.instantiateServiceProviderWithoutRegistration('ExpressionParser-Tokenizer');_this24.Linter=_this24.fable.instantiateServiceProviderWithoutRegistration('ExpressionParser-Linter');_this24.Postfix=_this24.fable.instantiateServiceProviderWithoutRegistration('ExpressionParser-Postfix');_this24.ValueMarshal=_this24.fable.instantiateServiceProviderWithoutRegistration('ExpressionParser-ValueMarshal');_this24.Solver=_this24.fable.instantiateServiceProviderWithoutRegistration('ExpressionParser-Solver');_this24.Messaging=_this24.fable.instantiateServiceProviderWithoutRegistration('ExpressionParser-Messaging');// Wire each sub service into this instance of the solver.
|
|
3396
|
+
_this24.Tokenizer.connectExpressionParser(_assertThisInitialized(_this24));_this24.Linter.connectExpressionParser(_assertThisInitialized(_this24));_this24.Postfix.connectExpressionParser(_assertThisInitialized(_this24));_this24.ValueMarshal.connectExpressionParser(_assertThisInitialized(_this24));_this24.Solver.connectExpressionParser(_assertThisInitialized(_this24));_this24.Messaging.connectExpressionParser(_assertThisInitialized(_this24));_this24.GenericManifest=_this24.fable.newManyfest();// This will look for a LogNoisiness on fable (or one that falls in from pict) and if it doesn't exist, set one for this service.
|
|
3397
|
+
_this24.LogNoisiness='LogNoisiness'in _this24.fable?_this24.fable.LogNoisiness:0;return _this24;}/**
|
|
3398
|
+
* Tokenizes the given mathematical expression string.
|
|
3399
|
+
*
|
|
3400
|
+
* @param {string} pExpression - The expression to tokenize.
|
|
3401
|
+
* @param {object} pResultObject - The result object to store the tokenized expression.
|
|
3402
|
+
* @returns {object} - The tokenized expression.
|
|
3403
|
+
*/_createClass2(FableServiceExpressionParser,[{key:"tokenize",value:function tokenize(pExpression,pResultObject){return this.Tokenizer.tokenize(pExpression,pResultObject);}/**
|
|
3404
|
+
* Lints a tokenized expression.
|
|
3405
|
+
*
|
|
3406
|
+
* @param {Array} pTokenizedExpression - The tokenized expression to lint.
|
|
3407
|
+
* @param {Object} pResultObject - The result object where we store the linting result.
|
|
3408
|
+
* @returns {Object} - The linting result object.
|
|
3409
|
+
*/},{key:"lintTokenizedExpression",value:function lintTokenizedExpression(pTokenizedExpression,pResultObject){return this.Linter.lintTokenizedExpression(pTokenizedExpression,pResultObject);}/**
|
|
3410
|
+
* Builds a postfix solve list for the given tokenized expression and result object.
|
|
3411
|
+
*
|
|
3412
|
+
* @param {Array} pTokenizedExpression - The tokenized expression.
|
|
3413
|
+
* @param {Object} pResultObject - The result object where the algorithm "shows its work".
|
|
3414
|
+
* @returns {Array} The postfix solve list.
|
|
3415
|
+
*/},{key:"buildPostfixedSolveList",value:function buildPostfixedSolveList(pTokenizedExpression,pResultObject){return this.Postfix.buildPostfixedSolveList(pTokenizedExpression,pResultObject);}/**
|
|
3416
|
+
* Substitutes values in tokenized objects.
|
|
3417
|
+
*
|
|
3418
|
+
* This means marshaling data from pDataSource into the array of objects with the passed in Manifest (or a generic manifest) to prepare for solving.
|
|
3419
|
+
*
|
|
3420
|
+
* @param {Array} pTokenizedObjects - The array of tokenized objects.
|
|
3421
|
+
* @param {Object} pDataSource - The data source object.
|
|
3422
|
+
* @param {Object} pResultObject - The result object.
|
|
3423
|
+
* @param {Object} pManifest - The manifest object.
|
|
3424
|
+
* @returns {Object} - The updated result object.
|
|
3425
|
+
*/},{key:"substituteValuesInTokenizedObjects",value:function substituteValuesInTokenizedObjects(pTokenizedObjects,pDataSource,pResultObject,pManifest){return this.ValueMarshal.substituteValuesInTokenizedObjects(pTokenizedObjects,pDataSource,pResultObject,pManifest);}/**
|
|
3426
|
+
* Solves a postfixed expression Array.
|
|
3427
|
+
*
|
|
3428
|
+
* @param {Array} pPostfixedExpression - The postfixed expression to solve.
|
|
3429
|
+
* @param {object} pDataDestinationObject - The data destination object where data gets marshaled to after solving.
|
|
3430
|
+
* @param {object} pResultObject - The result object where the algorithm "shows its work".
|
|
3431
|
+
* @param {object} pManifest - The manifest object.
|
|
3432
|
+
* @returns {any} The result of the solved expression.
|
|
3433
|
+
*/},{key:"solvePostfixedExpression",value:function solvePostfixedExpression(pPostfixedExpression,pDataDestinationObject,pResultObject,pManifest){return this.Solver.solvePostfixedExpression(pPostfixedExpression,pDataDestinationObject,pResultObject,pManifest);}/**
|
|
3384
3434
|
* Solves the given expression using the provided data and manifest.
|
|
3385
3435
|
*
|
|
3386
3436
|
* @param {string} pExpression - The expression to solve.
|
|
@@ -3389,7 +3439,10 @@ tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.substituteValuesInT
|
|
|
3389
3439
|
* @param {object} pManifest - (optional) The manifest object for dereferencing variables.
|
|
3390
3440
|
* @param {object} pDataDestinationObject - (optional) The data destination object for where to marshal the result into.
|
|
3391
3441
|
* @returns {any} - The result of solving the expression.
|
|
3392
|
-
*/},{key:"solve",value:function solve(pExpression,pDataSourceObject,pResultObject,pManifest,pDataDestinationObject){var tmpResultsObject=_typeof(pResultObject)==='object'?pResultObject:{};var tmpDataSourceObject=_typeof(pDataSourceObject)==='object'?pDataSourceObject:{};var tmpDataDestinationObject=_typeof(pDataDestinationObject)==='object'?pDataDestinationObject:{}
|
|
3442
|
+
*/},{key:"solve",value:function solve(pExpression,pDataSourceObject,pResultObject,pManifest,pDataDestinationObject){var tmpResultsObject=_typeof(pResultObject)==='object'?pResultObject:{};var tmpDataSourceObject=_typeof(pDataSourceObject)==='object'?pDataSourceObject:{};var tmpDataDestinationObject=_typeof(pDataDestinationObject)==='object'?pDataDestinationObject:{};// This is technically a "pre-compile" and we can keep this Results Object around to reuse for better performance. Not required.
|
|
3443
|
+
this.tokenize(pExpression,tmpResultsObject);this.lintTokenizedExpression(tmpResultsObject.RawTokens,tmpResultsObject);this.buildPostfixedSolveList(tmpResultsObject.RawTokens,tmpResultsObject);// This is where the data from variables gets marshaled into their symbols (from AppData or the like)
|
|
3444
|
+
this.substituteValuesInTokenizedObjects(tmpResultsObject.PostfixTokenObjects,tmpDataSourceObject,tmpResultsObject,pManifest);// Finally this is the expr solving method, which returns a string and also marshals it into tmpDataDestinationObject
|
|
3445
|
+
return this.solvePostfixedExpression(tmpResultsObject.PostfixSolveList,tmpDataDestinationObject,tmpResultsObject,pManifest);}}]);return FableServiceExpressionParser;}(libFableServiceBase);module.exports=FableServiceExpressionParser;},{"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer.js":137,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-FunctionMap.json":138,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Linter.js":139,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Messaging.js":140,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Postfix.js":141,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-SolvePostfixedExpression.js":142,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-TokenMap.json":143,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ValueMarshal.js":144,"big.js":17,"fable-serviceproviderbase":51}],136:[function(require,module,exports){var libFableServiceProviderBase=require('fable-serviceproviderbase');var ExpressionParserOperationBase=/*#__PURE__*/function(_libFableServiceProvi10){_inherits(ExpressionParserOperationBase,_libFableServiceProvi10);function ExpressionParserOperationBase(pFable,pOptions,pServiceHash){var _this25;_classCallCheck2(this,ExpressionParserOperationBase);_this25=_callSuper(this,ExpressionParserOperationBase,[pFable,pOptions,pServiceHash]);_this25.serviceType='ExpressionParserOperationBase';_this25.numberTest=/^-{0,1}\d*\.{0,1}\d+$/;_this25.ExpressionParser=false;return _this25;}_createClass2(ExpressionParserOperationBase,[{key:"connectExpressionParser",value:function connectExpressionParser(pExpressionParser){this.ExpressionParser=pExpressionParser;}},{key:"getTokenType",value:function getTokenType(pToken){if(pToken in this.ExpressionParser.tokenMap){return"Token.".concat(this.ExpressionParser.tokenMap[pToken].Type);}else if(pToken.length>2&&pToken[0]==='{'&&pToken[pToken.length-1]==='}'){return'Token.StateAddress';}else if(this.numberTest.test(pToken)){return'Token.Constant';}else{return'Token.Symbol';}// Just for documentation sake:
|
|
3393
3446
|
// There is a fifth token type, VirtualSymbol
|
|
3394
3447
|
// This is a value that's added during solve and looked up by address in the VirtualSymbol object.
|
|
3395
3448
|
}},{key:"getTokenContainerObject",value:function getTokenContainerObject(pToken,pTokenType){return{Token:pToken,Type:typeof pTokenType==='undefined'?this.getTokenType(pToken):pTokenType,Descriptor:pToken in this.ExpressionParser.tokenMap?this.ExpressionParser.tokenMap[pToken]:false};}}]);return ExpressionParserOperationBase;}(libFableServiceProviderBase);module.exports=ExpressionParserOperationBase;},{"fable-serviceproviderbase":51}],137:[function(require,module,exports){var libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');var ExpressionTokenizer=/*#__PURE__*/function(_libExpressionParserO){_inherits(ExpressionTokenizer,_libExpressionParserO);function ExpressionTokenizer(pFable,pOptions,pServiceHash){var _this26;_classCallCheck2(this,ExpressionTokenizer);_this26=_callSuper(this,ExpressionTokenizer,[pFable,pOptions,pServiceHash]);_this26.serviceType='ExpressionParser-Tokenizer';return _this26;}_createClass2(ExpressionTokenizer,[{key:"tokenize",value:function tokenize(pExpression,pResultObject){var tmpResults=_typeof(pResultObject)==='object'?pResultObject:{ExpressionParserLog:[]};tmpResults.RawExpression=pExpression;tmpResults.RawTokens=[];tmpResults.ExpressionParserLog=[];if(typeof pExpression!=='string'){this.log.warn('ExpressionParser.tokenize was passed a non-string expression.');return tmpResults.RawTokens;}/* Tokenize the expression
|
|
@@ -3459,7 +3512,15 @@ this.getTokenType(pTokenizedExpression[0])==='Token.StateAddress'||this.getToken
|
|
|
3459
3512
|
){tmpResults.ExpressionParserLog.push("WARNING: ExpressionParser.lintTokenizedExpression found a single equality assignment in the tokenized expression with no assignable address on the left side of the assignment.");tmpResults.LinterResults.push(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);}}}// 5. Check that there are no operators adjacent to each other
|
|
3460
3513
|
// This is a simple lint check, not a full-blown syntax check
|
|
3461
3514
|
var tmpTokenPrevious=false;for(var _i17=0;_i17<pTokenizedExpression.length-1;_i17++){if(pTokenizedExpression[_i17]in this.ExpressionParser.tokenMap&&this.ExpressionParser.tokenMap[pTokenizedExpression[_i17]].Type!='Parenthesis'&&!tmpTokenPrevious){tmpTokenPrevious=true;}else if(pTokenizedExpression[_i17]in this.ExpressionParser.tokenMap&&this.ExpressionParser.tokenMap[pTokenizedExpression[_i17]].Type!='Parenthesis'){// If this isn't a + or - positivity/negativity multiplier, it's an error.
|
|
3462
|
-
if(pTokenizedExpression[_i17]!=='+'&&pTokenizedExpression[_i17]!=='-'){tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.lintTokenizedExpression found an ".concat(pTokenizedExpression[_i17]," operator adjacent to another operator in the tokenized expression at token index ").concat(_i17));tmpResults.LinterResults.push(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);}}else{tmpTokenPrevious=false;}}return tmpResults.LinterResults;}}]);return ExpressionParserLinter;}(libExpressionParserOperationBase);module.exports=ExpressionParserLinter;},{"./Fable-Service-ExpressionParser-Base.js":136}],140:[function(require,module,exports){var
|
|
3515
|
+
if(pTokenizedExpression[_i17]!=='+'&&pTokenizedExpression[_i17]!=='-'){tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.lintTokenizedExpression found an ".concat(pTokenizedExpression[_i17]," operator adjacent to another operator in the tokenized expression at token index ").concat(_i17));tmpResults.LinterResults.push(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);}}else{tmpTokenPrevious=false;}}return tmpResults.LinterResults;}}]);return ExpressionParserLinter;}(libExpressionParserOperationBase);module.exports=ExpressionParserLinter;},{"./Fable-Service-ExpressionParser-Base.js":136}],140:[function(require,module,exports){var _require4=require('big.js'),PE=_require4.PE;var libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');/**
|
|
3516
|
+
* Represents a user-friendly messaging service for the ExpressionParser compiler output.
|
|
3517
|
+
* @class ExpressionParserMessaging
|
|
3518
|
+
* @extends libExpressionParserOperationBase
|
|
3519
|
+
*/var ExpressionParserMessaging=/*#__PURE__*/function(_libExpressionParserO3){_inherits(ExpressionParserMessaging,_libExpressionParserO3);function ExpressionParserMessaging(pFable,pOptions,pServiceHash){var _this28;_classCallCheck2(this,ExpressionParserMessaging);_this28=_callSuper(this,ExpressionParserMessaging,[pFable,pOptions,pServiceHash]);_this28.serviceType='ExpressionParser-Messaging';return _this28;}_createClass2(ExpressionParserMessaging,[{key:"getOperationVirtualSymbolName",value:function getOperationVirtualSymbolName(pOperationToken){return pOperationToken&&'VirtualSymbolName'in pOperationToken?pOperationToken.VirtualSymbolName:pOperationToken.Type==='Token.VirtualSymbol'?pOperationToken.Token:'NO_VIRTUAL_SYMBOL_NAME_FOUND';}},{key:"getVirtualTokenValue",value:function getVirtualTokenValue(pToken,pOperationResults){var tmpVirtualSymbol=this.getOperationVirtualSymbolName(pToken);var tmpVirtualSymbolData='VirtualSymbols'in pOperationResults?pOperationResults.VirtualSymbols:{};if(this.ExpressionParser.GenericManifest.checkAddressExists(tmpVirtualSymbolData,tmpVirtualSymbol)){var tmpValue=this.ExpressionParser.GenericManifest.getValueAtAddress(tmpVirtualSymbolData,tmpVirtualSymbol);if(_typeof(tmpValue)==='object'){return"{".concat(Object.keys(tmpValue).length," values}");}if(Array.isArray(tmpValue)){return"[".concat(Object.keys(tmpValue).length," values]");}return tmpValue;}return'NO_VALUE_FOUND';}},{key:"getTokenAddressString",value:function getTokenAddressString(pToken){return pExpression.Token;}},{key:"getTokenSymbolString",value:function getTokenSymbolString(pExpressionToken){return pExpressionToken.Token;}},{key:"getOperationSymbolMessage",value:function getOperationSymbolMessage(pOperation){if(!pOperation){return'INVALID_OPERATION';}var tmpOperationVirtualSymbol=this.getOperationVirtualSymbolName(pOperation);var tmpOperationLeftValue=this.getTokenSymbolString(pOperation.LeftValue);var tmpOperationSymbol=this.getTokenSymbolString(pOperation.Operation);var tmpOperationRightValue=this.getTokenSymbolString(pOperation.RightValue);var tmpVirtualSymbolPrefix=tmpOperationVirtualSymbol.substring(0,3);if(tmpOperationSymbol==='='){// Assignment operators are special
|
|
3520
|
+
return"".concat(tmpOperationVirtualSymbol," = ").concat(tmpOperationLeftValue);}if(tmpVirtualSymbolPrefix==='VFE'){// Virtual Function Expression
|
|
3521
|
+
return"".concat(tmpOperationVirtualSymbol," = ").concat(tmpOperationSymbol,"(").concat(tmpOperationRightValue,")");}return"".concat(tmpOperationVirtualSymbol," = ").concat(tmpOperationLeftValue," ").concat(tmpOperationSymbol," ").concat(tmpOperationRightValue);}},{key:"getOperationValueMessage",value:function getOperationValueMessage(pOperation,pResultObject){if(!pOperation){return'INVALID_OPERATION';}var tmpOperationVirtualSymbol=this.getOperationVirtualSymbolName(pOperation);var tmpOperationLeftValue=this.getVirtualTokenValue(pOperation.LeftValue,pResultObject);var tmpOperationSymbol=this.getTokenSymbolString(pOperation.Operation);var tmpOperationRightValue=this.getVirtualTokenValue(pOperation.RightValue,pResultObject);var tmpVirtualSymbolPrefix=tmpOperationVirtualSymbol.substring(0,3);if(tmpOperationSymbol==='='){// Assignment operators are special
|
|
3522
|
+
return"".concat(tmpOperationVirtualSymbol," = ").concat(tmpOperationLeftValue);}if(tmpVirtualSymbolPrefix==='VFE'){// Virtual Function Expression
|
|
3523
|
+
return"".concat(tmpOperationVirtualSymbol," = ").concat(tmpOperationSymbol,"(").concat(tmpOperationLeftValue,")");}return"".concat(tmpOperationVirtualSymbol," = ").concat(tmpOperationLeftValue," ").concat(tmpOperationSymbol," ").concat(tmpOperationRightValue);}},{key:"logFunctionOutcome",value:function logFunctionOutcome(pResultObject){if(_typeof(pResultObject)!=='object'){this.log.error("Solver results object was not an object. Cannot log outcome.");return;}var tmpAssignmentAddress='PostfixedAssignmentAddress'in pResultObject?pResultObject.PostfixedAssignmentAddress:'NO_ASSIGNMENT_ADDRESS_FOUND';var tmpRawExpression='RawExpression'in pResultObject?pResultObject.RawExpression:'NO_EXPRESSION_FOUND';var tmpRawResult='RawResult'in pResultObject?pResultObject.RawResult:'NO_RESULT_FOUND';this.log.info("Solved f(".concat(tmpAssignmentAddress,") = {").concat(tmpRawExpression,"}"));for(var i=0;i<pResultObject.PostfixSolveList.length;i++){var tmpToken=pResultObject.PostfixSolveList[i];var tmpTokenSymbolMessage=this.getOperationSymbolMessage(tmpToken);this.log.info("".concat(i," Symbols: ").concat(tmpTokenSymbolMessage));var tmpTokenValueMessage=this.getOperationValueMessage(tmpToken,pResultObject);this.log.info("".concat(i," Values: ").concat(tmpTokenValueMessage));}this.log.info("{".concat(tmpRawExpression,"} = ").concat(tmpRawResult));}},{key:"logFunctionSolve",value:function logFunctionSolve(pResultObject){if(_typeof(pResultObject)!=='object'){this.log.error("Solver results object was not an object. Cannot log the solve.");return;}if(!('PostfixSolveList'in pResultObject)||!Array.isArray(pResultObject.PostfixSolveList)){this.log.error("Solver results object did not contain a PostfixSolveList array. Cannot log the solve.");return;}for(var i=0;i<tmpExpressionParseOutcome.PostfixSolveList.length;i++){var tmpToken=tmpExpressionParseOutcome.PostfixSolveList[i];console.log("".concat(i,": ").concat(tmpToken.VirtualSymbolName," = (").concat(tmpToken.LeftValue.Token,"::").concat(tmpToken.LeftValue.Value,") ").concat(tmpToken.Operation.Token," (").concat(tmpToken.RightValue.Token,"::").concat(tmpToken.RightValue.Value,") "));}this.logFunctionOutcome(pResultObject);}}]);return ExpressionParserMessaging;}(libExpressionParserOperationBase);module.exports=ExpressionParserMessaging;},{"./Fable-Service-ExpressionParser-Base.js":136,"big.js":17}],141:[function(require,module,exports){var libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');var ExpressionParserPostfix=/*#__PURE__*/function(_libExpressionParserO4){_inherits(ExpressionParserPostfix,_libExpressionParserO4);function ExpressionParserPostfix(pFable,pOptions,pServiceHash){var _this29;_classCallCheck2(this,ExpressionParserPostfix);_this29=_callSuper(this,ExpressionParserPostfix,[pFable,pOptions,pServiceHash]);_this29.serviceType='ExpressionParser-Postfix';return _this29;}_createClass2(ExpressionParserPostfix,[{key:"getPosfixSolveListOperation",value:function getPosfixSolveListOperation(pOperation,pLeftValue,pRightValue,pDepthSolveList,pDepthSolveIndex){var tmpOperation={VirtualSymbolName:pOperation.VirtualSymbolName,Operation:pOperation,LeftValue:pLeftValue,RightValue:pRightValue};var tmpDepthSolveList=Array.isArray(pDepthSolveList)?pDepthSolveList:false;/* These two if blocks are very complex -- they basically provide a
|
|
3463
3524
|
* way to deal with recursion that can be expressed to the user in
|
|
3464
3525
|
* a meaningful way.
|
|
3465
3526
|
*
|
|
@@ -3544,8 +3605,8 @@ tmpFinalChainToken=_tmpToken2;}else if(_tmpToken2.Descriptor.Precedence<tmpLastP
|
|
|
3544
3605
|
if(tmpDecreasingPrecedenceStack.length>0){for(var _j=tmpDecreasingPrecedenceStack.length-1;_j>=0;_j--){if(tmpDecreasingPrecedenceStack[_j].Descriptor.Precedence>=_tmpToken3.Descriptor.Precedence){//console.log(`Hoisting ${tmpDecreasingPrecedenceStack[j].Token} up to ${tmpToken.Token}`);
|
|
3545
3606
|
tmpDecreasingPrecedenceStack[_j].LeftVirtualSymbolName=_tmpToken3.VirtualSymbolName;tmpDecreasingPrecedenceStack.slice(_j,1);break;}}}tmpLastToken=_tmpToken3;}else if(_tmpToken3.Descriptor.Precedence<tmpLastPrecedence){tmpDecreasingPrecedenceStack.push(tmpLastToken);tmpLastToken=_tmpToken3;}tmpLastPrecedence=_tmpToken3.Descriptor.Precedence;}}}// 5.3: Generate the Postfix Solve List
|
|
3546
3607
|
for(var _tmpSolveLayerIndex3=0;_tmpSolveLayerIndex3<tmpSolveLayerKeys.length;_tmpSolveLayerIndex3++){var _tmpSolveLayerTokens3=tmpSolveLayerMap[tmpSolveLayerKeys[_tmpSolveLayerIndex3]];// If this is a layer with one value, presume it's an assignment.
|
|
3547
|
-
if(_tmpSolveLayerTokens3.length===1){var
|
|
3548
|
-
if(!
|
|
3608
|
+
if(_tmpSolveLayerTokens3.length===1){var _tmpAbstractAssignToken=this.getTokenContainerObject('=');_tmpAbstractAssignToken.VirtualSymbolName=tmpResults.PostfixLayerstackMap[_tmpSolveLayerTokens3[0].SolveLayerStack];// If this doesn't have a matching solvelayerstack, get the virtual symbol name from the parenthesis group it's in
|
|
3609
|
+
if(!_tmpAbstractAssignToken.VirtualSymbolName){for(var _i26=0;_i26<tmpResults.PostfixTokenObjects.length;_i26++){if(tmpResults.PostfixTokenObjects[_i26].ParenthesisStack===_tmpSolveLayerTokens3[0].SolveLayerStack){_tmpAbstractAssignToken.VirtualSymbolName=tmpResults.PostfixTokenObjects[_i26].VirtualSymbolName;break;}}}tmpResults.PostfixSolveList.push(this.getPosfixSolveListOperation(_tmpAbstractAssignToken,_tmpSolveLayerTokens3[0],this.getTokenContainerObject('0.0')));continue;}// For each precedence level in the layer
|
|
3549
3610
|
for(var _tmpPrecedence=0;_tmpPrecedence<=this.ExpressionParser.tokenMaxPrecedence;_tmpPrecedence++){// Enumerate all tokens in a layer's expression.
|
|
3550
3611
|
// There is a recursive way to do this, but given the short length of even the most complex equations we're favoring readability.
|
|
3551
3612
|
for(var _i27=0;_i27<_tmpSolveLayerTokens3.length;_i27++){// If the token is an operator and at the current precedence, add it to the postfix solve list and mutate the array.
|
|
@@ -3558,20 +3619,41 @@ var _tmpAbstractMultiplyToken=this.getTokenContainerObject('*');_tmpAbstractMult
|
|
|
3558
3619
|
else if(_i27==0&&_tmpToken4.Token=='+'){continue;}// The + after an operator or a parenthesis is also a number line orientation modifier ... THAT WE IGNORE
|
|
3559
3620
|
else if(_i27>0&&_tmpToken4.Token=='+'&&(_tmpSolveLayerTokens3[_i27-1].Type==='Token.Operator'||_tmpSolveLayerTokens3[_i27-1].Token==='(')){continue;}// Finally add the dang thing.
|
|
3560
3621
|
else{tmpResults.PostfixSolveList.push(this.getPosfixSolveListOperation(_tmpToken4,_tmpSolveLayerTokens3[_i27-1],_tmpSolveLayerTokens3[_i27+1],_tmpSolveLayerTokens3,_i27));}}else if(_tmpSolveLayerTokens3[_i27].Type==='Token.Function'&&_tmpPrecedence===0){var _tmpToken5=_tmpSolveLayerTokens3[_i27];tmpResults.PostfixSolveList.push(this.getPosfixSolveListOperation(_tmpToken5,_tmpSolveLayerTokens3[_i27+1],this.getTokenContainerObject('0.0')));}}}}// 7. Lastly set the assignment address.
|
|
3561
|
-
var
|
|
3622
|
+
var tmpAbstractAssignToken=this.getTokenContainerObject('=');// The address we are assigning to
|
|
3623
|
+
tmpAbstractAssignToken.VirtualSymbolName=tmpResults.PostfixedAssignmentAddress;// The address it's coming from
|
|
3624
|
+
var tmpSolveResultToken=this.getTokenContainerObject('Result','Token.LastResult');var tmpFinalAssignmentInstruction=this.getPosfixSolveListOperation(tmpAbstractAssignToken,tmpSolveResultToken,this.getTokenContainerObject('SolverMarshal','Token.SolverMarshal'));tmpResults.PostfixSolveList.push(tmpFinalAssignmentInstruction);return tmpResults.PostfixSolveList;}}]);return ExpressionParserPostfix;}(libExpressionParserOperationBase);module.exports=ExpressionParserPostfix;},{"./Fable-Service-ExpressionParser-Base.js":136}],142:[function(require,module,exports){var libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');var ExpressionParserSolver=/*#__PURE__*/function(_libExpressionParserO5){_inherits(ExpressionParserSolver,_libExpressionParserO5);function ExpressionParserSolver(pFable,pOptions,pServiceHash){var _this30;_classCallCheck2(this,ExpressionParserSolver);_this30=_callSuper(this,ExpressionParserSolver,[pFable,pOptions,pServiceHash]);_this30.serviceType='ExpressionParser-Solver';return _this30;}_createClass2(ExpressionParserSolver,[{key:"solvePostfixedExpression",value:function solvePostfixedExpression(pPostfixedExpression,pDataDestinationObject,pResultObject,pManifest){var tmpResults=_typeof(pResultObject)==='object'?pResultObject:{ExpressionParserLog:[]};var tmpManifest=_typeof(pManifest)==='object'?pManifest:this.fable.newManyfest();var tmpDataDestinationObject=_typeof(pDataDestinationObject)==='object'?pDataDestinationObject:{};// If there was a fable passed in (e.g. the results object was a service or such), we won't decorate
|
|
3562
3625
|
var tmpPassedInFable=('fable'in tmpResults);if(!tmpPassedInFable){tmpResults.fable=this.fable;}if(!Array.isArray(pPostfixedExpression)){tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.solvePostfixedExpression was passed a non-array postfixed expression.");this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return false;}if(pPostfixedExpression.length<1){tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.solvePostfixedExpression was passed an empty postfixed expression.");this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return false;}// This is how the user communication magic happens.
|
|
3563
|
-
tmpResults.VirtualSymbols={};for(var i=0;i<pPostfixedExpression.length;i++){if(pPostfixedExpression[i].Operation.Type==='Token.SolverInstruction'){continue;}var tmpStepResultObject={ExpressionStep:pPostfixedExpression[i],ExpressionStepIndex:i,ResultsObject:tmpResults,Manifest:tmpManifest}
|
|
3564
|
-
if(tmpStepResultObject.ExpressionStep.LeftValue.Type==='Token.VirtualSymbol'){tmpStepResultObject.ExpressionStep.LeftValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.LeftValue.Token);}if(tmpStepResultObject.ExpressionStep.RightValue.Type==='Token.VirtualSymbol'){tmpStepResultObject.ExpressionStep.RightValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.RightValue.Token);}// Resolve the parenthesis to their actual values
|
|
3626
|
+
tmpResults.VirtualSymbols={};for(var i=0;i<pPostfixedExpression.length;i++){if(pPostfixedExpression[i].Operation.Type==='Token.SolverInstruction'){continue;}var tmpStepResultObject={ExpressionStep:pPostfixedExpression[i],ExpressionStepIndex:i,ResultsObject:tmpResults,Manifest:tmpManifest};if(tmpStepResultObject.ExpressionStep.LeftValue.Type==='Token.LastResult'){tmpStepResultObject.ExpressionStep.LeftValue.Value=tmpResults.LastResult;}if(tmpStepResultObject.ExpressionStep.RightValue.Type==='Token.LastResult'){tmpStepResultObject.ExpressionStep.RightValue.Value=tmpResults.LastResult;}if(tmpStepResultObject.ExpressionStep.LeftValue.Type==='Token.VirtualSymbol'){tmpStepResultObject.ExpressionStep.LeftValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.LeftValue.Token);}if(tmpStepResultObject.ExpressionStep.RightValue.Type==='Token.VirtualSymbol'){tmpStepResultObject.ExpressionStep.RightValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.RightValue.Token);}// Resolve the parenthesis to their actual values
|
|
3565
3627
|
if(tmpStepResultObject.ExpressionStep.LeftValue.Type==='Token.Parenthesis'){tmpStepResultObject.ExpressionStep.LeftValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.LeftValue.VirtualSymbolName);}if(tmpStepResultObject.ExpressionStep.RightValue.Type==='Token.Parenthesis'){tmpStepResultObject.ExpressionStep.RightValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.RightValue.VirtualSymbolName);}// Virtual Constants
|
|
3566
3628
|
if(tmpStepResultObject.ExpressionStep.LeftValue.Type==='Token.Constant'&&!('Value'in tmpStepResultObject.ExpressionStep.LeftValue)){tmpStepResultObject.ExpressionStep.LeftValue.Value=tmpStepResultObject.ExpressionStep.LeftValue.Token;}if(tmpStepResultObject.ExpressionStep.RightValue.Type==='Token.Constant'&&!('Value'in tmpStepResultObject.ExpressionStep.RightValue)){tmpStepResultObject.ExpressionStep.RightValue.Value=tmpStepResultObject.ExpressionStep.RightValue.Token;}if(tmpStepResultObject.ExpressionStep.Operation.Type='Operator'){// TODO: This can be optimized. A lot. If necessary. Seems pretty fast honestly for even thousands of operations. Slowest part is arbitrary precision.
|
|
3567
3629
|
// An operator always has a left and right value.
|
|
3568
3630
|
var tmpFunctionAddress=false;if(tmpStepResultObject.ExpressionStep.Operation.Token in this.ExpressionParser.tokenMap){tmpFunctionAddress="ResultsObject.".concat(tmpStepResultObject.ExpressionStep.Operation.Descriptor.Function);}else if(tmpStepResultObject.ExpressionStep.Operation.Token.toLowerCase()in this.ExpressionParser.functionMap){tmpFunctionAddress="ResultsObject.".concat(this.ExpressionParser.functionMap[tmpStepResultObject.ExpressionStep.Operation.Token.toLowerCase()].Address);}try{//this.log.trace(`Solving Step ${i} [${tmpStepResultObject.ExpressionStep.VirtualSymbolName}] --> [${tmpStepResultObject.ExpressionStep.Operation.Token}]: ( ${tmpStepResultObject.ExpressionStep.LeftValue.Value} , ${tmpStepResultObject.ExpressionStep.RightValue.Value} )`);
|
|
3569
|
-
tmpResults.VirtualSymbols
|
|
3631
|
+
tmpManifest.setValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.VirtualSymbolName,tmpManifest.getValueAtAddress(tmpStepResultObject,"".concat(tmpFunctionAddress,"(ExpressionStep.LeftValue.Value,ExpressionStep.RightValue.Value)")));tmpResults.LastResult=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.VirtualSymbolName);//this.log.trace(` ---> Step ${i}: ${tmpResults.VirtualSymbols[tmpStepResultObject.ExpressionStep.VirtualSymbolName]}`)
|
|
3570
3632
|
}catch(pError){tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.solvePostfixedExpression failed to solve step ".concat(i," with function ").concat(tmpStepResultObject.ExpressionStep.Operation.Token,": ").concat(pError));this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return false;}// Equations don't always solve in virtual symbol order.
|
|
3571
|
-
tmpResults.SolverFinalVirtualSymbol=tmpStepResultObject.ExpressionStep.VirtualSymbolName;}}var tmpSolverResultValue=tmpManifest.getValueAtAddress(tmpResults,"VirtualSymbols.".concat(tmpResults.SolverFinalVirtualSymbol));// Now deal with final assignment
|
|
3572
|
-
for(var _i28=0;_i28<pPostfixedExpression.length;_i28++){if(pPostfixedExpression[_i28].
|
|
3573
|
-
if(!tmpPassedInFable){delete tmpResults.fable;}return tmpSolverResultValue.toString();}}]);return ExpressionParserSolver;}(libExpressionParserOperationBase);module.exports=ExpressionParserSolver;},{"./Fable-Service-ExpressionParser-Base.js":136}],
|
|
3574
|
-
|
|
3633
|
+
tmpResults.SolverFinalVirtualSymbol=tmpStepResultObject.ExpressionStep.VirtualSymbolName;}}var tmpSolverResultValue=tmpManifest.getValueAtAddress(tmpResults,"VirtualSymbols.".concat(tmpResults.SolverFinalVirtualSymbol));// Now deal with final assignment(s)
|
|
3634
|
+
for(var _i28=0;_i28<pPostfixedExpression.length;_i28++){if(pPostfixedExpression[_i28].RightValue.Type==='Token.SolverMarshal'){tmpManifest.setValueAtAddress(tmpResults.VirtualSymbols,pPostfixedExpression[_i28].VirtualSymbolName,tmpSolverResultValue);tmpManifest.setValueByHash(tmpDataDestinationObject,pPostfixedExpression[_i28].VirtualSymbolName,tmpSolverResultValue);}}tmpResults.RawResult=tmpSolverResultValue;// Clean up the fable reference if we added it to the object.
|
|
3635
|
+
if(!tmpPassedInFable){delete tmpResults.fable;}return tmpSolverResultValue.toString();}}]);return ExpressionParserSolver;}(libExpressionParserOperationBase);module.exports=ExpressionParserSolver;},{"./Fable-Service-ExpressionParser-Base.js":136}],143:[function(require,module,exports){module.exports={"=":{"Name":"Equals","Token":"=","Function":"fable.Math.assignValue","Precedence":0,"Type":"Assignment"},"(":{"Name":"Left Parenthesis","Token":"(","Precedence":0,"Type":"Parenthesis"},")":{"Name":"Right Parenthesis","Token":")","Precedence":0,"Type":"Parenthesis"},"*":{"Name":"Multiply","Token":"*","Function":"fable.Math.multiplyPrecise","Precedence":3,"Type":"Operator"},"/":{"Name":"Divide","Token":"/","Function":"fable.Math.dividePrecise","Precedence":3,"Type":"Operator"},"^":{"Name":"Exponent","Token":"^","Function":"fable.Math.powerPrecise","Precedence":1,"Type":"Operator"},"%":{"Name":"Modulus","Token":"%","Function":"fable.Math.modPrecise","Precedence":3,"Type":"Operator"},"+":{"Name":"Add","Token":"+","Function":"fable.Math.addPrecise","Precedence":4,"Type":"Operator"},"-":{"Name":"Subtract","Token":"-","Function":"fable.Math.subtractPrecise","Precedence":4,"Type":"Operator"}};},{}],144:[function(require,module,exports){var libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');var ExpressionParserValueMarshal=/*#__PURE__*/function(_libExpressionParserO6){_inherits(ExpressionParserValueMarshal,_libExpressionParserO6);function ExpressionParserValueMarshal(pFable,pOptions,pServiceHash){var _this31;_classCallCheck2(this,ExpressionParserValueMarshal);_this31=_callSuper(this,ExpressionParserValueMarshal,[pFable,pOptions,pServiceHash]);_this31.serviceType='ExpressionParser-ValueMarshal';return _this31;}/**
|
|
3636
|
+
* Substitutes values in tokenized objects based on the provided data source and manifest.
|
|
3637
|
+
*
|
|
3638
|
+
* TODO: Move this to its own file in the "Fable-Service-ExpressionParser" directory.
|
|
3639
|
+
*
|
|
3640
|
+
* @param {Array} pTokenizedObjects - The array of tokenized objects.
|
|
3641
|
+
* @param {Object} pDataSource - The data source object where we pull values from.
|
|
3642
|
+
* @param {Object} pResultObject - The result object where the algorithm shows its work.
|
|
3643
|
+
* @param {Object} pManifest - The manifest object to use for hash resolution.
|
|
3644
|
+
* @returns {Array} - The modified tokenized objects array.
|
|
3645
|
+
*/_createClass2(ExpressionParserValueMarshal,[{key:"substituteValuesInTokenizedObjects",value:function substituteValuesInTokenizedObjects(pTokenizedObjects,pDataSource,pResultObject,pManifest){var tmpResults=_typeof(pResultObject)==='object'?pResultObject:{ExpressionParserLog:[]};if(!Array.isArray(pTokenizedObjects)){tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.substituteValuesInTokenizedObjects was passed a non-array tokenized object list.");this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return pTokenizedObjects;}if(_typeof(pDataSource)!=='object'){tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.substituteValuesInTokenizedObjects either was passed no data source, or was passed a non-object data source.");this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return pTokenizedObjects;}var tmpDataSource=pDataSource;var tmpManifest=_typeof(pManifest)=='object'?pManifest:this.fable.newManyfest(pManifest);for(var i=0;i<pTokenizedObjects.length;i++){if(_typeof(pTokenizedObjects[i])!=='object'){tmpResults.ExpressionParserLog.push("WARNING: ExpressionParser.substituteValuesInTokenizedObjects found a non-object tokenized object at index ".concat(i));this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);continue;}var tmpToken=pTokenizedObjects[i];if(pTokenizedObjects[i].Type==='Token.Symbol'&&!tmpToken.Resolved){// Symbols always look up values by hash first
|
|
3646
|
+
var tmpValue=tmpManifest.getValueByHash(tmpDataSource,tmpToken.Token);// if (!tmpValue)
|
|
3647
|
+
// {
|
|
3648
|
+
// // If no hash resolves, try by address.
|
|
3649
|
+
// tmpValue = tmpManifest.getValueAtAddress(tmpToken.Token, tmpDataSource);
|
|
3650
|
+
// }
|
|
3651
|
+
if(!tmpValue){tmpResults.ExpressionParserLog.push("WARNING: ExpressionParser.substituteValuesInTokenizedObjects found no value for the symbol hash or address ".concat(tmpToken.Token," at index ").concat(i));this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);continue;}else{tmpResults.ExpressionParserLog.push("INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [".concat(tmpValue,"] for the state address ").concat(tmpToken.Token," at index ").concat(i));if(this.LogNoisiness>1)this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);try{var tmpValueParsed=new this.fable.Utility.bigNumber(tmpValue);tmpToken.Resolved=true;tmpToken.Value=tmpValueParsed.toString();}catch(pError){// TODO: Should we allow this to be a function? Good god the complexity and beauty of that...
|
|
3652
|
+
if(Array.isArray(tmpValue)||_typeof(tmpValue)==='object'){tmpToken.Resolved=true;tmpToken.Value=tmpValue;}else{tmpResults.ExpressionParserLog.push("INFO: ExpressionParser.substituteValuesInTokenizedObjects found a non-numeric, non-set value for the state address ".concat(tmpToken.Token," at index ").concat(i));this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);tmpToken.Resolved=false;}}}}if(pTokenizedObjects[i].Type==='Token.StateAddress'&&!tmpToken.Resolved){// Symbols are always hashes. This gracefully works for simple shallow objects because hashes default to the address in Manyfest.
|
|
3653
|
+
var _tmpValue3=tmpManifest.getValueAtAddress(tmpDataSource,tmpToken.Token);if(!_tmpValue3){tmpResults.ExpressionParserLog.push("WARNING: ExpressionParser.substituteValuesInTokenizedObjects found no value for the state address ".concat(tmpToken.Token," at index ").concat(i));this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);continue;}else{//tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [${tmpValue}] for the state address ${tmpToken.Token} at index ${i}`);
|
|
3654
|
+
this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);try{var _tmpValueParsed=new this.fable.Utility.bigNumber(_tmpValue3);tmpToken.Resolved=true;tmpToken.Value=_tmpValueParsed.toString();}catch(pError){tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.substituteValuesInTokenizedObjects found a non-numeric value for the state address ".concat(tmpToken.Token," at index ").concat(i));this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);tmpToken.Resolved=false;}}}if(pTokenizedObjects[i].Type==='Token.Constant'&&!tmpToken.Resolved){tmpResults.ExpressionParserLog.push("INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [".concat(tmpToken.Token,"] for the constant ").concat(tmpToken.Token," at index ").concat(i));if(this.LogNoisiness>1)this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);try{var _tmpValueParsed2=new this.fable.Utility.bigNumber(tmpToken.Token);tmpToken.Resolved=true;tmpToken.Value=_tmpValueParsed2.toString();}catch(pError){// This constant has the right symbols but apparently isn't a parsable number.
|
|
3655
|
+
tmpResults.ExpressionParserLog.push("ERROR: ExpressionParser.substituteValuesInTokenizedObjects found a non-numeric value for the state address ".concat(tmpToken.Token," at index ").concat(i));this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);tmpToken.Resolved=false;}}}return pTokenizedObjects;}}]);return ExpressionParserValueMarshal;}(libExpressionParserOperationBase);module.exports=ExpressionParserValueMarshal;},{"./Fable-Service-ExpressionParser-Base.js":136}],145:[function(require,module,exports){(function(process){(function(){var libFableServiceBase=require('fable-serviceproviderbase');var libFS=require('fs');var libPath=require('path');var libReadline=require('readline');var FableServiceFilePersistence=/*#__PURE__*/function(_libFableServiceBase5){_inherits(FableServiceFilePersistence,_libFableServiceBase5);function FableServiceFilePersistence(pFable,pOptions,pServiceHash){var _this32;_classCallCheck2(this,FableServiceFilePersistence);_this32=_callSuper(this,FableServiceFilePersistence,[pFable,pOptions,pServiceHash]);_this32.serviceType='FilePersistence';if(!('Mode'in _this32.options)){_this32.options.Mode=parseInt('0777',8)&~process.umask();}_this32.libFS=libFS;_this32.libPath=libPath;_this32.libReadline=libReadline;return _this32;}_createClass2(FableServiceFilePersistence,[{key:"joinPath",value:function joinPath(){return libPath.resolve.apply(libPath,arguments);}},{key:"existsSync",value:function existsSync(pPath){return libFS.existsSync(pPath);}},{key:"exists",value:function exists(pPath,fCallback){var tmpFileExists=this.existsSync(pPath);;return fCallback(null,tmpFileExists);}},{key:"appendFileSync",value:function appendFileSync(pFileName,pAppendContent,pOptions){var tmpOptions=typeof pOptions==='undefined'?'utf8':pOptions;return libFS.appendFileSync(pFileName,pAppendContent,tmpOptions);}},{key:"deleteFileSync",value:function deleteFileSync(pFileName){return libFS.unlinkSync(pFileName);}},{key:"deleteFolderSync",value:function deleteFolderSync(pFileName){return libFS.rmdirSync(pFileName);}},{key:"readFileSync",value:function readFileSync(pFilePath,pOptions){var tmpOptions=typeof pOptions==='undefined'?'utf8':pOptions;return libFS.readFileSync(pFilePath,tmpOptions);}},{key:"readFile",value:function readFile(pFilePath,pOptions,fCallback){var tmpOptions=typeof pOptions==='undefined'?'utf8':pOptions;return libFS.readFile(pFilePath,tmpOptions,fCallback);}},{key:"writeFileSync",value:function writeFileSync(pFileName,pFileContent,pOptions){var tmpOptions=typeof pOptions==='undefined'?'utf8':pOptions;return libFS.writeFileSync(pFileName,pFileContent,tmpOptions);}},{key:"writeFileSyncFromObject",value:function writeFileSyncFromObject(pFileName,pObject){return this.writeFileSync(pFileName,JSON.stringify(pObject,null,4));}},{key:"writeFileSyncFromArray",value:function writeFileSyncFromArray(pFileName,pFileArray){if(!Array.isArray(pFileArray)){this.log.error("File Persistence Service attempted to write ".concat(pFileName," from array but the expected array was not an array (it was a ").concat(_typeof(pFileArray),")."));return Error('Attempted to write ${pFileName} from array but the expected array was not an array (it was a ${typeof(pFileArray)}).');}else{for(var i=0;i<pFileArray.length;i++){return this.appendFileSync(pFileName,"".concat(pFileArray[i],"\n"));}}}},{key:"writeFile",value:function writeFile(pFileName,pFileContent,pOptions,fCallback){var tmpOptions=typeof pOptions==='undefined'?'utf8':pOptions;return libFS.writeFile(pFileName,pFileContent,tmpOptions,fCallback);}},{key:"lineReaderFactory",value:function lineReaderFactory(pFilePath,fOnLine,fOnComplete,fOnError){var tmpLineReader={};if(typeof pFilePath!='string'){return false;}tmpLineReader.filePath=pFilePath;tmpLineReader.fileStream=libFS.createReadStream(tmpLineReader.filePath);tmpLineReader.reader=libReadline.createInterface({input:tmpLineReader.fileStream,crlfDelay:Infinity});if(typeof fOnError==='function'){tmpLineReader.reader.on('error',fOnError);}tmpLineReader.reader.on('line',typeof fOnLine==='function'?fOnLine:function(){});if(typeof fOnComplete==='function'){tmpLineReader.reader.on('close',fOnComplete);}return tmpLineReader;}// Folder management
|
|
3656
|
+
},{key:"makeFolderRecursive",value:function makeFolderRecursive(pParameters,fCallback){var _this33=this;var tmpParameters=pParameters;if(typeof pParameters=='string'){tmpParameters={Path:pParameters};}else if(_typeof(pParameters)!=='object'){fCallback(new Error('Parameters object or string not properly passed to recursive folder create.'));return false;}if(typeof tmpParameters.Path!=='string'){fCallback(new Error('Parameters object needs a path to run the folder create operation.'));return false;}if(!('Mode'in tmpParameters)){tmpParameters.Mode=this.options.Mode;}// Check if we are just starting .. if so, build the initial state for our recursive function
|
|
3575
3657
|
if(typeof tmpParameters.CurrentPathIndex==='undefined'){// Build the tools to start recursing
|
|
3576
3658
|
tmpParameters.ActualPath=libPath.normalize(tmpParameters.Path);tmpParameters.ActualPathParts=tmpParameters.ActualPath.split(libPath.sep);tmpParameters.CurrentPathIndex=0;tmpParameters.CurrentPath='';}else{// This is not our first run, so we will continue the recursion.
|
|
3577
3659
|
// Build the new base path
|
|
@@ -3579,8 +3661,8 @@ if(tmpParameters.CurrentPath==libPath.sep){tmpParameters.CurrentPath=tmpParamete
|
|
|
3579
3661
|
tmpParameters.CurrentPathIndex++;}// Check if the path is fully complete
|
|
3580
3662
|
if(tmpParameters.CurrentPathIndex>=tmpParameters.ActualPathParts.length){return fCallback(null);}// Check if the path exists (and is a folder)
|
|
3581
3663
|
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.
|
|
3582
|
-
return
|
|
3583
|
-
return
|
|
3664
|
+
return _this33.makeFolderRecursive(tmpParameters,fCallback);}else if(pCreateError.code=='EEXIST'){// The folder exists -- our dev might be running this in parallel/async/whatnot.
|
|
3665
|
+
return _this33.makeFolderRecursive(tmpParameters,fCallback);}else{console.log(pCreateError.code);return fCallback(pCreateError);}});}else{return _this33.makeFolderRecursive(tmpParameters,fCallback);}});}}]);return FableServiceFilePersistence;}(libFableServiceBase);module.exports=FableServiceFilePersistence;}).call(this);}).call(this,require('_process'));},{"_process":87,"fable-serviceproviderbase":51,"fs":19,"path":83,"readline":19}],146:[function(require,module,exports){/**
|
|
3584
3666
|
* @file Fable-Service-Math.js
|
|
3585
3667
|
* @description This file contains the implementation of the FableServiceMath class, which provides simple functions for performing arbitrary precision math operations.
|
|
3586
3668
|
* @module FableServiceMath
|
|
@@ -3591,7 +3673,7 @@ return _this31.makeFolderRecursive(tmpParameters,fCallback);}else{console.log(pC
|
|
|
3591
3673
|
* @description Simple functions that perform arbitrary precision math operations and return string resultant values. Wraps big.js
|
|
3592
3674
|
* @class FableServiceMath
|
|
3593
3675
|
* @extends libFableServiceBase
|
|
3594
|
-
*/var FableServiceMath=/*#__PURE__*/function(_libFableServiceBase6){_inherits(FableServiceMath,_libFableServiceBase6);function FableServiceMath(pFable,pOptions,pServiceHash){var
|
|
3676
|
+
*/var FableServiceMath=/*#__PURE__*/function(_libFableServiceBase6){_inherits(FableServiceMath,_libFableServiceBase6);function FableServiceMath(pFable,pOptions,pServiceHash){var _this34;_classCallCheck2(this,FableServiceMath);_this34=_callSuper(this,FableServiceMath,[pFable,pOptions,pServiceHash]);_this34.serviceType='Math';_this34.pi='3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679';return _this34;}/*
|
|
3595
3677
|
Pass-through Rounding Method Constants
|
|
3596
3678
|
|
|
3597
3679
|
Property Value BigDecimal Equiv Description
|
|
@@ -3751,7 +3833,7 @@ return 1;}return 0;}/**
|
|
|
3751
3833
|
*
|
|
3752
3834
|
* @param {Array|Object} pValueSet - The value set to be sorted.
|
|
3753
3835
|
* @returns {Array} - The sorted value set.
|
|
3754
|
-
*/},{key:"sortSetPrecise",value:function sortSetPrecise(pValueSet){var
|
|
3836
|
+
*/},{key:"sortSetPrecise",value:function sortSetPrecise(pValueSet){var _this35=this;var tmpSortedSet=[];if(Array.isArray(pValueSet)){for(var i=0;i<pValueSet.length;i++){tmpSortedSet.push(this.parsePrecise(pValueSet[i],NaN));}}else if(_typeof(pValueSet)==='object'){var tmpKeys=Object.keys(pValueSet);for(var _i29=0;_i29<tmpKeys.length;_i29++){tmpSortedSet.push(this.parsePrecise(pValueSet[tmpKeys[_i29]],NaN));}}tmpSortedSet.sort(function(pLeft,pRight){return _this35.comparePrecise(pLeft,pRight);});return tmpSortedSet;}/**
|
|
3755
3837
|
* Bucketizes a set of values based on a specified bucket size.
|
|
3756
3838
|
*
|
|
3757
3839
|
* @param {Array|Object} pValueSet - The set of values to be bucketized.
|
|
@@ -3806,11 +3888,11 @@ else{var tmpLeftMiddleValue=tmpSortedValueSet[tmpMiddleElement-1];var tmpRightMi
|
|
|
3806
3888
|
* @param {Array} pValueSet - The array of values to calculate the mode from.
|
|
3807
3889
|
* @returns {Array} - An array containing the mode value(s) from the given value set.
|
|
3808
3890
|
*/},{key:"modePrecise",value:function modePrecise(pValueSet){var tmpHistogram=this.bucketSetPrecise(pValueSet);var tmpMaxCount=0;// Philosophical question about whether the values should be returned sorted.
|
|
3809
|
-
var tmpHistogramValueSet=Object.keys(tmpHistogram);var tmpModeValueSet=[];for(var i=0;i<tmpHistogramValueSet.length;i++){if(tmpHistogram[tmpHistogramValueSet[i]]>tmpMaxCount){tmpMaxCount=tmpHistogram[tmpHistogramValueSet[i]];tmpModeValueSet=[tmpHistogramValueSet[i]];}else if(tmpHistogram[tmpHistogramValueSet[i]]==tmpMaxCount){tmpModeValueSet.push(tmpHistogramValueSet[i]);}}return tmpModeValueSet;}}]);return FableServiceMath;}(libFableServiceBase);module.exports=FableServiceMath;},{"fable-serviceproviderbase":51}],
|
|
3891
|
+
var tmpHistogramValueSet=Object.keys(tmpHistogram);var tmpModeValueSet=[];for(var i=0;i<tmpHistogramValueSet.length;i++){if(tmpHistogram[tmpHistogramValueSet[i]]>tmpMaxCount){tmpMaxCount=tmpHistogram[tmpHistogramValueSet[i]];tmpModeValueSet=[tmpHistogramValueSet[i]];}else if(tmpHistogram[tmpHistogramValueSet[i]]==tmpMaxCount){tmpModeValueSet.push(tmpHistogramValueSet[i]);}}return tmpModeValueSet;}}]);return FableServiceMath;}(libFableServiceBase);module.exports=FableServiceMath;},{"fable-serviceproviderbase":51}],147:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');/**
|
|
3810
3892
|
* Precedent Meta-Templating
|
|
3811
3893
|
* @author Steven Velozo <steven@velozo.com>
|
|
3812
3894
|
* @description Process text stream trie and postfix tree, parsing out meta-template expression functions.
|
|
3813
|
-
*/var libWordTree=require("./Fable-Service-MetaTemplate/MetaTemplate-WordTree.js");var libStringParser=require("./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js");var FableServiceMetaTemplate=/*#__PURE__*/function(_libFableServiceBase7){_inherits(FableServiceMetaTemplate,_libFableServiceBase7);function FableServiceMetaTemplate(pFable,pOptions,pServiceHash){var
|
|
3895
|
+
*/var libWordTree=require("./Fable-Service-MetaTemplate/MetaTemplate-WordTree.js");var libStringParser=require("./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js");var FableServiceMetaTemplate=/*#__PURE__*/function(_libFableServiceBase7){_inherits(FableServiceMetaTemplate,_libFableServiceBase7);function FableServiceMetaTemplate(pFable,pOptions,pServiceHash){var _this36;_classCallCheck2(this,FableServiceMetaTemplate);_this36=_callSuper(this,FableServiceMetaTemplate,[pFable,pOptions,pServiceHash]);_this36.serviceType='MetaTemplate';_this36.WordTree=new libWordTree();_this36.StringParser=new libStringParser(_this36.fable);_this36.ParseTree=_this36.WordTree.ParseTree;return _this36;}_createClass2(FableServiceMetaTemplate,[{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,pParser,pParserContext){return this.WordTree.addPattern(pPatternStart,pPatternEnd,pParser,pParserContext);}},{key:"addPatternBoth",value:function addPatternBoth(pPatternStart,pPatternEnd,pParser,pParserPromise,pParserContext){return this.WordTree.addPatternBoth(pPatternStart,pPatternEnd,pParser,pParserPromise,pParserContext);}/**
|
|
3814
3896
|
* Parse a string with the existing parse tree
|
|
3815
3897
|
* @method parseString
|
|
3816
3898
|
* @param {string} pString - The string to parse
|
|
@@ -3818,7 +3900,7 @@ var tmpHistogramValueSet=Object.keys(tmpHistogram);var tmpModeValueSet=[];for(va
|
|
|
3818
3900
|
* @param {function} fCallback - The callback function to call when a pattern is matched
|
|
3819
3901
|
* @param {array} pDataContext - The history of data objects already passed in
|
|
3820
3902
|
* @return {string} The result from the parser
|
|
3821
|
-
*/},{key:"parseString",value:function parseString(pString,pData,fCallback,pDataContext){if(this.LogNoisiness>4){this.fable.log.trace("Metatemplate parsing template string [".concat(pString,"] where the callback is a ").concat(_typeof(fCallback)),{TemplateData:pData});}return this.StringParser.parseString(pString,this.ParseTree,pData,fCallback,pDataContext);}}]);return FableServiceMetaTemplate;}(libFableServiceBase);module.exports=FableServiceMetaTemplate;},{"./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js":
|
|
3903
|
+
*/},{key:"parseString",value:function parseString(pString,pData,fCallback,pDataContext){if(this.LogNoisiness>4){this.fable.log.trace("Metatemplate parsing template string [".concat(pString,"] where the callback is a ").concat(_typeof(fCallback)),{TemplateData:pData});}return this.StringParser.parseString(pString,this.ParseTree,pData,fCallback,pDataContext);}}]);return FableServiceMetaTemplate;}(libFableServiceBase);module.exports=FableServiceMetaTemplate;},{"./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js":148,"./Fable-Service-MetaTemplate/MetaTemplate-WordTree.js":149,"fable-serviceproviderbase":51}],148:[function(require,module,exports){/**
|
|
3822
3904
|
* String Parser
|
|
3823
3905
|
* @author Steven Velozo <steven@velozo.com>
|
|
3824
3906
|
* @description Parse a string, properly processing each matched token in the word tree.
|
|
@@ -3865,10 +3947,10 @@ var _tmpFunctionContext='ParserContext'in pParserState.Pattern?pParserState.Patt
|
|
|
3865
3947
|
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)....
|
|
3866
3948
|
if(!pParserState.PatternMatch){// This may be the start of a new pattern....
|
|
3867
3949
|
if(pCharacter in pParserState.ParseTree){// ... assign the root node as the matched node.
|
|
3868
|
-
this.resetOutputBuffer(pParserState);this.appendOutputBuffer(pCharacter,pParserState);pParserState.Pattern=pParserState.ParseTree[pCharacter];pParserState.PatternMatch=true;return true;}else{this.appendOutputBuffer(pCharacter,pParserState);}}return false;}},{key:"executePatternAsync",value:function executePatternAsync(pParserState,pData,fCallback,pDataContext){var
|
|
3950
|
+
this.resetOutputBuffer(pParserState);this.appendOutputBuffer(pCharacter,pParserState);pParserState.Pattern=pParserState.ParseTree[pCharacter];pParserState.PatternMatch=true;return true;}else{this.appendOutputBuffer(pCharacter,pParserState);}}return false;}},{key:"executePatternAsync",value:function executePatternAsync(pParserState,pData,fCallback,pDataContext){var _this37=this;// ... this is the end of a pattern, cut off the end tag and parse it.
|
|
3869
3951
|
// Trim the start and end tags off the output buffer now
|
|
3870
3952
|
if(pParserState.Pattern.isAsync){// Run the function
|
|
3871
|
-
var tmpFunctionContext='ParserContext'in pParserState.Pattern?pParserState.Pattern.ParserContext:false;if(tmpFunctionContext){return pParserState.Pattern.ParseAsync.call(tmpFunctionContext,pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,function(pError,pAsyncOutput){if(pError){
|
|
3953
|
+
var tmpFunctionContext='ParserContext'in pParserState.Pattern?pParserState.Pattern.ParserContext:false;if(tmpFunctionContext){return pParserState.Pattern.ParseAsync.call(tmpFunctionContext,pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,function(pError,pAsyncOutput){if(pError){_this37.fable.log.info("Precedent ERROR: Async template error happened parsing ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd,": ").concat(pError));}pParserState.OutputBuffer=pAsyncOutput;_this37.resetOutputBuffer(pParserState);return fCallback();},pDataContext);}else{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){_this37.fable.log.info("Precedent ERROR: Async template error happened parsing ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd,": ").concat(pError));}pParserState.OutputBuffer=pAsyncOutput;_this37.resetOutputBuffer(pParserState);return fCallback();},pDataContext);}}else{// Run the t*mplate function
|
|
3872
3954
|
var _tmpFunctionContext2='ParserContext'in pParserState.Pattern?pParserState.Pattern.ParserContext:false;if(_tmpFunctionContext2){pParserState.OutputBuffer=pParserState.Pattern.Parse.call(_tmpFunctionContext2,pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,pDataContext);}else{pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,pDataContext);}this.resetOutputBuffer(pParserState);return fCallback();}}/**
|
|
3873
3955
|
* Parse a character in the buffer.
|
|
3874
3956
|
* @method parseCharacterAsync
|
|
@@ -3901,11 +3983,11 @@ return fCallback();}/**
|
|
|
3901
3983
|
* @param {Object} pData - The data to pass to the function as a second parameter
|
|
3902
3984
|
* @param {function} fCallback - The callback function to call when the parse is complete
|
|
3903
3985
|
* @param {array} pDataContext - The history of data objects/context already passed in
|
|
3904
|
-
*/},{key:"parseString",value:function parseString(pString,pParseTree,pData,fCallback,pDataContext){var
|
|
3986
|
+
*/},{key:"parseString",value:function parseString(pString,pParseTree,pData,fCallback,pDataContext){var _this38=this;// TODO: There is danger here if a template function attempts to functionally recurse and doesn't pass this in.
|
|
3905
3987
|
var tmpPreviousDataContext=Array.isArray(pDataContext)?pDataContext:[];var tmpDataContext=Array.from(tmpPreviousDataContext);tmpDataContext.push(pData);if(typeof fCallback!=='function'){var tmpParserState=this.newParserState(pParseTree);for(var i=0;i<pString.length;i++){// TODO: This is not fast.
|
|
3906
3988
|
this.parseCharacter(pString[i],tmpParserState,pData,tmpDataContext);}this.flushOutputBuffer(tmpParserState);return tmpParserState.Output;}else{// This is the async mode
|
|
3907
|
-
var _tmpParserState=this.newParserState(pParseTree);_tmpParserState.Asynchronous=true;var tmpAnticipate=this.fable.instantiateServiceProviderWithoutRegistration('Anticipate');var _loop=function _loop(_i34){tmpAnticipate.anticipate(function(fCallback){
|
|
3908
|
-
|
|
3989
|
+
var _tmpParserState=this.newParserState(pParseTree);_tmpParserState.Asynchronous=true;var tmpAnticipate=this.fable.instantiateServiceProviderWithoutRegistration('Anticipate');var _loop=function _loop(_i34){tmpAnticipate.anticipate(function(fCallback){_this38.parseCharacterAsync(pString[_i34],_tmpParserState,pData,fCallback,tmpDataContext);});};for(var _i34=0;_i34<pString.length;_i34++){_loop(_i34);}tmpAnticipate.wait(function(pError){// Flush the remaining data
|
|
3990
|
+
_this38.flushOutputBuffer(_tmpParserState);return fCallback(pError,_tmpParserState.Output);});}}}]);return StringParser;}();module.exports=StringParser;},{}],149:[function(require,module,exports){/**
|
|
3909
3991
|
* Word Tree
|
|
3910
3992
|
* @author Steven Velozo <steven@velozo.com>
|
|
3911
3993
|
* @description Create a tree (directed graph) of Javascript objects, one character per object.
|
|
@@ -3941,13 +4023,13 @@ if(pParserContext){tmpLeaf.ParserContext=pParserContext;}tmpLeaf.isAsync=true;re
|
|
|
3941
4023
|
* @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
|
|
3942
4024
|
* @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.
|
|
3943
4025
|
* @param {Object} pParserContext - The context to pass to the parser function
|
|
3944
|
-
*/},{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,fParser,pParserContext){return this.addPatternBoth(pPatternStart,pPatternEnd,fParser,null,pParserContext);}}]);return WordTree;}();module.exports=WordTree;},{}],
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
if(this.state.OverallProgressTracker.StartTimeStamp>0){return fExecutionCompleteCallback(new Error("Operation [".concat(this.state.Metadata.UUID,"] ").concat(this.state.Metadata.Name," has already been executed!")));}var tmpAnticipate=this.fable.instantiateServiceProviderWithoutRegistration('Anticipate');this.progressTrackerSet.setProgressTrackerTotalOperations(this.state.OverallProgressTracker.Hash,this.state.Status.StepCount);this.progressTrackerSet.startProgressTracker(this.state.OverallProgressTracker.Hash);this.info("Operation [".concat(this.state.Metadata.UUID,"] ").concat(this.state.Metadata.Name," starting..."));var _loop2=function _loop2(i){tmpAnticipate.anticipate(function(fNext){this.fable.log.info("Step #".concat(i," [").concat(this.state.Steps[i].GUIDStep,"] ").concat(this.state.Steps[i].Name," starting..."));this.progressTrackerSet.startProgressTracker(this.state.Steps[i].ProgressTracker.Hash);return fNext();}.bind(
|
|
3949
|
-
tmpAnticipate.anticipate(
|
|
3950
|
-
tmpAnticipate.wait(function(pError){if(pError){
|
|
4026
|
+
*/},{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,fParser,pParserContext){return this.addPatternBoth(pPatternStart,pPatternEnd,fParser,null,pParserContext);}}]);return WordTree;}();module.exports=WordTree;},{}],150:[function(require,module,exports){module.exports={"Metadata":{"UUID":false,"Hash":false,"Name":"","Summary":"","Version":0},"Status":{"Completed":false,"StepCount":0},"Steps":[],"Errors":[],"Log":[]};},{}],151:[function(require,module,exports){var _require5=require('big.js'),PE=_require5.PE;var libFableServiceBase=require('fable-serviceproviderbase');var _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));var FableOperation=/*#__PURE__*/function(_libFableServiceBase8){_inherits(FableOperation,_libFableServiceBase8);function FableOperation(pFable,pOptions,pServiceHash){var _this39;_classCallCheck2(this,FableOperation);_this39=_callSuper(this,FableOperation,[pFable,pOptions,pServiceHash]);// Timestamps will just be the long ints
|
|
4027
|
+
_this39.timeStamps={};_this39.serviceType='PhasedOperation';_this39.state=JSON.parse(_OperationStatePrototypeString);_this39.stepMap={};_this39.stepFunctions={};// Match the service instantiation to the operation.
|
|
4028
|
+
_this39.state.Metadata.Hash=_this39.Hash;_this39.state.Metadata.UUID=_this39.UUID;_this39.state.Metadata.Name=typeof _this39.options.Name=='string'?_this39.options.Name:"Unnamed Operation ".concat(_this39.state.Metadata.UUID);_this39.name=_this39.state.Metadata.Name;_this39.progressTrackerSet=_this39.fable.instantiateServiceProviderWithoutRegistration('ProgressTrackerSet');_this39.state.OverallProgressTracker=_this39.progressTrackerSet.createProgressTracker("Overall-".concat(_this39.state.Metadata.UUID));// This is here to use the pass-through logging functions in the operation itself.
|
|
4029
|
+
_this39.log=_assertThisInitialized(_this39);return _this39;}_createClass2(FableOperation,[{key:"execute",value:function execute(fExecutionCompleteCallback){var _this40=this;// TODO: Should the same operation be allowed to execute more than one time?
|
|
4030
|
+
if(this.state.OverallProgressTracker.StartTimeStamp>0){return fExecutionCompleteCallback(new Error("Operation [".concat(this.state.Metadata.UUID,"] ").concat(this.state.Metadata.Name," has already been executed!")));}var tmpAnticipate=this.fable.instantiateServiceProviderWithoutRegistration('Anticipate');this.progressTrackerSet.setProgressTrackerTotalOperations(this.state.OverallProgressTracker.Hash,this.state.Status.StepCount);this.progressTrackerSet.startProgressTracker(this.state.OverallProgressTracker.Hash);this.info("Operation [".concat(this.state.Metadata.UUID,"] ").concat(this.state.Metadata.Name," starting..."));var _loop2=function _loop2(i){tmpAnticipate.anticipate(function(fNext){this.fable.log.info("Step #".concat(i," [").concat(this.state.Steps[i].GUIDStep,"] ").concat(this.state.Steps[i].Name," starting..."));this.progressTrackerSet.startProgressTracker(this.state.Steps[i].ProgressTracker.Hash);return fNext();}.bind(_this40));// Steps are executed in a custom context with
|
|
4031
|
+
tmpAnticipate.anticipate(_this40.stepFunctions[_this40.state.Steps[i].GUIDStep].bind({log:_this40,fable:_this40.fable,options:_this40.state.Steps[i].Metadata,metadata:_this40.state.Steps[i].Metadata,ProgressTracker:_this40.progressTrackerSet.getProgressTracker(_this40.state.Steps[i].ProgressTracker.Hash),logProgressTrackerStatus:function(){return this.log.info("Step #".concat(i," [").concat(this.state.Steps[i].GUIDStep,"]: ").concat(this.progressTrackerSet.getProgressTrackerStatusString(this.state.Steps[i].ProgressTracker.Hash)));}.bind(_this40),OperationState:_this40.state,StepState:_this40.state.Steps[i]}));tmpAnticipate.anticipate(function(fNext){this.progressTrackerSet.endProgressTracker(this.state.Steps[i].ProgressTracker.Hash);var tmpStepTimingMessage=this.progressTrackerSet.getProgressTrackerStatusString(this.state.Steps[i].ProgressTracker.Hash);this.fable.log.info("Step #".concat(i," [").concat(this.state.Steps[i].GUIDStep,"] ").concat(this.state.Steps[i].Name," complete."));this.fable.log.info("Step #".concat(i," [").concat(this.state.Steps[i].GUIDStep,"] ").concat(this.state.Steps[i].Name," ").concat(tmpStepTimingMessage,"."));this.progressTrackerSet.incrementProgressTracker(this.state.OverallProgressTracker.Hash,1);var tmpOperationTimingMessage=this.progressTrackerSet.getProgressTrackerStatusString(this.state.OverallProgressTracker.Hash);this.fable.log.info("Operation [".concat(this.state.Metadata.UUID,"] ").concat(tmpOperationTimingMessage,"."));return fNext();}.bind(_this40));};for(var i=0;i<this.state.Steps.length;i++){_loop2(i);}// Wait for the anticipation to complete
|
|
4032
|
+
tmpAnticipate.wait(function(pError){if(pError){_this40.fable.log.error("Operation [".concat(_this40.state.Metadata.UUID,"] ").concat(_this40.state.Metadata.Name," had an error: ").concat(pError),pError);return fExecutionCompleteCallback(pError);}_this40.info("Operation [".concat(_this40.state.Metadata.UUID,"] ").concat(_this40.state.Metadata.Name," complete."));var tmpOperationTimingMessage=_this40.progressTrackerSet.getProgressTrackerStatusString(_this40.state.OverallProgressTracker.Hash);_this40.progressTrackerSet.endProgressTracker(_this40.state.OverallProgressTracker.Hash);_this40.fable.log.info("Operation [".concat(_this40.state.Metadata.UUID,"] ").concat(tmpOperationTimingMessage,"."));return fExecutionCompleteCallback();});}// There are three ways to add steps:
|
|
3951
4033
|
// 1. As a basic javascript function
|
|
3952
4034
|
// --
|
|
3953
4035
|
// This is the most basic, java"script" way to add a step. It will
|
|
@@ -3956,11 +4038,11 @@ tmpAnticipate.wait(function(pError){if(pError){_this38.fable.log.error("Operatio
|
|
|
3956
4038
|
},{key:"addStep",value:function addStep(fStepFunction,pStepMetadata,pStepName,pStepDescription,pGUIDStep){var tmpStep={};// GUID is optional
|
|
3957
4039
|
tmpStep.GUIDStep=typeof pGUIDStep!=='undefined'?pGUIDStep:"STEP-".concat(this.state.Steps.length,"-").concat(this.fable.DataGeneration.randomNumericString());// Name is optional
|
|
3958
4040
|
tmpStep.Name=typeof pStepName!=='undefined'?pStepName:"Step [".concat(tmpStep.GUIDStep,"]");tmpStep.Description=typeof pStepDescription!=='undefined'?pStepDescription:"Step execution of ".concat(tmpStep.Name,".");tmpStep.ProgressTracker=this.progressTrackerSet.createProgressTracker(tmpStep.GUIDStep);tmpStep.Metadata=_typeof(pStepMetadata)==='object'?pStepMetadata:{};// There is an array of steps, in the Operation State itself ... push a step there
|
|
3959
|
-
this.state.Steps.push(tmpStep);this.stepMap[tmpStep.GUIDStep]=tmpStep;this.stepFunctions[tmpStep.GUIDStep]=typeof fStepFunction=='function'?fStepFunction:function(fDone){return fDone();};this.state.Status.StepCount++;return tmpStep;}},{key:"setStepTotalOperations",value:function setStepTotalOperations(pGUIDStep,pTotalOperationCount){if(!(pGUIDStep in this.stepMap)){return new Error("Step [".concat(pGUIDStep,"] does not exist in operation [").concat(this.state.Metadata.UUID,"] ").concat(this.state.Metadata.Name," when attempting to set total operations to ").concat(pTotalOperationCount,"."));}this.progressTrackerSet.setProgressTrackerTotalOperations(this.stepMap[pGUIDStep].ProgressTracker.Hash,pTotalOperationCount);}},{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":
|
|
4041
|
+
this.state.Steps.push(tmpStep);this.stepMap[tmpStep.GUIDStep]=tmpStep;this.stepFunctions[tmpStep.GUIDStep]=typeof fStepFunction=='function'?fStepFunction:function(fDone){return fDone();};this.state.Status.StepCount++;return tmpStep;}},{key:"setStepTotalOperations",value:function setStepTotalOperations(pGUIDStep,pTotalOperationCount){if(!(pGUIDStep in this.stepMap)){return new Error("Step [".concat(pGUIDStep,"] does not exist in operation [").concat(this.state.Metadata.UUID,"] ").concat(this.state.Metadata.Name," when attempting to set total operations to ").concat(pTotalOperationCount,"."));}this.progressTrackerSet.setProgressTrackerTotalOperations(this.stepMap[pGUIDStep].ProgressTracker.Hash,pTotalOperationCount);}},{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":150,"big.js":17,"fable-serviceproviderbase":51}],152:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var FableServiceProgressTime=/*#__PURE__*/function(_libFableServiceBase9){_inherits(FableServiceProgressTime,_libFableServiceBase9);function FableServiceProgressTime(pFable,pOptions,pServiceHash){var _this41;_classCallCheck2(this,FableServiceProgressTime);_this41=_callSuper(this,FableServiceProgressTime,[pFable,pOptions,pServiceHash]);_this41.serviceType='ProgressTime';_this41.timeStamps={};return _this41;}_createClass2(FableServiceProgressTime,[{key:"formatTimeDuration",value:function formatTimeDuration(pTimeDurationInMilliseconds){var tmpTimeDuration=typeof pTimeDurationInMilliseconds=='number'?pTimeDurationInMilliseconds:0;if(pTimeDurationInMilliseconds<0){return'unknown';}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 tmpTimeStampHash in this.timeStamps?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.
|
|
3960
4042
|
if(typeof pReferenceTime=='string'){tmpReferenceTime=tmpReference in this.timeStamps?this.timeStamps[tmpReference]:false;}else if(typeof pReferenceTime=='number'){tmpReferenceTime=pReferenceTime;}else{tmpReferenceTime=+new Date();}if(tmpTimeStampHash in this.timeStamps&&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(tmpTimeStampHash in this.timeStamps){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.
|
|
3961
|
-
if(typeof pReferenceTime=='string'){tmpReferenceTime=tmpReference in this.timeStamps?this.timeStamps[tmpReference]:false;}else if(typeof pReferenceTime=='number'){tmpReferenceTime=pReferenceTime;}else{tmpReferenceTime=+new Date();}if(tmpTimeStampHash in this.timeStamps&&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(tmpTimeStampHashStart in this.timeStamps&&tmpTimeStampHashEnd in this.timeStamps){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}],
|
|
3962
|
-
|
|
3963
|
-
|
|
4043
|
+
if(typeof pReferenceTime=='string'){tmpReferenceTime=tmpReference in this.timeStamps?this.timeStamps[tmpReference]:false;}else if(typeof pReferenceTime=='number'){tmpReferenceTime=pReferenceTime;}else{tmpReferenceTime=+new Date();}if(tmpTimeStampHash in this.timeStamps&&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(tmpTimeStampHashStart in this.timeStamps&&tmpTimeStampHashEnd in this.timeStamps){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}],153:[function(require,module,exports){var ProgressTracker=/*#__PURE__*/function(){function ProgressTracker(pProgressTrackerSet,pProgressTrackerHash){_classCallCheck2(this,ProgressTracker);this.progressTrackerSet=pProgressTrackerSet;this.progressTrackerHash=pProgressTrackerHash;this.data=this.progressTrackerSet.getProgressTrackerData(this.progressTrackerHash);}_createClass2(ProgressTracker,[{key:"updateProgressTracker",value:function updateProgressTracker(pProgressAmount){return this.progressTrackerSet.updateProgressTracker(this.progressTrackerHash,pProgressAmount);}},{key:"incrementProgressTracker",value:function incrementProgressTracker(pProgressIncrementAmount){return this.progressTrackerSet.incrementProgressTracker(this.progressTrackerHash,pProgressIncrementAmount);}},{key:"setProgressTrackerTotalOperations",value:function setProgressTrackerTotalOperations(pTotalOperationCount){return this.progressTrackerSet.setProgressTrackerTotalOperations(this.progressTrackerHash,pTotalOperationCount);}},{key:"getProgressTrackerStatusString",value:function getProgressTrackerStatusString(){return this.progressTrackerSet.getProgressTrackerStatusString(this.progressTrackerHash);}}]);return ProgressTracker;}();module.exports=ProgressTracker;},{}],154:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var libProgressTrackerClass=require('./Fable-Service-ProgressTracker/ProgressTracker.js');var FableServiceProgressTrackerSet=/*#__PURE__*/function(_libFableServiceBase10){_inherits(FableServiceProgressTrackerSet,_libFableServiceBase10);function FableServiceProgressTrackerSet(pFable,pOptions,pServiceHash){var _this42;_classCallCheck2(this,FableServiceProgressTrackerSet);_this42=_callSuper(this,FableServiceProgressTrackerSet,[pFable,pOptions,pServiceHash]);_this42.serviceType='ProgressTrackerSet';_this42.progressTrackers={};// Create an internal PorgressTime service to track timestamps
|
|
4044
|
+
_this42.progressTimes=_this42.fable.instantiateServiceProviderWithoutRegistration('ProgressTime');// This timestamp is used and updated by *all* progress trackers.
|
|
4045
|
+
_this42.progressTimes.createTimeStamp('CurrentTime');return _this42;}_createClass2(FableServiceProgressTrackerSet,[{key:"getProgressTracker",value:function getProgressTracker(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';if(!(tmpProgressTrackerHash in this.progressTrackers)){this.fable.log.warn("ProgressTracker ".concat(tmpProgressTrackerHash," does not exist! Creating a new tracker..."));this.createProgressTracker(tmpProgressTrackerHash,100);}return new libProgressTrackerClass(this,pProgressTrackerHash);}},{key:"getProgressTrackerData",value:function getProgressTrackerData(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';if(!(tmpProgressTrackerHash in this.progressTrackers)){this.fable.log.warn("ProgressTracker ".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,// If this is set to true, PercentComplete will be calculated as CurrentCount / TotalCount even if it goes over 100%
|
|
3964
4046
|
AllowTruePercentComplete:false,ElapsedTime:-1,AverageOperationTime:-1,EstimatedCompletionTime:-1,TotalCount:tmpTotalOperations,CurrentCount:-1};if(tmpProgressTrackerHash in this.progressTrackers){this.fable.log.warn("ProgressTracker ".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:"setProgressTrackerTotalOperations",value:function setProgressTrackerTotalOperations(pProgressTrackerHash,pTotalOperations){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';var tmpTotalOperations=typeof pTotalOperations=='number'?pTotalOperations:100;if(!(tmpProgressTrackerHash in this.progressTrackers)){this.fable.log.warn("Attempted to set the total operations of ProgressTracker ".concat(tmpProgressTrackerHash," but it does not exist! Creating a new tracker..."));this.createProgressTracker(tmpProgressTrackerHash,tmpTotalOperations);}this.progressTrackers[tmpProgressTrackerHash].TotalCount=tmpTotalOperations;return this.progressTrackers[tmpProgressTrackerHash];}},{key:"startProgressTracker",value:function startProgressTracker(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';// This is the only method to lazily create ProgressTrackers now
|
|
3965
4047
|
if(!(tmpProgressTrackerHash in this.progressTrackers)){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);if(tmpProgressTracker.CurrentCount<0){tmpProgressTracker.CurrentCount=0;}return this.solveProgressTrackerStatus(tmpProgressTrackerHash);}},{key:"endProgressTracker",value:function endProgressTracker(pProgressTrackerHash){var tmpProgressTrackerHash=typeof pProgressTrackerHash=='string'?pProgressTrackerHash:'Default';if(!(tmpProgressTrackerHash in this.progressTrackers)){this.fable.log.error("Attempted to end ProgressTracker ".concat(tmpProgressTrackerHash," that does not exist!"));return false;}var tmpProgressTracker=this.progressTrackers[tmpProgressTrackerHash];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(!(tmpProgressTrackerHash in this.progressTrackers)){this.fable.log.error("Attempted to solve ProgressTracker ".concat(tmpProgressTrackerHash," that does not exist!"));return false;}var tmpProgressTracker=this.progressTrackers[tmpProgressTrackerHash];if(tmpProgressTracker.TotalCount<1||isNaN(tmpProgressTracker.TotalCount)){this.fable.log.error("ProgressTracker ".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.
|
|
3966
4048
|
if(tmpProgressTracker.CurrentCount<1){tmpProgressTracker.PercentComplete=0;}else{tmpProgressTracker.PercentComplete=tmpProgressTracker.CurrentCount/tmpProgressTracker.TotalCount*100.0;}if(!tmpProgressTracker.AllowTruePercentComplete&&tmpProgressTracker.PercentComplete>100){tmpProgressTracker.PercentComplete=100;}// Compute the average time per operation
|
|
@@ -3981,20 +4063,20 @@ this.solveProgressTrackerStatus(tmpProgressTrackerHash);if(!(tmpProgressTrackerH
|
|
|
3981
4063
|
if(tmpProgressTracker.StartTimeStamp<1){return"ProgressTracker ".concat(tmpProgressTracker.Hash," has not been started yet.");}// 2. Started, but no operations completed
|
|
3982
4064
|
if(tmpProgressTracker.CurrentCount<1&&tmpProgressTracker.EndTimeStamp<1){return"ProgressTracker ".concat(tmpProgressTracker.Hash," has no completed operations. ").concat(this.progressTimes.formatTimeDuration(tmpProgressTracker.ElapsedTime)," have elapsed since it was started.");}// 3. Started, some operations completed
|
|
3983
4065
|
else if(tmpProgressTracker.EndTimeStamp<1){return"ProgressTracker ".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: ").concat(this.progressTimes.formatTimeDuration(tmpProgressTracker.EstimatedCompletionTime));}// 4. Done
|
|
3984
|
-
else{return"ProgressTracker ".concat(tmpProgressTracker.Hash," is done. ").concat(tmpProgressTracker.CurrentCount," / ").concat(tmpProgressTracker.TotalCount," operations were completed in ").concat(this.progressTimes.formatTimeDuration(tmpProgressTracker.ElapsedTime)," (median ").concat(this.progressTimes.formatTimeDuration(tmpProgressTracker.AverageOperationTime)," per).");}}}},{key:"logProgressTrackerStatus",value:function logProgressTrackerStatus(pProgressTrackerHash){this.fable.log.info(this.getProgressTrackerStatusString(pProgressTrackerHash));}}]);return FableServiceProgressTrackerSet;}(libFableServiceBase);module.exports=FableServiceProgressTrackerSet;},{"./Fable-Service-ProgressTracker/ProgressTracker.js":
|
|
4066
|
+
else{return"ProgressTracker ".concat(tmpProgressTracker.Hash," is done. ").concat(tmpProgressTracker.CurrentCount," / ").concat(tmpProgressTracker.TotalCount," operations were completed in ").concat(this.progressTimes.formatTimeDuration(tmpProgressTracker.ElapsedTime)," (median ").concat(this.progressTimes.formatTimeDuration(tmpProgressTracker.AverageOperationTime)," per).");}}}},{key:"logProgressTrackerStatus",value:function logProgressTrackerStatus(pProgressTrackerHash){this.fable.log.info(this.getProgressTrackerStatusString(pProgressTrackerHash));}}]);return FableServiceProgressTrackerSet;}(libFableServiceBase);module.exports=FableServiceProgressTrackerSet;},{"./Fable-Service-ProgressTracker/ProgressTracker.js":153,"fable-serviceproviderbase":51}],155:[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(_libFableServiceBase11){_inherits(FableServiceRestClient,_libFableServiceBase11);function FableServiceRestClient(pFable,pOptions,pServiceHash){var _this43;_classCallCheck2(this,FableServiceRestClient);_this43=_callSuper(this,FableServiceRestClient,[pFable,pOptions,pServiceHash]);_this43.TraceLog=false;if(_this43.options.TraceLog||_this43.fable.TraceLog){_this43.TraceLog=true;}_this43.dataFormat=_this43.fable.services.DataFormat;_this43.serviceType='RestClient';_this43.cookie=false;// This is a function that can be overridden, to allow the management
|
|
3985
4067
|
// of the request options before they are passed to the request library.
|
|
3986
|
-
|
|
4068
|
+
_this43.prepareRequestOptions=function(pOptions){return pOptions;};return _this43;}_createClass2(FableServiceRestClient,[{key:"simpleGet",get:function get(){return libSimpleGet;}},{key:"prepareCookies",value:function prepareCookies(pRequestOptions){if(this.cookie){var tmpCookieObject=this.cookie;if(!('headers'in pRequestOptions)){pRequestOptions.headers={};}var tmpCookieKeys=Object.keys(tmpCookieObject);if(tmpCookieKeys.length>0){// Only grab the first for now.
|
|
3987
4069
|
pRequestOptions.headers.cookie=libCookie.serialize(tmpCookieKeys[0],tmpCookieObject[tmpCookieKeys[0]]);}}return pRequestOptions;}},{key:"preRequest",value:function preRequest(pOptions){// Validate the options object
|
|
3988
4070
|
var tmpOptions=this.prepareCookies(pOptions);// Prepend a string to the URL if it exists in the Fable Config
|
|
3989
|
-
if('RestClientURLPrefix'in this.fable.settings){tmpOptions.url=this.fable.settings.RestClientURLPrefix+tmpOptions.url;}return this.prepareRequestOptions(tmpOptions);}},{key:"executeChunkedRequest",value:function executeChunkedRequest(pOptions,fCallback){var
|
|
3990
|
-
if(
|
|
3991
|
-
if(
|
|
3992
|
-
if(!tmpDataBuffer){tmpDataBuffer=Buffer.from(pChunk);}else{tmpDataBuffer=Buffer.concat([tmpDataBuffer,pChunk]);}});pResponse.on('end',function(){if(
|
|
4071
|
+
if('RestClientURLPrefix'in this.fable.settings){tmpOptions.url=this.fable.settings.RestClientURLPrefix+tmpOptions.url;}return this.prepareRequestOptions(tmpOptions);}},{key:"executeChunkedRequest",value:function executeChunkedRequest(pOptions,fCallback){var _this44=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(_this44.TraceLog){var tmpConnectTime=_this44.fable.log.getTimeStamp();_this44.fable.log.debug("--> ".concat(tmpOptions.method," connected in ").concat(_this44.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.
|
|
4072
|
+
if(_this44.TraceLog){var tmpChunkTime=_this44.fable.log.getTimeStamp();_this44.fable.log.debug("--> ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this44.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}tmpData+=pChunk;});pResponse.on('end',function(){if(_this44.TraceLog){var tmpCompletionTime=_this44.fable.log.getTimeStamp();_this44.fable.log.debug("==> ".concat(tmpOptions.method," completed data size ").concat(tmpData.length,"b received in ").concat(_this44.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,tmpData);});});}},{key:"executeChunkedRequestBinary",value:function executeChunkedRequestBinary(pOptions,fCallback){var _this45=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(_this45.TraceLog){var tmpConnectTime=_this45.fable.log.getTimeStamp();_this45.fable.log.debug("--> ".concat(tmpOptions.method," connected in ").concat(_this45.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.
|
|
4073
|
+
if(_this45.TraceLog){var tmpChunkTime=_this45.fable.log.getTimeStamp();_this45.fable.log.debug("--> ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this45.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.
|
|
4074
|
+
if(!tmpDataBuffer){tmpDataBuffer=Buffer.from(pChunk);}else{tmpDataBuffer=Buffer.concat([tmpDataBuffer,pChunk]);}});pResponse.on('end',function(){if(_this45.TraceLog){var tmpCompletionTime=_this45.fable.log.getTimeStamp();_this45.fable.log.debug("==> ".concat(tmpOptions.method," completed data size ").concat(tmpDataBuffer.length,"b received in ").concat(_this45.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,tmpDataBuffer);});});}},{key:"executeJSONRequest",value:function executeJSONRequest(pOptions,fCallback){var _this46=this;pOptions.json=true;var tmpOptions=this.preRequest(pOptions);if(!('headers'in tmpOptions)){tmpOptions.headers={};}/* Automated headers break some APIs
|
|
3993
4075
|
if (!('Content-Type' in tmpOptions.headers))
|
|
3994
4076
|
{
|
|
3995
4077
|
tmpOptions.headers['Content-Type'] = 'application/json';
|
|
3996
4078
|
}
|
|
3997
|
-
*/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(
|
|
4079
|
+
*/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(_this46.TraceLog){var tmpConnectTime=_this46.fable.log.getTimeStamp();_this46.fable.log.debug("--> JSON ".concat(tmpOptions.method," connected in ").concat(_this46.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}var tmpJSONData='';pResponse.on('data',function(pChunk){if(_this46.TraceLog){var tmpChunkTime=_this46.fable.log.getTimeStamp();_this46.fable.log.debug("--> JSON ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this46.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}tmpJSONData+=pChunk;});pResponse.on('end',function(){if(_this46.TraceLog){var tmpCompletionTime=_this46.fable.log.getTimeStamp();_this46.fable.log.debug("==> JSON ".concat(tmpOptions.method," completed - received in ").concat(_this46.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":101}],156:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var FableServiceTemplate=/*#__PURE__*/function(_libFableServiceBase12){_inherits(FableServiceTemplate,_libFableServiceBase12);// Underscore and lodash have a behavior, _.template, which compiles a
|
|
3998
4080
|
// string-based template with code snippets into simple executable pieces,
|
|
3999
4081
|
// with the added twist of returning a precompiled function ready to go.
|
|
4000
4082
|
//
|
|
@@ -4003,18 +4085,18 @@ if(!tmpDataBuffer){tmpDataBuffer=Buffer.from(pChunk);}else{tmpDataBuffer=Buffer.
|
|
|
4003
4085
|
//
|
|
4004
4086
|
// This is an implementation of that.
|
|
4005
4087
|
// TODO: Make this use precedent, add configuration, add debugging.
|
|
4006
|
-
function FableServiceTemplate(pFable,pOptions,pServiceHash){var
|
|
4088
|
+
function FableServiceTemplate(pFable,pOptions,pServiceHash){var _this47;_classCallCheck2(this,FableServiceTemplate);_this47=_callSuper(this,FableServiceTemplate,[pFable,pOptions,pServiceHash]);_this47.serviceType='Template';// These are the exact regex's used in lodash/underscore
|
|
4007
4089
|
// TODO: Switch this to precedent
|
|
4008
|
-
|
|
4090
|
+
_this47.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.
|
|
4009
4091
|
GuaranteedNonMatch:/.^/};// This is a helper for the escaper and unescaper functions.
|
|
4010
4092
|
// Right now we are going to keep what underscore is doing, but, not forever.
|
|
4011
|
-
|
|
4093
|
+
_this47.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
|
|
4012
4094
|
// function on this class.
|
|
4013
|
-
|
|
4095
|
+
_this47.renderFunction=false;_this47.templateString=false;return _this47;}_createClass2(FableServiceTemplate,[{key:"renderTemplate",value:function renderTemplate(pData){return this.renderFunction(pData);}},{key:"templateFunction",value:function templateFunction(){var fRenderTemplateBound=this.renderTemplate.bind(this);return fRenderTemplateBound;}},{key:"buildTemplateFunction",value:function buildTemplateFunction(pTemplateText,pData){var _this48=this;// For now this is being kept in a weird form ... this is to mimic the old
|
|
4014
4096
|
// underscore code until this is rewritten using precedent.
|
|
4015
|
-
this.TemplateSource="__p+='"+pTemplateText.replace(this.Matchers.Escaper,function(pMatch){return"\\".concat(
|
|
4097
|
+
this.TemplateSource="__p+='"+pTemplateText.replace(this.Matchers.Escaper,function(pMatch){return"\\".concat(_this48.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
|
|
4016
4098
|
// precompilation.
|
|
4017
|
-
this.TemplateSourceCompiled='function(obj){\n'+this.TemplateSource+'}';return this.templateFunction();}}]);return FableServiceTemplate;}(libFableServiceBase);module.exports=FableServiceTemplate;},{"fable-serviceproviderbase":51}],
|
|
4099
|
+
this.TemplateSourceCompiled='function(obj){\n'+this.TemplateSource+'}';return this.templateFunction();}}]);return FableServiceTemplate;}(libFableServiceBase);module.exports=FableServiceTemplate;},{"fable-serviceproviderbase":51}],157:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');// TODO: These are still pretty big -- consider the smaller polyfills
|
|
4018
4100
|
var libAsyncWaterfall=require('async.waterfall');var libAsyncEachLimit=require('async.eachlimit');var libBigNumber=require('big.js');var FableServiceUtility=/*#__PURE__*/function(_libFableServiceBase13){_inherits(FableServiceUtility,_libFableServiceBase13);// Underscore and lodash have a behavior, _.template, which compiles a
|
|
4019
4101
|
// string-based template with code snippets into simple executable pieces,
|
|
4020
4102
|
// with the added twist of returning a precompiled function ready to go.
|
|
@@ -4024,8 +4106,8 @@ var libAsyncWaterfall=require('async.waterfall');var libAsyncEachLimit=require('
|
|
|
4024
4106
|
//
|
|
4025
4107
|
// This is an implementation of that.
|
|
4026
4108
|
// TODO: Make this use precedent, add configuration, add debugging.
|
|
4027
|
-
function FableServiceUtility(pFable,pOptions,pServiceHash){var
|
|
4028
|
-
|
|
4109
|
+
function FableServiceUtility(pFable,pOptions,pServiceHash){var _this49;_classCallCheck2(this,FableServiceUtility);_this49=_callSuper(this,FableServiceUtility,[pFable,pOptions,pServiceHash]);_this49.templates={};// These two functions are used extensively throughout
|
|
4110
|
+
_this49.waterfall=libAsyncWaterfall;_this49.eachLimit=libAsyncEachLimit;_this49.bigNumber=libBigNumber;return _this49;}// Underscore and lodash have a behavior, _.extend, which merges objects.
|
|
4029
4111
|
// Now that es6 gives us this, use the native thingy.
|
|
4030
4112
|
// Nevermind, the native thing is not stable enough across environments
|
|
4031
4113
|
// Basic shallow copy
|