fable 3.0.37 → 3.0.38
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/.browserslistrc +1 -1
- package/.config/vscode-sqltools/runningInfo.json +1 -1
- package/dist/fable.js +38 -8
- package/dist/fable.min.js +55 -3
- package/dist/fable.min.js.map +1 -1
- package/gulpfile-config.json +2 -2
- package/package.json +3 -2
- package/retold-harness/bookstore-serve-meadow-endpoint-apis.js +2 -4
- package/retold-harness/package.json +3 -3
- package/source/Fable.js +8 -17
- package/source/services/Fable-Service-CSVParser.js +199 -0
- package/source/services/Fable-Service-DataFormat.js +0 -3
- package/test/CSVParser_tests.js +66 -0
- package/test/RestClient_test.js +1 -1
- package/test/data/books.csv +10001 -0
package/.browserslistrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
since 2018
|
package/dist/fable.js
CHANGED
|
@@ -205,6 +205,7 @@ emitter.addEventListener(name,function wrapListener(arg){// IE does not have bui
|
|
|
205
205
|
if(flags.once){emitter.removeEventListener(name,wrapListener);}listener(arg);});}else{throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof emitter);}}},{}],22:[function(require,module,exports){/**
|
|
206
206
|
* Base Logger Class
|
|
207
207
|
*
|
|
208
|
+
* @license MIT
|
|
208
209
|
*
|
|
209
210
|
* @author Steven Velozo <steven@velozo.com>
|
|
210
211
|
*/class BaseLogger{constructor(pLogStreamSettings,pFableLog){// This should not possibly be able to be instantiated without a settings object
|
|
@@ -221,6 +222,7 @@ let tmpRandomData=(tmpDate+Math.random()*16)%16|0;tmpDate=Math.floor(tmpDate/16)
|
|
|
221
222
|
return true;}}module.exports=BaseLogger;},{}],23:[function(require,module,exports){/**
|
|
222
223
|
* Default Logger Provider Function
|
|
223
224
|
*
|
|
225
|
+
* @license MIT
|
|
224
226
|
*
|
|
225
227
|
* @author Steven Velozo <steven@velozo.com>
|
|
226
228
|
*/ // Return the providers that are available without extensions loaded
|
|
@@ -257,17 +259,20 @@ function autoConstruct(pSettings){return new FableLog(pSettings);}module.exports
|
|
|
257
259
|
* For a couple services, we need to be able to instantiate them before the Fable object is fully initialized.
|
|
258
260
|
* This is a base class for those services.
|
|
259
261
|
*
|
|
262
|
+
* @license MIT
|
|
260
263
|
* @author <steven@velozo.com>
|
|
261
264
|
*/class FableCoreServiceProviderBase{constructor(pOptions,pServiceHash){this.fable=false;this.options=typeof pOptions==='object'?pOptions:{};this.serviceType='Unknown';// The hash will be a non-standard UUID ... the UUID service uses this base class!
|
|
262
265
|
this.UUID="CORESVC-".concat(Math.floor(Math.random()*(99999-10000)+10000));this.Hash=typeof pServiceHash==='string'?pServiceHash:"".concat(this.UUID);}// After fable is initialized, it would be expected to be wired in as a normal service.
|
|
263
266
|
connectFable(pFable){this.fable=pFable;return true;}}_defineProperty2(FableCoreServiceProviderBase,"isFableService",true);module.exports=FableCoreServiceProviderBase;},{}],29:[function(require,module,exports){/**
|
|
264
267
|
* Fable Service Base
|
|
268
|
+
* @license MIT
|
|
265
269
|
* @author <steven@velozo.com>
|
|
266
270
|
*/class FableServiceProviderBase{constructor(pFable,pOptions,pServiceHash){this.fable=pFable;this.options=typeof pOptions==='object'?pOptions:{};this.serviceType='Unknown';this.UUID=pFable.getUUID();this.Hash=typeof pServiceHash==='string'?pServiceHash:"".concat(this.UUID);}}_defineProperty2(FableServiceProviderBase,"isFableService",true);module.exports=FableServiceProviderBase;module.exports.CoreServiceProviderBase=require('./Fable-ServiceProviderBase-Preinit.js');},{"./Fable-ServiceProviderBase-Preinit.js":28}],30:[function(require,module,exports){module.exports={"Product":"ApplicationNameHere","ProductVersion":"0.0.0","ConfigFile":false,"LogStreams":[{"level":"trace"}]};},{}],31:[function(require,module,exports){(function(process){(function(){/**
|
|
267
271
|
* Fable Settings Template Processor
|
|
268
272
|
*
|
|
269
273
|
* This class allows environment variables to come in via templated expressions, and defaults to be set.
|
|
270
274
|
*
|
|
275
|
+
* @license MIT
|
|
271
276
|
*
|
|
272
277
|
* @author Steven Velozo <steven@velozo.com>
|
|
273
278
|
* @module Fable Settings
|
|
@@ -277,6 +282,7 @@ this.templateProcessor.addPattern('${','}',pTemplateValue=>{let tmpTemplateValue
|
|
|
277
282
|
let tmpDefaultValue=tmpTemplateValue.substring(tmpSeparatorIndex+1);let tmpEnvironmentVariableName=tmpSeparatorIndex>-1?tmpTemplateValue.substring(0,tmpSeparatorIndex):tmpTemplateValue;if(process.env.hasOwnProperty(tmpEnvironmentVariableName)){return process.env[tmpEnvironmentVariableName];}else{return tmpDefaultValue;}});}parseSetting(pString){return this.templateProcessor.parseString(pString);}}module.exports=FableSettingsTemplateProcessor;}).call(this);}).call(this,require('_process'));},{"_process":43,"precedent":40}],32:[function(require,module,exports){/**
|
|
278
283
|
* Fable Settings Add-on
|
|
279
284
|
*
|
|
285
|
+
* @license MIT
|
|
280
286
|
*
|
|
281
287
|
* @author Steven Velozo <steven@velozo.com>
|
|
282
288
|
* @module Fable Settings
|
|
@@ -311,6 +317,7 @@ let tmpSettingsFromCopy=JSON.parse(JSON.stringify(tmpSettingsFrom));this.setting
|
|
|
311
317
|
function autoConstruct(pSettings){return new FableSettings(pSettings);}module.exports=FableSettings;module.exports.new=autoConstruct;},{"./Fable-Settings-Default":30,"./Fable-Settings-TemplateProcessor.js":31,"fable-serviceproviderbase":29}],33:[function(require,module,exports){/**
|
|
312
318
|
* Random Byte Generator - Browser version
|
|
313
319
|
*
|
|
320
|
+
* @license MIT
|
|
314
321
|
*
|
|
315
322
|
* @author Steven Velozo <steven@velozo.com>
|
|
316
323
|
*/ // Adapted from node-uuid (https://github.com/kelektiv/node-uuid)
|
|
@@ -1676,8 +1683,7 @@ if(!this.defaultServices.hasOwnProperty(tmpServiceType)){this.setDefaultServiceI
|
|
|
1676
1683
|
* Fable Application Services Support Library
|
|
1677
1684
|
* @author <steven@velozo.com>
|
|
1678
1685
|
*/ // Pre-init services
|
|
1679
|
-
const libFableSettings=require('fable-settings');const libFableUUID=require('fable-uuid');const libFableLog=require('fable-log');const libFableServiceManager=require('./Fable-ServiceManager.js')
|
|
1680
|
-
const libFableServiceEnvironmentData=require('./services/Fable-Service-EnvironmentData.js');const libFableServiceDataFormat=require('./services/Fable-Service-DataFormat.js');const libFableServiceMetaTemplate=require('./services/Fable-Service-MetaTemplate.js');const libFableServiceOperation=require('./services/Fable-Service-Operation.js');const libFableServiceRestClient=require('./services/Fable-Service-RestClient.js');const libFableServiceTemplate=require('./services/Fable-Service-Template.js');const libFableServiceUtility=require('./services/Fable-Service-Utility.js');class Fable{constructor(pSettings){// Initialization Phase 0: Set up the lowest level state (core services)
|
|
1686
|
+
const libFableSettings=require('fable-settings');const libFableUUID=require('fable-uuid');const libFableLog=require('fable-log');const libFableServiceManager=require('./Fable-ServiceManager.js');class Fable{constructor(pSettings){// Initialization Phase 0: Set up the lowest level state (core services)
|
|
1681
1687
|
// Container for the core services prototypes.
|
|
1682
1688
|
// This is here so if an API consumer changes the default for a core service,
|
|
1683
1689
|
// fable still runs with what was initialized.
|
|
@@ -1690,9 +1696,31 @@ this._coreServices.ServiceManager=new libFableServiceManager(this);this.serviceM
|
|
|
1690
1696
|
// Initialization Phase 2: Map in the default services.
|
|
1691
1697
|
// They will then be available in the Default service provider set as well.
|
|
1692
1698
|
this.serviceManager.connectPreinitServiceProviderInstance(this._coreServices.ServiceManager);this.serviceManager.connectPreinitServiceProviderInstance(this._coreServices.UUID);this.serviceManager.connectPreinitServiceProviderInstance(this._coreServices.Logging);this.serviceManager.connectPreinitServiceProviderInstance(this._coreServices.SettingsManager);// Initialize and instantiate the default baked-in Data Arithmatic service
|
|
1693
|
-
this.serviceManager.addAndInstantiateServiceType('EnvironmentData',
|
|
1694
|
-
function autoConstruct(pSettings){return new Fable(pSettings);}module.exports=Fable;module.exports.new=autoConstruct;module.exports.LogProviderBase=libFableLog.LogProviderBase;module.exports.ServiceProviderBase=libFableServiceManager.ServiceProviderBase;module.exports.CoreServiceProviderBase=libFableServiceManager.CoreServiceProviderBase;module.exports.precedent=libFableSettings.precedent;},{"./Fable-ServiceManager.js":78,"./services/Fable-Service-
|
|
1695
|
-
|
|
1699
|
+
this.serviceManager.addAndInstantiateServiceType('EnvironmentData',require('./services/Fable-Service-EnvironmentData.js'));this.serviceManager.addServiceType('Template',require('./services/Fable-Service-Template.js'));this.serviceManager.addServiceType('MetaTemplate',require('./services/Fable-Service-MetaTemplate.js'));this.serviceManager.addAndInstantiateServiceType('DataFormat',require('./services/Fable-Service-DataFormat.js'));this.serviceManager.addAndInstantiateServiceType('Utility',require('./services/Fable-Service-Utility.js'));this.serviceManager.addServiceType('Operation',require('./services/Fable-Service-Operation.js'));this.serviceManager.addServiceType('RestClient',require('./services/Fable-Service-RestClient.js'));this.serviceManager.addServiceType('CSVParser',require('./services/Fable-Service-CSVParser.js'));}get settings(){return this._coreServices.SettingsManager.settings;}get settingsManager(){return this._coreServices.SettingsManager;}get log(){return this._coreServices.Logging;}get services(){return this._coreServices.ServiceManager.services;}get defaultServices(){return this._coreServices.ServiceManager.defaultServices;}getUUID(){return this._coreServices.UUID.getUUID();}get fable(){return this;}}// This is for backwards compatibility
|
|
1700
|
+
function autoConstruct(pSettings){return new Fable(pSettings);}module.exports=Fable;module.exports.new=autoConstruct;module.exports.LogProviderBase=libFableLog.LogProviderBase;module.exports.ServiceProviderBase=libFableServiceManager.ServiceProviderBase;module.exports.CoreServiceProviderBase=libFableServiceManager.CoreServiceProviderBase;module.exports.precedent=libFableSettings.precedent;},{"./Fable-ServiceManager.js":78,"./services/Fable-Service-CSVParser.js":80,"./services/Fable-Service-DataFormat.js":81,"./services/Fable-Service-EnvironmentData.js":82,"./services/Fable-Service-MetaTemplate.js":83,"./services/Fable-Service-Operation.js":85,"./services/Fable-Service-RestClient.js":86,"./services/Fable-Service-Template.js":87,"./services/Fable-Service-Utility.js":88,"fable-log":27,"fable-settings":32,"fable-uuid":34}],80:[function(require,module,exports){const libFableServiceProviderBase=require('fable-serviceproviderbase');/**
|
|
1701
|
+
* Parsing CSVs. Why? Because it's a thing that needs to be done.
|
|
1702
|
+
*
|
|
1703
|
+
* 1. And the other node CSV parsers had issues with the really messy files we had.
|
|
1704
|
+
*
|
|
1705
|
+
*
|
|
1706
|
+
* 2. None of the CSV parsers dealt with and multi-line quoted string columns
|
|
1707
|
+
* which are apparently a-ok according to the official spec.
|
|
1708
|
+
* Plus a lot of them are asynchronous because apparently that's the best way to
|
|
1709
|
+
* do anything; unfortunately some files have a sequence issue with that.
|
|
1710
|
+
*
|
|
1711
|
+
* @class CSVParser
|
|
1712
|
+
*/class CSVParser extends libFableServiceProviderBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='CSVParser';this.Header=[];this.HeaderFieldNames=[];this.Delimiter=',';this.QuoteCharacter='"';this.CleanCharacters=['\r'];this.HeaderLineIndex=0;this.HasHeader=true;this.HasSetHeader=false;this.EmitHeader=false;this.EmitJSON=true;this.EscapedQuoteString='"';// Current Line Parsing State
|
|
1713
|
+
this.CurrentLine='';this.CurrentRecord=[];this.InQuote=false;this.InEscapedQuote=false;this.LinesParsed=0;this.RowsEmitted=0;}marshalRowToJSON(pRowArray){if(!Array.isArray(pRowArray)){return false;}for(let i=this.HeaderFieldNames.length;i<pRowArray.length;i++){this.HeaderFieldNames[i]="".concat(i);}let tmpObject={};for(let i=0;i<pRowArray.length;i++){tmpObject[this.HeaderFieldNames[i]]=pRowArray[i];}return tmpObject;}// Set the header data, for use in marshalling to JSON.
|
|
1714
|
+
setHeader(pHeaderArray){this.Header=pHeaderArray;for(let i=0;i<this.Header.length;i++){if(typeof this.Header[i]=='undefined'){this.HeaderFieldNames[i]="".concat(i);}else{this.HeaderFieldNames[i]=this.Header[i].toString();}}}resetRowState(){this.CurrentRecord=[];}pushLine(){for(let i=0;i<this.CleanCharacters.length;i++){this.CurrentLine=this.CurrentLine.replace(this.CleanCharacters[i],'');}this.CurrentRecord.push(this.CurrentLine);this.CurrentLine='';}emitRow(pFormatAsJSON){let tmpFormatAsJSON=typeof pFormatAsJSON=='undefined'?this.EmitJSON:pFormatAsJSON;this.RowsEmitted++;let tmpCompletedRecord=this.CurrentRecord;this.CurrentRecord=[];if(tmpFormatAsJSON){return this.marshalRowToJSON(tmpCompletedRecord);}else{return tmpCompletedRecord;}}parseCSVLine(pLineString){this.LinesParsed++;for(let i=0;i<pLineString.length;i++){if(!this.InQuote&&pLineString[i]==this.Delimiter){this.pushLine();}else if(pLineString[i]==this.QuoteCharacter){// If we are in the second part of an escaped quote, ignore it.
|
|
1715
|
+
if(this.InEscapedQuote){this.InEscapedQuote=false;}// If we aren't in a quote, enter quote
|
|
1716
|
+
else if(!this.InQuote){this.InQuote=true;}// We are in a quote, so peek forward to see if this is an "escaped" quote pair
|
|
1717
|
+
else if(i<pLineString.length&&pLineString[i+1]==this.QuoteCharacter){this.CurrentLine+=this.EscapedQuoteString;this.InEscapedQuote=true;}// We are in a quote, this isn't an "escaped" quote pair, so go out of quote mode
|
|
1718
|
+
else{this.InQuote=false;}}else{this.CurrentLine+=pLineString[i];}}// See if we are in a multiline quoted entry -- if not, emit the row.
|
|
1719
|
+
if(!this.InQuote){// Push the last remaining column from the buffer to the current line.
|
|
1720
|
+
this.pushLine();// Check to see if there is a header -- and if so, if this is the header row
|
|
1721
|
+
if(this.HasHeader&&!this.HasSetHeader&&this.RowsEmitted==this.HeaderLineIndex){this.HasSetHeader=true;// Override the format as json bit
|
|
1722
|
+
this.setHeader(this.emitRow(false));// No matter what, formatting this as JSON is silly and we don't want to go there anyway.
|
|
1723
|
+
if(this.EmitHeader){return this.Header;}else{return false;}}else{return this.emitRow();}}else{return false;}}}module.exports=CSVParser;},{"fable-serviceproviderbase":29}],81:[function(require,module,exports){const libFableServiceProviderBase=require('fable-serviceproviderbase');/**
|
|
1696
1724
|
* Data Formatting and Translation Functions
|
|
1697
1725
|
*
|
|
1698
1726
|
* @class DataFormat
|
|
@@ -1887,7 +1915,7 @@ return'';}if(tmpEnclosedValueEndIndex>0&&tmpEnclosedValueEndIndex>tmpEnclosedVal
|
|
|
1887
1915
|
* @param {number} pEnclosureEnd
|
|
1888
1916
|
* @returns {string}
|
|
1889
1917
|
*/stringRemoveEnclosureByIndex(pString,pEnclosureIndexToRemove,pEnclosureStart,pEnclosureEnd){let tmpString=typeof pString=='string'?pString:'';let tmpEnclosureIndexToRemove=typeof pEnclosureIndexToRemove=='number'?pEnclosureIndexToRemove:0;let tmpEnclosureStart=typeof pEnclosureStart=='string'?pEnclosureStart:'(';let tmpEnclosureEnd=typeof pEnclosureEnd=='string'?pEnclosureEnd:')';let tmpEnclosureCount=0;let tmpEnclosureDepth=0;let tmpMatchedEnclosureIndex=false;let tmpEnclosureStartIndex=0;let tmpEnclosureEndIndex=0;for(let i=0;i<tmpString.length;i++){// This is the start of an enclosure
|
|
1890
|
-
if(tmpString[i]==tmpEnclosureStart){tmpEnclosureDepth++;if(tmpEnclosureDepth==1){tmpEnclosureCount++;if(tmpEnclosureIndexToRemove==tmpEnclosureCount-1){tmpMatchedEnclosureIndex=true;tmpEnclosureStartIndex=i;}}}else if(tmpString[i]==tmpEnclosureEnd){tmpEnclosureDepth--;if(tmpEnclosureDepth==0&&tmpMatchedEnclosureIndex&&tmpEnclosureEndIndex<=tmpEnclosureStartIndex){tmpEnclosureEndIndex=i;tmpMatchedEnclosureIndex=false;}}}if(tmpEnclosureCount<=tmpEnclosureIndexToRemove){return tmpString;}let tmpReturnString='';if(tmpEnclosureStartIndex>1){tmpReturnString=tmpString.substring(0,tmpEnclosureStartIndex);}if(tmpString.length>tmpEnclosureEndIndex+1&&tmpEnclosureEndIndex>tmpEnclosureStartIndex){tmpReturnString+=tmpString.substring(tmpEnclosureEndIndex+1);}return tmpReturnString;}}module.exports=DataFormat;},{"fable-serviceproviderbase":29}],
|
|
1918
|
+
if(tmpString[i]==tmpEnclosureStart){tmpEnclosureDepth++;if(tmpEnclosureDepth==1){tmpEnclosureCount++;if(tmpEnclosureIndexToRemove==tmpEnclosureCount-1){tmpMatchedEnclosureIndex=true;tmpEnclosureStartIndex=i;}}}else if(tmpString[i]==tmpEnclosureEnd){tmpEnclosureDepth--;if(tmpEnclosureDepth==0&&tmpMatchedEnclosureIndex&&tmpEnclosureEndIndex<=tmpEnclosureStartIndex){tmpEnclosureEndIndex=i;tmpMatchedEnclosureIndex=false;}}}if(tmpEnclosureCount<=tmpEnclosureIndexToRemove){return tmpString;}let tmpReturnString='';if(tmpEnclosureStartIndex>1){tmpReturnString=tmpString.substring(0,tmpEnclosureStartIndex);}if(tmpString.length>tmpEnclosureEndIndex+1&&tmpEnclosureEndIndex>tmpEnclosureStartIndex){tmpReturnString+=tmpString.substring(tmpEnclosureEndIndex+1);}return tmpReturnString;}}module.exports=DataFormat;},{"fable-serviceproviderbase":29}],82:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;class FableServiceEnvironmentData extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='EnvironmentData';this.Environment="node.js";}}module.exports=FableServiceEnvironmentData;},{"../Fable-ServiceManager.js":78}],83:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;const libPrecedent=require('precedent');class FableServiceMetaTemplate extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='MetaTemplate';this._MetaTemplateLibrary=new libPrecedent(this.options);}/**
|
|
1891
1919
|
* Add a Pattern to the Parse Tree
|
|
1892
1920
|
* @method addPattern
|
|
1893
1921
|
* @param {Object} pTree - A node on the parse tree to push the characters into
|
|
@@ -1899,7 +1927,9 @@ if(tmpString[i]==tmpEnclosureStart){tmpEnclosureDepth++;if(tmpEnclosureDepth==1)
|
|
|
1899
1927
|
* @method parseString
|
|
1900
1928
|
* @param {string} pString - The string to parse
|
|
1901
1929
|
* @return {string} The result from the parser
|
|
1902
|
-
*/parseString(pString,pData){return this._MetaTemplateLibrary.parseString(pString,pData);}}module.exports=FableServiceMetaTemplate;},{"../Fable-ServiceManager.js":78,"precedent":40}],
|
|
1930
|
+
*/parseString(pString,pData){return this._MetaTemplateLibrary.parseString(pString,pData);}}module.exports=FableServiceMetaTemplate;},{"../Fable-ServiceManager.js":78,"precedent":40}],84:[function(require,module,exports){module.exports={"Metadata":{"GUID":false,"Hash":false,"Title":"","Summary":"","Version":0},"Status":{"Completed":false,"CompletionProgress":0,"CompletionTimeElapsed":0,"Steps":1,"StepsCompleted":0,"StartTime":0,"EndTime":0},"Errors":[],"Log":[]};},{}],85:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;const _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));class FableOperation extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='PhasedOperation';this.state=JSON.parse(_OperationStatePrototypeString);this.state.Metadata.GUID=this.fable.getUUID();this.state.Metadata.Hash=this.Hash;this.name=typeof this.options.Name=='string'?this.options.Name:"Unnamed Operation ".concat(this.state.Metadata.GUID);}get GUID(){return this.state.Metadata.GUID;}get log(){return this;}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));}}writeOperationErrors(pLogText,pLogObject){this.state.Errors.push("".concat(pLogText));if(typeof pLogObject=='object'){this.state.Errors.push(JSON.stringify(pLogObject));}}trace(pLogText,pLogObject){this.writeOperationLog('TRACE',pLogText,pLogObject);this.fable.log.trace(pLogText,pLogObject);}debug(pLogText,pLogObject){this.writeOperationLog('DEBUG',pLogText,pLogObject);this.fable.log.debug(pLogText,pLogObject);}info(pLogText,pLogObject){this.writeOperationLog('INFO',pLogText,pLogObject);this.fable.log.info(pLogText,pLogObject);}warn(pLogText,pLogObject){this.writeOperationLog('WARN',pLogText,pLogObject);this.fable.log.warn(pLogText,pLogObject);}error(pLogText,pLogObject){this.writeOperationLog('ERROR',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.error(pLogText,pLogObject);}fatal(pLogText,pLogObject){this.writeOperationLog('FATAL',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.fatal(pLogText,pLogObject);}}module.exports=FableOperation;},{"../Fable-ServiceManager.js":78,"./Fable-Service-Operation-DefaultSettings.js":84}],86:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;const libSimpleGet=require('simple-get');class FableServiceRestClient extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.TraceLog=false;if(this.options.TraceLog||this.fable.TraceLog){this.TraceLog=true;}this.dataFormat=this.fable.defaultServices.DataFormat;this.serviceType='RestClient';}executeChunkedRequest(pOptions,fCallback){pOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(pOptions.method," request to ").concat(pOptions.url," at ").concat(pOptions.RequestStartTime));}return libSimpleGet(pOptions,(pError,pResponse)=>{if(pError){return fCallback(pError,pResponse);}if(this.TraceLog){let tmpConnectTime=this.fable.log.getTimeStamp();this.fable.log.debug("--> ".concat(pOptions.method," connected in ").concat(this.dataFormat.formatTimeDelta(pOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}let tmpData='';pResponse.on('data',pChunk=>{// For JSON, the chunk is the serialized object.
|
|
1931
|
+
if(this.TraceLog){let tmpChunkTime=this.fable.log.getTimeStamp();this.fable.log.debug("--> ".concat(pOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(this.dataFormat.formatTimeDelta(pOptions.RequestStartTime,tmpChunkTime),"ms"));}tmpData+=pChunk;});pResponse.on('end',()=>{if(this.TraceLog){let tmpCompletionTime=this.fable.log.getTimeStamp();this.fable.log.debug("==> ".concat(pOptions.method," completed data size ").concat(tmpData.length,"b received in ").concat(this.dataFormat.formatTimeDelta(pOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,tmpData);});});}executeJSONRequest(pOptions,fCallback){pOptions.json=true;pOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(pOptions.method," JSON request to ").concat(pOptions.url," at ").concat(pOptions.RequestStartTime));}return libSimpleGet(pOptions,(pError,pResponse)=>{if(pError){return fCallback(pError,pResponse);}if(this.TraceLog){let tmpConnectTime=this.fable.log.getTimeStamp();this.fable.log.debug("--> JSON ".concat(pOptions.method," connected in ").concat(this.dataFormat.formatTimeDelta(pOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}pResponse.on('data',pChunk=>{if(this.TraceLog){let tmpChunkTime=this.fable.log.getTimeStamp();this.fable.log.debug("--> JSON ".concat(pOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(this.dataFormat.formatTimeDelta(pOptions.RequestStartTime,tmpChunkTime),"ms"));}// In a JSON request, the chunk is the serialized method.
|
|
1932
|
+
return fCallback(pError,pResponse,JSON.parse(pChunk));});pResponse.on('end',()=>{if(this.TraceLog){let tmpCompletionTime=this.fable.log.getTimeStamp();this.fable.log.debug("==> JSON ".concat(pOptions.method," completed - received in ").concat(this.dataFormat.formatTimeDelta(pOptions.RequestStartTime,tmpCompletionTime),"ms"));}});});}getJSON(pOptionsOrURL,fCallback){let tmpRequestOptions=typeof pOptions=='object'?pOptions:{};if(typeof pOptionsOrURL=='string'){tmpRequestOptions.url=pOptionsOrURL;}tmpRequestOptions.method='GET';return this.executeJSONRequest(tmpRequestOptions,fCallback);}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);}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);}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);}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);}delJSON(pOptions,fCallback){pOptions.method='DELETE';return this.executeJSONRequest(pOptions,fCallback);}getRawText(pOptionsOrURL,fCallback){let tmpRequestOptions=typeof pOptions=='object'?pOptions:{};if(typeof pOptionsOrURL=='string'){tmpRequestOptions.url=pOptionsOrURL;}tmpRequestOptions.method='GET';return this.executeChunkedRequest(tmpRequestOptions,fCallback);}}module.exports=FableServiceRestClient;},{"../Fable-ServiceManager.js":78,"simple-get":50}],87:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;class FableServiceTemplate extends libFableServiceBase{// Underscore and lodash have a behavior, _.template, which compiles a
|
|
1903
1933
|
// string-based template with code snippets into simple executable pieces,
|
|
1904
1934
|
// with the added twist of returning a precompiled function ready to go.
|
|
1905
1935
|
//
|
|
@@ -1919,7 +1949,7 @@ this.renderFunction=false;this.templateString=false;}renderTemplate(pData){retur
|
|
|
1919
1949
|
// underscore code until this is rewritten using precedent.
|
|
1920
1950
|
this.TemplateSource="__p+='"+pTemplateText.replace(this.Matchers.Escaper,pMatch=>{return"\\".concat(this.templateEscapes[pMatch]);}).replace(this.Matchers.Interpolate||this.Matchers.GuaranteedNonMatch,(pMatch,pCode)=>{return"'+\n(".concat(decodeURIComponent(pCode),")+\n'");}).replace(this.Matchers.Evaluate||this.Matchers.GuaranteedNonMatch,(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
|
|
1921
1951
|
// precompilation.
|
|
1922
|
-
this.TemplateSourceCompiled='function(obj){\n'+this.TemplateSource+'}';return this.templateFunction();}}module.exports=FableServiceTemplate;},{"../Fable-ServiceManager.js":78}],
|
|
1952
|
+
this.TemplateSourceCompiled='function(obj){\n'+this.TemplateSource+'}';return this.templateFunction();}}module.exports=FableServiceTemplate;},{"../Fable-ServiceManager.js":78}],88:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;// TODO: These are still pretty big -- consider the smaller polyfills
|
|
1923
1953
|
const libAsyncWaterfall=require('async.waterfall');const libAsyncEachLimit=require('async.eachlimit');class FableServiceUtility extends libFableServiceBase{// Underscore and lodash have a behavior, _.template, which compiles a
|
|
1924
1954
|
// string-based template with code snippets into simple executable pieces,
|
|
1925
1955
|
// with the added twist of returning a precompiled function ready to go.
|