ti2-tourplan 1.0.140 → 1.0.142

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/README.md CHANGED
@@ -4,11 +4,34 @@
4
4
 
5
5
  ### Requirements
6
6
 
7
- Some environment variables are required for this plugin to run it's tests
8
-
9
- - apiKey
10
- - endpoint
11
- - DTD_DAYS (optional) - Number of days to cache DTD version detection results (default: 7). This helps reduce API calls by caching the correct DTD version for each endpoint.
7
+ Live integration tests use `ti2_tourplan_endpoint`, `ti2_tourplan_username`,
8
+ and `ti2_tourplan_password`; the test suite supplies fixture defaults when
9
+ they are absent. Plugin credentials use the `endpoint`, `username`, and
10
+ `password` token fields. The optional `DTD_DAYS` plugin setting controls how
11
+ many days DTD version detection results are cached per endpoint (default: 7).
12
+
13
+ ## Itinerary product catalog fields
14
+
15
+ Product search passes Ti2's itinerary product type definitions and query to
16
+ `translateTPOption`. The query now returns the existing `city`, `country`, and
17
+ `currency` values alongside these HostConnect fields:
18
+
19
+ | Ti2 field | HostConnect source |
20
+ | --- | --- |
21
+ | `city` | Enriched destination, then `OptGeneral.LocalityDescription` or `Address3` |
22
+ | `country` | Enriched destination country |
23
+ | `currency` | Agent currency, then `OptRates.Currency` |
24
+ | `description` | SupplierInfo notes or description, excluding the supplier name |
25
+ | `optionClass` | `OptGeneral.ClassDescription`, then `OptGeneral.Class` |
26
+ | `chargeUnit` | `OptGeneral.SCU`, lowercased |
27
+ | Room `maxPaxWithInfants` | `OptGeneral.<room>_Max_With_Infants` |
28
+ | `Other` room restriction | `OptGeneral.Other_*` fields, when present |
29
+
30
+ For accommodation and package options, an `Other` unit is included only when
31
+ the source has an `Other_*` value. If those fields are absent, the `Other`
32
+ restriction is omitted. Optional source values omitted by the plugin appear as
33
+ `null` in Ti2's shared query. Adult, Child, and Infant restrictions still
34
+ select only `allowed`, `minAge`, and `maxAge`.
12
35
 
13
36
  ## Contributing
14
37
 
