uapi-json 1.14.8 → 1.14.10

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.10",
4
4
  "description": "Travelport Universal API",
5
5
  "main": "src/",
6
6
  "files": [
@@ -45,7 +45,7 @@
45
45
  "node-errors-helpers": "^1.0.0",
46
46
  "pretty-data": "^0.40.0",
47
47
  "promise-retry": "^1.1.1",
48
- "xml2js": "^0.4.23"
48
+ "xml2js": "^0.5.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "chai": "^4.3.7",
@@ -98,6 +98,7 @@ const AirRuntimeError = createErrorClass(
98
98
  errorTypes.RuntimeError
99
99
  );
100
100
  Object.assign(AirRuntimeError, createErrorsList({
101
+ NoSeatsAvailable: 'No seats available',
101
102
  PNRSyncFailed: 'Unexpected System Error. PNR(s) sync failed',
102
103
  SegmentBookingFailed: 'Failed to book on or more segments',
103
104
  SegmentWaitlisted: 'One or more segments is waitlisted, not allowed',
@@ -507,6 +507,8 @@ const AirErrorHandler = function (rsp) {
507
507
  }
508
508
  const pcc = utils.getErrorPcc(rsp.faultstring);
509
509
  switch (code) {
510
+ case '20':
511
+ throw new AirRuntimeError.NoSeatsAvailable(rsp);
510
512
  case '345':
511
513
  case '1512':
512
514
  if (pcc !== null) {
@@ -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 = {