@revolugo/common 6.15.5 → 6.15.6-alpha.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolugo/common",
3
- "version": "6.15.5",
3
+ "version": "6.15.6-alpha.0",
4
4
  "private": false,
5
5
  "description": "Revolugo common",
6
6
  "author": "Revolugo",
@@ -16,7 +16,6 @@
16
16
  ],
17
17
  "exports": {
18
18
  "./amenities": "./src/amenities/index.ts",
19
- "./assets": "./src/assets/index.ts",
20
19
  "./cancellation-policies": "./src/cancellation-policies.ts",
21
20
  "./countries": "./src/countries/index.ts",
22
21
  "./constants": "./src/constants/index.ts",
@@ -32,9 +31,9 @@
32
31
  "dependencies": {
33
32
  "change-case": "5.4.4",
34
33
  "dayjs": "1.11.19",
35
- "ky": "1.14.1",
34
+ "ky": "1.14.2",
36
35
  "slugify": "1.6.6",
37
- "type-fest": "5.3.0",
36
+ "type-fest": "5.3.1",
38
37
  "uuid": "13.0.0",
39
38
  "zod": "3.25.76"
40
39
  },
@@ -39,6 +39,7 @@ export const ICONS_NAME = Object.freeze({
39
39
  circle: 'ph:circle',
40
40
  circleNotch: 'ph:circle-notch',
41
41
  clock: 'ph:clock',
42
+ clockClockwise: 'ph:clock-clockwise',
42
43
  close: 'ph:x',
43
44
  closeCircle: 'ph:x-circle',
44
45
  cloud: 'ph:cloud',
@@ -110,6 +111,7 @@ export const ICONS_NAME = Object.freeze({
110
111
  lockKeyOpen: 'ph:lock-key-open',
111
112
  lockOpen: 'ph:lock-open',
112
113
  magnifyingGlass: 'ph:magnifying-glass',
114
+ magnifyingGlassList: 'ph:list-magnifying-glass',
113
115
  mapPin: 'ph:map-pin',
114
116
  mapPinArea: 'ph:map-pin-area',
115
117
  mapPinSimpleArea: 'ph:map-pin-simple-area',
@@ -137,6 +139,7 @@ export const ICONS_NAME = Object.freeze({
137
139
  policeCar: 'ph:police-car',
138
140
  praying: 'ph:hands-praying',
139
141
  questionMark: 'ph:question-mark',
142
+ receiptFail: 'ph:receipt-x',
140
143
  refresh: 'ph:arrows-counter-clockwise',
141
144
  running: 'ph:person-simple-run',
142
145
  scissors: 'ph:scissors',
@@ -178,6 +181,7 @@ export const ICONS_NAME = Object.freeze({
178
181
  van: 'ph:van',
179
182
  vault: 'ph:vault',
180
183
  walking: 'ph:person-simple-walk',
184
+ wallet: 'ph:wallet',
181
185
  warning: 'ph:warning',
182
186
  warningCircle: 'ph:warning-circle',
183
187
  wheelchair: 'ph:wheelchair',
@@ -34,7 +34,6 @@ export enum ElementsEvent {
34
34
  HotelOffersMarkerClick = 'hotel-offers:marker:click',
35
35
  HotelOffersPollingStarted = 'hotel-offers:polling:started',
36
36
  HotelOffersRetrieved = 'hotel-offers:retrieved',
37
- HotelOffersViewShowMap = 'hotel-offers-view:show-map',
38
37
  HotelRetrieved = 'hotel:retrieved',
39
38
  HotelRoomOfferRequestCreated = 'hotel-room-offer-request:created',
40
39
  HotelRoomOfferRequestRetrieved = 'hotel-room-offer-request:retrieved',
@@ -57,18 +56,17 @@ export interface ElementsEventCallbacks {
57
56
  [ElementsEvent.BookingPolicyCreated]: BookingPolicies
58
57
  [ElementsEvent.CancellationPoliciesUpdated]: CancellationPolicy[]
59
58
  [ElementsEvent.CurrencyUpdated]: CurrencyType
60
- [ElementsEvent.HotelOfferItemMouseleave]: [HotelOffer, number]
61
- [ElementsEvent.HotelOfferItemMouseover]: [HotelOffer, number]
62
- [ElementsEvent.HotelOfferItemVisible]: [HotelOffer, number]
59
+ [ElementsEvent.HotelOfferItemMouseleave]: HotelOffer | [HotelOffer, number]
60
+ [ElementsEvent.HotelOfferItemMouseover]: HotelOffer | [HotelOffer, number]
61
+ [ElementsEvent.HotelOfferItemVisible]: HotelOffer | [HotelOffer, number]
63
62
  [ElementsEvent.HotelOfferRequestCreated]: HotelOfferRequestResponse
64
63
  [ElementsEvent.HotelOfferRequestRetrieved]: HotelOfferRequestResponse
65
64
  [ElementsEvent.HotelOffersFiltersUpdated]: Partial<HotelOffersFilters>
66
- [ElementsEvent.HotelOffersItemClick]: [HotelOffer, number]
67
- [ElementsEvent.HotelOffersMarkerClick]: HotelOffer
65
+ [ElementsEvent.HotelOffersItemClick]: HotelOffer | [HotelOffer, number]
66
+ [ElementsEvent.HotelOffersMarkerClick]: HotelOffer | [HotelOffer, number]
68
67
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
68
  [ElementsEvent.HotelOffersPollingStarted]: any
70
69
  [ElementsEvent.HotelOffersRetrieved]: HotelOffer[]
71
- [ElementsEvent.HotelOffersViewShowMap]: boolean
72
70
  [ElementsEvent.HotelRetrieved]: Hotel
73
71
  [ElementsEvent.HotelRoomOfferRequestCreated]: HotelRoomOfferRequestResponse
74
72
  [ElementsEvent.HotelRoomOfferRequestRetrieved]: HotelRoomOfferRequestResponse
@@ -40,14 +40,14 @@ export interface HotelOfferRequest {
40
40
  * <b style="color: red;"> when no address parameter passed.</b>
41
41
  * @type {number}
42
42
  */
43
- latitude?: number | null
43
+ latitude: number
44
44
  /**
45
45
  * Search location longitude.
46
46
  *
47
47
  * <b style="color: red;"> when no address parameter passed.</b>
48
48
  * @type {number}
49
49
  */
50
- longitude?: number | null
50
+ longitude: number
51
51
  /**
52
52
  * 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.
53
53
  *
@@ -156,16 +156,15 @@ export interface HotelOfferRequestResponse {
156
156
  id: string
157
157
  }
158
158
 
159
- export type HotelOfferRequestCreate = Pick<
160
- HotelOfferRequest,
161
- | 'address'
162
- | 'adultCount'
163
- | 'checkInDate'
164
- | 'checkOutDate'
165
- | 'children'
166
- | 'eventMetadata'
167
- | 'latitude'
168
- | 'longitude'
169
- | 'roomCount'
170
- | 'sourceMarket'
171
- >
159
+ export interface HotelOfferRequestCreate {
160
+ address?: HotelOfferRequest['address']
161
+ adultCount: HotelOfferRequest['adultCount']
162
+ checkInDate: HotelOfferRequest['checkInDate']
163
+ checkOutDate: HotelOfferRequest['checkOutDate']
164
+ children?: HotelOfferRequest['children']
165
+ eventMetadata?: HotelOfferRequest['eventMetadata']
166
+ latitude?: HotelOfferRequest['latitude']
167
+ longitude?: HotelOfferRequest['longitude']
168
+ roomCount: HotelOfferRequest['roomCount']
169
+ sourceMarket: HotelOfferRequest['sourceMarket']
170
+ }
@@ -46,7 +46,7 @@ export enum PaymentMethodApiNameEnum {
46
46
  DepositAccount = 'DEPOSIT_ACCOUNT',
47
47
  }
48
48
 
49
- type PaymentMethodApiName = `${PaymentMethodApiNameEnum}`
49
+ export type PaymentMethodApiName = `${PaymentMethodApiNameEnum}`
50
50
 
51
51
  /**
52
52
  *
@@ -1,3 +1,3 @@
1
1
  export class HttpException extends Error {
2
- declare status: number
2
+ status!: number
3
3
  }
@@ -0,0 +1,15 @@
1
+ import { getRandomHexColor } from './get-random-hex-color.ts'
2
+ import { getRandomInt } from './get-random-int.ts'
3
+
4
+ import type { HotelImage } from '../types/index.ts'
5
+
6
+ export function createDummyHotelImage(count: number): HotelImage[] {
7
+ return Array.from({ length: count }, () => ({
8
+ isHeroImage: false,
9
+ l: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
10
+ m: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
11
+ s: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
12
+ xl: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
13
+ xs: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
14
+ }))
15
+ }
@@ -0,0 +1,15 @@
1
+ import { getRandomHexColor } from './get-random-hex-color.ts'
2
+ import { getRandomInt } from './get-random-int.ts'
3
+
4
+ import type { HotelImage, HotelOffer } from '../types/index.ts'
5
+
6
+ export function generateDummyHotelImages(): HotelImage {
7
+ return {
8
+ isHeroImage: false,
9
+ l: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
10
+ m: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
11
+ s: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
12
+ xl: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
13
+ xs: `https://dummyimage.com/${getRandomInt(300, 900)}x${getRandomInt(300, 900)}/${getRandomHexColor()}/${getRandomHexColor()}`,
14
+ }
15
+ }
@@ -0,0 +1,31 @@
1
+ import type { GeoCoordinates } from '../types/geo-coordinates.ts'
2
+
3
+ /**
4
+ * Generate random coordinates near a given latitude and longitude.
5
+ *
6
+ * @param lat - Base latitude
7
+ * @param lon - Base longitude
8
+ * @param radiusInMeters - Max distance from base point, in meters
9
+ * @returns { lat: number, lon: number }
10
+ */
11
+ export function generateRandomNearbyGeolocation(
12
+ { latitude: lat, longitude: lon }: GeoCoordinates,
13
+ radiusInMeters: number,
14
+ ): GeoCoordinates {
15
+ // Convert radius from meters to degrees
16
+ const radiusInDegrees = radiusInMeters / 111_320
17
+
18
+ // Random distance and angle
19
+ const u = Math.random()
20
+ const v = Math.random()
21
+ const w = radiusInDegrees * Math.sqrt(u)
22
+ const t = 2 * Math.PI * v
23
+
24
+ const deltaLat = w * Math.cos(t)
25
+ const deltaLon = (w * Math.sin(t)) / Math.cos((lat * Math.PI) / 180)
26
+
27
+ const newLat = lat + deltaLat
28
+ const newLon = lon + deltaLon
29
+
30
+ return { latitude: newLat, longitude: newLon }
31
+ }
@@ -0,0 +1,11 @@
1
+ import { dayjs } from './dayjs.ts'
2
+
3
+ /**
4
+ * Get the number of nights between two dates.
5
+ * @param startDate - The start date
6
+ * @param endDate - The end date
7
+ * @returns The number of nights
8
+ */
9
+ export function getNightCount(startDate: string, endDate: string): number {
10
+ return dayjs(endDate).diff(dayjs(startDate), 'day')
11
+ }
@@ -15,9 +15,12 @@ export * from './debounce.ts'
15
15
  export * from './defaults-deep.ts'
16
16
  export * from './delay.ts'
17
17
  export * from './find-unique-keys.ts'
18
+ export * from './generate-dummy-hotel-images.ts'
18
19
  export * from './generate-numbers-from-str.ts'
19
20
  export * from './generate-pseudo-random-string.ts'
21
+ export * from './generate-random-nearby-geolocation.ts'
20
22
  export * from './get-guest-count.ts'
23
+ export * from './get-night-count.ts'
21
24
  export * from './get-random-element-from-array.ts'
22
25
  export * from './get-random-hex-color.ts'
23
26
  export * from './get-random-int.ts'
@@ -54,3 +57,4 @@ export * from './uniq-by.ts'
54
57
  export * from './uniq-with.ts'
55
58
  export * from './validators.ts'
56
59
  export * from './weighted-mean.ts'
60
+ export * from './create-dummy-hotel-images.ts'
@@ -1,3 +0,0 @@
1
- export { default as hotelImagePlaceholder } from './placeholder-hotel.png'
2
-
3
- export { default as roomImagePlaceholder } from './placeholder-room.png'
Binary file
Binary file