@revolugo/common 6.9.6 → 6.9.7-beta.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 (63) hide show
  1. package/package.json +12 -7
  2. package/src/cancellation-policies.test.ts +12 -9
  3. package/src/cancellation-policies.ts +31 -26
  4. package/src/constants/countries.ts +0 -2515
  5. package/src/constants/currencies.ts +0 -1812
  6. package/src/constants/environment.ts +1 -0
  7. package/src/constants/hotel-offers.ts +2 -0
  8. package/src/constants/hotel.ts +3 -0
  9. package/src/constants/locales.ts +6 -0
  10. package/src/constants/measurement.ts +1 -0
  11. package/src/constants/time.ts +1 -0
  12. package/src/countries/constants.ts +2518 -0
  13. package/src/countries/index.ts +7 -0
  14. package/src/currencies/index.ts +1817 -0
  15. package/src/models/paginated-queries.ts +1 -0
  16. package/src/types/country.ts +1 -1
  17. package/src/types/elements/amenity.ts +266 -0
  18. package/src/types/elements/bed.ts +20 -0
  19. package/src/types/elements/booking-policy.ts +80 -0
  20. package/src/types/elements/booking.ts +236 -0
  21. package/src/types/elements/cancellation-policy.ts +20 -0
  22. package/src/types/elements/contact-person.ts +158 -0
  23. package/src/types/elements/currency.ts +3 -0
  24. package/src/types/elements/event-metadata.ts +38 -0
  25. package/src/types/elements/event.ts +14 -0
  26. package/src/types/elements/hotel-image.ts +44 -0
  27. package/src/types/elements/hotel-images.ts +47 -0
  28. package/src/types/elements/hotel-offer-request.ts +82 -0
  29. package/src/types/elements/hotel-offer.ts +208 -0
  30. package/src/types/elements/hotel-review-rating.ts +14 -0
  31. package/src/types/elements/hotel-room-offer-package-type.ts +8 -0
  32. package/src/types/elements/hotel-room-offer-request.ts +77 -0
  33. package/src/types/elements/hotel-room-offer-type.ts +6 -0
  34. package/src/types/elements/hotel-room-offer.ts +192 -0
  35. package/src/types/elements/hotel-room.ts +102 -0
  36. package/src/types/elements/hotel-rooming-list.ts +49 -0
  37. package/src/types/elements/hotel.ts +184 -0
  38. package/src/types/elements/index.ts +22 -0
  39. package/src/types/elements/invoice.ts +21 -0
  40. package/src/types/elements/payment-method.ts +159 -0
  41. package/src/types/elements/source-market.ts +247 -0
  42. package/src/types/elements/tag.ts +32 -0
  43. package/src/types/elements/tax.ts +52 -0
  44. package/src/types/elements/travel-times.ts +45 -0
  45. package/src/types/index.ts +1 -0
  46. package/src/utils/array-tools.ts +3 -2
  47. package/src/utils/case-transformers.ts +1 -0
  48. package/src/utils/colors.ts +4 -4
  49. package/src/utils/currency.ts +30 -18
  50. package/src/utils/dates.ts +6 -10
  51. package/src/utils/debounce.ts +2 -2
  52. package/src/utils/find-unique-keys.ts +2 -2
  53. package/src/utils/get-guest-count.ts +1 -0
  54. package/src/utils/index.ts +1 -1
  55. package/src/utils/lang-default-fallbacks.ts +1 -1
  56. package/src/utils/math.ts +3 -3
  57. package/src/utils/numbers.ts +8 -7
  58. package/src/utils/object-tools.ts +60 -2
  59. package/src/utils/poller.ts +1 -0
  60. package/src/utils/random.ts +12 -0
  61. package/src/utils/strings.ts +5 -2
  62. package/src/utils/validators.ts +1 -0
  63. package/src/utils/countries.ts +0 -4
