Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@findhotel/sapi

Package Overview
Dependencies
Maintainers
3
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@findhotel/sapi - npm Package Compare versions

Comparing version 0.21.2 to 0.22.0

dist/types/packages/core/src/saf-search.d.ts

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [0.22.0](https://github.com/FindHotel/sapi/compare/v0.21.2...v0.22.0) (2021-10-04)
### Added
- Support for SAF/search endpoint
### Changed
- sapi.getConfig() method replaced with onConfigReceived callback in SAPI client
## [0.21.2](https://github.com/FindHotel/sapi/compare/v0.21.1...v0.21.2) (2021-09-03)

@@ -2,0 +9,0 @@ ### Changed

3

dist/types/packages/core/src/profile.d.ts

@@ -1,3 +0,2 @@

import { InitConfig } from './sapi-init';
import { Profile, ProfileKey } from './types';
export declare function getProfile(profileKey: ProfileKey, initWithProfile?: Partial<Profile>, initConfig?: InitConfig): Profile;
export declare function getProfile(profileKey: ProfileKey, initWithProfile?: Partial<Profile>): Profile;

@@ -5,3 +5,3 @@ import { SearchClient } from 'algoliasearch';

import { Configs } from './algolia';
import { ProfileKey, ClientOptions, SapiClient, Profile, SafConfig, SapiFeature, Language } from './types';
import { ProfileKey, ClientOptions, SapiClient, Profile, SafConfig, SapiFeature, Language, Logger } from './types';
export declare type AlgoliaClient = Pick<SearchClient, 'search'>;

@@ -20,3 +20,4 @@ export interface Base {

/** Options persistent within single SAPI instance */
options: Except<ClientOptions, 'variations'> & {
options: Except<ClientOptions, 'variations' | 'logger'> & {
logger: Logger;
variations: string[];

@@ -23,0 +24,0 @@ pageSize: number;

import { Except } from 'type-fest';
import { BaseWithConfig } from '.';
import { AnchorType, Facets } from './algolia';
import { AnchorObject, AnchorType, Facets } from './algolia';
import { DealScores, DatesConfig } from './utils';
import { Anchor, ApiSearchParameters, Hotel, HotelOfferEntity, SearchParameters, HotelId } from './types';
interface SearchResults {
import { Anchor, ApiSearchParameters, Hotel, HotelOfferEntity, AnonymousId, SearchParameters, HotelId } from './types';
export interface SearchResults {
anchor: Anchor;

@@ -27,2 +27,9 @@ anchorHotelId?: HotelId;

declare type OnComplete = (response: SearchResults) => void;
interface Options {
anonymousId: AnonymousId;
language: string;
currency: string;
userCountry: string;
pageSize: number;
}
export declare type SearchFn = (parameters: ApiSearchParameters, callbacks?: {

@@ -39,4 +46,5 @@ onStart?: OnStart;

export declare function prepareSearchParameters(parameters: ApiSearchParameters, dates: DatesConfig): SearchParameters;
export declare function getRequestSize(anchorObject: AnchorObject, parameters: SearchParameters, options: Options): number;
declare type SearchFnParameters = Pick<BaseWithConfig, 'options' | 'profile' | 'algoliaClient' | 'raaClient' | 'configs' | 'getFeatureEnabled'>;
export declare function search({ getFeatureEnabled, profile, algoliaClient, raaClient, options, configs }: SearchFnParameters): SearchFn;
export {};

@@ -7,3 +7,3 @@ import { AlgoliaSearchOptions } from 'algoliasearch';

import { SuggestFn } from '../suggest';
import { ListOfValuesItem, ExchangeRates } from '../algolia';
import { Configs } from '../algolia';
export declare type ProfileKey = string;

@@ -14,3 +14,3 @@ interface Event {

}
interface Logger {
export interface Logger {
log: (event: Event) => void;

@@ -22,6 +22,2 @@ }

suggest: SuggestFn;
getConfig: () => {
lov: ListOfValuesItem[];
exchangeRates: ExchangeRates;
};
}

@@ -62,3 +58,7 @@ /** Options for initializing the Search API client. Persistent within single SAPI instance but may vary for different users */

variations?: Record<string, string>;
/** Client callbacks */
callbacks?: {
onConfigReceived?: (config: Pick<Configs, 'lov' | 'exchangeRates'>) => void;
};
}
export {};

@@ -29,2 +29,6 @@ /**

export interface OptionalSearchParameters {
placeId?: string;
hotelId?: string;
geolocation?: Location;
query?: string;
checkIn?: string;

@@ -31,0 +35,0 @@ checkOut?: string;

{
"name": "@findhotel/sapi",
"version": "0.21.2",
"version": "0.22.0",
"description": "FindHotel Search API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -11,11 +11,12 @@

3. [API Reference](#api-reference)
1. [SAPI client](#sapi-client):Constructor:
1. [SAPI client](#sapi-client)
1. [Supported options](#client-options)
2. [`search()` method](#search-method):Method:
1. [Search parameters](#search-parameters):Parameters:
2. [Callbacks](#search-callbacks):Parameters:
3. [Response](#search-response):Response:
3. [`rooms()` method](#rooms-method):Method:
1. [Rooms query parameters](#rooms-parameters):Parameters:
2. [Response](#rooms-response):Response:
2. [Available client callbacks](#client-callbacks)
2. [`search()` method](#search-method)
1. [Search parameters](#search-parameters)
2. [Callbacks](#search-callbacks)
3. [Response](#search-response)
3. [`rooms()` method](#rooms-method)
1. [Rooms parameters](#rooms-parameters)
2. [Response](#rooms-response)

@@ -57,3 +58,3 @@ SDK provides a high level TypeScript/JavaScript API for searching

const options = {
const sapiClient = await sapi(profileKey, {
anonymousId: 'fd9dbb5f-b337-4dd7-b640-1f177d1d3caa',

@@ -63,5 +64,3 @@ language: 'en',

userCountry: 'US'
}
const sapiClient = await sapi(profileKey, options)
})

@@ -137,3 +136,3 @@ Now SAPI client is ready to be used in your application.

## SAPI client :Constructor:
## SAPI client

@@ -144,10 +143,28 @@ Create SAPI client:

const options = {
const sapiClient = await sapi(profileKey, {
anonymousId: 'fd9dbb5f-b337-4dd7-b640-1f177d1d3caa',
language: 'en',
currency: 'USD',
userCountry: 'US'
}
const sapiClient = await sapi(profileKey, options)
userCountry: 'US',
deviceCategory: 'mobile',
includeLocalTaxes: true,
includeTaxes: false,
pageSize: 20,
useSaf: false,
initWithProfile: {
features: ['search', 'configs'],
},
algoliaClientOptions: {
timeouts: {
connect: 1, // Connection timeout in seconds
read: 2, // Read timeout in seconds
write: 30, // Write timeout in seconds
},
},
callbacks: {
onConfigReceived: (config) => {
console.log('Config received', config)
}
}
})

@@ -199,3 +216,3 @@

<td class="org-left">`language`</td>
<td class="org-left">yes</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>

@@ -210,3 +227,3 @@ <td class="org-left">`en`</td>

<td class="org-left">`currency`</td>
<td class="org-left">yes</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>

@@ -221,3 +238,3 @@ <td class="org-left">`USD`</td>

<td class="org-left">`userCountry`</td>
<td class="org-left">yes</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>

@@ -298,2 +315,12 @@ <td class="org-left">`US`</td>

</tr>
<tr>
<td class="org-left">`callbacks`</td>
<td class="org-left">no</td>
<td class="org-left">`Record<string, fnc>`</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">Client callbasks</td>
<td class="org-left">&#xa0;</td>
</tr>
</tbody>

@@ -303,5 +330,14 @@ </table>

<a id="client-callbacks"></a>
### Available client callbacks
1. onConfigReceived(configs)
Returns configuration settings that are in use by sapiClient when received from remote endpoint.
<a id="search-method"></a>
## `search()` method :Method:
## `search()` method

@@ -316,4 +352,6 @@ Search is a method of **sapiClient** for searching hotels and offers for

### Search parameters :Parameters:
### Search parameters
All parameters are optional.
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">

@@ -330,4 +368,2 @@

<col class="org-left" />
<col class="org-left" />
</colgroup>

@@ -337,3 +373,2 @@ <thead>

<th scope="col" class="org-left">name</th>
<th scope="col" class="org-left">required</th>
<th scope="col" class="org-left">type</th>

@@ -348,5 +383,4 @@ <th scope="col" class="org-left">description</th>

<td class="org-left">`hotelId`</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>
<td class="org-left">Hotel Id for hotel search</td>
<td class="org-left">Hotel Id for hotel search. If present, takes precedence over `placeId`, `query` and `geolocation`.</td>
<td class="org-left">`1371626`</td>

@@ -358,5 +392,4 @@ </tr>

<td class="org-left">`placeId`</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>
<td class="org-left">Place Id for place search</td>
<td class="org-left">Place Id for place search. If present, takes precedence over `query` and `geolocation`.</td>
<td class="org-left">`47319`</td>

@@ -367,7 +400,6 @@ </tr>

<tr>
<td class="org-left">`query`</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>
<td class="org-left">Text query</td>
<td class="org-left">`Amsterdam city`</td>
<td class="org-left">`geolocation`</td>
<td class="org-left">`{lat: number, lon: number}`</td>
<td class="org-left">Geolocation query. If present, takes precedence over `query`</td>
<td class="org-left">`{lat: 36.114303, lon: -115.178312}`</td>
</tr>

@@ -377,7 +409,6 @@

<tr>
<td class="org-left">`geolocation`</td>
<td class="org-left">no</td>
<td class="org-left">`{lat: number, lon: number}`</td>
<td class="org-left">Geolocation query</td>
<td class="org-left">`{lat: 36.114303, lon: -115.178312}`</td>
<td class="org-left">`query`</td>
<td class="org-left">`string`</td>
<td class="org-left">Free-text query</td>
<td class="org-left">`Amsterdam city`</td>
</tr>

@@ -388,3 +419,2 @@

<td class="org-left">`checkIn`</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>

@@ -398,3 +428,2 @@ <td class="org-left">Check in date (`YYYY-MM-DD`)</td>

<td class="org-left">`checkOut`</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>

@@ -408,5 +437,4 @@ <td class="org-left">Check out date (`YYYY-MM-DD`)</td>

<td class="org-left">`rooms`</td>
<td class="org-left">no</td>
<td class="org-left">`string`</td>
<td class="org-left">Rooms configuration</td>
<td class="org-left">[Rooms configuration](https://github.com/FindHotel/search-data-pipelines/wiki/Glossary#rooms-configuration)</td>
<td class="org-left">`2`</td>

@@ -420,3 +448,3 @@ </tr>

### Callbacks :Parameters:
### Callbacks

@@ -443,8 +471,14 @@ Search method receives callbacks object as the second argument:

1. onStart(response)
1. onStart()
Runs at the beginning of the each new search
`response` - *in progress&#x2026;*
Runs at the beginning of the each new search.
The callback is supplied with generated `searchId` and actual search
parameters that are used for the search, like dates, currency,
language used if invoker didn't provide those.
Another purpose of this callback is that invoker can track that hotels
search has started, in Search SPA the event is [HotelsSearched](https://engdocs.fih.io/event-analytics/sources/#event-hotelssearched).
2. onAnchorReceived(response)
2. onAnchorReceived()

@@ -454,3 +488,3 @@ Runs when SAPI receives anchor (and?) anchor hotel

3. onHotelsReceived(response)
3. onHotelsReceived()

@@ -460,3 +494,3 @@ Runs when SAPI receives static search results

4. onOffersReceived(response)
4. onOffersReceived()

@@ -466,3 +500,3 @@ Runs when SAPI receives a bunch of offers

5. onComplete(response)
5. onComplete()

@@ -475,3 +509,3 @@ Runs when current search is complete and all offers are retrieved

### Response :Response:
### Response

@@ -483,3 +517,3 @@ *in progress&#x2026;*

## `rooms()` method :Method:
## `rooms()` method

@@ -499,4 +533,6 @@ Rooms is a method of **sapiClient** for retrieving rooms information and

### Rooms query parameters :Parameters:
### Rooms parameters
All attributes of parameters object are required.
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">

@@ -513,6 +549,2 @@

<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>

@@ -522,5 +554,3 @@ <thead>

<th scope="col" class="org-left">name</th>
<th scope="col" class="org-left">required</th>
<th scope="col" class="org-left">type</th>
<th scope="col" class="org-left">default</th>
<th scope="col" class="org-left">description</th>

@@ -534,5 +564,3 @@ <th scope="col" class="org-left">example</th>

<td class="org-left">`hotelId`</td>
<td class="org-left">yes</td>
<td class="org-left">`string`</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">Hotel Id to retrieve rooms</td>

@@ -545,5 +573,3 @@ <td class="org-left">`1371626`</td>

<td class="org-left">`checkIn`</td>
<td class="org-left">yes</td>
<td class="org-left">`string`</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">Check in date (`YYYY-MM-DD`)</td>

@@ -556,5 +582,3 @@ <td class="org-left">`2021-10-10`</td>

<td class="org-left">`checkOut`</td>
<td class="org-left">yes</td>
<td class="org-left">`string`</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">Check out date (`YYYY-MM-DD`)</td>

@@ -567,6 +591,4 @@ <td class="org-left">`2021-10-11`</td>

<td class="org-left">`rooms`</td>
<td class="org-left">yes</td>
<td class="org-left">`string`</td>
<td class="org-left">&#xa0;</td>
<td class="org-left">Rooms configuration</td>
<td class="org-left">[Rooms configuration](https://github.com/FindHotel/search-data-pipelines/wiki/Glossary#rooms-configuration)</td>
<td class="org-left">`2`</td>

@@ -580,3 +602,3 @@ </tr>

### Response :Response:
### Response

@@ -583,0 +605,0 @@ *in progress&#x2026;*

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc