uapi-json 1.17.4 → 1.17.5
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.17.
|
|
3
|
+
"version": "1.17.5",
|
|
4
4
|
"description": "Travelport Universal API",
|
|
5
5
|
"main": "src/",
|
|
6
6
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"axios": "^1.
|
|
40
|
+
"axios": "^1.9.0",
|
|
41
41
|
"galileo-screen": "1.0.5",
|
|
42
42
|
"handlebars": "^4.7.8",
|
|
43
43
|
"handlebars-helper-equal": "^1.0.0",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"eslint": "^8.39.0",
|
|
54
54
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
55
55
|
"eslint-plugin-import": "^2.29.0",
|
|
56
|
-
"mocha": "^
|
|
56
|
+
"mocha": "^11.5.0",
|
|
57
57
|
"nyc": "^17.1.0",
|
|
58
58
|
"proxyquire": "^2.1.3",
|
|
59
59
|
"readline2": "^1.0.1",
|
|
60
|
-
"sinon": "^
|
|
60
|
+
"sinon": "^20.0.0",
|
|
61
61
|
"sinon-chai": "^3.7.0"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -117,50 +117,49 @@ module.exports = function (settings) {
|
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
// Getting session token
|
|
120
|
-
const getSessionToken =
|
|
120
|
+
const getSessionToken = async () => {
|
|
121
|
+
// Return error if not in correct state
|
|
121
122
|
if (state.terminalState === TERMINAL_STATE_BUSY) {
|
|
122
|
-
|
|
123
|
-
return;
|
|
123
|
+
throw new TerminalRuntimeError.TerminalIsBusy();
|
|
124
124
|
}
|
|
125
125
|
if (state.terminalState === TERMINAL_STATE_CLOSED) {
|
|
126
|
-
|
|
127
|
-
return;
|
|
126
|
+
throw new TerminalRuntimeError.TerminalIsClosed();
|
|
128
127
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
|
|
129
|
+
state.terminalState = TERMINAL_STATE_BUSY;
|
|
130
|
+
|
|
132
131
|
// Return token if already obtained
|
|
133
132
|
if (state.sessionToken !== null) {
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
return state.sessionToken;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const { sessionToken } = await service.getSessionToken({ timeout });
|
|
137
|
+
state.sessionToken = sessionToken;
|
|
138
|
+
|
|
139
|
+
if (!emulatePcc) {
|
|
140
|
+
state.terminalState = TERMINAL_STATE_READY;
|
|
141
|
+
return state.sessionToken;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const response = await service.executeCommand({
|
|
145
|
+
sessionToken,
|
|
146
|
+
command: `SEM/${emulatePcc}/AG`,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (response[0].match(/duty code not authorised/i)) {
|
|
150
|
+
throw new TerminalRuntimeError.TerminalAuthIssue(response);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (response[0].match(/INVALID ACCOUNT/)) {
|
|
154
|
+
throw new TerminalRuntimeError.InvalidAccount(response);
|
|
136
155
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return tokenData.sessionToken;
|
|
145
|
-
}
|
|
146
|
-
// Emulate pcc
|
|
147
|
-
return service.executeCommand({
|
|
148
|
-
sessionToken: tokenData.sessionToken,
|
|
149
|
-
command: `SEM/${emulatePcc}/AG`,
|
|
150
|
-
}).then((response) => {
|
|
151
|
-
if (response[0].match(/duty code not authorised/i)) {
|
|
152
|
-
return Promise.reject(new TerminalRuntimeError.TerminalAuthIssue(response));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (!response[0].match(/^PROCEED/)) {
|
|
156
|
-
return Promise.reject(new TerminalRuntimeError.TerminalEmulationFailed(response));
|
|
157
|
-
}
|
|
158
|
-
return Promise.resolve(tokenData.sessionToken);
|
|
159
|
-
});
|
|
160
|
-
})
|
|
161
|
-
.then(resolve)
|
|
162
|
-
.catch(reject);
|
|
163
|
-
});
|
|
156
|
+
|
|
157
|
+
if (!response[0].match(/^PROCEED/)) {
|
|
158
|
+
throw new TerminalRuntimeError.TerminalEmulationFailed(response);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return sessionToken;
|
|
162
|
+
};
|
|
164
163
|
|
|
165
164
|
// Runtime error handling
|
|
166
165
|
const executeCommandWithRetry = async (command, times = DEFAULT_RETRY_TIMES) => {
|
|
@@ -210,7 +209,12 @@ module.exports = function (settings) {
|
|
|
210
209
|
const getTerminalId = (sessionToken) => getHashSubstr(sessionToken);
|
|
211
210
|
|
|
212
211
|
const terminal = {
|
|
213
|
-
getToken:
|
|
212
|
+
getToken: async () => {
|
|
213
|
+
await getSessionToken();
|
|
214
|
+
// Needed here as getSessionToken marks terminal as busy
|
|
215
|
+
state.terminalState = TERMINAL_STATE_READY;
|
|
216
|
+
return state.sessionToken;
|
|
217
|
+
},
|
|
214
218
|
executeCommand: async (command, stopMD = defaultStopMD) => {
|
|
215
219
|
try {
|
|
216
220
|
const sessionToken = await getSessionToken();
|
|
@@ -47,6 +47,7 @@ Object.assign(TerminalRuntimeError, createErrorsList({
|
|
|
47
47
|
ErrorClosingSession: 'Error closing session',
|
|
48
48
|
NoAgreement: ['There is no agreement between current pcc and you trying to reach', errorCodes.Validation],
|
|
49
49
|
TerminalAuthIssue: ['Temporary terminal auth issue. Please, try again later', errorCodes.Validation],
|
|
50
|
+
InvalidAccount: ['Invalid account', errorCodes.Validation],
|
|
50
51
|
TerminalUnexpectedError: ['Unexpected error message is returned by Travelport system. Please check PNR and try again later.', errorCodes.Validation],
|
|
51
52
|
TerminalUnexpectedFinancialError: ['Unexpected error message is returned by Travelport system. Please check PNR and new Fare calculation. If the problem persists, contact your local helpdesk.', errorCodes.Validation],
|
|
52
53
|
}, TerminalRuntimeError));
|