@@ -0,0 +1,159 @@
1
+ export interface PaymentMethodRequestPayloadApi {
2
+ /**
3
+ *
4
+ * @type {string}
5
+ * @memberof PaymentMethodRequestPayloadApi
6
+ */
7
+ couponId?: string | null
8
+ }
9
+
10
+ export interface PaymentMethodRequestApi {
11
+ /**
12
+ *
13
+ * @type {string}
14
+ * @memberof PaymentMethodRequestApi
15
+ */
16
+ name: PaymentMethodApiName
17
+ /**
18
+ *
19
+ * @type {PaymentMethodRequestPayloadApi}
20
+ * @memberof PaymentMethodRequestApi
21
+ */
22
+ payload?: PaymentMethodRequestPayloadApi
23
+ }
24
+
25
+ export interface PaymentMethodApi {
26
+ /**
27
+ *
28
+ * @type {string}
29
+ * @memberof PaymentMethodApiOneOf
30
+ */
31
+ name: PaymentMethodApiName
32
+ /**
33
+ *
34
+ * @type {PaymentMethodApiOneOfPayload}
35
+ * @memberof PaymentMethodApiOneOf
36
+ */
37
+ payload:
38
+ | PaymentMethodApiOneOfPayload
39
+ | PaymentMethodApiOneOf1Payload
40
+ | PaymentMethodApiOneOf2Payload
41
+ }
42
+
43
+ export enum PaymentMethodApiNameEnum {
44
+ CreditCard = 'CREDIT_CARD',
45
+ Coupon = 'COUPON',
46
+ DepositAccount = 'DEPOSIT_ACCOUNT',
47
+ }
48
+
49
+ type PaymentMethodApiName = `${PaymentMethodApiNameEnum}`
50
+
51
+ /**
52
+ *
53
+ * @export
54
+ * @interface PaymentMethodApiOneOf1
55
+ */
56
+ export interface PaymentMethodApiOneOf1 {
57
+ /**
58
+ *
59
+ * @type {string}
60
+ * @memberof PaymentMethodApiOneOf1
61
+ */
62
+ name: PaymentMethodApiName
63
+ /**
64
+ *
65
+ * @type {PaymentMethodApiOneOf1Payload}
66
+ * @memberof PaymentMethodApiOneOf1
67
+ */
68
+ payload: PaymentMethodApiOneOf1Payload
69
+ }
70
+
71
+ /**
72
+ *
73
+ * @export
74
+ * @interface PaymentMethodApiOneOf1Payload
75
+ */
76
+ export interface PaymentMethodApiOneOf1Payload {
77
+ /**
78
+ *
79
+ * @type {number}
80
+ * @memberof PaymentMethodApiOneOf1Payload
81
+ */
82
+ amount: number
83
+ /**
84
+ *
85
+ * @type {string}
86
+ * @memberof PaymentMethodApiOneOf1Payload
87
+ */
88
+ couponId?: string | null
89
+ /**
90
+ *
91
+ * @type {string}
92
+ * @memberof PaymentMethodApiOneOf1Payload
93
+ */
94
+ token: string
95
+ }
96
+ /**
97
+ *
98
+ * @export
99
+ * @interface PaymentMethodApiOneOf2
100
+ */
101
+ export interface PaymentMethodApiOneOf2 {
102
+ /**
103
+ *
104
+ * @type {string}
105
+ * @memberof PaymentMethodApiOneOf2
106
+ */
107
+ name: PaymentMethodApiName
108
+ /**
109
+ *
110
+ * @type {PaymentMethodApiOneOf2Payload}
111
+ * @memberof PaymentMethodApiOneOf2
112
+ */
113
+ payload: PaymentMethodApiOneOf2Payload
114
+ }
115
+
116
+ /**
117
+ *
118
+ * @export
119
+ * @interface PaymentMethodApiOneOf2Payload
120
+ */
121
+ export interface PaymentMethodApiOneOf2Payload {
122
+ /**
123
+ *
124
+ * @type {number}
125
+ * @memberof PaymentMethodApiOneOf2Payload
126
+ */
127
+ amount: number
128
+ /**
129
+ *
130
+ * @type {string}
131
+ * @memberof PaymentMethodApiOneOf2Payload
132
+ */
133
+ couponId?: string | null
134
+ /**
135
+ *
136
+ * @type {string}
137
+ * @memberof PaymentMethodApiOneOf2Payload
138
+ */
139
+ token?: string | null
140
+ }
141
+ /**
142
+ *
143
+ * @export
144
+ * @interface PaymentMethodApiOneOfPayload
145
+ */
146
+ export interface PaymentMethodApiOneOfPayload {
147
+ /**
148
+ *
149
+ * @type {number}
150
+ * @memberof PaymentMethodApiOneOfPayload
151
+ */
152
+ amount: number
153
+ /**
154
+ *
155
+ * @type {string}
156
+ * @memberof PaymentMethodApiOneOfPayload
157
+ */
158
+ couponId: string
159
+ }
@@ -0,0 +1,247 @@
1
+ export enum SourceMarketEnum {
2
+ Ad = 'AD',
3
+ Ae = 'AE',
4
+ Af = 'AF',
5
+ Ag = 'AG',
6
+ Ai = 'AI',
7
+ Al = 'AL',
8
+ Am = 'AM',
9
+ Ao = 'AO',
10
+ Ar = 'AR',
11
+ As = 'AS',
12
+ At = 'AT',
13
+ Au = 'AU',
14
+ Aw = 'AW',
15
+ Ax = 'AX',
16
+ Az = 'AZ',
17
+ Ba = 'BA',
18
+ Bb = 'BB',
19
+ Bd = 'BD',
20
+ Be = 'BE',
21
+ Bf = 'BF',
22
+ Bg = 'BG',
23
+ Bh = 'BH',
24
+ Bi = 'BI',
25
+ Bj = 'BJ',
26
+ Bl = 'BL',
27
+ Bm = 'BM',
28
+ Bn = 'BN',
29
+ Bo = 'BO',
30
+ Bq = 'BQ',
31
+ Br = 'BR',
32
+ Bs = 'BS',
33
+ Bt = 'BT',
34
+ Bw = 'BW',
35
+ By = 'BY',
36
+ Bz = 'BZ',
37
+ Ca = 'CA',
38
+ Cc = 'CC',
39
+ Cd = 'CD',
40
+ Cf = 'CF',
41
+ Cg = 'CG',
42
+ Ch = 'CH',
43
+ Ci = 'CI',
44
+ Ck = 'CK',
45
+ Cl = 'CL',
46
+ Cm = 'CM',
47
+ Cn = 'CN',
48
+ Co = 'CO',
49
+ Cr = 'CR',
50
+ Cu = 'CU',
51
+ Cv = 'CV',
52
+ Cw = 'CW',
53
+ Cx = 'CX',
54
+ Cy = 'CY',
55
+ Cz = 'CZ',
56
+ De = 'DE',
57
+ Dj = 'DJ',
58
+ Dk = 'DK',
59
+ Dm = 'DM',
60
+ Do = 'DO',
61
+ Dz = 'DZ',
62
+ Ec = 'EC',
63
+ Ee = 'EE',
64
+ Eg = 'EG',
65
+ Eh = 'EH',
66
+ Er = 'ER',
67
+ Es = 'ES',
68
+ Et = 'ET',
69
+ Fi = 'FI',
70
+ Fj = 'FJ',
71
+ Fk = 'FK',
72
+ Fm = 'FM',
73
+ Fo = 'FO',
74
+ Fr = 'FR',
75
+ Ga = 'GA',
76
+ Gb = 'GB',
77
+ Gd = 'GD',
78
+ Ge = 'GE',
79
+ Gf = 'GF',
80
+ Gg = 'GG',
81
+ Gh = 'GH',
82
+ Gi = 'GI',
83
+ Gl = 'GL',
84
+ Gm = 'GM',
85
+ Gn = 'GN',
86
+ Gp = 'GP',
87
+ Gq = 'GQ',
88
+ Gr = 'GR',
89
+ Gt = 'GT',
90
+ Gu = 'GU',
91
+ Gw = 'GW',
92
+ Gy = 'GY',
93
+ Hk = 'HK',
94
+ Hn = 'HN',
95
+ Hr = 'HR',
96
+ Ht = 'HT',
97
+ Hu = 'HU',
98
+ Id = 'ID',
99
+ Ie = 'IE',
100
+ Il = 'IL',
101
+ Im = 'IM',
102
+ In = 'IN',
103
+ Io = 'IO',
104
+ Iq = 'IQ',
105
+ Ir = 'IR',
106
+ Is = 'IS',
107
+ It = 'IT',
108
+ Je = 'JE',
109
+ Jm = 'JM',
110
+ Jo = 'JO',
111
+ Jp = 'JP',
112
+ Ke = 'KE',
113
+ Kg = 'KG',
114
+ Kh = 'KH',
115
+ Ki = 'KI',
116
+ Km = 'KM',
117
+ Kn = 'KN',
118
+ Kp = 'KP',
119
+ Kr = 'KR',
120
+ Kw = 'KW',
121
+ Ky = 'KY',
122
+ Kz = 'KZ',
123
+ La = 'LA',
124
+ Lb = 'LB',
125
+ Lc = 'LC',
126
+ Li = 'LI',
127
+ Lk = 'LK',
128
+ Lr = 'LR',
129
+ Ls = 'LS',
130
+ Lt = 'LT',
131
+ Lu = 'LU',
132
+ Lv = 'LV',
133
+ Ly = 'LY',
134
+ Ma = 'MA',
135
+ Mc = 'MC',
136
+ Md = 'MD',
137
+ Me = 'ME',
138
+ Mf = 'MF',
139
+ Mg = 'MG',
140
+ Mh = 'MH',
141
+ Mk = 'MK',
142
+ Ml = 'ML',
143
+ Mm = 'MM',
144
+ Mn = 'MN',
145
+ Mo = 'MO',
146
+ Mp = 'MP',
147
+ Mq = 'MQ',
148
+ Mr = 'MR',
149
+ Ms = 'MS',
150
+ Mt = 'MT',
151
+ Mu = 'MU',
152
+ Mv = 'MV',
153
+ Mw = 'MW',
154
+ Mx = 'MX',
155
+ My = 'MY',
156
+ Mz = 'MZ',
157
+ Na = 'NA',
158
+ Nc = 'NC',
159
+ Ne = 'NE',
160
+ Nf = 'NF',
161
+ Ng = 'NG',
162
+ Ni = 'NI',
163
+ Nl = 'NL',
164
+ No = 'NO',
165
+ Np = 'NP',
166
+ Nr = 'NR',
167
+ Nu = 'NU',
168
+ Nz = 'NZ',
169
+ Om = 'OM',
170
+ Pa = 'PA',
171
+ Pe = 'PE',
172
+ Pf = 'PF',
173
+ Pg = 'PG',
174
+ Ph = 'PH',
175
+ Pk = 'PK',
176
+ Pl = 'PL',
177
+ Pm = 'PM',
178
+ Pr = 'PR',
179
+ Ps = 'PS',
180
+ Pt = 'PT',
181
+ Pw = 'PW',
182
+ Py = 'PY',
183
+ Qa = 'QA',
184
+ Re = 'RE',
185
+ Ro = 'RO',
186
+ Rs = 'RS',
187
+ Ru = 'RU',
188
+ Rw = 'RW',
189
+ Sa = 'SA',
190
+ Sb = 'SB',
191
+ Sc = 'SC',
192
+ Sd = 'SD',
193
+ Se = 'SE',
194
+ Sg = 'SG',
195
+ Sh = 'SH',
196
+ Si = 'SI',
197
+ Sj = 'SJ',
198
+ Sk = 'SK',
199
+ Sl = 'SL',
200
+ Sm = 'SM',
201
+ Sn = 'SN',
202
+ So = 'SO',
203
+ Sr = 'SR',
204
+ Ss = 'SS',
205
+ St = 'ST',
206
+ Sv = 'SV',
207
+ Sx = 'SX',
208
+ Sy = 'SY',
209
+ Sz = 'SZ',
210
+ Tc = 'TC',
211
+ Td = 'TD',
212
+ Tg = 'TG',
213
+ Th = 'TH',
214
+ Tj = 'TJ',
215
+ Tk = 'TK',
216
+ Tl = 'TL',
217
+ Tm = 'TM',
218
+ Tn = 'TN',
219
+ To = 'TO',
220
+ Tr = 'TR',
221
+ Tt = 'TT',
222
+ Tv = 'TV',
223
+ Tw = 'TW',
224
+ Tz = 'TZ',
225
+ Ua = 'UA',
226
+ Ug = 'UG',
227
+ Us = 'US',
228
+ Uy = 'UY',
229
+ Uz = 'UZ',
230
+ Va = 'VA',
231
+ Vc = 'VC',
232
+ Ve = 'VE',
233
+ Vg = 'VG',
234
+ Vi = 'VI',
235
+ Vn = 'VN',
236
+ Vu = 'VU',
237
+ Wf = 'WF',
238
+ Ws = 'WS',
239
+ Xk = 'XK',
240
+ Ye = 'YE',
241
+ Yt = 'YT',
242
+ Za = 'ZA',
243
+ Zm = 'ZM',
244
+ Zw = 'ZW',
245
+ }
246
+
247
+ export type SourceMarket = `${SourceMarketEnum}`
@@ -0,0 +1,32 @@
1
+ export interface Tag {
2
+ /**
3
+ *
4
+ * @type {string}
5
+ * @memberof Tag
6
+ */
7
+ bg?: string | null
8
+ /**
9
+ *
10
+ * @type {string}
11
+ * @memberof Tag
12
+ */
13
+ color?: string | null
14
+ /**
15
+ *
16
+ * @type {string}
17
+ * @memberof Tag
18
+ */
19
+ description?: string | null
20
+ /**
21
+ *
22
+ * @type {string}
23
+ * @memberof Tag
24
+ */
25
+ faIcon?: string | null
26
+ /**
27
+ *
28
+ * @type {string}
29
+ * @memberof Tag
30
+ */
31
+ name: string
32
+ }
@@ -0,0 +1,52 @@
1
+ export enum TaxFrequencyEnum {
2
+ Night = 'PER_NIGHT',
3
+ Stay = 'PER_STAY',
4
+ }
5
+
6
+ export type TaxFrequency = `${TaxFrequencyEnum}`
7
+
8
+ export enum TaxModeEnum {
9
+ Adult = 'PER_ADULT',
10
+ Booking = 'PER_BOOKING',
11
+ }
12
+
13
+ export type TaxMode = `${TaxModeEnum}`
14
+
15
+ export interface Tax {
16
+ /**
17
+ * Tax amount expressed in the requested currency.
18
+ * @type {number}
19
+ * @memberof Tax
20
+ */
21
+ amount?: number | null
22
+ /**
23
+ * Tax code.
24
+ * @type {string}
25
+ * @memberof Tax
26
+ */
27
+ code?: string
28
+ /**
29
+ * Tax description.
30
+ * @type {string}
31
+ * @memberof Tax
32
+ */
33
+ description?: string | null
34
+ /**
35
+ * Tax percentage on the total amount.
36
+ * @type {number}
37
+ * @memberof Tax
38
+ */
39
+ percentage?: number | null
40
+ /**
41
+ * Tax frequency. Specifies if the tax applies per stay or per night
42
+ * @type {string}
43
+ * @memberof Tax
44
+ */
45
+ taxFrequency: TaxFrequency
46
+ /**
47
+ * Tax mode. Specifies if the tax applies per occupant, per booking or per room
48
+ * @type {string}
49
+ * @memberof Tax
50
+ */
51
+ taxMode: TaxMode
52
+ }
@@ -0,0 +1,45 @@
1
+ export interface TravelTimeItem {
2
+ /**
3
+ *
4
+ * @type {string}
5
+ * @memberof TravelTimeItem
6
+ */
7
+ description?: string | null
8
+ /**
9
+ *
10
+ * @type {string}
11
+ * @memberof TravelTimeItem
12
+ */
13
+ name: string
14
+ /**
15
+ *
16
+ * @type {TravelTimes}
17
+ * @memberof TravelTimeItem
18
+ */
19
+ travelTimes?: TravelTimes | null
20
+ }
21
+ /**
22
+ *
23
+ * @export
24
+ * @interface TravelTimes
25
+ */
26
+ export interface TravelTimes {
27
+ /**
28
+ *
29
+ * @type {number}
30
+ * @memberof TravelTimes
31
+ */
32
+ driving?: number
33
+ /**
34
+ *
35
+ * @type {number}
36
+ * @memberof TravelTimes
37
+ */
38
+ transit?: number
39
+ /**
40
+ *
41
+ * @type {number}
42
+ * @memberof TravelTimes
43
+ */
44
+ walking?: number
45
+ }
@@ -16,3 +16,4 @@ export * from './taxable.ts'
16
16
  export * from './severities.ts'
