uapi-json 1.14.8 → 1.14.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uapi-json",
3
- "version": "1.14.8",
3
+ "version": "1.14.9",
4
4
  "description": "Travelport Universal API",
5
5
  "main": "src/",
6
6
  "files": [
@@ -19,6 +19,10 @@ const RETRY_CODES_LIST = ['14058'];
19
19
 
20
20
  const DEFAULT_RETRY_TIMES = 3;
21
21
 
22
+ const UNEXPECTED_TERMINAL_ERRORS = [
23
+ 'NO PREVIOUS OR ORIGINAL REQUEST',
24
+ ];
25
+
22
26
  // Adding event handler on beforeExit and exit process events to process open terminals
23
27
  process.on('beforeExit', () => {
24
28
  Promise.all(
@@ -188,6 +192,10 @@ module.exports = function (settings) {
188
192
  sessionToken: tokenData.sessionToken,
189
193
  command: `SEM/${emulatePcc}/AG`,
190
194
  }).then((response) => {
195
+ if (response[0].match(/duty code not authorised/i)) {
196
+ return Promise.reject(new TerminalRuntimeError.TerminalAuthIssue(response));
197
+ }
198
+
191
199
  if (!response[0].match(/^PROCEED/)) {
192
200
  return Promise.reject(new TerminalRuntimeError.TerminalEmulationFailed(response));
193
201
  }
@@ -202,7 +210,7 @@ module.exports = function (settings) {
202
210
 
203
211
  const terminal = {
204
212
  getToken: getSessionToken,
205
- executeCommand: (rawCommand, stopMD = defaultStopMD) => new Promise(async (resolve, reject) => {
213
+ executeCommand: async (rawCommand, stopMD = defaultStopMD) => {
206
214
  try {
207
215
  const sessionToken = await getSessionToken();
208
216
  const terminalId = getTerminalId(sessionToken);
@@ -223,14 +231,18 @@ module.exports = function (settings) {
223
231
  terminalState: TERMINAL_STATE_READY,
224
232
  });
225
233
 
226
- resolve(response);
234
+ if (UNEXPECTED_TERMINAL_ERRORS.some(e => response.includes(e))) {
235
+ throw new TerminalRuntimeError.TerminalUnexpectedError({ screen: response });
236
+ }
237
+
238
+ return response;
227
239
  } catch (err) {
228
240
  Object.assign(state, {
229
241
  terminalState: TERMINAL_STATE_ERROR,
230
242
  });
231
- reject(err);
243
+ throw err;
232
244
  }
233
- }),
245
+ },
234
246
  closeSession: () => getSessionToken()
235
247
  .then(
236
248
  sessionToken => service.closeSession({
@@ -46,6 +46,8 @@ Object.assign(TerminalRuntimeError, createErrorsList({
46
46
  TerminalIsClosed: 'Terminal is closed',
47
47
  ErrorClosingSession: 'Error closing session',
48
48
  NoAgreement: ['There is no agreement between current pcc and you trying to reach', errorCodes.Validation],
49
+ TerminalAuthIssue: ['Temporary terminal auth issue. Please, try again later', errorCodes.Validation],
50
+ TerminalUnexpectedError: ['Terminal unexpected error. Please, try again later', errorCodes.Validation],
49
51
  }, TerminalRuntimeError));
50
52
 
51
53
  module.exports = {