@google/chatbase
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -43,2 +43,4 @@ /** | ||
this.custom_session_id = null; | ||
/** @property {Number} transport_timeout [5000] the number of Milliseconds to let a request operate for */ | ||
this.transport_timeout = 5000; | ||
} | ||
@@ -122,2 +124,12 @@ /** | ||
/** | ||
* Set the timeout for requests to the Chatbase API. | ||
* @function setClientTimeout | ||
* @param {Number} customSessionId - the session id of current bot conversation | ||
* @chainable | ||
*/ | ||
setClientTimeout (t) { | ||
this.transport_timeout = t; | ||
return this; | ||
} | ||
/** | ||
* Create a new message instance which will have any default values set on | ||
@@ -139,3 +151,4 @@ * the interface by any applicable setters exposed publically. Optionally, API | ||
.setIntent(this.intent) | ||
.setCustomSessionId(this.custom_session_id); | ||
.setCustomSessionId(this.custom_session_id) | ||
.setClientTimeout(this.transport_timeout); | ||
if (this.type === MessageSink.messageTypes().agent) { | ||
@@ -142,0 +155,0 @@ msg.setAsTypeAgent(); |
@@ -159,2 +159,12 @@ /** | ||
/** | ||
* Set the timeout for requests to the Chatbase API. | ||
* @function setClientTimeout | ||
* @param {Number} customSessionId - the session id of current bot conversation | ||
* @chainable | ||
*/ | ||
setClientTimeout (t) { | ||
this.transport_timeout = t; | ||
return this; | ||
} | ||
/** | ||
* Rejection handler for creation errors. Wraps parent state sink method while | ||
@@ -201,3 +211,4 @@ * handling interface logic branching. | ||
.setIntent(this.intent) | ||
.setCustomSessionId(this.custom_session_id); | ||
.setCustomSessionId(this.custom_session_id) | ||
.setClientTimeout(this.transport_timeout); | ||
if (this.type === MessageSink.messageTypes().agent) { | ||
@@ -222,3 +233,4 @@ msg.setAsTypeAgent(); | ||
this._state.setAsCreateStarted(); | ||
Transport.sendMessageSet({messages: messagePayloadSet}) | ||
Transport.sendMessageSet({messages: messagePayloadSet}, | ||
this.transport_timeout) | ||
.then(response => { | ||
@@ -225,0 +237,0 @@ const e = MessageSet.validateCreateResponse(response); |
@@ -38,2 +38,4 @@ /** | ||
super(apiKey, userId); | ||
/** @property {Number} transport_timeout [5000] the number of Milliseconds to let a request operate for */ | ||
this.transport_timeout = 5000; | ||
} | ||
@@ -123,2 +125,12 @@ static extractMessageId (body) { | ||
/** | ||
* Set the timeout for requests to the Chatbase API. | ||
* @function setClientTimeout | ||
* @param {Number} customSessionId - the session id of current bot conversation | ||
* @chainable | ||
*/ | ||
setClientTimeout (t) { | ||
this.transport_timeout = t; | ||
return this; | ||
} | ||
/** | ||
* Attempts to export and send the message instance to the Chatbase service | ||
@@ -140,3 +152,3 @@ * for message creation. | ||
this._state.setAsCreateStarted(); | ||
Transport.sendMessage(payload) | ||
Transport.sendMessage(payload, this.transport_timeout) | ||
.then(response => { | ||
@@ -181,3 +193,4 @@ const e = MessageStateWrapper.validateCreateResponse(response); | ||
const opts = this._state.optionsManifest(); | ||
Transport.sendUpdate(query, pickBy(payload, (v, key) => opts[key])) | ||
Transport.sendUpdate(query, pickBy(payload, (v, key) => opts[key]), | ||
this.transport_timeout) | ||
.then(response => { | ||
@@ -184,0 +197,0 @@ const e = MessageStateWrapper.validateUpdateResponse(response); |
@@ -37,6 +37,7 @@ /** | ||
* @param {Object} messageBody - the message create payload | ||
* @param {Number} t - the TTL in milliseconds for the request | ||
* @returns {Promise} - returns a promise that will be resolved/rejected upon | ||
* request completion/error | ||
*/ | ||
static sendMessage (messageBody) { | ||
static sendMessage (messageBody, t) { | ||
logger('Sending Create Message \n %O', messageBody); | ||
@@ -47,2 +48,3 @@ return got( | ||
method: 'POST' | ||
, timeout: t | ||
, json: true | ||
@@ -62,6 +64,7 @@ , headers: { | ||
* @param {Object} messageBody - the message update payload | ||
* @param {Number} t - the TTL in milliseconds for the request | ||
* @returns {Promise} - returns a promise that will be resolved/rejected upon | ||
* request completion/error | ||
*/ | ||
static sendUpdate (params, messageBody) { | ||
static sendUpdate (params, messageBody, t) { | ||
logger('Sending Update Message:'); | ||
@@ -74,2 +77,3 @@ logger('Query \n %O', params); | ||
method: 'PUT' | ||
, timeout: t | ||
, json: true | ||
@@ -90,6 +94,7 @@ , query: params | ||
* @param {Object} messageBody - the message update payload | ||
* @param {Number} t - the TTL in milliseconds for the request | ||
* @returns {Promise} - returns a promise that will be resolved/rejected upon | ||
* request completion/error | ||
*/ | ||
static sendMessageSet (messageSet) { | ||
static sendMessageSet (messageSet, t) { | ||
logger('Sending Create Message Set \n %O', messageSet); | ||
@@ -100,2 +105,3 @@ return got( | ||
method: 'POST' | ||
, timeout: t | ||
, json: true | ||
@@ -102,0 +108,0 @@ , headers: { |
{ | ||
"name": "@google/chatbase", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -66,2 +66,3 @@ # Chatbase Node.JS Client | ||
.setMessageId('123'); // the id of the message, this is optional | ||
.setClientTimeout(5000) // Set the TTL in Milliseconds on requests to the Chatbase API. Default is 5000ms. | ||
``` | ||
@@ -122,2 +123,3 @@ | ||
.setUserId('unique-user-0') | ||
.setClientTimeout(8000) | ||
// This is a regular message object with all the same setter with the caveat | ||
@@ -124,0 +126,0 @@ // that one cannot send the message individually. All other setter methods |
155859
3827
144