@revolugo/common 7.0.0-alpha.16 → 7.0.0-alpha.17
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 +1 -1
- package/src/cancellation-policies.ts +2 -2
- package/src/currencies/types.ts +1 -1
- package/src/currencies/utils.ts +52 -52
- package/src/types/calendar.ts +2 -2
- package/src/types/elements/amenity.ts +10 -10
- package/src/types/elements/booking-policy.ts +7 -7
- package/src/types/elements/booking.ts +15 -15
- package/src/types/elements/event-metadata.ts +6 -6
- package/src/types/elements/hotel-offer-list.ts +1 -1
- package/src/types/elements/hotel-offer-request.ts +21 -21
- package/src/types/elements/hotel-offer.ts +15 -15
- package/src/types/elements/hotel-offers-filters.ts +1 -1
- package/src/types/elements/hotel-room-offer-request.ts +22 -22
- package/src/types/elements/hotel-room-offer.ts +14 -14
- package/src/types/elements/hotel-room.ts +6 -6
- package/src/types/elements/hotel-rooming-list.ts +8 -8
- package/src/types/elements/hotel.ts +6 -6
- package/src/types/elements/meta-polling.ts +6 -6
- package/src/types/event.ts +1 -1
- package/src/types/hotel-contract.ts +1 -1
- package/src/types/hotel-room-stock.ts +1 -1
- package/src/types/pagination.ts +2 -2
- package/src/utils/create-composite-key.ts +2 -2
- package/src/utils/debounce.ts +1 -1
- package/src/utils/get-sanitized-room-count.ts +1 -1
- package/src/utils/poller.ts +56 -55
package/package.json
CHANGED
|
@@ -452,10 +452,10 @@ export function getSanitizedCancellationPolicies({
|
|
|
452
452
|
initialDate,
|
|
453
453
|
timezone,
|
|
454
454
|
}: {
|
|
455
|
-
checkInDate: string
|
|
456
455
|
cancellationPolicies: ICancellationPolicy[]
|
|
457
|
-
|
|
456
|
+
checkInDate: string
|
|
458
457
|
initialDate?: string
|
|
458
|
+
timezone?: string
|
|
459
459
|
}): ICancellationPolicy[] {
|
|
460
460
|
if (!cancellationPolicies.length) {
|
|
461
461
|
return []
|
package/src/currencies/types.ts
CHANGED
|
@@ -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
|
}
|
package/src/currencies/utils.ts
CHANGED
|
@@ -98,49 +98,50 @@ export class MoneyCalculator {
|
|
|
98
98
|
this.isNormalized = isNormalized
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
public
|
|
102
|
-
|
|
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
|
-
|
|
107
|
-
amount: this.amount,
|
|
108
|
-
currency: this.currency,
|
|
109
|
-
})
|
|
118
|
+
const startingIsNormalized = this.isNormalized
|
|
110
119
|
|
|
111
|
-
|
|
120
|
+
if (startingIsNormalized) {
|
|
121
|
+
this.denormalize()
|
|
122
|
+
}
|
|
112
123
|
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
this.amount *= exchangeRate
|
|
125
|
+
this.currency = currency
|
|
115
126
|
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
if (startingIsNormalized) {
|
|
128
|
+
this.normalize()
|
|
129
|
+
}
|
|
118
130
|
|
|
119
131
|
return this
|
|
120
132
|
}
|
|
121
133
|
|
|
122
|
-
public
|
|
123
|
-
if (this.isNormalized) {
|
|
134
|
+
public denormalize(): this {
|
|
135
|
+
if (!this.isNormalized) {
|
|
124
136
|
return this
|
|
125
137
|
}
|
|
126
138
|
|
|
127
|
-
this.amount =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
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
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (this.
|
|
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
|
-
|
|
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
|
-
|
|
187
|
-
this.denormalize()
|
|
188
|
-
}
|
|
189
|
+
this.isNormalized = true
|
|
189
190
|
|
|
190
|
-
this
|
|
191
|
-
|
|
191
|
+
return this
|
|
192
|
+
}
|
|
192
193
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
194
|
+
public round(): this {
|
|
195
|
+
this.amount = Math.round(this.amount)
|
|
196
196
|
|
|
197
197
|
return this
|
|
198
198
|
}
|
package/src/types/calendar.ts
CHANGED
|
@@ -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
|
-
*
|
|
219
|
+
* Tennis court.
|
|
220
220
|
* @type {boolean}
|
|
221
221
|
* @memberof Amenities
|
|
222
222
|
*/
|
|
223
|
-
|
|
223
|
+
tennisCourt?: boolean
|
|
224
224
|
/**
|
|
225
|
-
*
|
|
225
|
+
* TV in room.
|
|
226
226
|
* @type {boolean}
|
|
227
227
|
* @memberof Amenities
|
|
228
228
|
*/
|
|
229
|
-
|
|
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
|
-
*
|
|
117
|
-
* @type {
|
|
116
|
+
*
|
|
117
|
+
* @type {HotelRoomOffer}
|
|
118
118
|
* @memberof Booking
|
|
119
119
|
*/
|
|
120
|
-
|
|
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}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
export interface EventMetadata {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Unique id of the event
|
|
4
4
|
* @type {string}
|
|
5
5
|
* @memberof EventMetadata
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
id?: string
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* End date of the event formatted as YYYY-MM-DD.
|
|
10
10
|
* @type {string}
|
|
11
11
|
* @memberof EventMetadata
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
dateEnd?: string
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Start date of the event formatted as YYYY-MM-DD.
|
|
16
16
|
* @type {string}
|
|
17
17
|
* @memberof EventMetadata
|
|
18
18
|
*/
|
|
19
|
-
|
|
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
|
-
|
|
65
|
-
|
|
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
|
-
*
|
|
106
|
-
* @type {
|
|
111
|
+
*
|
|
112
|
+
* @type {Array<HotelRoomOffer>}
|
|
107
113
|
* @memberof HotelOffer
|
|
108
114
|
*/
|
|
109
|
-
|
|
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
|
-
|
|
55
|
-
|
|
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
|
|
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
|
*
|
|
@@ -172,18 +172,16 @@ export interface HotelRoomOffer {
|
|
|
172
172
|
sourceMarket: SourceMarket
|
|
173
173
|
/**
|
|
174
174
|
*
|
|
175
|
-
* @type {
|
|
175
|
+
* @type {StayTaxesInfo}
|
|
176
176
|
* @memberof HotelRoomOffer
|
|
177
177
|
*/
|
|
178
|
-
|
|
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
|
-
*
|
|
183
|
-
* @type {number}
|
|
181
|
+
* @type {Array<Tag>}
|
|
184
182
|
* @memberof HotelRoomOffer
|
|
185
183
|
*/
|
|
186
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
9
|
+
id: string
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
* @type {string}
|
|
13
13
|
* @memberof HotelRoomingListGuest
|
|
14
14
|
*/
|
|
15
|
-
|
|
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
|
}
|
package/src/types/event.ts
CHANGED
|
@@ -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
|
package/src/types/pagination.ts
CHANGED
|
@@ -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>(
|
package/src/utils/debounce.ts
CHANGED
|
@@ -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) {
|
package/src/utils/poller.ts
CHANGED
|
@@ -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> =
|