@revolugo/common 7.2.4 → 7.3.0-rc.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.
Files changed (44) hide show
  1. package/package.json +4 -4
  2. package/src/amenities/index.ts +1 -1
  3. package/src/cancellation-policies.ts +21 -25
  4. package/src/constants/environment.ts +7 -7
  5. package/src/constants/index.ts +2 -2
  6. package/src/constants/locales.ts +17 -17
  7. package/src/http/index.ts +1 -1
  8. package/src/icons/index.ts +1 -1
  9. package/src/schemas/booking-policy.ts +1 -4
  10. package/src/schemas/index.ts +1 -1
  11. package/src/types/elements/allowed-payment-method.ts +1 -1
  12. package/src/types/elements/booking.ts +8 -8
  13. package/src/types/elements/hotel-offer-request.ts +12 -12
  14. package/src/types/elements/hotel-room-offer-request.ts +22 -24
  15. package/src/types/elements/index.ts +18 -18
  16. package/src/types/elements/payment-method.ts +2 -2
  17. package/src/types/hotel-contract.ts +1 -1
  18. package/src/types/http-exception/index.ts +1 -1
  19. package/src/types/index.ts +9 -9
  20. package/src/types/pagination.ts +1 -1
  21. package/src/types/payment.ts +3 -3
  22. package/src/types/severities.ts +6 -6
  23. package/src/utils/amount-from-percentage.ts +1 -1
  24. package/src/utils/case-transformers.ts +5 -5
  25. package/src/utils/create-composite-key.ts +1 -1
  26. package/src/utils/dates.ts +1 -1
  27. package/src/utils/group-by.ts +2 -2
  28. package/src/utils/images.ts +1 -1
  29. package/src/utils/index.ts +4 -4
  30. package/src/utils/key-by.ts +1 -1
  31. package/src/utils/map-keys.ts +2 -2
  32. package/src/utils/map-values.ts +1 -1
  33. package/src/utils/omit-by.ts +1 -1
  34. package/src/utils/omit.ts +2 -1
  35. package/src/utils/pick.ts +1 -0
  36. package/src/utils/poller.ts +3 -3
  37. package/src/utils/prepare-ts-query.ts +4 -4
  38. package/src/utils/shake.ts +1 -0
  39. package/src/utils/sort-by.ts +1 -1
  40. package/src/utils/sum.ts +2 -2
  41. package/src/utils/to-lang.ts +8 -8
  42. package/src/utils/to-locale.ts +8 -8
  43. package/src/utils/uniq-by.ts +2 -2
  44. package/src/utils/uniq.ts +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolugo/common",
3
- "version": "7.2.4",
3
+ "version": "7.3.0-rc.1",
4
4
  "private": false,
5
5
  "description": "Revolugo common",
6
6
  "author": "Revolugo",
@@ -23,11 +23,11 @@
23
23
  "./utils": "./src/utils/index.ts"
24
24
  },
