@revolugo/common 6.10.10-rc.2 → 6.11.0-beta.0
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 +2 -6
- package/src/cancellation-policies.ts +27 -19
- package/src/constants/index.ts +0 -1
- package/src/countries/{constants.ts → countries.ts} +2 -36
- package/src/{constants/countries.ts → countries/country.ts} +0 -1
- package/src/countries/europe.ts +35 -0
- package/src/countries/index.ts +4 -7
- package/src/{types/country.ts → countries/types.ts} +1 -1
- package/src/currencies/index.ts +1 -1
- package/src/types/elements/contact-person.ts +2 -1
- package/src/types/elements/currency.ts +2 -1
- package/src/types/elements/hotel-offer-list.ts +29 -0
- package/src/types/elements/hotel-offer-request.ts +89 -0
- package/src/types/elements/hotel-offer.ts +4 -1
- package/src/types/elements/hotel-room-offer-request.ts +63 -0
- package/src/types/elements/hotel-room-offer.ts +76 -1
- package/src/types/elements/index.ts +2 -0
- package/src/types/elements/meta-polling.ts +31 -0
- package/src/types/geo-coordinates.ts +4 -0
- package/src/types/index.ts +1 -1
- package/src/utils/{math.ts → amount-from-percentage.ts} +0 -10
- package/src/utils/case-transformers.ts +0 -1
- package/src/utils/chunk.ts +7 -0
- package/src/utils/colors.ts +4 -1
- package/src/utils/compact-object.ts +7 -0
- package/src/utils/compact.ts +28 -0
- package/src/utils/compute-margin-rate.ts +13 -0
- package/src/utils/compute-selling-price.ts +12 -0
- package/src/utils/dates.ts +10 -2
- package/src/utils/dayjs.ts +2 -0
- package/src/utils/defaults-deep.ts +85 -0
- package/src/utils/delay.ts +5 -0
- package/src/utils/generate-numbers-from-str.ts +15 -0
- package/src/utils/generate-pseudo-random-string.ts +3 -0
- package/src/utils/get-guest-count.ts +1 -2
- package/src/utils/get-random-element-from-array.ts +10 -0
- package/src/utils/get-random-hex-color.ts +5 -0
- package/src/utils/{random.ts → get-random-int.ts} +0 -6
- package/src/utils/index.ts +31 -12
- package/src/utils/key-by.ts +25 -0
- package/src/utils/merge.ts +140 -0
- package/src/utils/omit-by.ts +37 -0
- package/src/utils/omit.ts +39 -0
- package/src/utils/pick.ts +12 -0
- package/src/utils/poller.ts +11 -13
- package/src/utils/{strings.ts → prepare-ts-query.ts} +0 -6
- package/src/utils/{promise-tools.ts → promise-timeout.ts} +0 -6
- package/src/utils/random-int.ts +3 -0
- package/src/utils/shuffle-array.ts +13 -0
- package/src/utils/{array-tools.ts → sort-by.ts} +2 -93
- package/src/utils/sum-by.ts +23 -0
- package/src/utils/uniq-with.ts +16 -0
- package/src/utils/validators.ts +0 -1
- package/src/utils/weighted-mean.ts +9 -0
- package/src/utils/numbers.ts +0 -46
- package/src/utils/object-tools.ts +0 -126
- /package/src/utils/{value-tools.ts → is-nil.ts} +0 -0
- /package/src/utils/{children-tools.ts → parse-children.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revolugo/common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.11.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Revolugo common",
|
|
6
6
|
"author": "Revolugo",
|
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
|
-
"imports": {
|
|
12
|
-
"#constants": "./src/constants/index.ts"
|
|
13
|
-
},
|
|
14
11
|
"exports": {
|
|
15
12
|
"./cancellation-policies": "./src/cancellation-policies.ts",
|
|
16
13
|
"./countries": "./src/countries/index.ts",
|
|
@@ -25,8 +22,7 @@
|
|
|
25
22
|
"dependencies": {
|
|
26
23
|
"change-case": "5.4.4",
|
|
27
24
|
"dayjs": "1.11.18",
|
|
28
|
-
"ky": "1.
|
|
29
|
-
"lodash-es": "4.17.21",
|
|
25
|
+
"ky": "1.12.0",
|
|
30
26
|
"slugify": "1.6.6",
|
|
31
27
|
"uuid": "13.0.0"
|
|
32
28
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compact } from './utils/
|
|
1
|
+
import { compact } from './utils/compact.ts'
|
|
2
2
|
import { type Dayjs, dayjs } from './utils/dayjs.ts'
|
|
3
3
|
import { isEmpty } from './utils/is-empty.ts'
|
|
4
4
|
|
|
@@ -169,6 +169,7 @@ export function sanitizeCancellationPolicies({
|
|
|
169
169
|
|
|
170
170
|
if (
|
|
171
171
|
releaseDatetimeUTC &&
|
|
172
|
+
compactedCancellationPolicies[0] &&
|
|
172
173
|
dayjs(releaseDatetimeUTC).isBetween(
|
|
173
174
|
dayjs(bookingDatetimeUTC),
|
|
174
175
|
dayjs(compactedCancellationPolicies[0].dateFrom),
|
|
@@ -176,6 +177,7 @@ export function sanitizeCancellationPolicies({
|
|
|
176
177
|
'[)',
|
|
177
178
|
)
|
|
178
179
|
) {
|
|
180
|
+
const firstPolicyDateFrom = compactedCancellationPolicies[0].dateFrom
|
|
179
181
|
compactedCancellationPolicies.push(
|
|
180
182
|
{
|
|
181
183
|
dateFrom: bookingDatetimeUTC,
|
|
@@ -184,7 +186,7 @@ export function sanitizeCancellationPolicies({
|
|
|
184
186
|
},
|
|
185
187
|
{
|
|
186
188
|
dateFrom: releaseDatetimeUTC,
|
|
187
|
-
dateTo:
|
|
189
|
+
dateTo: firstPolicyDateFrom,
|
|
188
190
|
penaltyPercentage: 100,
|
|
189
191
|
},
|
|
190
192
|
)
|
|
@@ -268,11 +270,14 @@ export function sanitizeCancellationPolicies({
|
|
|
268
270
|
!dayjs(cp.dateFrom).isSameOrAfter(nextDayCheckInDateUTC),
|
|
269
271
|
)
|
|
270
272
|
|
|
271
|
-
sanitizedCancellationPolicies[0]
|
|
273
|
+
if (sanitizedCancellationPolicies[0]) {
|
|
274
|
+
sanitizedCancellationPolicies[0].dateFrom = bookingDatetimeUTC
|
|
275
|
+
}
|
|
272
276
|
|
|
273
|
-
sanitizedCancellationPolicies
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
const lastIndex = sanitizedCancellationPolicies.length - 1
|
|
278
|
+
if (sanitizedCancellationPolicies[lastIndex]) {
|
|
279
|
+
sanitizedCancellationPolicies[lastIndex].dateTo = nextDayCheckInDateUTC
|
|
280
|
+
}
|
|
276
281
|
|
|
277
282
|
return sanitizedCancellationPolicies
|
|
278
283
|
}
|
|
@@ -340,10 +345,7 @@ export function getPenaltyPercentage({
|
|
|
340
345
|
date: datetime,
|
|
341
346
|
})
|
|
342
347
|
|
|
343
|
-
return
|
|
344
|
-
matchingCancellationPolicies[0] &&
|
|
345
|
-
matchingCancellationPolicies[0].penaltyPercentage
|
|
346
|
-
)
|
|
348
|
+
return matchingCancellationPolicies[0]?.penaltyPercentage ?? 0
|
|
347
349
|
}
|
|
348
350
|
|
|
349
351
|
export function getCurrentPenaltyPercentage({
|
|
@@ -383,7 +385,7 @@ export function isBetterCancellationPolicies(
|
|
|
383
385
|
return false
|
|
384
386
|
}
|
|
385
387
|
|
|
386
|
-
if (!newVal[0]
|
|
388
|
+
if (!newVal[0]?.dateTo) {
|
|
387
389
|
return oldVal.every(oldCancellationPolicy => {
|
|
388
390
|
const relatedNewCancellationPolicy = newVal.find(newCancellationPolicy =>
|
|
389
391
|
dayjs(oldCancellationPolicy.dateTo).isBetween(
|
|
@@ -399,8 +401,8 @@ export function isBetterCancellationPolicies(
|
|
|
399
401
|
}
|
|
400
402
|
|
|
401
403
|
return (
|
|
402
|
-
oldCancellationPolicy.penaltyPercentage
|
|
403
|
-
relatedNewCancellationPolicy.penaltyPercentage
|
|
404
|
+
oldCancellationPolicy.penaltyPercentage >=
|
|
405
|
+
relatedNewCancellationPolicy.penaltyPercentage
|
|
404
406
|
)
|
|
405
407
|
})
|
|
406
408
|
}
|
|
@@ -420,8 +422,8 @@ export function isBetterCancellationPolicies(
|
|
|
420
422
|
}
|
|
421
423
|
|
|
422
424
|
return (
|
|
423
|
-
oldCancellationPolicy.penaltyPercentage
|
|
424
|
-
relatedNewCancellationPolicy.penaltyPercentage
|
|
425
|
+
oldCancellationPolicy.penaltyPercentage >=
|
|
426
|
+
relatedNewCancellationPolicy.penaltyPercentage
|
|
425
427
|
)
|
|
426
428
|
})
|
|
427
429
|
}
|
|
@@ -470,11 +472,17 @@ export function getSanitizedCancellationPolicies({
|
|
|
470
472
|
export function getCurrentCancellationPolicy(
|
|
471
473
|
sanitizedCancellationPolicies: ICancellationPolicy[],
|
|
472
474
|
): ICancellationPolicy {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
dayjs().isBetween(dayjs(policy.dateFrom), dayjs(policy.dateTo)),
|
|
476
|
-
) || sanitizedCancellationPolicies[0]
|
|
475
|
+
const found = sanitizedCancellationPolicies.find(policy =>
|
|
476
|
+
dayjs().isBetween(dayjs(policy.dateFrom), dayjs(policy.dateTo)),
|
|
477
477
|
)
|
|
478
|
+
if (found) {
|
|
479
|
+
return found
|
|
480
|
+
}
|
|
481
|
+
const first = sanitizedCancellationPolicies[0]
|
|
482
|
+
if (!first) {
|
|
483
|
+
throw new Error('No cancellation policies available')
|
|
484
|
+
}
|
|
485
|
+
return first
|
|
478
486
|
}
|
|
479
487
|
|
|
480
488
|
function adjustIfFullHour(date: string): Dayjs {
|
package/src/constants/index.ts
CHANGED
|
@@ -1,41 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { CountryIso2Code } from '../constants/countries.ts'
|
|
1
|
+
/* eslint-disable max-lines */
|
|
3
2
|
import { Currency } from '../constants/currencies.ts'
|
|
4
3
|
|
|
5
|
-
import type { Country } from '
|
|
4
|
+
import type { Country } from './types.ts'
|
|
6
5
|
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
export const EU_COUNTRIES_ISO2_CODE = new Set<string>([
|
|
9
|
-
CountryIso2Code.AT,
|
|
10
|
-
CountryIso2Code.BE,
|
|
11
|
-
CountryIso2Code.BG,
|
|
12
|
-
CountryIso2Code.CY,
|
|
13
|
-
CountryIso2Code.CZ,
|
|
14
|
-
CountryIso2Code.DE,
|
|
15
|
-
CountryIso2Code.DK,
|
|
16
|
-
CountryIso2Code.EE,
|
|
17
|
-
CountryIso2Code.ES,
|
|
18
|
-
CountryIso2Code.FI,
|
|
19
|
-
CountryIso2Code.FR,
|
|
20
|
-
CountryIso2Code.GR,
|
|
21
|
-
CountryIso2Code.HR,
|
|
22
|
-
CountryIso2Code.HU,
|
|
23
|
-
CountryIso2Code.IE,
|
|
24
|
-
CountryIso2Code.IT,
|
|
25
|
-
CountryIso2Code.LT,
|
|
26
|
-
CountryIso2Code.LU,
|
|
27
|
-
CountryIso2Code.LV,
|
|
28
|
-
CountryIso2Code.MT,
|
|
29
|
-
CountryIso2Code.NL,
|
|
30
|
-
CountryIso2Code.PL,
|
|
31
|
-
CountryIso2Code.PT,
|
|
32
|
-
CountryIso2Code.RO,
|
|
33
|
-
CountryIso2Code.SE,
|
|
34
|
-
CountryIso2Code.SI,
|
|
35
|
-
CountryIso2Code.SK,
|
|
36
|
-
])
|
|
37
|
-
|
|
38
|
-
/* @__PURE__ */
|
|
39
6
|
export const COUNTRIES: Record<string, Country> = {
|
|
40
7
|
AD: {
|
|
41
8
|
areaCodes: null,
|
|
@@ -2512,7 +2479,6 @@ export const COUNTRIES: Record<string, Country> = {
|
|
|
2512
2479
|
},
|
|
2513
2480
|
}
|
|
2514
2481
|
|
|
2515
|
-
/* @__PURE__ */
|
|
2516
2482
|
export const ISO_COUNTRIES = Object.values(COUNTRIES).map(
|
|
2517
2483
|
country => country.iso2,
|
|
2518
2484
|
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CountryIso2Code } from './country.ts'
|
|
2
|
+
|
|
3
|
+
export const EU_COUNTRIES_ISO2_CODE = new Set<string>([
|
|
4
|
+
CountryIso2Code.AT,
|
|
5
|
+
CountryIso2Code.BE,
|
|
6
|
+
CountryIso2Code.BG,
|
|
7
|
+
CountryIso2Code.CY,
|
|
8
|
+
CountryIso2Code.CZ,
|
|
9
|
+
CountryIso2Code.DE,
|
|
10
|
+
CountryIso2Code.DK,
|
|
11
|
+
CountryIso2Code.EE,
|
|
12
|
+
CountryIso2Code.ES,
|
|
13
|
+
CountryIso2Code.FI,
|
|
14
|
+
CountryIso2Code.FR,
|
|
15
|
+
CountryIso2Code.GR,
|
|
16
|
+
CountryIso2Code.HR,
|
|
17
|
+
CountryIso2Code.HU,
|
|
18
|
+
CountryIso2Code.IE,
|
|
19
|
+
CountryIso2Code.IT,
|
|
20
|
+
CountryIso2Code.LT,
|
|
21
|
+
CountryIso2Code.LU,
|
|
22
|
+
CountryIso2Code.LV,
|
|
23
|
+
CountryIso2Code.MT,
|
|
24
|
+
CountryIso2Code.NL,
|
|
25
|
+
CountryIso2Code.PL,
|
|
26
|
+
CountryIso2Code.PT,
|
|
27
|
+
CountryIso2Code.RO,
|
|
28
|
+
CountryIso2Code.SE,
|
|
29
|
+
CountryIso2Code.SI,
|
|
30
|
+
CountryIso2Code.SK,
|
|
31
|
+
])
|
|
32
|
+
|
|
33
|
+
export function isInEu(countryCode: string): boolean {
|
|
34
|
+
return EU_COUNTRIES_ISO2_CODE.has(countryCode)
|
|
35
|
+
}
|
package/src/countries/index.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from './
|
|
4
|
-
|
|
5
|
-
export function isInEu(countryCode: string): boolean {
|
|
6
|
-
return EU_COUNTRIES_ISO2_CODE.has(countryCode)
|
|
7
|
-
}
|
|
1
|
+
export * from './countries.ts'
|
|
2
|
+
export * from './country.ts'
|
|
3
|
+
export * from './europe.ts'
|
|
4
|
+
export type * from './types.ts'
|
package/src/currencies/index.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CurrencyType } from './currency.ts'
|
|
2
|
+
import type { HotelOffersSortByType } from './hotel-offer.ts'
|
|
3
|
+
// eslint-disable-next-line no-restricted-imports
|
|
4
|
+
import type { Locale } from '../../constants/index.ts'
|
|
5
|
+
|
|
6
|
+
export enum HotelOffersSortByOrderEnum {
|
|
7
|
+
Asc = 'asc',
|
|
8
|
+
Desc = 'desc',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type HotelOffersSortByOrderType = `${HotelOffersSortByOrderEnum}`
|
|
12
|
+
|
|
13
|
+
export interface HotelOffersListPayload {
|
|
14
|
+
currency: CurrencyType
|
|
15
|
+
hotelOfferRequestId: string
|
|
16
|
+
endingBefore?: string | null
|
|
17
|
+
filterByPrice?: string
|
|
18
|
+
filterByReviewRating?: number
|
|
19
|
+
filterByStar?: string
|
|
20
|
+
hotelRoomOffersLimit?: number
|
|
21
|
+
includeHotelContentDetails?: boolean | null
|
|
22
|
+
lang?: Locale
|
|
23
|
+
limit?: number
|
|
24
|
+
onlyRecommendedHotelOffers?: boolean | null
|
|
25
|
+
priceHistogramStepCount?: number
|
|
26
|
+
sortBy?: HotelOffersSortByType
|
|
27
|
+
sortByOrder?: HotelOffersSortByOrderType
|
|
28
|
+
startingAfter?: string | null
|
|
29
|
+
}
|
|
@@ -60,9 +60,98 @@ export interface HotelOfferRequest {
|
|
|
60
60
|
* @type {SourceMarket}
|
|
61
61
|
*/
|
|
62
62
|
sourceMarket: SourceMarket
|
|
63
|
+
/**
|
|
64
|
+
* Date of the **Hotel Room Offer Request** creation
|
|
65
|
+
* @type {string}
|
|
66
|
+
* @memberof HotelOfferRequestApiResponse
|
|
67
|
+
*/
|
|
68
|
+
createdAt: string
|
|
69
|
+
/**
|
|
70
|
+
* id of the **Hotel Offer Request**
|
|
71
|
+
* @type {string}
|
|
72
|
+
*/
|
|
73
|
+
id: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface HotelOfferRequestResponse {
|
|
77
|
+
/**
|
|
78
|
+
* 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
|
+
*
|
|
80
|
+
* <b style="color: red;">If address cannot be geocoded (transformed into a latitude/longitude pair) provided **latitude** and **longitude** parameters will be used as fallback.</b>
|
|
81
|
+
* @type {string}
|
|
82
|
+
* @memberof HotelOfferRequestApiResponse
|
|
83
|
+
*/
|
|
84
|
+
address?: string | null
|
|
85
|
+
/**
|
|
86
|
+
* The total number of adults who will be staying in the property.
|
|
87
|
+
* @type {number}
|
|
88
|
+
* @memberof HotelOfferRequestApiResponse
|
|
89
|
+
*/
|
|
90
|
+
adultCount: number
|
|
91
|
+
/**
|
|
92
|
+
* Date of check-in formatted as YYYY-MM-DD.
|
|
93
|
+
* @type {string}
|
|
94
|
+
* @memberof HotelOfferRequestApiResponse
|
|
95
|
+
*/
|
|
96
|
+
checkInDate: string
|
|
97
|
+
/**
|
|
98
|
+
* Date of check-out formatted as YYYY-MM-DD.
|
|
99
|
+
* @type {string}
|
|
100
|
+
* @memberof HotelOfferRequestApiResponse
|
|
101
|
+
*/
|
|
102
|
+
checkOutDate: string
|
|
103
|
+
/**
|
|
104
|
+
* A comma-separated list of child ages (0 up to 17). e.g.: "3,7" represents 2 children respectively 3 and 7 years old.
|
|
105
|
+
* @type {string}
|
|
106
|
+
* @memberof HotelOfferRequestApiResponse
|
|
107
|
+
*/
|
|
108
|
+
children?: string | null
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* @type {EventMetadataApi}
|
|
112
|
+
* @memberof HotelOfferRequestApiResponse
|
|
113
|
+
*/
|
|
114
|
+
eventMetadata?: EventMetadata | null
|
|
115
|
+
/**
|
|
116
|
+
* Search location latitude.
|
|
117
|
+
*
|
|
118
|
+
* <b style="color: red;"> when no address parameter passed.</b>
|
|
119
|
+
* @type {number}
|
|
120
|
+
* @memberof HotelOfferRequestApiResponse
|
|
121
|
+
*/
|
|
122
|
+
latitude?: number | null
|
|
123
|
+
/**
|
|
124
|
+
* Search location longitude.
|
|
125
|
+
*
|
|
126
|
+
* <b style="color: red;"> when no address parameter passed.</b>
|
|
127
|
+
* @type {number}
|
|
128
|
+
* @memberof HotelOfferRequestApiResponse
|
|
129
|
+
*/
|
|
130
|
+
longitude?: number | null
|
|
131
|
+
/**
|
|
132
|
+
* The total number of rooms requested for the stay. Results may display offers matching a different room count than the requested one, however those results will always provide enough occupancy for the total guest count needed.
|
|
133
|
+
*
|
|
134
|
+
* Constraint: The **room_count** cannot be greater than the requested guest count (adult and children guests) and the minimum **room_count** cannot be less than the total guest count (adult and children guests) divided by 4, meaning that the maximum number of guest in a single room cannot be greeater than 4.
|
|
135
|
+
* @type {number}
|
|
136
|
+
* @memberof HotelOfferRequestApiResponse
|
|
137
|
+
*/
|
|
138
|
+
roomCount: number
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @type {SourceMarket}
|
|
142
|
+
* @memberof HotelOfferRequestApiResponse
|
|
143
|
+
*/
|
|
144
|
+
sourceMarket: SourceMarket
|
|
145
|
+
/**
|
|
146
|
+
* Date of the **Hotel Offer Request** creation
|
|
147
|
+
* @type {string}
|
|
148
|
+
* @memberof HotelOfferRequestApiResponse
|
|
149
|
+
*/
|
|
150
|
+
createdAt: string
|
|
63
151
|
/**
|
|
64
152
|
* id of the **Hotel Offer Request**
|
|
65
153
|
* @type {string}
|
|
154
|
+
* @memberof HotelOfferRequestApiResponse
|
|
66
155
|
*/
|
|
67
156
|
id: string
|
|
68
157
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Currency } from '#constants'
|
|
2
1
|
import type { Amenities } from './amenity.ts'
|
|
3
2
|
import type { HotelImage } from './hotel-image.ts'
|
|
4
3
|
import type { HotelImages } from './hotel-images.ts'
|
|
@@ -6,6 +5,8 @@ import type { HotelReviewRating } from './hotel-review-rating.ts'
|
|
|
6
5
|
import type { HotelRoomOffer } from './hotel-room-offer.ts'
|
|
7
6
|
import type { Tag } from './tag.ts'
|
|
8
7
|
import type { TravelTimeItem } from './travel-times.ts'
|
|
8
|
+
// eslint-disable-next-line no-restricted-imports
|
|
9
|
+
import type { Currency } from '../../currencies/index.ts'
|
|
9
10
|
|
|
10
11
|
export interface HotelOffer {
|
|
11
12
|
/**
|
|
@@ -206,3 +207,5 @@ export enum HotelOffersSortByEnum {
|
|
|
206
207
|
ReviewRating = 'review_rating',
|
|
207
208
|
TopPicks = 'top_picks',
|
|
208
209
|
}
|
|
210
|
+
|
|
211
|
+
export type HotelOffersSortByType = `${HotelOffersSortByEnum}`
|
|
@@ -64,6 +64,69 @@ export interface HotelRoomOfferRequest {
|
|
|
64
64
|
id: string
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
export interface HotelRoomOfferRequestResponse {
|
|
68
|
+
/**
|
|
69
|
+
* Requested number of adult(s) to be accommodated.
|
|
70
|
+
* @type {number}
|
|
71
|
+
* @memberof HotelRoomOfferRequestApiResponse
|
|
72
|
+
*/
|
|
73
|
+
adultCount: number
|
|
74
|
+
/**
|
|
75
|
+
* Check-in date formatted as `YYYY-MM-DD`.
|
|
76
|
+
* @type {string}
|
|
77
|
+
* @memberof HotelRoomOfferRequestApiResponse
|
|
78
|
+
*/
|
|
79
|
+
checkInDate: string
|
|
80
|
+
/**
|
|
81
|
+
* Check-out date formatted as `YYYY-MM-DD`.
|
|
82
|
+
* @type {string}
|
|
83
|
+
* @memberof HotelRoomOfferRequestApiResponse
|
|
84
|
+
*/
|
|
85
|
+
checkOutDate: string
|
|
86
|
+
/**
|
|
87
|
+
* A comma-separated list of child ages (0 up to 17). e.g.: "3,7" represents 2 children respectively 3 and 7 years old.
|
|
88
|
+
* @type {string}
|
|
89
|
+
* @memberof HotelRoomOfferRequestApiResponse
|
|
90
|
+
*/
|
|
91
|
+
children?: string | null
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @type {EventMetadataApi}
|
|
95
|
+
* @memberof HotelRoomOfferRequestApiResponse
|
|
96
|
+
*/
|
|
97
|
+
eventMetadata?: EventMetadata | null
|
|
98
|
+
/**
|
|
99
|
+
* id of requested hotel
|
|
100
|
+
* @type {string}
|
|
101
|
+
* @memberof HotelRoomOfferRequestApiResponse
|
|
102
|
+
*/
|
|
103
|
+
hotelId: string
|
|
104
|
+
/**
|
|
105
|
+
* Number of room(s) requested. Results may display offers matching a different room count than the requested one, however those results will always provide enough occupancy for the total guest count needed.
|
|
106
|
+
* @type {number}
|
|
107
|
+
* @memberof HotelRoomOfferRequestApiResponse
|
|
108
|
+
*/
|
|
109
|
+
roomCount: number
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @type {SourceMarket}
|
|
113
|
+
* @memberof HotelRoomOfferRequestApiResponse
|
|
114
|
+
*/
|
|
115
|
+
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
|
+
}
|
|
129
|
+
|
|
67
130
|
export type HotelRoomOfferRequestCreate = Pick<
|
|
68
131
|
HotelRoomOfferRequest,
|
|
69
132
|
| 'adultCount'
|
|
@@ -1,12 +1,65 @@
|
|
|
1
|
-
import type { BreakfastOptionType } from '#constants'
|
|
2
1
|
import type { CancellationPolicy } from './cancellation-policy.ts'
|
|
3
2
|
import type { CurrencyType } from './currency.ts'
|
|
4
3
|
import type { HotelRoomOfferPackageType } from './hotel-room-offer-package-type.ts'
|
|
5
4
|
import type { HotelRoomOfferType } from './hotel-room-offer-type.ts'
|
|
6
5
|
import type { HotelRoom } from './hotel-room.ts'
|
|
6
|
+
import type { MetaPollingResponse } from './meta-polling.ts'
|
|
7
7
|
import type { SourceMarket } from './source-market.ts'
|
|
8
8
|
import type { Tag } from './tag.ts'
|
|
9
9
|
import type { Tax } from './tax.ts'
|
|
10
|
+
// eslint-disable-next-line no-restricted-imports
|
|
11
|
+
import type { BreakfastOptionType } from '../../constants/index.ts'
|
|
12
|
+
|
|
13
|
+
export interface HotelRoomOffersDataResponse {
|
|
14
|
+
/**
|
|
15
|
+
* The total number of adults who will be staying in the property.
|
|
16
|
+
* @type {number}
|
|
17
|
+
* @memberof HotelRoomOffersDataApiResponse
|
|
18
|
+
*/
|
|
19
|
+
adultCount: number
|
|
20
|
+
/**
|
|
21
|
+
* Date of check-in formatted as YYYY-MM-DD.
|
|
22
|
+
* @type {string}
|
|
23
|
+
* @memberof HotelRoomOffersDataApiResponse
|
|
24
|
+
*/
|
|
25
|
+
checkInDate: string
|
|
26
|
+
/**
|
|
27
|
+
* Date of check-out formatted as YYYY-MM-DD.
|
|
28
|
+
* @type {string}
|
|
29
|
+
* @memberof HotelRoomOffersDataApiResponse
|
|
30
|
+
*/
|
|
31
|
+
checkOutDate: string
|
|
32
|
+
/**
|
|
33
|
+
* A comma-separated list of child ages (0 up to 17). e.g.: "3,7" represents 2 children respectively 3 and 7 years old.
|
|
34
|
+
* @type {string}
|
|
35
|
+
* @memberof HotelRoomOffersDataApiResponse
|
|
36
|
+
*/
|
|
37
|
+
children?: string | null
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @type {CurrencyType}
|
|
41
|
+
* @memberof HotelRoomOffersDataApiResponse
|
|
42
|
+
*/
|
|
43
|
+
currency: CurrencyType
|
|
44
|
+
/**
|
|
45
|
+
* Hotel id
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @memberof HotelRoomOffersDataApiResponse
|
|
48
|
+
*/
|
|
49
|
+
hotelId: string
|
|
50
|
+
/**
|
|
51
|
+
* List of **Hotel Room Offers** sorted by price ascending.
|
|
52
|
+
* @type {HotelRoomOffer[]}
|
|
53
|
+
* @memberof HotelRoomOffersDataApiResponse
|
|
54
|
+
*/
|
|
55
|
+
hotelRoomOffers: HotelRoomOffer[]
|
|
56
|
+
/**
|
|
57
|
+
* Hotel timezone
|
|
58
|
+
* @type {string}
|
|
59
|
+
* @memberof HotelRoomOffersDataApiResponse
|
|
60
|
+
*/
|
|
61
|
+
hotelTimezone: string
|
|
62
|
+
}
|
|
10
63
|
|
|
11
64
|
/**
|
|
12
65
|
* Description of the Hotel Room Offer.
|
|
@@ -146,6 +199,28 @@ export interface HotelRoomOffer {
|
|
|
146
199
|
type?: HotelRoomOfferType
|
|
147
200
|
}
|
|
148
201
|
|
|
202
|
+
export interface HotelRoomOffersResponse {
|
|
203
|
+
/**
|
|
204
|
+
*
|
|
205
|
+
* @type {HotelRoomOffersDataResponse}
|
|
206
|
+
* @memberof HotelRoomOffersApiResponse
|
|
207
|
+
*/
|
|
208
|
+
data: HotelRoomOffersDataResponse
|
|
209
|
+
/**
|
|
210
|
+
*
|
|
211
|
+
* @type {any}
|
|
212
|
+
* @memberof HotelRoomOffersApiResponse
|
|
213
|
+
*/
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
215
|
+
event?: any | null
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
* @type {MetaApiPollingResponse}
|
|
219
|
+
* @memberof HotelRoomOffersApiResponse
|
|
220
|
+
*/
|
|
221
|
+
meta: MetaPollingResponse
|
|
222
|
+
}
|
|
223
|
+
|
|
149
224
|
export interface HotelRoomOfferResponse {
|
|
150
225
|
/**
|
|
151
226
|
* The total number of adults who will be staying in the property.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// eslint-disable-next-line no-restricted-imports
|
|
2
|
+
import type { PollerStatus } from '../../constants/poller.ts'
|
|
3
|
+
|
|
4
|
+
type PollerType = `${PollerStatus}`
|
|
5
|
+
|
|
6
|
+
export interface MetaPollingResponse {
|
|
7
|
+
/**
|
|
8
|
+
* A cursor to use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
|
|
9
|
+
* @type {string}
|
|
10
|
+
* @memberof MetaApiPollingResponse
|
|
11
|
+
*/
|
|
12
|
+
endingBefore?: string | null
|
|
13
|
+
/**
|
|
14
|
+
* A limit on the number of object to be returned.
|
|
15
|
+
* @type {number}
|
|
16
|
+
* @memberof MetaApiPollingResponse
|
|
17
|
+
*/
|
|
18
|
+
limit?: number
|
|
19
|
+
/**
|
|
20
|
+
* A cursor to use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @memberof MetaApiPollingResponse
|
|
23
|
+
*/
|
|
24
|
+
startingAfter?: string | null
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @type {PollerType}
|
|
28
|
+
* @memberof MetaApiPollingResponse
|
|
29
|
+
*/
|
|
30
|
+
status: PollerType
|
|
31
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -2,10 +2,10 @@ export type * from './api.ts'
|
|
|
2
2
|
export * from './booking.ts'
|
|
3
3
|
export type * from './calendar.ts'
|
|
4
4
|
export type * from './cancellation-policy.ts'
|
|
5
|
-
export type * from './country.ts'
|
|
6
5
|
export type * from './currency.ts'
|
|
7
6
|
export type * from './date.ts'
|
|
8
7
|
export type * from './event.ts'
|
|
8
|
+
export type * from './geo-coordinates.ts'
|
|
9
9
|
export type * from './hotel-contract.ts'
|
|
10
10
|
export type * from './hotel-room-stock.ts'
|
|
11
11
|
export type * from './money-object.ts'
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export function weightedMean(values: number[], weights: number[]): number {
|
|
2
|
-
const sum = values.reduce(
|
|
3
|
-
(acc: number, val: number, i: number) => acc + val * weights[i],
|
|
4
|
-
0,
|
|
5
|
-
)
|
|
6
|
-
const sumWeights = weights.reduce((acc: number, val: number) => acc + val, 0)
|
|
7
|
-
|
|
8
|
-
return sum / sumWeights
|
|
9
|
-
}
|
|
10
|
-
|
|
11
1
|
export function amountFromPercentage(
|
|
12
2
|
percentage: number,
|
|
13
3
|
amount: number,
|