@revolugo/common 7.0.0 → 7.0.1-alpha.1

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": "@revolugo/common",
3
- "version": "7.0.0",
3
+ "version": "7.0.1-alpha.1",
4
4
  "private": false,
5
5
  "description": "Revolugo common",
6
6
  "author": "Revolugo",
@@ -34,7 +34,7 @@
34
34
  "dayjs": "1.11.19",
35
35
  "ky": "1.14.3",
36
36
  "slugify": "1.6.6",
37
- "type-fest": "5.4.3",
37
+ "type-fest": "5.4.4",
38
38
  "uuid": "13.0.0",
39
39
  "zod": "4.3.6"
40
40
  },
@@ -238,7 +238,10 @@ describe('sanitizeCancellationPolicies', () => {
238
238
 
239
239
  describe('when Booking Date < Release Date < Check In Date', () => {
240
240
  const releaseDate = '2021-01-05'
241
- const releaseDatetime = getFormattedUTCLocalTime(releaseDate, timezone)
241
+ const releaseDateCP = dayjs(releaseDate)
242
+ .add(1, 'day')
243
+ .format('YYYY-MM-DD')
244
+ const releaseDatetime = getFormattedUTCLocalTime(releaseDateCP, timezone)
242
245
  const bookingDatetime = getFormattedUTCLocalTime(
243
246
  '2021-01-01T10:00:00',
244
247
  timezone,
@@ -404,7 +407,10 @@ describe('sanitizeCancellationPolicies', () => {
404
407
 
405
408
  describe('when Booking Date < Release Date < DF_0', () => {
406
409
  const releaseDate = '2020-12-30'
407
- const releaseDatetime = getFormattedUTCLocalTime(releaseDate, timezone)
410
+ const releaseDateCP = dayjs(releaseDate)
411
+ .add(1, 'day')
412
+ .format('YYYY-MM-DD')
413
+ const releaseDatetime = getFormattedUTCLocalTime(releaseDateCP, timezone)
408
414
  const bookingDatetime = getFormattedUTCLocalTime(
409
415
  '2020-12-20T10:00:00',
410
416
  timezone,
@@ -34,6 +34,31 @@ export interface SanitizeCancellationPolicies {
34
34
  timezone?: string
35
35
  }
36
36
 
37
+ function initReleaseDateUTC({
38
+ checkInDate,
39
+ releaseDate,
40
+ timezone,
41
+ }: {
42
+ releaseDate?: string
43
+ timezone: string
44
+ checkInDate: string
45
+ }): string | undefined {
46
+ if (!releaseDate) {
47
+ return undefined
48
+ }
49
+
50
+ if (dayjs(releaseDate).isSameOrAfter(dayjs(checkInDate))) {
51
+ return dayjs.tz(releaseDate, timezone).startOf('day').utc().format()
52
+ }
53
+
54
+ return dayjs
55
+ .tz(releaseDate, timezone)
56
+ .add(1, 'day')
57
+ .startOf('day')
58
+ .utc()
59
+ .format()
60
+ }
61
+
37
62
  // eslint-disable-next-line complexity, max-statements, max-lines-per-function
38
63
  export function sanitizeCancellationPolicies({
39
64
  bookingDatetime,
@@ -62,8 +87,11 @@ export function sanitizeCancellationPolicies({
62
87
 
63
88
  const nextDayCheckInDateUTC = nextDay(checkInDatetimeUTC)
64
89
 
65
- const releaseDatetimeUTC =
66
- releaseDate && dayjs.tz(releaseDate, timezone).startOf('day').utc().format()
90
+ const releaseDatetimeUTC = initReleaseDateUTC({
91
+ checkInDate,
92
+ releaseDate,
93
+ timezone,
94
+ })
67
95
 
68
96
  if (dayjs(bookingDatetimeUTC).isAfter(nextDayCheckInDateUTC)) {
69
97
  return sanitizeCancellationPolicies({
@@ -452,10 +480,10 @@ export function getSanitizedCancellationPolicies({
452
480
  initialDate,
453
481
  timezone,
454
482
  }: {
455
- checkInDate: string
456
483
  cancellationPolicies: ICancellationPolicy[]
457
- timezone?: string
484
+ checkInDate: string
458
485
  initialDate?: string
486
+ timezone?: string
459
487
  }): ICancellationPolicy[] {
460
488
  if (!cancellationPolicies.length) {
461
489
  return []
@@ -511,3 +539,28 @@ export function isFreeCancellable(cps: ICancellationPolicy[]): boolean {
511
539
  dayjs().isBetween(dayjs(freeCp.dateFrom), dayjs(freeCp.dateTo)))
512
540
  )
513
541
  }
542
+
543
+ export function filterForCustomers(
544
+ cps: ICancellationPolicy[],
545
+ ): ICancellationPolicy[] {
546
+ const now = dayjs()
547
+ const nowPlus2Hours = now.add(2, 'hours')
548
+
549
+ return cps.reduce<ICancellationPolicy[]>((result, cp) => {
550
+ if (
551
+ dayjs(cp.dateFrom).isSameOrBefore(nowPlus2Hours) &&
552
+ dayjs(cp.dateTo).isAfter(nowPlus2Hours)
553
+ ) {
554
+ result.push({
555
+ ...cp,
556
+ dateFrom: now.format(),
557
+ })
558
+ }
559
+
560
+ if (dayjs(cp.dateFrom).isAfter(nowPlus2Hours)) {
561
+ result.push(cp)
562
+ }
563
+
564
+ return result
565
+ }, [])
566
+ }
@@ -3,11 +3,11 @@ import type { CurrencyCode } from './constants.ts'
3
3
  export interface ICurrency {
4
4
  code: CurrencyCode
5
5
  decimalDigits: number
6
+ deprecated?: boolean
6
7
  name: string
7
8
  namePlural: string
8
9
  rounding: number
9
10
  symbol: string
10
11
  symbolNative: string
11
12
  zeroDecimal: boolean
12
- deprecated?: boolean
13
13
  }
@@ -98,49 +98,50 @@ export class MoneyCalculator {
98
98
  this.isNormalized = isNormalized
99
99
  }
100
100
 
101
- public denormalize(): this {
102
- if (!this.isNormalized) {
101
+ public ceil(): this {
102
+ this.amount = Math.ceil(this.amount)
103
+
104
+ return this
105
+ }
106
+
107
+ public convert({
108
+ currency,
109
+ exchangeRate,
110
+ }: {
111
+ currency: CurrencyCode
112
+ exchangeRate: number
113
+ }): this {
114
+ if (this.currency === currency || this.amount === 0) {
103
115
  return this
104
116
  }
105
117
 
106
- this.amount = denormalizeAmount({
107
- amount: this.amount,
108
- currency: this.currency,
109
- })
118
+ const startingIsNormalized = this.isNormalized
110
119
 
111
- this.isNormalized = false
120
+ if (startingIsNormalized) {
121
+ this.denormalize()
122
+ }
112
123
 
113
- return this
114
- }
124
+ this.amount *= exchangeRate
125
+ this.currency = currency
115
126
 
116
- public markup(percentage: number): this {
117
- this.amount /= 1 - percentage
127
+ if (startingIsNormalized) {
128
+ this.normalize()
129
+ }
118
130
 
119
131
  return this
120
132
  }
121
133
 
122
- public normalize(): this {
123
- if (this.isNormalized) {
134
+ public denormalize(): this {
135
+ if (!this.isNormalized) {
124
136
  return this
125
137
  }
126
138
 
127
- this.amount = Number(
128
- normalizeAmount({
129
- // Making sure we only have 2 decimals after comma
130
- amount: Number(this.amount.toFixed(2)),
131
- currency: this.currency,
132
- // Making sure Javascript doesnt give us back a float number
133
- // 1172.64 * 100 = 117264.00000000001 💩
134
- }).toFixed(0),
135
- )
136
-
137
- this.isNormalized = true
138
-
139
- return this
140
- }
139
+ this.amount = denormalizeAmount({
140
+ amount: this.amount,
141
+ currency: this.currency,
142
+ })
141
143
 
142
- public ceil(): this {
143
- this.amount = Math.ceil(this.amount)
144
+ this.isNormalized = false
144
145
 
145
146
  return this
146
147
  }
@@ -151,12 +152,6 @@ export class MoneyCalculator {
151
152
  return this
152
153
  }
153
154
 
154
- public round(): this {
155
- this.amount = Math.round(this.amount)
156
-
157
- return this
158
- }
159
-
160
155
  public format(locale?: string, space?: string): string {
161
156
  return formatAmount({
162
157
  amount: this.amount,
@@ -170,29 +165,34 @@ export class MoneyCalculator {
170
165
  return this.amount
171
166
  }
172
167
 
173
- public convert({
174
- currency,
175
- exchangeRate,
176
- }: {
177
- exchangeRate: number
178
- currency: CurrencyCode
179
- }): this {
180
- if (this.currency === currency || this.amount === 0) {
168
+ public markup(percentage: number): this {
169
+ this.amount /= 1 - percentage
170
+
171
+ return this
172
+ }
173
+
174
+ public normalize(): this {
175
+ if (this.isNormalized) {
181
176
  return this
182
177
  }
183
178
 
184
- const startingIsNormalized = this.isNormalized
179
+ this.amount = Number(
180
+ normalizeAmount({
181
+ // Making sure we only have 2 decimals after comma
182
+ amount: Number(this.amount.toFixed(2)),
183
+ currency: this.currency,
184
+ // Making sure Javascript doesnt give us back a float number
185
+ // 1172.64 * 100 = 117264.00000000001 💩
186
+ }).toFixed(0),
187
+ )
185
188
 
186
- if (startingIsNormalized) {
187
- this.denormalize()
188
- }
189
+ this.isNormalized = true
189
190
 
190
- this.amount *= exchangeRate
191
- this.currency = currency
191
+ return this
192
+ }
192
193
 
193
- if (startingIsNormalized) {
194
- this.normalize()
195
- }
194
+ public round(): this {
195
+ this.amount = Math.round(this.amount)
196
196
 
197
197
  return this
198
198
  }
@@ -5,12 +5,14 @@ import {
5
5
  BreakfastOption,
6
6
  HotelRoomOfferType,
7
7
  PackageType,
8
+ StayTaxesInfoEnum,
8
9
  } from '../constants/index.ts'
9
10
 
10
11
  import { CANCELLATION_POLICY_SCHEMA } from './cancellation-policies.ts'
11
12
  import { CURRENCY_SCHEMA } from './currency.ts'
12
13
  import { SOURCE_MARKET_SCHEMA } from './hotel-offer-request.ts'
13
14
  import { HOTEL_ROOMS_SCHEMA } from './hotel-room.ts'
15
+ import { LIST_POLLING_META_SCHEMA } from './list-polling-meta.ts'
14
16
  import { TAGS_SCHEMA } from './tag.ts'
15
17
  import { TAXES_SCHEMA } from './taxes.ts'
16
18
 
@@ -27,21 +29,17 @@ export const PACKAGE_TYPES_DESCRIPTION = `An **Hotel Room Offer** of type **${Ho
27
29
 
28
30
  export const HOTEL_ROOM_OFFER_SCHEMA = z
29
31
  .object({
30
- breakfast_count: z.number().min(0).optional().nullish().openapi({
32
+ breakfast_count: z.number().min(0).nullish().openapi({
31
33
  description:
32
34
  'Quantity of breakfast per night included in the given **Hotel Room Offer**',
33
35
  }),
34
36
  breakfast_option: z.enum(BreakfastOption).openapi({
35
37
  description: BREAKFAST_OPTION_DESCRIPTION,
36
38
  }),
37
- breakfast_price_per_guest_per_night: z
38
- .number()
39
- .optional()
40
- .nullish()
41
- .openapi({
42
- description:
43
- 'Price of breakfast per guest per night for the given **Hotel Room Offer**, expressed in the requested **currency**, when applicable.\n\n <div style="background-color: #ffffef; padding: 20px; border: 1px solid lightgrey; border-radius: 5px;"><b style="color: red; margin-top: 10px;">🛑 DEPRECATED.</b>\n\n <b style="color: orange;">Field renamed to "breakfast_unit_price"</div>',
44
- }),
39
+ breakfast_price_per_guest_per_night: z.number().nullish().openapi({
40
+ description:
41
+ 'Price of breakfast per guest per night for the given **Hotel Room Offer**, expressed in the requested **currency**, when applicable.\n\n <div style="background-color: #ffffef; padding: 20px; border: 1px solid lightgrey; border-radius: 5px;"><b style="color: red; margin-top: 10px;">🛑 DEPRECATED.</b>\n\n <b style="color: orange;">Field renamed to "breakfast_unit_price"</div>',
42
+ }),
45
43
  breakfast_unit_price: z.number().optional().nullish().openapi({
46
44
  description:
47
45
  'Price of breakfast per guest per night for the given **Hotel Room Offer**, expressed in the requested **currency**, when applicable.',
@@ -54,7 +52,6 @@ export const HOTEL_ROOM_OFFER_SCHEMA = z
54
52
  }),
55
53
  count: z
56
54
  .number()
57
- .optional()
58
55
  .nullish()
59
56
  .openapi({
60
57
  description: `When **type = ${HotelRoomOfferType.HotelRoom}**: this parameters represents the available quantity for the given **Hotel Room Offer**.
@@ -73,13 +70,15 @@ export const HOTEL_ROOM_OFFER_SCHEMA = z
73
70
  .openapi({
74
71
  description: PACKAGE_TYPES_DESCRIPTION,
75
72
  })
76
- .nullish()
77
- .optional(),
73
+ .nullish(),
78
74
  price: z.number().openapi({
79
75
  description:
80
76
  'Price with taxes NOT INCLUDED of the given **Hotel Room Offer** including breakfast(s) when applicable, expressed in the requested **currency**.',
81
77
  }),
82
78
  source_market: SOURCE_MARKET_SCHEMA,
79
+ stay_taxes_info: z
80
+ .enum(StayTaxesInfoEnum)
81
+ .openapi({ description: 'Either INCLUDED, NOT_INCLUDED or UNKNOWN' }),
83
82
  tags: TAGS_SCHEMA,
84
83
  tax_included_price: z.number().openapi({
85
84
  description: `Price of the given **Hotel Room Offer** including breakfast(s) when applicable, and including all taxes from returned **taxes** list parameter expressed in the requested **currency**.\n\nThis data is not returned for a **Hotel Room Offer** of type **${HotelRoomOfferType.HotelRoom}**, you'll need to compute and display the actual tax included price of the final **Hotel Room** package corresponding to the guest count and night count requested, or make a call to the **[Create Hotel Room Offer](/v1/documentation#operation/postV1Hotel_room_offers)** endpoint in order to get a valid and bookable **Hotel Room Offer** where **type = ${HotelRoomOfferType.Package}** based on a packaged list of **Hotel Room Offers** of type **${HotelRoomOfferType.HotelRoom}**.`,
@@ -90,10 +89,16 @@ export const HOTEL_ROOM_OFFER_SCHEMA = z
90
89
  .openapi({
91
90
  description: `Hotel Room Offer type.\n\n **Hotel Room Offers** with **type = "${HotelRoomOfferType.Package}"** are **Hotel Room Offers** that are already bookable and you'll be able to follow the next step of the **Booking Flow** calling **[Create Booking Policies endpoint](/v1/documentation#operation/postV1Booking_policies)**. \n\n Otherwise, you'll be able to create a new **Hotel Room Offer** with **type = "${HotelRoomOfferType.Package}"** from multiple **Hotel Room Offers** with **type = "${HotelRoomOfferType.HotelRoom}"**. See **[Create Hotel Room Offer endpoint](/v1/documentation#operation/postV1Hotel_room_offers)** for details.`,
92
91
  })
93
- .nullish()
94
92
  .optional(),
95
93
  })
96
94
  .openapi('hotelRoomOfferApi', {
97
95
  description: 'Description of the Hotel Room Offer.',
98
96
  })
97
+
98
+ export const HOTEL_ROOM_OFFERS_SCHEMA = z.array(HOTEL_ROOM_OFFER_SCHEMA)
99
+
100
+ export const HOTEL_ROOM_OFFERS_RESPONSE_SCHEMA = z.object({
101
+ data: HOTEL_ROOM_OFFERS_SCHEMA,
102
+ meta: LIST_POLLING_META_SCHEMA,
103
+ })
99
104
  /* eslint-enable camelcase */
@@ -57,10 +57,7 @@ export const HOTEL_ROOM_SCHEMA = z
57
57
  .openapi({ description: 'Whether high resolution images are available.' })
58
58
  .optional()
59
59
  .nullish(),
60
- id: z
61
- .string()
62
- .optional()
63
- .openapi({ description: 'Hotel Room id, when applicable.' }),
60
+ id: z.string().openapi({ description: 'Hotel Room id, when applicable.' }),
64
61
  image_indexes: z.array(z.number()).optional().nullish().openapi({
65
62
  description:
66
63
  'List of indexes corresponding to image names for the given Hotel Room among the related hotel images.',
@@ -6,11 +6,11 @@ export interface ICalendarRange<
6
6
  T extends ICalendarRangeDay = ICalendarRangeDay,
7
7
  U = Record<string, unknown> | undefined,
8
8
  > {
9
+ id: string
10
+ data: U
9
11
  dateFrom: string
10
12
  dateTo: string
11
13
  days: T[]
12
- data: U
13
- id: string
14
14
  name: string
15
15
  resourceId: string
16
16
  }
@@ -113,6 +113,12 @@ export interface Amenities {
113
113
  * @memberof Amenities
114
114
  */
115
115
  handicapAccessible?: boolean
116
+ /**
117
+ * Indoor pool.
118
+ * @type {boolean}
119
+ * @memberof Amenities
120
+ */
121
+ indoorPool?: boolean
116
122
  /**
117
123
  * In house bar.
118
124
  * @type {boolean}
@@ -131,12 +137,6 @@ export interface Amenities {
131
137
  * @memberof Amenities
132
138
  */
133
139
  inRoomMovies?: boolean
134
- /**
135
- * Indoor pool.
136
- * @type {boolean}
137
- * @memberof Amenities
138
- */
139
- indoorPool?: boolean
140
140
  /**
141
141
  * Interior room entrance.
142
142
  * @type {boolean}
@@ -216,17 +216,17 @@ export interface Amenities {
216
216
  */
217
217
  sauna?: boolean
218
218
  /**
219
- * TV in room.
219
+ * Tennis court.
220
220
  * @type {boolean}
221
221
  * @memberof Amenities
222
222
  */
223
- tVInRoom?: boolean
223
+ tennisCourt?: boolean
224
224
  /**
225
- * Tennis court.
225
+ * TV in room.
226
226
  * @type {boolean}
227
227
  * @memberof Amenities
228
228
  */
229
- tennisCourt?: boolean
229
+ tVInRoom?: boolean
230
230
  /**
231
231
  * 24/7 security.
232
232
  * @type {boolean}
@@ -3,6 +3,12 @@ import type { CurrencyType } from './currency.ts'
3
3
  import type { HotelRoomOffer } from './hotel-room-offer.ts'
4
4
 
5
5
  export interface BookingPolicies {
6
+ /**
7
+ * **Booking Policy** id
8
+ * @type {string}
9
+ * @memberof BookingPolicies
10
+ */
11
+ id: string
6
12
  /**
7
13
  * The total number of adults who will be staying in the property.
8
14
  * @type {number}
@@ -39,6 +45,7 @@ export interface BookingPolicies {
39
45
  * @memberof BookingPolicies
40
46
  */
41
47
  currency: CurrencyType
48
+
42
49
  /**
43
50
  * Expiration date for this **Booking Policy**.
44
51
  *
@@ -47,7 +54,6 @@ export interface BookingPolicies {
47
54
  * @memberof BookingPolicies
48
55
  */
49
56
  expiresAt: string | null
50
-
51
57
  hasRoomingLists: boolean
52
58
  /**
53
59
  * Hotel id
@@ -61,12 +67,6 @@ export interface BookingPolicies {
61
67
  * @memberof BookingPolicies
62
68
  */
63
69
  hotelRoomOffer: HotelRoomOffer
64
- /**
65
- * **Booking Policy** id
66
- * @type {string}
67
- * @memberof BookingPolicies
68
- */
69
- id: string
70
70
  /**
71
71
  * Indicates whether the price of the **Hotel Room Offer** (without breakfast included) has increased compared to the price returned by [Retrieve Hotel Room Offers endpoint](/v1/documentation#operation/getV1Hotel_room_offers).
72
72
  *
@@ -10,6 +10,12 @@ import type { SourceMarket } from './source-market.ts'
10
10
  import type { Tax } from './tax.ts'
11
11
 
12
12
  export interface Booking {
13
+ /**
14
+ * Booking Id
15
+ * @type {string}
16
+ * @memberof Booking
17
+ */
18
+ id?: string | null
13
19
  /**
14
20
  * The total number of adults who will be staying in the property.
15
21
  * @type {number}
@@ -100,12 +106,6 @@ export interface Booking {
100
106
  * @memberof Booking
101
107
  */
102
108
  hotelId: string
103
- /**
104
- *
105
- * @type {HotelRoomOffer}
106
- * @memberof Booking
107
- */
108
- hotelRoomOffer: HotelRoomOffer
109
109
  /**
110
110
  * Hotel rooming lists of a hotel booking
111
111
  * @type {Array<HotelRoomingList>}
@@ -113,11 +113,11 @@ export interface Booking {
113
113
  */
114
114
  hotelRoomingLists?: HotelRoomingList[]
115
115
  /**
116
- * Booking Id
117
- * @type {string}
116
+ *
117
+ * @type {HotelRoomOffer}
118
118
  * @memberof Booking
119
119
  */
120
- id?: string | null
120
+ hotelRoomOffer: HotelRoomOffer
121
121
  /**
122
122
  * The list of invoices and credit notes (when applicable) direct urls associated to the Booking.
123
123
  * @type {Array<InvoiceApi>}
@@ -184,18 +184,18 @@ export interface Booking {
184
184
  * @memberof Booking
185
185
  */
186
186
  taxAmount: number
187
- /**
188
- * Price of the booking including taxes expressed in the booking currency.
189
- * @type {number}
190
- * @memberof Booking
191
- */
192
- taxIncludedPrice: number
193
187
  /**
194
188
  *
195
189
  * @type {Array<Tax>}
196
190
  * @memberof Booking
197
191
  */
198
192
  taxes?: Tax[] | null
193
+ /**
194
+ * Price of the booking including taxes expressed in the booking currency.
195
+ * @type {number}
196
+ * @memberof Booking
197
+ */
198
+ taxIncludedPrice: number
199
199
  /**
200
200
  * Link to Revolugo terms and conditions under which the booking is made.
201
201
  * @type {string}
@@ -167,4 +167,11 @@ export interface PrebookFormValues {
167
167
  phoneNumber: string
168
168
  salutation: ContactPerson['salutation']
169
169
  specialRequests: ContactPerson['remarks']
170
+ organizationAddress?: string
171
+ organizationCity?: string
172
+ organizationCountry?: string
173
+ organizationName?: string
174
+ organizationState?: string
175
+ organizationVatNumber?: string
176
+ organizationZipCode?: string
170
177
  }
@@ -1,22 +1,22 @@
1
1
  export interface EventMetadata {
2
2
  /**
3
- * End date of the event formatted as YYYY-MM-DD.
3
+ * Unique id of the event
4
4
  * @type {string}
5
5
  * @memberof EventMetadata
6
6
  */
7
- dateEnd?: string
7
+ id?: string
8
8
  /**
9
- * Start date of the event formatted as YYYY-MM-DD.
9
+ * End date of the event formatted as YYYY-MM-DD.
10
10
  * @type {string}
11
11
  * @memberof EventMetadata
12
12
  */
13
- dateStart?: string
13
+ dateEnd?: string
14
14
  /**
15
- * Unique id of the event
15
+ * Start date of the event formatted as YYYY-MM-DD.
16
16
  * @type {string}
17
17
  * @memberof EventMetadata
18
18
  */
19
- id?: string
19
+ dateStart?: string
20
20
  /**
21
21
  * Image URL of the event
22
22
  * @type {string}
@@ -12,11 +12,11 @@ export type HotelOffersSortByOrderType = `${HotelOffersSortByOrderEnum}`
12
12
 
13
13
  export interface HotelOffersListPayload {
14
14
  currency: CurrencyType
15
- hotelOfferRequestId: string
16
15
  endingBefore?: string | null
17
16
  filterByPrice?: string
18
17
  filterByReviewRating?: number
19
18
  filterByStar?: string
19
+ hotelOfferRequestId: string
20
20
  hotelRoomOffersLimit?: number
21
21
  includeHotelContentDetails?: boolean | null
22
22
  lang?: Locale
@@ -2,6 +2,11 @@ import type { EventMetadata } from './event-metadata.ts'
2
2
  import type { SourceMarket } from './source-market.ts'
3
3
 
4
4
  export interface HotelOfferRequest {
5
+ /**
6
+ * id of the **Hotel Offer Request**
7
+ * @type {string}
8
+ */
9
+ id: string
5
10
  /**
6
11
  * This endpoint allows to find the geo-coordinates of a known address, place or locality via this free-text address query field. This address will eventually be geocoded into a latitude/longitude pair.
7
12
  *
@@ -29,6 +34,12 @@ export interface HotelOfferRequest {
29
34
  * @type {string}
30
35
  */
31
36
  children?: string | null
37
+ /**
38
+ * Date of the **Hotel Room Offer Request** creation
39
+ * @type {string}
40
+ * @memberof HotelOfferRequestApiResponse
41
+ */
42
+ createdAt: string
32
43
  /**
33
44
  *
34
45
  * @type {EventMetadata}
@@ -60,20 +71,15 @@ export interface HotelOfferRequest {
60
71
  * @type {SourceMarket}
61
72
  */
62
73
  sourceMarket: SourceMarket
63
- /**
64
- * Date of the **Hotel Room Offer Request** creation
65
- * @type {string}
66
- * @memberof HotelOfferRequestApiResponse
67
- */
68
- createdAt: string
74
+ }
75
+
76
+ export interface HotelOfferRequestResponse {
69
77
  /**
70
78
  * id of the **Hotel Offer Request**
71
79
  * @type {string}
80
+ * @memberof HotelOfferRequestApiResponse
72
81
  */
73
82
  id: string
74
- }
75
-
76
- export interface HotelOfferRequestResponse {
77
83
  /**
78
84
  * This endpoint allows to find the geo-coordinates of a known address, place or locality via this free-text address query field. This address will eventually be geocoded into a latitude/longitude pair.
79
85
  *
@@ -106,6 +112,12 @@ export interface HotelOfferRequestResponse {
106
112
  * @memberof HotelOfferRequestApiResponse
107
113
  */
108
114
  children?: string | null
115
+ /**
116
+ * Date of the **Hotel Offer Request** creation
117
+ * @type {string}
118
+ * @memberof HotelOfferRequestApiResponse
119
+ */
120
+ createdAt: string
109
121
  /**
110
122
  *
111
123
  * @type {EventMetadataApi}
@@ -142,18 +154,6 @@ export interface HotelOfferRequestResponse {
142
154
  * @memberof HotelOfferRequestApiResponse
143
155
  */
144
156
  sourceMarket: SourceMarket
145
- /**
146
- * Date of the **Hotel Offer Request** creation
147
- * @type {string}
148
- * @memberof HotelOfferRequestApiResponse
149
- */
150
- createdAt: string
151
- /**
152
- * id of the **Hotel Offer Request**
153
- * @type {string}
154
- * @memberof HotelOfferRequestApiResponse
155
- */
156
- id: string
157
157
  }
158
158
 
159
159
  export interface HotelOfferRequestCreate {
@@ -9,6 +9,12 @@ import type { TravelTimeItem } from './travel-times.ts'
9
9
  import type { CurrencyCode } from '../../currencies/constants.ts'
10
10
 
11
11
  export interface HotelOffer {
12
+ /**
13
+ * Hotel id.
14
+ * @type {string}
15
+ * @memberof HotelOffer
16
+ */
17
+ id: string
12
18
  /**
13
19
  * Hotel address.
14
20
  * @type {string}
@@ -102,11 +108,11 @@ export interface HotelOffer {
102
108
  */
103
109
  hotelReviewRatings?: HotelReviewRating[] | null
104
110
  /**
105
- * Hotel id.
106
- * @type {string}
111
+ *
112
+ * @type {Array<HotelRoomOffer>}
107
113
  * @memberof HotelOffer
108
114
  */
109
- id: string
115
+ hotelRoomOffers: HotelRoomOffer[]
110
116
  /**
111
117
  *
112
118
  * @type {HotelImages}
@@ -162,6 +168,12 @@ export interface HotelOffer {
162
168
  * @memberof HotelOffer
163
169
  */
164
170
  state?: string | null
171
+ /**
172
+ *
173
+ * @type {Array<Tag>}
174
+ * @memberof HotelOffer
175
+ */
176
+ tags?: Tag[]
165
177
  /**
166
178
  * TripAdvisor property id. When applicable.
167
179
  * @type {string}
@@ -186,18 +198,6 @@ export interface HotelOffer {
186
198
  * @memberof HotelOffer
187
199
  */
188
200
  website?: string | null
189
- /**
190
- *
191
- * @type {Array<HotelRoomOffer>}
192
- * @memberof HotelOffer
193
- */
194
- hotelRoomOffers: HotelRoomOffer[]
195
- /**
196
- *
197
- * @type {Array<Tag>}
198
- * @memberof HotelOffer
199
- */
200
- tags?: Tag[]
201
201
  }
202
202
 
203
203
  export enum HotelOffersSortByEnum {
@@ -9,9 +9,9 @@ export enum FilterName {
9
9
  }
10
10
 
11
11
  export interface HotelOffersFilters {
12
+ [FilterName.Price]: [number, number]
12
13
  [FilterName.Rating]: string
13
14
  [FilterName.ReviewRating]?: number
14
- [FilterName.Price]: [number, number]
15
15
  [FilterName.SortBy]: {
16
16
  direction: HotelOffersSortByOrderType
17
17
  value: HotelOffersSortByEnum
@@ -2,6 +2,12 @@ import type { EventMetadata } from './event-metadata.ts'
2
2
  import type { SourceMarket } from './source-market.ts'
3
3
 
4
4
  export interface HotelRoomOfferRequest {
5
+ /**
6
+ * id of the **Hotel Room Offer Request**
7
+ * @type {string}
8
+ * @memberof HotelRoomOfferRequest
9
+ */
10
+ id: string
5
11
  /**
6
12
  * Requested number of adult(s) to be accommodated.
7
13
  * @type {number}
@@ -26,6 +32,12 @@ export interface HotelRoomOfferRequest {
26
32
  * @memberof HotelRoomOfferRequest
27
33
  */
28
34
  children?: string | null
35
+ /**
36
+ * Date of the **Hotel Room Offer Request** creation
37
+ * @type {string}
38
+ * @memberof HotelRoomOfferRequest
39
+ */
40
+ createdAt: string
29
41
  /**
30
42
  *
31
43
  * @type {EventMetadata}
@@ -50,21 +62,15 @@ export interface HotelRoomOfferRequest {
50
62
  * @memberof HotelRoomOfferRequest
51
63
  */
52
64
  sourceMarket: SourceMarket
53
- /**
54
- * Date of the **Hotel Room Offer Request** creation
55
- * @type {string}
56
- * @memberof HotelRoomOfferRequest
57
- */
58
- createdAt: string
65
+ }
66
+
67
+ export interface HotelRoomOfferRequestResponse {
59
68
  /**
60
69
  * id of the **Hotel Room Offer Request**
61
70
  * @type {string}
62
- * @memberof HotelRoomOfferRequest
71
+ * @memberof HotelRoomOfferRequestApiResponse
63
72
  */
64
73
  id: string
65
- }
66
-
67
- export interface HotelRoomOfferRequestResponse {
68
74
  /**
69
75
  * Requested number of adult(s) to be accommodated.
70
76
  * @type {number}
@@ -89,6 +95,12 @@ export interface HotelRoomOfferRequestResponse {
89
95
  * @memberof HotelRoomOfferRequestApiResponse
90
96
  */
91
97
  children?: string | null
98
+ /**
99
+ * Date of the **Hotel Room Offer Request** creation
100
+ * @type {string}
101
+ * @memberof HotelRoomOfferRequestApiResponse
102
+ */
103
+ createdAt: string
92
104
  /**
93
105
  *
94
106
  * @type {EventMetadataApi}
@@ -113,18 +125,6 @@ export interface HotelRoomOfferRequestResponse {
113
125
  * @memberof HotelRoomOfferRequestApiResponse
114
126
  */
115
127
  sourceMarket: SourceMarket
116
- /**
117
- * Date of the **Hotel Room Offer Request** creation
118
- * @type {string}
119
- * @memberof HotelRoomOfferRequestApiResponse
120
- */
121
- createdAt: string
122
- /**
123
- * id of the **Hotel Room Offer Request**
124
- * @type {string}
125
- * @memberof HotelRoomOfferRequestApiResponse
126
- */
127
- id: string
128
128
  }
129
129
 
130
130
  export type HotelRoomOfferRequestCreate = Pick<
@@ -70,6 +70,12 @@ export interface HotelRoomOffersDataResponse {
70
70
  * @interface HotelRoomOffer
71
71
  */
72
72
  export interface HotelRoomOffer {
73
+ /**
74
+ * Hotel Room Offer id.
75
+ * @type {string}
76
+ * @memberof HotelRoomOffer
77
+ */
78
+ id?: string
73
79
  /**
74
80
  * Quantity of breakfast per night included in the given **Hotel Room Offer**
75
81
  * @type {number}
@@ -138,12 +144,6 @@ export interface HotelRoomOffer {
138
144
  * @memberof HotelRoomOffer
139
145
  */
140
146
  hotelRooms: HotelRoom[]
141
- /**
142
- * Hotel Room Offer id.
143
- * @type {string}
144
- * @memberof HotelRoomOffer
145
- */
146
- id?: string
147
147
  /**
148
148
  * An **Hotel Room Offer** of type **PACKAGE** can be of **4 types**, described by **package_type** parameter:
149
149
  *
@@ -157,7 +157,7 @@ export interface HotelRoomOffer {
157
157
  * @type {string}
158
158
  * @memberof HotelRoomOffer
159
159
  */
160
- packageType?: HotelRoomOfferPackageType
160
+ packageType?: HotelRoomOfferPackageType | null
161
161
  /**
162
162
  * Price with taxes NOT INCLUDED of the given **Hotel Room Offer** including breakfast(s) when applicable, expressed in the requested **currency**.
163
163
  * @type {number}
@@ -172,18 +172,16 @@ export interface HotelRoomOffer {
172
172
  sourceMarket: SourceMarket
173
173
  /**
174
174
  *
175
- * @type {Array<Tag>}
175
+ * @type {StayTaxesInfo}
176
176
  * @memberof HotelRoomOffer
177
177
  */
178
- tags?: Tag[]
178
+ stayTaxesInfo: StayTaxesInfo
179
179
  /**
180
- * Price of the given **Hotel Room Offer** including breakfast(s) when applicable, and including all taxes from returned **taxes** list parameter expressed in the requested **currency**.
181
180
  *
182
- * This data is not returned for a **Hotel Room Offer** of type **HOTEL_ROOM**, you'll need to compute and display the actual tax included price of the final **Hotel Room** package corresponding to the guest count and night count requested, or make a call to the **[Create Hotel Room Offer](/v1/documentation#operation/postV1Hotel_room_offers)** endpoint in order to get a valid and bookable **Hotel Room Offer** where **type = PACKAGE** based on a packaged list of **Hotel Room Offers** of type **HOTEL_ROOM**.
183
- * @type {number}
181
+ * @type {Array<Tag>}
184
182
  * @memberof HotelRoomOffer
185
183
  */
186
- taxIncludedPrice: number
184
+ tags?: Tag[]
187
185
  /**
188
186
  *
189
187
  * @type {Array<Tax>}
@@ -192,11 +190,13 @@ export interface HotelRoomOffer {
192
190
  taxes?: Tax[]
193
191
 
194
192
  /**
193
+ * Price of the given **Hotel Room Offer** including breakfast(s) when applicable, and including all taxes from returned **taxes** list parameter expressed in the requested **currency**.
195
194
  *
196
- * @type {StayTaxesInfo}
195
+ * This data is not returned for a **Hotel Room Offer** of type **HOTEL_ROOM**, you'll need to compute and display the actual tax included price of the final **Hotel Room** package corresponding to the guest count and night count requested, or make a call to the **[Create Hotel Room Offer](/v1/documentation#operation/postV1Hotel_room_offers)** endpoint in order to get a valid and bookable **Hotel Room Offer** where **type = PACKAGE** based on a packaged list of **Hotel Room Offers** of type **HOTEL_ROOM**.
196
+ * @type {number}
197
197
  * @memberof HotelRoomOffer
198
198
  */
199
- stayTaxesInfo: StayTaxesInfo
199
+ taxIncludedPrice: number
200
200
 
201
201
  /**
202
202
  * Hotel Room Offer type.
@@ -2,6 +2,12 @@ import type { Bed } from './bed.ts'
2
2
  import type { HotelImage } from './hotel-image.ts'
3
3
 
4
4
  export interface HotelRoom {
5
+ /**
6
+ * Hotel Room id, when applicable.
7
+ * @type {string}
8
+ * @memberof HotelRoom
9
+ */
10
+ id: string
5
11
  /**
6
12
  * List of amenities in the room. May be subject to changes at the Hotel.
7
13
  * @type {Array<string>}
@@ -52,12 +58,6 @@ export interface HotelRoom {
52
58
  * @memberof HotelRoom
53
59
  */
54
60
  highresImages?: boolean | null
55
- /**
56
- * Hotel Room id, when applicable.
57
- * @type {string}
58
- * @memberof HotelRoom
59
- */
60
- id: string
61
61
  /**
62
62
  * List of indexes corresponding to image names for the given Hotel Room among the related hotel images.
63
63
  * @type {Array<number>}
@@ -6,16 +6,22 @@ export interface HotelRoomingListGuest {
6
6
  * @type {string}
7
7
  * @memberof HotelRoomingListGuest
8
8
  */
9
- fullname: string
9
+ id: string
10
10
  /**
11
11
  *
12
12
  * @type {string}
13
13
  * @memberof HotelRoomingListGuest
14
14
  */
15
- id: string
15
+ fullname: string
16
16
  }
17
17
 
18
18
  export interface HotelRoomingList {
19
+ /**
20
+ *
21
+ * @type {string}
22
+ * @memberof HotelRoomingList
23
+ */
24
+ id: string
19
25
  /**
20
26
  *
21
27
  * @type {HotelRoom}
@@ -34,12 +40,6 @@ export interface HotelRoomingList {
34
40
  * @memberof HotelRoomingList
35
41
  */
36
42
  hotelRoomingListGuests: HotelRoomingListGuest[]
37
- /**
38
- *
39
- * @type {string}
40
- * @memberof HotelRoomingList
41
- */
42
- id: string
43
43
  /**
44
44
  *
45
45
  * @type {string}
@@ -6,6 +6,12 @@ import type { HotelReviewRating } from './hotel-review-rating.ts'
6
6
  import type { TravelTimeItem } from './travel-times.ts'
7
7
 
8
8
  export interface Hotel {
9
+ /**
10
+ * Hotel id.
11
+ * @type {string}
12
+ * @memberof HotelApi
13
+ */
14
+ id: string
9
15
  /**
10
16
  * Hotel address.
11
17
  * @type {string}
@@ -96,12 +102,6 @@ export interface Hotel {
96
102
  * @memberof HotelApi
97
103
  */
98
104
  hotelReviewRatings?: HotelReviewRating[] | null
99
- /**
100
- * Hotel id.
101
- * @type {string}
102
- * @memberof HotelApi
103
- */
104
- id: string
105
105
  /**
106
106
  *
107
107
  * @type {HotelImages}
@@ -22,16 +22,16 @@ export interface MetaPollingResponse {
22
22
  * @memberof MetaApiPollingResponse
23
23
  */
24
24
  startingAfter?: string | null
25
- /**
26
- *
27
- * @type {number}
28
- * @memberof HotelOffersApiResponseMeta
29
- */
30
- totalCount?: number | null
31
25
  /**
32
26
  *
33
27
  * @type {PollerType}
34
28
  * @memberof MetaApiPollingResponse
35
29
  */
36
30
  status: PollerType
31
+ /**
32
+ *
33
+ * @type {number}
34
+ * @memberof HotelOffersApiResponseMeta
35
+ */
36
+ totalCount?: number | null
37
37
  }
@@ -1,7 +1,7 @@
1
1
  export interface IEvent {
2
+ id: string
2
3
  eventDateFrom?: Date
3
4
  eventDateTo?: Date
4
- id: string
5
5
  name: string
6
6
  slug: string
7
7
  }
@@ -1,13 +1,13 @@
1
1
  import type { IHotelRoomStock } from './hotel-room-stock.ts'
2
2
 
3
3
  export interface IHotelContract {
4
+ id: string
4
5
  createdAt: string
5
6
  forcedTotalComissionsAmount: number
6
7
  forcedTotalPurchasedAmount: number
7
8
  forcedTotalVatComissionsAmount: number
8
9
  hotelId: string
9
10
  hotelRoomStocks?: IHotelRoomStock[]
10
- id: string
11
11
  name: string
12
12
  status: string
13
13
  updatedAt: string
@@ -1,6 +1,7 @@
1
1
  import type { BreakfastOption } from '../constants/hotel.ts'
2
2
 
3
3
  export interface IHotelRoomStock {
4
+ id?: string
4
5
  breakfastOption: BreakfastOption
5
6
  breakfastRetrocommission?: number
6
7
  breakfastUnitPrice?: number
@@ -9,7 +10,6 @@ export interface IHotelRoomStock {
9
10
  eventScoped: boolean
10
11
  hotelContractId?: string
11
12
  hotelRoomId: string
12
- id?: string
13
13
  marginRate: number
14
14
  minNightCount?: number
15
15
  rate: number
@@ -17,10 +17,10 @@ export interface IPaginationOptions {
17
17
  }
18
18
 
19
19
  export interface IPaginationPageInfo {
20
+ endCursor: string | null
20
21
  hasNextPage: boolean
21
22
  hasPreviousPage: boolean
22
23
  startCursor: string | null
23
- endCursor: string | null
24
24
  totalCount: number
25
25
  }
26
26
 
@@ -30,8 +30,8 @@ export interface IPaginationEdge<T> {
30
30
  }
31
31
 
32
32
  export interface IPaginationConnection<T> {
33
- pageInfo: IPaginationPageInfo
34
33
  edges: IPaginationEdge<T>[]
34
+ pageInfo: IPaginationPageInfo
35
35
  }
36
36
 
37
37
  export enum PaginationException {
@@ -1,7 +1,7 @@
1
1
  interface CompositeLeafAttributes {
2
2
  excludedTokens?: string[]
3
- removeSplitCharacters?: boolean
4
3
  parentKey?: string
4
+ removeSplitCharacters?: boolean
5
5
  }
6
6
 
7
7
  export enum CompositeAttributesType {
@@ -17,7 +17,6 @@ type CompositeKeyOptions<T> =
17
17
  ? CompositeKeyOptions<U>
18
18
  : CompositeLeafAttributes & {
19
19
  attributes: CompositeOmitAttributes<T> | CompositeAttributesType
20
- sort?: (keyof T)[]
21
20
  children?: {
22
21
  [K in keyof T]?: NonNullable<T[K]> extends object
23
22
  ? CompositeKeyOptions<NonNullable<T[K]>>
@@ -25,6 +24,7 @@ type CompositeKeyOptions<T> =
25
24
  ? CompositeKeyOptions<U>
26
25
  : CompositeLeafAttributes
27
26
  }
27
+ sort?: (keyof T)[]
28
28
  }
29
29
 
30
30
  export function createCompositeKey<T>(
@@ -17,8 +17,8 @@ export interface DebouncedFunction<
17
17
  }
18
18
 
19
19
  interface DebouncedPromise<FunctionReturn> {
20
- resolve: (result: FunctionReturn) => void
21
20
  reject: (reason?: any) => void
21
+ resolve: (result: FunctionReturn) => void
22
22
  }
23
23
 
24
24
  export function debounce<Args extends any[], F extends (...args: Args) => any>(
@@ -6,8 +6,8 @@ export function getSanitizedRoomCount({
6
6
  roomCount,
7
7
  }: {
8
8
  adultCount: number
9
- roomCount: number
10
9
  maxAdultsPerRoom?: number
10
+ roomCount: number
11
11
  }): number {
12
12
  // Ensure at least enough rooms for each adult and at most MAX_ADULTS_PER_ROOM per room
13
13
  if (!Number.isFinite(roomCount) || roomCount < 1) {
@@ -45,13 +45,14 @@ export class Poller<V extends IPollerResponse> {
45
45
  minCallCount: 1,
46
46
  }
47
47
 
48
- private pollings: Record<string, string> = {}
49
48
  private events: TPollerEvents<V> = {
50
49
  complete: () => undefined,
51
50
  data: () => undefined,
52
51
  error: () => undefined,
53
52
  }
54
53
 
54
+ private pollings: Record<string, string> = {}
55
+
55
56
  static getInstance<R extends IPollerResponse>(): Poller<R> {
56
57
  if (!Poller.instance) {
57
58
  Poller.instance = new Poller<R>() as Poller<IPollerResponse>
@@ -60,6 +61,13 @@ export class Poller<V extends IPollerResponse> {
60
61
  return Poller.instance as Poller<R>
61
62
  }
62
63
 
64
+ on(
65
+ eventName: TPollerEventName,
66
+ eventCallback: TPollerEventCallback<V>,
67
+ ): void {
68
+ this.events[eventName] = eventCallback
69
+ }
70
+
63
71
  poll(request: TRequest<V>, options: TOptions<V>): Poller<V> {
64
72
  const buildedOptions = this.buildPollerOptions(options)
65
73
  this.storeCurrentPolling(buildedOptions)
@@ -75,13 +83,6 @@ export class Poller<V extends IPollerResponse> {
75
83
  return this
76
84
  }
77
85
 
78
- on(
79
- eventName: TPollerEventName,
80
- eventCallback: TPollerEventCallback<V>,
81
- ): void {
82
- this.events[eventName] = eventCallback
83
- }
84
-
85
86
  public stop(type: string): void {
86
87
  if (type && this.pollings[type]) {
87
88
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
@@ -89,6 +90,25 @@ export class Poller<V extends IPollerResponse> {
89
90
  }
90
91
  }
91
92
 
93
+ private buildPollerOptions(options: TOptions<V>): TOptions<V> {
94
+ const compactedOptions = Object.entries(options).reduce<
95
+ Record<string, unknown>
96
+ >((acc, [key, value]) => {
97
+ if (value !== undefined) {
98
+ const tKey = key as keyof TOptions<V>
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ acc[tKey] = value as any
101
+ }
102
+
103
+ return acc
104
+ }, {}) as TOptions<V>
105
+
106
+ return {
107
+ ...this.defaultOptions,
108
+ ...compactedOptions,
109
+ }
110
+ }
111
+
92
112
  private dispatch(
93
113
  eventName: TPollerEventName,
94
114
  payload?: TPollerEventCallbackArg<V>,
@@ -96,6 +116,27 @@ export class Poller<V extends IPollerResponse> {
96
116
  this.events[eventName](payload)
97
117
  }
98
118
 
119
+ private isActivePoller(options: TOptions<V>): boolean {
120
+ if (options.type) {
121
+ return (
122
+ !!this.pollings[options.type] &&
123
+ this.pollings[options.type] === options.uuid
124
+ )
125
+ }
126
+
127
+ return true
128
+ }
129
+
130
+ private isInProgress(result: V): boolean {
131
+ return (result?.meta?.status ?? '') !== 'COMPLETE'
132
+ }
133
+
134
+ private onComplete(result: V, options: TOptions<V>) {
135
+ this.dispatch('data', result)
136
+ this.dispatch('complete', result)
137
+ this.removeCurrentPolling(options)
138
+ }
139
+
99
140
  private async onRequest(
100
141
  result: V,
101
142
  request: TRequest<V>,
@@ -148,53 +189,6 @@ export class Poller<V extends IPollerResponse> {
148
189
  }
149
190
  }
150
191
 
151
- private onComplete(result: V, options: TOptions<V>) {
152
- this.dispatch('data', result)
153
- this.dispatch('complete', result)
154
- this.removeCurrentPolling(options)
155
- }
156
-
157
- private isInProgress(result: V): boolean {
158
- return (result?.meta?.status ?? '') !== 'COMPLETE'
159
- }
160
-
161
- private buildPollerOptions(options: TOptions<V>): TOptions<V> {
162
- const compactedOptions = Object.entries(options).reduce<
163
- Record<string, unknown>
164
- >((acc, [key, value]) => {
165
- if (value !== undefined) {
166
- const tKey = key as keyof TOptions<V>
167
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
- acc[tKey] = value as any
169
- }
170
-
171
- return acc
172
- }, {}) as TOptions<V>
173
-
174
- return {
175
- ...this.defaultOptions,
176
- ...compactedOptions,
177
- }
178
- }
179
-
180
- private storeCurrentPolling(options: TOptions<V>): void {
181
- if (options.type && !options.uuid) {
182
- options.uuid = uuidv4()
183
- this.pollings[options.type] = options.uuid
184
- }
185
- }
186
-
187
- private isActivePoller(options: TOptions<V>): boolean {
188
- if (options.type) {
189
- return (
190
- !!this.pollings[options.type] &&
191
- this.pollings[options.type] === options.uuid
192
- )
193
- }
194
-
195
- return true
196
- }
197
-
198
192
  private pause(options: TOptions<V>): Promise<void> {
199
193
  return new Promise(resolve => {
200
194
  setTimeout(resolve, options.interval)
@@ -207,6 +201,13 @@ export class Poller<V extends IPollerResponse> {
207
201
  delete this.pollings[options.type]
208
202
  }
209
203
  }
204
+
205
+ private storeCurrentPolling(options: TOptions<V>): void {
206
+ if (options.type && !options.uuid) {
207
+ options.uuid = uuidv4()
208
+ this.pollings[options.type] = options.uuid
209
+ }
210
+ }
210
211
  }
211
212
 
212
213
  export type PollerReturn<R extends IPollerResponse = IPollerResponse> =