diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 7e7197aa..1e6e3867 100644 --- a/THIRD-PARTY-NOTICES +++ b/THIRD-PARTY-NOTICES @@ -157,6 +157,82 @@ This package contains the following license and notice below: ----------- +The following NPM package may be included in this product: + + - tsc@2.0.4 + +This package contains the following license and notice below: + +## DEPRECATED. + +Use [`typescript`](https://www.npmjs.com/package/typescript) to get access to the `tsc` CLI command. + +----------- + +The following NPM package may be included in this product: + + - typescript@5.0.4 + +This package contains the following license and notice below: + +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +----------- + The following NPM package may be included in this product: - webidl-conversions@3.0.1 diff --git a/docs/search-core.basesearchconfig.cloudregion.md b/docs/search-core.basesearchconfig.cloudregion.md new file mode 100644 index 00000000..6fe93ecb --- /dev/null +++ b/docs/search-core.basesearchconfig.cloudregion.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@yext/search-core](./search-core.md) > [BaseSearchConfig](./search-core.basesearchconfig.md) > [cloudRegion](./search-core.basesearchconfig.cloudregion.md) + +## BaseSearchConfig.cloudRegion property + +Defines the cloud region of the API domains. + +Signature: + +```typescript +cloudRegion?: CloudRegion; +``` diff --git a/docs/search-core.basesearchconfig.environment.md b/docs/search-core.basesearchconfig.environment.md new file mode 100644 index 00000000..6294b2f6 --- /dev/null +++ b/docs/search-core.basesearchconfig.environment.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@yext/search-core](./search-core.md) > [BaseSearchConfig](./search-core.basesearchconfig.md) > [environment](./search-core.basesearchconfig.environment.md) + +## BaseSearchConfig.environment property + +Defines the environment of the API domains. + +Signature: + +```typescript +environment?: Environment; +``` diff --git a/docs/search-core.basesearchconfig.md b/docs/search-core.basesearchconfig.md index e3e2d413..db9b02da 100644 --- a/docs/search-core.basesearchconfig.md +++ b/docs/search-core.basesearchconfig.md @@ -4,20 +4,23 @@ ## BaseSearchConfig interface -The base configuration options for [SearchCore](./search-core.searchcore.md). +The base configuration options for [SearchCore](./search-core.searchcore.md), which includes the options from [ServingConfig](./search-core.servingconfig.md). Signature: ```typescript -export interface BaseSearchConfig +export interface BaseSearchConfig extends ServingConfig ``` +Extends: [ServingConfig](./search-core.servingconfig.md) ## Properties | Property | Type | Description | | --- | --- | --- | | [additionalQueryParams?](./search-core.basesearchconfig.additionalqueryparams.md) | { \[key: string\]: string \| number \| boolean; } | (Optional) Additional query params added on to every request. | +| [cloudRegion?](./search-core.basesearchconfig.cloudregion.md) | [CloudRegion](./search-core.cloudregion.md) | (Optional) Defines the cloud region of the API domains. | | [endpoints?](./search-core.basesearchconfig.endpoints.md) | [Endpoints](./search-core.endpoints.md) | (Optional) Overrides for the URLs which are used when making requests to the Search API. | +| [environment?](./search-core.basesearchconfig.environment.md) | [Environment](./search-core.environment.md) | (Optional) Defines the environment of the API domains. | | [experienceKey](./search-core.basesearchconfig.experiencekey.md) | string | The experience key of the search experience. | | [experienceVersion?](./search-core.basesearchconfig.experienceversion.md) | 'STAGING' \| 'PRODUCTION' \| string \| number | (Optional) The version of the search experience configuration. | | [locale](./search-core.basesearchconfig.locale.md) | string | The locale of the search experience. | diff --git a/docs/search-core.cloudregion.md b/docs/search-core.cloudregion.md new file mode 100644 index 00000000..e6db39bc --- /dev/null +++ b/docs/search-core.cloudregion.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@yext/search-core](./search-core.md) > [CloudRegion](./search-core.cloudregion.md) + +## CloudRegion enum + +Defines the cloud region of the API domains. + +Signature: + +```typescript +export declare enum CloudRegion +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| EU | "eu" | | +| US | "us" | | + diff --git a/docs/search-core.context.md b/docs/search-core.context.md index 526795e2..78b28cba 100644 --- a/docs/search-core.context.md +++ b/docs/search-core.context.md @@ -9,7 +9,7 @@ Used to trigger Search [Query Rules](https://hitchhikers.yext.com/tracks/answers Signature: ```typescript -export declare type Context = any; +export type Context = any; ``` ## Remarks diff --git a/docs/search-core.enumorliteral.md b/docs/search-core.enumorliteral.md index 7dc80b4c..22b56c8c 100644 --- a/docs/search-core.enumorliteral.md +++ b/docs/search-core.enumorliteral.md @@ -9,5 +9,5 @@ Produces a union type from the enum passed as a generic which consists of the en Signature: ```typescript -export declare type EnumOrLiteral = T | `${T}`; +export type EnumOrLiteral = T | `${T}`; ``` diff --git a/docs/search-core.environment.md b/docs/search-core.environment.md new file mode 100644 index 00000000..238ee840 --- /dev/null +++ b/docs/search-core.environment.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@yext/search-core](./search-core.md) > [Environment](./search-core.environment.md) + +## Environment enum + +Defines the environment of the API domains. + +Signature: + +```typescript +export declare enum Environment +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| PROD | "prod" | | +| SANDBOX | "sbx" | | + diff --git a/docs/search-core.featuredsnippetdirectanswer.md b/docs/search-core.featuredsnippetdirectanswer.md index fb2a6e1f..dea968c5 100644 --- a/docs/search-core.featuredsnippetdirectanswer.md +++ b/docs/search-core.featuredsnippetdirectanswer.md @@ -9,7 +9,7 @@ All possible built-in [BaseFeaturedSnippetDirectAnswer](./search-core.basefeatur Signature: ```typescript -export declare type FeaturedSnippetDirectAnswer = MultiLineTextSnippetDirectAnswer | RichTextSnippetDirectAnswer; +export type FeaturedSnippetDirectAnswer = MultiLineTextSnippetDirectAnswer | RichTextSnippetDirectAnswer; ``` References: [MultiLineTextSnippetDirectAnswer](./search-core.multilinetextsnippetdirectanswer.md), [RichTextSnippetDirectAnswer](./search-core.richtextsnippetdirectanswer.md) diff --git a/docs/search-core.fieldvaluedirectanswer.md b/docs/search-core.fieldvaluedirectanswer.md index 952a3fbb..eced3cb6 100644 --- a/docs/search-core.fieldvaluedirectanswer.md +++ b/docs/search-core.fieldvaluedirectanswer.md @@ -9,7 +9,7 @@ Possible built-in and custom [BaseFieldValueDirectAnswer](./search-core.basefiel Signature: ```typescript -export declare type FieldValueDirectAnswer = UnknownFieldValueDirectAnswer | TextDirectAnswer | UrlDirectAnswer | RichTextDirectAnswer | DecimalDirectAnswer | FacebookUrlDirectAnswer | InstagramHandleDirectAnswer | TwitterHandleDirectAnswer | IosAppUrlDirectAnswer | AndroidAppUrlDirectAnswer | ComplexUrlDirectAnswer | IntegerDirectAnswer | PhoneDirectAnswer | EmailDirectAnswer | AddressDirectAnswer | HoursDirectAnswer; +export type FieldValueDirectAnswer = UnknownFieldValueDirectAnswer | TextDirectAnswer | UrlDirectAnswer | RichTextDirectAnswer | DecimalDirectAnswer | FacebookUrlDirectAnswer | InstagramHandleDirectAnswer | TwitterHandleDirectAnswer | IosAppUrlDirectAnswer | AndroidAppUrlDirectAnswer | ComplexUrlDirectAnswer | IntegerDirectAnswer | PhoneDirectAnswer | EmailDirectAnswer | AddressDirectAnswer | HoursDirectAnswer; ``` References: [UnknownFieldValueDirectAnswer](./search-core.unknownfieldvaluedirectanswer.md), [TextDirectAnswer](./search-core.textdirectanswer.md), [UrlDirectAnswer](./search-core.urldirectanswer.md), [RichTextDirectAnswer](./search-core.richtextdirectanswer.md), [DecimalDirectAnswer](./search-core.decimaldirectanswer.md), [FacebookUrlDirectAnswer](./search-core.facebookurldirectanswer.md), [InstagramHandleDirectAnswer](./search-core.instagramhandledirectanswer.md), [TwitterHandleDirectAnswer](./search-core.twitterhandledirectanswer.md), [IosAppUrlDirectAnswer](./search-core.iosappurldirectanswer.md), [AndroidAppUrlDirectAnswer](./search-core.androidappurldirectanswer.md), [ComplexUrlDirectAnswer](./search-core.complexurldirectanswer.md), [IntegerDirectAnswer](./search-core.integerdirectanswer.md), [PhoneDirectAnswer](./search-core.phonedirectanswer.md), [EmailDirectAnswer](./search-core.emaildirectanswer.md), [AddressDirectAnswer](./search-core.addressdirectanswer.md), [HoursDirectAnswer](./search-core.hoursdirectanswer.md) diff --git a/docs/search-core.highlightedfields.md b/docs/search-core.highlightedfields.md index a78aa79f..64a8d17e 100644 --- a/docs/search-core.highlightedfields.md +++ b/docs/search-core.highlightedfields.md @@ -9,7 +9,7 @@ A mapping of fields to the values emphasized by the Search API. Signature: ```typescript -export declare type HighlightedFields = { +export type HighlightedFields = { [fieldId: string]: HighlightedValue | HighlightedValue[] | HighlightedFields | HighlightedFields[]; }; ``` diff --git a/docs/search-core.md b/docs/search-core.md index 615f03a8..ceda135f 100644 --- a/docs/search-core.md +++ b/docs/search-core.md @@ -17,8 +17,10 @@ | --- | --- | | [AppliedQueryFilterType](./search-core.appliedqueryfiltertype.md) | Represents the type of [AppliedQueryFilter](./search-core.appliedqueryfilter.md) applied to a search. | | [BuiltInFieldType](./search-core.builtinfieldtype.md) | Possible built-in field types for [DirectAnswer.fieldType](./search-core.directanswer.fieldtype.md). | +| [CloudRegion](./search-core.cloudregion.md) | Defines the cloud region of the API domains. | | [DirectAnswerType](./search-core.directanswertype.md) | Represents the type of direct answer. | | [Direction](./search-core.direction.md) | The direction of a sort. | +| [Environment](./search-core.environment.md) | Defines the environment of the API domains. | | [ErrorType](./search-core.errortype.md) | Identifier for the type of error causing the failure. | | [FilterCombinator](./search-core.filtercombinator.md) | Indicates how child filters in a [StaticFilter](./search-core.staticfilter.md) should be combined. | | [LocationBiasMethod](./search-core.locationbiasmethod.md) | The method used to determine the location. | @@ -50,7 +52,7 @@ | [AutocompleteService](./search-core.autocompleteservice.md) | A service for autocomplete requests. | | [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) | A direct answer which was found within a document. | | [BaseFieldValueDirectAnswer](./search-core.basefieldvaluedirectanswer.md) | A direct answer where the answer came from a field from the knowledge graph. | -| [BaseSearchConfig](./search-core.basesearchconfig.md) | The base configuration options for [SearchCore](./search-core.searchcore.md). | +| [BaseSearchConfig](./search-core.basesearchconfig.md) | The base configuration options for [SearchCore](./search-core.searchcore.md), which includes the options from [ServingConfig](./search-core.servingconfig.md). | | [ClientSDKHeaderValues](./search-core.clientsdkheadervalues.md) | Additional agents and their versions used to create the Search experience. The information for these agents is added to the Client-SDK HTTP header along with that of the ANSWERS\_CORE agent. | | [ComplexURL](./search-core.complexurl.md) | The shape of a [BuiltInFieldType.ComplexURL](./search-core.builtinfieldtype.md) DirectAnswer value | | [ComplexUrlDirectAnswer](./search-core.complexurldirectanswer.md) | A direct answer for a complex url field. | @@ -100,6 +102,7 @@ | [SearchParameterField](./search-core.searchparameterfield.md) | Indicates which entity field to perform the autocomplete request on. | | [SearchRequest](./search-core.searchrequest.md) | Options for a Search API request. | | [SearchService](./search-core.searchservice.md) | A service which performs Yext Search. | +| [ServingConfig](./search-core.servingconfig.md) | The configuration options for getting the endpoints. | | [Snippet](./search-core.snippet.md) | The section of text where a [FeaturedSnippetDirectAnswer](./search-core.featuredsnippetdirectanswer.md) was found. | | [SortBy](./search-core.sortby.md) | Represents a criterion that can be used to sort results. | | [SpellCheck](./search-core.spellcheck.md) | A spellcheck response from a search query. | diff --git a/docs/search-core.sandboxendpoints.md b/docs/search-core.sandboxendpoints.md index 4b28fa12..03769138 100644 --- a/docs/search-core.sandboxendpoints.md +++ b/docs/search-core.sandboxendpoints.md @@ -4,6 +4,11 @@ ## SandboxEndpoints variable +> Warning: This API is now obsolete. +> +> Use [provideCore()](./search-core.providecore.md) with the appropriate [ServingConfig](./search-core.servingconfig.md) instead +> + The endpoints to use for sandbox experiences. Signature: diff --git a/docs/search-core.searchconfig.md b/docs/search-core.searchconfig.md index 56d994c6..5d9997b2 100644 --- a/docs/search-core.searchconfig.md +++ b/docs/search-core.searchconfig.md @@ -9,7 +9,7 @@ The main configuration options for [SearchCore](./search-core.searchcore.md), [SearchConfigWithToken](./search-core.searchconfigwithtoken.md) diff --git a/docs/search-core.servingconfig.cloudregion.md b/docs/search-core.servingconfig.cloudregion.md new file mode 100644 index 00000000..b610eaf3 --- /dev/null +++ b/docs/search-core.servingconfig.cloudregion.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@yext/search-core](./search-core.md) > [ServingConfig](./search-core.servingconfig.md) > [cloudRegion](./search-core.servingconfig.cloudregion.md) + +## ServingConfig.cloudRegion property + +Defines the cloud region of the API domains. + +Signature: + +```typescript +cloudRegion?: CloudRegion; +``` diff --git a/docs/search-core.servingconfig.environment.md b/docs/search-core.servingconfig.environment.md new file mode 100644 index 00000000..f8d8fce3 --- /dev/null +++ b/docs/search-core.servingconfig.environment.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@yext/search-core](./search-core.md) > [ServingConfig](./search-core.servingconfig.md) > [environment](./search-core.servingconfig.environment.md) + +## ServingConfig.environment property + +Defines the environment of the API domains. + +Signature: + +```typescript +environment?: Environment; +``` diff --git a/docs/search-core.servingconfig.md b/docs/search-core.servingconfig.md new file mode 100644 index 00000000..233f2845 --- /dev/null +++ b/docs/search-core.servingconfig.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@yext/search-core](./search-core.md) > [ServingConfig](./search-core.servingconfig.md) + +## ServingConfig interface + +The configuration options for getting the endpoints. + +Signature: + +```typescript +export interface ServingConfig +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [cloudRegion?](./search-core.servingconfig.cloudregion.md) | [CloudRegion](./search-core.cloudregion.md) | (Optional) Defines the cloud region of the API domains. | +| [environment?](./search-core.servingconfig.environment.md) | [Environment](./search-core.environment.md) | (Optional) Defines the environment of the API domains. | + diff --git a/docs/search-core.staticfilter.md b/docs/search-core.staticfilter.md index 757a6a6d..b2bdffba 100644 --- a/docs/search-core.staticfilter.md +++ b/docs/search-core.staticfilter.md @@ -9,7 +9,7 @@ Represents a static filter that will be used to refine results. Signature: ```typescript -export declare type StaticFilter = FieldValueStaticFilter | DisjunctionStaticFilter | ConjunctionStaticFilter; +export type StaticFilter = FieldValueStaticFilter | DisjunctionStaticFilter | ConjunctionStaticFilter; ``` References: [FieldValueStaticFilter](./search-core.fieldvaluestaticfilter.md), [DisjunctionStaticFilter](./search-core.disjunctionstaticfilter.md), [ConjunctionStaticFilter](./search-core.conjunctionstaticfilter.md) diff --git a/etc/search-core.api.md b/etc/search-core.api.md index 68e326d1..a44ffbea 100644 --- a/etc/search-core.api.md +++ b/etc/search-core.api.md @@ -105,11 +105,13 @@ export interface BaseFieldValueDirectAnswer extends DirectAnswer } // @public -export interface BaseSearchConfig { +export interface BaseSearchConfig extends ServingConfig { additionalQueryParams?: { [key: string]: string | number | boolean; }; + cloudRegion?: CloudRegion; endpoints?: Endpoints; + environment?: Environment; experienceKey: string; experienceVersion?: 'STAGING' | 'PRODUCTION' | string | number; locale: string; @@ -158,6 +160,14 @@ export interface ClientSDKHeaderValues { ANSWERS_CORE?: never; } +// @public +export enum CloudRegion { + // (undocumented) + EU = "eu", + // (undocumented) + US = "us" +} + // @public export interface ComplexURL { // (undocumented) @@ -266,6 +276,14 @@ export interface Endpoints { // @public export type EnumOrLiteral = T | `${T}`; +// @public +export enum Environment { + // (undocumented) + PROD = "prod", + // (undocumented) + SANDBOX = "sbx" +} + // @public export enum ErrorType { BackendError = "BACKEND_ERROR", @@ -581,7 +599,7 @@ export interface RichTextSnippetDirectAnswer extends Omit; } -// @public +// @public @deprecated export const SandboxEndpoints: Required; // @public @@ -642,6 +660,12 @@ export interface SearchService { verticalSearch(request: VerticalSearchRequest): Promise; } +// @public +export interface ServingConfig { + cloudRegion?: CloudRegion; + environment?: Environment; +} + // @public export interface Snippet { matchedSubstrings: { diff --git a/src/constants.ts b/src/constants.ts deleted file mode 100644 index fed7d675..00000000 --- a/src/constants.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Endpoints } from './models/core/Endpoints'; - -export const defaultApiVersion = 20220511; - -export const defaultEndpoints: Required = { - universalSearch: 'https://liveapi.yext.com/v2/accounts/me/search/query', - verticalSearch: 'https://liveapi.yext.com/v2/accounts/me/search/vertical/query', - questionSubmission: 'https://liveapi.yext.com/v2/accounts/me/createQuestion', - status: 'https://answersstatus.pagescdn.com', - universalAutocomplete: 'https://liveapi-cached.yext.com/v2/accounts/me/search/autocomplete', - verticalAutocomplete: 'https://liveapi-cached.yext.com/v2/accounts/me/search/vertical/autocomplete', - filterSearch: 'https://liveapi-cached.yext.com/v2/accounts/me/search/filtersearch', -} as const; - -/** - * The endpoints to use for sandbox experiences. - * - * @public - */ -export const SandboxEndpoints: Required = { - universalSearch: 'https://liveapi-sandbox.yext.com/v2/accounts/me/search/query', - verticalSearch: 'https://liveapi-sandbox.yext.com/v2/accounts/me/search/vertical/query', - questionSubmission: 'https://liveapi-sandbox.yext.com/v2/accounts/me/createQuestion', - status: 'https://answersstatus.pagescdn.com', - universalAutocomplete: 'https://liveapi-sandbox.yext.com/v2/accounts/me/search/autocomplete', - verticalAutocomplete: 'https://liveapi-sandbox.yext.com/v2/accounts/me/search/vertical/autocomplete', - filterSearch: 'https://liveapi-sandbox.yext.com/v2/accounts/me/search/filtersearch', -} as const; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index fcff8109..3c763909 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ // main symbols export { SearchCore } from './SearchCore'; export { provideCore } from './provideCore'; -export { SandboxEndpoints } from './constants'; +export { SandboxEndpoints } from './provideEndpoints'; export * from './models'; export * from './services'; \ No newline at end of file diff --git a/src/infra/AutocompleteServiceImpl.ts b/src/infra/AutocompleteServiceImpl.ts index 6068ebde..5f0669eb 100644 --- a/src/infra/AutocompleteServiceImpl.ts +++ b/src/infra/AutocompleteServiceImpl.ts @@ -5,7 +5,7 @@ import { UniversalAutocompleteRequest } from '../models/autocompleteservice/AutocompleteRequest'; import { AutocompleteResponse, FilterSearchResponse } from '../models/autocompleteservice/AutocompleteResponse'; -import { defaultApiVersion } from '../constants'; +import { defaultApiVersion } from '../provideEndpoints'; import { SearchConfigWithDefaulting } from '../models/core/SearchConfig'; import { HttpService } from '../services/HttpService'; import { AutocompleteQueryParams } from '../models/autocompleteservice/AutocompleteQueryParams'; diff --git a/src/infra/QuestionSubmissionServiceImpl.ts b/src/infra/QuestionSubmissionServiceImpl.ts index 5609da1d..9b63687c 100644 --- a/src/infra/QuestionSubmissionServiceImpl.ts +++ b/src/infra/QuestionSubmissionServiceImpl.ts @@ -1,4 +1,4 @@ -import { defaultApiVersion } from '../constants'; +import { defaultApiVersion } from '../provideEndpoints'; import { QuestionSubmissionService } from '../services/QuestionSubmissionService'; import { HttpService } from '../services/HttpService'; import { SearchConfigWithDefaulting } from '../models/core/SearchConfig'; diff --git a/src/infra/SearchServiceImpl.ts b/src/infra/SearchServiceImpl.ts index 0355e8b7..053cad1f 100644 --- a/src/infra/SearchServiceImpl.ts +++ b/src/infra/SearchServiceImpl.ts @@ -1,6 +1,6 @@ import { createVerticalSearchResponse } from '../transformers/searchservice/createVerticalSearchResponse'; import { SearchService } from '../services/SearchService'; -import { defaultApiVersion } from '../constants'; +import { defaultApiVersion } from '../provideEndpoints'; import { QueryParams } from '../models/http/params'; import { QueryTrigger } from '../models/searchservice/request/QueryTrigger'; import { QuerySource } from '../models/searchservice/request/QuerySource'; diff --git a/src/models/core/CloudRegion.ts b/src/models/core/CloudRegion.ts new file mode 100644 index 00000000..ea36ec02 --- /dev/null +++ b/src/models/core/CloudRegion.ts @@ -0,0 +1,9 @@ +/** + * Defines the cloud region of the API domains. + * + * @public + */ +export enum CloudRegion { + US = 'us', + EU = 'eu', +} \ No newline at end of file diff --git a/src/models/core/Environment.ts b/src/models/core/Environment.ts new file mode 100644 index 00000000..8db28830 --- /dev/null +++ b/src/models/core/Environment.ts @@ -0,0 +1,9 @@ +/** + * Defines the environment of the API domains. + * + * @public + */ +export enum Environment { + PROD = 'prod', + SANDBOX = 'sbx', +} \ No newline at end of file diff --git a/src/models/core/SearchConfig.ts b/src/models/core/SearchConfig.ts index ae6e2178..67e4fea2 100644 --- a/src/models/core/SearchConfig.ts +++ b/src/models/core/SearchConfig.ts @@ -1,11 +1,35 @@ import { Endpoints } from './Endpoints'; import { Visitor } from './Visitor'; +import { Environment } from './Environment'; +import { CloudRegion } from './CloudRegion'; /** - * The base configuration options for {@link SearchCore}. + * The configuration options for getting the endpoints. + * * @public */ -export interface BaseSearchConfig { +export interface ServingConfig { + /** + * {@inheritDoc Environment} + * + * @public + */ + environment?: Environment, + /** + * {@inheritDoc CloudRegion} + * + * @public + */ + cloudRegion?: CloudRegion +} + +/** + * The base configuration options for {@link SearchCore}, which includes the + * options from {@link ServingConfig}. + * + * @public + */ +export interface BaseSearchConfig extends ServingConfig { /** The experience key of the search experience. */ experienceKey: string, /** The locale of the search experience. */ @@ -35,7 +59,19 @@ export interface BaseSearchConfig { */ additionalQueryParams?: { [key: string]: string | number | boolean - } + }, + /** + * {@inheritDoc Environment} + * + * @public + */ + environment?: Environment, + /** + * {@inheritDoc CloudRegion} + * + * @public + */ + cloudRegion?: CloudRegion } /** diff --git a/src/models/index.ts b/src/models/index.ts index 023f7576..2c095d9c 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -3,6 +3,7 @@ export { SearchError } from './searchapi/SearchError'; // Core models export { + ServingConfig, SearchConfig, BaseSearchConfig, SearchConfigWithApiKey, @@ -15,6 +16,8 @@ export { AdditionalHttpHeaders, ClientSDKHeaderValues } from './core/AdditionalHttpHeaders'; +export { Environment } from './core/Environment'; +export { CloudRegion } from './core/CloudRegion'; // Autocomplete service export * from './autocompleteservice/AutocompleteRequest'; diff --git a/src/provideCore.ts b/src/provideCore.ts index be1aac89..d69bec1a 100644 --- a/src/provideCore.ts +++ b/src/provideCore.ts @@ -5,7 +5,7 @@ import { SearchConfig, SearchConfigWithDefaulting } from './models/core/SearchCo import { AutocompleteServiceImpl } from './infra/AutocompleteServiceImpl'; import { ApiResponseValidator } from './validation/ApiResponseValidator'; import { SearchCore } from './SearchCore'; -import { defaultEndpoints } from './constants'; +import { EndpointsFactory } from './provideEndpoints'; /** * The entrypoint to the search-core library. @@ -25,7 +25,7 @@ export function provideCore(config: SearchConfig): SearchCore { const defaultedConfig: SearchConfigWithDefaulting = { ...config, endpoints: { - ...defaultEndpoints, + ...new EndpointsFactory(config).getEndpoints(), ...config.endpoints } }; diff --git a/src/provideEndpoints.ts b/src/provideEndpoints.ts new file mode 100644 index 00000000..7ebc894a --- /dev/null +++ b/src/provideEndpoints.ts @@ -0,0 +1,50 @@ +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 EndpointsFactory { + 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. */ + getDomain() { + return `https://${this.environment}-cdn.${this.cloudRegion}.yextapis.com`; + } + + /** Provides all endpoints based on environment and cloud region. */ + 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 provideCore} with the appropriate {@link ServingConfig} instead + * + * @public + */ +export const SandboxEndpoints: Required = + new EndpointsFactory({ environment: Environment.SANDBOX, cloudRegion: CloudRegion.US }) + .getEndpoints(); diff --git a/tests/infra/AutocompleteServiceImpl.ts b/tests/infra/AutocompleteServiceImpl.ts index 5d2838ee..12b2be08 100644 --- a/tests/infra/AutocompleteServiceImpl.ts +++ b/tests/infra/AutocompleteServiceImpl.ts @@ -11,12 +11,15 @@ import mockAutocompleteResponse from '../fixtures/autocompleteresponse.json'; import mockAutocompleteResponseWithSections from '../fixtures/autocompleteresponsewithsections.json'; import mockAutocompleteResponseWithFailedVerticals from '../fixtures/autocompleteresponsewithfailedverticals.json'; import mockAutocompleteResponseWithVerticalKeys from '../fixtures/autocompleteresponsewithverticalkeys.json'; -import { defaultEndpoints, defaultApiVersion } from '../../src/constants'; +import { defaultApiVersion, EndpointsFactory } from '../../src/provideEndpoints'; import { ApiResponseValidator } from '../../src/validation/ApiResponseValidator'; import { ApiResponse } from '../../src/models/searchapi/ApiResponse'; import { SearchError } from '../../src/models/searchapi/SearchError'; import { getClientSdk } from '../../src/utils/getClientSdk'; import { Matcher } from '../../src/models/searchservice/common/Matcher'; +import { Endpoints } from '../../src/models/core/Endpoints'; + +const defaultEndpoints: Required = new EndpointsFactory().getEndpoints(); describe('AutocompleteService', () => { const config: SearchConfigWithDefaulting = { diff --git a/tests/infra/QuestionSubmissionServiceImpl.ts b/tests/infra/QuestionSubmissionServiceImpl.ts index 87933a2a..f355b9fc 100644 --- a/tests/infra/QuestionSubmissionServiceImpl.ts +++ b/tests/infra/QuestionSubmissionServiceImpl.ts @@ -3,14 +3,14 @@ import { HttpServiceMock } from '../mocks/HttpServiceMock'; import { HttpService } from '../../src/services/HttpService'; import { SearchConfigWithDefaulting } from '../../src/models/core/SearchConfig'; import { ApiResponseValidator } from '../../src/validation/ApiResponseValidator'; -import { defaultApiVersion, defaultEndpoints } from '../../src/constants'; +import { defaultApiVersion, EndpointsFactory } from '../../src/provideEndpoints'; const baseCoreConfig = { apiKey: 'anApiKey', experienceKey: 'anExperienceKey', locale: 'fr', experienceVersion: 'STAGING', - endpoints: defaultEndpoints + endpoints: new EndpointsFactory().getEndpoints() }; const qaRequest = { @@ -42,7 +42,7 @@ describe('Question submission', () => { }); it('uses the production endpoint by default', () => { - const expectedUrl = 'https://liveapi.yext.com/v2/accounts/me/createQuestion'; + const expectedUrl = 'https://prod-cdn.us.yextapis.com/v2/accounts/me/createQuestion'; const actualUrl = actualHttpParams[0]; expect(expectedUrl).toEqual(actualUrl); }); diff --git a/tests/infra/SearchServiceImpl.ts b/tests/infra/SearchServiceImpl.ts index 5460b3eb..8c5181b6 100644 --- a/tests/infra/SearchServiceImpl.ts +++ b/tests/infra/SearchServiceImpl.ts @@ -11,7 +11,10 @@ import { Matcher } from '../../src/models/searchservice/common/Matcher'; import { Direction } from '../../src/models/searchservice/request/Direction'; import { SortType } from '../../src/models/searchservice/request/SortType'; import { getClientSdk } from '../../src/utils/getClientSdk'; -import { defaultApiVersion, defaultEndpoints } from '../../src/constants'; +import { defaultApiVersion, EndpointsFactory } from '../../src/provideEndpoints'; +import { Endpoints } from '../../src/models/core/Endpoints'; + +const defaultEndpoints: Required = new EndpointsFactory().getEndpoints(); describe('SearchService', () => { const configWithRequiredApiKey: SearchConfigWithDefaulting = { @@ -74,7 +77,7 @@ describe('SearchService', () => { }); describe('Universal Search', () => { - const expectedUniversalUrl = 'https://liveapi.yext.com/v2/accounts/me/search/query'; + const expectedUniversalUrl = 'https://prod-cdn.us.yextapis.com/v2/accounts/me/search/query'; it('Query params are correct when only required params (without token) are supplied', async () => { const requestWithRequiredParams: UniversalSearchRequest = { @@ -157,10 +160,7 @@ describe('SearchService', () => { const customUrl = 'http://custom.endpoint.com/api'; const config: SearchConfigWithDefaulting = { ...configWithRequiredApiKey, - endpoints: { - ...defaultEndpoints, - universalSearch: customUrl - } + endpoints: { ...defaultEndpoints, universalSearch: customUrl } }; const searchService: SearchServiceImpl = new SearchServiceImpl( config, @@ -200,7 +200,7 @@ describe('SearchService', () => { }); describe('Vertical Search', () => { - const expectedVerticalUrl = 'https://liveapi.yext.com/v2/accounts/me/search/vertical/query'; + const expectedVerticalUrl = 'https://prod-cdn.us.yextapis.com/v2/accounts/me/search/vertical/query'; it('Query params are correct when only required params (without token) are supplied', async () => { const requestWithRequiredParams: VerticalSearchRequest = { diff --git a/tests/provideCore.ts b/tests/provideCore.ts index 92615fdb..2370d646 100644 --- a/tests/provideCore.ts +++ b/tests/provideCore.ts @@ -1,4 +1,4 @@ -import { SandboxEndpoints } from '../src/constants'; +import { EndpointsFactory } from '../src/provideEndpoints'; import { AutocompleteServiceImpl } from '../src/infra/AutocompleteServiceImpl'; import { QuestionSubmissionServiceImpl } from '../src/infra/QuestionSubmissionServiceImpl'; import { SearchServiceImpl } from '../src/infra/SearchServiceImpl'; @@ -12,7 +12,7 @@ jest.mock('../src/infra/SearchServiceImpl'); it('can specify custom endpoints', () => { const customEndPoints: Required = { - ...SandboxEndpoints, + ...new EndpointsFactory().getEndpoints(), verticalSearch: '' };