17
17
  export * from './http-exception/index.ts'
18
18
  export * from './hotel-rooming-list.ts'
19
+ export * from './elements/index.ts'
@@ -6,8 +6,9 @@ export function chunk<T>(array: T[], size: number): T[][] {
6
6
  return chunks
7
7
  }
8
8
 
9
- export const getRandomElementFromArray = <T>(array: readonly T[]): T =>
10
- array[Math.floor(Math.random() * array.length)]
9
+ export function getRandomElementFromArray<T>(array: readonly T[]): T {
10
+ return array[Math.floor(Math.random() * array.length)]
11
+ }
11
12
 
12
13
  export function shuffleArray<T>(array: T[]): T[] {
13
14
  const shuffled = [...array]
@@ -23,6 +23,7 @@ export enum CaseTransformer {
23
23
  Snake = 'snakeCase',
24
24
  }
25
25
 
26
+ /* @__PURE__ */
26
27
  const CASE_TRANSORMERS_MAPPING = {
27
28
  [CaseTransformer.Camel]: camelCase,
28
29
  [CaseTransformer.Capital]: capitalCase,
@@ -1,9 +1,9 @@
1
1
  import { generateNumbersFromStr } from './numbers.ts'
2
2
 
3
- export const generateRandomColorFromString = (
3
+ export function generateRandomColorFromString(
4
4
  str: string,
5
5
  existingColors: string[],
6
- ): string => {
6
+ ): string {
7
7
  const [num1, num2] = generateNumbersFromStr(str)
8
8
  // adjust this value to control how close the generated color is to the existing colors
9
9
  const hueRange = 5
@@ -20,7 +20,7 @@ export const generateRandomColorFromString = (
20
20
  return newColor
21
21
  }
22
22
 
23
- export const hexToRgba = (hex: string, opacity: number): string => {
23
+ export function hexToRgba(hex: string, opacity: number): string {
24
24
  // Copy the value of 'hex' into a local variable without modifying the original parameter
25
25
  let hexWithoutHash = hex
26
26
 
@@ -44,7 +44,7 @@ export const hexToRgba = (hex: string, opacity: number): string => {
44
44
  const barColors = ['#006EFF', '#FF9800', '#9C27B0', '#F44336', '#4CAF50']
45
45
  const contractIdToColors = new Map<string, string>()
46
46
 
47
- export const getRangeColor = (id: string): string => {
47
+ export function getRangeColor(id: string): string {
48
48
  if (!contractIdToColors.has(id)) {
49
49
  contractIdToColors.set(id, generateRandomColorFromString(id, barColors))
50
50
  }