@findhotel/sapi 0.23.5 → 0.23.6

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.
@@ -3,7 +3,7 @@ import { ProfileKey, IndexVariation } from './types';
3
3
  * Fixed number of price bucket count
4
4
  */
5
5
  export declare const PRICE_BUCKET_COUNT = 31;
6
- declare type Features = 'offers' | 'search' | 'suggests' | 'configs' | 'rooms';
6
+ export declare type Features = 'offers' | 'search' | 'suggests' | 'configs' | 'rooms' | 'get-hotel';
7
7
  export interface AppConfig {
8
8
  daedalus: {
9
9
  raaEndpoint: string | undefined;
@@ -20,6 +20,7 @@ export interface AppConfig {
20
20
  endpoints: {
21
21
  offersRooms: string;
22
22
  search: string;
23
+ hotel: string;
23
24
  };
24
25
  };
25
26
  algolia: {
@@ -38,4 +39,3 @@ export interface AppConfig {
38
39
  };
39
40
  }
40
41
  export declare function getAppConfig(profileKey: ProfileKey, initWithAppConfig?: Partial<AppConfig>): AppConfig;
41
- export {};
@@ -1,5 +1,5 @@
1
1
  import { Base, ProfileKey } from '.';
2
- import { SearchResults, SearchFn, SearchFnParameters } from './search';
2
+ import { SearchResults, SearchHandler, SearchFnParameters } from './search';
3
3
  import { SearchParameters } from './types';
4
4
  declare type AttributesToRetrieve = keyof SearchResults;
5
5
  interface RequestParameters {
@@ -10,5 +10,5 @@ interface RequestParameters {
10
10
  attributes?: AttributesToRetrieve[];
11
11
  }
12
12
  export declare function createRequestString({ profileKey, searchParameters, options, offset, attributes }: RequestParameters): string;
13
- export declare function backendSearch({ getFeatureEnabled, profileKey, appConfig, offersClient, options }: SearchFnParameters): SearchFn;
13
+ export declare function backendSearch({ getFeatureEnabled, profileKey, appConfig, offersClient, options }: SearchFnParameters): SearchHandler;
14
14
  export {};
@@ -0,0 +1,57 @@
1
+ import { BaseWithConfig } from '.';
2
+ import { Language, HotelId, TranslatedString, GuestRating, GuestType, Location, TranslatedArray, Pricing, ContentHotel, LOVItem } from './types';
3
+ export interface SafHotel {
4
+ objectID: HotelId;
5
+ _geoloc: Location;
6
+ hotelName: TranslatedString;
7
+ imageURIs: string[];
8
+ guestType: GuestType;
9
+ guestRating: GuestRating;
10
+ address?: TranslatedString;
11
+ isDeleted?: boolean;
12
+ updatedAt?: number;
13
+ propertyTypeId?: number;
14
+ starRating?: number;
15
+ feesOpt?: TranslatedString;
16
+ placeADName?: TranslatedArray;
17
+ checkInSpInst?: TranslatedString;
18
+ policies?: TranslatedString;
19
+ phone?: string;
20
+ checkInTime?: string;
21
+ placeDN?: TranslatedArray;
22
+ checkInInst?: TranslatedString;
23
+ checkInMinAge?: number;
24
+ reviewCount?: number;
25
+ chainID?: string;
26
+ checkInEnd?: string;
27
+ lastBooked?: number;
28
+ checkOutTime?: string;
29
+ themeIds?: number[];
30
+ feesMnd?: TranslatedString;
31
+ reviewCountBkt?: number;
32
+ placeID?: string;
33
+ pricing?: Pricing;
34
+ facilities?: LOVItem[];
35
+ themes?: LOVItem[];
36
+ propertyType?: LOVItem;
37
+ sentiments?: LOVItem[];
38
+ }
39
+ export declare type HotelHandler = (hotelId: HotelId) => Promise<ContentHotel>;
40
+ export declare function safToSapiHotel(safHotel: SafHotel, languages: Language[]): ContentHotel;
41
+ /**
42
+ * Creates hotel request string
43
+ *
44
+ * @param hotelId - Requested hotel id
45
+ * @param languages - list of languages with fallback
46
+ *
47
+ * @returns request string
48
+ */
49
+ export declare function createRequestString(hotelId: HotelId, languages: Language[]): string;
50
+ /**
51
+ * Creates hotel function with binded in configuration object
52
+ *
53
+ * @param configuration - Configuration for hotel function initialisation
54
+ *
55
+ * @returns function that asynchronously returns hotel's content by hotelId
56
+ */
57
+ export declare function hotel({ appConfig, options }: Pick<BaseWithConfig, 'options' | 'appConfig'>): HotelHandler;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,11 @@
1
1
  import { BaseWithConfig } from '.';
2
2
  import { RoomsRequestParameters, RoomsRequestOptions, RoomsResults } from './types';
3
- export declare type RoomsFn = (parameters: RoomsRequestParameters) => Promise<RoomsResults>;
3
+ export declare type RoomsHandler = (parameters: RoomsRequestParameters) => Promise<RoomsResults>;
4
4
  /**
5
5
  * Creates rooms request string.
6
6
  *
7
7
  * @param parameters - Rooms request parameters - dynamic parameters that change search
8
- * @param options - Rooms request options - persistent within single SAPI instance
8
+ * @param options - Rooms request options - persistent within single SAPI instance
9
9
  *
10
10
  * @returns request string
11
11
  *
@@ -38,4 +38,4 @@ export declare function createRequestString(parameters: RoomsRequestParameters,
38
38
  *
39
39
  * @returns rooms search function
40
40
  */
41
- export declare function rooms({ appConfig, options }: Pick<BaseWithConfig, 'options' | 'appConfig'>): RoomsFn;
41
+ export declare function rooms({ appConfig, options }: Pick<BaseWithConfig, 'options' | 'appConfig'>): RoomsHandler;
@@ -2,14 +2,14 @@ import { SearchClient } from 'algoliasearch';
2
2
  import { Except } from 'type-fest';
3
3
  import { OffersClient } from './raa';
4
4
  import { Configs } from './algolia';
5
- import { AppConfig } from './app-config';
6
- import { ProfileKey, ClientOptions, SapiClient, SapiFeature, Language, Logger } from './types';
5
+ import { AppConfig, Features } from './app-config';
6
+ import { ProfileKey, ClientOptions, SapiClient, Language, Logger } from './types';
7
7
  export declare type AlgoliaClient = Pick<SearchClient, 'search'>;
8
8
  export interface Base {
9
9
  /** SAPI client application config */
10
10
  appConfig: AppConfig;
11
11
  /** Check if SAPI feature is enabled */
12
- getFeatureEnabled: (feature: SapiFeature) => boolean;
12
+ getFeatureEnabled: (feature: Features) => boolean;
13
13
  /** Instance of Algolia Client */
14
14
  algoliaClient: AlgoliaClient;
15
15
  /** Instance of Offers Client */
@@ -31,7 +31,7 @@ interface Options {
31
31
  countryCode: string;
32
32
  pageSize: number;
33
33
  }
34
- export declare type SearchFn = (parameters: ApiSearchParameters, callbacks?: {
34
+ export declare type SearchHandler = (parameters: ApiSearchParameters, callbacks?: {
35
35
  onStart?: OnStart;
36
36
  onAnchorReceived?: OnAnchorReceived;
37
37
  onHotelsReceived?: OnHotelsReceived;
@@ -44,5 +44,5 @@ export declare type SearchFn = (parameters: ApiSearchParameters, callbacks?: {
44
44
  export declare function prepareSearchParameters(parameters: ApiSearchParameters, dates: DatesConfig): SearchParameters;
45
45
  export declare function getRequestSize(anchorObject: AnchorObject, parameters: SearchParameters, options: Options): number;
46
46
  export declare type SearchFnParameters = Pick<BaseWithConfig, 'profileKey' | 'options' | 'appConfig' | 'algoliaClient' | 'offersClient' | 'configs' | 'getFeatureEnabled'>;
47
- export declare function search({ getFeatureEnabled, appConfig, algoliaClient, offersClient, options, configs }: SearchFnParameters): SearchFn;
47
+ export declare function search({ getFeatureEnabled, appConfig, algoliaClient, offersClient, options, configs }: SearchFnParameters): SearchHandler;
48
48
  export {};
@@ -1,4 +1,4 @@
1
1
  import { Base } from '.';
2
2
  import { Suggestion } from './types';
3
- export declare type SuggestFn = (query: string, suggestsCount?: number) => Promise<Suggestion[]>;
4
- export declare function suggest(base: Base): SuggestFn;
3
+ export declare type SuggestHandler = (query: string, suggestsCount?: number) => Promise<Suggestion[]>;
4
+ export declare function suggest(base: Base): SuggestHandler;
@@ -1,4 +1,3 @@
1
1
  export * from './types';
2
2
  export * from './rooms';
3
3
  export * from './sapi-client';
4
- export * from './sapi-configs';
@@ -1,9 +1,10 @@
1
1
  import { AlgoliaSearchOptions } from 'algoliasearch';
2
2
  import { AnonymousId, Language, Currency, Country, DeviceType, Brand } from './types';
3
3
  import { AppConfig } from '../app-config';
4
- import { SearchFn } from '../search';
5
- import { RoomsFn } from '../rooms';
6
- import { SuggestFn } from '../suggest';
4
+ import { SearchHandler } from '../search';
5
+ import { RoomsHandler } from '../rooms';
6
+ import { HotelHandler } from '../hotel';
7
+ import { SuggestHandler } from '../suggest';
7
8
  import { Configs } from '../algolia';
8
9
  export declare type ProfileKey = 'findhotel-website' | 'findhotel-website-e2e' | 'findhotel-website-stg' | 'findhotel-website-ci' | 'findhotel-website-dev' | 'findhotel-checkout' | 'findhotel-checkout-e2e' | 'findhotel-checkout-stg';
9
10
  interface Event {
@@ -14,9 +15,10 @@ export interface Logger {
14
15
  log: (event: Event) => void;
15
16
  }
16
17
  export interface SapiClient {
17
- rooms: RoomsFn;
18
- search: SearchFn;
19
- suggest: SuggestFn;
18
+ rooms: RoomsHandler;
19
+ search: SearchHandler;
20
+ suggest: SuggestHandler;
21
+ hotel: HotelHandler;
20
22
  }
21
23
  /** Options for initializing the Search API client. Persistent within single SAPI instance but may vary for different users */
22
24
  export interface ClientOptions {
@@ -1,3 +1,8 @@
1
+ export interface IndexVariation {
2
+ name: string;
3
+ objectID?: string;
4
+ variationID?: string;
5
+ }
1
6
  /**
2
7
  * Unique ID identifying users
3
8
  *
@@ -136,7 +141,7 @@ export interface HotelSuggestHit extends BasicSuggestHit {
136
141
  };
137
142
  }
138
143
  export declare type SuggestHit = HotelSuggestHit | PlaceSuggestHit;
139
- /** Hit */
144
+ /** Search Hit */
140
145
  export interface Hit {
141
146
  address: TranslatedString;
142
147
  checkInTime: string;
@@ -163,12 +168,57 @@ export interface Hit {
163
168
  /**
164
169
  * Product
165
170
  */
171
+ export interface LOVItem {
172
+ importance?: number;
173
+ categoryID?: number;
174
+ id: number;
175
+ value: TranslatedString;
176
+ }
177
+ export interface TranslatedLOVItem {
178
+ importance?: number;
179
+ categoryID?: number;
180
+ id: number;
181
+ value: string;
182
+ }
166
183
  export interface Hotel extends Omit<Hit, 'hotelName' | 'address' | 'placeDN' | 'placeADName'> {
167
184
  displayAddress: string;
168
185
  hotelName: string;
169
186
  placeDisplayName: string;
170
187
  regularPriceRange?: [number, number];
171
188
  }
189
+ export interface ContentHotel {
190
+ objectID: HotelId;
191
+ _geoloc: Location;
192
+ hotelName: string;
193
+ imageURIs: string[];
194
+ guestType: GuestType;
195
+ guestRating: GuestRating;
196
+ isDeleted?: boolean;
197
+ propertyTypeId?: number;
198
+ starRating?: number;
199
+ feesOpt?: string;
200
+ checkInSpInst?: string;
201
+ policies?: string;
202
+ phone?: string;
203
+ checkInTime?: string;
204
+ checkInInst?: string;
205
+ checkInMinAge?: number;
206
+ reviewCount?: number;
207
+ chainID?: string;
208
+ checkInEnd?: string;
209
+ lastBooked?: number;
210
+ checkOutTime?: string;
211
+ feesMnd?: string;
212
+ reviewCountBkt?: number;
213
+ placeID?: string;
214
+ pricing?: Pricing;
215
+ placeDisplayName?: string;
216
+ displayAddress?: string;
217
+ facilities?: TranslatedLOVItem[];
218
+ themes?: TranslatedLOVItem[];
219
+ propertyType?: TranslatedLOVItem;
220
+ sentiments?: TranslatedLOVItem[];
221
+ }
172
222
  export interface HotelAnchor extends Omit<HotelAnchorHit, 'hotelName' | 'placeADN' | 'placeDN'> {
173
223
  placeDisplayName: string;
174
224
  hotelName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findhotel/sapi",
3
- "version": "0.23.5",
3
+ "version": "0.23.6",
4
4
  "description": "FindHotel Search API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/packages/core/src",
@@ -1,27 +0,0 @@
1
- import { DateString, Language } from './types';
2
- export declare type SapiFeature = 'offers' | 'search' | 'rooms' | 'suggests' | 'configs';
3
- export interface IndexVariation {
4
- name: string;
5
- objectID?: string;
6
- variationID?: string;
7
- }
8
- export interface Profile {
9
- features: SapiFeature[];
10
- blockedDefaultDates: DateString[];
11
- daysFromNow: number;
12
- fallbackLanguages: Record<Language, Language[]>;
13
- hotelIndex: string;
14
- autocompleteIndex: string;
15
- lovIndex: string;
16
- currencyIndex: string;
17
- hsoIndex: IndexVariation[];
18
- raa: {
19
- endpoint?: string;
20
- };
21
- offers: {
22
- endpoint: string;
23
- };
24
- algolia: {
25
- apiKey: string;
26
- };
27
- }