@findhotel/sapi 0.22.13 → 0.23.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.
- package/CHANGELOG.md +27 -1
- package/README.md +89 -9
- package/dist/index.js +1 -1
- package/dist/types/packages/core/src/algolia/configs.d.ts +7 -2
- package/dist/types/packages/core/src/algolia/geo-search.d.ts +5 -2
- package/dist/types/packages/core/src/algolia/get-anchor.d.ts +6 -2
- package/dist/types/packages/core/src/algolia/load-suggests.d.ts +4 -2
- package/dist/types/packages/core/src/app-config.d.ts +41 -0
- package/dist/types/packages/core/src/backend-search.d.ts +2 -2
- package/dist/types/packages/core/src/offers.d.ts +105 -0
- package/dist/types/packages/core/src/offers.test.d.ts +1 -0
- package/dist/types/packages/core/src/raa/raa.d.ts +10 -10
- package/dist/types/packages/core/src/raa/utils.d.ts +1 -1
- package/dist/types/packages/core/src/rooms.d.ts +2 -4
- package/dist/types/packages/core/src/sapi.d.ts +9 -13
- package/dist/types/packages/core/src/search.d.ts +3 -3
- package/dist/types/packages/core/src/types/rooms.d.ts +2 -3
- package/dist/types/packages/core/src/types/sapi-client.d.ts +14 -12
- package/dist/types/packages/core/src/types/sapi-configs.d.ts +3 -0
- package/dist/types/packages/core/src/types/types.d.ts +25 -11
- package/dist/types/packages/core/src/utils/search-id.d.ts +1 -1
- package/package.json +10 -8
- package/dist/types/packages/core/src/configs.d.ts +0 -23
- package/dist/types/packages/core/src/profile.d.ts +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AlgoliaClient } from '..';
|
|
2
|
-
import {
|
|
2
|
+
import { IndexVariation } from '../types';
|
|
3
3
|
declare type HsoConfigContext = Record<string, unknown>;
|
|
4
4
|
export declare type HsoConfigType = 'place_search' | 'hotel_search';
|
|
5
5
|
interface HsoConfig {
|
|
@@ -61,5 +61,10 @@ export declare function exchangeRatesFromResponse(hits: ExchangeRateHit[]): Reco
|
|
|
61
61
|
* @param languages
|
|
62
62
|
*/
|
|
63
63
|
export declare function getLovAttributesToRetrieve(languages: string[]): string[];
|
|
64
|
-
|
|
64
|
+
interface IndicesConfiguration {
|
|
65
|
+
hsoIndex: IndexVariation[];
|
|
66
|
+
lovIndex: string;
|
|
67
|
+
currencyIndex: string;
|
|
68
|
+
}
|
|
69
|
+
export declare function loadConfigs({ search }: AlgoliaClient, { hsoIndex, lovIndex, currencyIndex }: IndicesConfiguration, options: LoadConfigOptions): Promise<Configs>;
|
|
65
70
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AlgoliaClient } from '..';
|
|
2
2
|
import { HsoFilter } from './configs';
|
|
3
|
-
import { OptionalSearchParameters, Hotel, Location
|
|
3
|
+
import { OptionalSearchParameters, Hotel, Location } from '../types';
|
|
4
4
|
interface Options {
|
|
5
5
|
languages: string[];
|
|
6
6
|
requestSize: number;
|
|
@@ -13,7 +13,10 @@ export interface GeoSearchParameters extends OptionalSearchParameters {
|
|
|
13
13
|
geolocation?: Location;
|
|
14
14
|
anchorHotelId?: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
interface IndicesConfiguration {
|
|
17
|
+
hotelIndex: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function geoSearch({ search }: AlgoliaClient, { hotelIndex }: IndicesConfiguration, options: Options): (parameters: GeoSearchParameters) => Promise<{
|
|
17
20
|
hotelIds: string[];
|
|
18
21
|
hotelEntities: Record<string, Hotel>;
|
|
19
22
|
resultsCount: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AlgoliaClient } from '..';
|
|
2
|
-
import {
|
|
2
|
+
import { Anchor, Hotel, Location } from '../types';
|
|
3
3
|
interface GetAnchorParameters {
|
|
4
4
|
hotelId?: string;
|
|
5
5
|
placeId?: string;
|
|
@@ -12,7 +12,11 @@ export declare type AnchorObject = {
|
|
|
12
12
|
anchor: Anchor;
|
|
13
13
|
anchorHotel: Hotel | undefined;
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
interface IndicesConfiguration {
|
|
16
|
+
autocompleteIndex: string;
|
|
17
|
+
hotelIndex: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function getAnchor({ search }: AlgoliaClient, { autocompleteIndex, hotelIndex }: IndicesConfiguration, { languages }: {
|
|
16
20
|
languages: string[];
|
|
17
21
|
}): (parameters: GetAnchorParameters) => Promise<{
|
|
18
22
|
anchor: Anchor;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AlgoliaClient } from '..';
|
|
2
|
-
import { Profile } from '../types';
|
|
3
2
|
interface Options {
|
|
4
3
|
languages: string[];
|
|
5
4
|
suggestsCount?: number;
|
|
6
5
|
}
|
|
7
|
-
|
|
6
|
+
interface IndicesConfiguration {
|
|
7
|
+
autocompleteIndex: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadSuggests({ search }: AlgoliaClient, { autocompleteIndex }: IndicesConfiguration, { languages, suggestsCount }: Options): (query: string) => Promise<import("..").Suggestion[]>;
|
|
8
10
|
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ProfileKey, IndexVariation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Fixed number of price bucket count
|
|
4
|
+
*/
|
|
5
|
+
export declare const PRICE_BUCKET_COUNT = 31;
|
|
6
|
+
declare type Features = 'offers' | 'search' | 'suggests' | 'configs' | 'rooms';
|
|
7
|
+
export interface AppConfig {
|
|
8
|
+
daedalus: {
|
|
9
|
+
raaEndpoint: string;
|
|
10
|
+
};
|
|
11
|
+
sapiBackend: {
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
endpoints: {
|
|
14
|
+
search: string;
|
|
15
|
+
offers: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
saf: {
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
endpoints: {
|
|
21
|
+
offersRooms: string;
|
|
22
|
+
search: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
algolia: {
|
|
26
|
+
apiKey: string;
|
|
27
|
+
hotelIndex: string;
|
|
28
|
+
autocompleteIndex: string;
|
|
29
|
+
lovIndex: string;
|
|
30
|
+
currencyIndex: string;
|
|
31
|
+
hsoIndex: IndexVariation[];
|
|
32
|
+
};
|
|
33
|
+
client: {
|
|
34
|
+
features: Features[];
|
|
35
|
+
blockedDefaultDates: string[];
|
|
36
|
+
daysFromNow: number;
|
|
37
|
+
fallbackLanguages: Record<string, string[]>;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
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 } from './search';
|
|
2
|
+
import { SearchResults, SearchFn, 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,
|
|
13
|
+
export declare function backendSearch({ getFeatureEnabled, profileKey, appConfig, offersClient, options }: SearchFnParameters): SearchFn;
|
|
14
14
|
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { CugDeals, HotelId, HotelOfferEntity, Brand, Currency, DeviceType, RoomId, Meals } from './types';
|
|
2
|
+
interface V3RateBreakdown {
|
|
3
|
+
base: number;
|
|
4
|
+
hotelFees: number;
|
|
5
|
+
taxes: number;
|
|
6
|
+
}
|
|
7
|
+
interface CancellationPenalty {
|
|
8
|
+
amount: number;
|
|
9
|
+
percent?: number;
|
|
10
|
+
nights?: number;
|
|
11
|
+
currency: string;
|
|
12
|
+
end: string;
|
|
13
|
+
start: string;
|
|
14
|
+
}
|
|
15
|
+
declare type Amenities = Meals & 'internetIncluded';
|
|
16
|
+
declare type OfferTag = 'top_offer' | 'anchor_price' | 'exclusive_cheapest_offer';
|
|
17
|
+
interface SapiResponseOffer {
|
|
18
|
+
accessTier: string;
|
|
19
|
+
availableRooms: number;
|
|
20
|
+
cancellationPenalties: CancellationPenalty[];
|
|
21
|
+
currency: Currency;
|
|
22
|
+
id: string;
|
|
23
|
+
intermediaryProvider: string;
|
|
24
|
+
metadata: {
|
|
25
|
+
feedID: string;
|
|
26
|
+
};
|
|
27
|
+
occupancy: string | number | null;
|
|
28
|
+
package: {
|
|
29
|
+
amenities: Amenities[];
|
|
30
|
+
canPayLater: boolean;
|
|
31
|
+
refundable: boolean;
|
|
32
|
+
};
|
|
33
|
+
providerCode: string;
|
|
34
|
+
rate: V3RateBreakdown;
|
|
35
|
+
roomID: RoomId;
|
|
36
|
+
tags: OfferTag[] | null;
|
|
37
|
+
url: string;
|
|
38
|
+
}
|
|
39
|
+
declare type Rooms = Record<RoomId, {
|
|
40
|
+
name: string;
|
|
41
|
+
}>;
|
|
42
|
+
export interface SapiResponseOfferEntity {
|
|
43
|
+
anchorRate: V3RateBreakdown;
|
|
44
|
+
availableOffersCount: number;
|
|
45
|
+
fetchedAllOffers: boolean;
|
|
46
|
+
hasMoreOffers: boolean;
|
|
47
|
+
id: HotelId;
|
|
48
|
+
offers: SapiResponseOffer[];
|
|
49
|
+
rooms: Rooms;
|
|
50
|
+
}
|
|
51
|
+
interface Options {
|
|
52
|
+
brand?: Brand;
|
|
53
|
+
anonymousId: string;
|
|
54
|
+
currency: string;
|
|
55
|
+
countryCode: string;
|
|
56
|
+
language: string;
|
|
57
|
+
includeLocalTaxes?: boolean;
|
|
58
|
+
includeTaxes?: boolean;
|
|
59
|
+
skipBackendAugmentation?: boolean;
|
|
60
|
+
facetsEnabled?: boolean;
|
|
61
|
+
WebSocket?: any;
|
|
62
|
+
sapiCliKey?: string;
|
|
63
|
+
deviceType: DeviceType;
|
|
64
|
+
variations: string[];
|
|
65
|
+
}
|
|
66
|
+
export interface GetOffersParameters {
|
|
67
|
+
anchorHotelId?: HotelId;
|
|
68
|
+
hotelIds?: HotelId[];
|
|
69
|
+
cugDeals?: CugDeals;
|
|
70
|
+
getAllOffers?: boolean;
|
|
71
|
+
originId?: string;
|
|
72
|
+
checkIn: string;
|
|
73
|
+
checkOut: string;
|
|
74
|
+
rooms: string;
|
|
75
|
+
searchId: string;
|
|
76
|
+
filters?: {
|
|
77
|
+
freeCancellation?: boolean;
|
|
78
|
+
};
|
|
79
|
+
preferredRate?: number;
|
|
80
|
+
trafficSource?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface OffersResponse {
|
|
83
|
+
anchorHotelOfferEntity?: HotelOfferEntity;
|
|
84
|
+
hotelOfferEntities?: HotelOfferEntity[];
|
|
85
|
+
}
|
|
86
|
+
export interface OffersClient {
|
|
87
|
+
getOffers: (parameters: GetOffersParameters, onOffersReceived?: (response: OffersResponse) => void) => Promise<OffersResponse>;
|
|
88
|
+
}
|
|
89
|
+
interface MappingContext {
|
|
90
|
+
checkIn: string;
|
|
91
|
+
checkOut: string;
|
|
92
|
+
includeTaxes?: boolean;
|
|
93
|
+
includeLocalTaxes?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export declare function sapiResponseToHotelOfferEntity(offerEntity: SapiResponseOfferEntity, context: MappingContext): HotelOfferEntity;
|
|
96
|
+
interface ApiConfig {
|
|
97
|
+
baseUrl: string;
|
|
98
|
+
endpoints: {
|
|
99
|
+
offers: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export declare function offers(config: ApiConfig, options: Options): {
|
|
103
|
+
getOffers: (parameters: GetOffersParameters, onOffersReceived?: ((response: OffersResponse) => void) | undefined) => Promise<OffersResponse>;
|
|
104
|
+
};
|
|
105
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { HotelOfferEntity } from '../types';
|
|
2
|
-
export interface
|
|
1
|
+
import { CugDeals, HotelId, HotelOfferEntity } from '../types';
|
|
2
|
+
export interface OffersClient {
|
|
3
3
|
getOffers: GetOffers;
|
|
4
4
|
}
|
|
5
5
|
interface RaaOptions {
|
|
6
6
|
anonymousId: string;
|
|
7
7
|
currency: string;
|
|
8
|
-
|
|
8
|
+
countryCode: string;
|
|
9
9
|
language: string;
|
|
10
10
|
includeLocalTaxes?: boolean;
|
|
11
11
|
includeTaxes?: boolean;
|
|
@@ -13,16 +13,16 @@ interface RaaOptions {
|
|
|
13
13
|
facetsEnabled?: boolean;
|
|
14
14
|
WebSocket?: any;
|
|
15
15
|
sapiCliKey?: string;
|
|
16
|
-
|
|
16
|
+
deviceType: string;
|
|
17
17
|
variations: string[];
|
|
18
18
|
}
|
|
19
19
|
export interface GetOffersParameters {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
anchorHotelId?: HotelId;
|
|
21
|
+
hotelIds?: HotelId[];
|
|
22
|
+
cugDeals?: CugDeals;
|
|
22
23
|
getAllOffers?: boolean;
|
|
23
|
-
|
|
24
|
+
originId?: string;
|
|
24
25
|
useAlternativeRaaKeys?: boolean;
|
|
25
|
-
destination?: string;
|
|
26
26
|
checkIn: string;
|
|
27
27
|
checkOut: string;
|
|
28
28
|
rooms: string;
|
|
@@ -34,8 +34,8 @@ export interface GetOffersParameters {
|
|
|
34
34
|
trafficSource?: string;
|
|
35
35
|
}
|
|
36
36
|
export interface OffersResponse {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
anchorHotelOfferEntity?: HotelOfferEntity;
|
|
38
|
+
hotelOfferEntities?: HotelOfferEntity[];
|
|
39
39
|
}
|
|
40
40
|
declare type GetOffers = (parameters: GetOffersParameters, onOffersReceived?: (response: OffersResponse) => void) => Promise<OffersResponse>;
|
|
41
41
|
export declare function raa(raaEndpoint: string, options: RaaOptions): {
|
|
@@ -10,6 +10,7 @@ interface Parameters {
|
|
|
10
10
|
priceBucketWidth?: number;
|
|
11
11
|
priceBucketsCount: number;
|
|
12
12
|
exchangeRate: number;
|
|
13
|
+
variations?: string[];
|
|
13
14
|
}
|
|
14
15
|
interface SortingBoostParameters {
|
|
15
16
|
filters?: {
|
|
@@ -30,7 +31,6 @@ export declare function augmentOffersWithAnchorPrice({ offers }: {
|
|
|
30
31
|
export declare function augmentHotelOffersWithAnchorPrice(hotelOfferEntity: HotelOfferEntity): HotelOfferEntity;
|
|
31
32
|
export declare function augmentRaaResponse(offersResults: OffersResponse, parameters: Parameters): {
|
|
32
33
|
hotelIds: string[];
|
|
33
|
-
anchorHotelId: string | undefined;
|
|
34
34
|
hotelOfferEntities: Record<string, HotelOfferEntity>;
|
|
35
35
|
};
|
|
36
36
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseWithConfig } from '.';
|
|
2
2
|
import { RoomsRequestParameters, RoomsRequestOptions, RoomsResults } from './types';
|
|
3
3
|
export declare type RoomsFn = (parameters: RoomsRequestParameters) => Promise<RoomsResults>;
|
|
4
4
|
/**
|
|
@@ -31,7 +31,6 @@ export declare type RoomsFn = (parameters: RoomsRequestParameters) => Promise<Ro
|
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
33
|
export declare function createRequestString(parameters: RoomsRequestParameters, options: RoomsRequestOptions): string;
|
|
34
|
-
declare type RoomsFnParameters = Pick<Base, 'options' | 'safConfig'>;
|
|
35
34
|
/**
|
|
36
35
|
* Creates rooms search function with binded base configuration object
|
|
37
36
|
*
|
|
@@ -39,5 +38,4 @@ declare type RoomsFnParameters = Pick<Base, 'options' | 'safConfig'>;
|
|
|
39
38
|
*
|
|
40
39
|
* @returns rooms search function
|
|
41
40
|
*/
|
|
42
|
-
export declare function rooms({
|
|
43
|
-
export {};
|
|
41
|
+
export declare function rooms({ appConfig, options }: Pick<BaseWithConfig, 'options' | 'appConfig'>): RoomsFn;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { SearchClient } from 'algoliasearch';
|
|
2
2
|
import { Except } from 'type-fest';
|
|
3
|
-
import {
|
|
3
|
+
import { OffersClient } from './raa';
|
|
4
4
|
import { Configs } from './algolia';
|
|
5
|
-
import {
|
|
6
|
-
import { ProfileKey, ClientOptions, SapiClient,
|
|
5
|
+
import { AppConfig } from './app-config';
|
|
6
|
+
import { ProfileKey, ClientOptions, SapiClient, SapiFeature, Language, Logger } from './types';
|
|
7
7
|
export declare type AlgoliaClient = Pick<SearchClient, 'search'>;
|
|
8
8
|
export interface Base {
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
/** SAPI backend config */
|
|
12
|
-
backendConfig: BackendConfig;
|
|
9
|
+
/** SAPI client application config */
|
|
10
|
+
appConfig: AppConfig;
|
|
13
11
|
/** Check if SAPI feature is enabled */
|
|
14
12
|
getFeatureEnabled: (feature: SapiFeature) => boolean;
|
|
15
|
-
/** Client profile */
|
|
16
|
-
profile: Profile;
|
|
17
13
|
/** Instance of Algolia Client */
|
|
18
14
|
algoliaClient: AlgoliaClient;
|
|
19
|
-
/** Instance of
|
|
20
|
-
|
|
15
|
+
/** Instance of Offers Client */
|
|
16
|
+
offersClient?: OffersClient;
|
|
21
17
|
/** Profile key of specific client */
|
|
22
18
|
profileKey: ProfileKey;
|
|
23
19
|
/** Options persistent within single SAPI instance */
|
|
@@ -36,8 +32,8 @@ export interface BaseWithConfig extends Base {
|
|
|
36
32
|
/**
|
|
37
33
|
* SAPI constructor
|
|
38
34
|
*
|
|
39
|
-
* @param profileKey - Profile key
|
|
40
|
-
* @param clientOptions - Options for initializing SAPI
|
|
35
|
+
* @param profileKey - Profile key for customer identification
|
|
36
|
+
* @param clientOptions - Options for initializing SAPI client
|
|
41
37
|
*
|
|
42
38
|
* @returns Promise which resolves to SAPI client
|
|
43
39
|
*/
|
|
@@ -28,7 +28,7 @@ interface Options {
|
|
|
28
28
|
anonymousId: AnonymousId;
|
|
29
29
|
language: string;
|
|
30
30
|
currency: string;
|
|
31
|
-
|
|
31
|
+
countryCode: string;
|
|
32
32
|
pageSize: number;
|
|
33
33
|
}
|
|
34
34
|
export declare type SearchFn = (parameters: ApiSearchParameters, callbacks?: {
|
|
@@ -43,6 +43,6 @@ export declare type SearchFn = (parameters: ApiSearchParameters, callbacks?: {
|
|
|
43
43
|
}>;
|
|
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
|
-
declare type SearchFnParameters = Pick<BaseWithConfig, 'options' | '
|
|
47
|
-
export declare function search({ getFeatureEnabled,
|
|
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;
|
|
48
48
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HotelId, AnonymousId, Currency, Language,
|
|
1
|
+
import { HotelId, AnonymousId, Currency, Language, DeviceType, RoomId } from './types';
|
|
2
2
|
export interface RoomsRequestParameters {
|
|
3
3
|
hotelId: HotelId;
|
|
4
4
|
checkIn: string;
|
|
@@ -8,13 +8,12 @@ export interface RoomsRequestParameters {
|
|
|
8
8
|
cugDeals?: string;
|
|
9
9
|
}
|
|
10
10
|
export interface RoomsRequestOptions {
|
|
11
|
-
|
|
11
|
+
deviceType: DeviceType;
|
|
12
12
|
language: Language;
|
|
13
13
|
currency: Currency;
|
|
14
14
|
anonymousId: AnonymousId;
|
|
15
15
|
variations: string[];
|
|
16
16
|
}
|
|
17
|
-
export declare type RoomId = string;
|
|
18
17
|
export declare type RoomPackageId = string;
|
|
19
18
|
export interface RoomCancellationPenalties {
|
|
20
19
|
start: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AlgoliaSearchOptions } from 'algoliasearch';
|
|
2
|
-
import { AnonymousId, Language, Currency, Country,
|
|
3
|
-
import {
|
|
2
|
+
import { AnonymousId, Language, Currency, Country, DeviceType, Brand } from './types';
|
|
3
|
+
import { AppConfig } from '../app-config';
|
|
4
4
|
import { SearchFn } from '../search';
|
|
5
5
|
import { RoomsFn } from '../rooms';
|
|
6
6
|
import { SuggestFn } from '../suggest';
|
|
7
7
|
import { Configs } from '../algolia';
|
|
8
|
-
export declare type ProfileKey =
|
|
8
|
+
export declare type ProfileKey = 'findhotel-website' | 'findhotel-website-e2e' | 'findhotel-website-stg' | 'findhotel-website-ci' | 'findhotel-website-dev' | 'findhotel-checkout' | 'findhotel-checkout-e2e';
|
|
9
9
|
interface Event {
|
|
10
10
|
name: string;
|
|
11
11
|
value: any;
|
|
@@ -26,28 +26,30 @@ export interface ClientOptions {
|
|
|
26
26
|
language: Language;
|
|
27
27
|
/** Currency code for selected user currency */
|
|
28
28
|
currency: Currency;
|
|
29
|
+
/** @deprecated since 0.23.0 use countryCode instead */
|
|
30
|
+
userCountry?: Country;
|
|
29
31
|
/** Country code for selected user origin userCountry */
|
|
30
|
-
|
|
32
|
+
countryCode: Country;
|
|
31
33
|
/** Displayed page size */
|
|
32
34
|
pageSize?: number;
|
|
33
35
|
/** Include or not local taxes based on localisation logic */
|
|
34
36
|
includeLocalTaxes?: boolean;
|
|
35
37
|
/** Include or not taxes based on localisation logic */
|
|
36
38
|
includeTaxes?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
deviceCategory
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
/** Enable raa faceting */
|
|
42
|
-
facetsEnabled?: boolean;
|
|
39
|
+
/** @deprecated since 0.23.0 use deviceType instead */
|
|
40
|
+
deviceCategory?: DeviceType;
|
|
41
|
+
/** User's device type */
|
|
42
|
+
deviceType: DeviceType;
|
|
43
43
|
/** Used to identify SAPI Cli interface on the RAA backend */
|
|
44
44
|
sapiCliKey?: string;
|
|
45
45
|
/** Algolia client options used for debugging and setting additional options like timeouts etc. */
|
|
46
46
|
algoliaClientOptions?: AlgoliaSearchOptions;
|
|
47
|
-
/** External
|
|
48
|
-
|
|
47
|
+
/** External app config to override internal sapi sdk app config */
|
|
48
|
+
initWithAppConfig?: Partial<AppConfig>;
|
|
49
49
|
/** A/B test variations */
|
|
50
50
|
variations?: Record<string, string>;
|
|
51
|
+
/** Brand name of the client */
|
|
52
|
+
brand?: Brand;
|
|
51
53
|
/** External logger to log sapi events */
|
|
52
54
|
logger?: Logger;
|
|
53
55
|
/** Client callbacks */
|
|
@@ -8,7 +8,9 @@ export declare type Currency = string;
|
|
|
8
8
|
export declare type Language = string;
|
|
9
9
|
export declare type Country = string;
|
|
10
10
|
export declare type DateString = string;
|
|
11
|
-
export declare type
|
|
11
|
+
export declare type DeviceType = 'desktop' | 'mobile' | 'tablet';
|
|
12
|
+
export declare type CugDeals = string[];
|
|
13
|
+
export declare type Brand = string;
|
|
12
14
|
/**
|
|
13
15
|
* Search client types
|
|
14
16
|
*/
|
|
@@ -37,18 +39,13 @@ export interface OptionalSearchParameters {
|
|
|
37
39
|
nights?: number;
|
|
38
40
|
sortField?: string;
|
|
39
41
|
sortOrder?: string;
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated Should set this as SAPI client option
|
|
42
|
-
*/
|
|
43
|
-
offers?: boolean;
|
|
44
42
|
filters?: FilterParameters;
|
|
45
43
|
offset?: number;
|
|
46
44
|
length?: number;
|
|
47
45
|
boundingBox?: BoundingBox;
|
|
48
46
|
polygon?: Polygon;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
profileId?: string;
|
|
47
|
+
cugDeals?: CugDeals;
|
|
48
|
+
originId?: string;
|
|
52
49
|
searchId?: string;
|
|
53
50
|
useAlternativeRaaKeys?: boolean;
|
|
54
51
|
skipGeoSearch?: boolean;
|
|
@@ -191,6 +188,7 @@ export interface Suggestion {
|
|
|
191
188
|
value: string;
|
|
192
189
|
}
|
|
193
190
|
export declare type HotelId = Hotel['objectID'];
|
|
191
|
+
export declare type RoomId = string;
|
|
194
192
|
/**
|
|
195
193
|
* RAA types
|
|
196
194
|
*/
|
|
@@ -212,7 +210,11 @@ export interface CancellationPolicy {
|
|
|
212
210
|
freeRefundableUntil: string;
|
|
213
211
|
description: string;
|
|
214
212
|
}
|
|
213
|
+
export declare type Meals = 'allInclusive' | 'breakfast' | 'partialBreakfast' | 'lunch' | 'dinner' | 'fullBoard' | 'halfBoard' | 'meals';
|
|
215
214
|
export interface Offer {
|
|
215
|
+
additionalProviderParams: {
|
|
216
|
+
feedId: string;
|
|
217
|
+
};
|
|
216
218
|
id: string;
|
|
217
219
|
bookURI: string;
|
|
218
220
|
providerCode: string;
|
|
@@ -221,9 +223,9 @@ export interface Offer {
|
|
|
221
223
|
nightlyRate: number;
|
|
222
224
|
calculatedTotalRate: number;
|
|
223
225
|
availableRooms: number;
|
|
224
|
-
cug: string[];
|
|
226
|
+
cug: string[] | null;
|
|
225
227
|
currency: Currency;
|
|
226
|
-
meals:
|
|
228
|
+
meals: Meals[];
|
|
227
229
|
tags: string[];
|
|
228
230
|
canPayLater?: boolean;
|
|
229
231
|
cancellationPolicy?: CancellationPolicy;
|
|
@@ -239,8 +241,12 @@ export interface Offer {
|
|
|
239
241
|
roomID?: string;
|
|
240
242
|
roomName?: string;
|
|
241
243
|
rateBasedOnNumberOfRooms?: number;
|
|
244
|
+
feedId?: string;
|
|
245
|
+
providerOfferId?: string;
|
|
246
|
+
rateType?: string;
|
|
242
247
|
}
|
|
243
248
|
export interface RaaResponseOffer {
|
|
249
|
+
availableOffersCount: number;
|
|
244
250
|
anchorPriceRateBreakdown?: AnchorPriceRateBreakdown;
|
|
245
251
|
cheapestPriceRateBreakdown?: RateBreakdown;
|
|
246
252
|
fetchedAllOffers: boolean;
|
|
@@ -250,7 +256,15 @@ export interface RaaResponseOffer {
|
|
|
250
256
|
topOfferData?: TopOfferData;
|
|
251
257
|
errors: Array<Record<string, number | string>>;
|
|
252
258
|
}
|
|
253
|
-
export interface HotelOfferEntity
|
|
259
|
+
export interface HotelOfferEntity {
|
|
260
|
+
availableOffersCount: number;
|
|
261
|
+
anchorPriceRateBreakdown?: AnchorPriceRateBreakdown;
|
|
262
|
+
cheapestPriceRateBreakdown?: RateBreakdown;
|
|
263
|
+
fetchedAllOffers: boolean;
|
|
264
|
+
hasMoreOffers: boolean;
|
|
265
|
+
id: string;
|
|
266
|
+
offers: Offer[];
|
|
267
|
+
topOfferData?: TopOfferData;
|
|
254
268
|
}
|
|
255
269
|
export interface RaaResponse {
|
|
256
270
|
errors: any[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@findhotel/sapi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "FindHotel Search API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/types/packages/core/src",
|
|
@@ -16,13 +16,15 @@
|
|
|
16
16
|
"test": "lerna run test",
|
|
17
17
|
"test:watch": "lerna run test:watch",
|
|
18
18
|
"rollup": "rollup -c",
|
|
19
|
-
"rollup:watch": "npm run clean:dist && rollup -c --watch",
|
|
19
|
+
"rollup:watch": "npm run clean:dist && tsc --outDir dist/lib --declarationDir dist/types --declaration true --emitDeclarationOnly && rollup -c --watch",
|
|
20
20
|
"typedoc": "lerna run typedoc",
|
|
21
21
|
"typedoc:publish": " aws s3 cp packages/core/docs/ s3://fh-search/metrics/sapi/typedoc --recursive",
|
|
22
22
|
"typescript": "tsc",
|
|
23
23
|
"typescript:watch": "tsc --watch",
|
|
24
24
|
"install:all": "cd packages/core && npm install && cd ../playground && npm install && cd ../cli && npm install && cd ../../ && npm install",
|
|
25
25
|
"playground": "cd packages/playground && npm run dev",
|
|
26
|
+
"webclient:start": "cd packages/webclient && npm start",
|
|
27
|
+
"webclient:build": "cd packages/core && npm install && cd ../../ npm run build && cd packages/webclient && npm run build",
|
|
26
28
|
"release": "shipjs prepare"
|
|
27
29
|
},
|
|
28
30
|
"repository": {
|
|
@@ -39,23 +41,23 @@
|
|
|
39
41
|
"@rollup/plugin-commonjs": "^16.0.0",
|
|
40
42
|
"@rollup/plugin-node-resolve": "^10.0.0",
|
|
41
43
|
"@rollup/plugin-typescript": "^6.1.0",
|
|
42
|
-
"rollup": "^2.33.3",
|
|
43
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
44
|
-
"typescript": "^4.1.2",
|
|
45
44
|
"eslint-config-xo-react": "^0.23.0",
|
|
46
45
|
"eslint-plugin-jest": "^24.1.3",
|
|
47
|
-
"eslint-plugin-react": "^7.
|
|
46
|
+
"eslint-plugin-react": "^7.28.0",
|
|
48
47
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
49
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
50
|
-
"rollup-plugin-visualizer": "^5.5.0",
|
|
51
48
|
"husky": "^5.0.6",
|
|
52
49
|
"jest": "^26.6.3",
|
|
53
50
|
"lerna": "^3.15.0",
|
|
51
|
+
"rollup": "^2.33.3",
|
|
52
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
53
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
54
|
+
"rollup-plugin-visualizer": "^5.5.0",
|
|
54
55
|
"shipjs": "0.23.3",
|
|
55
56
|
"ts-jest": "^26.4.4",
|
|
56
57
|
"tslib": "^2.0.3",
|
|
57
58
|
"type-fest": "^0.20.2",
|
|
58
59
|
"typedoc": "^0.19.2",
|
|
60
|
+
"typescript": "^4.1.2",
|
|
59
61
|
"xo": "^0.35.0"
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Profile, ProfileKey } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Fixed number of price bucket count
|
|
4
|
-
*/
|
|
5
|
-
export declare const PRICE_BUCKET_COUNT = 31;
|
|
6
|
-
export declare const profiles: Record<ProfileKey, Profile>;
|
|
7
|
-
/**
|
|
8
|
-
* SAF (Search Application Frontend) configuration
|
|
9
|
-
*/
|
|
10
|
-
export interface SafConfig {
|
|
11
|
-
baseUrl: string;
|
|
12
|
-
baseCloudFrontUrl: string;
|
|
13
|
-
endpoints: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
export declare function getSafConfig(profileKey: ProfileKey): SafConfig;
|
|
16
|
-
/**
|
|
17
|
-
* SAPI backend configuration
|
|
18
|
-
*/
|
|
19
|
-
export interface BackendConfig {
|
|
20
|
-
baseUrl: string;
|
|
21
|
-
endpoints: Record<string, string>;
|
|
22
|
-
}
|
|
23
|
-
export declare function getBackendConfig(profileKey: ProfileKey): BackendConfig;
|