25
25
  "dependencies": {
26
- "@asteasolutions/zod-to-openapi": "8.4.0",
26
+ "@asteasolutions/zod-to-openapi": "8.4.3",
27
27
  "change-case": "5.4.4",
28
- "dayjs": "1.11.19",
28
+ "dayjs": "1.11.20",
29
29
  "ky": "1.14.3",
30
- "slugify": "1.6.6",
30
+ "slugify": "1.6.8",
31
31
  "type-fest": "5.4.4",
32
32
  "uuid": "13.0.0",
33
33
  "zod": "4.3.6"
@@ -20,10 +20,10 @@ export const AMENITY_TO_ICONS = Object.freeze({
20
20
  GolfCourse: 'golf',
21
21
  HairDryer: 'hairDryer',
22
22
  HandicapAccessible: 'wheelchair',
23
+ IndoorPool: 'swimmingPool',
23
24
  InHouseBar: 'champagne',
24
25
  InHouseDining: 'forkKnife',
25
26
  InRoomMovies: 'filmReel',
26
- IndoorPool: 'swimmingPool',
27
27
  InteriorRoomEntrance: 'doorOpen',
28
28
  Kitchen: 'forkKnife',
29
29
  Map: 'mapPin',
@@ -401,9 +401,10 @@ export function getCurrentPenaltyPercentage({
401
401
  })
402
402
  }
403
403
 
404
- export function isBetterCancellationPolicies(
404
+ function checkCancellationPolicies(
405
405
  newVal: ICancellationPolicy[],
406
406
  oldVal: ICancellationPolicy[],
407
+ orEqual: boolean,
407
408
  ): boolean {
408
409
  if (isEmpty(newVal)) {
409
410
  return true
@@ -413,27 +414,8 @@ export function isBetterCancellationPolicies(
413
414
  return false
414
415
  }
415
416
 
416
- if (!newVal[0]?.dateTo) {
417
- return oldVal.every(oldCancellationPolicy => {
418
- const relatedNewCancellationPolicy = newVal.find(newCancellationPolicy =>
419
- dayjs(oldCancellationPolicy.dateTo).isBetween(
420
- newCancellationPolicy.dateFrom,
421
- newCancellationPolicy.dateTo,
422
- null,
423
- '[]',
424
- ),
425
- )
426
-
427
- if (!relatedNewCancellationPolicy) {
428
- return true
429
- }
430
-
431
- return (
432
- oldCancellationPolicy.penaltyPercentage >=
433
- relatedNewCancellationPolicy.penaltyPercentage
434
- )
435
- })
436
- }
417
+ const isBetter = (oldPenalty: number, newPenalty: number) =>
418
+ orEqual ? oldPenalty >= newPenalty : oldPenalty > newPenalty
437
419
 
438
420
  return oldVal.every(oldCancellationPolicy => {
439
421
  const relatedNewCancellationPolicy = newVal.find(newCancellationPolicy =>
@@ -449,13 +431,27 @@ export function isBetterCancellationPolicies(
449
431
  return true
450
432
  }
451
433
 
452
- return (
453
- oldCancellationPolicy.penaltyPercentage >=
454
- relatedNewCancellationPolicy.penaltyPercentage
434
+ return isBetter(
435
+ oldCancellationPolicy.penaltyPercentage,
436
+ relatedNewCancellationPolicy.penaltyPercentage,
455
437
  )
456
438
  })
457
439
  }
458
440
 
441
+ export function isBetterCancellationPolicies(
442
+ newVal: ICancellationPolicy[],
443
+ oldVal: ICancellationPolicy[],
444
+ ): boolean {
445
+ return checkCancellationPolicies(newVal, oldVal, false)
446
+ }
447
+
448
+ export function isSameOrBetterCancellationPolicies(
449
+ newVal: ICancellationPolicy[],
450
+ oldVal: ICancellationPolicy[],
451
+ ): boolean {
452
+ return checkCancellationPolicies(newVal, oldVal, true)
453
+ }
454
+
459
455
  export function parseCancellationPolicies(
460
456
  cancellationPolicies: {
461
457
  dateFrom: string
@@ -14,18 +14,18 @@ export enum RevolutEnv {
14
14
  }
15
15
 
16
16
  export enum StripeEnv {
17
+ Local = 'local',
17
18
  Production = 'live',
18
19
  Sandbox = 'sandbox',
19
20
  Staging = 'staging',
20
- Local = 'local',
21
21
  }
22
22
 
23
23
  export enum Environment {
24
+ CiCd = 'CI-CD',
25
+ Local = 'LOCAL',
24
26
  Production = 'LIVE',
25
27
  Sandbox = 'SANDBOX',
26
28
  Staging = 'STAGING',
27
- CiCd = 'CI-CD',
28
- Local = 'LOCAL',
29
29
  }
30
30
 
31
31
  export enum NodeEnv {
@@ -42,19 +42,19 @@ export enum LogLevel {
42
42
  Error = 50,
43
43
  }
44
44
  export enum BookingEnvironment {
45
+ // DEVELOPMENT: do NOT book hotel, do NOT send confirmation email
46
+ Development = 'development',
45
47
  // PRODUCTION: actually book hotel, send confirmation email
46
48
  Production = 'production',
47
49
  // SANDBOX: do NOT book hotel, still send confirmation email
48
50
  Sandbox = 'sandbox',
49
- // DEVELOPMENT: do NOT book hotel, do NOT send confirmation email
50
- Development = 'development',
51
51
  }
52
52
 
53
53
  /* @__PURE__ */
54
54
  export const BOOKING_API_URLS = {
55
+ [Environment.CiCd]: 'https://booking-api.staging.revolugo.com',
56
+ [Environment.Local]: 'http://127.0.0.1:3001',
55
57
  [Environment.Production]: 'https://booking-api.revolugo.com',
56
58
  [Environment.Sandbox]: 'https://booking-api.sandbox.revolugo.com',
57
59
  [Environment.Staging]: 'https://booking-api.staging.revolugo.com',
58
- [Environment.CiCd]: 'https://booking-api.staging.revolugo.com',
59
- [Environment.Local]: 'http://127.0.0.1:3001',
60
60
  }
@@ -1,13 +1,13 @@
1
1
  export * from '../countries/constants.ts'
2
2
  export * from '../currencies/constants.ts'
3
3
  export * from './environment.ts'
4
- export * from './hotel.ts'
5
4
  export * from './hotel-offers.ts'
6
5
  export * from './hotel-room-offer.ts'
6
+ export * from './hotel.ts'
7
7
  export * from './locales.ts'
8
8
  export * from './measurement.ts'
9
9
  export * from './poller.ts'
10
+ export * from './stay-taxes-info.ts'
10
11
  export * from './tax.ts'
11
12
  export * from './time.ts'
12
- export * from './stay-taxes-info.ts'
13
13
  export * from './venue.ts'
@@ -19,7 +19,7 @@ export enum Lang {
19
19
  PT = 'pt',
20
20
  }
21
21
 
22
- export type ExtendedLocale = Locale | Lang
22
+ export type ExtendedLocale = Lang | Locale
23
23
 
24
24
  export function langFromString(langStr: string): Lang | undefined {
25
25
  return Object.entries(Lang).find(entry => {
@@ -33,10 +33,10 @@ export function langFromString(langStr: string): Lang | undefined {
33
33
 
34
34
  /* @__PURE__ */
35
35
  export const LANG_TO_LOCALE: Record<Lang, Locale> = {
36
- [Lang.EN]: Locale.en_US,
37
- [Lang.FR]: Locale.fr_FR,
38
36
  [Lang.DE]: Locale.de_DE,
37
+ [Lang.EN]: Locale.en_US,
39
38
  [Lang.ES]: Locale.es_ES,
39
+ [Lang.FR]: Locale.fr_FR,
40
40
  [Lang.IT]: Locale.it_IT,
41
41
  [Lang.NL]: Locale.nl_NL,
42
42
  [Lang.PT]: Locale.pt_PT,
@@ -55,20 +55,6 @@ export const LOCALE_TO_LANG = {
55
55
 
56
56
  /* @__PURE__ */
57
57
  export const LOCALES = {
58
- [Locale.en_US]: {
59
- code: Locale.en_US,
60
- countryCode: 'US',
61
- icon: '🇺🇸',
62
- locale: Lang.EN,
63
- name: 'English',
64
- },
65
- [Locale.fr_FR]: {
66
- code: Locale.fr_FR,
67
- countryCode: 'FR',
68
- icon: '🇫🇷',
69
- locale: Lang.FR,
70
- name: 'Français',
71
- },
72
58
  [Locale.de_DE]: {
73
59
  code: Locale.de_DE,
74
60
  countryCode: 'DE',
@@ -76,6 +62,13 @@ export const LOCALES = {
76
62
  locale: Lang.DE,
77
63
  name: 'Deutsch',
78
64
  },
65
+ [Locale.en_US]: {
66
+ code: Locale.en_US,
67
+ countryCode: 'US',
68
+ icon: '🇺🇸',
69
+ locale: Lang.EN,
70
+ name: 'English',
71
+ },
79
72
  [Locale.es_ES]: {
80
73
  code: Locale.es_ES,
81
74
  countryCode: 'ES',
@@ -83,6 +76,13 @@ export const LOCALES = {
83
76
  locale: Lang.ES,
84
77
  name: 'Español',
85
78
  },
79
+ [Locale.fr_FR]: {
80
+ code: Locale.fr_FR,
81
+ countryCode: 'FR',
82
+ icon: '🇫🇷',
83
+ locale: Lang.FR,
84
+ name: 'Français',
85
+ },
86
86
  [Locale.it_IT]: {
87
87
  code: Locale.it_IT,
88
88
  countryCode: 'IT',
package/src/http/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from 'ky'
2
1
  export * from './http.utils.ts'
2
+ export * from 'ky'
3
3
 
4
4
  export { default } from 'ky'
@@ -167,7 +167,6 @@ export const ICONS_NAME = Object.freeze({
167
167
  subway: 'ph:subway',
168
168
  swimmingPool: 'ph:swimming-pool',
169
169
  synagogue: 'ph:synagogue',
170
- tShirt: 'ph:t-shirt',
171
170
  taxi: 'ph:taxi',
172
171
  tennisBall: 'ph:tennis-ball',
173
172
  tent: 'ph:tent',
@@ -181,6 +180,7 @@ export const ICONS_NAME = Object.freeze({
181
180
  trendDown: 'ph:trend-down',
182
181
  trendUp: 'ph:trend-up',
183
182
  truck: 'ph:truck',
183
+ tShirt: 'ph:t-shirt',
184
184
  upload: 'ph:upload-simple',
185
185
  uploadThick: 'ph:arrow-fat-line-up',
186
186
  user: 'ph:user',
@@ -35,10 +35,7 @@ export const BOOKING_POLICY_SCHEMA = z
35
35
  hotel_id: z.string().openapi({
36
36
  description: 'Hotel id',
37
37
  }),
38
- hotel_room_offer: HOTEL_ROOM_OFFER_SCHEMA.openapi({
39
- description:
40
- 'The **Hotel Room Offer** associated with this **Booking Policy**.',
41
- }),
38
+ hotel_room_offer: HOTEL_ROOM_OFFER_SCHEMA,
42
39
  id: z.string().openapi({
43
40
  description: '**Booking Policy** id',
44
41
  }),
@@ -1,5 +1,5 @@
1
- export * from './breakfast.ts'
2
1
  export * from './booking-policy.ts'
2
+ export * from './breakfast.ts'
3
3
  export * from './cancellation-policies.ts'
4
4
  export * from './currency.ts'
5
5
  export * from './global.ts'
@@ -7,10 +7,10 @@ import type {
7
7
  } from './payment-method.ts'
8
8
 
9
9
  export type AllowedPaymentMethod =
10
+ | AllowedPaymentMethodPayLater
10
11
  | BasePaymentMethodCoupon
11
12
  | BasePaymentMethodCreditCard
12
13
  | BasePaymentMethodDepositAccount
13
- | AllowedPaymentMethodPayLater
14
14
 
15
15
  export interface AllowedPaymentMethodPayLater extends BasePaymentMethodPayLater {
16
16
  payload: PayloadPayLater
@@ -16,6 +16,12 @@ export interface Booking {
16
16
  * @memberof Booking
17
17
  */
18
18
  id?: string | null
19
+ /**
20
+ * Creation date of the **Booking**.
21
+ * @type {string}
22
+ * @memberof Booking
23
+ */
24
+ createdAt: string
19
25
  /**
20
26
  * The total number of adults who will be staying in the property.
21
27
  * @type {number}
@@ -70,12 +76,6 @@ export interface Booking {
70
76
  * @memberof Booking
71
77
  */
72
78
  contactPerson: ContactPerson
73
- /**
74
- * Creation date of the **Booking**.
75
- * @type {string}
76
- * @memberof Booking
77
- */
78
- createdAt: string
79
79
  /**
80
80
  *
81
81
  * @type {CurrencyClient}
@@ -223,10 +223,10 @@ export enum BookingApiPayLaterEnum {
223
223
  type BookingApiPayLater = `${BookingApiPayLaterEnum}`
224
224
 
225
225
  export enum BookingStatusEnum {
226
- Cx = 'bkg-cx',
226
+ Af = 'bkg-af',
227
227
  Cf = 'bkg-cf',
228
228
  Created = 'bkg-created',
229
- Af = 'bkg-af',
229
+ Cx = 'bkg-cx',
230
230
  Ip = 'bkg-ip',
231
231
  Pc = 'bkg-pc',
232
232
  Pp = 'bkg-pp',
@@ -7,6 +7,12 @@ export interface HotelOfferRequest {
7
7
  * @type {string}
8
8
  */
9
9
  id: string
10
+ /**
11
+ * Date of the **Hotel Room Offer Request** creation
12
+ * @type {string}
13
+ * @memberof HotelOfferRequestApiResponse
14
+ */
15
+ createdAt: string
10
16
  /**
11
17
  * 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.
12
18
  *
@@ -34,12 +40,6 @@ export interface HotelOfferRequest {
34
40
  * @type {string}
35
41
  */
36
42
  children?: string | null
37
- /**
38
- * Date of the **Hotel Room Offer Request** creation
39
- * @type {string}
40
- * @memberof HotelOfferRequestApiResponse
41
- */
42
- createdAt: string
43
43
  /**
44
44
  *
45
45
  * @type {EventMetadata}
@@ -80,6 +80,12 @@ export interface HotelOfferRequestResponse {
80
80
  * @memberof HotelOfferRequestApiResponse
81
81
  */
82
82
  id: string
83
+ /**
84
+ * Date of the **Hotel Offer Request** creation
85
+ * @type {string}
86
+ * @memberof HotelOfferRequestApiResponse
87
+ */
88
+ createdAt: string
83
89
  /**
84
90
  * 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.
85
91
  *
@@ -112,12 +118,6 @@ export interface HotelOfferRequestResponse {
112
118
  * @memberof HotelOfferRequestApiResponse
113
119
  */
114
120
  children?: string | null
115
- /**
116
- * Date of the **Hotel Offer Request** creation
117
- * @type {string}
118
- * @memberof HotelOfferRequestApiResponse
119
- */
120
- createdAt: string
121
121
  /**
122
122
  *
123
123
  * @type {EventMetadataApi}
@@ -8,6 +8,12 @@ export interface HotelRoomOfferRequest {
8
8
  * @memberof HotelRoomOfferRequest
9
9
  */
10
10
  id: string
11
+ /**
12
+ * Date of the **Hotel Room Offer Request** creation
13
+ * @type {string}
14
+ * @memberof HotelRoomOfferRequest
15
+ */
16
+ createdAt: string
11
17
  /**
12
18
  * Requested number of adult(s) to be accommodated.
13
19
  * @type {number}
@@ -32,12 +38,6 @@ export interface HotelRoomOfferRequest {
32
38
  * @memberof HotelRoomOfferRequest
33
39
  */
34
40
  children?: string | null
35
- /**
36
- * Date of the **Hotel Room Offer Request** creation
37
- * @type {string}
38
- * @memberof HotelRoomOfferRequest
39
- */
40
- createdAt: string
41
41
  /**
42
42
  *
43
43
  * @type {EventMetadata}
@@ -71,6 +71,12 @@ export interface HotelRoomOfferRequestResponse {
71
71
  * @memberof HotelRoomOfferRequestApiResponse
72
72
  */
73
73
  id: string
74
+ /**
75
+ * Date of the **Hotel Room Offer Request** creation
76
+ * @type {string}
77
+ * @memberof HotelRoomOfferRequestApiResponse
78
+ */
79
+ createdAt: string
74
80
  /**
75
81
  * Requested number of adult(s) to be accommodated.
76
82
  * @type {number}
@@ -95,12 +101,6 @@ export interface HotelRoomOfferRequestResponse {
95
101
  * @memberof HotelRoomOfferRequestApiResponse
96
102
  */
97
103
  children?: string | null
98
- /**
99
- * Date of the **Hotel Room Offer Request** creation
100
- * @type {string}
101
- * @memberof HotelRoomOfferRequestApiResponse
102
- */
103
- createdAt: string
104
104
  /**
105
105
  *
106
106
  * @type {EventMetadataApi}
@@ -127,18 +127,16 @@ export interface HotelRoomOfferRequestResponse {
127
127
  sourceMarket: SourceMarket
128
128
  }
129
129
 
130
- // eslint-disable-next-line no-restricted-syntax
131
- export type HotelRoomOfferRequestCreate = Pick<
132
- HotelRoomOfferRequest,
133
- | 'adultCount'
134
- | 'checkInDate'
135
- | 'checkOutDate'
136
- | 'children'
137
- | 'eventMetadata'
138
- | 'hotelId'
139
- | 'roomCount'
140
- | 'sourceMarket'
141
- >
130
+ export interface HotelRoomOfferRequestCreate {
131
+ adultCount: HotelRoomOfferRequest['adultCount']
132
+ checkInDate: HotelRoomOfferRequest['checkInDate']
133
+ checkOutDate: HotelRoomOfferRequest['checkOutDate']
134
+ children?: HotelRoomOfferRequest['children']
135
+ eventMetadata?: HotelRoomOfferRequest['eventMetadata']
136
+ hotelId: HotelRoomOfferRequest['hotelId']
137
+ roomCount: HotelRoomOfferRequest['roomCount']
138
+ sourceMarket: HotelRoomOfferRequest['sourceMarket']
139
+ }
142
140
  export interface HotelRoomOfferRequestsCreatePayload {
143
141
  hotelRoomOfferRequestCreateApi?: HotelRoomOfferRequestCreate
144
142
  }
@@ -1,31 +1,31 @@
1
+ export * from './booking.ts'
2
+ export * from './contact-person.ts'
3
+ export * from './elements-events.ts'
4
+ export * from './hotel-offer-list.ts'
5
+ export * from './hotel-offer.ts'
6
+ export * from './hotel-offers-filters.ts'
7
+ export * from './hotel-room-offer-package-type.ts'
8
+ export * from './hotel-room-offer-type.ts'
9
+ export * from './invoice.ts'
10
+ export * from './payment-method.ts'
11
+ export * from './source-market.ts'
12
+ export * from './tax.ts'
13
+ export type * from './allowed-payment-method.ts'
1
14
  export type * from './bed.ts'
2
15
  export type * from './booking-flow.ts'
3
16
  export type * from './booking-policy.ts'
4
17
  export type * from './cancellation-policy.ts'
5
18
  export type * from './currency.ts'
6
- export * from './elements-events.ts'
7
19
  export type * from './event-metadata.ts'
8
20
  export type * from './hotel-image.ts'
9
21
  export type * from './hotel-images.ts'
10
22
  export type * from './hotel-offer-request.ts'
11
- export * from './hotel-offers-filters.ts'
12
- export type * from './hotel-room-offer.ts'
13
- export * from './hotel-room-offer-type.ts'
14
- export * from './hotel-room-offer-package-type.ts'
23
+ export type * from './hotel-review-rating.ts'
24
+ export type * from './hotel-room-offer-list.ts'
15
25
  export type * from './hotel-room-offer-request.ts'
26
+ export type * from './hotel-room-offer.ts'
16
27
  export type * from './hotel-room.ts'
17
- export * from './source-market.ts'
18
- export type * from './tag.ts'
19
- export * from './tax.ts'
20
- export * from './booking.ts'
21
- export * from './payment-method.ts'
22
- export * from './invoice.ts'
28
+ export type * from './hotel-rooming-list.ts'
23
29
  export type * from './hotel.ts'
24
- export * from './hotel-offer.ts'
25
- export * from './contact-person.ts'
26
- export type * from './hotel-review-rating.ts'
30
+ export type * from './tag.ts'
27
31
  export type * from './travel-times.ts'
28
- export * from './hotel-offer-list.ts'
29
- export type * from './hotel-room-offer-list.ts'
30
- export type * from './hotel-rooming-list.ts'
31
- export type * from './allowed-payment-method.ts'
@@ -1,8 +1,8 @@
1
1
  import type { PayLaterStatus } from '../booking.ts'
2
2
 
3
3
  export enum PaymentMethodNameEnum {
4
- CreditCard = 'CREDIT_CARD',
5
4
  Coupon = 'COUPON',
5
+ CreditCard = 'CREDIT_CARD',
6
6
  DepositAccount = 'DEPOSIT_ACCOUNT',
7
7
  PayLater = 'PAY_LATER',
8
8
  }
@@ -61,7 +61,7 @@ export interface PayloadPayLater {
61
61
  status: PayLaterStatus
62
62
  }
63
63
  export interface PaymentMethodPayLater extends BasePaymentMethodPayLater {
64
- payload: { amount: number; couponId?: string | null } & PayloadPayLater
64
+ payload: PayloadPayLater & { amount: number; couponId?: string | null }
65
65
  }
66
66
 
67
67
  export interface PaymentMethodRequest {
@@ -3,6 +3,7 @@ import type { IHotelRoomStock } from './hotel-room-stock.ts'
3
3
  export interface IHotelContract {
4
4
  id: string
5
5
  createdAt: string
6
+ updatedAt: string
6
7
  forcedTotalComissionsAmount: number
7
8
  forcedTotalPurchasedAmount: number
8
9
  forcedTotalVatComissionsAmount: number
@@ -10,6 +11,5 @@ export interface IHotelContract {
10
11
  hotelRoomStocks?: IHotelRoomStock[]
11
12
  name: string
12
13
  status: string
13
- updatedAt: string
14
14
  userId: string
15
15
  }
@@ -1,5 +1,5 @@
1
1
  export * from './bad-request.exception.ts'
2
2
  export * from './forbidden.exception.ts'
3
+ export * from './internal-server-error.exception.ts'
3
4
  export * from './unauthorized.exception.ts'
4
5
  export * from './unprocessable-entity.exception.ts'
5
- export * from './internal-server-error.exception.ts'
@@ -1,8 +1,15 @@
1
+ export * from './booking.ts'
2
+ export * from './elements/index.ts'
3
+
4
+ export * from './hotel-rooming-list.ts'
5
+ export * from './http-exception/index.ts'
6
+ export * from './pagination.ts'
7
+ export * from './payment.ts'
8
+ export * from './severities.ts'
9
+ export * from './taxable.ts'
1
10
  export type * from '../countries/types.ts'
2
11
  export type * from '../currencies/types.ts'
3
-
4
12
  export type * from './api.ts'
5
- export * from './booking.ts'
6
13
  export type * from './calendar.ts'
7
14
  export type * from './cancellation-policy.ts'
8
15
  export type * from './date.ts'
@@ -12,10 +19,3 @@ export type * from './hotel-contract.ts'
12
19
  export type * from './hotel-room-stock.ts'
13
20
  export type * from './money-object.ts'
14
21
  export type * from './paginated-queries.ts'
15
- export * from './pagination.ts'
16
- export * from './payment.ts'
17
- export * from './taxable.ts'
18
- export * from './severities.ts'
19
- export * from './http-exception/index.ts'
20
- export * from './hotel-rooming-list.ts'
21
- export * from './elements/index.ts'
@@ -4,8 +4,8 @@ export enum Order {
4
4
  }
5
5
 
6
6
  export enum PaginationMode {
7
- StartingAfter = 'STARTING_AFTER',
8
7
  EndingBefore = 'ENDING_BEFORE',
8
+ StartingAfter = 'STARTING_AFTER',
9
9
  }
10
10
 
11
11
  export interface IPaginationOptions {
@@ -11,10 +11,10 @@ export enum PaymentAssociationResourceType {
11
11
  }
12
12
 
13
13
  export enum PaymentProvider {
14
- Stripe = 'STRIPE',
15
- Qonto = 'QONTO',
16
14
  IbanFirst = 'IBANFIRST',
15
+ Qonto = 'QONTO',
17
16
  Revolut = 'REVOLUT',
17
+ Stripe = 'STRIPE',
18
18
  }
19
19
 
20
20
  export enum PublicPaymentMethod {
@@ -25,6 +25,6 @@ export enum PublicPaymentMethod {
25
25
 
26
26
  export enum PublicPaymentStatus {
27
27
  Confirmed = 'confirmed',
28
- Pending = 'pending',
29
28
  Failed = 'failed',
29
+ Pending = 'pending',
30
30
  }
@@ -1,12 +1,12 @@
1
1
  export enum Severity {
2
- Info = 'info',
3
- Success = 'success',
4
- Warn = 'warn',
2
+ Contrast = 'contrast',
3
+ Danger = 'danger',
4
+ Error = 'error',
5
5
  Help = 'help',
6
+ Info = 'info',
6
7
  Primary = 'primary',
7
8
  Secondary = 'secondary',
9
+ Success = 'success',
8
10
  Tertiary = 'tertiary',
9
- Danger = 'danger',
10
- Error = 'error',
11
- Contrast = 'contrast',
11
+ Warn = 'warn',
12
12
  }
@@ -1,7 +1,7 @@
1
1
  export function amountFromPercentage(
2
2
  percentage: number,
3
3
  amount: number,
4
- roundingType: 'none' | 'round' | 'ceil' | 'floor' = 'none',
4
+ roundingType: 'ceil' | 'floor' | 'none' | 'round' = 'none',
5
5
  ): number {
6
6
  if (Number.isNaN(Number(percentage)) || Number.isNaN(Number(amount))) {
7
7
  throw new TypeError(`${percentage} || ${amount} is NaN`)
@@ -32,7 +32,7 @@ export const CASE_TRANSFORMERS_MAPPING = {
32
32
  [CaseTransformer.Snake]: snakeCase,
33
33
  }
34
34
 
35
- export function changeCase<T extends string | string[]>(
35
+ export function changeCase<T extends string[] | string>(
36
36
  input: T,
37
37
  toCase: CaseTransformer,
38
38
  ): T extends string ? string : string[] {
@@ -47,7 +47,7 @@ export function changeCase<T extends string | string[]>(
47
47
  : string[]
48
48
  }
49
49
 
50
- function matches(patterns: (string | RegExp)[], value: string) {
50
+ function matches(patterns: (RegExp | string)[], value: string) {
51
51
  return patterns.some(pattern =>
52
52
  typeof pattern === 'string' ? pattern === value : pattern.test(value),
53
53
  )
@@ -62,14 +62,14 @@ export function keysChangeCase<T = any>(
62
62
  obj: any[],
63
63
  toCase: CaseTransformer,
64
64
 
65
- options?: { deep?: boolean; exclude?: (string | RegExp)[] },
65
+ options?: { deep?: boolean; exclude?: (RegExp | string)[] },
66
66
  ): T[]
67
67
 
68
68
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
69
69
  export function keysChangeCase<T = any>(
70
70
  obj: unknown,
71
71
  toCase: CaseTransformer,
72
- options?: { deep?: boolean; exclude?: (string | RegExp)[] },
72
+ options?: { deep?: boolean; exclude?: (RegExp | string)[] },
73
73
  ): T
74
74
 
75
75
  export function keysChangeCase<T>(
@@ -77,7 +77,7 @@ export function keysChangeCase<T>(
77
77
  obj: any,
78
78
  toCase: CaseTransformer,
79
79
 
80
- options: { deep?: boolean; exclude?: (string | RegExp)[] } = { deep: true },
80
+ options: { deep?: boolean; exclude?: (RegExp | string)[] } = { deep: true },
81
81
  ): unknown {
82
82
  if (isObject(obj) && !(obj instanceof Date)) {
83
83
  return Object.keys(obj).reduce<any>((result, key) => {
@@ -16,7 +16,7 @@ type CompositeKeyOptions<T> =
16
16
  NonNullable<T> extends (infer U)[]
17
17
  ? CompositeKeyOptions<U>
18
18
  : CompositeLeafAttributes & {
19
- attributes: CompositeOmitAttributes<T> | CompositeAttributesType
19
+ attributes: CompositeAttributesType | CompositeOmitAttributes<T>
20
20
  children?: {
21
21
  [K in keyof T]?: NonNullable<T[K]> extends object
22
22
  ? CompositeKeyOptions<NonNullable<T[K]>>
@@ -72,7 +72,7 @@ export function isDate(value: unknown): value is Date {
72
72
  return value instanceof Date && !isNaN(value.getTime())
73
73
  }
74
74
 
75
- export type DateInput = string | Date
75
+ export type DateInput = Date | string
76
76
 
77
77
  export function generateDates(
78
78
  startDate: DateInput,
@@ -4,9 +4,9 @@
4
4
  * @param keyOrGetter The key to group by or a function that returns the key.
5
5
  * @returns An object where keys are the group identifiers and values are arrays of items.
6
6
  */
7
- function groupBy<T, K extends string | number>(
7
+ function groupBy<T, K extends number | string>(
8
8
  array: T[],
9
- keyOrGetter: keyof T | ((item: T) => K | undefined),
9
+ keyOrGetter: ((item: T) => K | undefined) | keyof T,
10
10
  ): Record<K, T[]> {
11
11
  return array.reduce(
12
12
  (acc, item) => {
@@ -26,7 +26,7 @@ export function generateImageUrls(
26
26
  )
27
27
  }
28
28
 
29
- type ImageSize = 'xs' | 's' | 'm' | 'l' | 'xl'
29
+ type ImageSize = 'l' | 'm' | 's' | 'xl' | 'xs'
30
30
 
31
31
  function selectBestSize(
32
32
  hotelImage: HotelImage,
@@ -1,7 +1,6 @@
1
1
  export * from './add-classes.ts'
2
2
  export * from './amount-from-percentage.ts'
3
3
  export * from './case-transformers.ts'
4
- export * from './keys-case-transformer.ts'
5
4
  export * from './chunk.ts'
6
5
  export * from './colors.ts'
7
6
  export * from './compact-object.ts'
@@ -9,6 +8,7 @@ export * from './compact.ts'
9
8
  export * from './compute-margin-rate.ts'
10
9
  export * from './compute-selling-price.ts'
11
10
  export * from './create-composite-key.ts'
11
+ export * from './create-dummy-hotel-images.ts'
12
12
  export * from './dates.ts'
13
13
  export * from './dayjs.ts'
14
14
  export * from './debounce.ts'
@@ -20,8 +20,8 @@ export * from './generate-numbers-from-str.ts'
20
20
  export * from './generate-pseudo-random-string.ts'
21
21
  export * from './generate-random-nearby-geolocation.ts'
22
22
  export * from './get-guest-count.ts'
23
- export * from './get-night-count.ts'
24
23
  export * from './get-hotel-room-offer-room-count.ts'
24
+ export * from './get-night-count.ts'
25
25
  export * from './get-random-element-from-array.ts'
26
26
  export * from './get-random-hex-color.ts'
27
27
  export * from './get-random-int.ts'
@@ -33,6 +33,7 @@ export * from './is-equal.ts'
33
33
  export * from './is-nil.ts'
34
34
  export * from './is-object.ts'
35
35
  export * from './key-by.ts'
36
+ export * from './keys-case-transformer.ts'
36
37
  export * from './lang-default-fallbacks.ts'
37
38
  export * from './map-keys.ts'
38
39
  export * from './map-values.ts'
@@ -55,9 +56,8 @@ export * from './to-boolean.ts'
55
56
  export * from './to-lang.ts'
56
57
  export * from './to-locale.ts'
57
58
  export * from './transform-schema-keys.ts'
58
- export * from './uniq.ts'
59
59
  export * from './uniq-by.ts'
60
60
  export * from './uniq-with.ts'
61
+ export * from './uniq.ts'
61
62
  export * from './validators.ts'
62
63
  export * from './weighted-mean.ts'
63
- export * from './create-dummy-hotel-images.ts'
@@ -8,7 +8,7 @@
8
8
  */
9
9
  export function keyBy<T>(
10
10
  collection: T[] | null | undefined,
11
- iteratee: ((value: T) => string | number) | keyof T,
11
+ iteratee: ((value: T) => number | string) | keyof T,
12
12
  ): Record<string, T> {
13
13
  return (
14
14
  collection?.reduce<Record<string, T>>((acc, item) => {
@@ -4,8 +4,8 @@
4
4
  */
5
5
  export const mapKeys = <
6
6
  TValue,
7
- TKey extends string | number | symbol,
8
- TNewKey extends string | number | symbol,
7
+ TKey extends number | string | symbol,
8
+ TNewKey extends number | string | symbol,
9
9
  >(
10
10
  obj: Record<TKey, TValue>,
11
11
  mapFunc: (key: TKey, value: TValue) => TNewKey,
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const mapValues = <
5
5
  TValue,
6
- TKey extends string | number | symbol,
6
+ TKey extends number | string | symbol,
7
7
  TNewValue,
8
8
  >(
9
9
  obj: Record<TKey, TValue>,
@@ -9,7 +9,7 @@
9
9
  */
10
10
  export function omitBy<T extends object>(
11
11
  object: T,
12
- predicate: ((value: T[keyof T], key: keyof T) => boolean) | string,
12
+ predicate: string | ((value: T[keyof T], key: keyof T) => boolean),
13
13
  ): Partial<T> {
14
14
  const result = {} as Partial<T>
15
15
 
package/src/utils/omit.ts CHANGED
@@ -3,9 +3,10 @@
3
3
  * Accepts a single key or an array of keys. Symbol keys are supported.
4
4
  * If `object` is nullish, returns an empty object.
5
5
  */
6
+ // eslint-disable-next-line no-restricted-syntax
6
7
  export function omit<T extends object, K extends keyof T>(
7
8
  object: T | null | undefined,
8
- keys: readonly K[] | K,
9
+ keys: K | readonly K[],
9
10
  // eslint-disable-next-line no-restricted-syntax
10
11
  ): Omit<T, K> {
11
12
  if (object === null || object === undefined) {
package/src/utils/pick.ts CHANGED
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line no-restricted-syntax
1
2
  export function pick<T extends object, K extends keyof T>(
2
3
  obj: T,
3
4
  keys: readonly K[],
@@ -6,7 +6,7 @@ import { CaseTransformer, keysChangeCase } from './case-transformers.ts'
6
6
  export interface IPollerResponse<T = any> {
7
7
  data?: T
8
8
  meta?: {
9
- status: 'IN_PROGRESS' | 'COMPLETE'
9
+ status: 'COMPLETE' | 'IN_PROGRESS'
10
10
  }
11
11
  }
12
12
 
@@ -14,7 +14,7 @@ export type TPollerRequestCallback<V> = () => Promise<V>
14
14
  export type TPollerEventCallbackArg<
15
15
  V extends IPollerResponse = IPollerResponse,
16
16
  > = V | Error
17
- export type TPollerEventName = 'data' | 'error' | 'complete'
17
+ export type TPollerEventName = 'complete' | 'data' | 'error'
18
18
  export type TPollerEventCallback<V extends IPollerResponse = IPollerResponse> =
19
19
  (arg?: TPollerEventCallbackArg<V>) => void
20
20
  export type TPollerEvents<V extends IPollerResponse = IPollerResponse> = {
@@ -233,7 +233,7 @@ export function pollRequest<R extends IPollerResponse>(
233
233
  request: TRequest<R>,
234
234
  options: TOptions<R>,
235
235
  pollerCallback?: TPollerCallback<R>,
236
- ): Promise<PollerReturn<R> | R | undefined> | PollerReturn<R> | R | undefined {
236
+ ): PollerReturn<R> | Promise<PollerReturn<R> | R | undefined> | R | undefined {
237
237
  const poller: Poller<R> = Poller.getInstance()
238
238
 
239
239
  poller.poll(request, options)
@@ -1,16 +1,16 @@
1
1
  const TS_QUERY_SPECIAL_CHARS = new Set([
2
- '&',
3
- '|',
4
- ':',
5
2
  '!',
3
+ '&',
6
4
  '(',
7
5
  ')',
6
+ ':',
8
7
  '<',
9
8
  '>',
10
9
  '@',
10
+ '|',
11
11
  ])
12
12
 
13
- const REGEX_SPECIAL_CHARS = new Set(['|', '(', ')'])
13
+ const REGEX_SPECIAL_CHARS = new Set(['(', ')', '|'])
14
14
 
15
15
  export function prepareTsQuery(query: string): string | null {
16
16
  // Remove leading/trailing whitespaces
@@ -3,6 +3,7 @@
3
3
  * object. Optional second argument shakes out values
4
4
  * by custom evaluation.
5
5
  */
6
+ // eslint-disable-next-line no-restricted-syntax
6
7
  export function shake<RemovedKeys extends string, T>(
7
8
  obj: T,
8
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -2,7 +2,7 @@ type Iteratee<T> = ((item: T) => unknown) | keyof T
2
2
  type SortOrder = 'asc' | 'desc'
3
3
 
4
4
  export function sortBy<T>(
5
- collection: T[] | Record<string, T> | null | undefined,
5
+ collection: Record<string, T> | T[] | null | undefined,
6
6
  iteratees?: Iteratee<T> | Iteratee<T>[] | string,
7
7
  order?: SortOrder | SortOrder[],
8
8
  ): T[] {
package/src/utils/sum.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export function sum(arr: number[]): number
2
2
  export function sum<T>(
3
3
  arr: T[],
4
- keyOrFunc: keyof T | ((item: T) => number),
4
+ keyOrFunc: ((item: T) => number) | keyof T,
5
5
  ): number
6
6
  export function sum<T>(
7
7
  arr: T[],
8
- keyOrFunc?: keyof T | ((item: T) => number),
8
+ keyOrFunc?: ((item: T) => number) | keyof T,
9
9
  ): number {
10
10
  if (arr.length === 0) {
11
11
  return 0
@@ -4,22 +4,22 @@ import type { ExtendedLocale } from '../constants/locales.ts'
4
4
 
5
5
  export function toLang(localeOrLang: ExtendedLocale): Lang {
6
6
  switch (localeOrLang) {
7
- case Lang.EN:
8
- case Locale.en_US: {
9
- return Lang.EN
10
- }
11
- case Lang.FR:
12
- case Locale.fr_FR: {
13
- return Lang.FR
14
- }
15
7
  case Lang.DE:
16
8
  case Locale.de_DE: {
17
9
  return Lang.DE
18
10
  }
11
+ case Lang.EN:
12
+ case Locale.en_US: {
13
+ return Lang.EN
14
+ }
19
15
  case Lang.ES:
20
16
  case Locale.es_ES: {
21
17
  return Lang.ES
22
18
  }
19
+ case Lang.FR:
20
+ case Locale.fr_FR: {
21
+ return Lang.FR
22
+ }
23
23
  case Lang.IT:
24
24
  case Locale.it_IT: {
25
25
  return Lang.IT
@@ -4,22 +4,22 @@ import type { ExtendedLocale } from '../constants/locales.ts'
4
4
 
5
5
  export function toLocale(localeOrLang: ExtendedLocale): Locale {
6
6
  switch (localeOrLang) {
7
- case Lang.EN:
8
- case Locale.en_US: {
9
- return Locale.en_US
10
- }
11
- case Lang.FR:
12
- case Locale.fr_FR: {
13
- return Locale.fr_FR
14
- }
15
7
  case Lang.DE:
16
8
  case Locale.de_DE: {
17
9
  return Locale.de_DE
18
10
  }
11
+ case Lang.EN:
12
+ case Locale.en_US: {
13
+ return Locale.en_US
14
+ }
19
15
  case Lang.ES:
20
16
  case Locale.es_ES: {
21
17
  return Locale.es_ES
22
18
  }
19
+ case Lang.FR:
20
+ case Locale.fr_FR: {
21
+ return Locale.fr_FR
22
+ }
23
23
  case Lang.IT:
24
24
  case Locale.it_IT: {
25
25
  return Locale.it_IT
@@ -1,6 +1,6 @@
1
1
  export function uniqBy<T>(
2
- array: T[] | undefined | null,
3
- iteratee: keyof T | ((item: T) => unknown),
2
+ array: T[] | null | undefined,
3
+ iteratee: ((item: T) => unknown) | keyof T,
4
4
  ): T[] {
5
5
  const seen = new Set()
6
6
  return (
package/src/utils/uniq.ts CHANGED
@@ -6,11 +6,11 @@
6
6
  */
7
7
  export function uniq<T>(
8
8
  array: readonly T[],
9
- toKey?: (item: T) => string | number | symbol,
9
+ toKey?: (item: T) => number | string | symbol,
10
10
  ): T[] {
11
- const valueMap = array.reduce<Record<string | number | symbol, T>>(
11
+ const valueMap = array.reduce<Record<number | string | symbol, T>>(
12
12
  (acc, item) => {
13
- const key = toKey ? toKey(item) : (item as string | number | symbol)
13
+ const key = toKey ? toKey(item) : (item as number | string | symbol)
14
14
  if (acc[key]) {
15
15
  return acc
16
16
  }