eh-api-client
Advanced tools
Comparing version 0.42.1 to 0.43.0
@@ -39,5 +39,8 @@ // Type definitions for eh-api-client 0.24.0 | ||
on(event: string, cb: any): void | ||
static on(event: string, cb: any): void | ||
static setAsyncLocalStorage(asyncLocalStorage): void | ||
static getRequestIdFromStore(): string | ||
} | ||
export = APIFactory |
38
index.js
@@ -46,2 +46,6 @@ var | ||
this._client._factory = this; | ||
const requestId = Factory.getRequestIdFromStore() | ||
if (null !== requestId) { | ||
this._client.setRequestId(requestId) | ||
} | ||
} | ||
@@ -52,2 +56,21 @@ return this._client; | ||
Factory.asyncLocalStorage = null | ||
Factory.setAsyncLocalStorage = function(asyncLocalStorage) { | ||
Factory.asyncLocalStorage = asyncLocalStorage | ||
} | ||
Factory.getRequestIdFromStore = function() { | ||
if (null !== Factory.asyncLocalStorage) { | ||
const store = Factory.asyncLocalStorage.getStore() | ||
if (undefined !== store) { | ||
const requestId = store.get('requestId') | ||
if (requestId) { | ||
return requestId | ||
} | ||
} | ||
} | ||
return null | ||
} | ||
Factory.prototype.setRetryOptions = function(options) { | ||
@@ -102,2 +125,6 @@ var self = this; | ||
}); | ||
const requestId = Factory.getRequestIdFromStore() | ||
if (null !== requestId) { | ||
client.setRequestId(requestId) | ||
} | ||
client._factory = this; | ||
@@ -112,2 +139,6 @@ return client; | ||
client._factory = this; | ||
const requestId = Factory.getRequestIdFromStore() | ||
if (null !== requestId) { | ||
client.setRequestId(requestId) | ||
} | ||
return client; | ||
@@ -125,3 +156,8 @@ }; | ||
}); | ||
client.setRequestId(context.requestId); | ||
const requestId = Factory.getRequestIdFromStore() | ||
if (null !== requestId) { | ||
client.setRequestId(requestId) | ||
} else { | ||
client.setRequestId(context.requestId); | ||
} | ||
client.setSessionId(context.sessionId); | ||
@@ -128,0 +164,0 @@ client._factory = this; |
{ | ||
"name": "eh-api-client", | ||
"version": "0.42.1", | ||
"version": "0.43.0", | ||
"description": "Node.js rest client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
86339
2112