orator 3.0.4 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/debug/Harness.js
CHANGED
package/dist/orator.js
CHANGED
|
@@ -980,7 +980,7 @@ this.responseData+=this.responseData+JSON.stringify(pData);return true;}else{thi
|
|
|
980
980
|
const libOratorServiceServerIPCSynthesizedResponse=require('./Orator-ServiceServer-IPC-SynthesizedResponse.js');// A simple constrainer for the find-my-way router since we aren't using any kind of headers to pass version or host
|
|
981
981
|
const libOratorServiceServerIPCCustomConstrainer=require('./Orator-ServiceServer-IPC-RouterConstrainer.js');// This library is the default router for our services
|
|
982
982
|
const libFindMyWay=require('find-my-way');//const libAsync = require('async');
|
|
983
|
-
const libAsyncWaterfall=require("async/waterfall");const libAsyncEachOfSeries=require('async/
|
|
983
|
+
const libAsyncWaterfall=require("async/waterfall");const libAsyncEachOfSeries=require('async/eachOfSeries');class OratorServiceServerIPC extends libOratorServiceServerBase{constructor(pOrator){super(pOrator);this.routerOptions=this.orator.settings.hasOwnProperty('router_options')&&typeof this.orator.settings.router_options=='object'?this.orator.settings.router_options:{};this.router=libFindMyWay(this.routerOptions);this.router.addConstraintStrategy(libOratorServiceServerIPCCustomConstrainer);this.URL='IPC';this.preBehaviorFunctions=[];this.behaviorMap={};this.postBehaviorFunctions=[];}use(fHandlerFunction){if(!super.use(fHandlerFunction)){this.log.error(`IPC provider failed to map USE handler function!`);return false;}this.preBehaviorFunctions.push(fHandlerFunction);}addPostBehaviorFunction(fHandlerFunction){if(!super.use(fHandlerFunction)){this.log.error(`IPC provider failed to map USE handler function!`);return false;}this.preBehaviorFunctions.push(fHandlerFunction);}executePreBehaviorFunctions(pRequest,pResponse,fNext){libAsyncEachOfSeries(this.preBehaviorFunctions,(fBehaviorFunction,pFunctionIndex,fCallback)=>{return fBehaviorFunction(pRequest,pResponse,fCallback);},pError=>{if(pError){this.log.error(`IPC Provider preBehaviorFunction ${pFunctionIndex} failed with error: ${pError}`,pError);}return fNext(pError);});}addPostBehaviorFunction(fHandlerFunction){if(!super.use(fHandlerFunction)){this.log.error(`IPC provider failed to map USE handler function!`);return false;}this.preBehaviorFunctions.push(fHandlerFunction);}executePostBehaviorFunctions(pRequest,pResponse,fNext){libAsyncEachOfSeries(this.postBehaviorFunctions,(fBehaviorFunction,pFunctionIndex,fCallback)=>{return fBehaviorFunction(pRequest,pResponse,fCallback);},pError=>{if(pError){this.log.error(`IPC Provider postBehaviorFunction ${pFunctionIndex} failed with error: ${pError}`,pError);}return fNext(pError);});}/*
|
|
984
984
|
* Service Route Creation Functions
|
|
985
985
|
*
|
|
986
986
|
* These base functions provide basic validation for the routes, but don't actually
|
|
@@ -1005,8 +1005,8 @@ invoke(pMethod,pRoute,pData,fCallback){// If the data is skipped and a callback
|
|
|
1005
1005
|
let tmpCallback=typeof fCallback=='function'?fCallback:typeof pData=='function'?pData:// This is here in case the developer passed no callback and just wants to fire and forget the IPC call which might not be async safe
|
|
1006
1006
|
()=>{};// Create a bare minimum request object for IPC to pass to our router
|
|
1007
1007
|
let tmpRequest={method:pMethod,url:pRoute,guid:this.orator.fable.getUUID()};// Create a container for the IPC response data to be aggregated to from send() methodds
|
|
1008
|
-
let tmpSynthesizedResponseData=new libOratorServiceServerIPCSynthesizedResponse(this.log,tmpRequest.guid);return this.router.lookup(tmpRequest,tmpSynthesizedResponseData,(pError,pResults)=>{if(pError){this.log.error(`IPC Request Error Request GUID [${tmpRequest.guid}] handling route [${pRoute}]: ${pError}`,{Error:pError,Route:pRoute,Data:pData});}// by default, send data back through
|
|
1009
|
-
return tmpCallback(pError,tmpSynthesizedResponseData.responseData,tmpSynthesizedResponseData,pResults);});}}module.exports=OratorServiceServerIPC;},{"./Orator-ServiceServer-IPC-RouterConstrainer.js":67,"./Orator-ServiceServer-IPC-SynthesizedResponse.js":68,"async/
|
|
1008
|
+
let tmpSynthesizedResponseData=new libOratorServiceServerIPCSynthesizedResponse(this.log,tmpRequest.guid);return this.router.lookup(tmpRequest,tmpSynthesizedResponseData,(pError,pResults)=>{if(pError){this.log.error(`IPC Request Error Request GUID [${tmpRequest.guid}] handling route [${pRoute}]: ${pError}`,{Error:pError,Route:pRoute,Data:pData});}// by default, send data back through
|
|
1009
|
+
return tmpCallback(pError,tmpSynthesizedResponseData.responseData,tmpSynthesizedResponseData,pResults);});}}module.exports=OratorServiceServerIPC;},{"./Orator-ServiceServer-IPC-RouterConstrainer.js":67,"./Orator-ServiceServer-IPC-SynthesizedResponse.js":68,"async/eachOfSeries":8,"async/waterfall":22,"find-my-way":44,"orator-serviceserver":52}],70:[function(require,module,exports){/**
|
|
1010
1010
|
* Orator Service Abstraction
|
|
1011
1011
|
*
|
|
1012
1012
|
* @license MIT
|
|
@@ -1024,7 +1024,7 @@ this.settings.ServicePort=defaultOratorConfiguration.ServicePort;}}// Now check
|
|
|
1024
1024
|
if(!this.settings.hasOwnProperty('Product')){this.settings.Product=defaultOratorConfiguration.Product;}}initializeServiceServer(fNext){var tmpNext=typeof fNext==='function'?fNext:()=>{};if(!this.serviceServer){// If the developer hasn't set this to a service provider class of their own choosing,
|
|
1025
1025
|
// use the built-in network-less one.
|
|
1026
1026
|
if(!this.serviceServerProvider){this.serviceServerProvider=defaultOratorServiceServers.default;}this.serviceServer=new this.serviceServerProvider(this);// For legacy reasons, we also will provide this under the "webServer" variable.
|
|
1027
|
-
this.webServer=this.serviceServer;}else{this.log.warn(`Orator attempting to initialize a service server after initialization has already completed.`);}}_startServiceListener(fNext){return this.serviceServer.listen(this.settings.ServicePort,pError=>{this.log.info(`${this.serviceServer.Name} listening at ${this.serviceServer.URL} port ${this.serviceServer.Port}`);return fNext(pError);});}startService(fNext){var tmpNext=typeof fNext==='function'?fNext:()=>{};if(!this.serviceServer){this.initializeServiceServer();}return this._startServiceListener(tmpNext);}stopService(fNext){var tmpNext=typeof fNext==='function'?fNext:()=>{};if(!this.serviceServer){let tmpMessage=`Orator attempting to stop a service server but the service server has not been intialized yet.`;this.log.warn(tmpMessage);return tmpNext(tmpMessage);}if(!this.serviceServer.Active){let tmpMessage=`Orator attempting to stop a service server but the service server is not actively running.`;this.log.warn(tmpMessage);return tmpNext(tmpMessage);}return this.serviceServer.close(tmpNext);}invoke(pMethod,pRoute,pData,fCallback){return this.serviceServer.invoke(pMethod,pRoute,pData,fCallback);}/*
|
|
1027
|
+
this.webServer=this.serviceServer;}else{this.log.warn(`Orator attempting to initialize a service server after initialization has already completed.`);}return tmpNext();}_startServiceListener(fNext){return this.serviceServer.listen(this.settings.ServicePort,pError=>{this.log.info(`${this.serviceServer.Name} listening at ${this.serviceServer.URL} port ${this.serviceServer.Port}`);return fNext(pError);});}startService(fNext){var tmpNext=typeof fNext==='function'?fNext:()=>{};if(!this.serviceServer){this.initializeServiceServer();}return this._startServiceListener(tmpNext);}stopService(fNext){var tmpNext=typeof fNext==='function'?fNext:()=>{};if(!this.serviceServer){let tmpMessage=`Orator attempting to stop a service server but the service server has not been intialized yet.`;this.log.warn(tmpMessage);return tmpNext(tmpMessage);}if(!this.serviceServer.Active){let tmpMessage=`Orator attempting to stop a service server but the service server is not actively running.`;this.log.warn(tmpMessage);return tmpNext(tmpMessage);}return this.serviceServer.close(tmpNext);}invoke(pMethod,pRoute,pData,fCallback){return this.serviceServer.invoke(pMethod,pRoute,pData,fCallback);}/*
|
|
1028
1028
|
* Legacy Orator Functions
|
|
1029
1029
|
*************************************************************************/startWebServer(fNext){return this.startService(fNext);}// For legacy purposes
|
|
1030
1030
|
stopWebServer(fNext){return this.stopService(fNext);}// For legacy purposes
|
package/dist/orator.min.js
CHANGED
|
@@ -123,7 +123,7 @@ var n=t("./Orator.js");"object"!=typeof window||window.hasOwnProperty("Orator")|
|
|
|
123
123
|
*
|
|
124
124
|
* @author Steven Velozo <steven@velozo.com>
|
|
125
125
|
*/
|
|
126
|
-
getDefaultServiceServers=()=>{let e={};return e.ipc=t("./Orator-ServiceServer-IPC.js"),e.default=e.ipc,e},e.exports=getDefaultServiceServers()},{"./Orator-ServiceServer-IPC.js":69}],67:[function(t,e,r){"use strict";e.exports={name:"ipc",isAsync:!0,storage:()=>{let t={};return{get:e=>t[e]||null,set:(e,r)=>{t[e]=r}}},deriveConstraint:(t,e,r)=>r(null,"IPC"),mustMatchWhenDerived:!0}},{}],68:[function(t,e,r){e.exports=class{constructor(t,e){this.log=t,this.requestGUID=e,this.responseData=null,this.responseStatus=-1}send(t){return"string"==typeof t?null===this.responseData?(this.responseData=t,!0):"string"==typeof this.responseData?(this.responseData=this.responseData+t,!0):(this.log(`Request ${this.requestGUID} has tried to send() a string value after send()ing data type ${typeof this.responseData}.`,t),!1):"object"==typeof t?null===this.responseData?(this.responseData=JSON.stringify(t),!0):"string"==typeof this.responseData?(this.responseData+=this.responseData+JSON.stringify(t),!0):(this.log(`Request ${this.requestGUID} has tried to send() an object value to be auto stringified after send()ing data type ${typeof this.responseData}.`,t),!1):void 0}}},{}],69:[function(t,e,r){const n=t("orator-serviceserver"),i=t("./Orator-ServiceServer-IPC-SynthesizedResponse.js"),s=t("./Orator-ServiceServer-IPC-RouterConstrainer.js"),o=t("find-my-way"),a=t("async/waterfall"),u=t("async/
|
|
126
|
+
getDefaultServiceServers=()=>{let e={};return e.ipc=t("./Orator-ServiceServer-IPC.js"),e.default=e.ipc,e},e.exports=getDefaultServiceServers()},{"./Orator-ServiceServer-IPC.js":69}],67:[function(t,e,r){"use strict";e.exports={name:"ipc",isAsync:!0,storage:()=>{let t={};return{get:e=>t[e]||null,set:(e,r)=>{t[e]=r}}},deriveConstraint:(t,e,r)=>r(null,"IPC"),mustMatchWhenDerived:!0}},{}],68:[function(t,e,r){e.exports=class{constructor(t,e){this.log=t,this.requestGUID=e,this.responseData=null,this.responseStatus=-1}send(t){return"string"==typeof t?null===this.responseData?(this.responseData=t,!0):"string"==typeof this.responseData?(this.responseData=this.responseData+t,!0):(this.log(`Request ${this.requestGUID} has tried to send() a string value after send()ing data type ${typeof this.responseData}.`,t),!1):"object"==typeof t?null===this.responseData?(this.responseData=JSON.stringify(t),!0):"string"==typeof this.responseData?(this.responseData+=this.responseData+JSON.stringify(t),!0):(this.log(`Request ${this.requestGUID} has tried to send() an object value to be auto stringified after send()ing data type ${typeof this.responseData}.`,t),!1):void 0}}},{}],69:[function(t,e,r){const n=t("orator-serviceserver"),i=t("./Orator-ServiceServer-IPC-SynthesizedResponse.js"),s=t("./Orator-ServiceServer-IPC-RouterConstrainer.js"),o=t("find-my-way"),a=t("async/waterfall"),u=t("async/eachOfSeries");e.exports=class extends n{constructor(t){super(t),this.routerOptions=this.orator.settings.hasOwnProperty("router_options")&&"object"==typeof this.orator.settings.router_options?this.orator.settings.router_options:{},this.router=o(this.routerOptions),this.router.addConstraintStrategy(s),this.URL="IPC",this.preBehaviorFunctions=[],this.behaviorMap={},this.postBehaviorFunctions=[]}use(t){if(!super.use(t))return this.log.error("IPC provider failed to map USE handler function!"),!1;this.preBehaviorFunctions.push(t)}addPostBehaviorFunction(t){if(!super.use(t))return this.log.error("IPC provider failed to map USE handler function!"),!1;this.preBehaviorFunctions.push(t)}executePreBehaviorFunctions(t,e,r){u(this.preBehaviorFunctions,((r,n,i)=>r(t,e,i)),(t=>(t&&this.log.error(`IPC Provider preBehaviorFunction ${pFunctionIndex} failed with error: ${t}`,t),r(t))))}addPostBehaviorFunction(t){if(!super.use(t))return this.log.error("IPC provider failed to map USE handler function!"),!1;this.preBehaviorFunctions.push(t)}executePostBehaviorFunctions(t,e,r){u(this.postBehaviorFunctions,((r,n,i)=>r(t,e,i)),(t=>(t&&this.log.error(`IPC Provider postBehaviorFunction ${pFunctionIndex} failed with error: ${t}`,t),r(t))))}addRouteProcessor(t,e,r){return this.router.on(t,e,{constraints:{ipc:"IPC"}},((t,e,n)=>{a([e=>(t.params=n,e()),r=>this.executePreBehaviorFunctions(t,e,r),n=>{u(r,((r,n,i)=>r(t,e,i)),(t=>{if(t)return this.log.error(`IPC Provider behavior function ${pFunctionIndex} failed with error: ${t}`,t),fNext(pError)}))},r=>this.executePostBehaviorFunctions(t,e,r)],(t=>{t&&this.log.error(`IPC Provider behavior function ${pFunctionIndex} failed with error: ${pBehaviorFunctionError}`,pBehaviorFunctionError)}))})),!0}get(t,...e){return super.get(t,...e)?this.addRouteProcessor("GET",t,Array.from(e)):(this.log.error(`IPC provider failed to map GET route [${t}]!`),!1)}put(t,...e){return!!super.get(t,...e)||(this.log.error(`IPC provider failed to map PUT route [${t}]!`),!1)}post(t,...e){return!!super.get(t,...e)||(this.log.error(`IPC provider failed to map POST route [${t}]!`),!1)}del(t,...e){return!!super.get(t,...e)||(this.log.error(`IPC provider failed to map DEL route [${t}]!`),!1)}invoke(t,e,r,n){let s="function"==typeof n?n:"function"==typeof r?r:()=>{},o={method:t,url:e,guid:this.orator.fable.getUUID()},a=new i(this.log,o.guid);return this.router.lookup(o,a,((t,n)=>(t&&this.log.error(`IPC Request Error Request GUID [${o.guid}] handling route [${e}]: ${t}`,{Error:t,Route:e,Data:r}),s(t,a.responseData,a,n))))}}},{"./Orator-ServiceServer-IPC-RouterConstrainer.js":67,"./Orator-ServiceServer-IPC-SynthesizedResponse.js":68,"async/eachOfSeries":8,"async/waterfall":22,"find-my-way":44,"orator-serviceserver":52}],70:[function(t,e,r){
|
|
127
127
|
/**
|
|
128
128
|
* Orator Service Abstraction
|
|
129
129
|
*
|
|
@@ -132,5 +132,5 @@ getDefaultServiceServers=()=>{let e={};return e.ipc=t("./Orator-ServiceServer-IP
|
|
|
132
132
|
* @author Steven Velozo <steven@velozo.com>
|
|
133
133
|
* @module Orator Service
|
|
134
134
|
*/
|
|
135
|
-
const n=t("fable"),i=t("./Orator-Default-Configuration.js"),s=t("./Orator-Default-ServiceServers-Node.js");e.exports=class{constructor(t,e){this.fable="object"==typeof t&&t instanceof n?t:new n("object"==typeof t?t:i),this.settings=this.fable.settings,this.log=this.fable.log,this.serviceServer=!1,this.serviceServerProvider=!1,void 0!==e&&(this.serviceServerProvider=e),this.settings.hasOwnProperty("ServicePort")||(this.settings.hasOwnProperty("APIServerPort")?this.settings.ServicePort=this.fable.settings.APIServerPort:this.settings.ServicePort=i.ServicePort),this.settings.hasOwnProperty("Product")||(this.settings.Product=i.Product)}initializeServiceServer(t){this.serviceServer?this.log.warn("Orator attempting to initialize a service server after initialization has already completed."):(this.serviceServerProvider||(this.serviceServerProvider=s.default),this.serviceServer=new this.serviceServerProvider(this),this.webServer=this.serviceServer)}_startServiceListener(t){return this.serviceServer.listen(this.settings.ServicePort,(e=>(this.log.info(`${this.serviceServer.Name} listening at ${this.serviceServer.URL} port ${this.serviceServer.Port}`),t(e))))}startService(t){var e="function"==typeof t?t:()=>{};return this.serviceServer||this.initializeServiceServer(),this._startServiceListener(e)}stopService(t){var e="function"==typeof t?t:()=>{};if(!this.serviceServer){let t="Orator attempting to stop a service server but the service server has not been intialized yet.";return this.log.warn(t),e(t)}if(!this.serviceServer.Active){let t="Orator attempting to stop a service server but the service server is not actively running.";return this.log.warn(t),e(t)}return this.serviceServer.close(e)}invoke(t,e,r,n){return this.serviceServer.invoke(t,e,r,n)}startWebServer(t){return this.startService(t)}stopWebServer(t){return this.stopService(t)}getWebServer(){return this.serviceServer||this.initializeServiceServer(),this.serviceServer}}},{"./Orator-Default-Configuration.js":65,"./Orator-Default-ServiceServers-Node.js":66,fable:35}]},{},[64])(64)}));
|
|
135
|
+
const n=t("fable"),i=t("./Orator-Default-Configuration.js"),s=t("./Orator-Default-ServiceServers-Node.js");e.exports=class{constructor(t,e){this.fable="object"==typeof t&&t instanceof n?t:new n("object"==typeof t?t:i),this.settings=this.fable.settings,this.log=this.fable.log,this.serviceServer=!1,this.serviceServerProvider=!1,void 0!==e&&(this.serviceServerProvider=e),this.settings.hasOwnProperty("ServicePort")||(this.settings.hasOwnProperty("APIServerPort")?this.settings.ServicePort=this.fable.settings.APIServerPort:this.settings.ServicePort=i.ServicePort),this.settings.hasOwnProperty("Product")||(this.settings.Product=i.Product)}initializeServiceServer(t){var e="function"==typeof t?t:()=>{};return this.serviceServer?this.log.warn("Orator attempting to initialize a service server after initialization has already completed."):(this.serviceServerProvider||(this.serviceServerProvider=s.default),this.serviceServer=new this.serviceServerProvider(this),this.webServer=this.serviceServer),e()}_startServiceListener(t){return this.serviceServer.listen(this.settings.ServicePort,(e=>(this.log.info(`${this.serviceServer.Name} listening at ${this.serviceServer.URL} port ${this.serviceServer.Port}`),t(e))))}startService(t){var e="function"==typeof t?t:()=>{};return this.serviceServer||this.initializeServiceServer(),this._startServiceListener(e)}stopService(t){var e="function"==typeof t?t:()=>{};if(!this.serviceServer){let t="Orator attempting to stop a service server but the service server has not been intialized yet.";return this.log.warn(t),e(t)}if(!this.serviceServer.Active){let t="Orator attempting to stop a service server but the service server is not actively running.";return this.log.warn(t),e(t)}return this.serviceServer.close(e)}invoke(t,e,r,n){return this.serviceServer.invoke(t,e,r,n)}startWebServer(t){return this.startService(t)}stopWebServer(t){return this.stopService(t)}getWebServer(){return this.serviceServer||this.initializeServiceServer(),this.serviceServer}}},{"./Orator-Default-Configuration.js":65,"./Orator-Default-ServiceServers-Node.js":66,fable:35}]},{},[64])(64)}));
|
|
136
136
|
//# sourceMappingURL=orator.min.js.map
|