-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(javascript): allow overriding all transporter options
In v4 these are all allowed, and this allows users to work around possible issues we have smoothly, see eg. algolia/react-instantsearch#3487 At the same time I also simplified the passing of options in node/browser, they were double checking a variable that later overrides the original with the spread anyway. Note to self: #614 touches a similar part of the code, whichever merges last will have to deal with a conflict
- Loading branch information
Showing
4 changed files
with
46 additions
and
48 deletions.
There are no files selected for viewing
44 changes: 18 additions & 26 deletions
44
clients/algoliasearch-client-javascript/packages/client-common/src/types/CreateClient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,23 @@ | ||
import type { Cache } from './Cache'; | ||
import type { Host } from './Host'; | ||
import type { Requester } from './Requester'; | ||
import type { | ||
Timeouts, | ||
AlgoliaAgentOptions, | ||
TransporterOptions, | ||
} from './Transporter'; | ||
import type { AlgoliaAgentOptions, TransporterOptions } from './Transporter'; | ||
|
||
export type AuthMode = 'WithinHeaders' | 'WithinQueryParameters'; | ||
|
||
export type CreateClientOptions = Pick< | ||
type OverriddenTransporterOptions = | ||
| 'baseHeaders' | ||
| 'baseQueryParameters' | ||
| 'hosts'; | ||
|
||
export type CreateClientOptions = Omit< | ||
TransporterOptions, | ||
'hostsCache' | 'requestsCache' | 'responsesCache' | ||
> & { | ||
appId: string; | ||
apiKey: string; | ||
requester: Requester; | ||
timeouts: Timeouts; | ||
algoliaAgents: AlgoliaAgentOptions[]; | ||
hosts?: Host[]; | ||
authMode?: AuthMode; | ||
}; | ||
OverriddenTransporterOptions | 'algoliaAgent' | ||
> & | ||
Partial<Pick<TransporterOptions, OverriddenTransporterOptions>> & { | ||
appId: string; | ||
apiKey: string; | ||
authMode?: AuthMode; | ||
algoliaAgents: AlgoliaAgentOptions[]; | ||
}; | ||
|
||
export type InitClientOptions = Partial<{ | ||
requester: Requester; | ||
hosts: Host[]; | ||
responsesCache: Cache; | ||
requestsCache: Cache; | ||
hostsCache: Cache; | ||
}>; | ||
export type InitClientOptions = Partial< | ||
Omit<CreateClientOptions, 'apiKey' | 'appId'> | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters