ti2-tourplan 1.0.42 → 1.0.44

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/index.js CHANGED
@@ -12,6 +12,7 @@ const Normalizer = require('./normalizer');
12
12
 
13
13
  const xmlParser = new xml2js.Parser();
14
14
  const fastParser = new XMLParser();
15
+ const BAD_XML_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007f-\u0084\u0086-\u009f\uD800-\uDFFF\uFDD0-\uFDFF\uFFFF\uC008\uFEFF]/g;
15
16
 
16
17
  const defaultXmlOptions = {
17
18
  prettyPrinting: { enabled: false },
@@ -142,12 +143,14 @@ class Plugin {
142
143
  if (!replyObj) {
143
144
  // in case of error /xmlproxy, fallback to call tourplan directly
144
145
  // and then use pyfilematch xml2json to parse the xml
145
- const reply = R.path(['data'], await axios({
146
+ const axiospayload = {
146
147
  method: 'post',
147
148
  url: endpoint,
148
149
  data,
149
150
  headers: getHeaders({ length: data.length }),
150
- }));
151
+ };
152
+ // console.log(axiospayload)
153
+ const reply = R.path(['data'], await axios(axiospayload));
151
154
  if (this.xmlProxyUrl) {
152
155
  try {
153
156
  // using raw axios to avoid logging the large xml request
@@ -208,20 +211,21 @@ class Plugin {
208
211
  Twin: 'TW',
209
212
  Triple: 'TR',
210
213
  Quad: 'QD',
214
+ Other: 'OT',
211
215
  })[roomType];
212
216
  if (RoomType) RoomConfig.RoomType = RoomType;
213
217
  if (passengers && passengers.length && !noPaxList) {
214
218
  RoomConfig.PaxList = passengers.map(p => {
215
219
  const PaxDetails = {
216
- Forename: p.firstName,
217
- Surname: p.lastName,
220
+ Forename: this.escapeInvalidXmlChars(p.firstName),
221
+ Surname: this.escapeInvalidXmlChars(p.lastName),
218
222
  PaxType: {
219
223
  Adult: 'A',
220
224
  Child: 'C',
221
225
  Infant: 'I',
222
226
  }[p.passengerType] || 'A',
223
227
  };
224
- if (p.salutation) PaxDetails.Title = p.salutation;
228
+ if (p.salutation) PaxDetails.Title = this.escapeInvalidXmlChars(p.salutation);
225
229
  if (p.dob) PaxDetails.DateOfBirth = p.dob;
226
230
  if (!R.isNil(p.age) && !isNaN(p.age)) {
227
231
  if (!(p.passengerType === 'Adult' && p.age === 0)) {
@@ -237,7 +241,10 @@ class Plugin {
237
241
  });
238
242
  this.escapeInvalidXmlChars = str => {
239
243
  if (!str) return '';
240
- return str.replace(/[^\x00-\x7F]+/g, '')
244
+ const convertAccentedChars = s => {
245
+ return s.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
246
+ }
247
+ return convertAccentedChars(str)
241
248
  .replace(/’/g, "'")
242
249
  .replace(/‘/g, "'")
243
250
  .replace(/“/g, '"')
@@ -248,6 +255,7 @@ class Plugin {
248
255
  .replace(/>/g, '>')
249
256
  .replace(/"/g, '"')
250
257
  .replace(/'/g, ''')
258
+ .replace(BAD_XML_CHARS, '')
251
259
  };
252
260
 
253
261
  // this.errorPathsAxiosErrors = () => ([ // axios triggered errors
@@ -694,7 +702,7 @@ class Plugin {
694
702
  ${doInfo.flightDetails ? `Flight: ${doInfo.flightDetails || 'NA'},` : ''}
695
703
  `),
696
704
  } : {}),
697
- Remarks: this.escapeInvalidXmlChars(`${notes || ''} ${extraText ? `\nExtras: ${extraText}` : ''}`).slice(0, 240),
705
+ Remarks: this.escapeInvalidXmlChars(`${notes || ''} ${extraText ? `\nExtras: ${extraText}` : ''}`).slice(0, 220),
698
706
  Opt: optionId,
699
707
  DateFrom: startDate,
700
708
  RateId: 'Default',
@@ -773,10 +781,10 @@ class Plugin {
773
781
  });
774
782
  let searchCriterias = [];
775
783
  if (bookingId) {
776
- searchCriterias = ['BookingId', 'Ref', 'AgentRef'].map(key => ({ [key]: bookingId }));
784
+ searchCriterias = ['BookingId', 'Ref', 'AgentRef'].map(key => ({ [key]: this.escapeInvalidXmlChars(bookingId) }));
777
785
  }
778
786
  if (name) {
779
- searchCriterias.push({ NameContains: name });
787
+ searchCriterias.push({ NameContains: this.escapeInvalidXmlChars(name) });
780
788
  }
781
789
  const allSearches = searchCriterias.length
782
790
  ? searchCriterias.map(async keyObj => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -36,7 +36,8 @@ const translateTCMLCollection = async ({ rootValue, typeDefs, query }) => {
36
36
 
37
37
  const translateTPOption = ({ optionsGroupedBySupplierId, supplierData }) => {
38
38
  return {
39
- productId: supplierData.supplierId,
39
+ // LLM sends the product id as string
40
+ productId: supplierData.supplierId + "",
40
41
  productName: supplierData.supplierName,
41
42
  address: supplierData.supplierAddress,
42
43
  serviceTypes: supplierData.serviceTypes,