-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
234 additions
and
51 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-core](./search-core.md) > [provideEndpoints](./search-core.provideendpoints.md) | ||
|
||
## provideEndpoints() function | ||
|
||
Provides all endpoints based on environment and cloud region. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare function provideEndpoints(config?: ServingConfig): Required<Endpoints>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| config | [ServingConfig](./search-core.servingconfig.md) | serving config to use for the domain, defaults to Prod and US if not provided. | | ||
|
||
<b>Returns:</b> | ||
|
||
Required<[Endpoints](./search-core.endpoints.md)<!-- -->> | ||
|
||
## Remarks | ||
|
||
Returns an [Endpoints](./search-core.endpoints.md) instance. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-core](./search-core.md) > [ServingConfig](./search-core.servingconfig.md) > [cloudRegion](./search-core.servingconfig.cloudregion.md) | ||
|
||
## ServingConfig.cloudRegion property | ||
|
||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
cloudRegion?: CloudRegion; | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-core](./search-core.md) > [ServingConfig](./search-core.servingconfig.md) > [environment](./search-core.servingconfig.environment.md) | ||
|
||
## ServingConfig.environment property | ||
|
||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
environment?: Environment; | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-core](./search-core.md) > [ServingConfig](./search-core.servingconfig.md) | ||
|
||
## ServingConfig interface | ||
|
||
The configuration options for [provideEndpoints()](./search-core.provideendpoints.md)<!-- -->. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface ServingConfig | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [cloudRegion?](./search-core.servingconfig.cloudregion.md) | CloudRegion | <i>(Optional)</i> | | ||
| [environment?](./search-core.servingconfig.environment.md) | Environment | <i>(Optional)</i> | | ||
|
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 was deleted.
Oops, something went wrong.
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,6 +1,6 @@ | ||
// main symbols | ||
export { SearchCore } from './SearchCore'; | ||
export { provideCore } from './provideCore'; | ||
export { SandboxEndpoints } from './constants'; | ||
export { provideEndpoints, SandboxEndpoints } from './provideEndpoints'; | ||
export * from './models'; | ||
export * from './services'; |
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Defines the cloud region of the API domains. | ||
* | ||
* @public | ||
*/ | ||
export enum CloudRegion { | ||
US = 'us', | ||
EU = 'eu', | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Defines the environment of the API domains. | ||
* | ||
* @public | ||
*/ | ||
export enum Environment { | ||
PROD = 'prod', | ||
SANDBOX = 'sbx', | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Endpoints } from './models/core/Endpoints'; | ||
import { Environment } from './models/core/Environment'; | ||
import { CloudRegion } from './models/core/CloudRegion'; | ||
import { ServingConfig } from './models/core/SearchConfig'; | ||
|
||
export const defaultApiVersion = 20220511; | ||
|
||
/** | ||
* Provides methods for getting various endpoints. | ||
* | ||
* @internal | ||
*/ | ||
export class EndpointsAdapter { | ||
private readonly environment: Environment; | ||
private readonly cloudRegion: CloudRegion; | ||
|
||
constructor(config?: ServingConfig) { | ||
this.environment = config?.environment || Environment.PROD; | ||
this.cloudRegion = config?.cloudRegion || CloudRegion.US; | ||
} | ||
|
||
/** Provides the domain based on environment and cloud region. | ||
* @internal | ||
*/ | ||
getDomain() { | ||
return `https://${this.environment}-cdn.${this.cloudRegion}.yextapis.com`; | ||
} | ||
|
||
/** | ||
* Provides all endpoints based on environment and cloud region. | ||
* @internal | ||
*/ | ||
getEndpoints() { | ||
return { | ||
universalSearch: `${this.getDomain()}/v2/accounts/me/search/query`, | ||
verticalSearch: `${this.getDomain()}/v2/accounts/me/search/vertical/query`, | ||
questionSubmission: `${this.getDomain()}/v2/accounts/me/createQuestion`, | ||
status: 'https://answersstatus.pagescdn.com', | ||
universalAutocomplete: `${this.getDomain()}/v2/accounts/me/search/autocomplete`, | ||
verticalAutocomplete: `${this.getDomain()}/v2/accounts/me/search/vertical/autocomplete`, | ||
filterSearch: `${this.getDomain()}/v2/accounts/me/search/filtersearch`, | ||
}; | ||
} | ||
} | ||
|
||
/** | ||
* The endpoints to use for sandbox experiences. | ||
* | ||
* @deprecated Use {@link provideEndpoints} instead | ||
* | ||
* @public | ||
*/ | ||
export const SandboxEndpoints: Required<Endpoints> = | ||
new EndpointsAdapter({ environment: Environment.SANDBOX, cloudRegion: CloudRegion.US }) | ||
.getEndpoints(); | ||
|
||
/** | ||
* Provides all endpoints based on environment and cloud region. | ||
* | ||
* @remarks | ||
* Returns an {@link Endpoints} instance. | ||
* | ||
* @param config - serving config to use for the domain, defaults to Prod and US if not provided. | ||
* | ||
* @public | ||
*/ | ||
export function provideEndpoints(config?: ServingConfig): Required<Endpoints> { | ||
return new EndpointsAdapter(config).getEndpoints(); | ||
} |
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
Oops, something went wrong.