@@ -141,6 +141,7 @@ const fetchFullBookingByBookingId = async (
141
141
  hostConnectAgentID,
142
142
  itineraryBookingTypeDefs,
143
143
  itineraryBookingQuery,
144
+ rejectErrors = false,
144
145
  ) => {
145
146
  try {
146
147
  const getBookingPayload = getPayload('GetBookingRequest', {
@@ -150,12 +151,14 @@ const fetchFullBookingByBookingId = async (
150
151
  });
151
152
  const bookingReply = await callTourplan(getBookingPayload);
152
153
  const booking = R.path(['GetBookingReply'], bookingReply);
154
+ if (rejectErrors && !booking) throw new Error('GetBookingReply is missing');
153
155
  return await translateItineraryBooking({
154
156
  rootValue: booking && { ...booking, agentId: hostConnectAgentID },
155
157
  typeDefs: itineraryBookingTypeDefs,
156
158
  query: itineraryBookingQuery,
157
159
  });
158
160
  } catch (err) {
161
+ if (rejectErrors) throw err;
159
162
  const detail = err instanceof Error ? (err.stack || err.message) : String(err);
160
163
  // Log the failing identifier so the booking can be investigated without
161
164
  // crashing the whole search — the caller filters out nulls.
@@ -250,16 +253,19 @@ const searchItineraries = async ({
250
253
 
251
254
  // Step3: Build base search filters.
252
255
  if (applyBaseSearchFilters) {
256
+ baseSearchFilters = {};
253
257
  // Build base search filters.
254
258
  // If booking reference(s) or bookingid are provided these those are used.
255
259
  // But if no booking reference(s) or bookingid are provided then we use the travel
256
260
  // dates window as a base search filters. To keep the search bounded (and not crash Tourplan)
257
261
  // If purchase dates are provided then its part of base search filters.
258
- const travelDateWindow = resolveTravelDateWindow(travelDateStart, travelDateEnd);
259
- baseSearchFilters = {
260
- TravelDateFrom: travelDateWindow.from,
261
- TravelDateTo: travelDateWindow.to,
262
- };
262
+ if (!(purchaseDateStart && purchaseDateEnd) || travelDateStart || travelDateEnd) {
263
+ const travelDateWindow = resolveTravelDateWindow(travelDateStart, travelDateEnd);
264
+ baseSearchFilters = {
265
+ TravelDateFrom: travelDateWindow.from,
266
+ TravelDateTo: travelDateWindow.to,
267
+ };
268
+ }
263
269
  if (purchaseDateStart || purchaseDateEnd) {
264
270
  const purchaseDateWindow = resolvePurchaseDateWindow(purchaseDateStart, purchaseDateEnd);
265
271
  baseSearchFilters.BookingEnteredDateFrom = purchaseDateWindow.from;
@@ -268,6 +274,8 @@ const searchItineraries = async ({
268
274
  }
269
275
 
270
276
  // Step4: Fetch for bookings based on the search criterias.
277
+ const enteredDateOnly = Boolean(applyBaseSearchFilters && purchaseDateStart && purchaseDateEnd
278
+ && !travelDateStart && !travelDateEnd);
271
279
  const allSearches = searchCriteriaGroups.length
272
280
  ? searchCriteriaGroups
273
281
  : [[baseSearchFilters]];
@@ -318,7 +326,7 @@ const searchItineraries = async ({
318
326
  */
319
327
  } catch (err) {
320
328
  const errMsg = typeof err === 'string' ? err : (err && err.message) || String(err);
321
- if (hasAgentReferenceIds) {
329
+ if (hasAgentReferenceIds || enteredDateOnly) {
322
330
  throw err instanceof Error ? err : Error(errMsg);
323
331
  }
324
332
  if (errMsg.includes('Request failed with status code')) throw Error(errMsg);
@@ -407,6 +415,7 @@ const searchItineraries = async ({
407
415
  hostConnectAgentID,
408
416
  itineraryBookingTypeDefs,
409
417
  itineraryBookingQuery,
418
+ enteredDateOnly,
410
419
  ),
411
420
  { concurrency: 10 },
412
421
  );
@@ -53,6 +53,41 @@ describe('searchItineraries agentReferenceIds', () => {
53
53
  .map(([request]) => request.model.ListBookingsRequest)
54
54
  .filter(Boolean);
55
55
 
56
+ it('uses entered-date filters without silently restricting travel dates', async () => {
57
+ const callTourplan = jest.fn(async () => ({
58
+ ListBookingsReply: { BookingHeaders: { BookingHeader: [] } },
59
+ }));
60
+ await runSearch({ purchaseDateStart: '2026-02-01', purchaseDateEnd: '2026-02-02' }, callTourplan);
61
+ expect(listRequestsFrom(callTourplan)).toEqual([{
62
+ AgentID: 'agent-id', Password: 'agent-password',
63
+ BookingEnteredDateFrom: '2026-02-01', BookingEnteredDateTo: '2026-02-02',
64
+ }]);
65
+ callTourplan.mockClear();
66
+ await runSearch({ purchaseDateStart: '2026-02-01', purchaseDateEnd: '2026-02-02',
67
+ travelDateStart: '2028-01-01', travelDateEnd: '2028-01-31' }, callTourplan);
68
+ expect(listRequestsFrom(callTourplan)[0]).toMatchObject({
69
+ BookingEnteredDateFrom: '2026-02-01', BookingEnteredDateTo: '2026-02-02',
70
+ TravelDateFrom: '2028-01-01', TravelDateTo: '2028-01-31',
71
+ });
72
+ });
73
+
74
+ it('propagates entered-date retrieval timeouts instead of reporting successful empty coverage', async () => {
75
+ const timeout = Object.assign(new Error('timed out'), { code: 'ETIMEDOUT' });
76
+ const callTourplan = jest.fn().mockRejectedValue(timeout);
77
+ await expect(runSearch({ purchaseDateStart: '2026-02-01', purchaseDateEnd: '2026-02-02' }, callTourplan))
78
+ .rejects.toMatchObject({ code: 'ETIMEDOUT' });
79
+ expect(callTourplan).toHaveBeenCalledTimes(1);
80
+ });
81
+
82
+ it('fails entered-date retrieval if a booking detail cannot be fetched', async () => {
83
+ const callTourplan = jest.fn(async ({ model }) => {
84
+ if (model.ListBookingsRequest) return { ListBookingsReply: { BookingHeaders: { BookingHeader: [{ BookingId: 'A' }] } } };
85
+ throw Object.assign(new Error('detail timeout'), { code: 'ETIMEDOUT' });
86
+ });
87
+ await expect(runSearch({ purchaseDateStart: '2026-02-01', purchaseDateEnd: '2026-02-02' }, callTourplan))
88
+ .rejects.toMatchObject({ code: 'ETIMEDOUT' });
89
+ });
90
+
56
91
  it('treats a numeric agentReferenceIds value as an exact AgentRef with explicit precedence', async () => {
57
92
  const callTourplan = jest.fn(async ({ model }) => {
58
93
  if (model.ListBookingsRequest) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.140",
3
+ "version": "1.0.142",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {